Re: [PATCH 3/4] megaraid_sas: task management code optimizations

2016-04-15 Thread Hannes Reinecke
On 04/15/2016 09:23 AM, Sumit Saxena wrote:
> This patch will do code optmization for task management functions.
> Below are key changes-
> 1. Remove reset_device hook as it was not being used and driver was setting 
> this to NULL.
> 2. Create wrapper functions for task abort and target reset and inside these 
> functions
>adapter specific calls be made. e.g. fusion adapters support task abort 
> and target reset
>so task abort and target reset should be issued to fusion adapters only 
> and for MFI adapters,
>print a message saying feature not supported.
> 
> Signed-off-by: Sumit Saxena 
> ---
>  drivers/scsi/megaraid/megaraid_sas_base.c | 67 
> +--
>  1 file changed, 46 insertions(+), 21 deletions(-)
> 
Reviewed-by: Hannes Reinecke 

Cheers,

Hannes
-- 
Dr. Hannes ReineckeTeamlead Storage & Networking
h...@suse.de   +49 911 74053 688
SUSE LINUX GmbH, Maxfeldstr. 5, 90409 Nürnberg
GF: F. Imendörffer, J. Smithard, J. Guild, D. Upmanyu, G. Norton
HRB 21284 (AG Nürnberg)
--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCH 3/4] megaraid_sas: task management code optimizations

2016-04-15 Thread Sumit Saxena
This patch will do code optmization for task management functions.
Below are key changes-
1. Remove reset_device hook as it was not being used and driver was setting 
this to NULL.
2. Create wrapper functions for task abort and target reset and inside these 
functions
   adapter specific calls be made. e.g. fusion adapters support task abort and 
target reset
   so task abort and target reset should be issued to fusion adapters only and 
for MFI adapters,
   print a message saying feature not supported.

Signed-off-by: Sumit Saxena 
---
 drivers/scsi/megaraid/megaraid_sas_base.c | 67 +--
 1 file changed, 46 insertions(+), 21 deletions(-)

diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c 
b/drivers/scsi/megaraid/megaraid_sas_base.c
index 8588202..b84756c 100644
--- a/drivers/scsi/megaraid/megaraid_sas_base.c
+++ b/drivers/scsi/megaraid/megaraid_sas_base.c
@@ -2670,17 +2670,6 @@ blk_eh_timer_return megasas_reset_timer(struct scsi_cmnd 
*scmd)
 }
 
 /**
- * megasas_reset_device -  Device reset handler entry point
- */
-static int megasas_reset_device(struct scsi_cmnd *scmd)
-{
-   /*
-* First wait for all commands to complete
-*/
-   return megasas_generic_reset(scmd);
-}
-
-/**
  * megasas_reset_bus_host -Bus & host reset handler entry point
  */
 static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
@@ -2702,6 +2691,50 @@ static int megasas_reset_bus_host(struct scsi_cmnd *scmd)
 }
 
 /**
+ * megasas_task_abort - Issues task abort request to firmware
+ * (supported only for fusion adapters)
+ * @scmd:  SCSI command pointer
+ */
+static int megasas_task_abort(struct scsi_cmnd *scmd)
+{
+   int ret;
+   struct megasas_instance *instance;
+
+   instance = (struct megasas_instance *)scmd->device->host->hostdata;
+
+   if (instance->ctrl_context)
+   ret = megasas_task_abort_fusion(scmd);
+   else {
+   sdev_printk(KERN_NOTICE, scmd->device, "TASK ABORT not 
supported\n");
+   ret = FAILED;
+   }
+
+   return ret;
+}
+
+/**
+ * megasas_reset_target:  Issues target reset request to firmware
+ *(supported only for fusion adapters)
+ * @scmd: SCSI command pointer
+ */
+static int megasas_reset_target(struct scsi_cmnd *scmd)
+{
+   int ret;
+   struct megasas_instance *instance;
+
+   instance = (struct megasas_instance *)scmd->device->host->hostdata;
+
+   if (instance->ctrl_context)
+   ret = megasas_reset_target_fusion(scmd);
+   else {
+   sdev_printk(KERN_NOTICE, scmd->device, "TARGET RESET not 
supported\n");
+   ret = FAILED;
+   }
+
+   return ret;
+}
+
+/**
  * megasas_bios_param - Returns disk geometry for a disk
  * @sdev:  device handle
  * @bdev:  block device
@@ -2969,8 +3002,8 @@ static struct scsi_host_template megasas_template = {
.slave_alloc = megasas_slave_alloc,
.slave_destroy = megasas_slave_destroy,
.queuecommand = megasas_queue_command,
-   .eh_device_reset_handler = megasas_reset_device,
-   .eh_bus_reset_handler = megasas_reset_bus_host,
+   .eh_target_reset_handler = megasas_reset_target,
+   .eh_abort_handler = megasas_task_abort,
.eh_host_reset_handler = megasas_reset_bus_host,
.eh_timed_out = megasas_reset_timer,
.shost_attrs = megaraid_host_attrs,
@@ -5598,14 +5631,6 @@ static int megasas_io_attach(struct megasas_instance 
*instance)
host->max_lun = MEGASAS_MAX_LUN;
host->max_cmd_len = 16;
 
-   /* Fusion only supports host reset */
-   if (instance->ctrl_context) {
-   host->hostt->eh_device_reset_handler = NULL;
-   host->hostt->eh_bus_reset_handler = NULL;
-   host->hostt->eh_target_reset_handler = 
megasas_reset_target_fusion;
-   host->hostt->eh_abort_handler = megasas_task_abort_fusion;
-   }
-
/*
 * Notify the mid-layer about the new controller
 */
-- 
2.4.11

--
To unsubscribe from this list: send the line "unsubscribe linux-scsi" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html