From patchwork Thu Oct 19 09:48:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shivasharan Srikanteshwara X-Patchwork-Id: 10016287 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 9D96B60215 for ; Thu, 19 Oct 2017 09:50:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7D51828BD0 for ; Thu, 19 Oct 2017 09:50:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 71FFD28CB4; Thu, 19 Oct 2017 09:50:32 +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 1C0B028BD0 for ; Thu, 19 Oct 2017 09:50:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752647AbdJSJub (ORCPT ); Thu, 19 Oct 2017 05:50:31 -0400 Received: from mail-pf0-f195.google.com ([209.85.192.195]:43102 "EHLO mail-pf0-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752626AbdJSJua (ORCPT ); Thu, 19 Oct 2017 05:50:30 -0400 Received: by mail-pf0-f195.google.com with SMTP id a8so6201243pfc.0 for ; Thu, 19 Oct 2017 02:50:30 -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=5RfGxcL/Zc8R/G3MXJuXEbVQfXL0XRC2KI3I+rlw2XU=; b=L2FKD+Jo2WzmvGaPIUKpY3NFMHqp3ISiHbWe2STtL4PzwSJFK8vLE0vBA0A2JrOQTb tewuoLF0euDVMnUC9kEm+cAudq/2QGT5/QwTHmhmPN9INjW7aeeEvuYeL/IdpJIx8DE9 3iTuinJ7LqwqM18jR3Fb28CGnJW07vjVLIFn4= 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=5RfGxcL/Zc8R/G3MXJuXEbVQfXL0XRC2KI3I+rlw2XU=; b=luyUl5I1yReJOGZWwvbzHnoipXTY8pcfUovoyP+1jI9Pmdq4RMY/SiRPtOr6twoLUw JtTiSM4XjVAUTI9Qj6zavU4MKpqv1DTrRiN4KrqxieN2+SkoTsaFz+l8TbhOtjBKPx5z FkfZt0J+TWyiZoThwTkB6HDWq9MaLi5rhL0CbO/ThJNNX4hyu6Wq0dfXCUOALSTI21O4 on9CI9q5rPEjj3NCrh4LKyAEhHCXEdkpZ2RcXosnRB/M8HWhXHl/P+v4KH7adnNA+PJp LPG721SOwKQbazb4JijdEjfD10lUPZDLCyYUvu7IiE/3f03UQtVJU8FxKdY1s4bH+LNe ZtgQ== X-Gm-Message-State: AMCzsaWlBRM/W1OFtgXSMPXIHV4GcmHtT5dKhLtmdIg9jtoWzfGtIBYq Xs7pBd9UtxGMC4l25o7By7v1x4Rc X-Google-Smtp-Source: ABhQp+TKtst0P4HbZ1oaVoMWX+Mp1lRriPobe9n4tzo+107JUGS0nDk1NlHgJ0yCE5kMonE1Zg1/kw== X-Received: by 10.159.195.73 with SMTP id z9mr1098328pln.346.1508406629432; Thu, 19 Oct 2017 02:50:29 -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.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 19 Oct 2017 02:50:28 -0700 (PDT) From: Shivasharan S To: linux-scsi@vger.kernel.org Cc: kashyap.desai@broadcom.com, sumit.saxena@broadcom.com, Shivasharan S Subject: [PATCH 12/19] megaraid_sas: Move controller memory allocations and DMA mask settings from probe to megasas_init_fw Date: Thu, 19 Oct 2017 02:48:59 -0700 Message-Id: <1508406546-25944-13-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 Signed-off-by: Kashyap Desai Signed-off-by: Shivasharan S --- drivers/scsi/megaraid/megaraid_sas_base.c | 43 ++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 15 deletions(-) diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index 86cceb48ba84..3a179c3fabc0 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c @@ -206,6 +206,18 @@ wait_and_poll(struct megasas_instance *instance, struct megasas_cmd *cmd, void megasas_fusion_ocr_wq(struct work_struct *work); static int megasas_get_ld_vf_affiliation(struct megasas_instance *instance, int initial); +static int +megasas_set_dma_mask(struct pci_dev *pdev); +static int +megasas_alloc_ctrl_mem(struct megasas_instance *instance); +static inline void +megasas_free_ctrl_mem(struct megasas_instance *instance); +static inline int +megasas_alloc_ctrl_dma_buffers(struct megasas_instance *instance); +static inline void +megasas_free_ctrl_dma_buffers(struct megasas_instance *instance); +static inline void +megasas_init_ctrl_params(struct megasas_instance *instance); void megasas_issue_dcmd(struct megasas_instance *instance, struct megasas_cmd *cmd) @@ -5179,6 +5191,19 @@ static int megasas_init_fw(struct megasas_instance *instance) goto fail_ready_state; } + megasas_init_ctrl_params(instance); + + if (megasas_set_dma_mask(instance->pdev)) + goto fail_ready_state; + + if (megasas_alloc_ctrl_mem(instance)) + goto fail_alloc_dma_buf; + + if (megasas_alloc_ctrl_dma_buffers(instance)) + goto fail_alloc_dma_buf; + + fusion = instance->ctrl_context; + if (instance->adapter_type == VENTURA_SERIES) { scratch_pad_3 = readl(&instance->reg_set->outbound_scratch_pad_3); @@ -5475,6 +5500,9 @@ static int megasas_init_fw(struct megasas_instance *instance) if (instance->msix_vectors) pci_free_irq_vectors(instance->pdev); instance->msix_vectors = 0; +fail_alloc_dma_buf: + megasas_free_ctrl_dma_buffers(instance); + megasas_free_ctrl_mem(instance); fail_ready_state: iounmap(instance->reg_set); @@ -6318,9 +6346,6 @@ static int megasas_probe_one(struct pci_dev *pdev, pci_set_master(pdev); - if (megasas_set_dma_mask(pdev)) - goto fail_set_dma_mask; - host = scsi_host_alloc(&megasas_template, sizeof(struct megasas_instance)); @@ -6343,14 +6368,6 @@ static int megasas_probe_one(struct pci_dev *pdev, megasas_set_adapter_type(instance); - megasas_init_ctrl_params(instance); - - 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 */ @@ -6432,13 +6449,9 @@ static int megasas_probe_one(struct pci_dev *pdev, if (instance->msix_vectors) pci_free_irq_vectors(instance->pdev); fail_init_mfi: -fail_alloc_dma_buf: - megasas_free_ctrl_dma_buffers(instance); - megasas_free_ctrl_mem(instance); scsi_host_put(host); fail_alloc_instance: -fail_set_dma_mask: pci_disable_device(pdev); return -ENODEV;