remote node context rework
Subsystems (2)
cover remote node context rework
This series is unfortunately being posted during the merge window but has been in development since the beginning of February. Part of the delay in getting it posted was due to waiting for the libsas error-handling and hotplug work to stabilize, and waiting for the full test results to come back showing that this development topic was effective.
With these patches, on top of the libsas changes, our hotplug / exception handling tests are now passing. Previously we were seeing frequent system crashes and sometimes locking up the silicon. I will let Jeff describe the technical changes in more detail, but it bears pointing out that this comes with a modest but welcome cleanup of the code complexity:
15 files changed, 1316 insertions(+), 1633 deletions(-)
Also available via:
git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git isci-rnc-v1
...this topic builds on top of isci-for-3.4-v4.
--
Dan
From: Jeff Skirvin
In the controller, devices as they appear on a SAS domain (or direct-attached SATA devices) are represented by memory structures known as "Remote Node Contexts" (RNCs). These structures are transferred from main memory to the controller using a set of register commands; these commands include setting up the context ("posting"), removing the context ("invalidating"), and commands to control the scheduling of commands and connections to that remote device ("suspensions" and "resumptions"). There is a similar path to control RNC scheduling from the protocol engine, which interprets the results of command and data transmission and reception.
In general, the controller chooses among non-suspended RNCs to find one that has work requiring scheduling the transmission of command and data frames to a target. Likewise, when a target tries to return data back to the initiator, the state of the RNC is used by the controller to determine how to treat the incoming request. As an example, if the RNC is in the state "TX/RX Suspended", incoming SSP connection requests from the target will be rejected by the controller hardware. When an RNC is "TX Suspended", it will not be selected by the controller hardware to start outgoing command or data operations (with certain priority-based exceptions).
As mentioned above, there are two sources for management of the RNC
states: commands from driver software, and the result of transmission and reception conditions of commands and data signaled by the controller hardware. As an example of the latter, if an outgoing SSP command ends with a OPEN_REJECT(BAD_DESTINATION) status, the RNC state will transition to the "TX Suspended" state, and this is signaled by the controller hardware in the status to the completion of the pending command as well as signaled in a controller hardware event. Examples of the former are included in the patch changelogs.
Driver software is required to suspend the RNC in a "TX/RX Suspended" condition before any outstanding commands can be terminated. Failure to guarantee this can lead to a complete hardware hang condition. Earlier versions of the driver software did not guarantee that an RNC was correctly managed before I/O termination, and so operated in an unsafe way.
Further, the driver performed unnecessary contortions to preserve the remote device command state and so was more complicated than it needed to be. A simplifying driver assumption is that once an I/O has entered the error handler path without having completed in the target, the requirement on the driver is that all use of the sas_task must end. Beyond that, recovery of operation is dependent on libsas and other components to reset, rediscover and reconfigure the device before normal operation can restart. In the driver, this simplifying assumption meant that the RNC management could be reduced to entry into the suspended state, terminating the targeted I/O request, and resuming the RNC as needed for device-specific management such as an SSP Abort Task or LUN Reset Management request.
---
Jeff Skirvin (37):
isci: Manage the link layer hang detect timer for RNC suspensions.
isci: Fixed bug in resumption from RNC Tx/Rx suspend state.
isci: Handle all suspending TC completions
isci: Terminate outstanding TCs on TX/RX RNC suspensions.
isci: Manage device suspensions during TC terminations.
isci: Remote device must be suspended for NCQ cleanup.
isci: Remote device stop also suspends the RNC and terminates I/O.
isci: Escalate to I_T_Nexus_Reset when the device is gone.
isci: Redesign device suspension, abort, cleanup.
isci: Add suspension cases for RNC INVALIDATING, POSTING states.
isci: Device access in the error path does not depend on IDEV_GONE.
isci: All pending TCs are terminated when the RNC is invalidated.
isci: Only set IDEV_GONE in the device stop path.
isci: Remove isci_device reqs_in_process and dev_node from isci_device.
isci: Distinguish between remote device suspension cases
isci: Fix the terminated I/O to not call sas_task_abort().
isci: Save the suspension hint for upcoming suspensions.
isci: Manage the LLHANG timer enable/disable per-device.
isci: Make sure all TCs are terminated and cleaned in LUN reset.
isci: Implement waiting for suspend in the abort path.
isci: When in the abort path, defeat other resume calls until done.
isci: Callbacks to libsas occur under scic_lock and are synchronized.
isci: Manage tag releases differently when aborting tasks.
isci: Fix RNC suspend call for SCI_RESUMING state.
isci: Wait for RNC resumption before leaving the abort path.
isci: Directly control IREQ_ABORT_PATH_ACTIVE when completing TMFs.
isci: Add protocol indicator for TMF requests.
isci: Added timeouts to RNC suspensions in the abort path.
isci: Change the phy control and link reset interface for HW reasons.
isci: Don't wait for an RNC suspend if it's being destroyed.
isci: Restore the ATAPI device RNC management code.
isci: Check IDEV_GONE before performing abort path operations.
isci: Remove obviated host callback list.
isci: Manage the IREQ_NO_AUTO_FREE_TAG under scic_lock.
isci: Fix RNC AWAIT_SUSPENSION->INVALIDATING transition.
isci: Fixed RNC bug that lost the suspension or resumption during destroy
isci: End the RNC resumption wait when the RNC is destroyed.
drivers/scsi/isci/host.c | 143 ++--- drivers/scsi/isci/host.h | 8 drivers/scsi/isci/init.c | 3 drivers/scsi/isci/phy.c | 2 drivers/scsi/isci/port.c | 45 +- drivers/scsi/isci/port.h | 5 drivers/scsi/isci/remote_device.c | 547 ++++++++++++++++----- drivers/scsi/isci/remote_device.h | 62 ++ drivers/scsi/isci/remote_node_context.c | 345 ++++++++++--- drivers/scsi/isci/remote_node_context.h | 43 +- drivers/scsi/isci/request.c | 696 +++++++++++--------------- drivers/scsi/isci/request.h | 116 ---- drivers/scsi/isci/scu_completion_codes.h | 2 drivers/scsi/isci/task.c | 800 +++++------------------------- drivers/scsi/isci/task.h | 132 ----- 15 files changed, 1316 insertions(+), 1633 deletions(-)
PATCH 1/37 isci: Manage the link layer hang detect timer for RNC suspensions.
From: Jeff Skirvin <[email protected]>
For STP devices under certain protocol conditions, an RNC will not suspend until the current transfer state is broken with a SYNC/ESC sequence from the SCU. The SYNC/ESC driven by expiration of the SCU link layer hang detect timer, which has too small a dynamic range to support slow SATA devices, so normally it is disabled.
This change enables the timer with the minimum period at the point when the suspension is requested.
Note that there is potential collateral damage to other open connections to slow SATA devices on the same port, since there is no alternative but to enable the LLHANG timer on every phy in the port for the current suspension request - there is no way to tell on which phy the RNC in question is currently active.
--- drivers/scsi/isci/port.c | 26 +++++++++++++++++++++++++- drivers/scsi/isci/port.h | 5 +++++ drivers/scsi/isci/remote_device.h | 7 +++++++ drivers/scsi/isci/remote_node_context.c | 15 ++++++++++++++- 4 files changed, 51 insertions(+), 2 deletions(-)
drivers/scsi/isci/port.c +25 -1
@@ -1546,6 +1546,29 @@ static void sci_port_failed_state_enter(struct sci_base_state_machine *sm)isci_port_hard_reset_complete (iport,SCI_FAILURE_TIMEOUT ); } +void sci_port_set_hang_detection_timeout (struct isci_port *iport,u32 timeout) +{ +int phy_index; +u32 phy_mask = iport->active_phy_mask; + +if (timeout) + ++iport->hang_detect_users; +else if (iport->hang_detect_users >1 ) + --iport->hang_detect_users; +else + iport->hang_detect_users =0 ; + +if (timeout || (iport->hang_detect_users ==0 )) { +for (phy_index =0 ; phy_index <SCI_MAX_PHYS ; phy_index++) { +if ((phy_mask >> phy_index) &1 ) { +writel (timeout, + &iport->phy_table[phy_index] + ->link_layer_registers + ->link_layer_hang_detection_timeout); + } + } + } +}/* --------------------------------------------------------------------------- */ static const struct sci_base_state sci_port_state_table[] = {
@@ -1594,6 +1617,7 @@ void sci_port_construct(struct isci_port *iport, u8 index, iport->started_request_count =0 ; iport->assigned_device_count =0 ; + iport->hang_detect_users =0 ; iport->reserved_rni =SCU_DUMMY_INDEX ; iport->reserved_tag =SCI_CONTROLLER_INVALID_IO_TAG ;
@@ -1731,7 +1755,7 @@ void isci_port_formed(struct asd_sas_phy *phy)struct isci_host *ihost = phy->ha->lldd_ha;struct isci_phy *iphy =to_iphy (phy);struct asd_sas_port *port = phy->port; -struct isci_port *iport; +struct isci_port *iport =NULL ;unsigned long flags;int i;
drivers/scsi/isci/port.h +5 -0
@@ -111,6 +111,7 @@ struct isci_port {u16 reserved_tag;u32 started_request_count;u32 assigned_device_count; +u32 hang_detect_users;u32 not_ready_reason;struct isci_phy *phy_table[SCI_MAX_PHYS ];struct isci_host *owning_controller;
@@ -269,6 +270,10 @@ void sci_port_get_attached_sas_address(struct isci_port *iport, struct sci_sas_address *sas_address); +void sci_port_set_hang_detection_timeout ( +struct isci_port *isci_port, +u32 timeout); +void isci_port_formed (struct asd_sas_phy *);void isci_port_deformed (struct asd_sas_phy *);
drivers/scsi/isci/remote_device.h +7 -0
@@ -301,6 +301,13 @@ static inline void sci_remote_device_decrement_request_count(struct isci_remote_ idev->started_request_count--; } +static inline void isci_dev_set_hang_detection_timeout ( +struct isci_remote_device *idev, +u32 timeout) +{ +sci_port_set_hang_detection_timeout (idev->owning_port, timeout); +} +enum sci_status sci_remote_device_frame_handler (struct isci_remote_device *idev,u32 frame_index);
drivers/scsi/isci/remote_node_context.c +14 -1
@@ -316,6 +316,15 @@ static void sci_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_sci_remote_node_context_continue_state_transitions (rnc); } +static void sci_remote_node_context_await_suspend_state_exit ( +struct sci_base_state_machine *sm) +{ +struct sci_remote_node_context *rnc + =container_of (sm,typeof (*rnc), sm); + +isci_dev_set_hang_detection_timeout (rnc_to_dev (rnc),0 ); +} +static const struct sci_base_state sci_remote_node_context_state_table[] = { [SCI_RNC_INITIAL ] = { .enter_state = sci_remote_node_context_initial_state_enter,
@@ -338,7 +347,9 @@ static const struct sci_base_state sci_remote_node_context_state_table[] = { [SCI_RNC_TX_RX_SUSPENDED ] = { .enter_state = sci_remote_node_context_tx_rx_suspended_state_enter, }, - [SCI_RNC_AWAIT_SUSPENSION] = { }, + [SCI_RNC_AWAIT_SUSPENSION ] = { + .exit_state = sci_remote_node_context_await_suspend_state_exit, + }, }; void sci_remote_node_context_construct(struct sci_remote_node_context *rnc,
@@ -513,6 +524,8 @@ enum sci_status sci_remote_node_context_suspend(struct sci_remote_node_context *if (suspend_type ==SCI_SOFTWARE_SUSPENSION ) {sci_remote_device_post_request (rnc_to_dev (sci_rnc),SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX ); +isci_dev_set_hang_detection_timeout (rnc_to_dev (sci_rnc), +0x00000001 ); }sci_change_state (&sci_rnc->sm,SCI_RNC_AWAIT_SUSPENSION );
PATCH 2/37 isci: Fixed bug in resumption from RNC Tx/Rx suspend state.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
The resumption from the Tx/Rx suspended state should work the same as the Tx suspended state.
--- drivers/scsi/isci/remote_node_context.c | 12 +++++++----- 1 files changed, 7 insertions(+), 5 deletions(-)
drivers/scsi/isci/remote_node_context.c +7 -5
@@ -557,10 +557,16 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *s sci_rnc->user_callback = cb_fn; sci_rnc->user_cookie = cb_p;return SCI_SUCCESS ; -case SCI_RNC_TX_SUSPENDED : { +case SCI_RNC_TX_SUSPENDED : +case SCI_RNC_TX_RX_SUSPENDED : {struct isci_remote_device *idev =rnc_to_dev (sci_rnc);struct domain_device *dev = idev->domain_dev; +/* If this is an expander attached SATA device we must +* invalidate and repost the RNC since this is the only way +* to clear the TCi to NCQ tag mapping table for the RNi. +* All other device types we can just resume. +*/ sci_remote_node_context_setup_to_resume (sci_rnc, cb_fn, cb_p);if (dev_is_sata (dev) && dev->parent)
@@ -569,10 +575,6 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *ssci_change_state (&sci_rnc->sm,SCI_RNC_RESUMING );return SCI_SUCCESS ; } -case SCI_RNC_TX_RX_SUSPENDED : -sci_remote_node_context_setup_to_resume (sci_rnc, cb_fn, cb_p); -sci_change_state (&sci_rnc->sm,SCI_RNC_RESUMING ); -return SCI_FAILURE_INVALID_STATE ;case SCI_RNC_AWAIT_SUSPENSION :sci_remote_node_context_setup_to_resume (sci_rnc, cb_fn, cb_p);return SCI_SUCCESS ;
PATCH 3/37 isci: Handle all suspending TC completions
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Add comprehensive decode for all TC completions that generate RNC suspensions.
Note that this commit also removes unconditional resumptions of ATAPI devices when in the SCI_STP_DEV_ATAPI_ERROR state, and STP devices when in the SCI_STP_DEV_IDLE state. This is because the SCI_STP_DEV_IDLE and SCI_STP_DEV_ATAPI state entry functions manage the RNC resumption.
--- drivers/scsi/isci/remote_device.c | 86 ++++++++--------- drivers/scsi/isci/remote_device.h | 4 - drivers/scsi/isci/remote_node_context.c | 74 ++++++++++----- drivers/scsi/isci/remote_node_context.h | 13 ++- drivers/scsi/isci/request.c | 149 ++++++++++++++++++++++++++++-- drivers/scsi/isci/request.h | 1 drivers/scsi/isci/scu_completion_codes.h | 2 7 files changed, 242 insertions(+), 87 deletions(-)
drivers/scsi/isci/remote_device.c +42 -44
@@ -265,20 +265,12 @@ enum sci_status sci_remote_device_reset_complete(struct isci_remote_device *idevreturn SCI_SUCCESS ; } -enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev, -u32 suspend_type) +enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev) { -struct sci_base_state_machine *sm = &idev->sm; -enum sci_remote_device_states state = sm->current_state_id; - -if (state !=SCI_STP_DEV_CMD ) { -dev_warn (scirdev_to_dev (idev),"%s: in wrong state: %s\n" , - __func__,dev_state_name (state)); -return SCI_FAILURE_INVALID_STATE ; - } -return sci_remote_node_context_suspend (&idev->rnc, - suspend_type,NULL ,NULL ); +SCI_SOFTWARE_SUSPENSION , +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , +NULL ,NULL ); } enum sci_status sci_remote_device_frame_handler(struct isci_remote_device *idev,
@@ -412,8 +404,6 @@ static void atapi_remote_device_resume_done(void *_dev)enum sci_status sci_remote_device_event_handler (struct isci_remote_device *idev,u32 event_code) { -struct sci_base_state_machine *sm = &idev->sm; -enum sci_remote_device_states state = sm->current_state_id;enum sci_status status;switch (scu_get_event_type (event_code)) {
@@ -427,9 +417,11 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, status =SCI_SUCCESS ;/* Suspend the associated RNC */ -sci_remote_node_context_suspend (&idev->rnc, -SCI_SOFTWARE_SUSPENSION , -NULL ,NULL ); +sci_remote_node_context_suspend ( + &idev->rnc, +SCI_SOFTWARE_SUSPENSION , +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , +NULL ,NULL ); dev_dbg(scirdev_to_dev(idev), "%s: device: %p event code: %x: %s\n",
@@ -455,26 +447,6 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev,if (status !=SCI_SUCCESS )return status; -if (state ==SCI_STP_DEV_ATAPI_ERROR ) { -/* For ATAPI error state resume the RNC right away. */ -if (scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX || -scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX ) { -return sci_remote_node_context_resume (&idev->rnc, - atapi_remote_device_resume_done, - idev); - } - } - -if (state ==SCI_STP_DEV_IDLE ) { - -/* We pick up suspension events to handle specifically to this -* state. We resume the RNC right away. -*/ -if (scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX || -scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX ) - status =sci_remote_node_context_resume (&idev->rnc,NULL ,NULL ); - } -return status; }
@@ -765,11 +737,11 @@ enum sci_status sci_remote_device_start_task(struct isci_host *ihost,* the correct action when the remote node context is suspended * and later resumed. */ -sci_remote_node_context_suspend (&idev->rnc, -SCI_SOFTWARE_SUSPENSION ,NULL ,NULL ); -sci_remote_node_context_resume (&idev->rnc, - sci_remote_device_continue_request, - idev); +sci_remote_node_context_suspend ( + &idev->rnc,SCI_SOFTWARE_SUSPENSION , +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); +sci_remote_node_context_resume ( + &idev->rnc, sci_remote_device_continue_request, idev); out:sci_remote_device_start_request (idev, ireq, status);
@@ -954,14 +926,23 @@ static void sci_remote_device_ready_state_exit(struct sci_base_state_machine *smstatic void sci_remote_device_resetting_state_enter (struct sci_base_state_machine *sm) {struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm); +struct isci_host *ihost = idev->owning_port->owning_controller; + +dev_dbg (&ihost->pdev->dev, +"%s: isci_device = %p\n" , __func__, idev);sci_remote_node_context_suspend ( - &idev->rnc,SCI_SOFTWARE_SUSPENSION ,NULL ,NULL ); + &idev->rnc,SCI_SOFTWARE_SUSPENSION , +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); }static void sci_remote_device_resetting_state_exit (struct sci_base_state_machine *sm) {struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm); +struct isci_host *ihost = idev->owning_port->owning_controller; + +dev_dbg (&ihost->pdev->dev, +"%s: isci_device = %p\n" , __func__, idev);sci_remote_node_context_resume (&idev->rnc,NULL ,NULL ); }
@@ -1004,6 +985,21 @@ static void sci_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base idev->not_ready_reason); } +static void sci_stp_remote_device_atapi_error_substate_enter ( +struct sci_base_state_machine *sm) +{ +struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm); + +/* This state is entered when an I/O is decoded with an error +* condition. By this point the RNC expected suspension state is set. +* The error conditions suspend the device, so unsuspend here if +* possible. +*/ +sci_remote_node_context_resume (&idev->rnc, + atapi_remote_device_resume_done, + idev); +} +static void sci_smp_remote_device_ready_idle_substate_enter (struct sci_base_state_machine *sm) {struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm);
@@ -1054,7 +1050,9 @@ static const struct sci_base_state sci_remote_device_state_table[] = { [SCI_STP_DEV_NCQ_ERROR] = { .enter_state = sci_stp_remote_device_ready_ncq_error_substate_enter, }, - [SCI_STP_DEV_ATAPI_ERROR] = { }, + [SCI_STP_DEV_ATAPI_ERROR] = { + .enter_state = sci_stp_remote_device_atapi_error_substate_enter, + }, [SCI_STP_DEV_AWAIT_RESET] = { }, [SCI_SMP_DEV_IDLE] = { .enter_state = sci_smp_remote_device_ready_idle_substate_enter,
drivers/scsi/isci/remote_device.h +0 -4
@@ -331,10 +331,6 @@ enum sci_status sci_remote_device_complete_io(struct isci_remote_device *idev, struct isci_request *ireq); -enum sci_status sci_remote_device_suspend ( -struct isci_remote_device *idev, -u32 suspend_type); -void sci_remote_device_post_request (struct isci_remote_device *idev,u32 request);
drivers/scsi/isci/remote_node_context.c +51 -23
117 lines not on this page · raw message
drivers/scsi/isci/remote_node_context.h +9 -4
@@ -75,8 +75,12 @@*/ #define SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX 0x0FFF -#define SCU_HARDWARE_SUSPENSION (0) -#define SCI_SOFTWARE_SUSPENSION (1) +enum sci_remote_node_suspension_reasons { +SCU_HARDWARE_SUSPENSION , +SCI_SOFTWARE_SUSPENSION +}; +#define SCI_SOFTWARE_SUSPEND_CMD SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX +#define SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT SCU_EVENT_TL_RNC_SUSPEND_TX_RXstruct isci_request ;struct isci_remote_device ;
@@ -156,10 +160,10 @@ struct sci_remote_node_context {u16 remote_node_index;/** -* This field is the recored suspension code or the reason for the remote node +* This field is the recored suspension type of the remote node * context suspension. */ -u32 suspension_code; +u32 suspend_type;/** * This field is true if the remote node context is resuming from its current
@@ -200,6 +204,7 @@ enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context void *callback_parameter);enum sci_status sci_remote_node_context_suspend (struct sci_remote_node_context *sci_rnc,u32 suspend_type, +u32 suspension_code,scics_sds_remote_node_context_callback cb_fn,void *cb_p); enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *sci_rnc,
drivers/scsi/isci/request.c +138 -11
175 lines not on this page · raw message
drivers/scsi/isci/request.h +0 -1
@@ -414,5 +414,4 @@ static inline int isci_task_is_ncq_recovery(struct sas_task *task) task->ata_task.fis.lbal == ATA_LOG_SATA_NCQ); } -#endif /* !defined(_ISCI_REQUEST_H_) */
drivers/scsi/isci/scu_completion_codes.h +2 -0
@@ -224,6 +224,7 @@* 32-bit value like we want, each immediate value must be cast to a u32. */ #define SCU_TASK_DONE_GOOD ((u32)0x00) +#define SCU_TASK_DONE_TX_RAW_CMD_ERR ((u32)0x08)#define SCU_TASK_DONE_CRC_ERR ((u32)0x14)#define SCU_TASK_DONE_CHECK_RESPONSE ((u32)0x14)#define SCU_TASK_DONE_GEN_RESPONSE ((u32)0x15)
@@ -237,6 +238,7 @@#define SCU_TASK_DONE_LL_LF_TERM ((u32)0x1A)#define SCU_TASK_DONE_DATA_LEN_ERR ((u32)0x1A)#define SCU_TASK_DONE_LL_CL_TERM ((u32)0x1B) +#define SCU_TASK_DONE_BREAK_RCVD ((u32)0x1B)#define SCU_TASK_DONE_LL_ABORT_ERR ((u32)0x1B)#define SCU_TASK_DONE_SEQ_INV_TYPE ((u32)0x1C)#define SCU_TASK_DONE_UNEXP_XR ((u32)0x1C)
PATCH 4/37 isci: Terminate outstanding TCs on TX/RX RNC suspensions.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
TCs must only be terminated when RNCs are suspended.
--- drivers/scsi/isci/host.c | 22 +++--- drivers/scsi/isci/remote_device.c | 106 ++++++++++++++++++++++++++++--- drivers/scsi/isci/remote_device.h | 10 +++ drivers/scsi/isci/remote_node_context.c | 56 ++++++++++++++++ drivers/scsi/isci/remote_node_context.h | 2 + drivers/scsi/isci/request.c | 22 ++++-- drivers/scsi/isci/request.h | 2 + 7 files changed, 188 insertions(+), 32 deletions(-)
drivers/scsi/isci/host.c +11 -11
@@ -2678,18 +2678,18 @@ enum sci_status sci_controller_terminate_request(struct isci_host *ihost, __func__, ihost->sm.current_state_id);return SCI_FAILURE_INVALID_STATE ; } - status =sci_io_request_terminate (ireq); -if (status !=SCI_SUCCESS ) -return status; - -/* -* Utilize the original post context command and or in the POST_TC_ABORT -* request sub-type. -*/ -sci_controller_post_request (ihost, - ireq->post_context |SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT ); -return SCI_SUCCESS ; +if ((status ==SCI_SUCCESS ) && + !test_bit (IREQ_PENDING_ABORT , &ireq->flags) && + !test_and_set_bit (IREQ_TC_ABORT_POSTED , &ireq->flags)) { +/* Utilize the original post context command and or in the +* POST_TC_ABORT request sub-type. +*/ +sci_controller_post_request ( + ihost, ireq->post_context | +SCU_CONTEXT_COMMAND_REQUEST_POST_TC_ABORT ); + } +return status; }/**
drivers/scsi/isci/remote_device.c +95 -11
145 lines not on this page · raw message
drivers/scsi/isci/remote_device.h +10 -0
@@ -85,6 +85,7 @@ struct isci_remote_device {#define IDEV_GONE 3#define IDEV_IO_READY 4#define IDEV_IO_NCQERROR 5 +#define IDEV_TXRX_SUSPENDED 6unsigned long flags;struct kref kref;struct isci_port *isci_port;
@@ -335,4 +336,13 @@ void sci_remote_device_post_request(struct isci_remote_device *idev, u32 request); +enum sci_status sci_remote_device_terminate_requests ( +struct isci_remote_device *idev); + +int isci_remote_device_is_safe_to_abort ( +struct isci_remote_device *idev); + +enum sci_status +sci_remote_device_abort_requests_pending_abort ( +struct isci_remote_device *idev);#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
drivers/scsi/isci/remote_node_context.c +56 -0
94 lines not on this page · raw message
drivers/scsi/isci/remote_node_context.h +2 -0
@@ -214,5 +214,7 @@ enum sci_status sci_remote_node_context_start_task(struct sci_remote_node_contex struct isci_request *ireq);enum sci_status sci_remote_node_context_start_io (struct sci_remote_node_context *sci_rnc,struct isci_request *ireq); +int sci_remote_node_context_is_safe_to_abort ( +struct sci_remote_node_context *sci_rnc);#endif /* _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ */
drivers/scsi/isci/request.c +12 -10
@@ -863,6 +863,8 @@ sci_io_request_terminate(struct isci_request *ireq)switch (state) {case SCI_REQ_CONSTRUCTED : +/* Set to make sure no HW terminate posting is done: */ +set_bit (IREQ_TC_ABORT_POSTED , &ireq->flags); ireq->scu_status =SCU_TASK_DONE_TASK_ABORT ; ireq->sci_status =SCI_FAILURE_IO_TERMINATED ;sci_change_state (&ireq->sm,SCI_REQ_COMPLETED );
@@ -883,8 +885,7 @@ sci_io_request_terminate(struct isci_request *ireq)case SCI_REQ_ATAPI_WAIT_PIO_SETUP :case SCI_REQ_ATAPI_WAIT_D2H :case SCI_REQ_ATAPI_WAIT_TC_COMP : -sci_change_state (&ireq->sm,SCI_REQ_ABORTING ); -return SCI_SUCCESS ; +/* Fall through and change state to ABORTING... */ case SCI_REQ_TASK_WAIT_TC_RESP :/* The task frame was already confirmed to have been * sent by the SCU HW. Since the state machine is
@@ -893,20 +894,21 @@ sci_io_request_terminate(struct isci_request *ireq)* and don't wait for the task response. */ sci_change_state (&ireq->sm,SCI_REQ_ABORTING ); -sci_change_state (&ireq->sm,SCI_REQ_COMPLETED ); -return SCI_SUCCESS ; +/* Fall through and handle like ABORTING... */ case SCI_REQ_ABORTING : -/* If a request has a termination requested twice, return -* a failure indication, since HW confirmation of the first -* abort is still outstanding. +if (!isci_remote_device_is_safe_to_abort (ireq->target_device)) +set_bit (IREQ_PENDING_ABORT , &ireq->flags); +else +clear_bit (IREQ_PENDING_ABORT , &ireq->flags); +/* If the request is only waiting on the remote device +* suspension, return SUCCESS so the caller will wait too. */ +return SCI_SUCCESS ;case SCI_REQ_COMPLETED :default :dev_warn (&ireq->owning_controller->pdev->dev,"%s: SCIC IO Request requested to abort while in wrong " -"state %d\n" , - __func__, - ireq->sm.current_state_id); +"state %d\n" , __func__, ireq->sm.current_state_id);break ; }
drivers/scsi/isci/request.h +2 -0
@@ -102,6 +102,8 @@ struct isci_request {#define IREQ_TERMINATED 1#define IREQ_TMF 2#define IREQ_ACTIVE 3 +#define IREQ_PENDING_ABORT 4/* Set == device was not suspended yet */ +#define IREQ_TC_ABORT_POSTED 5unsigned long flags;/* XXX kill ttype and ttype_ptr, allocate full sas_task */ union ttype_ptr_union {
PATCH 5/37 isci: Manage device suspensions during TC terminations.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
TCs must be terminated only while the RNC is suspended. This commit adds remote device suspensions and resumptions in the abort, reset and termination paths.
--- drivers/scsi/isci/remote_device.c | 90 ++++++++++++++++++++++++++++++------- drivers/scsi/isci/remote_device.h | 33 ++++++++++++++ drivers/scsi/isci/task.c | 80 ++++++++++++++++++++------------- 3 files changed, 154 insertions(+), 49 deletions(-)
drivers/scsi/isci/remote_device.c +73 -17
@@ -143,6 +143,12 @@ static enum sci_status sci_remote_device_suspend( NULL, NULL); } +static int isci_remote_device_suspendcheck (struct isci_remote_device *idev) +{ +return test_bit (IDEV_TXRX_SUSPENDED , &idev->flags) + || !test_bit (IDEV_ALLOCATED , &idev->flags); +} +enum sci_status isci_remote_device_suspend (struct isci_host *ihost,struct isci_remote_device *idev)
@@ -151,18 +157,18 @@ enum sci_status isci_remote_device_suspend(unsigned long flags;spin_lock_irqsave (&ihost->scic_lock, flags); - -if (isci_lookup_device (idev->domain_dev) ==NULL ) { +if (isci_get_device (idev->domain_dev) ==NULL ) {spin_unlock_irqrestore (&ihost->scic_lock, flags); status =SCI_FAILURE ; }else { status =sci_remote_device_suspend (idev);spin_unlock_irqrestore (&ihost->scic_lock, flags);if (status ==SCI_SUCCESS ) { +dev_dbg (&ihost->pdev->dev, +"%s: idev=%p, about to wait\n" , + __func__, idev);wait_event (ihost->eventq, -test_bit (IDEV_TXRX_SUSPENDED , &idev->flags) - || !test_bit (IDEV_ALLOCATED , &idev->flags)); - +isci_remote_device_suspendcheck (idev)); status =test_bit (IDEV_TXRX_SUSPENDED , &idev->flags) ?SCI_SUCCESS :SCI_FAILURE ; dev_dbg(&ihost->pdev->dev,
@@ -171,7 +177,10 @@ enum sci_status isci_remote_device_suspend(test_bit (IDEV_TXRX_SUSPENDED , &idev->flags) ? "<suspended>" : "<deallocated!>"); - } + }else +dev_dbg (scirdev_to_dev (idev), +"%s: sci_remote_device_suspend failed, " +"status = %d\n" , __func__, status);isci_put_device (idev); }return status;
@@ -1218,6 +1227,35 @@ static enum sci_status sci_remote_device_ea_construct(struct isci_port *iport,return SCI_SUCCESS ; } +enum sci_status sci_remote_device_resume ( +struct isci_remote_device *idev, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p) +{ +enum sci_status status; + + status =sci_remote_node_context_resume (&idev->rnc, cb_fn, cb_p); +if (status !=SCI_SUCCESS ) +dev_dbg (scirdev_to_dev (idev),"%s: failed to resume: %d\n" , + __func__, status); +return status; +} + +enum sci_status isci_remote_device_resume ( +struct isci_host *ihost, +struct isci_remote_device *idev, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p) +{ +unsigned long flags; +enum sci_status status; + +spin_lock_irqsave (&ihost->scic_lock, flags); + status =sci_remote_device_resume (idev, cb_fn, cb_p); +spin_unlock_irqrestore (&ihost->scic_lock, flags); + +return status; +}/** * sci_remote_device_start() - This method will start the supplied remote * device. This method enables normal IO requests to flow through to the
@@ -1244,9 +1282,8 @@ static enum sci_status sci_remote_device_start(struct isci_remote_device *idev,return SCI_FAILURE_INVALID_STATE ; } - status =sci_remote_node_context_resume (&idev->rnc, - remote_device_resume_done, - idev); + status =sci_remote_device_resume (idev, remote_device_resume_done, + idev);if (status !=SCI_SUCCESS )return status;
@@ -1461,26 +1498,29 @@ int isci_remote_device_found(struct domain_device *dev) }enum sci_status isci_remote_device_reset ( +struct isci_host *ihost,struct isci_remote_device *idev) { -struct isci_host *ihost =dev_to_ihost (idev->domain_dev);unsigned long flags;enum sci_status status; -/* Wait for the device suspend. */ - status =isci_remote_device_suspend (ihost, idev); +/* Put the device into a reset state so the suspension will not +* automatically resume. +*/ +spin_lock_irqsave (&ihost->scic_lock, flags); + status =sci_remote_device_reset (idev); +spin_unlock_irqrestore (&ihost->scic_lock, flags);if (status !=SCI_SUCCESS ) {dev_dbg (&ihost->pdev->dev, -"%s: isci_remote_device_suspend(%p) returned %d!\n" , +"%s: sci_remote_device_reset(%p) returned %d!\n" , __func__, idev, status);return status; } -spin_lock_irqsave (&ihost->scic_lock, flags); - status =sci_remote_device_reset (idev); -spin_unlock_irqrestore (&ihost->scic_lock, flags); +/* Wait for the device suspend. */ + status =isci_remote_device_suspend (ihost, idev);if (status !=SCI_SUCCESS ) {dev_dbg (&ihost->pdev->dev, -"%s: sci_remote_device_reset(%p) returned %d!\n" , +"%s: isci_remote_device_suspend(%p) returned %d!\n" , __func__, idev, status); }return status;
@@ -1497,3 +1537,19 @@ enum sci_status sci_remote_device_abort_requests_pending_abort( {return sci_remote_device_terminate_requests_checkabort (idev,1 ); } + +enum sci_status isci_remote_device_reset_complete ( +struct isci_host *ihost, +struct isci_remote_device *idev) +{ +unsigned long flags; +enum sci_status status; + +spin_lock_irqsave (&ihost->scic_lock, flags); + status =sci_remote_device_reset_complete (idev); +sci_remote_device_resume (idev,NULL ,NULL ); +spin_unlock_irqrestore (&ihost->scic_lock, flags); + +return status; +} +
drivers/scsi/isci/remote_device.h +33 -0
@@ -106,6 +106,16 @@ struct isci_remote_device {#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000/* device reference routines must be called under sci_lock */ +static inline struct isci_remote_device *isci_get_device ( +struct domain_device *dev) +{ +struct isci_remote_device *idev = dev->lldd_dev; + +if (idev) +kref_get (&idev->kref); +return idev; +} +static inline struct isci_remote_device *isci_lookup_device (struct domain_device *dev) {struct isci_remote_device *idev = dev->lldd_dev;
@@ -345,4 +355,27 @@ int isci_remote_device_is_safe_to_abort(enum sci_status sci_remote_device_abort_requests_pending_abort (struct isci_remote_device *idev); + +enum sci_status isci_remote_device_suspend ( +struct isci_host *ihost, +struct isci_remote_device *idev); + +enum sci_status sci_remote_device_resume ( +struct isci_remote_device *idev, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p); + +enum sci_status isci_remote_device_resume ( +struct isci_host *ihost, +struct isci_remote_device *idev, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p); + +enum sci_status isci_remote_device_reset ( +struct isci_host *ihost, +struct isci_remote_device *idev); + +enum sci_status isci_remote_device_reset_complete ( +struct isci_host *ihost, +struct isci_remote_device *idev);#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
drivers/scsi/isci/task.c +48 -32
190 lines not on this page · raw message
PATCH 6/37 isci: Remote device must be suspended for NCQ cleanup.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
When the remote device enters the NCQ error state, the device must be suspended so that the I/O terminations can take place.
--- drivers/scsi/isci/remote_device.c | 25 ++++++++++++------------- 1 files changed, 12 insertions(+), 13 deletions(-)
drivers/scsi/isci/remote_device.c +12 -13
@@ -72,6 +72,14 @@ const char *dev_state_name(enum sci_remote_device_states state) }#undef C +static enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev) +{ +return sci_remote_node_context_suspend (&idev->rnc, +SCI_SOFTWARE_SUSPENSION , +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , +NULL ,NULL ); +} +/** * isci_remote_device_not_ready() - This function is called by the ihost when * the remote device is not ready. We mark the isci device as ready (not
@@ -96,6 +104,9 @@ static void isci_remote_device_not_ready(struct isci_host *ihost,case SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED :set_bit (IDEV_IO_NCQERROR , &idev->flags); +/* Suspend the remote device so the I/O can be terminated. */ +sci_remote_device_suspend (idev); +/* Kill all outstanding requests for the device. */ list_for_each_entry (ireq, &idev->reqs_in_process, dev_node) {
@@ -103,9 +114,7 @@ static void isci_remote_device_not_ready(struct isci_host *ihost,"%s: isci_device = %p request = %p\n" , __func__, idev, ireq); -sci_controller_terminate_request (ihost, - idev, - ireq); +sci_controller_terminate_request (ihost, idev, ireq); }/* Fall through into the default case... */ default :
@@ -133,16 +142,6 @@ static void isci_remote_device_ready(struct isci_host *ihost, struct isci_remotewake_up (&ihost->eventq); } -static enum sci_status sci_remote_device_suspend ( -struct isci_remote_device *idev) -{ -return sci_remote_node_context_suspend ( - &idev->rnc, -SCI_SOFTWARE_SUSPENSION , -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , -NULL ,NULL ); -} -static int isci_remote_device_suspendcheck (struct isci_remote_device *idev) {return test_bit (IDEV_TXRX_SUSPENDED , &idev->flags)
PATCH 7/37 isci: Remote device stop also suspends the RNC and terminates I/O.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Fixing the remote device state machine to suspend and terminate all outstanding I/O before the device stopped state is reached.
--- drivers/scsi/isci/remote_device.c | 23 +++++++++++------------ 1 files changed, 11 insertions(+), 12 deletions(-)
drivers/scsi/isci/remote_device.c +11 -12
@@ -263,13 +263,15 @@ enum sci_status sci_remote_device_stop(struct isci_remote_device *idev,case SCI_SMP_DEV_IDLE :case SCI_SMP_DEV_CMD :sci_change_state (sm,SCI_DEV_STOPPING ); -if (idev->started_request_count ==0 ) { +if (idev->started_request_count ==0 )sci_remote_node_context_destruct (&idev->rnc, - rnc_destruct_done, idev); -return SCI_SUCCESS ; - }else -return sci_remote_device_terminate_requests (idev); -break ; + rnc_destruct_done, + idev); +else { +sci_remote_device_suspend (idev); +sci_remote_device_terminate_requests (idev); + } +return SCI_SUCCESS ;case SCI_DEV_STOPPING :/* All requests should have been terminated, but if there is an * attempt to stop a device already in the stopping state, then
@@ -1403,14 +1405,8 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_remspin_lock_irqsave (&ihost->scic_lock, flags); idev->domain_dev->lldd_dev =NULL ;/* disable new lookups */ set_bit (IDEV_GONE , &idev->flags); -spin_unlock_irqrestore (&ihost->scic_lock, flags); - -/* Kill all outstanding requests. */ -isci_remote_device_nuke_requests (ihost, idev);set_bit (IDEV_STOP_PENDING , &idev->flags); - -spin_lock_irqsave (&ihost->scic_lock, flags); status =sci_remote_device_stop (idev,50 );spin_unlock_irqrestore (&ihost->scic_lock, flags);
@@ -1420,6 +1416,9 @@ enum sci_status isci_remote_device_stop(struct isci_host *ihost, struct isci_remelse wait_for_device_stop (ihost, idev); +dev_dbg (&ihost->pdev->dev, +"%s: isci_device = %p, waiting done.\n" , __func__, idev); +return status; }
PATCH 8/37 isci: Escalate to I_T_Nexus_Reset when the device is gone.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
If LUN reset sees that the device is gone, it returns TMF_RESP_FUNC_FAILED to cause libsas to escalate to an I_T_Nexus_Reset.
--- drivers/scsi/isci/task.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/isci/task.c +2 -2
@@ -842,10 +842,10 @@ int isci_task_lu_reset(struct domain_device *dev, u8 *lun) __func__, dev, ihost, isci_device);if (!isci_device) { -/* If the device is gone, stop the escalations. */ +/* If the device is gone, escalate to I_T_Nexus_Reset. */ dev_dbg (&ihost->pdev->dev,"%s: No dev\n" , __func__); - ret =TMF_RESP_FUNC_COMPLETE ; + ret =TMF_RESP_FUNC_FAILED ; goto out; }if (isci_remote_device_suspend (ihost, isci_device) !=SCI_SUCCESS ) {
PATCH 9/37 isci: Redesign device suspension, abort, cleanup.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
This commit changes the means by which outstanding I/Os are handled for cleanup.
The likelihood is that this commit will be broken into smaller pieces, however that will be a later revision. Among the changes:
- All completion structures have been removed from the tmf and abort paths.
- Now using one completed I/O list, with the I/O completed in host bit being used to select error or normal callback paths.
--- drivers/scsi/isci/host.c | 86 +--- drivers/scsi/isci/host.h | 1 drivers/scsi/isci/init.c | 1 drivers/scsi/isci/remote_device.c | 255 +++++----- drivers/scsi/isci/remote_device.h | 15 - drivers/scsi/isci/remote_node_context.c | 23 - drivers/scsi/isci/remote_node_context.h | 4 drivers/scsi/isci/request.c | 509 ++++++--------------- drivers/scsi/isci/request.h | 108 ---- drivers/scsi/isci/task.c | 758 ++++--------------------------- drivers/scsi/isci/task.h | 132 ----- 11 files changed, 418 insertions(+), 1474 deletions(-)
drivers/scsi/isci/host.c +26 -60
@@ -1078,33 +1078,25 @@ void isci_host_completion_routine(unsigned long data) {struct isci_host *ihost = (struct isci_host *)data;struct list_head completed_request_list; -struct list_head errored_request_list;struct list_head *current_position;struct list_head *next_position;struct isci_request *request; -struct isci_request *next_request;struct sas_task *task;u16 active;INIT_LIST_HEAD (&completed_request_list); -INIT_LIST_HEAD (&errored_request_list);spin_lock_irq (&ihost->scic_lock);sci_controller_completion_handler (ihost);/* Take the lists of completed I/Os from the host. */ -list_splice_init (&ihost->requests_to_complete, &completed_request_list); -/* Take the list of errored I/Os from the host. */ -list_splice_init (&ihost->requests_to_errorback, - &errored_request_list); -spin_unlock_irq (&ihost->scic_lock); -/* Process any completions in the lists. */ +/* Process any completions in the list. */ list_for_each_safe (current_position, next_position, &completed_request_list) {
@@ -1112,23 +1104,30 @@ void isci_host_completion_routine(unsigned long data) completed_node); task =isci_request_access_task (request); -/* Normal notification (task_done) */ -dev_dbg (&ihost->pdev->dev, -"%s: Normal - request/task = %p/%p\n" , - __func__, - request, - task);/* Return the task to libsas */ if (task !=NULL ) { task->lldd_task =NULL ; -if (!(task->task_state_flags &SAS_TASK_STATE_ABORTED )) { - -/* If the task is already in the abort path, -* the task_done callback cannot be called. -*/ - task->task_done (task); +if (!test_bit (IREQ_ABORT_PATH_ACTIVE , &request->flags) && + !(task->task_state_flags &SAS_TASK_STATE_ABORTED )) { +if (test_bit (IREQ_COMPLETE_IN_TARGET , + &request->flags)) { + +/* Normal notification (task_done) */ +dev_dbg (&ihost->pdev->dev,"%s: Normal" +" - request/task = %p/%p\n" , + __func__, request, task); + + task->task_done (task); + }else { +dev_warn (&ihost->pdev->dev, +"%s: Error - request/task" +" = %p/%p\n" , + __func__, request, task); + +sas_task_abort (task); + } } }
@@ -1136,44 +1135,6 @@ void isci_host_completion_routine(unsigned long data)isci_free_tag (ihost, request->io_tag);spin_unlock_irq (&ihost->scic_lock); } -list_for_each_entry_safe (request, next_request, &errored_request_list, - completed_node) { - - task =isci_request_access_task (request); - -/* Use sas_task_abort */ -dev_warn (&ihost->pdev->dev, -"%s: Error - request/task = %p/%p\n" , - __func__, - request, - task); - -if (task !=NULL ) { - -/* Put the task into the abort path if it's not there -* already. -*/ -if (!(task->task_state_flags &SAS_TASK_STATE_ABORTED )) -sas_task_abort (task); - - }else { -/* This is a case where the request has completed with a -* status such that it needed further target servicing, -* but the sas_task reference has already been removed -* from the request. Since it was errored, it was not -* being aborted, so there is nothing to do except free -* it. -*/ - -spin_lock_irq (&ihost->scic_lock); -/* Remove the request from the remote device's list -* of pending requests. -*/ -list_del_init (&request->dev_node); -isci_free_tag (ihost, request->io_tag); -spin_unlock_irq (&ihost->scic_lock); - } - }/* the coalesence timeout doubles at each encoding step, so * update it based on the ilog2 value of the outstanding requests
@@ -2329,7 +2290,6 @@ static int sci_controller_dma_alloc(struct isci_host *ihost) ireq->tc = &ihost->task_context_table[i]; ireq->owning_controller = ihost; -spin_lock_init (&ireq->state_lock); ireq->request_daddr = dma; ireq->isci_host = ihost; ihost->reqs[i] = ireq;
@@ -2679,6 +2639,10 @@ enum sci_status sci_controller_terminate_request(struct isci_host *ihost,return SCI_FAILURE_INVALID_STATE ; } status =sci_io_request_terminate (ireq); + +dev_dbg (&ihost->pdev->dev,"%s: status=%d; ireq=%p; flags=%lx\n" , + __func__, status, ireq, ireq->flags); +if ((status ==SCI_SUCCESS ) && !test_bit (IREQ_PENDING_ABORT , &ireq->flags) && !test_and_set_bit (IREQ_TC_ABORT_POSTED , &ireq->flags)) {
@@ -2721,6 +2685,8 @@ enum sci_status sci_controller_complete_io(struct isci_host *ihost, index =ISCI_TAG_TCI (ireq->io_tag);clear_bit (IREQ_ACTIVE , &ireq->flags); +if (test_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags)) +wake_up_all (&ihost->eventq);return SCI_SUCCESS ;default : dev_warn(&ihost->pdev->dev, "%s invalid state: %d\n",
drivers/scsi/isci/host.h +0 -1
@@ -203,7 +203,6 @@ struct isci_host {struct Scsi_Host *shost;struct tasklet_struct completion_tasklet;struct list_head requests_to_complete; -struct list_head requests_to_errorback;spinlock_t scic_lock;struct isci_request *reqs[SCI_MAX_IO_REQUESTS ];struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES ];
drivers/scsi/isci/init.c +0 -1
@@ -560,7 +560,6 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id) }INIT_LIST_HEAD (&ihost->requests_to_complete); -INIT_LIST_HEAD (&ihost->requests_to_errorback);for (i =0 ; i <SCI_MAX_PORTS ; i++) {struct isci_port *iport = &ihost->ports[i];
drivers/scsi/isci/remote_device.c +119 -136
344 lines not on this page · raw message
drivers/scsi/isci/remote_device.h +11 -4
@@ -85,7 +85,6 @@ struct isci_remote_device {#define IDEV_GONE 3#define IDEV_IO_READY 4#define IDEV_IO_NCQERROR 5 -#define IDEV_TXRX_SUSPENDED 6unsigned long flags;struct kref kref;struct isci_port *isci_port;
@@ -107,10 +106,8 @@ struct isci_remote_device {/* device reference routines must be called under sci_lock */ static inline struct isci_remote_device *isci_get_device ( -struct domain_device *dev) +struct isci_remote_device *idev) { -struct isci_remote_device *idev = dev->lldd_dev; -if (idev)kref_get (&idev->kref);return idev;
@@ -378,4 +375,14 @@ enum sci_status isci_remote_device_reset(enum sci_status isci_remote_device_reset_complete (struct isci_host *ihost,struct isci_remote_device *idev); + +enum sci_status isci_remote_device_suspend_terminate ( +struct isci_host *ihost, +struct isci_remote_device *idev, +struct isci_request *ireq); + +enum sci_status isci_remote_device_terminate_requests ( +struct isci_host *ihost, +struct isci_remote_device *idev, +struct isci_request *ireq);#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
drivers/scsi/isci/remote_node_context.c +6 -17
@@ -317,8 +317,6 @@ static void sci_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_struct isci_remote_device *idev =rnc_to_dev (rnc);struct isci_host *ihost = idev->owning_port->owning_controller; -set_bit (IDEV_TXRX_SUSPENDED , &idev->flags); -/* Terminate outstanding requests pending abort. */ sci_remote_device_abort_requests_pending_abort (idev);
@@ -326,16 +324,6 @@ static void sci_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_sci_remote_node_context_continue_state_transitions (rnc); } -static void sci_remote_node_context_tx_rx_suspended_state_exit ( -struct sci_base_state_machine *sm) -{ -struct sci_remote_node_context *rnc - =container_of (sm,typeof (*rnc), sm); -struct isci_remote_device *idev =rnc_to_dev (rnc); - -clear_bit (IDEV_TXRX_SUSPENDED , &idev->flags); -} -static void sci_remote_node_context_await_suspend_state_exit (struct sci_base_state_machine *sm) {
@@ -366,8 +354,6 @@ static const struct sci_base_state sci_remote_node_context_state_table[] = { }, [SCI_RNC_TX_RX_SUSPENDED] = { .enter_state = sci_remote_node_context_tx_rx_suspended_state_enter, - .exit_state - = sci_remote_node_context_tx_rx_suspended_state_exit, }, [SCI_RNC_AWAIT_SUSPENSION] = { .exit_state = sci_remote_node_context_await_suspend_state_exit,
@@ -671,8 +657,11 @@ enum sci_status sci_remote_node_context_start_io(struct sci_remote_node_context } } -enum sci_status sci_remote_node_context_start_task (struct sci_remote_node_context *sci_rnc, -struct isci_request *ireq) +enum sci_status sci_remote_node_context_start_task ( +struct sci_remote_node_context *sci_rnc, +struct isci_request *ireq, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p) {enum scis_sds_remote_node_context_states state;
@@ -684,7 +673,7 @@ enum sci_status sci_remote_node_context_start_task(struct sci_remote_node_contexreturn SCI_SUCCESS ;case SCI_RNC_TX_SUSPENDED :case SCI_RNC_TX_RX_SUSPENDED : -sci_remote_node_context_resume (sci_rnc,NULL ,NULL ); +sci_remote_node_context_resume (sci_rnc, cb_fn, cb_p);return SCI_SUCCESS ;default : dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
drivers/scsi/isci/remote_node_context.h +3 -1
@@ -211,7 +211,9 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *sscics_sds_remote_node_context_callback cb_fn, void *cb_p);enum sci_status sci_remote_node_context_start_task (struct sci_remote_node_context *sci_rnc, -struct isci_request *ireq); +struct isci_request *ireq, +scics_sds_remote_node_context_callback cb_fn, +void *cb_p);enum sci_status sci_remote_node_context_start_io (struct sci_remote_node_context *sci_rnc,struct isci_request *ireq); int sci_remote_node_context_is_safe_to_abort(
drivers/scsi/isci/request.c +146 -363
693 lines not on this page · raw message
drivers/scsi/isci/request.h +1 -107
144 lines not on this page · raw message
drivers/scsi/isci/task.c +105 -653
947 lines not on this page · raw message
drivers/scsi/isci/task.h +1 -131
154 lines not on this page · raw message
PATCH 10/37 isci: Add suspension cases for RNC INVALIDATING, POSTING states.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
The RNC can be any of the states in the loop from suspended to ready when the API "suspend" or "resume" are called. This change adds destination states parameters that control the suspension / resumption action of the RNC statemachine for those transition states.
--- drivers/scsi/isci/port.c | 11 -- drivers/scsi/isci/remote_device.c | 2 drivers/scsi/isci/remote_node_context.c | 145 +++++++++++++++++++++---------- drivers/scsi/isci/remote_node_context.h | 10 +- 4 files changed, 105 insertions(+), 63 deletions(-)
drivers/scsi/isci/port.c +0 -11
@@ -1686,17 +1686,6 @@ int isci_port_perform_hard_reset(struct isci_host *ihost, struct isci_port *ipor __func__, iport, status); } - -/* If the hard reset for the port has failed, consider this -* the same as link failures on all phys in the port. -*/ -if (ret !=TMF_RESP_FUNC_COMPLETE ) { - -dev_err (&ihost->pdev->dev, -"%s: iport = %p; hard reset failed " -"(0x%x) - driving explicit link fail for all phys\n" , - __func__, iport, iport->hard_reset_status); - }return ret; }
drivers/scsi/isci/remote_device.c +1 -1
@@ -192,7 +192,7 @@ static void isci_remote_device_not_ready(struct isci_host *ihost, u32 reason) {dev_dbg (&ihost->pdev->dev, -"%s: isci_device = %p\n" , __func__, idev); +"%s: isci_device = %p; reason = %d\n" , __func__, idev, reason);switch (reason) {case SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED :
drivers/scsi/isci/remote_node_context.c +97 -48
256 lines not on this page · raw message
drivers/scsi/isci/remote_node_context.h +7 -3
@@ -141,9 +141,13 @@ const char *rnc_state_name(enum scis_sds_remote_node_context_states state);* node context. */ enum sci_remote_node_context_destination_state { -SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_UNSPECIFIED , -SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_READY , -SCIC_SDS_REMOTE_NODE_DESTINATION_STATE_FINAL +RNC_DEST_UNSPECIFIED , +RNC_DEST_READY , +RNC_DEST_FINAL , +RNC_DEST_SUSPENDED ,/* Set when suspend during post/invalidate */ +RNC_DEST_SUSPENDED_RESUME /* Set when a resume was done during posting +* or invalidating and already suspending. +*/ };/**
PATCH 11/37 isci: Device access in the error path does not depend on IDEV_GONE.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
--- drivers/scsi/isci/task.c | 7 +++++-- 1 files changed, 5 insertions(+), 2 deletions(-)
drivers/scsi/isci/task.c +5 -2
@@ -427,7 +427,7 @@ int isci_task_lu_reset(struct domain_device *dev, u8 *lun)int ret;spin_lock_irqsave (&ihost->scic_lock, flags); - idev =isci_lookup_device (dev); + idev =isci_get_device (dev->lldd_dev);spin_unlock_irqrestore (&ihost->scic_lock, flags); dev_dbg(&ihost->pdev->dev,
@@ -507,7 +507,7 @@ int isci_task_abort_task(struct sas_task *task)if (!(task->task_state_flags &SAS_TASK_STATE_DONE ) && (task->task_state_flags &SAS_TASK_AT_INITIATOR ) && old_request) - idev =isci_lookup_device (task->dev); + idev =isci_get_device (task->dev->lldd_dev);spin_unlock (&task->task_state_lock);spin_unlock_irqrestore (&ihost->scic_lock, flags);
@@ -593,6 +593,9 @@ int isci_task_abort_task(struct sas_task *task) ISCI_ABORT_TASK_TIMEOUT_MS); } out: +dev_warn (&ihost->pdev->dev, +"%s: Done; dev = %p, task = %p , old_request == %p\n" , + __func__, idev, task, old_request);isci_put_device (idev);return ret; }
PATCH 12/37 isci: All pending TCs are terminated when the RNC is invalidated.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
--- drivers/scsi/isci/remote_node_context.c | 4 ++-- 1 files changed, 2 insertions(+), 2 deletions(-)
drivers/scsi/isci/remote_node_context.c +2 -2
@@ -275,8 +275,8 @@ static void sci_remote_node_context_invalidating_state_enter(struct sci_base_sta {struct sci_remote_node_context *rnc =container_of (sm,typeof (*rnc), sm); -/* Terminate outstanding requests pending abort. */ -sci_remote_device_abort_requests_pending_abort (rnc_to_dev (rnc)); +/* Terminate all outstanding requests. */ +sci_remote_device_terminate_requests (rnc_to_dev (rnc));sci_remote_node_context_invalidate_context_buffer (rnc); }
PATCH 13/37 isci: Only set IDEV_GONE in the device stop path.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
--- drivers/scsi/isci/port.c | 23 ----------------------- drivers/scsi/isci/remote_device.c | 3 --- 2 files changed, 0 insertions(+), 26 deletions(-)
drivers/scsi/isci/port.c +0 -23
@@ -240,32 +240,9 @@ static void isci_port_link_down(struct isci_host *isci_host, struct isci_phy *isci_phy, struct isci_port *isci_port) { - struct isci_remote_device *isci_device; - dev_dbg(&isci_host->pdev->dev, "%s: isci_port = %p\n", __func__, isci_port); -if (isci_port) { - -/* check to see if this is the last phy on this port. */ -if (isci_phy->sas_phy.port && - isci_phy->sas_phy.port->num_phys ==1 ) { -/* change the state for all devices on this port. The -* next task sent to this device will be returned as -* SAS_TASK_UNDELIVERED, and the scsi mid layer will -* remove the target -*/ -list_for_each_entry (isci_device, - &isci_port->remote_dev_list, - node) { -dev_dbg (&isci_host->pdev->dev, -"%s: isci_device = %p\n" , - __func__, isci_device); -set_bit (IDEV_GONE , &isci_device->flags); - } - } - } -/* Notify libsas of the borken link, this will trigger calls to our * isci_port_deformed and isci_dev_gone functions. */
drivers/scsi/isci/remote_device.c +0 -3
@@ -195,9 +195,6 @@ static void isci_remote_device_not_ready(struct isci_host *ihost, "%s: isci_device = %p; reason = %d\n", __func__, idev, reason);switch (reason) { -case SCIC_REMOTE_DEVICE_NOT_READY_STOP_REQUESTED : -set_bit (IDEV_GONE , &idev->flags); -break ;case SCIC_REMOTE_DEVICE_NOT_READY_SATA_SDB_ERROR_FIS_RECEIVED :set_bit (IDEV_IO_NCQERROR , &idev->flags);
PATCH 14/37 isci: Remove isci_device reqs_in_process and dev_node from isci_device.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
--- drivers/scsi/isci/init.c | 1 - drivers/scsi/isci/remote_device.c | 6 +----- drivers/scsi/isci/remote_device.h | 1 - drivers/scsi/isci/request.c | 12 ------------ drivers/scsi/isci/request.h | 2 -- drivers/scsi/isci/task.c | 4 ---- 6 files changed, 1 insertions(+), 25 deletions(-)
drivers/scsi/isci/init.c +0 -1
@@ -573,7 +573,6 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)for (i =0 ; i <SCI_MAX_REMOTE_DEVICES ; i++) {struct isci_remote_device *idev = &ihost->devices[i]; -INIT_LIST_HEAD (&idev->reqs_in_process);INIT_LIST_HEAD (&idev->node); }
drivers/scsi/isci/remote_device.c +1 -5
@@ -919,7 +919,7 @@ static void isci_remote_device_deconstruct(struct isci_host *ihost, struct isci_* here should go through isci_remote_device_nuke_requests. * If we hit this condition, we will need a way to complete * io requests in process */ -BUG_ON (!list_empty (&idev->reqs_in_process)); +BUG_ON (idev->started_request_count >0 );sci_remote_device_destruct (idev);list_del_init (&idev->node);
@@ -1345,10 +1345,6 @@ isci_remote_device_alloc(struct isci_host *ihost, struct isci_port *iport)dev_warn (&ihost->pdev->dev,"%s: failed\n" , __func__);return NULL ; } - -if (WARN_ONCE (!list_empty (&idev->reqs_in_process),"found requests in process\n" )) -return NULL ; -if (WARN_ONCE (!list_empty (&idev->node),"found non-idle remote device\n" ))return NULL ;
drivers/scsi/isci/remote_device.h +0 -1
@@ -90,7 +90,6 @@ struct isci_remote_device {struct isci_port *isci_port;struct domain_device *domain_dev;struct list_head node; -struct list_head reqs_in_process;struct sci_base_state_machine sm;u32 device_port_width;enum sas_linkrate connection_rate;
drivers/scsi/isci/request.c +0 -12
@@ -2956,9 +2956,6 @@ static void isci_request_io_request_complete(struct isci_host *ihost,/* Add to the completed list. */ list_add (&request->completed_node, &ihost->requests_to_complete); -/* Take the request off the device's pending request list. */ -list_del_init (&request->dev_node); -/* complete the io request to the core. */ sci_controller_complete_io (ihost, request->target_device, request);
@@ -3412,7 +3409,6 @@ static struct isci_request *isci_request_from_tag(struct isci_host *ihost, u16 t ireq->flags =0 ; ireq->num_sg_entries =0 ;INIT_LIST_HEAD (&ireq->completed_node); -INIT_LIST_HEAD (&ireq->dev_node);return ireq; }
@@ -3496,17 +3492,9 @@ int isci_request_execute(struct isci_host *ihost, struct isci_remote_device *idespin_unlock_irqrestore (&ihost->scic_lock, flags);return status; } -/* Either I/O started OK, or the core has signaled that * the device needs a target reset. -* -* In either case, hold onto the I/O for later. -* -* Update it's status and add it to the list in the -* remote device object. */ -list_add (&ireq->dev_node, &idev->reqs_in_process); -if (status !=SCI_SUCCESS ) {/* The request did not really start in the * hardware, so clear the request handle
drivers/scsi/isci/request.h +0 -2
@@ -96,8 +96,6 @@ struct isci_request {struct isci_host *isci_host;/* For use in the requests_to_{complete|abort} lists: */ struct list_head completed_node; -/* For use in the reqs_in_process list: */ -struct list_head dev_node;dma_addr_t request_daddr;dma_addr_t zero_scatter_daddr;unsigned int num_sg_entries;
drivers/scsi/isci/task.c +0 -4
@@ -317,9 +317,6 @@ static int isci_task_execute_tmf(struct isci_host *ihost,spin_unlock_irqrestore (&ihost->scic_lock, flags); goto err_tci; } -/* add the request to the remote device request list. */ -list_add (&ireq->dev_node, &idev->reqs_in_process); -/* The RNC must be unsuspended before the TMF can get a response. */ sci_remote_device_resume (idev,NULL ,NULL );
@@ -721,7 +718,6 @@ isci_task_request_complete(struct isci_host *ihost,set_bit (IREQ_TERMINATED , &ireq->flags);isci_free_tag (ihost, ireq->io_tag); -list_del_init (&ireq->dev_node);/* The task management part completes last. */ if (tmf_complete)
PATCH 15/37 isci: Distinguish between remote device suspension cases
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
For NCQ error conditions among others, there is no need to enable the link layer hang detect timer.
--- drivers/scsi/isci/remote_device.c | 27 +++++++++++---------------- drivers/scsi/isci/remote_node_context.c | 19 +++++++++++++------ drivers/scsi/isci/remote_node_context.h | 5 +++-- drivers/scsi/isci/request.c | 2 +- 4 files changed, 28 insertions(+), 25 deletions(-)
drivers/scsi/isci/remote_device.c +11 -16
@@ -72,10 +72,11 @@ const char *dev_state_name(enum sci_remote_device_states state) }#undef C -static enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev) +static enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev, +enum sci_remote_node_suspension_reasons reason) {return sci_remote_node_context_suspend (&idev->rnc, -SCI_SOFTWARE_SUSPENSION , + reason,SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); }
@@ -199,7 +200,7 @@ static void isci_remote_device_not_ready(struct isci_host *ihost,set_bit (IDEV_IO_NCQERROR , &idev->flags);/* Suspend the remote device so the I/O can be terminated. */ -sci_remote_device_suspend (idev); +sci_remote_device_suspend (idev,SCI_SW_SUSPEND_NORMAL );/* Kill all outstanding requests for the device. */ sci_remote_device_terminate_requests (idev);
@@ -268,7 +269,8 @@ enum sci_status sci_remote_device_stop(struct isci_remote_device *idev, rnc_destruct_done, idev); else { -sci_remote_device_suspend (idev); +sci_remote_device_suspend ( + idev,SCI_SW_SUSPEND_LINKHANG_DETECT );sci_remote_device_terminate_requests (idev); }return SCI_SUCCESS ;
@@ -473,11 +475,7 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, status =SCI_SUCCESS ;/* Suspend the associated RNC */ -sci_remote_node_context_suspend ( - &idev->rnc, -SCI_SOFTWARE_SUSPENSION , -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , -NULL ,NULL ); +sci_remote_device_suspend (idev,SCI_SW_SUSPEND_NORMAL ); dev_dbg(scirdev_to_dev(idev), "%s: device: %p event code: %x: %s\n",
@@ -789,9 +787,8 @@ enum sci_status sci_remote_device_start_task(struct isci_host *ihost,* the correct action when the remote node context is suspended * and later resumed. */ -sci_remote_node_context_suspend ( - &idev->rnc,SCI_SOFTWARE_SUSPENSION , -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); +sci_remote_device_suspend (idev, +SCI_SW_SUSPEND_LINKHANG_DETECT ); status =sci_remote_node_context_start_task (&idev->rnc, ireq, sci_remote_device_continue_request, idev);
@@ -986,9 +983,7 @@ static void sci_remote_device_resetting_state_enter(struct sci_base_state_machindev_dbg (&ihost->pdev->dev,"%s: isci_device = %p\n" , __func__, idev); -sci_remote_node_context_suspend ( - &idev->rnc,SCI_SOFTWARE_SUSPENSION , -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); +sci_remote_device_suspend (idev,SCI_SW_SUSPEND_LINKHANG_DETECT ); }static void sci_remote_device_resetting_state_exit (struct sci_base_state_machine *sm)
@@ -1486,7 +1481,7 @@ enum sci_status isci_remote_device_suspend_terminate(/* Put the device into suspension. */ spin_lock_irqsave (&ihost->scic_lock, flags); -sci_remote_device_suspend (idev); +sci_remote_device_suspend (idev,SCI_SW_SUSPEND_LINKHANG_DETECT );spin_unlock_irqrestore (&ihost->scic_lock, flags);/* Terminate and wait for the completions. */
drivers/scsi/isci/remote_node_context.c +13 -6
@@ -52,7 +52,7 @@* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - +#include <scsi/sas_ata.h> #include "host.h" #include "isci.h" #include "remote_device.h"
@@ -315,7 +315,7 @@ static void sci_remote_node_context_ready_state_enter(struct sci_base_state_machif ((dest_select ==RNC_DEST_SUSPENDED ) || (dest_select ==RNC_DEST_SUSPENDED_RESUME )) {sci_remote_node_context_suspend ( - rnc,SCI_SOFTWARE_SUSPENSION , + rnc,SCI_SW_SUSPEND_NORMAL ,SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL );if (dest_select ==RNC_DEST_SUSPENDED_RESUME ) {
@@ -352,8 +352,10 @@ static void sci_remote_node_context_await_suspend_state_exit( {struct sci_remote_node_context *rnc =container_of (sm,typeof (*rnc), sm); +struct isci_remote_device *idev =rnc_to_dev (rnc); -isci_dev_set_hang_detection_timeout (rnc_to_dev (rnc),0 ); +if (dev_is_sata (idev->domain_dev)) +isci_dev_set_hang_detection_timeout (idev,0 ); }static const struct sci_base_state sci_remote_node_context_state_table[] = {
@@ -556,7 +558,7 @@ enum sci_status sci_remote_node_context_suspend( suspend_type);/* Disable automatic state continuations if explicitly suspending. */ -if ((suspend_reason !=SCI_SOFTWARE_SUSPENSION ) || +if ((suspend_reason ==SCI_HW_SUSPEND ) || (sci_rnc->destination_state ==RNC_DEST_FINAL )) dest_param = sci_rnc->destination_state;
@@ -612,8 +614,13 @@ enum sci_status sci_remote_node_context_suspend(wake_up_all (&ihost->eventq);/* Let observers look. */ return SCI_SUCCESS ; } -if (suspend_reason ==SCI_SOFTWARE_SUSPENSION ) { -isci_dev_set_hang_detection_timeout (idev,0x00000001 ); +if ((suspend_reason ==SCI_SW_SUSPEND_NORMAL ) || + (suspend_reason ==SCI_SW_SUSPEND_LINKHANG_DETECT )) { + +if ((suspend_reason ==SCI_SW_SUSPEND_LINKHANG_DETECT ) + &&dev_is_sata (idev->domain_dev)) +isci_dev_set_hang_detection_timeout (idev,0x00000001 ); +sci_remote_device_post_request ( idev,SCI_SOFTWARE_SUSPEND_CMD ); }
drivers/scsi/isci/remote_node_context.h +3 -2
@@ -76,8 +76,9 @@#define SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX 0x0FFFenum sci_remote_node_suspension_reasons { -SCU_HARDWARE_SUSPENSION , -SCI_SOFTWARE_SUSPENSION +SCI_HW_SUSPEND , +SCI_SW_SUSPEND_NORMAL , +SCI_SW_SUSPEND_LINKHANG_DETECT };#define SCI_SOFTWARE_SUSPEND_CMD SCU_CONTEXT_COMMAND_POST_RNC_SUSPEND_TX_RX#define SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT SCU_EVENT_TL_RNC_SUSPEND_TX_RX
drivers/scsi/isci/request.c +1 -1
@@ -2380,7 +2380,7 @@ static void sci_request_handle_suspending_completions(sci_remote_node_context_suspend ( &ireq->target_device->rnc, -SCU_HARDWARE_SUSPENSION , +SCI_HW_SUSPEND , (is_tx_rx) ?SCU_EVENT_TL_RNC_SUSPEND_TX_RX :SCU_EVENT_TL_RNC_SUSPEND_TX ,NULL ,NULL );
PATCH 16/37 isci: Fix the terminated I/O to not call sas_task_abort().
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
This addresses a regression from the commit "isci: Redesign device suspension, abort, cleanup." in which the sas_task end condition for terminated I/Os was made to call back on sas_task_abort()".
This commit will be rolled into the original.
--- drivers/scsi/isci/request.c | 2 +- 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/scsi/isci/request.c +1 -1
@@ -2832,7 +2832,7 @@ static void isci_request_io_request_complete(struct isci_host *ihost, __func__, request, task);/* The request was terminated explicitly. */ -clear_bit (IREQ_COMPLETE_IN_TARGET , &request->flags); +set_bit (IREQ_COMPLETE_IN_TARGET , &request->flags); response =SAS_TASK_UNDELIVERED ;/* See if the device has been/is being stopped. Note
PATCH 17/37 isci: Save the suspension hint for upcoming suspensions.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
In the case of a suspend call while in SCI_RNC_POSTING or INVALIDATING states, the LLHANG detect needed to be saved so the upcoming suspension would enable it correctly. The unused suspend callback parameters were removed.
--- drivers/scsi/isci/remote_device.c | 6 ++---- drivers/scsi/isci/remote_node_context.c | 16 +++++++--------- drivers/scsi/isci/remote_node_context.h | 5 ++--- drivers/scsi/isci/request.c | 3 +-- 4 files changed, 12 insertions(+), 18 deletions(-)
drivers/scsi/isci/remote_device.c +2 -4
@@ -75,10 +75,8 @@ const char *dev_state_name(enum sci_remote_device_states state)static enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev,enum sci_remote_node_suspension_reasons reason) { -return sci_remote_node_context_suspend (&idev->rnc, - reason, -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT , -NULL ,NULL ); +return sci_remote_node_context_suspend (&idev->rnc, reason, +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ); }/**
drivers/scsi/isci/remote_node_context.c +7 -9
@@ -315,8 +315,8 @@ static void sci_remote_node_context_ready_state_enter(struct sci_base_state_machif ((dest_select ==RNC_DEST_SUSPENDED ) || (dest_select ==RNC_DEST_SUSPENDED_RESUME )) {sci_remote_node_context_suspend ( - rnc,SCI_SW_SUSPEND_NORMAL , -SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT ,NULL ,NULL ); + rnc, rnc->suspend_reason, +SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT );if (dest_select ==RNC_DEST_SUSPENDED_RESUME ) {sci_remote_node_context_resume (rnc, usr_cb, usr_param);
@@ -539,9 +539,7 @@ enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_contextenum sci_status sci_remote_node_context_suspend (struct sci_remote_node_context *sci_rnc,enum sci_remote_node_suspension_reasons suspend_reason, -u32 suspend_type, -scics_sds_remote_node_context_callback cb_fn, -void *cb_p) +u32 suspend_type) {enum scis_sds_remote_node_context_states state = sci_rnc->sm.current_state_id;
@@ -581,6 +579,8 @@ enum sci_status sci_remote_node_context_suspend(* needs to be done immediately. */ sci_rnc->destination_state =RNC_DEST_SUSPENDED ; + sci_rnc->suspend_type = suspend_type; + sci_rnc->suspend_reason = suspend_reason;return SCI_SUCCESS ;case SCI_RNC_TX_SUSPENDED :
@@ -603,14 +603,12 @@ enum sci_status sci_remote_node_context_suspend(return SCI_FAILURE_INVALID_STATE ; } sci_rnc->destination_state = dest_param; - sci_rnc->user_callback = cb_fn; - sci_rnc->user_cookie = cb_p; - sci_rnc->suspend_type = suspend_type; + sci_rnc->suspend_type = suspend_type; + sci_rnc->suspend_reason = suspend_reason;if (status ==SCI_SUCCESS ) {/* Already in the destination state? */ struct isci_host *ihost = idev->owning_port->owning_controller; -sci_remote_node_context_notify_user (sci_rnc);wake_up_all (&ihost->eventq);/* Let observers look. */ return SCI_SUCCESS ; }
drivers/scsi/isci/remote_node_context.h +2 -3
@@ -169,6 +169,7 @@ struct sci_remote_node_context {* context suspension. */ u32 suspend_type; +enum sci_remote_node_suspension_reasons suspend_reason;/** * This field is true if the remote node context is resuming from its current
@@ -209,9 +210,7 @@ enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context void *callback_parameter);enum sci_status sci_remote_node_context_suspend (struct sci_remote_node_context *sci_rnc,u32 suspend_type, -u32 suspension_code, -scics_sds_remote_node_context_callback cb_fn, -void *cb_p); +u32 suspension_code);enum sci_status sci_remote_node_context_resume (struct sci_remote_node_context *sci_rnc,scics_sds_remote_node_context_callback cb_fn,void *cb_p);
drivers/scsi/isci/request.c +1 -2
@@ -2382,8 +2382,7 @@ static void sci_request_handle_suspending_completions( &ireq->target_device->rnc,SCI_HW_SUSPEND , (is_tx_rx) ?SCU_EVENT_TL_RNC_SUSPEND_TX_RX - :SCU_EVENT_TL_RNC_SUSPEND_TX , - NULL, NULL); + : SCU_EVENT_TL_RNC_SUSPEND_TX); } }
PATCH 18/37 isci: Manage the LLHANG timer enable/disable per-device.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
The LLHANG timer should be enabled once per device. This patch corrects both the timer enable and the timer disable for the remote device.
--- drivers/scsi/isci/remote_device.c | 17 +++++++++++++++++ drivers/scsi/isci/remote_device.h | 8 ++------ drivers/scsi/isci/remote_node_context.c | 3 +-- 3 files changed, 20 insertions(+), 8 deletions(-)
drivers/scsi/isci/remote_device.c +17 -0
@@ -1520,3 +1520,20 @@ enum sci_status isci_remote_device_reset_complete(return status; } +void isci_dev_set_hang_detection_timeout ( +struct isci_remote_device *idev, +u32 timeout) +{ +if (dev_is_sata (idev->domain_dev)) { +if (timeout) { +if (test_and_set_bit (IDEV_RNC_LLHANG_ENABLED , + &idev->flags)) +return ;/* Already enabled. */ + }else if (!test_and_clear_bit (IDEV_RNC_LLHANG_ENABLED , + &idev->flags)) +return ;/* Not enabled. */ + +sci_port_set_hang_detection_timeout (idev->owning_port, + timeout); + } +}
drivers/scsi/isci/remote_device.h +2 -6
@@ -85,6 +85,7 @@ struct isci_remote_device {#define IDEV_GONE 3#define IDEV_IO_READY 4#define IDEV_IO_NCQERROR 5 +#define IDEV_RNC_LLHANG_ENABLED 6unsigned long flags;struct kref kref;struct isci_port *isci_port;
@@ -308,12 +309,7 @@ static inline void sci_remote_device_decrement_request_count(struct isci_remote_ idev->started_request_count--; } -static inline void isci_dev_set_hang_detection_timeout ( -struct isci_remote_device *idev, -u32 timeout) -{ -sci_port_set_hang_detection_timeout (idev->owning_port, timeout); -} +void isci_dev_set_hang_detection_timeout (struct isci_remote_device *idev,u32 timeout); enum sci_status sci_remote_device_frame_handler( struct isci_remote_device *idev,
drivers/scsi/isci/remote_node_context.c +1 -2
@@ -615,8 +615,7 @@ enum sci_status sci_remote_node_context_suspend(if ((suspend_reason ==SCI_SW_SUSPEND_NORMAL ) || (suspend_reason ==SCI_SW_SUSPEND_LINKHANG_DETECT )) { -if ((suspend_reason ==SCI_SW_SUSPEND_LINKHANG_DETECT ) - &&dev_is_sata (idev->domain_dev)) +if (suspend_reason ==SCI_SW_SUSPEND_LINKHANG_DETECT )isci_dev_set_hang_detection_timeout (idev,0x00000001 ); sci_remote_device_post_request(
PATCH 19/37 isci: Make sure all TCs are terminated and cleaned in LUN reset.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
In the libsas error path, SATA disks require extra handling in libata to recover operation. However, libsas expects to be able to immediately recover all outstanding I/O once the error handler escalation stops. This patch fixes the condition where the libata error handler is scheduled for operation but libsas has already deleted the outstanding sas_tasks.
--- drivers/scsi/isci/task.c | 14 ++++++++------ 1 files changed, 8 insertions(+), 6 deletions(-)
drivers/scsi/isci/task.c +8 -6
@@ -439,16 +439,18 @@ int isci_task_lu_reset(struct domain_device *dev, u8 *lun) goto out; } +/* Suspend the RNC, kill all TCs */ +if (isci_remote_device_suspend_terminate (ihost, idev,NULL ) + !=SCI_SUCCESS ) { +/* The suspend/terminate only fails if isci_get_device fails */ + ret =TMF_RESP_FUNC_FAILED ; + goto out; + } +/* All pending I/Os have been terminated and cleaned up. */ if (dev_is_sata (dev)) {sas_ata_schedule_reset (dev); ret =TMF_RESP_FUNC_COMPLETE ; }else { -/* Suspend the RNC, kill all TCs */ -if (isci_remote_device_suspend_terminate (ihost, idev,NULL ) - !=SCI_SUCCESS ) { - ret =TMF_RESP_FUNC_FAILED ; - goto out; - }/* Send the task management part of the reset. */ ret =isci_task_send_lu_reset_sas (ihost, idev, lun); }
PATCH 20/37 isci: Implement waiting for suspend in the abort path.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
In order to prevent a device from receiving an I/O request while still in an RNC suspending or resuming state (and therefore failing that I/O back to libsas with a reset required status) wait for the RNC state change before proceding in the abort path.
--- drivers/scsi/isci/remote_device.c | 44 +++++++++++++++++++++++-------- drivers/scsi/isci/remote_device.h | 6 +--- drivers/scsi/isci/remote_node_context.c | 21 +++++++++++++++ drivers/scsi/isci/remote_node_context.h | 3 ++ drivers/scsi/isci/task.c | 14 +++++----- 5 files changed, 66 insertions(+), 22 deletions(-)
drivers/scsi/isci/remote_device.c +33 -11
@@ -137,6 +137,14 @@ static enum sci_status sci_remote_device_terminate_reqs_checkabort(return status; } +static bool isci_compare_suspendcount ( +struct isci_remote_device *idev, +u32 localcount) +{ +smp_rmb (); +return localcount != idev->rnc.suspend_count; +} + enum sci_status isci_remote_device_terminate_requests( struct isci_host *ihost, struct isci_remote_device *idev,
@@ -144,31 +152,44 @@ enum sci_status isci_remote_device_terminate_requests( {enum sci_status status =SCI_SUCCESS ;unsigned long flags; +u32 rnc_suspend_count;spin_lock_irqsave (&ihost->scic_lock, flags); +if (isci_get_device (idev) ==NULL ) {dev_dbg (&ihost->pdev->dev,"%s: failed isci_get_device(idev=%p)\n" , __func__, idev);spin_unlock_irqrestore (&ihost->scic_lock, flags); status =SCI_FAILURE ; }else { +/* If already suspended, don't wait for another suspension. */ +smp_rmb (); + rnc_suspend_count + =sci_remote_node_context_is_suspended (&idev->rnc) + ?0 : idev->rnc.suspend_count; +dev_dbg (&ihost->pdev->dev,"%s: idev=%p, ireq=%p; started_request_count=%d, " +"rnc_suspend_count=%d, rnc.suspend_count=%d" "about to wait\n" , - __func__, idev, ireq, idev->started_request_count); + __func__, idev, ireq, idev->started_request_count, + rnc_suspend_count, idev->rnc.suspend_count);if (ireq) {/* Terminate a specific TC. */ sci_remote_device_terminate_req (ihost, idev,0 , ireq);spin_unlock_irqrestore (&ihost->scic_lock, flags); -wait_event (ihost->eventq, !test_bit (IREQ_ACTIVE , - &ireq->flags)); - +wait_event (ihost->eventq, + (isci_compare_suspendcount (idev, + rnc_suspend_count) + && !test_bit (IREQ_ACTIVE , &ireq->flags))); }else {/* Terminate all TCs. */ sci_remote_device_terminate_requests (idev);spin_unlock_irqrestore (&ihost->scic_lock, flags);wait_event (ihost->eventq, - idev->started_request_count ==0 ); + (isci_compare_suspendcount (idev, + rnc_suspend_count) + && idev->started_request_count ==0 )); }dev_dbg (&ihost->pdev->dev,"%s: idev=%p, wait done\n" , __func__, idev);
@@ -1234,19 +1255,20 @@ enum sci_status sci_remote_device_resume(return status; } -enum sci_status isci_remote_device_resume ( +enum sci_status isci_remote_device_resume_from_abort (struct isci_host *ihost, -struct isci_remote_device *idev, -scics_sds_remote_node_context_callback cb_fn, -void *cb_p) +struct isci_remote_device *idev) {unsigned long flags;enum sci_status status;spin_lock_irqsave (&ihost->scic_lock, flags); - status =sci_remote_device_resume (idev, cb_fn, cb_p); +/* Preserve any current resume callbacks, for instance from other +* resumptions. +*/ + status =sci_remote_device_resume (idev, idev->rnc.user_callback, + idev->rnc.user_cookie);spin_unlock_irqrestore (&ihost->scic_lock, flags); -return status; }/**
drivers/scsi/isci/remote_device.h +2 -4
@@ -357,11 +357,9 @@ enum sci_status sci_remote_device_resume(scics_sds_remote_node_context_callback cb_fn, void *cb_p); -enum sci_status isci_remote_device_resume ( +enum sci_status isci_remote_device_resume_from_abort (struct isci_host *ihost, -struct isci_remote_device *idev, -scics_sds_remote_node_context_callback cb_fn, -void *cb_p); +struct isci_remote_device *idev); enum sci_status isci_remote_device_reset( struct isci_host *ihost,
drivers/scsi/isci/remote_node_context.c +21 -0
@@ -90,6 +90,15 @@ bool sci_remote_node_context_is_ready(return false; } +bool sci_remote_node_context_is_suspended (struct sci_remote_node_context *sci_rnc) +{ +u32 current_state = sci_rnc->sm.current_state_id; + +if (current_state ==SCI_RNC_TX_RX_SUSPENDED ) +return true; +return false; +} +static union scu_remote_node_context *sci_rnc_by_id (struct isci_host *ihost,u16 id) { if (id < ihost->remote_node_entries &&
@@ -339,6 +348,13 @@ static void sci_remote_node_context_tx_rx_suspended_state_enter(struct sci_base_struct sci_remote_node_context *rnc =container_of (sm,typeof (*rnc), sm);struct isci_remote_device *idev =rnc_to_dev (rnc);struct isci_host *ihost = idev->owning_port->owning_controller; +u32 new_count = rnc->suspend_count +1 ; + +if (new_count ==0 ) + rnc->suspend_count =1 ; +else + rnc->suspend_count = new_count; +smp_wmb ();/* Terminate outstanding requests pending abort. */ sci_remote_device_abort_requests_pending_abort (idev);
@@ -634,6 +650,11 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *senum scis_sds_remote_node_context_states state; state = sci_rnc->sm.current_state_id; +dev_dbg (scirdev_to_dev (rnc_to_dev (sci_rnc)), +"%s: state %s, cb_fn = %p, cb_p = %p; dest_state = %d\n" , + __func__,rnc_state_name (state), cb_fn, cb_p, + sci_rnc->destination_state); +switch (state) {case SCI_RNC_INITIAL :if (sci_rnc->remote_node_index ==SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX )
drivers/scsi/isci/remote_node_context.h +3 -0
@@ -170,6 +170,7 @@ struct sci_remote_node_context {*/ u32 suspend_type;enum sci_remote_node_suspension_reasons suspend_reason; +u32 suspend_count;/** * This field is true if the remote node context is resuming from its current
@@ -203,6 +204,8 @@ void sci_remote_node_context_construct(struct sci_remote_node_context *rnc,bool sci_remote_node_context_is_ready (struct sci_remote_node_context *sci_rnc); +bool sci_remote_node_context_is_suspended (struct sci_remote_node_context *sci_rnc); +enum sci_status sci_remote_node_context_event_handler (struct sci_remote_node_context *sci_rnc,u32 event_code); enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_context *sci_rnc,
drivers/scsi/isci/task.c +7 -7
@@ -317,11 +317,11 @@ static int isci_task_execute_tmf(struct isci_host *ihost,spin_unlock_irqrestore (&ihost->scic_lock, flags); goto err_tci; } -/* The RNC must be unsuspended before the TMF can get a response. */ -sci_remote_device_resume (idev,NULL ,NULL ); -spin_unlock_irqrestore (&ihost->scic_lock, flags); +/* The RNC must be unsuspended before the TMF can get a response. */ +isci_remote_device_resume_from_abort (ihost, idev); +/* Wait for the TMF to complete, or a timeout. */ timeleft =wait_for_completion_timeout (&completion,msecs_to_jiffies (timeout_ms));
@@ -554,11 +554,11 @@ int isci_task_abort_task(struct sas_task *task) sas_protocol_ata(task->task_proto) || test_bit(IREQ_COMPLETE_IN_TARGET, &old_request->flags)) { -/* No task to send, so explicitly resume the device here */ -sci_remote_device_resume (idev,NULL ,NULL ); -spin_unlock_irqrestore (&ihost->scic_lock, flags); +/* No task to send, so explicitly resume the device here */ +isci_remote_device_resume_from_abort (ihost, idev); + dev_warn(&ihost->pdev->dev, "%s: %s request" " or complete_in_target (%d), thus no TMF\n",
@@ -757,7 +757,7 @@ static int isci_reset_device(struct isci_host *ihost, reset_stat =sas_phy_reset (phy, !dev_is_sata (dev));/* Explicitly resume the RNC here, since there was no task sent. */ -isci_remote_device_resume (ihost, idev,NULL ,NULL ); +isci_remote_device_resume_from_abort (ihost, idev);dev_dbg (&ihost->pdev->dev,"%s: idev %p complete, reset_stat=%d.\n" , __func__, idev, reset_stat);
PATCH 21/37 isci: When in the abort path, defeat other resume calls until done.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Completion of I/Os during the one of the abort path interface calls from libsas can drive remote device state changes and the resumption of the device RNC. This is a problem when the abort path is attempting to cleanup outstanding I/O at the same time - the resumption can prevent the termination from occuring correctly.
--- drivers/scsi/isci/remote_device.c | 2 drivers/scsi/isci/remote_device.h | 1 drivers/scsi/isci/remote_node_context.c | 126 ++++++++++++++++++++----------- 3 files changed, 83 insertions(+), 46 deletions(-)
drivers/scsi/isci/remote_device.c +2 -0
@@ -1266,6 +1266,7 @@ enum sci_status isci_remote_device_resume_from_abort(/* Preserve any current resume callbacks, for instance from other * resumptions. */ +clear_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags); status =sci_remote_device_resume (idev, idev->rnc.user_callback, idev->rnc.user_cookie);spin_unlock_irqrestore (&ihost->scic_lock, flags);
@@ -1501,6 +1502,7 @@ enum sci_status isci_remote_device_suspend_terminate(/* Put the device into suspension. */ spin_lock_irqsave (&ihost->scic_lock, flags); +set_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags);sci_remote_device_suspend (idev,SCI_SW_SUSPEND_LINKHANG_DETECT );spin_unlock_irqrestore (&ihost->scic_lock, flags);
drivers/scsi/isci/remote_device.h +1 -0
@@ -86,6 +86,7 @@ struct isci_remote_device {#define IDEV_IO_READY 4#define IDEV_IO_NCQERROR 5#define IDEV_RNC_LLHANG_ENABLED 6 +#define IDEV_ABORT_PATH_ACTIVE 7unsigned long flags;struct kref kref;struct isci_port *isci_port;
drivers/scsi/isci/remote_node_context.c +80 -46
163 lines not on this page · raw message
PATCH 22/37 isci: Callbacks to libsas occur under scic_lock and are synchronized.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
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.
--- drivers/scsi/isci/host.c | 10 +++------ drivers/scsi/isci/remote_device.c | 43 ++++++++++++++++++++++++++++++++----- 2 files changed, 40 insertions(+), 13 deletions(-)
drivers/scsi/isci/host.c +3 -7
@@ -1094,8 +1094,6 @@ void isci_host_completion_routine(unsigned long data)list_splice_init (&ihost->requests_to_complete, &completed_request_list); -spin_unlock_irq (&ihost->scic_lock); -/* Process any completions in the list. */ list_for_each_safe (current_position, next_position, &completed_request_list) {
@@ -1104,7 +1102,6 @@ void isci_host_completion_routine(unsigned long data) completed_node); task =isci_request_access_task (request); -/* Return the task to libsas */ if (task !=NULL ) {
@@ -1130,11 +1127,12 @@ void isci_host_completion_routine(unsigned long data) } } } +if (test_and_clear_bit (IREQ_ABORT_PATH_ACTIVE , &request->flags)) +wake_up_all (&ihost->eventq); -spin_lock_irq (&ihost->scic_lock);isci_free_tag (ihost, request->io_tag); -spin_unlock_irq (&ihost->scic_lock); } +spin_unlock_irq (&ihost->scic_lock);/* the coalesence timeout doubles at each encoding step, so * update it based on the ilog2 value of the outstanding requests
@@ -2685,8 +2683,6 @@ enum sci_status sci_controller_complete_io(struct isci_host *ihost, index =ISCI_TAG_TCI (ireq->io_tag);clear_bit (IREQ_ACTIVE , &ireq->flags); -if (test_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags)) -wake_up_all (&ihost->eventq);return SCI_SUCCESS ;default : dev_warn(&ihost->pdev->dev, "%s invalid state: %d\n",
drivers/scsi/isci/remote_device.c +37 -6
60 lines not on this page · raw message
PATCH 23/37 isci: Manage tag releases differently when aborting tasks.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
When an individual request is being terminated, the request's tag is managed in the terminate function.
--- drivers/scsi/isci/host.c | 3 ++- drivers/scsi/isci/remote_device.c | 11 +++++++---- drivers/scsi/isci/request.h | 1 + drivers/scsi/isci/task.c | 3 ++- 4 files changed, 12 insertions(+), 6 deletions(-)
drivers/scsi/isci/host.c +2 -1
@@ -1130,7 +1130,8 @@ void isci_host_completion_routine(unsigned long data)if (test_and_clear_bit (IREQ_ABORT_PATH_ACTIVE , &request->flags))wake_up_all (&ihost->eventq); -isci_free_tag (ihost, request->io_tag); +if (!test_bit (IREQ_NO_AUTO_FREE_TAG , &request->flags)) +isci_free_tag (ihost, request->io_tag); }spin_unlock_irq (&ihost->scic_lock);
drivers/scsi/isci/remote_device.c +7 -4
@@ -104,15 +104,15 @@ static enum sci_status sci_remote_device_terminate_req( int check_abort, struct isci_request *ireq) { - dev_dbg(&ihost->pdev->dev, -"%s: idev=%p; flags=%lx; req=%p; req target=%p\n" , - __func__, idev, idev->flags, ireq, ireq->target_device); -if (!test_bit (IREQ_ACTIVE , &ireq->flags) || (ireq->target_device != idev) || (check_abort && !test_bit (IREQ_PENDING_ABORT , &ireq->flags)))return SCI_SUCCESS ; +dev_dbg (&ihost->pdev->dev, +"%s: idev=%p; flags=%lx; req=%p; req target=%p\n" , + __func__, idev, idev->flags, ireq, ireq->target_device); +set_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags);return sci_controller_terminate_request (ihost, idev, ireq);
@@ -209,11 +209,14 @@ enum sci_status isci_remote_device_terminate_requests( rnc_suspend_count, idev->rnc.suspend_count);if (ireq) {/* Terminate a specific TC. */ +set_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags);sci_remote_device_terminate_req (ihost, idev,0 , ireq);spin_unlock_irqrestore (&ihost->scic_lock, flags);wait_event (ihost->eventq,isci_check_reqterm (ihost, idev, ireq, rnc_suspend_count)); +clear_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags); +isci_free_tag (ihost, ireq->io_tag); }else {/* Terminate all TCs. */ sci_remote_device_terminate_requests (idev);
drivers/scsi/isci/request.h +1 -0
@@ -87,6 +87,7 @@ struct isci_request {#define IREQ_PENDING_ABORT 4/* Set == device was not suspended yet */ #define IREQ_TC_ABORT_POSTED 5#define IREQ_ABORT_PATH_ACTIVE 6 +#define IREQ_NO_AUTO_FREE_TAG 7/* Set when being explicitly managed */ unsigned long flags;/* XXX kill ttype and ttype_ptr, allocate full sas_task */ union ttype_ptr_union {
drivers/scsi/isci/task.c +2 -1
@@ -719,7 +719,8 @@ isci_task_request_complete(struct isci_host *ihost,*/ set_bit (IREQ_TERMINATED , &ireq->flags); -isci_free_tag (ihost, ireq->io_tag); +if (!test_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags)) +isci_free_tag (ihost, ireq->io_tag);/* The task management part completes last. */ if (tmf_complete)
PATCH 24/37 isci: Fix RNC suspend call for SCI_RESUMING state.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Instead of immediately transitioning to the SCI_RNC_AWAIT_SUSPENSION state, handle the SCI_RNC_RESUMING suspend transition from the SCI_RNC_READY state like the SCI_RNC_INVALIDATING --> SCI_RNC_POSTING transitions do now, by setting the destination state for the entry into the READY state.
--- drivers/scsi/isci/remote_node_context.c | 12 ++++-------- 1 files changed, 4 insertions(+), 8 deletions(-)
drivers/scsi/isci/remote_node_context.c +4 -8
@@ -321,8 +321,6 @@ static void sci_remote_node_context_ready_state_enter(struct sci_base_state_mach {struct sci_remote_node_context *rnc =container_of (sm,typeof (*rnc), sm);enum sci_remote_node_context_destination_state dest_select; -scics_sds_remote_node_context_callback usr_cb = rnc->user_callback; -void *usr_param = rnc->user_cookie;int tell_user =1 ; dest_select = rnc->destination_state;
@@ -334,12 +332,10 @@ static void sci_remote_node_context_ready_state_enter(struct sci_base_state_mach rnc, rnc->suspend_reason, SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT); -if (dest_select ==RNC_DEST_SUSPENDED_RESUME ) { -sci_remote_node_context_resume (rnc, usr_cb, usr_param); +if (dest_select ==RNC_DEST_SUSPENDED_RESUME ) tell_user =0 ;/* Wait until ready again. */ - } } -if (tell_user && rnc->user_callback) +if (tell_user)sci_remote_node_context_notify_user (rnc); }
@@ -584,8 +580,6 @@ enum sci_status sci_remote_node_context_suspend( dest_param = sci_rnc->destination_state;switch (state) { -case SCI_RNC_RESUMING : -break ;/* The RNC has been posted, so start the suspend. */ case SCI_RNC_READY :break ;case SCI_RNC_INVALIDATING :
@@ -596,6 +590,8 @@ enum sci_status sci_remote_node_context_suspend(return SCI_FAILURE_INVALID_STATE ; }/* Fall through and handle like SCI_RNC_POSTING */ +case SCI_RNC_RESUMING : +/* Fall through and handle like SCI_RNC_POSTING */ case SCI_RNC_POSTING :/* Set the destination state to AWAIT - this signals the * entry into the SCI_RNC_READY state that a suspension
PATCH 25/37 isci: Wait for RNC resumption before leaving the abort path.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
In the case of TMF execution, or device resets, wait for the RNC to fully resume before returning to the caller. This ensures that the remote device will not fail I/O requests while waiting for the RNC resumption to complete.
--- drivers/scsi/isci/remote_device.c | 52 ++++++++++++++++++++++++++++++++++++- drivers/scsi/isci/remote_device.h | 3 ++ 2 files changed, 53 insertions(+), 2 deletions(-)
drivers/scsi/isci/remote_device.c +50 -2
@@ -1289,6 +1289,48 @@ enum sci_status sci_remote_device_resume(return status; } +static void isci_remote_device_resume_from_abort_complete (void *cbparam) +{ +struct isci_remote_device *idev = cbparam; +struct isci_host *ihost = idev->owning_port->owning_controller; +scics_sds_remote_node_context_callback abort_resume_cb = + idev->abort_resume_cb; + +dev_dbg (scirdev_to_dev (idev),"%s: passing-along resume: %p\n" , + __func__, abort_resume_cb); + +if (abort_resume_cb !=NULL ) { + idev->abort_resume_cb =NULL ; +abort_resume_cb (idev->abort_resume_cbparam); + } +clear_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags); +wake_up (&ihost->eventq); +} + + +void isci_remote_device_wait_for_resume_from_abort ( +struct isci_host *ihost, +struct isci_remote_device *idev) +{ +dev_dbg (scirdev_to_dev (idev),"%s: starting resume wait: %p\n" , + __func__, idev); + +#define MAX_RESUME_MSECS 5 +if (!wait_event_timeout (ihost->eventq, + (!test_bit (IDEV_ABORT_PATH_RESUME_PENDING , + &idev->flags) + ||test_bit (IDEV_STOP_PENDING , &idev->flags)), +msecs_to_jiffies (MAX_RESUME_MSECS ))) { + +dev_warn (scirdev_to_dev (idev),"%s: #### Timeout waiting for " +"resume: %p\n" , __func__, idev); + } +clear_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags); + +dev_dbg (scirdev_to_dev (idev),"%s: resume wait done: %p\n" , + __func__, idev); +} +enum sci_status isci_remote_device_resume_from_abort (struct isci_host *ihost,struct isci_remote_device *idev)
@@ -1300,12 +1342,18 @@ enum sci_status isci_remote_device_resume_from_abort(/* Preserve any current resume callbacks, for instance from other * resumptions. */ + idev->abort_resume_cb = idev->rnc.user_callback; + idev->abort_resume_cbparam = idev->rnc.user_cookie; +set_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags);clear_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags); - status =sci_remote_device_resume (idev, idev->rnc.user_callback, - idev->rnc.user_cookie); + status =sci_remote_device_resume ( + idev, isci_remote_device_resume_from_abort_complete, + idev);spin_unlock_irqrestore (&ihost->scic_lock, flags); +isci_remote_device_wait_for_resume_from_abort (ihost, idev);return status; } +/** * sci_remote_device_start() - This method will start the supplied remote * device. This method enables normal IO requests to flow through to the
drivers/scsi/isci/remote_device.h +3 -0
@@ -87,6 +87,7 @@ struct isci_remote_device {#define IDEV_IO_NCQERROR 5#define IDEV_RNC_LLHANG_ENABLED 6#define IDEV_ABORT_PATH_ACTIVE 7 +#define IDEV_ABORT_PATH_RESUME_PENDING 8unsigned long flags;struct kref kref;struct isci_port *isci_port;
@@ -101,6 +102,8 @@ struct isci_remote_device {u32 started_request_count;struct isci_request *working_request;u32 not_ready_reason; +scics_sds_remote_node_context_callback abort_resume_cb; +void *abort_resume_cbparam; };#define ISCI_REMOTE_DEVICE_START_TIMEOUT 5000
PATCH 26/37 isci: Directly control IREQ_ABORT_PATH_ACTIVE when completing TMFs.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
TMF requests, unlike normal I/O requests, need to handle I/O management conditions in the completion function because TMFs are not handled in the completion tasklet.
--- drivers/scsi/isci/task.c | 3 +++ 1 files changed, 3 insertions(+), 0 deletions(-)
drivers/scsi/isci/task.c +3 -0
@@ -719,6 +719,9 @@ isci_task_request_complete(struct isci_host *ihost,*/ set_bit (IREQ_TERMINATED , &ireq->flags); +if (test_and_clear_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags)) +wake_up_all (&ihost->eventq); +if (!test_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags))isci_free_tag (ihost, ireq->io_tag);
PATCH 27/37 isci: Add protocol indicator for TMF requests.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Requests contructed as task management requests need to have the protocol indicator set so the completion decode can observe any RNC suspension conditions.
--- drivers/scsi/isci/request.c | 6 ++++++ 1 files changed, 6 insertions(+), 0 deletions(-)
drivers/scsi/isci/request.c +6 -0
@@ -3130,6 +3130,12 @@ enum sci_status sci_task_request_construct(struct isci_host *ihost,if (dev->dev_type ==SAS_END_DEV ||dev_is_sata (dev)) {set_bit (IREQ_TMF , &ireq->flags);memset (ireq->tc,0 ,sizeof (struct scu_task_context )); + +/* Set the protocol indicator. */ +if (dev_is_sata (dev)) + ireq->protocol =SAS_PROTOCOL_STP ; +else + ireq->protocol =SAS_PROTOCOL_SSP ; }else status =SCI_FAILURE_UNSUPPORTED_PROTOCOL ;
PATCH 28/37 isci: Added timeouts to RNC suspensions in the abort path.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
This change adds timeouts to the RNC suspension wait. It makes the suspend and resume timeouts the same.
The previous resume timeout of 5 ms was too short, and timeouts were seen in resumptions of devices in the abort task/LUN reset path - which would receive an RNC resumed message within a tenth of a second later.
--- drivers/scsi/isci/remote_device.c | 58 +++++++++++++++++++++++++++---- drivers/scsi/isci/remote_node_context.c | 8 ++-- 2 files changed, 55 insertions(+), 11 deletions(-)
drivers/scsi/isci/remote_device.c +51 -7
@@ -207,23 +207,67 @@ enum sci_status isci_remote_device_terminate_requests("about to wait\n" , __func__, idev, ireq, idev->started_request_count, rnc_suspend_count, idev->rnc.suspend_count); + +#define MAX_SUSPEND_MSECS 10000if (ireq) {/* Terminate a specific TC. */ set_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags);sci_remote_device_terminate_req (ihost, idev,0 , ireq);spin_unlock_irqrestore (&ihost->scic_lock, flags); -wait_event (ihost->eventq, -isci_check_reqterm (ihost, idev, ireq, - rnc_suspend_count)); +if (!wait_event_timeout (ihost->eventq, +isci_check_reqterm (ihost, idev, ireq, + rnc_suspend_count), +msecs_to_jiffies (MAX_SUSPEND_MSECS ))) { + +dev_warn (&ihost->pdev->dev,"%s host%d timeout single\n" , + __func__, ihost->id); +dev_dbg (&ihost->pdev->dev, +"%s: ******* Timeout waiting for " +"suspend; idev=%p, current state %s; " +"started_request_count=%d, flags=%lx\n\t" +"rnc_suspend_count=%d, rnc.suspend_count=%d " +"RNC: current state %s, current " +"suspend_type %x dest state %d;\n" +"ireq=%p, ireq->flags = %lx\n" , + __func__, idev, +dev_state_name (idev->sm.current_state_id), + idev->started_request_count, idev->flags, + rnc_suspend_count, idev->rnc.suspend_count, +rnc_state_name (idev->rnc.sm.current_state_id), + idev->rnc.suspend_type, + idev->rnc.destination_state, + ireq, ireq->flags); + }clear_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags);isci_free_tag (ihost, ireq->io_tag); }else {/* Terminate all TCs. */ sci_remote_device_terminate_requests (idev);spin_unlock_irqrestore (&ihost->scic_lock, flags); -wait_event (ihost->eventq, -isci_check_devempty (ihost, idev, - rnc_suspend_count)); +if (!wait_event_timeout (ihost->eventq, +isci_check_devempty (ihost, idev, + rnc_suspend_count), +msecs_to_jiffies (MAX_SUSPEND_MSECS ))) { + +dev_warn (&ihost->pdev->dev,"%s host%d timeout all\n" , + __func__, ihost->id); +dev_dbg (&ihost->pdev->dev, +"%s: ******* Timeout waiting for " +"suspend; idev=%p, current state %s; " +"started_request_count=%d, flags=%lx\n\t" +"rnc_suspend_count=%d, " +"RNC: current state %s, " +"rnc.suspend_count=%d, current " +"suspend_type %x dest state %d\n" , + __func__, idev, +dev_state_name (idev->sm.current_state_id), + idev->started_request_count, idev->flags, + rnc_suspend_count, +rnc_state_name (idev->rnc.sm.current_state_id), + idev->rnc.suspend_count, + idev->rnc.suspend_type, + idev->rnc.destination_state); + } }dev_dbg (&ihost->pdev->dev,"%s: idev=%p, wait done\n" , __func__, idev);
@@ -1315,7 +1359,7 @@ void isci_remote_device_wait_for_resume_from_abort(dev_dbg (scirdev_to_dev (idev),"%s: starting resume wait: %p\n" , __func__, idev); -#define MAX_RESUME_MSECS 5 +#define MAX_RESUME_MSECS 10000 if (!wait_event_timeout(ihost->eventq, (!test_bit(IDEV_ABORT_PATH_RESUME_PENDING, &idev->flags)
drivers/scsi/isci/remote_node_context.c +4 -4
@@ -445,7 +445,7 @@ enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_concase SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX :/* We really dont care if the hardware is going to suspend * the device since it's being invalidated anyway */ -dev_dbg (scirdev_to_dev (rnc_to_dev (sci_rnc)), +dev_warn (scirdev_to_dev (rnc_to_dev (sci_rnc)),"%s: SCIC Remote Node Context 0x%p was " "suspeneded by hardware while being " "invalidated.\n" , __func__, sci_rnc);
@@ -464,7 +464,7 @@ enum sci_status sci_remote_node_context_event_handler(struct sci_remote_node_concase SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX :/* We really dont care if the hardware is going to suspend * the device since it's being resumed anyway */ -dev_dbg (scirdev_to_dev (rnc_to_dev (sci_rnc)), +dev_warn (scirdev_to_dev (rnc_to_dev (sci_rnc)),"%s: SCIC Remote Node Context 0x%p was " "suspeneded by hardware while being resumed.\n" , __func__, sci_rnc);
@@ -568,9 +568,9 @@ enum sci_status sci_remote_node_context_suspend(RNC_DEST_UNSPECIFIED ;dev_dbg (scirdev_to_dev (idev), -"%s: current state %d, current suspend_type %x dest state %d," +"%s: current state %s, current suspend_type %x dest state %d," " arg suspend_reason %d, arg suspend_type %x" , - __func__, state, sci_rnc->suspend_type, + __func__,rnc_state_name (state), sci_rnc->suspend_type, sci_rnc->destination_state, suspend_reason, suspend_type);
PATCH 29/37 isci: Change the phy control and link reset interface for HW reasons.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
There is an apparent HW lockup caused when the PE is disabled while there is an outstanding TC in progress. This change puts the link into OOB to force the TC to end before the PE is disabled.
--- drivers/scsi/isci/phy.c | 2 ++ 1 files changed, 2 insertions(+), 0 deletions(-)
drivers/scsi/isci/phy.c +2 -0
@@ -1387,12 +1387,14 @@ int isci_phy_control(struct asd_sas_phy *sas_phy,switch (func) {case PHY_FUNC_DISABLE :spin_lock_irqsave (&ihost->scic_lock, flags); +scu_link_layer_start_oob (iphy);sci_phy_stop (iphy);spin_unlock_irqrestore (&ihost->scic_lock, flags);break ;case PHY_FUNC_LINK_RESET :spin_lock_irqsave (&ihost->scic_lock, flags); +scu_link_layer_start_oob (iphy);sci_phy_stop (iphy);sci_phy_start (iphy);spin_unlock_irqrestore (&ihost->scic_lock, flags);
PATCH 30/37 isci: Don't wait for an RNC suspend if it's being destroyed.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Make sure that the wait for suspend can handle the RNC destruction case.
--- drivers/scsi/isci/remote_device.c | 20 ++++++++++++++++---- drivers/scsi/isci/remote_node_context.c | 5 +++++ drivers/scsi/isci/remote_node_context.h | 7 +++++++ 3 files changed, 28 insertions(+), 4 deletions(-)
drivers/scsi/isci/remote_device.c +16 -4
@@ -142,7 +142,12 @@ static bool isci_compare_suspendcount( u32 localcount) {smp_rmb (); -return localcount != idev->rnc.suspend_count; + +/* Check for a change in the suspend count, or the RNC +* being destroyed. +*/ +return (localcount != idev->rnc.suspend_count) + ||sci_remote_node_context_is_being_destroyed (&idev->rnc); } static bool isci_check_reqterm(
@@ -1380,7 +1385,8 @@ enum sci_status isci_remote_device_resume_from_abort( struct isci_remote_device *idev) {unsigned long flags; -enum sci_status status; +enum sci_status status =SCI_SUCCESS ; +int destroyed;spin_lock_irqsave (&ihost->scic_lock, flags);/* Preserve any current resume callbacks, for instance from other
@@ -1390,11 +1396,17 @@ enum sci_status isci_remote_device_resume_from_abort( idev->abort_resume_cbparam = idev->rnc.user_cookie;set_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags);clear_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags); - status =sci_remote_device_resume ( + destroyed =sci_remote_node_context_is_being_destroyed (&idev->rnc); +if (!destroyed) + status =sci_remote_device_resume ( idev, isci_remote_device_resume_from_abort_complete, idev);spin_unlock_irqrestore (&ihost->scic_lock, flags); -isci_remote_device_wait_for_resume_from_abort (ihost, idev); +if (!destroyed) +isci_remote_device_wait_for_resume_from_abort (ihost, idev); +else +clear_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags); +return status; }
drivers/scsi/isci/remote_node_context.c +5 -0
@@ -270,6 +270,8 @@ static void sci_remote_node_context_invalidate_context_buffer(struct sci_remote_static void sci_remote_node_context_initial_state_enter (struct sci_base_state_machine *sm) {struct sci_remote_node_context *rnc =container_of (sm,typeof (*rnc), sm); +struct isci_remote_device *idev =rnc_to_dev (rnc); +struct isci_host *ihost = idev->owning_port->owning_controller;/* Check to see if we have gotten back to the initial state because * someone requested to destroy the remote node context object.
@@ -277,6 +279,9 @@ static void sci_remote_node_context_initial_state_enter(struct sci_base_state_maif (sm->previous_state_id ==SCI_RNC_INVALIDATING ) { rnc->destination_state =RNC_DEST_UNSPECIFIED ;sci_remote_node_context_notify_user (rnc); + +smp_wmb (); +wake_up (&ihost->eventq); } }
drivers/scsi/isci/remote_node_context.h +7 -0
@@ -226,4 +226,11 @@ enum sci_status sci_remote_node_context_start_io(struct sci_remote_node_contextint sci_remote_node_context_is_safe_to_abort (struct sci_remote_node_context *sci_rnc); +static inline bool sci_remote_node_context_is_being_destroyed ( +struct sci_remote_node_context *sci_rnc) +{ +return ((sci_rnc->sm.current_state_id ==SCI_RNC_INVALIDATING ) + && (sci_rnc->destination_state ==RNC_DEST_FINAL )) + || (sci_rnc->sm.current_state_id ==SCI_RNC_INITIAL ); +}#endif /* _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ */
PATCH 31/37 isci: Restore the ATAPI device RNC management code.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
The ATAPI specific and STP general RNC suspension code had been incorrectly removed from the remote device code.
--- drivers/scsi/isci/remote_device.c | 49 ++++++++++++++++++++++--------------- drivers/scsi/isci/remote_device.h | 2 ++ drivers/scsi/isci/request.c | 3 ++ 3 files changed, 34 insertions(+), 20 deletions(-)
drivers/scsi/isci/remote_device.c +29 -20
@@ -72,8 +72,8 @@ const char *dev_state_name(enum sci_remote_device_states state) }#undef C -static enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev, -enum sci_remote_node_suspension_reasons reason) +enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev, +enum sci_remote_node_suspension_reasons reason) {return sci_remote_node_context_suspend (&idev->rnc, reason,SCI_SOFTWARE_SUSPEND_EXPECTED_EVENT );
@@ -565,6 +565,8 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev, u32 event_code) {enum sci_status status; +struct sci_base_state_machine *sm = &idev->sm; +enum sci_remote_device_states state = sm->current_state_id;switch (scu_get_event_type (event_code)) {case SCU_EVENT_TYPE_RNC_OPS_MISC :
@@ -603,6 +605,30 @@ enum sci_status sci_remote_device_event_handler(struct isci_remote_device *idev,if (status !=SCI_SUCCESS )return status; +/* Decode device-specific states that may require an RNC resume during +* normal operation. When the abort path is active, these resumes are +* managed when the abort path exits. +*/ +if (state ==SCI_STP_DEV_ATAPI_ERROR ) { +/* For ATAPI error state resume the RNC right away. */ +if (scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX || +scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX ) { +return sci_remote_node_context_resume (&idev->rnc, + atapi_remote_device_resume_done, + idev); + } + } + +if (state ==SCI_STP_DEV_IDLE ) { + +/* We pick up suspension events to handle specifically to this +* state. We resume the RNC right away. +*/ +if (scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX || +scu_get_event_type (event_code) ==SCU_EVENT_TYPE_RNC_SUSPEND_TX_RX ) + status =sci_remote_node_context_resume (&idev->rnc,NULL ,NULL ); + } +return status; }
@@ -1137,21 +1163,6 @@ static void sci_stp_remote_device_ready_ncq_error_substate_enter(struct sci_base idev->not_ready_reason); } -static void sci_stp_remote_device_atapi_error_substate_enter ( -struct sci_base_state_machine *sm) -{ -struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm); - -/* This state is entered when an I/O is decoded with an error -* condition. By this point the RNC expected suspension state is set. -* The error conditions suspend the device, so unsuspend here if -* possible. -*/ -sci_remote_node_context_resume (&idev->rnc, - atapi_remote_device_resume_done, - idev); -} -static void sci_smp_remote_device_ready_idle_substate_enter (struct sci_base_state_machine *sm) {struct isci_remote_device *idev =container_of (sm,typeof (*idev), sm);
@@ -1202,9 +1213,7 @@ static const struct sci_base_state sci_remote_device_state_table[] = { [SCI_STP_DEV_NCQ_ERROR] = { .enter_state = sci_stp_remote_device_ready_ncq_error_substate_enter, }, - [SCI_STP_DEV_ATAPI_ERROR] = { - .enter_state = sci_stp_remote_device_atapi_error_substate_enter, - }, + [SCI_STP_DEV_ATAPI_ERROR] = { }, [SCI_STP_DEV_AWAIT_RESET] = { }, [SCI_SMP_DEV_IDLE] = { .enter_state = sci_smp_remote_device_ready_idle_substate_enter,
drivers/scsi/isci/remote_device.h +2 -0
@@ -382,4 +382,6 @@ enum sci_status isci_remote_device_terminate_requests(struct isci_host *ihost, struct isci_remote_device *idev, struct isci_request *ireq); +enum sci_status sci_remote_device_suspend (struct isci_remote_device *idev, +enum sci_remote_node_suspension_reasons reason);#endif /* !defined(_ISCI_REMOTE_DEVICE_H_) */
drivers/scsi/isci/request.c +3 -0
@@ -2118,6 +2118,9 @@ static enum sci_status stp_request_udma_await_tc_event(struct isci_request *ireq* completion. */ if (ireq->stp.rsp.fis_type ==FIS_REGD2H ) { +sci_remote_device_suspend (ireq->target_device, +SCI_SW_SUSPEND_NORMAL ); + ireq->scu_status =SCU_TASK_DONE_CHECK_RESPONSE ; ireq->sci_status =SCI_FAILURE_IO_RESPONSE_VALID ;sci_change_state (&ireq->sm,SCI_REQ_COMPLETED );
PATCH 32/37 isci: Check IDEV_GONE before performing abort path operations.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
In the link fail path, set IDEV_GONE for every device on the domain when the last link in the port fails.
In the abort path functions like isci_reset_device, make sure that there has not already been a detected domain failure with the device by checking IDEV_GONE, before performing any kind of hard reset, SMP phy control, or TMF operation.
The check for IDEV_GONE makes sure that the device in the abort path really has control of the port with which it is associated. This prevents starting hard resets at incorrect times and scheduling unnecessary LUN resets for SATA devices.
--- drivers/scsi/isci/port.c | 23 +++++++++++++++++++ drivers/scsi/isci/task.c | 55 ++++++++++++++++++++++++++++------------------ 2 files changed, 57 insertions(+), 21 deletions(-)
drivers/scsi/isci/port.c +23 -0
@@ -240,9 +240,32 @@ static void isci_port_link_down(struct isci_host *isci_host,struct isci_phy *isci_phy, struct isci_port *isci_port) { + struct isci_remote_device *isci_device; +dev_dbg (&isci_host->pdev->dev,"%s: isci_port = %p\n" , __func__, isci_port); +if (isci_port) { + +/* check to see if this is the last phy on this port. */ +if (isci_phy->sas_phy.port && + isci_phy->sas_phy.port->num_phys ==1 ) { +/* change the state for all devices on this port. The +* next task sent to this device will be returned as +* SAS_TASK_UNDELIVERED, and the scsi mid layer will +* remove the target +*/ +list_for_each_entry (isci_device, + &isci_port->remote_dev_list, + node) { +dev_dbg (&isci_host->pdev->dev, +"%s: isci_device = %p\n" , + __func__, isci_device); +set_bit (IDEV_GONE , &isci_device->flags); + } + } + } +/* Notify libsas of the borken link, this will trigger calls to our * isci_port_deformed and isci_dev_gone functions. */
drivers/scsi/isci/task.c +34 -21
103 lines not on this page · raw message
PATCH 33/37 isci: Remove obviated host callback list.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Since the callbacks to libsas now occur under scic_lock, there is no longer any reason to save the completed requests in a separate list for completion to libsas.
--- drivers/scsi/isci/host.c | 78 ++++++++++++++----------------------------- drivers/scsi/isci/host.h | 2 + drivers/scsi/isci/init.c | 1 - drivers/scsi/isci/request.c | 14 ++------ drivers/scsi/isci/request.h | 2 - 5 files changed, 31 insertions(+), 66 deletions(-)
drivers/scsi/isci/host.c +26 -52
@@ -1066,6 +1066,32 @@ static void sci_controller_completion_handler(struct isci_host *ihost)writel (0 , &ihost->smu_registers->interrupt_mask); } +void ireq_done (struct isci_host *ihost,struct isci_request *ireq,struct sas_task *task) +{ + task->lldd_task =NULL ; +if (!test_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags) && + !(task->task_state_flags &SAS_TASK_STATE_ABORTED )) { +if (test_bit (IREQ_COMPLETE_IN_TARGET , &ireq->flags)) { +/* Normal notification (task_done) */ +dev_dbg (&ihost->pdev->dev, +"%s: Normal - ireq/task = %p/%p\n" , + __func__, ireq, task); + + task->task_done (task); + }else { +dev_dbg (&ihost->pdev->dev, +"%s: Error - ireq/task = %p/%p\n" , + __func__, ireq, task); + +sas_task_abort (task); + } + } +if (test_and_clear_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags)) +wake_up_all (&ihost->eventq); + +if (!test_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags)) +isci_free_tag (ihost, ireq->io_tag); +}/** * isci_host_completion_routine() - This function is the delayed service * routine that calls the sci core library's completion handler. It's
@@ -1077,62 +1103,10 @@ static void sci_controller_completion_handler(struct isci_host *ihost)void isci_host_completion_routine (unsigned long data) {struct isci_host *ihost = (struct isci_host *)data; -struct list_head completed_request_list; -struct list_head *current_position; -struct list_head *next_position; -struct isci_request *request; -struct sas_task *task;u16 active; -INIT_LIST_HEAD (&completed_request_list); -spin_lock_irq (&ihost->scic_lock); -sci_controller_completion_handler (ihost); - -/* Take the lists of completed I/Os from the host. */ -list_splice_init (&ihost->requests_to_complete, - &completed_request_list); - -/* Process any completions in the list. */ -list_for_each_safe (current_position, next_position, - &completed_request_list) { - - request = list_entry(current_position, struct isci_request, - completed_node); - task =isci_request_access_task (request); - -/* Return the task to libsas */ -if (task !=NULL ) { - - task->lldd_task =NULL ; -if (!test_bit (IREQ_ABORT_PATH_ACTIVE , &request->flags) && - !(task->task_state_flags &SAS_TASK_STATE_ABORTED )) { -if (test_bit (IREQ_COMPLETE_IN_TARGET , - &request->flags)) { - -/* Normal notification (task_done) */ -dev_dbg (&ihost->pdev->dev,"%s: Normal" -" - request/task = %p/%p\n" , - __func__, request, task); - - task->task_done (task); - }else { -dev_warn (&ihost->pdev->dev, -"%s: Error - request/task" -" = %p/%p\n" , - __func__, request, task); - -sas_task_abort (task); - } - } - } -if (test_and_clear_bit (IREQ_ABORT_PATH_ACTIVE , &request->flags)) -wake_up_all (&ihost->eventq); - -if (!test_bit (IREQ_NO_AUTO_FREE_TAG , &request->flags)) -isci_free_tag (ihost, request->io_tag); - }spin_unlock_irq (&ihost->scic_lock);/* the coalesence timeout doubles at each encoding step, so
drivers/scsi/isci/host.h +1 -1
@@ -202,7 +202,6 @@ struct isci_host {wait_queue_head_t eventq;struct Scsi_Host *shost;struct tasklet_struct completion_tasklet; -struct list_head requests_to_complete;spinlock_t scic_lock;struct isci_request *reqs[SCI_MAX_IO_REQUESTS ];struct isci_remote_device devices[SCI_MAX_REMOTE_DEVICES ];
@@ -466,6 +465,7 @@ void isci_host_scan_start(struct Scsi_Host *);u16 isci_alloc_tag (struct isci_host *ihost);enum sci_status isci_free_tag (struct isci_host *ihost,u16 io_tag);void isci_tci_free (struct isci_host *ihost,u16 tci); +void ireq_done (struct isci_host *ihost,struct isci_request *ireq,struct sas_task *task);int isci_host_init (struct isci_host *);void isci_host_completion_routine (unsigned long data);
drivers/scsi/isci/init.c +0 -1
@@ -559,7 +559,6 @@ static struct isci_host *isci_host_alloc(struct pci_dev *pdev, int id)return NULL ; } -INIT_LIST_HEAD (&ihost->requests_to_complete);for (i =0 ; i <SCI_MAX_PORTS ; i++) {struct isci_port *iport = &ihost->ports[i];
drivers/scsi/isci/request.c +4 -10
@@ -2748,13 +2748,9 @@ static void isci_request_io_request_complete(struct isci_host *ihost,enum exec_status status =SAS_ABORTED_TASK ;dev_dbg (&ihost->pdev->dev, -"%s: request = %p, task = %p,\n" +"%s: request = %p, task = %p, " "task->data_dir = %d completion_status = 0x%x\n" , - __func__, - request, - task, - task->data_dir, - completion_status); + __func__, request, task, task->data_dir, completion_status);/* The request is done from an SCU HW perspective. */
@@ -2955,9 +2951,6 @@ static void isci_request_io_request_complete(struct isci_host *ihost, }spin_unlock_irqrestore (&task->task_state_lock, task_flags); -/* Add to the completed list. */ -list_add (&request->completed_node, &ihost->requests_to_complete); -/* complete the io request to the core. */ sci_controller_complete_io (ihost, request->target_device, request);
@@ -2966,6 +2959,8 @@ static void isci_request_io_request_complete(struct isci_host *ihost,* task to recognize the already completed case. */ set_bit (IREQ_TERMINATED , &request->flags); + +ireq_done (ihost, request, task); }static void sci_request_started_state_enter (struct sci_base_state_machine *sm)
@@ -3416,7 +3411,6 @@ static struct isci_request *isci_request_from_tag(struct isci_host *ihost, u16 t ireq->io_request_completion =NULL ; ireq->flags =0 ; ireq->num_sg_entries =0 ; -INIT_LIST_HEAD (&ireq->completed_node);return ireq; }
drivers/scsi/isci/request.h +0 -2
@@ -95,8 +95,6 @@ struct isci_request {struct isci_tmf *tmf_task_ptr;/* When ttype==tmf_task */ } ttype_ptr;struct isci_host *isci_host; -/* For use in the requests_to_{complete|abort} lists: */ -struct list_head completed_node;dma_addr_t request_daddr;dma_addr_t zero_scatter_daddr;unsigned int num_sg_entries;
PATCH 34/37 isci: Manage the IREQ_NO_AUTO_FREE_TAG under scic_lock.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
Since there is a possibilty of a timeout waiting for the RNC suspension, handle the exit case from the task termination under scic_lock, and leave the tag allocated if the termination timed-out.
--- drivers/scsi/isci/remote_device.c | 5 ++++- 1 files changed, 4 insertions(+), 1 deletions(-)
drivers/scsi/isci/remote_device.c +4 -1
@@ -243,8 +243,11 @@ enum sci_status isci_remote_device_terminate_requests( idev->rnc.destination_state, ireq, ireq->flags); } +spin_lock_irqsave (&ihost->scic_lock, flags);clear_bit (IREQ_NO_AUTO_FREE_TAG , &ireq->flags); -isci_free_tag (ihost, ireq->io_tag); +if (!test_bit (IREQ_ABORT_PATH_ACTIVE , &ireq->flags)) +isci_free_tag (ihost, ireq->io_tag); +spin_unlock_irqrestore (&ihost->scic_lock, flags); }else {/* Terminate all TCs. */ sci_remote_device_terminate_requests (idev);
PATCH 35/37 isci: Fix RNC AWAIT_SUSPENSION->INVALIDATING transition.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
The RNC state machine would incorrectly transition from SCI_RNC_AWAIT_SUSPENSION directly to SCI_RNC_INVALIDATING when a destruct request was made. This would skip the increment of the suspension count and the abort of pending TCs (although the invalidating state would at least cleanup outstanding TCs).
Instead, the RNC will transition to SCI_RNC_SUSPENDED and then start the destruction process.
--- drivers/scsi/isci/remote_node_context.c | 18 +++++++++++++----- 1 files changed, 13 insertions(+), 5 deletions(-)
drivers/scsi/isci/remote_node_context.c +13 -5
@@ -222,13 +222,19 @@ static void sci_remote_node_context_notify_user(static void sci_remote_node_context_continue_state_transitions (struct sci_remote_node_context *rnc) { -if ((rnc->destination_state ==RNC_DEST_READY ) || - (rnc->destination_state ==RNC_DEST_SUSPENDED_RESUME )) { +switch (rnc->destination_state) { +case RNC_DEST_READY : +case RNC_DEST_SUSPENDED_RESUME : rnc->destination_state =RNC_DEST_READY ; +/* Fall through... */ +case RNC_DEST_FINAL :sci_remote_node_context_resume (rnc, rnc->user_callback, - rnc->user_cookie); - }else + rnc->user_cookie); +break ; +default : rnc->destination_state =RNC_DEST_UNSPECIFIED ; +break ; + } }static void sci_remote_node_context_validate_context_buffer (struct sci_remote_node_context *sci_rnc)
@@ -539,10 +545,12 @@ enum sci_status sci_remote_node_context_destruct(struct sci_remote_node_contextcase SCI_RNC_READY :case SCI_RNC_TX_SUSPENDED :case SCI_RNC_TX_RX_SUSPENDED : -case SCI_RNC_AWAIT_SUSPENSION :sci_remote_node_context_setup_to_destroy (sci_rnc, cb_fn, cb_p);sci_change_state (&sci_rnc->sm,SCI_RNC_INVALIDATING );return SCI_SUCCESS ; +case SCI_RNC_AWAIT_SUSPENSION : +sci_remote_node_context_setup_to_destroy (sci_rnc, cb_fn, cb_p); +return SCI_SUCCESS ;case SCI_RNC_INITIAL : dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)), "%s: invalid state: %s\n", __func__,
PATCH 36/37 isci: Fixed RNC bug that lost the suspension or resumption during destroy
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
This fix corrects the saving of resume parameters when the destruction of the RNC has already been directed, and makes sure not to overwrite the RNC destruction callbacks.
--- drivers/scsi/isci/remote_node_context.c | 96 ++++++++++++------------------- 1 files changed, 38 insertions(+), 58 deletions(-)
drivers/scsi/isci/remote_node_context.c +38 -58
@@ -160,15 +160,6 @@ static void sci_remote_node_context_construct_buffer(struct sci_remote_node_cont rnc->ssp.oaf_source_zone_group =0 ; rnc->ssp.oaf_more_compatibility_features =0 ; } - -static void sci_remote_node_context_save_cbparams ( -struct sci_remote_node_context *sci_rnc, -scics_sds_remote_node_context_callback callback, -void *callback_parameter) -{ - sci_rnc->user_callback = callback; - sci_rnc->user_cookie = callback_parameter; -}/** * * @sci_rnc:
@@ -187,9 +178,10 @@ static void sci_remote_node_context_setup_to_resume( {if (sci_rnc->destination_state !=RNC_DEST_FINAL ) { sci_rnc->destination_state = dest_param; -if (callback !=NULL ) -sci_remote_node_context_save_cbparams ( - sci_rnc, callback, callback_parameter); +if (callback !=NULL ) { + sci_rnc->user_callback = callback; + sci_rnc->user_cookie = callback_parameter; + } } }
@@ -610,7 +602,8 @@ enum sci_status sci_remote_node_context_suspend(* entry into the SCI_RNC_READY state that a suspension * needs to be done immediately. */ - sci_rnc->destination_state =RNC_DEST_SUSPENDED ; +if (sci_rnc->destination_state !=RNC_DEST_FINAL ) + sci_rnc->destination_state =RNC_DEST_SUSPENDED ; sci_rnc->suspend_type = suspend_type; sci_rnc->suspend_reason = suspend_reason;return SCI_SUCCESS ;
@@ -680,12 +673,9 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *sif (sci_rnc->remote_node_index ==SCIC_SDS_REMOTE_NODE_CONTEXT_INVALID_INDEX )return SCI_FAILURE_INVALID_STATE ; -if (test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) -sci_remote_node_context_save_cbparams (sci_rnc, cb_fn, - cb_p); -else { -sci_remote_node_context_setup_to_resume (sci_rnc, cb_fn, - cb_p,RNC_DEST_READY ); +sci_remote_node_context_setup_to_resume (sci_rnc, cb_fn, cb_p, +RNC_DEST_READY ); +if (!test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) {sci_remote_node_context_construct_buffer (sci_rnc);sci_change_state (&sci_rnc->sm,SCI_RNC_POSTING ); }
@@ -694,38 +684,30 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *scase SCI_RNC_POSTING :case SCI_RNC_INVALIDATING :case SCI_RNC_RESUMING : -if (test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) -sci_remote_node_context_save_cbparams (sci_rnc, cb_fn, - cb_p); -else { -/* We are still waiting to post when a resume was -* requested. +/* We are still waiting to post when a resume was +* requested. +*/ +switch (sci_rnc->destination_state) { +case RNC_DEST_SUSPENDED : +case RNC_DEST_SUSPENDED_RESUME : +/* Previously waiting to suspend after posting. +* Now continue onto resumption. */ -switch (sci_rnc->destination_state) { -case RNC_DEST_SUSPENDED : -case RNC_DEST_SUSPENDED_RESUME : -/* Previously waiting to suspend after posting. -* Now continue onto resumption. -*/ -sci_remote_node_context_setup_to_resume ( - sci_rnc, cb_fn, cb_p, -RNC_DEST_SUSPENDED_RESUME ); -break ; -default : -sci_remote_node_context_setup_to_resume ( - sci_rnc, cb_fn, cb_p, -RNC_DEST_READY ); -break ; - } +sci_remote_node_context_setup_to_resume ( + sci_rnc, cb_fn, cb_p, +RNC_DEST_SUSPENDED_RESUME ); +break ; +default : +sci_remote_node_context_setup_to_resume ( + sci_rnc, cb_fn, cb_p, +RNC_DEST_READY ); +break ; }return SCI_SUCCESS ;case SCI_RNC_TX_SUSPENDED :case SCI_RNC_TX_RX_SUSPENDED : -if (test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) -sci_remote_node_context_save_cbparams (sci_rnc, cb_fn, - cb_p); -else { + {struct domain_device *dev = idev->domain_dev;/* If this is an expander attached SATA device we must * invalidate and repost the RNC since this is the only
@@ -735,23 +717,21 @@ enum sci_status sci_remote_node_context_resume(struct sci_remote_node_context *ssci_remote_node_context_setup_to_resume ( sci_rnc, cb_fn, cb_p,RNC_DEST_READY ); -if (dev_is_sata (dev) && dev->parent) -sci_change_state (&sci_rnc->sm, -SCI_RNC_INVALIDATING ); -else -sci_change_state (&sci_rnc->sm, -SCI_RNC_RESUMING ); +if (!test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) { +if ((dev_is_sata (dev) && dev->parent) || + (sci_rnc->destination_state ==RNC_DEST_FINAL )) +sci_change_state (&sci_rnc->sm, +SCI_RNC_INVALIDATING ); +else +sci_change_state (&sci_rnc->sm, +SCI_RNC_RESUMING ); + } }return SCI_SUCCESS ;case SCI_RNC_AWAIT_SUSPENSION : -if (test_bit (IDEV_ABORT_PATH_ACTIVE , &idev->flags)) -sci_remote_node_context_save_cbparams (sci_rnc, cb_fn, - cb_p); -else -sci_remote_node_context_setup_to_resume ( - sci_rnc, cb_fn, cb_p, -RNC_DEST_SUSPENDED_RESUME ); +sci_remote_node_context_setup_to_resume ( + sci_rnc, cb_fn, cb_p,RNC_DEST_SUSPENDED_RESUME );return SCI_SUCCESS ;default : dev_warn(scirdev_to_dev(rnc_to_dev(sci_rnc)),
PATCH 37/37 isci: End the RNC resumption wait when the RNC is destroyed.
In reply to Dan WilliamsFrom: Jeff Skirvin <[email protected]>
While the RNC is suspended for I/O cleanup, the remote device can be stopped and the RNC setup for destruction. These changes accomodate that case in the abort path.
--- drivers/scsi/isci/host.h | 5 +++++ drivers/scsi/isci/remote_device.c | 29 +++++++++++++++++++++-------- drivers/scsi/isci/remote_node_context.c | 4 ++++ drivers/scsi/isci/remote_node_context.h | 6 +++--- 4 files changed, 33 insertions(+), 11 deletions(-)
drivers/scsi/isci/host.h +5 -0
@@ -333,6 +333,11 @@ static inline struct isci_host *dev_to_ihost(struct domain_device *dev)return dev->port->ha->lldd_ha; } +static inline struct isci_host *idev_to_ihost (struct isci_remote_device *idev) +{ +return dev_to_ihost (idev->domain_dev); +} +/* we always use protocol engine group zero */ #define ISCI_PEG 0
drivers/scsi/isci/remote_device.c +21 -8
@@ -1368,27 +1368,40 @@ static void isci_remote_device_resume_from_abort_complete(void *cbparam)wake_up (&ihost->eventq); } +static bool isci_remote_device_test_resume_done ( +struct isci_host *ihost, +struct isci_remote_device *idev) +{ +unsigned long flags; +bool done; + +spin_lock_irqsave (&ihost->scic_lock, flags); + done = !test_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags) + ||test_bit (IDEV_STOP_PENDING , &idev->flags) + ||sci_remote_node_context_is_being_destroyed (&idev->rnc); +spin_unlock_irqrestore (&ihost->scic_lock, flags); + +return done; +}void isci_remote_device_wait_for_resume_from_abort (struct isci_host *ihost,struct isci_remote_device *idev) { -dev_dbg (scirdev_to_dev (idev),"%s: starting resume wait: %p\n" , +dev_dbg (&ihost->pdev->dev,"%s: starting resume wait: %p\n" , __func__, idev);#define MAX_RESUME_MSECS 10000if (!wait_event_timeout (ihost->eventq, - (!test_bit (IDEV_ABORT_PATH_RESUME_PENDING , - &idev->flags) - ||test_bit (IDEV_STOP_PENDING , &idev->flags)), -msecs_to_jiffies (MAX_RESUME_MSECS ))) { +isci_remote_device_test_resume_done (ihost, idev), +msecs_to_jiffies (MAX_RESUME_MSECS ))) { -dev_warn (scirdev_to_dev (idev),"%s: #### Timeout waiting for " +dev_warn (&ihost->pdev->dev,"%s: #### Timeout waiting for " "resume: %p\n" , __func__, idev); }clear_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags); -dev_dbg (scirdev_to_dev (idev),"%s: resume wait done: %p\n" , +dev_dbg (&ihost->pdev->dev,"%s: resume wait done: %p\n" , __func__, idev); }
@@ -1414,7 +1427,7 @@ enum sci_status isci_remote_device_resume_from_abort( idev, isci_remote_device_resume_from_abort_complete, idev);spin_unlock_irqrestore (&ihost->scic_lock, flags); -if (!destroyed) +if (!destroyed && (status ==SCI_SUCCESS ))isci_remote_device_wait_for_resume_from_abort (ihost, idev);else clear_bit (IDEV_ABORT_PATH_RESUME_PENDING , &idev->flags);
drivers/scsi/isci/remote_node_context.c +4 -0
@@ -190,9 +190,13 @@ static void sci_remote_node_context_setup_to_destroy(scics_sds_remote_node_context_callback callback, void *callback_parameter) { + struct isci_host *ihost = idev_to_ihost(rnc_to_dev(sci_rnc)); + sci_rnc->destination_state =RNC_DEST_FINAL ; sci_rnc->user_callback = callback; sci_rnc->user_cookie = callback_parameter; + +wake_up (&ihost->eventq); }/**
drivers/scsi/isci/remote_node_context.h +3 -3
@@ -229,8 +229,8 @@ int sci_remote_node_context_is_safe_to_abort(static inline bool sci_remote_node_context_is_being_destroyed (struct sci_remote_node_context *sci_rnc) { -return ((sci_rnc->sm.current_state_id ==SCI_RNC_INVALIDATING ) - && (sci_rnc->destination_state ==RNC_DEST_FINAL )) - || (sci_rnc->sm.current_state_id ==SCI_RNC_INITIAL ); +return (sci_rnc->destination_state ==RNC_DEST_FINAL ) + || ((sci_rnc->sm.current_state_id ==SCI_RNC_INITIAL ) + && (sci_rnc->destination_state ==RNC_DEST_UNSPECIFIED )); }#endif /* _SCIC_SDS_REMOTE_NODE_CONTEXT_H_ */