summaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/port.c
AgeCommit message (Collapse)Author
2016-04-18treewide: Fix typos in printkMasanari Iida
This patch fix spelling typos found in printk within various part of the kernel sources. Signed-off-by: Masanari Iida <standby24x7@gmail.com> Acked-by: Randy Dunlap <rdunlap@infradead.org> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-09-01scsi: fix various printk and comment typosMasanari Iida
Correct spelling typo within drivers/scsi Signed-off-by: Masanari Iida <standby24x7@gmail.com> Signed-off-by: Jiri Kosina <jkosina@suse.cz>
2012-05-17isci: Check IDEV_GONE before performing abort path operations.Jeff Skirvin
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. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: Only set IDEV_GONE in the device stop path.Jeff Skirvin
Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: Add suspension cases for RNC INVALIDATING, POSTING states.Jeff Skirvin
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. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: Manage the link layer hang detect timer for RNC suspensions.Jeff Skirvin
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. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: enable BCN in sci_port_add_phy()Maciej Trela
Ensure we enable receiving BCN's from the hardware when adding phy to isci_port. Otherwise if we get BCN before the port is created we won't see any BCN Signed-off-by: Maciej Trela <maciej.trela@intel.com> Reported-by: Richard Boyd <richard.g.boyd@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: kill isci_port.domain_dev_listDan Williams
Another unused field, and isci_port_init is overkill. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-05-17isci: kill sci_phy_protocol and sci_request_protocolDan Williams
Holdovers from the initial driver cleanup, replace with enum sas_protocol. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2012-02-29[SCSI] isci: debug, provide state-enum-to-string conversionsDan Williams
Debugging the driver requires tracing the state transtions and tracing state names is less work than decoding numbers. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-02-29[SCSI] isci: ->lldd_ata_check_ready handlerDan Williams
Report to libata whether the link to the given domain_device is up and the signature fis has been received. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-02-29[SCSI] isci: fix interpretation of "hard" resetDan Williams
A hard reset to isci in the direct-attached case is one where the driver internally manages debouncing the link. In the sas-expander-attached case a hard reset is one that clears affiliations. The driver should not be prematurely dropping affiliations at run time, that decision (to force expander hard resets to ata devices) is left to userspace to manage. So, arrange for I_T_nexus resets to be sas-link-resets in the expander-attached case and isci-hard-resets in the direct-attached case. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-02-29[SCSI] isci: kill isci_port->statusDan Williams
It only tracks whether the port is stopping in order to gate new devices being discovered while the port is stopping. However, since the check and subsequent handling is unlocked there is nothing to stop the port from going down immediately after the check. Driver is already prepared to handle devices arriving on stale ports, and those will be cleaned up by an eventual ->lldd_dev_gone() notification. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-02-29[SCSI] isci: kill iphy->isci_port lookupsDan Williams
This field is a holdover from the OS abstraction conversion. The stable phy to port lookups are done via iphy->ownining_port under scic_lock. After this conversion to use port->lldd_port the only volatile lookup is the initial lookup in isci_port_formed(). After that point any lookup via a successfully notified domain_device is guaranteed to be valid until the domain_device is destroyed. Delete ->start_complete as it is only set once and is set as a consequence of the port going link up, by definition of getting a port formed event the port is "ready". While we are correcting port lookups also move the asd_sas_port table out from under the isci_port. This is to preclude any temptation to use container_of() to convert an asd_sas_port to an isci_port, the association is dynamic and under libsas control. Tested-by: Maciej Trela <maciej.trela@intel.com> [dmilburn@redhat.com: fix i686 compile error] Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-01-16[SCSI] isci: fix, prevent port from getting stuck in the 'configuring' stateMarcin Tomczak
When expander connected in x2 or x4 mode and with IO runnning, if a cable from wideport is plugged out from the phy, IO's start failing on all the targets. Observed that when cable is pulled with IO running, cominit is happening on all the links and IO's start dropping to 0 and eventually the whole IO fails. Second observation, target is trying to open and SCU is responding with "Open reject no destination". A cause of the problem is when the port went from the "ready configuring substate" back to "ready configuring substate" as a result of phy being pulled off, scic suspended the port task scheduler register. As a result no IO was allowed and in the "substate configuring enter" routine the IO never goes back to 0. As a result the port never comes out of "ready substate configuring". The patch adds a mechanism of activate and deactivate phy when a port link up, which fixes the problem. Signed-off-by: Bartek Nowakowski <bartek.nowakowski@intel.com> Signed-off-by: Maciej Trela <maciej.trela@intel.com> Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-01-16[SCSI] isci: enable wide port targetsBartek Nowakowski
Arrange for task_contexts prepared for the wide targets to account for all the attached phys in the port. Signed-off-by: Bartek Nowakowski <bartek.nowakowski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2012-01-16[SCSI] isci: Fix IO fails when pull cable from phy in x4 wideport in MPC mode.Marcin Tomczak
Failure seen pulling a cable from a x4 port configured in manual port configuration (MPC) mode (MPC mode is set by the the OEM paramaters provided by the platform or isci_firmware.bin). While IO running to devices behind and expander, plugging out the cable from phy is causing IO failures and IO drops on disks and never recover. It happens because during link up/down the phy were being taken out of the port. Fix: during link down the phy is kept in the same logical port. Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-10-31[SCSI] isci: revert bcn filteringDan Williams
The initial bcn filtering implementation was validated on a kernel baseline that predated the switch to new libata error handling. Also, prior to that conversion we borrowed the mvsas MVS_DEV_EH approach to prevent the unwanted extra ap->ops->phy_reset(ap) that occurred in the ata_bus_probe() path. After the conversion to new libata eh resets at discovery are more frequent and get filtered prematurely by IDEV_EH. The result is that our bcn filtering has been blocked from running and at discovery and it appears to stall discovery completion to the point of triggering hung task timeouts. So, revert the implementation for now. When it returns it will go into libsas proper. The domain rediscovery that takes place due to ->lldd_I_T_nexus_reset() events should now be properly waited for by the ata_port_wait_eh() call in ata_port_probe(). So the hard coded delay in the isci ->lldd_I_T_nexus_reset() and other libsas drivers should help debounce the libsas thread from seeing temporary device removals. Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-10-31[SCSI] isci: Fix hard reset timeout conditions.Jeff Skirvin
A hard reset can timeout before or after the last phy in the port goes away. If after, then notify the OS that the last phy has failed. The recovery for the failed hard reset has been removed. This recovery code was unecessary in that the link would recover from the failure normally by a new link reset sequence or hotplug of the remote device. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-10-02[SCSI] isci: The port state should be set to stopping on the last phy.Jeff Skirvin
Fixes a bug where any phy removed from the port set the port state to "stopping" - do this only when the last phy removed from the port. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com> Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2011-07-03isci: kill 'get/set' macrosDan Williams
Most of these simple dereference macros are longer than their open coded equivalent. Deleting enum sci_controller_mode is thrown in for good measure. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: retire scic_sds_ and scic_ prefixesDan Williams
The distinction between scic_sds_ scic_ and sci_ are no longer relevant so just unify the prefixes on sci_. The distinction between isci_ and sci_ is historically significant, and useful for comparing the old 'core' to the current Linux driver. 'sci_' represents the former core as well as the routines that are closer to the hardware and protocol than their 'isci_' brethren. sci == sas controller interface. Also unwind the 'sds1' out of the parameter structs. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_host and scic_sds_controllerDan Williams
Remove the distinction between these two implementations and unify on isci_host (local instances named ihost). Hmmm, we had two 'oem_parameters' instances, one was unused... nice. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_remote_device and scic_sds_remote_deviceDan Williams
Remove the distinction between these two implementations and unify on isci_remote_device (local instances named idev). Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_port and scic_sds_portDan Williams
Remove the distinction between these two implementations and unify on isci_port (local instances named iport). The duplicate '->owning_port' and '->isci_port' in both isci_phy and isci_remote_device will be fixed in a later patch... this is just the straightforward rename/unification. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_phy and scic_sds_phyDan Williams
They are one in the same object so remove the distinction. The near duplicate fields (owning_port, and isci_port) will be cleaned up after the scic_sds_port isci_port unification. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_request and scic_sds_requestDan Williams
They are one in the same object so remove the distinction. The near duplicate fields (owning_controller, and isci_host) will be cleaned up after the scic_sds_contoller isci_host unification. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify can_queue tracking on the tci_pool, uplevel tag assignmentDan Williams
The tci_pool tracks our outstanding command slots which are also the 'index' portion of our tags. Grabbing the tag early in ->lldd_execute_task let's us drop the isci_host_can_queue() and ->was_tag_assigned_by_user infrastructure. ->was_tag_assigned_by_user required the task context to be duplicated in request-local buffer. With the tci established early we can build the task_context directly into its final location and skip a memcpy. With the task context buffer at a known address at request construction we have the opportunity/obligation to also fix sgl handling. This rework feels like it belongs in another patch but the sgl handling and task_context are too intertwined. 1/ fix the 'ab' pair embedded in the task context to point to the 'cd' pair in the task context (previously we were prematurely linking to the staging buffer). 2/ fix the broken iteration of pio sgls that assumes all sgls are relative to the request, and does a dangerous looking reverse lookup of physical address to virtual address. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: atomic device lookup and reference countingDan Williams
We have unsafe references to remote devices that are notified to disappear at lldd_dev_gone. In order to clean this up we need a single canonical source for device lookups and stable references once a lookup succeeds. Towards that end guarantee that domain_device.lldd_dev is NULL as soon as we start the process of stopping a device. Any code path that wants to safely lookup a remote device must do so through task->dev->lldd_dev (isci_lookup_device()). For in-flight references outside of scic_lock we need reference counting to ensure that the device is not recycled before we are done with it. Simplify device back references to just scic_sds_request.target_device which is now the only permissible internal reference that is maintained relative to the reference count. There were two occasions where we wanted new i/o's to be treated as SAS_TASK_UNDELIVERED but where the domain_dev->lldd_dev link is still intact. Introduce a 'gone' flag to prevent i/o while waiting for libsas to take action on the port down event. One 'core' leftover is that we currently call scic_remote_device_destruct() from isci_remote_device_deconstruct() which is called when the 'core' says the device is stopped. It would be more natural for the final put to trigger isci_remote_device_deconstruct() but this implementation is deferred as it requires other changes. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: cleanup tag macrosDan Williams
A tag is a 16 bit number where the upper four bits is a sequence number and the remainder is the task context index (tci). Sanitize the macro names and shave 256-bytes out of scic_sds_controller by reducing the size of io_request_sequence. scic_sds_io_tag_construct --> ISCI_TAG scic_sds_io_tag_get_sequence --> ISCI_TAG_SEQ scic_sds_io_tag_get_index() --> ISCI_TAG_TCI scic_sds_io_sequence_increment() [delete / open code] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Hard reset failure will link reset all phys in the portJeff Skirvin
In the case where the hard reset process fails, each link in the port is put through a link reset sequence. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: filter broadcast change notifications during SMP phy resetsJeff Skirvin
When resetting a sata device in the domain we have seen occasions where libsas prematurely marks a device gone in the time it takes for the device to re-establish the link. This plays badly with software raid arrays. Other libsas drivers have non-uniform delays in their reset handlers to try to cover this condition, but not sufficient to close the hole. Given that a sata device can take many seconds to recover we filter bcns and poll for the device reattach state before notifying libsas that the port needs the domain to be rediscovered. Once this has been proven out at the lldd level we can think about uplevelling this feature to a common implementation in libsas. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> [ use kzalloc instead of kmem_cache ] Signed-off-by: Dave Jiang <dave.jiang@intel.com> [ use eventq and time macros ] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: additional state machine cleanupEdmund Nadolski
Additional state machine cleanups: o Remove static functions sci_state_machine_exit_state() and sci_state_machine_enter_state() o Combines sci_base_state_machine_construct() and sci_base_state_machine_start() into a single function, sci_init_sm() o Remove sci_base_state_machine_stop() which is unused. o Kill state_machine.[ch] Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> [fixed too large to inline functions] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: state machine cleanupEdmund Nadolski
This cleans up several areas of the state machine mechanism: o Rename sci_base_state_machine_change_state to sci_change_state o Remove sci_base_state_machine_get_state function o Rename 'state_machine' struct member to 'sm' in client structs o Shorten the name of request states o Shorten state machine state names as follows: SCI_BASE_CONTROLLER_STATE_xxx to SCIC_xxx SCI_BASE_PHY_STATE_xxx to SCI_PHY_xxx SCIC_SDS_PHY_STARTING_SUBSTATE_xxx to SCI_PHY_SUB_xxx SCI_BASE_PORT_STATE_xxx to SCI_PORT_xxx and SCIC_SDS_PORT_READY_SUBSTATE_xxx to SCI_PORT_SUB_xxx SCI_BASE_REMOTE_DEVICE_STATE_xxx to SCI_DEV_xxx SCIC_SDS_STP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_STP_DEV_xxx SCIC_SDS_SMP_REMOTE_DEVICE_READY_SUBSTATE_xxx to SCI_SMP_DEV_xxx SCIC_SDS_REMOTE_NODE_CONTEXT_xxx_STATE to SCI_RNC_xxx Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove isci_timer interfaceEdmund Nadolski
Delete code which is no longer used. Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: replace isci_timer list with proper embedded timersEdmund Nadolski
Rather than preallocating a list of timers and doling them out at runtime, embed a struct timerlist in each object that needs one. A struct sci_timer interface is introduced to manage the timer cancellation semantics which currently need to guarantee the timer is cancelled while holding spin_lock(ihost->scic_lock). Since the timeout functions also need to acquire the lock it currently prevents the driver from using del_timer_sync() for runtime cancellations. del_timer_sync() is used however before the objects go out of scope. Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: add some type safety to the state machine interfaceDan Williams
Now that any given object type only has one state_machine we can use container_of() to get back to the given state machine owner. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify port start_io and complete_io handlersDan Williams
Unify the handlers and kill the state handler infrastructure. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify port link_up and link_down handlersPiotr Sawicki
Unify the handlers and kill the state handler implementations. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove port frame and event handlersPiotr Sawicki
Unused infrastructure. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify port reset, add_phy, and remove_phy handlersPiotr Sawicki
Unify the implementations and remove the state handlers. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove port destruct handlerPiotr Sawicki
The handler was never used. Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify port stop handlersPiotr Sawicki
Implement the stop handlers directly in scic_sds_port_stop() Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove port start handlerPiotr Sawicki
remove the handler from the port state handler table and implement the logic directly in scic_sds_port_start(). Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> [remove a level of indirection] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: merge port ready substates into primary state machinePiotr Sawicki
This conversion was complicated by the fact that the ready state exit routine took unconditional action beyond just stopping the substate machine (like in previous conversions). In order to ensure identical behaviour every state transition needs to be instrumented to catch ready-->!ready transitions and execute scic_sds_port_invalidate_dummy_remote_node() Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> [fix ready state exit handling] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: c99 port state handlersPiotr Sawicki
Name the table fields for consistancy and clarity. Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: clarify phy to port lookupsDan Williams
While cleaning up the driver it is very tempting to convert scic_sds_get_* macros to their open coded equivalent. They are all just pointer dereferences *except* scic_sds_phy_get_port() which returns NULL if the phy is assigned to the dummy port. Clarify this by renaming it to phy_get_non_dummy_port(). Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: uplevel port infrastructureDan Williams
* Move port configuration agent implementation * Merge core/scic_sds_port.[ch] into port.[ch] Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: uplevel phy infrastructureDan Williams
Merge core/scic_sds_phy.[ch] into phy.[ch] Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: uplevel request infrastructureDan Williams
* Consolidate tiny header files * Move files out of core/ (drop core/scic_sds_ prefix) * Merge core/scic_sds_request.[ch] into request.[ch] * Cleanup request.c namespace (clean forward declarations and global namespace pollution) Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>