Skip to contentSkip to conversation

megaraid_sas : Do not process IOCTLs and SCSI commands during driver removal

PATCH RESEND In review [email protected] 2 participants 2 messages Nov 17, 2014 – Nov 21, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 3/7 megaraid_sas : Do not process IOCTLs and SCSI commands during driver removal

Do not process any SCSI and IOCTL command further(return them with appropriate return values to callers), while driver removal is in progress/PCI shutdown is invoked.

---
 drivers/scsi/megaraid/megaraid_sas_base.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +15 -4
index 5fa6ce2..3781920 100644
@@ -1571,6 +1571,12 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
+	if (instance->unload == 1) {
+		scmd->result = DID_NO_CONNECT << 16;
+		scmd->scsi_done(scmd);
+		return 0;
+	}
+
 	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
@@ -4956,10 +4962,6 @@ static int megasas_io_attach(struct megasas_instance *instance)
 		return -ENODEV;
 	}
 
-	/*
-	 * Trigger SCSI to scan our drives
-	 */
-	scsi_scan_host(host);
 	return 0;
 }
 
@@ -5287,6 +5289,10 @@ retry_irq_register:
 		goto fail_io_attach;
 
 	instance->unload = 0;
+	/*
+	 * Trigger SCSI to scan our drives
+	 */
+	scsi_scan_host(host);
 
 	/*
 	 * Initiate AEN (Asynchronous Event Notification)
@@ -6050,6 +6056,11 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
 	megasas_issue_blocked_cmd(instance, cmd, 0);
 	cmd->sync_cmd = 0;
 
+	if (instance->unload == 1) {
+		dev_info(&instance->pdev->dev, "Driver unload is in progress "
+			"don't submit data to application\n");
+		goto out;
+	}
 	/*
 	 * copy out the kernel buffers to user buffers
 	 */
Signature · 1 line
1.7.1
Reviewed-by on v1 3/7
#1 lore raw
Quoted 50 lines · On 11/17/2014 10:54 AM, [email protected] wrote:

Do not process any SCSI and IOCTL command further(return them with appropriate return values to callers), while driver removal is in progress/PCI shutdown is invoked.

---
 drivers/scsi/megaraid/megaraid_sas_base.c |   19 +++++++++++++++----
 1 files changed, 15 insertions(+), 4 deletions(-)
drivers/scsi/megaraid/megaraid_sas_base.c +10 -4
index 5fa6ce2..3781920 100644
@@ -1571,6 +1571,12 @@ megasas_queue_command(struct Scsi_Host *shost, struct scsi_cmnd *scmd)
 	instance = (struct megasas_instance *)
 	    scmd->device->host->hostdata;
 
+	if (instance->unload == 1) {
+		scmd->result = DID_NO_CONNECT << 16;
+		scmd->scsi_done(scmd);
+		return 0;
+	}
+
 	if (instance->issuepend_done == 0)
 		return SCSI_MLQUEUE_HOST_BUSY;
 
@@ -4956,10 +4962,6 @@ static int megasas_io_attach(struct megasas_instance *instance)
 		return -ENODEV;
 	}
 
-	/*
-	 * Trigger SCSI to scan our drives
-	 */
-	scsi_scan_host(host);
 	return 0;
 }
 
@@ -5287,6 +5289,10 @@ retry_irq_register:
 		goto fail_io_attach;
 
 	instance->unload = 0;
+	/*
+	 * Trigger SCSI to scan our drives
+	 */
+	scsi_scan_host(host);
 
 	/*
 	 * Initiate AEN (Asynchronous Event Notification)
@@ -6050,6 +6056,11 @@ megasas_mgmt_fw_ioctl(struct megasas_instance *instance,
 	megasas_issue_blocked_cmd(instance, cmd, 0);

drivers/scsi/megaraid/megaraid_sas_base.c megasas_mgmt_fw_ioctl(struct megasas_instance *instance, · line 6066

Quoted 10 lines
drivers/scsi/megaraid/megaraid_sas_base.c +5 -0
 	cmd->sync_cmd = 0;
 
+	if (instance->unload == 1) {
+		dev_info(&instance->pdev->dev, "Driver unload is in progress "
+			"don't submit data to application\n");
+		goto out;
+	}
 	/*
 	 * copy out the kernel buffers to user buffers
 	 */