diff options
Diffstat (limited to 'drivers/scsi/isci/remote_device.c')
-rw-r--r-- | drivers/scsi/isci/remote_device.c | 43 |
1 files changed, 37 insertions, 6 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c index d1c2a2294a3..21a9800a9be 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 | ||
148 | static 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 | |||
165 | static 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 | |||
148 | enum sci_status isci_remote_device_terminate_requests( | 181 | enum 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); |