From patchwork Wed Dec 6 15:25:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13481947 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="Ex4wA3UJ" Received: from mail-pl1-x62a.google.com (mail-pl1-x62a.google.com [IPv6:2607:f8b0:4864:20::62a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B8EF3DE for ; Wed, 6 Dec 2023 07:27:11 -0800 (PST) Received: by mail-pl1-x62a.google.com with SMTP id d9443c01a7336-1d0ccda19eeso12720615ad.1 for ; Wed, 06 Dec 2023 07:27:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1701876430; x=1702481230; darn=vger.kernel.org; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date:message-id:reply-to; bh=lsbMtaCHeDpWRSYvsY+iHmFytTvYqXWxBqixrjfiSGo=; b=Ex4wA3UJzx/9GCxaZmrXteYy7GmeuoVx02lu0v+wO/FWmUZvJcTCR7y9Uzc+uD0BRq 6btnHcDqToGEvNGR+Gvaop/mOmxE7dfiFimPtkIgTffflBPphhuqgw/XgEszkQwZonG9 gaVVem9/gGKuPQRqx8MUmAw4kFVa5aCI795OQ= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701876430; x=1702481230; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lsbMtaCHeDpWRSYvsY+iHmFytTvYqXWxBqixrjfiSGo=; b=cmmSZtznpAbW50l4urWqOVrBOZjGsrB/xhj5BhkrORXu+JyAEluGxchkXeklpoXD09 8mChQ7+/XabP9j28Q+EvpOcaAnwU5yNxUAVgS2QSJ8u8LHmewxS3ho9jTpAnJ4vvZwGk Lruk5WetL8Uvo6zx7iF5L7bJkpRx+PASSvHXZes7pIgm8F5ybWOFRatG+/RoceznQFvO S/nYE9PMhsYcbvYSygrTCKaH+eOIp67bkjQm1y5+vKDDaQ+MaZ0+9hpJNMf5q0/Vh3MV +wbx3xM/A7gH37IQ80I0hR972YPZH1i9a2GSNvQVbVoqAe5lhYr+4hUDfgFqLB26BjMM e2Tg== X-Gm-Message-State: AOJu0YwH64K9NX1jlC9KB6QWvSu6CpGKseI5sxLjuYG6/3thdpeAxGSm R7FUqWne1owHsHy+V+I7kCg4HVQhuqENNW4NrQQCpGjRCzAErutHp3Y8e2dabO0fjCaDCwnY6HM C+j1W80Ea7e7HC1q/qIkZE+8eQDatagxOpZE9sC9of+nZ3XDyTMXij63xtcuCB8KIKLxXkMNgCi YXTQBw6mITMQ== X-Google-Smtp-Source: AGHT+IGaQ1jGEFMr3PsijV2jO4vNH1rR0DaY8/mcPIkDOZ9AthYKIzR6TarpvcmrqMrlNjtLxFDVkg== X-Received: by 2002:a17:902:7d8a:b0:1d0:d04a:7bfa with SMTP id a10-20020a1709027d8a00b001d0d04a7bfamr815248plm.90.1701876430233; Wed, 06 Dec 2023 07:27:10 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id w17-20020a170902e89100b001cfc2e0a82fsm12182553plg.26.2023.12.06.07.27.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 07:27:08 -0800 (PST) From: Ranjan Kumar To: linux-scsi@vger.kernel.org, martin.petersen@oracle.com Cc: rajsekhar.chundru@broadcom.com, sathya.prakash@broadcom.com, sumit.saxena@broadcom.com, chandrakanth.patil@broadcom.com, prayas.patel@broadcom.com, Ranjan Kumar Subject: [PATCH v1 1/4] mpi3mr: Improve Shutdown times when firmware has faulted Date: Wed, 6 Dec 2023 20:55:10 +0530 Message-Id: <20231206152513.71253-2-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231206152513.71253-1-ranjan.kumar@broadcom.com> References: <20231206152513.71253-1-ranjan.kumar@broadcom.com> Precedence: bulk X-Mailing-List: linux-scsi@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 The driver monitors the controller state periodically while waiting for the shutdown notification MPI request to complete. If the firmware is faulty, the driver resets the controller and re-issues the shutdown notification. The driver will make three attempts to complete the shutdown process and will not retry the notification request if the controller reset is unsuccessful. Signed-off-by: Prayas Patel Signed-off-by: Ranjan Kumar --- drivers/scsi/mpi3mr/mpi3mr.h | 1 + drivers/scsi/mpi3mr/mpi3mr_fw.c | 36 +++++++++++++++++++++++++-------- 2 files changed, 29 insertions(+), 8 deletions(-) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 3de1ee05c44e..e44e262748ea 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -158,6 +158,7 @@ extern atomic64_t event_counter; /* Controller Reset related definitions */ #define MPI3MR_HOSTDIAG_UNLOCK_RETRY_COUNT 5 #define MPI3MR_MAX_RESET_RETRY_COUNT 3 +#define MPI3MR_MAX_SHUTDOWN_RETRY_COUNT 2 /* ResponseCode definitions */ #define MPI3MR_RI_MASK_RESPCODE (0x000000FF) diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index d8c57a0a518f..9e4a075fd7f0 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -4555,9 +4555,10 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) */ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) { - u32 ioc_config, ioc_status; - u8 retval = 1; + u32 ioc_config, ioc_status, shutdown_action; + u8 retval = 1, retry = 0; u32 timeout = MPI3MR_DEFAULT_SHUTDOWN_TIME * 10; + u32 timeout_remaining = 0; ioc_info(mrioc, "Issuing shutdown Notification\n"); if (mrioc->unrecoverable) { @@ -4572,15 +4573,16 @@ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) return; } + shutdown_action = MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL | + MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ; ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); - ioc_config |= MPI3_SYSIF_IOC_CONFIG_SHUTDOWN_NORMAL; - ioc_config |= MPI3_SYSIF_IOC_CONFIG_DEVICE_SHUTDOWN_SEND_REQ; + ioc_config |= shutdown_action; writel(ioc_config, &mrioc->sysif_regs->ioc_configuration); if (mrioc->facts.shutdown_timeout) timeout = mrioc->facts.shutdown_timeout * 10; - + timeout_remaining = timeout; do { ioc_status = readl(&mrioc->sysif_regs->ioc_status); if ((ioc_status & MPI3_SYSIF_IOC_STATUS_SHUTDOWN_MASK) @@ -4588,8 +4590,26 @@ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) retval = 0; break; } + if (mrioc->unrecoverable) + break; + if (ioc_status & MPI3_SYSIF_IOC_STATUS_FAULT) { + mpi3mr_print_fault_info(mrioc); + if (retry >= MPI3MR_MAX_SHUTDOWN_RETRY_COUNT) + break; + if (mpi3mr_issue_reset(mrioc, + MPI3_SYSIF_HOST_DIAG_RESET_ACTION_SOFT_RESET, + MPI3MR_RESET_FROM_CTLR_CLEANUP)) + break; + ioc_config = + readl(&mrioc->sysif_regs->ioc_configuration); + ioc_config |= shutdown_action; + writel(ioc_config, + &mrioc->sysif_regs->ioc_configuration); + timeout_remaining = timeout; + retry++; + } msleep(100); - } while (--timeout); + } while (--timeout_remaining); ioc_status = readl(&mrioc->sysif_regs->ioc_status); ioc_config = readl(&mrioc->sysif_regs->ioc_configuration); @@ -4598,11 +4618,11 @@ static void mpi3mr_issue_ioc_shutdown(struct mpi3mr_ioc *mrioc) if ((ioc_status & MPI3_SYSIF_IOC_STATUS_SHUTDOWN_MASK) == MPI3_SYSIF_IOC_STATUS_SHUTDOWN_IN_PROGRESS) ioc_warn(mrioc, - "shutdown still in progress after timeout\n"); + "shutdown still in progress\n"); } ioc_info(mrioc, - "Base IOC Sts/Config after %s shutdown is (0x%x)/(0x%x)\n", + "ioc_status/ioc_config after %s shutdown is (0x%x)/(0x%x)\n", (!retval) ? "successful" : "failed", ioc_status, ioc_config); }