aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/remote_device.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/scsi/isci/remote_device.c')
-rw-r--r--drivers/scsi/isci/remote_device.c349
1 files changed, 171 insertions, 178 deletions
diff --git a/drivers/scsi/isci/remote_device.c b/drivers/scsi/isci/remote_device.c
index 68b63b04be19..6c93f20f3dd3 100644
--- a/drivers/scsi/isci/remote_device.c
+++ b/drivers/scsi/isci/remote_device.c
@@ -126,8 +126,7 @@ static void rnc_destruct_done(void *_dev)
126 struct scic_sds_remote_device *sci_dev = _dev; 126 struct scic_sds_remote_device *sci_dev = _dev;
127 127
128 BUG_ON(sci_dev->started_request_count != 0); 128 BUG_ON(sci_dev->started_request_count != 0);
129 sci_base_state_machine_change_state(&sci_dev->state_machine, 129 sci_change_state(&sci_dev->sm, SCI_DEV_STOPPED);
130 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
131} 130}
132 131
133static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds_remote_device *sci_dev) 132static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds_remote_device *sci_dev)
@@ -154,20 +153,20 @@ static enum sci_status scic_sds_remote_device_terminate_requests(struct scic_sds
154enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev, 153enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
155 u32 timeout) 154 u32 timeout)
156{ 155{
157 struct sci_base_state_machine *sm = &sci_dev->state_machine; 156 struct sci_base_state_machine *sm = &sci_dev->sm;
158 enum scic_sds_remote_device_states state = sm->current_state_id; 157 enum scic_sds_remote_device_states state = sm->current_state_id;
159 158
160 switch (state) { 159 switch (state) {
161 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 160 case SCI_DEV_INITIAL:
162 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 161 case SCI_DEV_FAILED:
163 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 162 case SCI_DEV_FINAL:
164 default: 163 default:
165 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 164 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
166 __func__, state); 165 __func__, state);
167 return SCI_FAILURE_INVALID_STATE; 166 return SCI_FAILURE_INVALID_STATE;
168 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 167 case SCI_DEV_STOPPED:
169 return SCI_SUCCESS; 168 return SCI_SUCCESS;
170 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 169 case SCI_DEV_STARTING:
171 /* device not started so there had better be no requests */ 170 /* device not started so there had better be no requests */
172 BUG_ON(sci_dev->started_request_count != 0); 171 BUG_ON(sci_dev->started_request_count != 0);
173 scic_sds_remote_node_context_destruct(&sci_dev->rnc, 172 scic_sds_remote_node_context_destruct(&sci_dev->rnc,
@@ -175,17 +174,17 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
175 /* Transition to the stopping state and wait for the 174 /* Transition to the stopping state and wait for the
176 * remote node to complete being posted and invalidated. 175 * remote node to complete being posted and invalidated.
177 */ 176 */
178 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); 177 sci_change_state(sm, SCI_DEV_STOPPING);
179 return SCI_SUCCESS; 178 return SCI_SUCCESS;
180 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 179 case SCI_DEV_READY:
181 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 180 case SCI_STP_DEV_IDLE:
182 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 181 case SCI_STP_DEV_CMD:
183 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: 182 case SCI_STP_DEV_NCQ:
184 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 183 case SCI_STP_DEV_NCQ_ERROR:
185 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 184 case SCI_STP_DEV_AWAIT_RESET:
186 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 185 case SCI_SMP_DEV_IDLE:
187 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 186 case SCI_SMP_DEV_CMD:
188 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); 187 sci_change_state(sm, SCI_DEV_STOPPING);
189 if (sci_dev->started_request_count == 0) { 188 if (sci_dev->started_request_count == 0) {
190 scic_sds_remote_node_context_destruct(&sci_dev->rnc, 189 scic_sds_remote_node_context_destruct(&sci_dev->rnc,
191 rnc_destruct_done, sci_dev); 190 rnc_destruct_done, sci_dev);
@@ -193,70 +192,70 @@ enum sci_status scic_remote_device_stop(struct scic_sds_remote_device *sci_dev,
193 } else 192 } else
194 return scic_sds_remote_device_terminate_requests(sci_dev); 193 return scic_sds_remote_device_terminate_requests(sci_dev);
195 break; 194 break;
196 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 195 case SCI_DEV_STOPPING:
197 /* All requests should have been terminated, but if there is an 196 /* All requests should have been terminated, but if there is an
198 * attempt to stop a device already in the stopping state, then 197 * attempt to stop a device already in the stopping state, then
199 * try again to terminate. 198 * try again to terminate.
200 */ 199 */
201 return scic_sds_remote_device_terminate_requests(sci_dev); 200 return scic_sds_remote_device_terminate_requests(sci_dev);
202 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: 201 case SCI_DEV_RESETTING:
203 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STOPPING); 202 sci_change_state(sm, SCI_DEV_STOPPING);
204 return SCI_SUCCESS; 203 return SCI_SUCCESS;
205 } 204 }
206} 205}
207 206
208enum sci_status scic_remote_device_reset(struct scic_sds_remote_device *sci_dev) 207enum sci_status scic_remote_device_reset(struct scic_sds_remote_device *sci_dev)
209{ 208{
210 struct sci_base_state_machine *sm = &sci_dev->state_machine; 209 struct sci_base_state_machine *sm = &sci_dev->sm;
211 enum scic_sds_remote_device_states state = sm->current_state_id; 210 enum scic_sds_remote_device_states state = sm->current_state_id;
212 211
213 switch (state) { 212 switch (state) {
214 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 213 case SCI_DEV_INITIAL:
215 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 214 case SCI_DEV_STOPPED:
216 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 215 case SCI_DEV_STARTING:
217 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 216 case SCI_SMP_DEV_IDLE:
218 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 217 case SCI_SMP_DEV_CMD:
219 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 218 case SCI_DEV_STOPPING:
220 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 219 case SCI_DEV_FAILED:
221 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: 220 case SCI_DEV_RESETTING:
222 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 221 case SCI_DEV_FINAL:
223 default: 222 default:
224 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 223 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
225 __func__, state); 224 __func__, state);
226 return SCI_FAILURE_INVALID_STATE; 225 return SCI_FAILURE_INVALID_STATE;
227 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 226 case SCI_DEV_READY:
228 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 227 case SCI_STP_DEV_IDLE:
229 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 228 case SCI_STP_DEV_CMD:
230 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: 229 case SCI_STP_DEV_NCQ:
231 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 230 case SCI_STP_DEV_NCQ_ERROR:
232 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 231 case SCI_STP_DEV_AWAIT_RESET:
233 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_RESETTING); 232 sci_change_state(sm, SCI_DEV_RESETTING);
234 return SCI_SUCCESS; 233 return SCI_SUCCESS;
235 } 234 }
236} 235}
237 236
238enum sci_status scic_remote_device_reset_complete(struct scic_sds_remote_device *sci_dev) 237enum sci_status scic_remote_device_reset_complete(struct scic_sds_remote_device *sci_dev)
239{ 238{
240 struct sci_base_state_machine *sm = &sci_dev->state_machine; 239 struct sci_base_state_machine *sm = &sci_dev->sm;
241 enum scic_sds_remote_device_states state = sm->current_state_id; 240 enum scic_sds_remote_device_states state = sm->current_state_id;
242 241
243 if (state != SCI_BASE_REMOTE_DEVICE_STATE_RESETTING) { 242 if (state != SCI_DEV_RESETTING) {
244 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 243 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
245 __func__, state); 244 __func__, state);
246 return SCI_FAILURE_INVALID_STATE; 245 return SCI_FAILURE_INVALID_STATE;
247 } 246 }
248 247
249 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_READY); 248 sci_change_state(sm, SCI_DEV_READY);
250 return SCI_SUCCESS; 249 return SCI_SUCCESS;
251} 250}
252 251
253enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sci_dev, 252enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sci_dev,
254 u32 suspend_type) 253 u32 suspend_type)
255{ 254{
256 struct sci_base_state_machine *sm = &sci_dev->state_machine; 255 struct sci_base_state_machine *sm = &sci_dev->sm;
257 enum scic_sds_remote_device_states state = sm->current_state_id; 256 enum scic_sds_remote_device_states state = sm->current_state_id;
258 257
259 if (state != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD) { 258 if (state != SCI_STP_DEV_CMD) {
260 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 259 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
261 __func__, state); 260 __func__, state);
262 return SCI_FAILURE_INVALID_STATE; 261 return SCI_FAILURE_INVALID_STATE;
@@ -269,30 +268,30 @@ enum sci_status scic_sds_remote_device_suspend(struct scic_sds_remote_device *sc
269enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_device *sci_dev, 268enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_device *sci_dev,
270 u32 frame_index) 269 u32 frame_index)
271{ 270{
272 struct sci_base_state_machine *sm = &sci_dev->state_machine; 271 struct sci_base_state_machine *sm = &sci_dev->sm;
273 enum scic_sds_remote_device_states state = sm->current_state_id; 272 enum scic_sds_remote_device_states state = sm->current_state_id;
274 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; 273 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
275 enum sci_status status; 274 enum sci_status status;
276 275
277 switch (state) { 276 switch (state) {
278 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 277 case SCI_DEV_INITIAL:
279 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 278 case SCI_DEV_STOPPED:
280 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 279 case SCI_DEV_STARTING:
281 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 280 case SCI_STP_DEV_IDLE:
282 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 281 case SCI_SMP_DEV_IDLE:
283 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 282 case SCI_DEV_FINAL:
284 default: 283 default:
285 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 284 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
286 __func__, state); 285 __func__, state);
287 /* Return the frame back to the controller */ 286 /* Return the frame back to the controller */
288 scic_sds_controller_release_frame(scic, frame_index); 287 scic_sds_controller_release_frame(scic, frame_index);
289 return SCI_FAILURE_INVALID_STATE; 288 return SCI_FAILURE_INVALID_STATE;
290 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 289 case SCI_DEV_READY:
291 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 290 case SCI_STP_DEV_NCQ_ERROR:
292 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 291 case SCI_STP_DEV_AWAIT_RESET:
293 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 292 case SCI_DEV_STOPPING:
294 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 293 case SCI_DEV_FAILED:
295 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: { 294 case SCI_DEV_RESETTING: {
296 struct scic_sds_request *sci_req; 295 struct scic_sds_request *sci_req;
297 struct ssp_frame_hdr hdr; 296 struct ssp_frame_hdr hdr;
298 void *frame_header; 297 void *frame_header;
@@ -319,7 +318,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
319 } 318 }
320 break; 319 break;
321 } 320 }
322 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: { 321 case SCI_STP_DEV_NCQ: {
323 struct dev_to_host_fis *hdr; 322 struct dev_to_host_fis *hdr;
324 323
325 status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control, 324 status = scic_sds_unsolicited_frame_control_get_header(&scic->uf_control,
@@ -333,7 +332,7 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
333 sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; 332 sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
334 333
335 /* TODO Check sactive and complete associated IO if any. */ 334 /* TODO Check sactive and complete associated IO if any. */
336 sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR); 335 sci_change_state(sm, SCI_STP_DEV_NCQ_ERROR);
337 } else if (hdr->fis_type == FIS_REGD2H && 336 } else if (hdr->fis_type == FIS_REGD2H &&
338 (hdr->status & ATA_ERR)) { 337 (hdr->status & ATA_ERR)) {
339 /* 338 /*
@@ -341,16 +340,15 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
341 * Treat this like an SDB error FIS ready reason. 340 * Treat this like an SDB error FIS ready reason.
342 */ 341 */
343 sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED; 342 sci_dev->not_ready_reason = SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED;
344 sci_base_state_machine_change_state(&sci_dev->state_machine, 343 sci_change_state(&sci_dev->sm, SCI_STP_DEV_NCQ_ERROR);
345 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR);
346 } else 344 } else
347 status = SCI_FAILURE; 345 status = SCI_FAILURE;
348 346
349 scic_sds_controller_release_frame(scic, frame_index); 347 scic_sds_controller_release_frame(scic, frame_index);
350 break; 348 break;
351 } 349 }
352 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 350 case SCI_STP_DEV_CMD:
353 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 351 case SCI_SMP_DEV_CMD:
354 /* The device does not process any UF received from the hardware while 352 /* The device does not process any UF received from the hardware while
355 * in this state. All unsolicited frames are forwarded to the io request 353 * in this state. All unsolicited frames are forwarded to the io request
356 * object. 354 * object.
@@ -365,18 +363,18 @@ enum sci_status scic_sds_remote_device_frame_handler(struct scic_sds_remote_devi
365static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev) 363static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev)
366{ 364{
367 365
368 struct sci_base_state_machine *sm = &sci_dev->state_machine; 366 struct sci_base_state_machine *sm = &sci_dev->sm;
369 enum scic_sds_remote_device_states state = sm->current_state_id; 367 enum scic_sds_remote_device_states state = sm->current_state_id;
370 368
371 switch (state) { 369 switch (state) {
372 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 370 case SCI_DEV_READY:
373 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 371 case SCI_STP_DEV_IDLE:
374 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 372 case SCI_STP_DEV_CMD:
375 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: 373 case SCI_STP_DEV_NCQ:
376 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 374 case SCI_STP_DEV_NCQ_ERROR:
377 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 375 case SCI_STP_DEV_AWAIT_RESET:
378 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 376 case SCI_SMP_DEV_IDLE:
379 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 377 case SCI_SMP_DEV_CMD:
380 return true; 378 return true;
381 default: 379 default:
382 return false; 380 return false;
@@ -386,7 +384,7 @@ static bool is_remote_device_ready(struct scic_sds_remote_device *sci_dev)
386enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_device *sci_dev, 384enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_device *sci_dev,
387 u32 event_code) 385 u32 event_code)
388{ 386{
389 struct sci_base_state_machine *sm = &sci_dev->state_machine; 387 struct sci_base_state_machine *sm = &sci_dev->sm;
390 enum scic_sds_remote_device_states state = sm->current_state_id; 388 enum scic_sds_remote_device_states state = sm->current_state_id;
391 enum sci_status status; 389 enum sci_status status;
392 390
@@ -429,7 +427,7 @@ enum sci_status scic_sds_remote_device_event_handler(struct scic_sds_remote_devi
429 if (status != SCI_SUCCESS) 427 if (status != SCI_SUCCESS)
430 return status; 428 return status;
431 429
432 if (state == SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE) { 430 if (state == SCI_STP_DEV_IDLE) {
433 431
434 /* We pick up suspension events to handle specifically to this 432 /* We pick up suspension events to handle specifically to this
435 * state. We resume the RNC right away. 433 * state. We resume the RNC right away.
@@ -459,26 +457,26 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
459 struct scic_sds_remote_device *sci_dev, 457 struct scic_sds_remote_device *sci_dev,
460 struct scic_sds_request *sci_req) 458 struct scic_sds_request *sci_req)
461{ 459{
462 struct sci_base_state_machine *sm = &sci_dev->state_machine; 460 struct sci_base_state_machine *sm = &sci_dev->sm;
463 enum scic_sds_remote_device_states state = sm->current_state_id; 461 enum scic_sds_remote_device_states state = sm->current_state_id;
464 struct scic_sds_port *sci_port = sci_dev->owning_port; 462 struct scic_sds_port *sci_port = sci_dev->owning_port;
465 struct isci_request *ireq = sci_req_to_ireq(sci_req); 463 struct isci_request *ireq = sci_req_to_ireq(sci_req);
466 enum sci_status status; 464 enum sci_status status;
467 465
468 switch (state) { 466 switch (state) {
469 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 467 case SCI_DEV_INITIAL:
470 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 468 case SCI_DEV_STOPPED:
471 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 469 case SCI_DEV_STARTING:
472 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 470 case SCI_STP_DEV_NCQ_ERROR:
473 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 471 case SCI_DEV_STOPPING:
474 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 472 case SCI_DEV_FAILED:
475 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: 473 case SCI_DEV_RESETTING:
476 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 474 case SCI_DEV_FINAL:
477 default: 475 default:
478 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 476 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
479 __func__, state); 477 __func__, state);
480 return SCI_FAILURE_INVALID_STATE; 478 return SCI_FAILURE_INVALID_STATE;
481 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 479 case SCI_DEV_READY:
482 /* attempt to start an io request for this device object. The remote 480 /* attempt to start an io request for this device object. The remote
483 * device object will issue the start request for the io and if 481 * device object will issue the start request for the io and if
484 * successful it will start the request for the port object then 482 * successful it will start the request for the port object then
@@ -494,7 +492,7 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
494 492
495 status = scic_sds_request_start(sci_req); 493 status = scic_sds_request_start(sci_req);
496 break; 494 break;
497 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: { 495 case SCI_STP_DEV_IDLE: {
498 /* handle the start io operation for a sata device that is in 496 /* handle the start io operation for a sata device that is in
499 * the command idle state. - Evalute the type of IO request to 497 * the command idle state. - Evalute the type of IO request to
500 * be started - If its an NCQ request change to NCQ substate - 498 * be started - If its an NCQ request change to NCQ substate -
@@ -519,15 +517,15 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
519 break; 517 break;
520 518
521 if (task->ata_task.use_ncq) 519 if (task->ata_task.use_ncq)
522 new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ; 520 new_state = SCI_STP_DEV_NCQ;
523 else { 521 else {
524 sci_dev->working_request = sci_req; 522 sci_dev->working_request = sci_req;
525 new_state = SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD; 523 new_state = SCI_STP_DEV_CMD;
526 } 524 }
527 sci_base_state_machine_change_state(sm, new_state); 525 sci_change_state(sm, new_state);
528 break; 526 break;
529 } 527 }
530 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: { 528 case SCI_STP_DEV_NCQ: {
531 struct sas_task *task = isci_request_access_task(ireq); 529 struct sas_task *task = isci_request_access_task(ireq);
532 530
533 if (task->ata_task.use_ncq) { 531 if (task->ata_task.use_ncq) {
@@ -544,9 +542,9 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
544 return SCI_FAILURE_INVALID_STATE; 542 return SCI_FAILURE_INVALID_STATE;
545 break; 543 break;
546 } 544 }
547 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 545 case SCI_STP_DEV_AWAIT_RESET:
548 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED; 546 return SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED;
549 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 547 case SCI_SMP_DEV_IDLE:
550 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); 548 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
551 if (status != SCI_SUCCESS) 549 if (status != SCI_SUCCESS)
552 return status; 550 return status;
@@ -560,11 +558,10 @@ enum sci_status scic_sds_remote_device_start_io(struct scic_sds_controller *scic
560 break; 558 break;
561 559
562 sci_dev->working_request = sci_req; 560 sci_dev->working_request = sci_req;
563 sci_base_state_machine_change_state(&sci_dev->state_machine, 561 sci_change_state(&sci_dev->sm, SCI_SMP_DEV_CMD);
564 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD);
565 break; 562 break;
566 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 563 case SCI_STP_DEV_CMD:
567 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 564 case SCI_SMP_DEV_CMD:
568 /* device is already handling a command it can not accept new commands 565 /* device is already handling a command it can not accept new commands
569 * until this one is complete. 566 * until this one is complete.
570 */ 567 */
@@ -597,31 +594,31 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
597 struct scic_sds_remote_device *sci_dev, 594 struct scic_sds_remote_device *sci_dev,
598 struct scic_sds_request *sci_req) 595 struct scic_sds_request *sci_req)
599{ 596{
600 struct sci_base_state_machine *sm = &sci_dev->state_machine; 597 struct sci_base_state_machine *sm = &sci_dev->sm;
601 enum scic_sds_remote_device_states state = sm->current_state_id; 598 enum scic_sds_remote_device_states state = sm->current_state_id;
602 struct scic_sds_port *sci_port = sci_dev->owning_port; 599 struct scic_sds_port *sci_port = sci_dev->owning_port;
603 enum sci_status status; 600 enum sci_status status;
604 601
605 switch (state) { 602 switch (state) {
606 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 603 case SCI_DEV_INITIAL:
607 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 604 case SCI_DEV_STOPPED:
608 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 605 case SCI_DEV_STARTING:
609 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 606 case SCI_STP_DEV_IDLE:
610 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 607 case SCI_SMP_DEV_IDLE:
611 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 608 case SCI_DEV_FAILED:
612 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 609 case SCI_DEV_FINAL:
613 default: 610 default:
614 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 611 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
615 __func__, state); 612 __func__, state);
616 return SCI_FAILURE_INVALID_STATE; 613 return SCI_FAILURE_INVALID_STATE;
617 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 614 case SCI_DEV_READY:
618 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 615 case SCI_STP_DEV_AWAIT_RESET:
619 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: 616 case SCI_DEV_RESETTING:
620 status = common_complete_io(sci_port, sci_dev, sci_req); 617 status = common_complete_io(sci_port, sci_dev, sci_req);
621 break; 618 break;
622 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 619 case SCI_STP_DEV_CMD:
623 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: 620 case SCI_STP_DEV_NCQ:
624 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 621 case SCI_STP_DEV_NCQ_ERROR:
625 status = common_complete_io(sci_port, sci_dev, sci_req); 622 status = common_complete_io(sci_port, sci_dev, sci_req);
626 if (status != SCI_SUCCESS) 623 if (status != SCI_SUCCESS)
627 break; 624 break;
@@ -632,17 +629,17 @@ enum sci_status scic_sds_remote_device_complete_io(struct scic_sds_controller *s
632 * can reach RNC state handler, these IOs will be completed by RNC with 629 * can reach RNC state handler, these IOs will be completed by RNC with
633 * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE". 630 * status of "DEVICE_RESET_REQUIRED", instead of "INVALID STATE".
634 */ 631 */
635 sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET); 632 sci_change_state(sm, SCI_STP_DEV_AWAIT_RESET);
636 } else if (scic_sds_remote_device_get_request_count(sci_dev) == 0) 633 } else if (scic_sds_remote_device_get_request_count(sci_dev) == 0)
637 sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 634 sci_change_state(sm, SCI_STP_DEV_IDLE);
638 break; 635 break;
639 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 636 case SCI_SMP_DEV_CMD:
640 status = common_complete_io(sci_port, sci_dev, sci_req); 637 status = common_complete_io(sci_port, sci_dev, sci_req);
641 if (status != SCI_SUCCESS) 638 if (status != SCI_SUCCESS)
642 break; 639 break;
643 sci_base_state_machine_change_state(sm, SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE); 640 sci_change_state(sm, SCI_SMP_DEV_IDLE);
644 break; 641 break;
645 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 642 case SCI_DEV_STOPPING:
646 status = common_complete_io(sci_port, sci_dev, sci_req); 643 status = common_complete_io(sci_port, sci_dev, sci_req);
647 if (status != SCI_SUCCESS) 644 if (status != SCI_SUCCESS)
648 break; 645 break;
@@ -676,30 +673,30 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
676 struct scic_sds_remote_device *sci_dev, 673 struct scic_sds_remote_device *sci_dev,
677 struct scic_sds_request *sci_req) 674 struct scic_sds_request *sci_req)
678{ 675{
679 struct sci_base_state_machine *sm = &sci_dev->state_machine; 676 struct sci_base_state_machine *sm = &sci_dev->sm;
680 enum scic_sds_remote_device_states state = sm->current_state_id; 677 enum scic_sds_remote_device_states state = sm->current_state_id;
681 struct scic_sds_port *sci_port = sci_dev->owning_port; 678 struct scic_sds_port *sci_port = sci_dev->owning_port;
682 enum sci_status status; 679 enum sci_status status;
683 680
684 switch (state) { 681 switch (state) {
685 case SCI_BASE_REMOTE_DEVICE_STATE_INITIAL: 682 case SCI_DEV_INITIAL:
686 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPED: 683 case SCI_DEV_STOPPED:
687 case SCI_BASE_REMOTE_DEVICE_STATE_STARTING: 684 case SCI_DEV_STARTING:
688 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 685 case SCI_SMP_DEV_IDLE:
689 case SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 686 case SCI_SMP_DEV_CMD:
690 case SCI_BASE_REMOTE_DEVICE_STATE_STOPPING: 687 case SCI_DEV_STOPPING:
691 case SCI_BASE_REMOTE_DEVICE_STATE_FAILED: 688 case SCI_DEV_FAILED:
692 case SCI_BASE_REMOTE_DEVICE_STATE_RESETTING: 689 case SCI_DEV_RESETTING:
693 case SCI_BASE_REMOTE_DEVICE_STATE_FINAL: 690 case SCI_DEV_FINAL:
694 default: 691 default:
695 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 692 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
696 __func__, state); 693 __func__, state);
697 return SCI_FAILURE_INVALID_STATE; 694 return SCI_FAILURE_INVALID_STATE;
698 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE: 695 case SCI_STP_DEV_IDLE:
699 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD: 696 case SCI_STP_DEV_CMD:
700 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ: 697 case SCI_STP_DEV_NCQ:
701 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR: 698 case SCI_STP_DEV_NCQ_ERROR:
702 case SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET: 699 case SCI_STP_DEV_AWAIT_RESET:
703 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); 700 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
704 if (status != SCI_SUCCESS) 701 if (status != SCI_SUCCESS)
705 return status; 702 return status;
@@ -717,7 +714,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
717 * management request. 714 * management request.
718 */ 715 */
719 sci_dev->working_request = sci_req; 716 sci_dev->working_request = sci_req;
720 sci_base_state_machine_change_state(sm, SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD); 717 sci_change_state(sm, SCI_STP_DEV_CMD);
721 718
722 /* The remote node context must cleanup the TCi to NCQ mapping 719 /* The remote node context must cleanup the TCi to NCQ mapping
723 * table. The only way to do this correctly is to either write 720 * table. The only way to do this correctly is to either write
@@ -739,7 +736,7 @@ enum sci_status scic_sds_remote_device_start_task(struct scic_sds_controller *sc
739 * post TC when RNC gets resumed. 736 * post TC when RNC gets resumed.
740 */ 737 */
741 return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS; 738 return SCI_FAILURE_RESET_DEVICE_PARTIAL_SUCCESS;
742 case SCI_BASE_REMOTE_DEVICE_STATE_READY: 739 case SCI_DEV_READY:
743 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req); 740 status = scic_sds_port_start_io(sci_port, sci_dev, sci_req);
744 if (status != SCI_SUCCESS) 741 if (status != SCI_SUCCESS)
745 return status; 742 return status;
@@ -790,8 +787,7 @@ static void remote_device_resume_done(void *_dev)
790 return; 787 return;
791 788
792 /* go 'ready' if we are not already in a ready state */ 789 /* go 'ready' if we are not already in a ready state */
793 sci_base_state_machine_change_state(&sci_dev->state_machine, 790 sci_change_state(&sci_dev->sm, SCI_DEV_READY);
794 SCI_BASE_REMOTE_DEVICE_STATE_READY);
795} 791}
796 792
797static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev) 793static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handler(void *_dev)
@@ -803,17 +799,16 @@ static void scic_sds_stp_remote_device_ready_idle_substate_resume_complete_handl
803 /* For NCQ operation we do not issue a isci_remote_device_not_ready(). 799 /* For NCQ operation we do not issue a isci_remote_device_not_ready().
804 * As a result, avoid sending the ready notification. 800 * As a result, avoid sending the ready notification.
805 */ 801 */
806 if (sci_dev->state_machine.previous_state_id != SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ) 802 if (sci_dev->sm.previous_state_id != SCI_STP_DEV_NCQ)
807 isci_remote_device_ready(scic_to_ihost(scic), idev); 803 isci_remote_device_ready(scic_to_ihost(scic), idev);
808} 804}
809 805
810static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm) 806static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_machine *sm)
811{ 807{
812 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 808 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
813 809
814 /* Initial state is a transitional state to the stopped state */ 810 /* Initial state is a transitional state to the stopped state */
815 sci_base_state_machine_change_state(&sci_dev->state_machine, 811 sci_change_state(&sci_dev->sm, SCI_DEV_STOPPED);
816 SCI_BASE_REMOTE_DEVICE_STATE_STOPPED);
817} 812}
818 813
819/** 814/**
@@ -831,11 +826,11 @@ static void scic_sds_remote_device_initial_state_enter(struct sci_base_state_mac
831 */ 826 */
832static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev) 827static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device *sci_dev)
833{ 828{
834 struct sci_base_state_machine *sm = &sci_dev->state_machine; 829 struct sci_base_state_machine *sm = &sci_dev->sm;
835 enum scic_sds_remote_device_states state = sm->current_state_id; 830 enum scic_sds_remote_device_states state = sm->current_state_id;
836 struct scic_sds_controller *scic; 831 struct scic_sds_controller *scic;
837 832
838 if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { 833 if (state != SCI_DEV_STOPPED) {
839 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 834 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
840 __func__, state); 835 __func__, state);
841 return SCI_FAILURE_INVALID_STATE; 836 return SCI_FAILURE_INVALID_STATE;
@@ -845,7 +840,7 @@ static enum sci_status scic_remote_device_destruct(struct scic_sds_remote_device
845 scic_sds_controller_free_remote_node_context(scic, sci_dev, 840 scic_sds_controller_free_remote_node_context(scic, sci_dev,
846 sci_dev->rnc.remote_node_index); 841 sci_dev->rnc.remote_node_index);
847 sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX; 842 sci_dev->rnc.remote_node_index = SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX;
848 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_FINAL); 843 sci_change_state(sm, SCI_DEV_FINAL);
849 844
850 return SCI_SUCCESS; 845 return SCI_SUCCESS;
851} 846}
@@ -906,7 +901,7 @@ static void isci_remote_device_stop_complete(struct isci_host *ihost,
906 901
907static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm) 902static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_machine *sm)
908{ 903{
909 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 904 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
910 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; 905 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
911 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); 906 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
912 u32 prev_state; 907 u32 prev_state;
@@ -914,8 +909,8 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac
914 /* If we are entering from the stopping state let the SCI User know that 909 /* If we are entering from the stopping state let the SCI User know that
915 * the stop operation has completed. 910 * the stop operation has completed.
916 */ 911 */
917 prev_state = sci_dev->state_machine.previous_state_id; 912 prev_state = sci_dev->sm.previous_state_id;
918 if (prev_state == SCI_BASE_REMOTE_DEVICE_STATE_STOPPING) 913 if (prev_state == SCI_DEV_STOPPING)
919 isci_remote_device_stop_complete(scic_to_ihost(scic), idev); 914 isci_remote_device_stop_complete(scic_to_ihost(scic), idev);
920 915
921 scic_sds_controller_remote_device_stopped(scic, sci_dev); 916 scic_sds_controller_remote_device_stopped(scic, sci_dev);
@@ -923,7 +918,7 @@ static void scic_sds_remote_device_stopped_state_enter(struct sci_base_state_mac
923 918
924static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm) 919static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_machine *sm)
925{ 920{
926 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 921 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
927 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); 922 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
928 struct isci_host *ihost = scic_to_ihost(scic); 923 struct isci_host *ihost = scic_to_ihost(scic);
929 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); 924 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
@@ -934,7 +929,7 @@ static void scic_sds_remote_device_starting_state_enter(struct sci_base_state_ma
934 929
935static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm) 930static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machine *sm)
936{ 931{
937 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 932 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
938 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller; 933 struct scic_sds_controller *scic = sci_dev->owning_port->owning_controller;
939 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); 934 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
940 struct domain_device *dev = idev->domain_dev; 935 struct domain_device *dev = idev->domain_dev;
@@ -942,18 +937,16 @@ static void scic_sds_remote_device_ready_state_enter(struct sci_base_state_machi
942 scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++; 937 scic->remote_device_sequence[sci_dev->rnc.remote_node_index]++;
943 938
944 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) { 939 if (dev->dev_type == SATA_DEV || (dev->tproto & SAS_PROTOCOL_SATA)) {
945 sci_base_state_machine_change_state(&sci_dev->state_machine, 940 sci_change_state(&sci_dev->sm, SCI_STP_DEV_IDLE);
946 SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
947 } else if (dev_is_expander(dev)) { 941 } else if (dev_is_expander(dev)) {
948 sci_base_state_machine_change_state(&sci_dev->state_machine, 942 sci_change_state(&sci_dev->sm, SCI_SMP_DEV_IDLE);
949 SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE);
950 } else 943 } else
951 isci_remote_device_ready(scic_to_ihost(scic), idev); 944 isci_remote_device_ready(scic_to_ihost(scic), idev);
952} 945}
953 946
954static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm) 947static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machine *sm)
955{ 948{
956 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 949 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
957 struct domain_device *dev = sci_dev_to_domain(sci_dev); 950 struct domain_device *dev = sci_dev_to_domain(sci_dev);
958 951
959 if (dev->dev_type == SAS_END_DEV) { 952 if (dev->dev_type == SAS_END_DEV) {
@@ -967,7 +960,7 @@ static void scic_sds_remote_device_ready_state_exit(struct sci_base_state_machin
967 960
968static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm) 961static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_machine *sm)
969{ 962{
970 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 963 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
971 964
972 scic_sds_remote_node_context_suspend( 965 scic_sds_remote_node_context_suspend(
973 &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL); 966 &sci_dev->rnc, SCI_SOFTWARE_SUSPENSION, NULL, NULL);
@@ -975,14 +968,14 @@ static void scic_sds_remote_device_resetting_state_enter(struct sci_base_state_m
975 968
976static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm) 969static void scic_sds_remote_device_resetting_state_exit(struct sci_base_state_machine *sm)
977{ 970{
978 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 971 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
979 972
980 scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL); 973 scic_sds_remote_node_context_resume(&sci_dev->rnc, NULL, NULL);
981} 974}
982 975
983static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) 976static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
984{ 977{
985 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 978 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
986 979
987 sci_dev->working_request = NULL; 980 sci_dev->working_request = NULL;
988 if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) { 981 if (scic_sds_remote_node_context_is_ready(&sci_dev->rnc)) {
@@ -999,7 +992,7 @@ static void scic_sds_stp_remote_device_ready_idle_substate_enter(struct sci_base
999 992
1000static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) 993static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
1001{ 994{
1002 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 995 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
1003 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); 996 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
1004 997
1005 BUG_ON(sci_dev->working_request == NULL); 998 BUG_ON(sci_dev->working_request == NULL);
@@ -1010,7 +1003,7 @@ static void scic_sds_stp_remote_device_ready_cmd_substate_enter(struct sci_base_
1010 1003
1011static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm) 1004static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base_state_machine *sm)
1012{ 1005{
1013 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 1006 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
1014 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); 1007 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
1015 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev); 1008 struct isci_remote_device *idev = sci_dev_to_idev(sci_dev);
1016 1009
@@ -1021,7 +1014,7 @@ static void scic_sds_stp_remote_device_ready_ncq_error_substate_enter(struct sci
1021 1014
1022static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm) 1015static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base_state_machine *sm)
1023{ 1016{
1024 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 1017 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
1025 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); 1018 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
1026 1019
1027 isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev)); 1020 isci_remote_device_ready(scic_to_ihost(scic), sci_dev_to_idev(sci_dev));
@@ -1029,7 +1022,7 @@ static void scic_sds_smp_remote_device_ready_idle_substate_enter(struct sci_base
1029 1022
1030static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm) 1023static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_state_machine *sm)
1031{ 1024{
1032 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 1025 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
1033 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev); 1026 struct scic_sds_controller *scic = scic_sds_remote_device_get_controller(sci_dev);
1034 1027
1035 BUG_ON(sci_dev->working_request == NULL); 1028 BUG_ON(sci_dev->working_request == NULL);
@@ -1040,50 +1033,50 @@ static void scic_sds_smp_remote_device_ready_cmd_substate_enter(struct sci_base_
1040 1033
1041static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm) 1034static void scic_sds_smp_remote_device_ready_cmd_substate_exit(struct sci_base_state_machine *sm)
1042{ 1035{
1043 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), state_machine); 1036 struct scic_sds_remote_device *sci_dev = container_of(sm, typeof(*sci_dev), sm);
1044 1037
1045 sci_dev->working_request = NULL; 1038 sci_dev->working_request = NULL;
1046} 1039}
1047 1040
1048static const struct sci_base_state scic_sds_remote_device_state_table[] = { 1041static const struct sci_base_state scic_sds_remote_device_state_table[] = {
1049 [SCI_BASE_REMOTE_DEVICE_STATE_INITIAL] = { 1042 [SCI_DEV_INITIAL] = {
1050 .enter_state = scic_sds_remote_device_initial_state_enter, 1043 .enter_state = scic_sds_remote_device_initial_state_enter,
1051 }, 1044 },
1052 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPED] = { 1045 [SCI_DEV_STOPPED] = {
1053 .enter_state = scic_sds_remote_device_stopped_state_enter, 1046 .enter_state = scic_sds_remote_device_stopped_state_enter,
1054 }, 1047 },
1055 [SCI_BASE_REMOTE_DEVICE_STATE_STARTING] = { 1048 [SCI_DEV_STARTING] = {
1056 .enter_state = scic_sds_remote_device_starting_state_enter, 1049 .enter_state = scic_sds_remote_device_starting_state_enter,
1057 }, 1050 },
1058 [SCI_BASE_REMOTE_DEVICE_STATE_READY] = { 1051 [SCI_DEV_READY] = {
1059 .enter_state = scic_sds_remote_device_ready_state_enter, 1052 .enter_state = scic_sds_remote_device_ready_state_enter,
1060 .exit_state = scic_sds_remote_device_ready_state_exit 1053 .exit_state = scic_sds_remote_device_ready_state_exit
1061 }, 1054 },
1062 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 1055 [SCI_STP_DEV_IDLE] = {
1063 .enter_state = scic_sds_stp_remote_device_ready_idle_substate_enter, 1056 .enter_state = scic_sds_stp_remote_device_ready_idle_substate_enter,
1064 }, 1057 },
1065 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { 1058 [SCI_STP_DEV_CMD] = {
1066 .enter_state = scic_sds_stp_remote_device_ready_cmd_substate_enter, 1059 .enter_state = scic_sds_stp_remote_device_ready_cmd_substate_enter,
1067 }, 1060 },
1068 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ] = { }, 1061 [SCI_STP_DEV_NCQ] = { },
1069 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_NCQ_ERROR] = { 1062 [SCI_STP_DEV_NCQ_ERROR] = {
1070 .enter_state = scic_sds_stp_remote_device_ready_ncq_error_substate_enter, 1063 .enter_state = scic_sds_stp_remote_device_ready_ncq_error_substate_enter,
1071 }, 1064 },
1072 [SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_AWAIT_RESET] = { }, 1065 [SCI_STP_DEV_AWAIT_RESET] = { },
1073 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_IDLE] = { 1066 [SCI_SMP_DEV_IDLE] = {
1074 .enter_state = scic_sds_smp_remote_device_ready_idle_substate_enter, 1067 .enter_state = scic_sds_smp_remote_device_ready_idle_substate_enter,
1075 }, 1068 },
1076 [SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_CMD] = { 1069 [SCI_SMP_DEV_CMD] = {
1077 .enter_state = scic_sds_smp_remote_device_ready_cmd_substate_enter, 1070 .enter_state = scic_sds_smp_remote_device_ready_cmd_substate_enter,
1078 .exit_state = scic_sds_smp_remote_device_ready_cmd_substate_exit, 1071 .exit_state = scic_sds_smp_remote_device_ready_cmd_substate_exit,
1079 }, 1072 },
1080 [SCI_BASE_REMOTE_DEVICE_STATE_STOPPING] = { }, 1073 [SCI_DEV_STOPPING] = { },
1081 [SCI_BASE_REMOTE_DEVICE_STATE_FAILED] = { }, 1074 [SCI_DEV_FAILED] = { },
1082 [SCI_BASE_REMOTE_DEVICE_STATE_RESETTING] = { 1075 [SCI_DEV_RESETTING] = {
1083 .enter_state = scic_sds_remote_device_resetting_state_enter, 1076 .enter_state = scic_sds_remote_device_resetting_state_enter,
1084 .exit_state = scic_sds_remote_device_resetting_state_exit 1077 .exit_state = scic_sds_remote_device_resetting_state_exit
1085 }, 1078 },
1086 [SCI_BASE_REMOTE_DEVICE_STATE_FINAL] = { }, 1079 [SCI_DEV_FINAL] = { },
1087}; 1080};
1088 1081
1089/** 1082/**
@@ -1102,11 +1095,11 @@ static void scic_remote_device_construct(struct scic_sds_port *sci_port,
1102 sci_dev->owning_port = sci_port; 1095 sci_dev->owning_port = sci_port;
1103 sci_dev->started_request_count = 0; 1096 sci_dev->started_request_count = 0;
1104 1097
1105 sci_base_state_machine_construct(&sci_dev->state_machine, 1098 sci_base_state_machine_construct(&sci_dev->sm,
1106 scic_sds_remote_device_state_table, 1099 scic_sds_remote_device_state_table,
1107 SCI_BASE_REMOTE_DEVICE_STATE_INITIAL); 1100 SCI_DEV_INITIAL);
1108 1101
1109 sci_base_state_machine_start(&sci_dev->state_machine); 1102 sci_base_state_machine_start(&sci_dev->sm);
1110 1103
1111 scic_sds_remote_node_context_construct(&sci_dev->rnc, 1104 scic_sds_remote_node_context_construct(&sci_dev->rnc,
1112 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX); 1105 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX);
@@ -1224,11 +1217,11 @@ static enum sci_status scic_remote_device_ea_construct(struct scic_sds_port *sci
1224static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev, 1217static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *sci_dev,
1225 u32 timeout) 1218 u32 timeout)
1226{ 1219{
1227 struct sci_base_state_machine *sm = &sci_dev->state_machine; 1220 struct sci_base_state_machine *sm = &sci_dev->sm;
1228 enum scic_sds_remote_device_states state = sm->current_state_id; 1221 enum scic_sds_remote_device_states state = sm->current_state_id;
1229 enum sci_status status; 1222 enum sci_status status;
1230 1223
1231 if (state != SCI_BASE_REMOTE_DEVICE_STATE_STOPPED) { 1224 if (state != SCI_DEV_STOPPED) {
1232 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n", 1225 dev_warn(scirdev_to_dev(sci_dev), "%s: in wrong state: %d\n",
1233 __func__, state); 1226 __func__, state);
1234 return SCI_FAILURE_INVALID_STATE; 1227 return SCI_FAILURE_INVALID_STATE;
@@ -1240,7 +1233,7 @@ static enum sci_status scic_remote_device_start(struct scic_sds_remote_device *s
1240 if (status != SCI_SUCCESS) 1233 if (status != SCI_SUCCESS)
1241 return status; 1234 return status;
1242 1235
1243 sci_base_state_machine_change_state(sm, SCI_BASE_REMOTE_DEVICE_STATE_STARTING); 1236 sci_change_state(sm, SCI_DEV_STARTING);
1244 1237
1245 return SCI_SUCCESS; 1238 return SCI_SUCCESS;
1246} 1239}