From patchwork Thu Dec 14 20:58:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ranjan Kumar X-Patchwork-Id: 13493680 Received: from mail-pg1-f180.google.com (mail-pg1-f180.google.com [209.85.215.180]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 8821D7494 for ; Thu, 14 Dec 2023 21:01:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=broadcom.com Authentication-Results: smtp.subspace.kernel.org; spf=fail smtp.mailfrom=broadcom.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=broadcom.com header.i=@broadcom.com header.b="J/EqLPwu" Received: by mail-pg1-f180.google.com with SMTP id 41be03b00d2f7-5c210e34088so7285a12.2 for ; Thu, 14 Dec 2023 13:01:14 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; t=1702587673; x=1703192473; 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=wpUkK6ITIMil2yG9knOEkvfpxottBbwtLLuhrQinNns=; b=J/EqLPwuPGTugutiFlp+hqAyP/vh6RXrMCIZNx8e5c/R9yx0Zj3HIPQLMbk09xxfMI B+gMAlxoA49stENjckvtaIugiKP4TecKR+ZUE+DoZs2DqQaXKI+UnNio150wPDGiDRXU 3L9HMaG2LlG6eV4dSomnnwjDuVTzfhaTidIY8= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1702587673; x=1703192473; 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=wpUkK6ITIMil2yG9knOEkvfpxottBbwtLLuhrQinNns=; b=T563UyPmYVw/bcBZCj9x3PahYdIBUp4Vh/0O8qI4Oz3XoSLjOi9pvtZVpMD1EMZ7A8 Ut/wvQLH6ghE1mZFPb6QT6eIAAlnek6dISACp4ETv8mhDd0zLlnbq0013gZqOZ994OeY bwq3ZuyPLxgfov4n8UYWh/5bN5b2Hwij5lTkooGQNLQAGsnAaXR7V6stUAlB36+1C/Wz OUP4uObQ/GxmJPelQInPxkwwjPTul6J7/5NOpJggSYf5Ci2SJX0Hf3QCLQ1+Vt2MNE3H 4y/OTqtwpAnQXs7TDMIKptmsTprsIAy4+Nf5gOYC5vNFf0rhT0dx6Z0Wy32RCk6Zdv/S g4kA== X-Gm-Message-State: AOJu0YxGV80xCuwcdg6RGrxbKwJROvaBT5iXyI6XjQXLGt2WCnjFBMbC mpD/a2kqcVkdjDW64LO5XOHcL5B7t+S3WkUwezAvhx+lf8s+O/duGlQgpDcJzGyXxIe2CnhbPB7 +CoNMyCuC+HOz8tyD2XcuAHxNq3JoEOtP7kR9aaKdjrIp8n9WQxz3NclHKubFgMwfE0Wf4LH3OG OnTfSXAYp+6w== X-Google-Smtp-Source: AGHT+IGukzCheuPz33VN+IQ7Us8vPqCqiZ4590d4yynT0ZGqFYsB7wwM9VojxitKsVmjC729+xpFew== X-Received: by 2002:a05:6a20:b3aa:b0:18f:e1f:32ce with SMTP id eg42-20020a056a20b3aa00b0018f0e1f32cemr10600679pzb.115.1702587672769; Thu, 14 Dec 2023 13:01:12 -0800 (PST) Received: from localhost.localdomain ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id bv190-20020a632ec7000000b005c2967852c5sm11904303pgb.30.2023.12.14.13.01.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 14 Dec 2023 13:01:11 -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 v2 4/6] mpi3mr: Improve Shutdown times when firmware has faulted Date: Fri, 15 Dec 2023 02:28:58 +0530 Message-Id: <20231214205900.270488-5-ranjan.kumar@broadcom.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20231214205900.270488-1-ranjan.kumar@broadcom.com> References: <20231214205900.270488-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 1ac7f88dc1cd..de953eb055d0 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -159,6 +159,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 c50fc27231cd..491ef854fdba 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -4566,9 +4566,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) { @@ -4583,15 +4584,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) @@ -4599,8 +4601,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); @@ -4609,11 +4629,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); }