From patchwork Fri Jan 18 17:11:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10771259 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 615A81580 for ; Fri, 18 Jan 2019 17:12:03 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E82E300E7 for ; Fri, 18 Jan 2019 17:12:03 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 429E330143; Fri, 18 Jan 2019 17:12:03 +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 D46DE3011A for ; Fri, 18 Jan 2019 17:12:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728467AbfARRMC (ORCPT ); Fri, 18 Jan 2019 12:12:02 -0500 Received: from mail-ed1-f67.google.com ([209.85.208.67]:32846 "EHLO mail-ed1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727986AbfARRMC (ORCPT ); Fri, 18 Jan 2019 12:12:02 -0500 Received: by mail-ed1-f67.google.com with SMTP id p6so11749494eds.0 for ; Fri, 18 Jan 2019 09:12:01 -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=rc+IxcW4JzmJMU8HfN18uHVpghQV3fjwIvd3SPJLJ4w=; b=D+SkigG0zsoivqIYgpZ6A5WMV2+ulwj5WzCOY5CW+f3Kf8KHtXxOpko2gSWc14paYq 8U+qsMreZp5JDxfYDwfpvQLkTHQbwkpxZWLptwICnWRQhHbXxvCU9aRSZwR3YnJ8zF+I KeWSD6TsYcZltJu/fFpFG/T9GJd7XyVw5HzCY= 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=rc+IxcW4JzmJMU8HfN18uHVpghQV3fjwIvd3SPJLJ4w=; b=tWHdNz2bmDsX69U/BTlYjs8nDxFHiBYHRzdys7UXI8Clj4IiIa2fecalfrTzS/P0Gv 7qbO5WPM440GOWokmWy3Oy770rFodnr1yDw+ddMTp0AvgSVlJr1te7MJJ9utfsLzLdD4 SzpDtq2XDdTePvelp7ugGQQVuLgkQuS/O94gUf31VoOBNsnn+K3gUD7QW8zDfAhS5jHI JE4SULeESooeAzt2oUBX87ouzrlMUA5Q/lfeShn6kWJ4hDL46JXT4x0ZcTwzSs/WdxM6 /zVfS/GvkMW/6/PSjXRQ6Mw6RG8TKjs2rUa3qu5oI3weOhlMnLjpnHr+0InFYW4GMJgv ehUw== X-Gm-Message-State: AJcUukcuwCCGHXRl78V9wAyaOK9H+B4uXh4ng8GuCy4z2PfBSSeO03Kb 8HIN9spEnn8T35R4fXDmWsXatPSyDHrccHfC11purVSxgQCsLtYLC3LHr5uGKBCc+ZZxSDU4BnY 6kPhKq+GMxXZ2phAsUpjwersnCdq9VwaWiHZLEHr3dGeILjbrfaUJxJJmegVLTa83NL/az8Ba6e mKuVB3b5UP9xxQquknQa3I X-Google-Smtp-Source: ALg8bN7hR4o9TdrEdN86yuB24f+PU7KaQub0iDDTl9/GvG+fBQGwayw0HqyEHcFxV2JaGlYwNwi9LA== X-Received: by 2002:a17:906:f252:: with SMTP id gy18-v6mr15563007ejb.37.1547831519855; Fri, 18 Jan 2019 09:11:59 -0800 (PST) Received: from dhcp-135-24-192-142.dhcp.broadcom.net ([192.19.252.250]) by smtp.gmail.com with ESMTPSA id f31sm7581511eda.16.2019.01.18.09.11.55 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 18 Jan 2019 09:11:59 -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 1/3] megaraid_sas: Rework code to get PD and LD list Date: Fri, 18 Jan 2019 09:11:38 -0800 Message-Id: <1547831500-26751-2-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1547831500-26751-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1547831500-26751-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..c16f8533c8a8 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.