lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <39ebba5f96ec4c8b0266a55f8eea6972b91a150e.1720056514.git.mengfanhui@kylinos.cn>
Date: Thu,  4 Jul 2024 09:40:48 +0800
From: Fanhui Meng <mengfanhui@...inos.cn>
To: kashyap.desai@...adcom.com,
	sumit.saxena@...adcom.com,
	shivasharan.srikanteshwara@...adcom.com,
	chandrakanth.patil@...adcom.com,
	martin.petersen@...cle.com,
	James.Bottomley@...senPartnership.com
Cc: linux-scsi@...r.kernel.org,
	linux-kernel@...r.kernel.org,
	Geliang Tang <geliang@...nel.org>,
	Jackie Liu <liuyun01@...inos.cn>
Subject: [scsi-next v2 1/2] scsi: megaraid_sas: Add megasas_dcmd_timeout helper

DCMD timeout is handled in many places, it makes sense to
add a helper to handle it. This patch adds a new helper
named megasas_dcmd_timeout() to reduce duplicate code.

Suggested-by: Geliang Tang <geliang@...nel.org>
Co-developed-by: Jackie Liu <liuyun01@...inos.cn>
Signed-off-by: Jackie Liu <liuyun01@...inos.cn>
Signed-off-by: Fanhui Meng <mengfanhui@...inos.cn>
---
 drivers/scsi/megaraid/megaraid_sas.h      |   2 +
 drivers/scsi/megaraid/megaraid_sas_base.c | 198 ++++------------------
 2 files changed, 35 insertions(+), 165 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas.h b/drivers/scsi/megaraid/megaraid_sas.h
index 5680c6cdb221..277f179157e8 100644
--- a/drivers/scsi/megaraid/megaraid_sas.h
+++ b/drivers/scsi/megaraid/megaraid_sas.h
@@ -2760,5 +2760,7 @@ void megasas_exit_debugfs(void);
 void megasas_setup_debugfs(struct megasas_instance *instance);
 void megasas_destroy_debugfs(struct megasas_instance *instance);
 int megasas_blk_mq_poll(struct Scsi_Host *shost, unsigned int queue_num);
+void megasas_dcmd_timeout(struct megasas_instance *instance,
+			  struct megasas_cmd *cmd);
 
 #endif				/*LSI_MEGARAID_SAS_H */
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c
index 6c79c350a4d5..e6a9cef027c0 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -4529,6 +4529,30 @@ dcmd_timeout_ocr_possible(struct megasas_instance *instance) {
 		return INITIATE_OCR;
 }
 
+/*
+ * megasas_dcmd_timeout -	Classification processing dcmd timeout.
+ * @instance:				Adapter soft state
+ */
+void megasas_dcmd_timeout(struct megasas_instance *instance, struct megasas_cmd *cmd)
+{
+	switch (dcmd_timeout_ocr_possible(instance)) {
+	case INITIATE_OCR:
+		cmd->flags |= DRV_DCMD_SKIP_REFIRE;
+		mutex_unlock(&instance->reset_mutex);
+		megasas_reset_fusion(instance->host,
+					MFI_IO_TIMEOUT_OCR);
+		mutex_lock(&instance->reset_mutex);
+		break;
+	case KILL_ADAPTER:
+		megaraid_sas_kill_hba(instance);
+		break;
+	case IGNORE_TIMEOUT:
+		dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
+			__func__, __LINE__);
+		break;
+	}
+}
+
 static void
 megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev)
 {
@@ -4580,24 +4604,7 @@ megasas_get_pd_info(struct megasas_instance *instance, struct scsi_device *sdev)
 		break;
 
 	case DCMD_TIMEOUT:
-
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-				MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
-
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 	}
 
@@ -4676,29 +4683,7 @@ megasas_get_pd_list(struct megasas_instance *instance)
 			instance->pd_list_not_supported = 1;
 		break;
 	case DCMD_TIMEOUT:
-
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			/*
-			 * DCMD failed from AEN path.
-			 * AEN path already hold reset_mutex to avoid PCI access
-			 * while OCR is in progress.
-			 */
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-						MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d \n",
-				__func__, __LINE__);
-			break;
-		}
-
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 
 	case DCMD_SUCCESS:
@@ -4803,29 +4788,7 @@ megasas_get_ld_list(struct megasas_instance *instance)
 		megaraid_sas_kill_hba(instance);
 		break;
 	case DCMD_TIMEOUT:
-
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			/*
-			 * DCMD failed from AEN path.
-			 * AEN path already hold reset_mutex to avoid PCI access
-			 * while OCR is in progress.
-			 */
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-						MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
-
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 
 	case DCMD_SUCCESS:
@@ -4923,28 +4886,7 @@ megasas_ld_list_query(struct megasas_instance *instance, u8 query_type)
 		ret = megasas_get_ld_list(instance);
 		break;
 	case DCMD_TIMEOUT:
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			/*
-			 * DCMD failed from AEN path.
-			 * AEN path already hold reset_mutex to avoid PCI access
-			 * while OCR is in progress.
-			 */
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-						MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
-
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 	case DCMD_SUCCESS:
 		tgtid_count = le32_to_cpu(ci->count);
@@ -5079,22 +5021,7 @@ megasas_host_device_list_query(struct megasas_instance *instance,
 		break;
 
 	case DCMD_TIMEOUT:
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-				MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				 __func__, __LINE__);
-			break;
-		}
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 	case DCMD_FAILED:
 		dev_err(&instance->pdev->dev,
@@ -5230,22 +5157,7 @@ void megasas_get_snapdump_properties(struct megasas_instance *instance)
 		break;
 
 	case DCMD_TIMEOUT:
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-				MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
+		megasas_dcmd_timeout(instance, cmd);
 	}
 
 	if (ret != DCMD_TIMEOUT)
@@ -5370,22 +5282,7 @@ megasas_get_ctrl_info(struct megasas_instance *instance)
 		break;
 
 	case DCMD_TIMEOUT:
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-				MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 	case DCMD_FAILED:
 		megaraid_sas_kill_hba(instance);
@@ -5452,20 +5349,7 @@ int megasas_set_crash_dump_params(struct megasas_instance *instance,
 		ret = megasas_issue_polled(instance, cmd);
 
 	if (ret == DCMD_TIMEOUT) {
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			megasas_reset_fusion(instance->host,
-					MFI_IO_TIMEOUT_OCR);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev, "Ignore DCMD timeout: %s %d\n",
-				__func__, __LINE__);
-			break;
-		}
+		megasas_dcmd_timeout(instance, cmd);
 	} else
 		megasas_return_cmd(instance, cmd);
 
@@ -6838,23 +6722,7 @@ megasas_get_target_prop(struct megasas_instance *instance,
 
 	switch (ret) {
 	case DCMD_TIMEOUT:
-		switch (dcmd_timeout_ocr_possible(instance)) {
-		case INITIATE_OCR:
-			cmd->flags |= DRV_DCMD_SKIP_REFIRE;
-			mutex_unlock(&instance->reset_mutex);
-			megasas_reset_fusion(instance->host,
-					     MFI_IO_TIMEOUT_OCR);
-			mutex_lock(&instance->reset_mutex);
-			break;
-		case KILL_ADAPTER:
-			megaraid_sas_kill_hba(instance);
-			break;
-		case IGNORE_TIMEOUT:
-			dev_info(&instance->pdev->dev,
-				 "Ignore DCMD timeout: %s %d\n",
-				 __func__, __LINE__);
-			break;
-		}
+		megasas_dcmd_timeout(instance, cmd);
 		break;
 
 	default:
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ