aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeff Skirvin <jeffrey.d.skirvin@intel.com>2011-03-31 16:10:40 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:00:36 -0400
commited8a72d108bd951909b28fa4a89aad6489f414e1 (patch)
treed93a624b0677c756c77a2bf3846b69f6209221e8
parent26e953bc6ec11c9e81ad8e9a59b14cf260776007 (diff)
isci: Qualify when the host lock is managed for STP/SATA callbacks.
In the case of internal discovery related STP/SATA I/O started through sas_execute_task the host lock is not taken by libsas before calling lldd_execute_task, so the lock should not be managed before calling back to libsas through task->task_done or sas_task_abort. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/request.c20
-rw-r--r--drivers/scsi/isci/sata.c1
-rw-r--r--drivers/scsi/isci/task.c29
-rw-r--r--drivers/scsi/isci/task.h37
4 files changed, 50 insertions, 37 deletions
diff --git a/drivers/scsi/isci/request.c b/drivers/scsi/isci/request.c
index 946caaeb66c6..b519373597a5 100644
--- a/drivers/scsi/isci/request.c
+++ b/drivers/scsi/isci/request.c
@@ -53,7 +53,6 @@
53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 53 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
54 */ 54 */
55 55
56#include <scsi/sas_ata.h>
57#include "isci.h" 56#include "isci.h"
58#include "scic_remote_device.h" 57#include "scic_remote_device.h"
59#include "scic_io_request.h" 58#include "scic_io_request.h"
@@ -452,22 +451,11 @@ int isci_request_execute(
452 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET; 451 task->task_state_flags |= SAS_TASK_NEED_DEV_RESET;
453 spin_unlock_irqrestore(&task->task_state_lock, flags); 452 spin_unlock_irqrestore(&task->task_state_lock, flags);
454 453
455 /* Cause this task to be scheduled in the SCSI error handler 454 /* Cause this task to be scheduled in the SCSI error
456 * thread. 455 * handler thread.
457 */ 456 */
458 if (dev_is_sata(task->dev)) { 457 isci_execpath_callback(isci_host, task,
459 /* Since we are still in the submit path, and since 458 sas_task_abort);
460 * libsas takes the host lock on behalf of SATA
461 * devices before I/O starts, we need to unlock
462 * before we can put the task in the error path.
463 */
464 raw_local_irq_save(flags);
465 spin_unlock(isci_host->shost->host_lock);
466 sas_task_abort(task);
467 spin_lock(isci_host->shost->host_lock);
468 raw_local_irq_restore(flags);
469 } else
470 sas_task_abort(task);
471 459
472 /* Change the status, since we are holding 460 /* Change the status, since we are holding
473 * the I/O until it is managed by the SCSI 461 * the I/O until it is managed by the SCSI
diff --git a/drivers/scsi/isci/sata.c b/drivers/scsi/isci/sata.c
index 794ab7ca9f1a..c941d9090b8d 100644
--- a/drivers/scsi/isci/sata.c
+++ b/drivers/scsi/isci/sata.c
@@ -299,7 +299,6 @@ int isci_task_send_lu_reset_sata(
299{ 299{
300 struct isci_tmf tmf; 300 struct isci_tmf tmf;
301 int ret = TMF_RESP_FUNC_FAILED; 301 int ret = TMF_RESP_FUNC_FAILED;
302 unsigned long flags;
303 302
304 /* Send the soft reset to the target */ 303 /* Send the soft reset to the target */
305 #define ISCI_SRST_TIMEOUT_MS 25000 /* 25 second timeout. */ 304 #define ISCI_SRST_TIMEOUT_MS 25000 /* 25 second timeout. */
diff --git a/drivers/scsi/isci/task.c b/drivers/scsi/isci/task.c
index 338f08ec4d8e..5bcea60fd8c4 100644
--- a/drivers/scsi/isci/task.c
+++ b/drivers/scsi/isci/task.c
@@ -55,7 +55,6 @@
55 55
56#include <linux/completion.h> 56#include <linux/completion.h>
57#include <linux/irqflags.h> 57#include <linux/irqflags.h>
58#include <scsi/sas_ata.h>
59#include "scic_task_request.h" 58#include "scic_task_request.h"
60#include "scic_remote_device.h" 59#include "scic_remote_device.h"
61#include "scic_io_request.h" 60#include "scic_io_request.h"
@@ -93,26 +92,13 @@ static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task,
93 case isci_perform_normal_io_completion: 92 case isci_perform_normal_io_completion:
94 /* Normal notification (task_done) */ 93 /* Normal notification (task_done) */
95 dev_dbg(&ihost->pdev->dev, 94 dev_dbg(&ihost->pdev->dev,
96 "%s: Normal - task = %p, response=%d, status=%d\n", 95 "%s: Normal - task = %p, response=%d, "
96 "status=%d\n",
97 __func__, task, response, status); 97 __func__, task, response, status);
98 98
99 task->lldd_task = NULL; 99 task->lldd_task = NULL;
100 if (dev_is_sata(task->dev)) {
101 /* Since we are still in the submit path, and since
102 * libsas takes the host lock on behalf of SATA
103 * devices before I/O starts, we need to unlock
104 * before we can call back and report the I/O
105 * submission error.
106 */
107 unsigned long flags;
108 100
109 raw_local_irq_save(flags); 101 isci_execpath_callback(ihost, task, task->task_done);
110 spin_unlock(ihost->shost->host_lock);
111 task->task_done(task);
112 spin_lock(ihost->shost->host_lock);
113 raw_local_irq_restore(flags);
114 } else
115 task->task_done(task);
116 break; 102 break;
117 103
118 case isci_perform_aborted_io_completion: 104 case isci_perform_aborted_io_completion:
@@ -120,16 +106,19 @@ static void isci_task_refuse(struct isci_host *ihost, struct sas_task *task,
120 * abort path. 106 * abort path.
121 */ 107 */
122 dev_warn(&ihost->pdev->dev, 108 dev_warn(&ihost->pdev->dev,
123 "%s: Aborted - task = %p, response=%d, status=%d\n", 109 "%s: Aborted - task = %p, response=%d, "
110 "status=%d\n",
124 __func__, task, response, status); 111 __func__, task, response, status);
125 break; 112 break;
126 113
127 case isci_perform_error_io_completion: 114 case isci_perform_error_io_completion:
128 /* Use sas_task_abort */ 115 /* Use sas_task_abort */
129 dev_warn(&ihost->pdev->dev, 116 dev_warn(&ihost->pdev->dev,
130 "%s: Error - task = %p, response=%d, status=%d\n", 117 "%s: Error - task = %p, response=%d, "
118 "status=%d\n",
131 __func__, task, response, status); 119 __func__, task, response, status);
132 sas_task_abort(task); 120
121 isci_execpath_callback(ihost, task, sas_task_abort);
133 break; 122 break;
134 123
135 default: 124 default:
diff --git a/drivers/scsi/isci/task.h b/drivers/scsi/isci/task.h
index d7cb6fe268c4..c5afd1cfbde7 100644
--- a/drivers/scsi/isci/task.h
+++ b/drivers/scsi/isci/task.h
@@ -56,6 +56,8 @@
56#if !defined(_ISCI_TASK_H_) 56#if !defined(_ISCI_TASK_H_)
57#define _ISCI_TASK_H_ 57#define _ISCI_TASK_H_
58 58
59#include <scsi/sas_ata.h>
60
59struct isci_request; 61struct isci_request;
60struct isci_host; 62struct isci_host;
61 63
@@ -332,5 +334,40 @@ isci_task_set_completion_status(
332 return task_notification_selection; 334 return task_notification_selection;
333 335
334} 336}
337/**
338* isci_execpath_callback() - This function is called from the task
339* execute path when the task needs to callback libsas about the submit-time
340* task failure. The callback occurs either through the task's done function
341* or through sas_task_abort. In the case of regular non-discovery SATA/STP I/O
342* requests, libsas takes the host lock before calling execute task. Therefore
343* in this situation the host lock must be managed before calling the func.
344*
345* @ihost: This parameter is the controller to which the I/O request was sent.
346* @task: This parameter is the I/O request.
347* @func: This parameter is the function to call in the correct context.
348* @status: This parameter is the status code for the completed task.
349*
350*/
351static inline void isci_execpath_callback(
352 struct isci_host *ihost,
353 struct sas_task *task,
354 void (*func)(struct sas_task *))
355{
356 unsigned long flags;
357
358 if (dev_is_sata(task->dev) && task->uldd_task) {
359 /* Since we are still in the submit path, and since
360 * libsas takes the host lock on behalf of SATA
361 * devices before I/O starts (in the non-discovery case),
362 * we need to unlock before we can call the callback function.
363 */
364 raw_local_irq_save(flags);
365 spin_unlock(ihost->shost->host_lock);
366 func(task);
367 spin_lock(ihost->shost->host_lock);
368 raw_local_irq_restore(flags);
369 } else
370 func(task);
371}
335 372
336#endif /* !defined(_SCI_TASK_H_) */ 373#endif /* !defined(_SCI_TASK_H_) */