From patchwork Thu Oct 19 09:48:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan S X-Patchwork-Id: 10016285 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id CC40D60215 for ; Thu, 19 Oct 2017 09:50:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id AC2C928C6D for ; Thu, 19 Oct 2017 09:50:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A117328CB5; Thu, 19 Oct 2017 09:50:30 +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=-6.5 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, RCVD_IN_DNSWL_HI, RCVD_IN_SORBS_SPAM 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 3778928C6D for ; Thu, 19 Oct 2017 09:50:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752313AbdJSJu3 (ORCPT ); Thu, 19 Oct 2017 05:50:29 -0400 Received: from mail-pf0-f194.google.com ([209.85.192.194]:56203 "EHLO mail-pf0-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752643AbdJSJu2 (ORCPT ); Thu, 19 Oct 2017 05:50:28 -0400 Received: by mail-pf0-f194.google.com with SMTP id 17so6189409pfn.12 for ; Thu, 19 Oct 2017 02:50:27 -0700 (PDT) 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=h23hKI7fYqV7sM9EH7vr4S9NWqbHm+tFqRN/k5ICZ28=; b=GENbOFsBrVciq2Y8apFTEFdUtNux1G77yheb8Y2WsD0kZE/nqQog+DZ/aKV4dI6iG1 pzENSVTqDpDcSoT34WAdO8yya4hueM44vnK1x6/lXuC3yiax8JdHaBdXGRPalK0CFt6t ZjNLy6ho+EElFAhbkiBjokSuqPGP/5uU5f4vM= 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=h23hKI7fYqV7sM9EH7vr4S9NWqbHm+tFqRN/k5ICZ28=; b=HbV5jSWNRJEsPDP4HyGSQ0FnTza2NN13IYf9/Bv8EYKaJfliuQnZbAI+pw++P7yiKU qq6igOsL4YYgpvCstjA6hMs9IcHqrK4EXrctXsea27ZAs1qBKztg6hyDjSxKnCzK1IqY acNf6kOmrgyhbquuYmc/EIdnCWPH0qoWhyLTpiFp4Arn8OgIehwnA1HSGI1mty8yLHDg Dn26QVZMrKEPb/LiJh7cTR0QIaNy0luwqn3kJ5+OXO/hrfy6QjnkI0NqkJV96/J3w2TR TG+Fy1QpXizHWTPUxovxAnSVou5l+Cidavq3B0zv/my3dFv+Zg/9sdqiMmF91iuNy9e6 cZ9g== X-Gm-Message-State: AMCzsaWR9dB8h60UXp8HuBzDDo4CATSiONN9aj+TMKErvJi1ObnjAMvq MaCWq7JwFcYM5+220x+1neUR7g0Y X-Google-Smtp-Source: ABhQp+TmprcWmXZZSFLxdY85HdhLO7tqu9VL2ajnBw7qfpmGVEZXzjWyzuZeybhJhEUnq1/qSBQnBg== X-Received: by 10.98.59.210 with SMTP id w79mr1002841pfj.52.1508406626781; Thu, 19 Oct 2017 02:50:26 -0700 (PDT) Received: from dhcp-135-24-192-142.localdomain ([192.19.239.250]) by smtp.gmail.com with ESMTPSA id e84sm27202885pfd.1.2017.10.19.02.50.24 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 02:50:25 -0700 (PDT) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Shivasharan S Subject: [PATCH 11/19] megaraid_sas: Move initialization of instance parameters inside newly created function megasas_init_ctrl_params Date: Thu, 19 Oct 2017 02:48:58 -0700 Message-Id: <1508406546-25944-12-git-send-email-shivasharan.srikanteshwara@broadcom.com> X-Mailer: git-send-email 2.4.3 In-Reply-To: <1508406546-25944-1-git-send-email-shivasharan.srikanteshwara@broadcom.com> References: <1508406546-25944-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 Code refactoring, no functional change - Create new function to initialize all the controller parameters during load time. Signed-off-by: Kashyap Desai Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas_base.c | 119 +++++++++++++++--------------- 1 file changed, 61 insertions(+), 58 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 2a68c75b7c4e..86cceb48ba84 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -6225,6 +6225,59 @@ void megasas_free_ctrl_dma_buffers(struct megasas_instance *instance) instance->crash_dump_h); } +/* + * megasas_init_ctrl_params - Initialize controller's instance + * parameters before FW init + * @instance - Adapter soft instance + * @return - void + */ +static inline void megasas_init_ctrl_params(struct megasas_instance *instance) +{ + instance->fw_crash_state = UNAVAILABLE; + + megasas_poll_wait_aen = 0; + instance->issuepend_done = 1; + atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); + + /* + * Initialize locks and queues + */ + INIT_LIST_HEAD(&instance->cmd_pool); + INIT_LIST_HEAD(&instance->internal_reset_pending_q); + + atomic_set(&instance->fw_outstanding, 0); + + init_waitqueue_head(&instance->int_cmd_wait_q); + init_waitqueue_head(&instance->abort_cmd_wait_q); + + spin_lock_init(&instance->crashdump_lock); + spin_lock_init(&instance->mfi_pool_lock); + spin_lock_init(&instance->hba_lock); + spin_lock_init(&instance->stream_lock); + spin_lock_init(&instance->completion_lock); + + mutex_init(&instance->hba_mutex); + mutex_init(&instance->reset_mutex); + + if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || + (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) + instance->flag_ieee = 1; + + megasas_dbg_lvl = 0; + instance->flag = 0; + instance->unload = 1; + instance->last_time = 0; + instance->disableOnlineCtrlReset = 1; + instance->UnevenSpanSupport = 0; + + if (instance->adapter_type != MFI_SERIES) { + INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); + INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq); + } else { + INIT_WORK(&instance->work_init, process_fw_state_change_wq); + } +} + /** * megasas_probe_one - PCI hotplug entry point * @pdev: PCI device structure @@ -6279,74 +6332,24 @@ static int megasas_probe_one(struct pci_dev *pdev, instance = (struct megasas_instance *)host->hostdata; memset(instance, 0, sizeof(*instance)); atomic_set(&instance->fw_reset_no_pci_access, 0); - instance->pdev = pdev; - - megasas_set_adapter_type(instance); - - if (megasas_alloc_ctrl_mem(instance)) - goto fail_alloc_dma_buf; - - if (megasas_alloc_ctrl_dma_buffers(instance)) - goto fail_alloc_dma_buf; - - /* Crash dump feature related initialisation*/ - instance->drv_buf_index = 0; - instance->drv_buf_alloc = 0; - instance->crash_dump_fw_support = 0; - instance->crash_dump_app_support = 0; - instance->fw_crash_state = UNAVAILABLE; - spin_lock_init(&instance->crashdump_lock); - instance->crash_dump_buf = NULL; - - megasas_poll_wait_aen = 0; - instance->flag_ieee = 0; - instance->ev = NULL; - instance->issuepend_done = 1; - atomic_set(&instance->adprecovery, MEGASAS_HBA_OPERATIONAL); - instance->is_imr = 0; - - /* - * Initialize locks and queues - */ - INIT_LIST_HEAD(&instance->cmd_pool); - INIT_LIST_HEAD(&instance->internal_reset_pending_q); - - atomic_set(&instance->fw_outstanding,0); - - init_waitqueue_head(&instance->int_cmd_wait_q); - init_waitqueue_head(&instance->abort_cmd_wait_q); - - spin_lock_init(&instance->mfi_pool_lock); - spin_lock_init(&instance->hba_lock); - spin_lock_init(&instance->stream_lock); - spin_lock_init(&instance->completion_lock); - - mutex_init(&instance->reset_mutex); - mutex_init(&instance->hba_mutex); /* * Initialize PCI related and misc parameters */ + instance->pdev = pdev; instance->host = host; instance->unique_id = pdev->bus->number << 8 | pdev->devfn; instance->init_id = MEGASAS_DEFAULT_INIT_ID; - if ((instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0073SKINNY) || - (instance->pdev->device == PCI_DEVICE_ID_LSI_SAS0071SKINNY)) - instance->flag_ieee = 1; + megasas_set_adapter_type(instance); - megasas_dbg_lvl = 0; - instance->flag = 0; - instance->unload = 1; - instance->last_time = 0; - instance->disableOnlineCtrlReset = 1; - instance->UnevenSpanSupport = 0; + megasas_init_ctrl_params(instance); - if (instance->adapter_type != MFI_SERIES) { - INIT_WORK(&instance->work_init, megasas_fusion_ocr_wq); - INIT_WORK(&instance->crash_init, megasas_fusion_crash_dump_wq); - } else - INIT_WORK(&instance->work_init, process_fw_state_change_wq); + if (megasas_alloc_ctrl_mem(instance)) + goto fail_alloc_dma_buf; + + if (megasas_alloc_ctrl_dma_buffers(instance)) + goto fail_alloc_dma_buf; /* * Initialize MFI Firmware