From patchwork Thu Jan 24 10:19:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10778651 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D55B41850 for ; Thu, 24 Jan 2019 10:19:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C5C7F2E530 for ; Thu, 24 Jan 2019 10:19:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BA0A92E59E; Thu, 24 Jan 2019 10:19:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5D87F2E530 for ; Thu, 24 Jan 2019 10:19:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726378AbfAXKTs (ORCPT ); Thu, 24 Jan 2019 05:19:48 -0500 Received: from mail-yw1-f67.google.com ([209.85.161.67]:39935 "EHLO mail-yw1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727183AbfAXKTr (ORCPT ); Thu, 24 Jan 2019 05:19:47 -0500 Received: by mail-yw1-f67.google.com with SMTP id k188so2188904ywa.6 for ; Thu, 24 Jan 2019 02:19:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=k3Q4sT16+jXkJuo/Ms1uN+Tb0xLQlQl8nEMZVnvxkI4=; b=ShnWGNn3gUfH7ir/uFmtke/2crhDSrdwwx7YXhCI3KLsEd+I4F5z7HZ73aw151bwd5 xT0H+/XuqWlcOjp2dHxEi4PsdJpCOXQSkPY6JqpNFC3l2LhLj2pjxiW9Ne22OhBmVLpa ju0muuiRTYdeHKGLzgcyO+eU3K4M4ridUST2E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=k3Q4sT16+jXkJuo/Ms1uN+Tb0xLQlQl8nEMZVnvxkI4=; b=WhjC1Uy4dPytEC2kW+62TmAB29juAXZqJuLzTgKgjWKibyAg/EqXatJWoQ0iW2y1bM HwV1RdhL7/Yx2A73IMMmfYTXRQSC2SOhwz5jxsfsZk6d5PofXegzRkIiUOCpmenz282M jFG3vkoFiS96u0rsu/93gMtHrc+/kH/ZzvOlnekwty6AVC7AGZ2PUw/U0co657KVMSJV qJD8WmItgxx82HQvfPu/Gu9bM0HOSa3+2TpUA6jAJ9iz/ZAQoL1JoI8cthw8WRUsqPnJ lx1guGStJxYWo7b8ZoKR/mzxzUptyT0Vbi2tpl2sobxLQAE/uZxB3+eCNLkT1EvOImqE Kpxw== X-Gm-Message-State: AJcUukdSu5HHGYFVvPzbF7zQjBtGx7ePnKvd4oy+goARBUrUPudkI47R CctgthV15YrAKrTrB1AIvO7FZ906k/lDxH/mnf76M37YqpY8n7/IMg34ERRJGkKvCimckatXhFY m8uotptCOpCxFnTDF6KpBFxNm4GQutp61gcfixp4cgbwsApKcEFa4ZCyOzWsYrpKbVC/ltv0yT9 W8IVQXNyqo4RcSaQRoALXX X-Google-Smtp-Source: ALg8bN55aNbgx6DckeNmEVTiXQz13NzVjps6Meo46M3UkJKbYrvtYAgQcbKm4krl1v46sEpPXRnZ8g== X-Received: by 2002:a81:3d3:: with SMTP id 202mr5612016ywd.18.1548325186026; Thu, 24 Jan 2019 02:19:46 -0800 (PST) Received: from dhcp-135-24-192-142.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id e3sm9838956ywe.63.2019.01.24.02.19.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 24 Jan 2019 02:19:45 -0800 (PST) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, kiran-kumar.kasturi@broadcom.com, sankar.patra@broadcom.com, sasikumar.pc@broadcom.com, Shivasharan S Subject: [PATCH V2 1/3] megaraid_sas: Rework code to get PD and LD list Date: Thu, 24 Jan 2019 02:19:28 -0800 Message-Id: <1548325170-1171-2-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1548325170-1171-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1548325170-1171-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> Sender: linux-scsi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP During FW init, combine the code to get the PD and LD list from FW into a single function. This patch is in preparation for adding support for HOST_DEVICE_LIST DCMD. Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas_base.c | 47 ++++++++++++++++++++++--------- 1 file changed, 34 insertions(+), 13 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index f7bdd783360a..cf065f0b84fa 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -5319,6 +5319,36 @@ static void megasas_setup_reply_map(struct megasas_instance *instance) instance->reply_map[cpu] = cpu % instance->msix_vectors; } +/* + * megasas_get_device_list - Get the PD and LD device list from FW. + * @instance: Adapter soft state + * + * @return: Success or failure + * + * Issue DCMDs to Firmware to update the internal device list in driver. + * Based on the FW support, driver sends the HOST_DEVICE_LIST or combination + * of PD_LIST/LD_LIST_QUERY DCMDs to get the device list. + */ +static +int megasas_get_device_list(struct megasas_instance *instance) +{ + memset(instance->pd_list, 0, + (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list))); + memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); + + if (megasas_get_pd_list(instance) < 0) { + dev_err(&instance->pdev->dev, "failed to get PD list\n"); + return FAILED; + } + + if (megasas_ld_list_query(instance, + MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) { + dev_err(&instance->pdev->dev, "failed to get LD list\n"); + return FAILED; + } + + return SUCCESS; +} /** * megasas_init_fw - Initializes the FW * @instance: Adapter soft state @@ -5571,18 +5601,13 @@ static int megasas_init_fw(struct megasas_instance *instance) megasas_setup_jbod_map(instance); - /** for passthrough - * the following function will get the PD LIST. - */ - memset(instance->pd_list, 0, - (MEGASAS_MAX_PD * sizeof(struct megasas_pd_list))); - if (megasas_get_pd_list(instance) < 0) { - dev_err(&instance->pdev->dev, "failed to get PD list\n"); + if (megasas_get_device_list(instance) != SUCCESS) { + dev_err(&instance->pdev->dev, + "%s: megasas_get_device_list failed\n", + __func__); goto fail_get_ld_pd_list; } - memset(instance->ld_ids, 0xff, MEGASAS_MAX_LD_IDS); - /* stream detection initialization */ if (instance->adapter_type >= VENTURA_SERIES) { fusion->stream_detect_by_ld = @@ -5612,10 +5637,6 @@ static int megasas_init_fw(struct megasas_instance *instance) } } - if (megasas_ld_list_query(instance, - MR_LD_QUERY_TYPE_EXPOSED_TO_HOST)) - goto fail_get_ld_pd_list; - /* * Compute the max allowed sectors per IO: The controller info has two * limits on max sectors. Driver should use the minimum of these two.