aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/scsi/isci/request.c
AgeCommit message (Collapse)Author
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: Terminate dev requests on FIS err bit rx in NCQJeff Skirvin
When the remote device transitions to a not-ready state because of an NCQ error condition, all outstanding requests to that device are terminated and completed to libsas on the normal path. The device then waits for a READ LOG EXT command to issue on the task management path. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix support for arbitrarily large smp requestsDan Williams
Instead of duplicating the smp request buffer reuse the one provided by libsas. This future proofs the driver to support arbitrarily large smp requests, and shrinks the request structure size by ~700 bytes. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix dma_unmap_sg usageDan Williams
One bug and a cleanup: 1/ Fix cases where we were unmapping invalid addresses (smp requests were being unmapped) [ 604.662770] ------------[ cut here ]------------ [ 604.668026] WARNING: at lib/dma-debug.c:800 check_unmap+0x418/0x740() [ 604.675315] Hardware name: SandyBridge Platform [ 604.680465] isci 0000:03:00.0: DMA-API: device driver tries to free an invalid DMA memory address 2/ The unmap routine is too large to be an inline function, and isci_request_io_request_get_next_sge is unused. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix smp response frame overrunDan Williams
Due to a typo we currently copy way too much when copying over the response data, but since a request is likely backed by a full page allocation we don't corrupt live data. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: kill device_sequenceDan Williams
Now that we have upleveled device reassignment protection to the isci_remote_device reference count we no longer need this level of self-defense. 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 request allocationDan Williams
Rather than return an error code and update a pointer that was passed by reference just return the request object directly (or null if allocation failed). 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: Handle timed-out request terminations correctlyJeff Skirvin
In the situation where a termination of an I/O times-out, make sure that the linkage from the request to the task is severed completely. Also make sure that the selection of tasks to terminate occurs under scic_lock. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Requests that do not start must be set to "complete"Jeff Skirvin
Requests that fail at start because of a reset pending condition must be set to complete in order to allow for later cleanup. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Add decode for SMP request retry error conditionJeff Skirvin
There are situations with slow expanders in which a first attempt to execute an SMP request will fail with a timeout. Immediate subsequent retries will generally succeed. This change makes sure SMP I/O failures are immediately failed to libsas so that retries happen with no discovery process timeout delay. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> 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: Removing unused variables compiler warningsDave Jiang
Newer gcc's are better at identifying "set, but not used" variables. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: removing the kmalloc in smp request constructDave Jiang
It doesn't look like there is any reason to do a kmalloc. We can do the byte swap in place and avoid the allocation. This allow us to remove a kmalloc and a memcpy. Signed-off-by: Dave Jiang <dave.jiang@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: remove the completion and event state handlersDan Williams
With these handlers gone the rest of the state handler infrastructure is removed. Added some WARN_ONCEs where previously we would cause NULL pointer dereferences or silently run handlers from a previous state. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove request task context completion state handlerDan Williams
Unlike the other conversions this only updates scic_sds_io_request_tc_completion() to call the old state handlers directly (with less verbose names). This was done for future patch readability, the implementations have only minor differences for different completion codes. Without a reference to the function name it would be difficult to dicern which state is being updated. Considered changing the order to look up the completion code before the state but that was not a clean conversion either. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify request frame handlersDan Williams
Unify the implementation in scic_sds_io_request_frame_handler and kill the state handler. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify request start handlersPiotr Sawicki
Unify the implementation in scic_sds_request_start and kill the state handler. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com> [remove scic_sds_request_constructed_state_start_handler] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify request abort handlersDan Williams
Unify the implementation in scic_sds_io_request_terminate and kill the state handler. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: merge stp request substates into primary state machineDan Williams
Remove usage of the request substate machine for stp requests, and kill the request substate infrastructure. Similar to the previous conversions this adds the substates to the primary state machine and arranges for the 'started' state to transition to the proper stp substate. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: merge smp request substates into primary state machineDan Williams
Remove usage of the request substate machine for smp requests identified by: task->task_proto == SAS_PROTOCOL_SMP While merging over the smp_request infrastructure noticed that all the assign buffer implementations are now equal, so moved it to scic_sds_general_request_construct. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: merge ssp task management substates into primary state machineDan Williams
Remove usage of the request substate machine for ssp task management requests identified by: ireq->ttype == tmf_task && dev->dev_type == SAS_END_DEV; The only routine that checks the base 'started' state is scic_sds_io_request_tc_completion which calls the substate machine handler if we are not in the 'started' state or we are 'started' and no substate machine is defined. This routine requires no conversion because we have transitioned out of 'started' and the substate routine will be called naturally as a result. There are also no side effects of this conversion on exiting the 'started', state because it only stops the substate machine, which is no longer relevant for this transaction type. Reported-by: Christoph Hellwig <hch@lst.de> 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 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>
2011-07-03isci: move core/controller to hostDan Williams
Now that the data structures are unified unify the implementation in host.[ch] and cleanup namespace pollution. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify constantsDan Williams
cross driver constants are spread out over multiple header files, consolidate them into isci.h, and push some includes out to the source files that need them. TODO: remove SCI_MODE_SIZE infrastructure. TODO: task.h is full of inlines that are too large Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify request data structuresDan Williams
Make scic_sds_request a proper member of isci_request. Also let's us get rid of the dma pool object size tracking since we now know that all requests are sizeof(isci_request). While cleaning up the construct routine incidentally replaced SCI_FIELD_OFFSET with offsetof. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: make command/response iu explicit request object membersDan Williams
Final elimination of the anonymous data at the end of the request structure. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: make sgl explicit/aligned request object memberDan Williams
Towards unifying request objects we need all members to be defined in the object and not carved out of anonymous buffer space. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Removing unnecessary functions in request.cDave Jiang
No need for wrappers, just access sas_task directly. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify isci_host data structuresArtur Wojcik
Make it explicit that isci_host and scic_sds_controller are one in the same object. Signed-off-by: Artur Wojcik <artur.wojcik@intel.com> [removed ->ihost back pointer] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Fixup of smp requestDave Jiang
The struct smp_request data structure has be fixed up for Linux consumption. This probably should go to scsi/sas.h eventually. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Fixup SSP command IU and task IUDave Jiang
Fixup of SSP command IU and SSP task IU to something that looks like Linux Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Removed sci_base_object from scic_sds_request.Maciej Patelczyk
The 'struct sci_base_object' was removed from the struct scic_sds_request and was replaced by a pointer to struct isci_request. Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: kill smp_discover_response_protocols in favor of domain_device.dev_typeDan Williams
This is step 1 of removing the contortions to: 1/ unparse expander phy data into a smp discover frame 2/ open-code-parse the smp discover fram into a domain_device.dev_type equivalent libsas has already spent cycles determining the dev_type, so now that scic_sds_remote_device is unified with isci_remote_device we can directly reference dev_type. This might also change multi-level expander detection as we previously only looked at dev_type == EDGE_DEV and we did not consider the FANOUT_DEV case. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: move remote_device handling out of the coreDan Williams
Now that the core/lldd remote_device data structures are nominally unified merge the corresponding sources into the top-level directory. Also move the remote_node_context infrastructure which has no analog at the lldd level. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: unify remote_device data structuresDan Williams
Make it explicit that isci_remote_device and scic_sds_remote_device are one in the same object. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: audit usage of BUG_ON macro in isci driverBartosz Barcinski
Removes unnecessary usage of BUG_ON macro, excluding core directory. In some cases macro is unnecesary, check is done in caller function. In other cases macro is replaced by if construction with appropriate warning. Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com> [changed some survivable bug conditions to WARN_ONCE] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix fragile/conditional isci_host lookupsDan Williams
A domain_device can always reference back to ->lldd_ha unlike local lldd structures. Fix up cases where the driver uses local objects to look up the isci_host. This also changes the calling conventions of some routines to expect a valid isci_host parameter rather than re-lookup the pointer on entry. Incidentally cleans up some macros that are longer to type than the open-coded equivalent: isci_host_from_sas_ha isci_dev_from_domain_dev Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Qualify when the host lock is managed for STP/SATA callbacks.Jeff Skirvin
In the case of internal discovery related STP/SATA I/O started through sas_execute_task the host lock is not taken by libsas before calling lldd_execute_task, so the lock should not be managed before calling back to libsas through task->task_done or sas_task_abort. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Free host lock for SATA/STP abort escalation at submission time.Jeff Skirvin
In the case of I/O requests that fail at submit time because of a pending reset condition, the host lock for SATA/STP devices must be managed for any SCSI-initiated I/O before sas_task_abort is called. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: namespacecheck cleanupsDan Williams
* mark needlessly global routines static * delete unused functions * move kernel-doc blocks from header files to source * reorder some functions to delete declarations * more default handler cleanups phy Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: don't hold scic_lock over calls to sas_task_abort()Jeff Skirvin
In the case where submitted I/Os fail with the status code SCI_FAILURE_REMOTE_DEVICE_RESET_REQUIRED, the execute function now waits until scic_lock is cleared before calling the helper function "isci_request_signal_device_reset" which sets the flag for the pending reset condition on the I/O. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Always set response/status for requests going into the error path.Jeff Skirvin
In the case of I/O requests being failed because of a required device reset condition, set the response and status to indicate an I/O failure. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: save the i/o tag outside the scic request structure.Jeff Skirvin
The pointer to the core representation of a request is marked NULL at completion, but we need to save the i/o tag for task management. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com> [revise changelog] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Any reset indicated on an I/O completion escalates it to the error path.Jeff Skirvin
If there is a pending device reset, the I/O is used to accomplish the reset by setting the RESET bit in the task status, and then putting the task into the error handler path using sas abort task. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix completion / abort path.Jeff Skirvin
Corrected use of the request state_lock in the completion callback. In the case where an abort (or reset) thread is trying to terminate an I/O request, it sets the request state to "aborting" (or "terminating") if the state is still "starting". One of the bugs was to never set the state to "completed". Another was to not correctly recognize the situation where the I/O had completed but the sas_task was still pending callback to task_done - this was typically a problem in the LUN and device reset cases. It is now possible that we leave isci_task_abort_task() with request->io_request_completion pointing to localy allocated aborted_io_completion struct. It may result in a system crash. Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com> Signed-off-by: Maciej Trela <Maciej.Trela@intel.com> Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>