aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci
diff options
context:
space:
mode:
authorJeff Skirvin <jeffrey.d.skirvin@intel.com>2012-03-09 01:42:03 -0500
committerDan Williams <dan.j.williams@intel.com>2012-05-17 17:33:41 -0400
commit033d19d298b4245da2d3d6c795ea97e419f9ac61 (patch)
tree2e66627f294b9e2b52174e719ff987464cedaeec /drivers/scsi/isci
parent0c3ce38f1bc8b6a6d8df0959e3c0dece31f9350c (diff)
isci: Callbacks to libsas occur under scic_lock and are synchronized.
This patch changes the callback mechanism to libsas to only occur while the scic_lock is held; the abort path cleanup of I/Os also checks to make sure IREQ_ABORT_PATH_ACTIVE is clear before proceding. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Diffstat (limited to 'drivers/scsi/isci')
-rw-r--r--drivers/scsi/isci/host.c10
-rw-r--r--drivers/scsi/isci/remote_device.c43
2 files changed, 40 insertions, 13 deletions
diff --git a/drivers/scsi/isci/host.c b/drivers/scsi/isci/host.c
index 25d537e2f5c4..53c3ad64c998 100644
--- a/drivers/scsi/isci/host.c
+++ b/drivers/scsi/isci/host.c
@@ -1105,8 +1105,6 @@ void isci_host_completion_routine(unsigned long data)
1105 list_splice_init(&ihost->requests_to_complete, 1105 list_splice_init(&ihost->requests_to_complete,
1106 &completed_request_list); 1106 &completed_request_list);
1107 1107
1108 spin_unlock_irq(&ihost->scic_lock);
1109
1110 /* Process any completions in the list. */ 1108 /* Process any completions in the list. */
1111 list_for_each_safe(current_position, next_position, 1109 list_for_each_safe(current_position, next_position,
1112 &completed_request_list) { 1110 &completed_request_list) {
@@ -1115,7 +1113,6 @@ void isci_host_completion_routine(unsigned long data)
1115 completed_node); 1113 completed_node);
1116 task = isci_request_access_task(request); 1114 task = isci_request_access_task(request);
1117 1115
1118
1119 /* Return the task to libsas */ 1116 /* Return the task to libsas */
1120 if (task != NULL) { 1117 if (task != NULL) {
1121 1118
@@ -1141,11 +1138,12 @@ void isci_host_completion_routine(unsigned long data)
1141 } 1138 }
1142 } 1139 }
1143 } 1140 }
1141 if (test_and_clear_bit(IREQ_ABORT_PATH_ACTIVE, &request->flags))
1142 wake_up_all(&ihost->eventq);
1144 1143
1145 spin_lock_irq(&ihost->scic_lock);
1146 isci_free_tag(ihost, request->io_tag); 1144 isci_free_tag(ihost, request->io_tag);
1147 spin_unlock_irq(&ihost->scic_lock);
1148 } 1145 }
1146 spin_unlock_irq(&ihost->scic_lock);
1149 1147
1150 /* the coalesence timeout doubles at each encoding step, so 1148 /* the coalesence timeout doubles at each encoding step, so
1151 * update it based on the ilog2 value of the outstanding requests 1149 * update it based on the ilog2 value of the outstanding requests
@@ -2703,8 +2701,6 @@ enum sci_status sci_controller_complete_io(struct isci_host *ihost,
2703 2701
2704 index = ISCI_TAG_TCI(ireq->io_tag); 2702 index = ISCI_TAG_TCI(ireq->io_tag);
2705 clear_bit(IREQ_ACTIVE, &ireq->flags); 2703 clear_bit(IREQ_ACTIVE, &ireq->flags);
2706 if (test_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags))
2707 wake_up_all(&ihost->eventq);
2708 return SCI_SUCCESS; 2704 return SCI_SUCCESS;
2709 default: 2705 default:
2710 dev_warn(&ihost->pdev->dev, "%s invalid state: %d\n", 2706 dev_warn(&ihost->pdev->dev, "%s invalid state: %d\n",
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index d1c2a2294a32..21a9800a9bec 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -145,6 +145,39 @@ static bool isci_compare_suspendcount(
145 return localcount != idev->rnc.suspend_count; 145 return localcount != idev->rnc.suspend_count;
146} 146}
147 147
148static bool isci_check_reqterm(
149 struct isci_host *ihost,
150 struct isci_remote_device *idev,
151 struct isci_request *ireq,
152 u32 localcount)
153{
154 unsigned long flags;
155 bool res;
156
157 spin_lock_irqsave(&ihost->scic_lock, flags);
158 res = isci_compare_suspendcount(idev, localcount)
159 && !test_bit(IREQ_ABORT_PATH_ACTIVE, &ireq->flags);
160 spin_unlock_irqrestore(&ihost->scic_lock, flags);
161
162 return res;
163}
164
165static bool isci_check_devempty(
166 struct isci_host *ihost,
167 struct isci_remote_device *idev,
168 u32 localcount)
169{
170 unsigned long flags;
171 bool res;
172
173 spin_lock_irqsave(&ihost->scic_lock, flags);
174 res = isci_compare_suspendcount(idev, localcount)
175 && idev->started_request_count == 0;
176 spin_unlock_irqrestore(&ihost->scic_lock, flags);
177
178 return res;
179}
180
148enum sci_status isci_remote_device_terminate_requests( 181enum sci_status isci_remote_device_terminate_requests(
149 struct isci_host *ihost, 182 struct isci_host *ihost,
150 struct isci_remote_device *idev, 183 struct isci_remote_device *idev,
@@ -179,17 +212,15 @@ enum sci_status isci_remote_device_terminate_requests(
179 sci_remote_device_terminate_req(ihost, idev, 0, ireq); 212 sci_remote_device_terminate_req(ihost, idev, 0, ireq);
180 spin_unlock_irqrestore(&ihost->scic_lock, flags); 213 spin_unlock_irqrestore(&ihost->scic_lock, flags);
181 wait_event(ihost->eventq, 214 wait_event(ihost->eventq,
182 (isci_compare_suspendcount(idev, 215 isci_check_reqterm(ihost, idev, ireq,
183 rnc_suspend_count) 216 rnc_suspend_count));
184 && !test_bit(IREQ_ACTIVE, &ireq->flags)));
185 } else { 217 } else {
186 /* Terminate all TCs. */ 218 /* Terminate all TCs. */
187 sci_remote_device_terminate_requests(idev); 219 sci_remote_device_terminate_requests(idev);
188 spin_unlock_irqrestore(&ihost->scic_lock, flags); 220 spin_unlock_irqrestore(&ihost->scic_lock, flags);
189 wait_event(ihost->eventq, 221 wait_event(ihost->eventq,
190 (isci_compare_suspendcount(idev, 222 isci_check_devempty(ihost, idev,
191 rnc_suspend_count) 223 rnc_suspend_count));
192 && idev->started_request_count == 0));
193 } 224 }
194 dev_dbg(&ihost->pdev->dev, "%s: idev=%p, wait done\n", 225 dev_dbg(&ihost->pdev->dev, "%s: idev=%p, wait done\n",
195 __func__, idev); 226 __func__, idev);