From patchwork Mon Dec 20 14:11:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 526248 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2FCCC433FE for ; Mon, 20 Dec 2021 14:04:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233451AbhLTOEl (ORCPT ); Mon, 20 Dec 2021 09:04:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51710 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229612AbhLTOEg (ORCPT ); Mon, 20 Dec 2021 09:04:36 -0500 Received: from mail-pg1-x52b.google.com (mail-pg1-x52b.google.com [IPv6:2607:f8b0:4864:20::52b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9DF39C061401 for ; Mon, 20 Dec 2021 06:04:36 -0800 (PST) Received: by mail-pg1-x52b.google.com with SMTP id v25so4401405pge.2 for ; Mon, 20 Dec 2021 06:04:36 -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 :mime-version; bh=YSud9AYv114NQxl501NNFTjwP/ugNnXMRXF2t3ZBqlM=; b=M+otdVNxtoneHKFhae3t85l40U1sd88K9A/6TE9vgUg5jcdCpJ/5G2IxTVIdAs4DXI uup9oi4cRE8RyLV5xSNscDnDLCfZiG8JM4ky+vSFghRWkr20FZpZMsclaJCXdzBJ5OkG q+vwHxBWvjs8ktBlPVJdBiuY4u7/2KZuVptJk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version; bh=YSud9AYv114NQxl501NNFTjwP/ugNnXMRXF2t3ZBqlM=; b=Nf39OVEo0F3YqRgdGsfl0b2Idao+glI7WiK7hqgszDQ8x9zOfkB1zPDjdg7+jkdtug SdtI9DPbpD8vKZMtq+J9rt4jwNDvufiDiz0ukd2APdBQl9QKmYMfacjwHqA4Xh5qw5a3 Lr1Gj08hvJJ6WbpU7pfQx2HwQJ0RDHKUbN1X3N+T04qEXAFo09aD/b7SB3BdQDC7fTGo HY/yxgR6xhc2j4PqVFalFAvmtBKy+mtotuQ73DoBqvv5oQcXgURKeK6yRrf3Cb2xW4QE D0bmRGLwkowZtHhCuUpszqY+TEbQ9VfIEkIu6zBN3RN//Y1VJ844j1c82LwCrcrlFPeS DKTA== X-Gm-Message-State: AOAM533YwIS198iesPW1c1eRWu3UbOQkyDVf7DnsiEatdS9Yfj6cePwq POd+JBFxXSaDVuDZK3wHPK5TZEOpvxViReZHn+Ymk9zVRzld32dTSSQWW4JCAzUsjdTbX21i9UH wfWpFfoRTwgUl1NR1YUTarWewHWFkXZbcJpI/+Sw1kINCANsCvJ6DUgF7Wrt92OH3NWi/KW4PhA iC2yxvQQj2 X-Google-Smtp-Source: ABdhPJwVrsyenEP9uaHg47/Phel3IyQOy9J37qFVlvV2Fh95aeTeLMwzfyWSoGZssDDXKvO6k0AkmA== X-Received: by 2002:a63:9854:: with SMTP id l20mr15100734pgo.536.1640009075115; Mon, 20 Dec 2021 06:04:35 -0800 (PST) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id b4sm5434180pjm.17.2021.12.20.06.04.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 20 Dec 2021 06:04:34 -0800 (PST) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, mpi3mr-linuxdrv.pdl@broadcom.com, Sreekanth Reddy Subject: [PATCH 15/25] mpi3mr: Add IOC reinit function Date: Mon, 20 Dec 2021 19:41:49 +0530 Message-Id: <20211220141159.16117-16-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> References: <20211220141159.16117-1-sreekanth.reddy@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Adding IOC reinitialization function. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr_fw.c | 116 +++++++++++++++++++++++++++++++- 1 file changed, 115 insertions(+), 1 deletion(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index bad708a..a7cd02f 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -3568,10 +3568,124 @@ out_failed_noretry: return retval; } +/** + * mpi3mr_reinit_ioc - Re-Initialize the controller + * @mrioc: Adapter instance reference + * @is_resume: Called from resume or reset path + * + * This the controller re-initialization routine, executed from + * the soft reset handler or resume callback. creates + * operational reply queue pairs, allocate required memory for + * reply pool, sense buffer pool, issue IOC init request to the + * firmware, unmask the events and issue port enable to discover + * SAS/SATA/NVMe devices and RAID volumes. + * + * Return: 0 on success and non-zero on failure. + */ int mpi3mr_reinit_ioc(struct mpi3mr_ioc *mrioc, u8 is_resume) { + int retval = 0; + u8 retry = 0; + struct mpi3_ioc_facts_data facts_data; - return 0; +retry_init: + dprint_reset(mrioc, "bringing up the controller to ready state\n"); + retval = mpi3mr_bring_ioc_ready(mrioc); + if (retval) { + ioc_err(mrioc, "failed to bring to ready state\n"); + goto out_failed_noretry; + } + + if (is_resume) { + dprint_reset(mrioc, "setting up single ISR\n"); + retval = mpi3mr_setup_isr(mrioc, 1); + if (retval) { + ioc_err(mrioc, "failed to setup ISR\n"); + goto out_failed_noretry; + } + } else + mpi3mr_ioc_enable_intr(mrioc); + + dprint_reset(mrioc, "getting ioc_facts\n"); + retval = mpi3mr_issue_iocfacts(mrioc, &facts_data); + if (retval) { + ioc_err(mrioc, "failed to get ioc_facts\n"); + goto out_failed; + } + + mpi3mr_process_factsdata(mrioc, &facts_data); + + mpi3mr_print_ioc_info(mrioc); + + dprint_reset(mrioc, "sending ioc_init\n"); + retval = mpi3mr_issue_iocinit(mrioc); + if (retval) { + ioc_err(mrioc, "failed to send ioc_init\n"); + goto out_failed; + } + + dprint_reset(mrioc, "getting package version\n"); + retval = mpi3mr_print_pkg_ver(mrioc); + if (retval) { + ioc_err(mrioc, "failed to get package version\n"); + goto out_failed; + } + + if (is_resume) { + dprint_reset(mrioc, "setting up multiple ISR\n"); + retval = mpi3mr_setup_isr(mrioc, 0); + if (retval) { + ioc_err(mrioc, "failed to re-setup ISR\n"); + goto out_failed_noretry; + } + } + + dprint_reset(mrioc, "creating operational queue pairs\n"); + retval = mpi3mr_create_op_queues(mrioc); + if (retval) { + ioc_err(mrioc, "failed to create operational queue pairs\n"); + goto out_failed; + } + + if (mrioc->shost->nr_hw_queues > mrioc->num_op_reply_q) { + ioc_err(mrioc, + "cannot create minimum number of operatioanl queues expected:%d created:%d\n", + mrioc->shost->nr_hw_queues, mrioc->num_op_reply_q); + goto out_failed_noretry; + } + + dprint_reset(mrioc, "enabling events\n"); + retval = mpi3mr_enable_events(mrioc); + if (retval) { + ioc_err(mrioc, "failed to enable events\n"); + goto out_failed; + } + + ioc_info(mrioc, "sending port enable\n"); + retval = mpi3mr_issue_port_enable(mrioc, 0); + if (retval) { + ioc_err(mrioc, "failed to issue port enable\n"); + goto out_failed; + } + + ioc_info(mrioc, "controller %s completed successfully\n", + (is_resume)?"resume":"re-initialization"); + return retval; +out_failed: + if (retry < 2) { + retry++; + ioc_warn(mrioc, "retrying controller %s, retry_count:%d\n", + (is_resume)?"resume":"re-initialization", retry); + mpi3mr_memset_buffers(mrioc); + goto retry_init; + } +out_failed_noretry: + ioc_err(mrioc, "controller %s is failed\n", + (is_resume)?"resume":"re-initialization"); + mpi3mr_issue_reset(mrioc, MPI3_SYSIF_HOST_DIAG_RESET_ACTION_DIAG_FAULT, + MPI3MR_RESET_FROM_CTLR_CLEANUP); + mrioc->unrecoverable = 1; + return retval; } /**