summaryrefslogtreecommitdiff
path: root/drivers/scsi/isci/host.c
AgeCommit message (Collapse)Author
2011-07-03isci: cleanup/optimize queue increment macrosDan Williams
Every single i/o or event completion incurs a test and branch to see if the cycle bit changed. For power-of-2 queue sizes the cycle bit can be read directly from the rollover of the queue pointer. Likely premature optimization, but the hidden if() and hidden assignments / side-effects in the macros were already asking to be cleaned up. 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: cleanup/optimize pool implementationDan Williams
The circ_buf macros are ~6% faster, as measured by perf, because they take advantage of power-of-two math assumptions i.e. no test and branch for rollover. Their semantics are clearer than the hidden side effects in pool.h (like sci_pool_get() which hides an assignment). Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove 'min memory' infrastructureDan Williams
The old 'core' had aspirations of running in severely memory constrained environments like bios option-rom, it's not needed for Linux and gets in the way of other cleanups (like unifying/reducing the number of structure members in scic_sds_controller/isci_host). This also fixes a theoretical bug in that the driver would blindly override the silicon advertised limits for number of ports, task contexts, and remote node contexts. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Added support for C0 to SCU DriverAdam Gruchala
C0 silicon updates the pci revision id and requires new AFE parameters for phy signal integrity. Support for previous silicon revisions is deprecated (it's also broken for the theoretical case of multiple controllers at different silicon revisions, all the more reason to get it removed as soon as possible) Signed-off-by: Adam Gruchala <adam.gruchala@intel.com> [fixed up deprecated silicon support] 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: convert phy_startup_timer to sci_timerEdmund Nadolski
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: convert scic_timeout_timer to sci_timerEdmund Nadolski
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: convert power control timer to sci_timerEdmund Nadolski
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: convert phy sata_timeout_timer to sci_timerEdmund Nadolski
Convert the sata_timeout_timer in the scic_sds_phy struct to use a struct sci_timer Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: convert port config agent timer to sci_timerEdmund Nadolski
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> [squashed collateral cleanups] 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 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: 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: merge phy substatesAdam Gruchala
Merged states and substates into one state machine, as we always unconditionally transitioned to the substate machine it was straightforward to enter that substate from the starting state. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Adam Gruchala <adam.gruchala@intel.com> [fixed construction, starting_state_enter, and starting check] 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: uplevel register hardware data structures and unsolicited frame handlingDan Williams
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: unify port data structuresDan Williams
Make scic_sds_port a member of isci_port and merge their lifetimes which means removing the port table from scic_sds_controller in favor of the one at the isci_host level. Merge ihost->sas_ports into ihost->ports. _ Reported-by: Christoph Hellwig <hch@lst.de> 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: Removed sci_base_object from scic_sds_controller.Maciej Patelczyk
The 'struct sci_base_object' was removed from the struct scic_sds_controller and was replaced by a pointer to struct isci_host. Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com> 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: rely on irq core for intx multiplexing, and silence screaming intxDan Williams
Remove the extra logic to poll each controller for interrupts, that's the core's job for shared interrupts. While testing noticed that a number of interrupts fire while waiting for the completion tasklet to run, so added an irq-ack. Reported-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: simplify dma coherent allocationChristoph Hellwig
Remove the insane infrastructure for preallocating coheren DMA regions, and just allocate the memory where needed. This also gets rid of the aligment adjustments given that Documentation/DMA-API-HOWTO.txt sais: "The cpu return address and the DMA bus master address are both guaranteed to be aligned to the smallest PAGE_SIZE order which is greater than or equal to the requested size. This invariant exists (for example) to guarantee that if you allocate a chunk which is smaller than or equal to 64 kilobytes, the extent of the buffer you receive will not cross a 64K boundary." Signed-off-by: Christoph Hellwig <hch@lst.de> [djbw: moved allocation from start to init, re-add memset] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: remove base_controller abstractionChristoph Hellwig
Merge struct sci_base_controller into scic_sds_controller, and also factor the two types of state machine handlers into one function. While we're at it also remove lots of duplicate incorrect kerneldoc comments for the state machine handlers. Signed-off-by: Christoph Hellwig <hch@lst.de> 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: exposing user parameters via module paramsDave Jiang
Exposing the user config parameters through the kernel module parameters. The kernel module params will have the default values set and we will no longer pulling the default values for user params from the core. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix oem parameter initialization and mode detectionDan Williams
1/ Since commit 858d4aa7 "isci: Move firmware loading to per PCI device" we have been silently falling back to built-in defaults for the parameter settings by skipping the call to scic_oem_parameters_set(). 2/ The afe parameters from the firmware were not being honored 3/ The latest oem parameter definition flips the mode_type values which are now 0: for APC 1: for MPC. For APC we need to make sure all the phys default to the same address otherwise strict_wide_ports will cause duplicate domains. 4/ Fix up the driver announcement to indicate the source of the parameters. 5/ Fix up the sas addresses to be unique per controller (in the fallback case) Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Add support for probing OROM for OEM paramsDan Williams
We need to scan the OROM for signature and grab the OEM parameters. We also need to do the same for EFI. If all fails then we resort to user binary blob, and if that fails then we go to the defaults. Share the format with the create_fw utility so that all possible sources of the parameters are in-sync. Signed-off-by: Dave Jiang <dave.jiang@intel.com> 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: Changes in isci_host_completion_routineJeff Skirvin
Changes to move management of the reqs_in_process entry for the request here. Made changes to note when the task is already in the abort path and cannot be completed through callbacks. 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: preallocate remote devicesDan Williams
Until we synchronize against device removal this limits the damage of use after free bugs to the driver's own objects. Unless we implement reference counting we need to ensure at least a subset of a remote device is valid at all times. We follow the lead of other libsas drivers that also preallocate devices. This also enforces maximum remote device accounting at the lldd layer, but the core may still run out of RNC's before we hit this limit. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: replace isci_remote_device completion with event queueDan Williams
Replace the device completion infrastructure with the controller wide event queue. There was a potential for the stop and ready notifications to corrupt each other, now that cannot happen. The stop pending flag cannot be used until devices are statically allocated. We temporarily need to maintain a completion to handle waiting for an object that has disappeared, but we can at least stop scribbling on freed memory. A future change will also get rid of the "stopping" state as it should not be exposed to the rest of the driver. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: kill isci_host list in favor of an arrayDan Williams
isci_host_by_id() should have been a clue that an array would have been a simpler approach. Reported-by: James Bottomley <James.Bottomley@suse.de> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: workaround port task scheduler starvation issueTomasz Chudy
There is a condition whereby TCs (task contexts) can jump to the head of the round robin queue causing indefinite starvation of pending tasks. Posting a TC to a suspended RNC (remote node context) causes the hardware to select that task first, but since the RNC is suspended the scheduler proceeds to the next task in the expected round robin fashion, restoring TC arbitration fairness. Signed-off-by: Tomasz Chudy <tomasz.chudy@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: rework timer apiDan Williams
Prepare the timer api for the arrival of dynamic creation and destruction events from the core. It pretended to do this previously but the core to date only used it in a static init-time only fashion. This is an interim fix until a cleaner event queue can be developed. 1/ make all locking external to the api (add WARN_ONCE to verify) 2/ add a timer_destroy interface (to be used by the core) 3/ use del_timer_sync() prior to deallocating timer data 4/ delete the "timer_list" indirection, we only have timers allocated for the isci_host 5/ fix detection of timer list allocation errors Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: fix sas address reportingDan Williams
Undo the open coded and incorrect translation of the oem parameter sas address to its libsas expected format. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: Move firmware loading to per PCI deviceDave Jiang
Moved the firmware loading from per adapter to per PCI device. This should prevent firmware from being loaded twice becuase of 2 SCU controller per PCI device. We do have to do it per PCI device because request_firmware() requires a struct device passed in. Signed-off-by: Dave Jiang <dave.jiang@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: implement error isrDan Williams
Add basic support for handling/reporting error interrupts. Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: enable interrupts during controller start, and flush discoveryEdmund Nadolski
Polling the event queue during scan is an unneeded holdover from the original driver. Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> [djbw: ensure we flush all port events and domain discovery] Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03isci: cleanup "starting" state handlingDan Williams
The lldd actively disallows requests in the "starting" state. Retrying or holding off commands in this state is sub-optimal: 1/ it adds another state check to the fast path 2/ retrying can cause libsas to give up However, isci's ->lldd_dev_found() routine already waits for controller start to complete before allowing further progress. Checking the "starting" state in isci_task_execute_task and the isr is redundant and misleading. Clean this up and introduce a controller-wide event queue to start reeling in "completion" proliferation in the driver. The "stopping" state cleanups are in a similar vein, rely on the the isr and other paths being precluded from occurring rather than implementing state checking logic. Reported-by: Christoph Hellwig <hch@infradead.org> Cc: Jeff Garzik <jeff@garzik.org> Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com> Signed-off-by: Dan Williams <dan.j.williams@intel.com>