aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDan Williams <dan.j.williams@intel.com>2011-05-12 11:26:56 -0400
committerDan Williams <dan.j.williams@intel.com>2011-07-03 07:04:49 -0400
commitc845ae96bcb1625a093003248ffaf13b92a81ac2 (patch)
treeeb9a026332b5770783f1f92f7ab72db51b367d73
parent338e386d12c2440e39c987d35fda403d319a79a0 (diff)
isci: unify rnc destruct handlers
Unify rnc destruct handlers and delete the state handler. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
-rw-r--r--drivers/scsi/isci/remote_node_context.c106
-rw-r--r--drivers/scsi/isci/remote_node_context.h13
2 files changed, 39 insertions, 80 deletions
diff --git a/drivers/scsi/isci/remote_node_context.c b/drivers/scsi/isci/remote_node_context.c
index 9f2407f0f5a6..769a3fc6ec4b 100644
--- a/drivers/scsi/isci/remote_node_context.c
+++ b/drivers/scsi/isci/remote_node_context.c
@@ -218,26 +218,6 @@ static enum sci_status scic_sds_remote_node_context_continue_to_resume_handler(
218 return SCI_FAILURE_INVALID_STATE; 218 return SCI_FAILURE_INVALID_STATE;
219} 219}
220 220
221/* --------------------------------------------------------------------------- */
222
223static enum sci_status scic_sds_remote_node_context_default_destruct_handler(
224 struct scic_sds_remote_node_context *sci_rnc,
225 scics_sds_remote_node_context_callback callback,
226 void *callback_parameter)
227{
228 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
229 "%s: SCIC Remote Node Context 0x%p requested to stop while "
230 "in unexpected state %d\n",
231 __func__,
232 sci_rnc,
233 sci_base_state_machine_get_state(&sci_rnc->state_machine));
234
235 /*
236 * We have decided that the destruct request on the remote node context can not fail
237 * since it is either in the initial/destroyed state or is can be destroyed. */
238 return SCI_SUCCESS;
239}
240
241static enum sci_status scic_sds_remote_node_context_default_suspend_handler( 221static enum sci_status scic_sds_remote_node_context_default_suspend_handler(
242 struct scic_sds_remote_node_context *sci_rnc, 222 struct scic_sds_remote_node_context *sci_rnc,
243 u32 suspend_type, 223 u32 suspend_type,
@@ -315,36 +295,6 @@ static enum sci_status scic_sds_remote_node_context_success_start_task_handler(
315 return SCI_SUCCESS; 295 return SCI_SUCCESS;
316} 296}
317 297
318/**
319 *
320 * @sci_rnc:
321 * @callback:
322 * @callback_parameter:
323 *
324 * This method handles destruct calls from the various state handlers. The
325 * remote node context can be requested to destroy from any state. If there was
326 * a user callback it is always replaced with the request to destroy user
327 * callback. enum sci_status
328 */
329static enum sci_status scic_sds_remote_node_context_general_destruct_handler(
330 struct scic_sds_remote_node_context *sci_rnc,
331 scics_sds_remote_node_context_callback callback,
332 void *callback_parameter)
333{
334 scic_sds_remote_node_context_setup_to_destory(
335 sci_rnc, callback, callback_parameter
336 );
337
338 sci_base_state_machine_change_state(
339 &sci_rnc->state_machine,
340 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE
341 );
342
343 return SCI_SUCCESS;
344}
345
346/* --------------------------------------------------------------------------- */
347
348static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler( 298static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler(
349 struct scic_sds_remote_node_context *sci_rnc, 299 struct scic_sds_remote_node_context *sci_rnc,
350 scics_sds_remote_node_context_callback callback, 300 scics_sds_remote_node_context_callback callback,
@@ -368,18 +318,6 @@ static enum sci_status scic_sds_remote_node_context_initial_state_resume_handler
368 return SCI_FAILURE_INVALID_STATE; 318 return SCI_FAILURE_INVALID_STATE;
369} 319}
370 320
371static enum sci_status scic_sds_remote_node_context_invalidating_state_destruct_handler(
372 struct scic_sds_remote_node_context *sci_rnc,
373 scics_sds_remote_node_context_callback callback,
374 void *callback_parameter)
375{
376 scic_sds_remote_node_context_setup_to_destory(
377 sci_rnc, callback, callback_parameter
378 );
379
380 return SCI_SUCCESS;
381}
382
383/** 321/**
384 * 322 *
385 * @sci_rnc: The remote node context object being suspended. 323 * @sci_rnc: The remote node context object being suspended.
@@ -539,56 +477,48 @@ static enum sci_status scic_sds_remote_node_context_await_suspension_state_start
539 477
540static struct scic_sds_remote_node_context_handlers scic_sds_remote_node_context_state_handler_table[] = { 478static struct scic_sds_remote_node_context_handlers scic_sds_remote_node_context_state_handler_table[] = {
541 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = { 479 [SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE] = {
542 .destruct_handler = scic_sds_remote_node_context_default_destruct_handler,
543 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 480 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
544 .resume_handler = scic_sds_remote_node_context_initial_state_resume_handler, 481 .resume_handler = scic_sds_remote_node_context_initial_state_resume_handler,
545 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 482 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
546 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler, 483 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
547 }, 484 },
548 [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = { 485 [SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE] = {
549 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
550 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 486 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
551 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler, 487 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
552 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 488 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
553 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler, 489 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
554 }, 490 },
555 [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = { 491 [SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE] = {
556 .destruct_handler = scic_sds_remote_node_context_invalidating_state_destruct_handler,
557 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 492 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
558 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler, 493 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
559 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 494 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
560 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler, 495 .start_task_handler = scic_sds_remote_node_context_default_start_task_handler,
561 }, 496 },
562 [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = { 497 [SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE] = {
563 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
564 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 498 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
565 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler, 499 .resume_handler = scic_sds_remote_node_context_continue_to_resume_handler,
566 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 500 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
567 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler, 501 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
568 }, 502 },
569 [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = { 503 [SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE] = {
570 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
571 .suspend_handler = scic_sds_remote_node_context_ready_state_suspend_handler, 504 .suspend_handler = scic_sds_remote_node_context_ready_state_suspend_handler,
572 .resume_handler = scic_sds_remote_node_context_default_resume_handler, 505 .resume_handler = scic_sds_remote_node_context_default_resume_handler,
573 .start_io_handler = scic_sds_remote_node_context_ready_state_start_io_handler, 506 .start_io_handler = scic_sds_remote_node_context_ready_state_start_io_handler,
574 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler, 507 .start_task_handler = scic_sds_remote_node_context_success_start_task_handler,
575 }, 508 },
576 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = { 509 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE] = {
577 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
578 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 510 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
579 .resume_handler = scic_sds_remote_node_context_tx_suspended_state_resume_handler, 511 .resume_handler = scic_sds_remote_node_context_tx_suspended_state_resume_handler,
580 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 512 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
581 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler, 513 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
582 }, 514 },
583 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = { 515 [SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE] = {
584 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
585 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 516 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
586 .resume_handler = scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler, 517 .resume_handler = scic_sds_remote_node_context_tx_rx_suspended_state_resume_handler,
587 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 518 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
588 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler, 519 .start_task_handler = scic_sds_remote_node_context_suspended_start_task_handler,
589 }, 520 },
590 [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = { 521 [SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE] = {
591 .destruct_handler = scic_sds_remote_node_context_general_destruct_handler,
592 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler, 522 .suspend_handler = scic_sds_remote_node_context_default_suspend_handler,
593 .resume_handler = scic_sds_remote_node_context_await_suspension_state_resume_handler, 523 .resume_handler = scic_sds_remote_node_context_await_suspension_state_resume_handler,
594 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler, 524 .start_io_handler = scic_sds_remote_node_context_default_start_io_handler,
@@ -1023,3 +953,39 @@ enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remot
1023 return SCI_FAILURE; 953 return SCI_FAILURE;
1024 954
1025} 955}
956
957enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_node_context *sci_rnc,
958 scics_sds_remote_node_context_callback cb_fn,
959 void *cb_p)
960{
961 enum scis_sds_remote_node_context_states state;
962
963 state = sci_rnc->state_machine.current_state_id;
964 switch (state) {
965 case SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE:
966 scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
967 return SCI_SUCCESS;
968 case SCIC_SDS_REMOTE_NODE_CONTEXT_POSTING_STATE:
969 case SCIC_SDS_REMOTE_NODE_CONTEXT_RESUMING_STATE:
970 case SCIC_SDS_REMOTE_NODE_CONTEXT_READY_STATE:
971 case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_SUSPENDED_STATE:
972 case SCIC_SDS_REMOTE_NODE_CONTEXT_TX_RX_SUSPENDED_STATE:
973 case SCIC_SDS_REMOTE_NODE_CONTEXT_AWAIT_SUSPENSION_STATE:
974 scic_sds_remote_node_context_setup_to_destory(sci_rnc, cb_fn, cb_p);
975 sci_base_state_machine_change_state(&sci_rnc->state_machine,
976 SCIC_SDS_REMOTE_NODE_CONTEXT_INVALIDATING_STATE);
977 return SCI_SUCCESS;
978 case SCIC_SDS_REMOTE_NODE_CONTEXT_INITIAL_STATE:
979 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
980 "%s: invalid state %d\n", __func__, state);
981 /* We have decided that the destruct request on the remote node context
982 * can not fail since it is either in the initial/destroyed state or is
983 * can be destroyed.
984 */
985 return SCI_SUCCESS;
986 default:
987 dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
988 "%s: invalid state %d\n", __func__, state);
989 return SCI_FAILURE_INVALID_STATE;
990 }
991}
diff --git a/drivers/scsi/isci/remote_node_context.h b/drivers/scsi/isci/remote_node_context.h
index fb93f09d4df6..1cd323438292 100644
--- a/drivers/scsi/isci/remote_node_context.h
+++ b/drivers/scsi/isci/remote_node_context.h
@@ -104,12 +104,6 @@ typedef enum sci_status (*scic_sds_remote_node_context_io_request)(
104 104
105struct scic_sds_remote_node_context_handlers { 105struct scic_sds_remote_node_context_handlers {
106 /** 106 /**
107 * This handle is invoked to stop the RNC. The callback is invoked when after
108 * the hardware notification that the RNC has been invalidated.
109 */
110 scic_sds_remote_node_context_operation destruct_handler;
111
112 /**
113 * This handler is invoked when there is a request to suspend the RNC. The 107 * This handler is invoked when there is a request to suspend the RNC. The
114 * callback is invoked after the hardware notification that the remote node is 108 * callback is invoked after the hardware notification that the remote node is
115 * suspended. 109 * suspended.
@@ -260,19 +254,18 @@ bool scic_sds_remote_node_context_is_ready(
260#define scic_sds_remote_node_context_get_remote_node_index(rcn) \ 254#define scic_sds_remote_node_context_get_remote_node_index(rcn) \
261 ((rnc)->remote_node_index) 255 ((rnc)->remote_node_index)
262 256
263
264enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc, 257enum sci_status scic_sds_remote_node_context_event_handler(struct scic_sds_remote_node_context *sci_rnc,
265 u32 event_code); 258 u32 event_code);
266 259
260enum sci_status scic_sds_remote_node_context_destruct(struct scic_sds_remote_node_context *sci_rnc,
261 scics_sds_remote_node_context_callback callback,
262 void *callback_parameter);
267#define scic_sds_remote_node_context_resume(rnc, callback, parameter) \ 263#define scic_sds_remote_node_context_resume(rnc, callback, parameter) \
268 ((rnc)->state_handlers->resume_handler(rnc, callback, parameter)) 264 ((rnc)->state_handlers->resume_handler(rnc, callback, parameter))
269 265
270#define scic_sds_remote_node_context_suspend(rnc, suspend_type, callback, parameter) \ 266#define scic_sds_remote_node_context_suspend(rnc, suspend_type, callback, parameter) \
271 ((rnc)->state_handlers->suspend_handler(rnc, suspend_type, callback, parameter)) 267 ((rnc)->state_handlers->suspend_handler(rnc, suspend_type, callback, parameter))
272 268
273#define scic_sds_remote_node_context_destruct(rnc, callback, parameter) \
274 ((rnc)->state_handlers->destruct_handler(rnc, callback, parameter))
275
276#define scic_sds_remote_node_context_start_io(rnc, request) \ 269#define scic_sds_remote_node_context_start_io(rnc, request) \
277 ((rnc)->state_handlers->start_io_handler(rnc, request)) 270 ((rnc)->state_handlers->start_io_handler(rnc, request))
278 271