Commit Graph

7518 Commits (4711ba10b13891edf228944a9d0a21dfe7fe90f0)

Author SHA1 Message Date
Dan Williams 4711ba10b1 isci: fix oem parameter initialization and mode detection
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-03 03:55:31 -07:00
Dave Jiang 2e8320f751 isci: Fixup for OEM parameter EFI variable retrieval
Updating the EFI variable OEM parameter retrieval after examining the EFI
variable exported via sysfs.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:31 -07:00
Dan Williams 3b67c1f376 isci: fixup with testing from isci OROM in BIOS
Added fixups for the OROM parsing code after testing with BIOS OROM

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:31 -07:00
Dave Jiang 02839a8b51 isci: copy the oem parameters instead of assign
Since the data structure for oem from orom/efi/firmware is the same as what
the core uses, we can just do a direct copy instead of assignment.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Dave Jiang ca507b98e6 isci: update efi variable name and guid
These are the finalized values that the driver can expect to see in
production.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Henryk Dembkowski 07373a5caa isci: add support for 2 more oem parmeters
1/ add OEM paramater support for mode_type (MPC vs APC)
2/ add OEM parameter support for max_number_concurrent_device_spin_up
3/ cleanup scic_sds_controller_start_next_phy

todo: hook up the amp control afe parameters into the afe init code

Signed-off-by: Henryk Dembkowski <henryk.dembkowski@intel.com>
Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
[cleaned up scic_sds_controller_start_next_phy]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Dave Jiang 8db37aabac isci: Adding EFI variable skeletal support
Adding EFI variable retrieving for OEM parameters. Still need GUID and
variable name.

Also updated the data struct for oem parameters and hex file for firmware

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
[fix CONFIG_EFI=n compile error]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Dan Williams d044af17aa isci: Add support for probing OROM for OEM params
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-03 03:55:30 -07:00
Dan Williams 9affa289e2 isci: reset hardware at init
Don't assume the hardware is in a known state at init.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Dan Williams ce0b89f356 isci: task.h compile and checkpatch fixes
A usage of "FALSE" leaked in as well as some checkpatch escapes.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin c4b9e24c4b isci: don't hold scic_lock over calls to sas_task_abort()
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-03 03:55:30 -07:00
Dan Williams 1077a57410 isci: fix incorrect assumptions about task->dev and task->dev->port being NULL
A domain_device has the same lifetime as its related scsi_target.  The
scsi_target is reference counted based on outstanding commands,
therefore it is safe to assume that if we have a valid sas_task that the
->dev pointer is also valid.

The asd_sas_port of a domain_device has the same lifetime as the driver
so it can also never be NULL as long as the sas_task is valid and the
driver is loaded.

This also cleans up isci_task_complete_for_upper_layer(), renames it to
isci_task_refuse() and notices that the isci_completion_selection
parameter was set to isci_perform_normal_io_completion by all callers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Dan Williams 34cad85d18 isci: add "isci_id" attribute
Allow each controller to be identified via sysfs.

# cat /sys/class/scsi_host/host13/isci_id
1

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin 6e2802a7fc isci: All pending requests are terminated before stopping the device.
Make sure all pending I/O including any in the libsas error handler
process is cleaned-up.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin aa14510295 isci: Always set response/status for requests going into the error path.
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-03 03:55:30 -07:00
Dan Williams 50e7f9b5a9 isci: Errors in the submit path for SATA devices manage the ap lock.
Since libsas takes the domain device sata_dev.ap->lock before submitting
a task, error completions in the submit path for SATA devices must
unlock/relock when completing the sas_task back to libsas.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin 70957a94d7 isci: Fixed BUG_ON in isci_abort_task_process_cb callback.
The request may be in the "aborted" or the "completed" state when
performing a task management operation on it.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin c3f42feb0c isci: Fix TMF build for SAS/SATA LUN reset cases.
In the case where a SAS or SATA LUN reset TMF is built a NULL pointer
dereference occurred because of the (unused) callback data pointer.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin 4dc043c410 isci: Termination handling cleanup, added termination timeouts.
Added a request "dead" state for use when a termination wait times-out.

isci_terminate_pending_requests now detaches the device's pending list
and terminates each entry on the detached list.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin cbb65c665b isci: Code review change for completion pointer cleanup.
Since the request structure contains a pointer to the completion to be
used if the request is being aborted or terminated, there is no reason
to pass the completion as a pointer to isci_terminate_request_core().

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-03 03:55:30 -07:00
Jeff Skirvin f0846c6891 isci: Cleaning up task execute path.
Made sure the device ready check accounts for all states.
Moved the aborted task check into the loop of pulling task requests
off of the submitted list.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
[remove host and device starting state checks]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:30 -07:00
Jeff Skirvin 1fad9e934a isci: save the i/o tag outside the scic request structure.
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-03 03:55:30 -07:00
Jeff Skirvin ec6c9638b0 isci: Any reset indicated on an I/O completion escalates it to the error path.
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-03 03:55:29 -07:00
Jeff Skirvin a5fde22536 isci: fix completion / abort path.
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>
2011-07-03 03:55:29 -07:00
Jeff Skirvin 11b00c194c isci: Changes in isci_host_completion_routine
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-03 03:55:29 -07:00
Jeff Skirvin 18d3d72a42 isci: isci_request_cleanup_completed_loiterer checks task before task_done
In the condition where outstanding I/Os are being cleaned from the device
requests in process list, the cleanup function needs to check that the
request is actually a sas-task and not a task management function.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams 5409bc3a20 isci: cleanup debug leftovers in isci.h
Reported-by: James Bottomley <James.Bottomley@suse.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams 1a38045ba8 isci: replace remote_device_lock with scic_lock
The remote_device_lock is currently used to protect a controller global
resource (RNCs), but the remote_device_lock is per-port.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams d9c37390c4 isci: preallocate remote devices
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-03 03:55:29 -07:00
Dan Williams 6ad31fec30 isci: replace isci_remote_device completion with event queue
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-03 03:55:29 -07:00
Dan Williams 8acaec1593 isci: kill "host quiesce" mechanism
The midlayer is already throttling i/o in the places where host_quiesce
was trying to prevent further i/o to the device.  It's also problematic
in that it holds a lock over GFP_KERNEL allocations.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams 3a97eec6d7 isci: remove sci_device_handle
It belies the fact that isci_remote_device and scic_sds_remote_device
are one in same object with the same lifetime rules.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams b329aff107 isci: kill isci_host list in favor of an array
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-03 03:55:29 -07:00
Dan Williams 52bed8eab5 isci: enable isci for dmar builds
Now that phys_to_virt() and virt_to_phys() have been removed we are no
longer violating the dma mapping (or kmap apis).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams fe9a643157 isci: pad stp and smp request sizes
Ross says:
 "The memory allocation for these requests doesn’t take into account the
  additional memory needed when the code in
  scic_sds_s[mst]p_request_assign_buffers() shifts the struct
  scu_task_context so that it is cache line aligned:

  In an example from my machine, total buffer that I’ve given to SCIC goes
  from 0x410024566f84 to 0x410024567308.  From this same example, this
  call shifts my task_context_buffer from 0x410024567208 to
  0x410024567240.

  This means that the task_context_buffer that used to range from
  0x410024567208 to 0x410024567308 instead now goes from 0x410024567240 to
  0x410024567340.

  When the memset() call at the end of scic_task_request_construct()
  clears out this task_context_buffer, it does so from 0x410024567240 to
  0x410024567340, effectively killing whatever buffer follows this
  allocation in memory."

djbw:
Use the kernel's PTR_ALIGN instead of
scic_sds_request_align_task_context_buffer() and SMP_CACHE_BYTES instead of
the local CACHE_LINE_SIZE definition.

TODO: These allocations really want to be better defined in a union rather
than opaque buffers carved up by macros.

Reported-by: Ross Zwisler <ross.zwisler@intel.com>
Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dan Williams 27ce51df9a isci: fix hang after target reset
When aborting a task context we need to be sure that the hardware has acted on
this request (retrieved the task context) before invalidating the remote node
context.  In the case of the "dummy" task context and remote node we do not
have the full state machine that goes through the complete tc abort and rnc
invalidate states.  Instead we ensure the hardware has seen and acted on

Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dave Jiang d7628d0522 isci: Cleanup warning messages for phy resets
Moving some of the chattiness of warning messages to debug so only the Linux
system messages are shown.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Dave Jiang 4d07f7f367 isci: Adding support for phy enable and disable
Adding support for PHY_FUNC_LINK_RESET and PHY_FUNC_DISABLE. This allow the
sysfs knob enable (both 0 and 1) and link_reset to work properly.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Pawel Marek c658b109d3 isci: controller stop/start fixes
Core reworks to support stopping and re-starting the controller, lays the
groundwork for phy disable / re-enable and fixes other bugs around port/phy
setup/teardown.

Signed-off-by: Pawel Marek <pawel.marek@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Piotr Sawicki 3ff0121a70 isci: handle cases where a d2h fis is used report an ncq error
Observed that some devices return a d2h fis, treat like an sdb error fis.

Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:29 -07:00
Tomasz Chudy a8d4b9fe91 isci: workaround port task scheduler starvation issue
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-03 03:55:28 -07:00
Dan Williams 7c40a80358 isci: rework timer api
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-03 03:55:28 -07:00
Dan Williams 150fc6fc72 isci: fix sas address reporting
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-03 03:55:28 -07:00
Dave Jiang 7392d27580 isci: Removing deprecated functions
Removed all callbacks in the deprecated.c. Core will call the appropriate
functions directly.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Dave Jiang a1914059f1 isci: Change event notify calls from scic_cb_* to isci_event_*
Renaming the callbacks to apparopriate event notify calls for the LLDD.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Dave Jiang 6389a77596 isci: have the driver use native SG calls and DMA-API
Remove abstraction for SG building and get rid of callbacks for getting
DMA memory mapping.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Dave Jiang 103a00c200 isci: Make the driver copy data directly from and to sg for PIO
We can copy the data directly to and from sg for SATA PIO read operations.
There is no reason to involve the hardware SGL. In the process we also need
to kmap the sg because we don't know where that can come from.

We also do to not call phys_to_virt(). The driver already has the information.
We can just calculcate the appropriate offets.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Dave Jiang f7885c8490 isci: Removed special macros that does 64bit address math
These macros are not necessary. We can do 64bit math directly.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Piotr Sawicki b3824292cb isci: fix for asserts during aborts/resets to SAS/SATA in APC mode
Sending aborts/resets to SAS/SATA targets in APC mode eventually causes
an assert in scic_sds_apc_agent_link_up().  We need to handle the hard reset
case for apc mode ports.

Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00
Tomasz Chudy 52b957c80c isci: Add Support for new TC completion codes
Update the SCI Core to comprehend the changes in the TC completion
codes from A0 to B0.  Specifically, there isnew R_ER code
differences for command and data FISes.

Changes are as follows:

1) 0x16 now additionally indicates an R_ERR received for a COMMAND
FIS being sent to a SATA target.  0x16 for SSP still indicates a
NAK received for a COMMAND frame.  Fix is to retry TC to be compliant
with SATA spec or ensure proper error handling of return value
(not spec compliant I don't believe).
2) 0x1B was previously called DONE_BREAK_RCVD for STP and
DONE_LL_ABORT_ERR for SSP.  Now it is universally called
DONE_LL_ABORT_ERR.  This is purely a superficial change.
3) 0x32 is no longer a reserved code.  Now it indicates
DONE_CMD_SDMA_ERR for STP/SSP.  There was a fatal error on the
SDMA for a command IU (includes Raw frames).  Consider retry,
but at a minimum gracefully fail the request.
4) 0x33 is no longer a reserved code.  Now it indicates
DONE_CMD_LL_ABORT_ERR for SSP.  There was a break receivd
during transmission of a command IU.  Consider retry, but
at a minimum gracefully fail the request.

Signed-off-by: Tomasz Chudy <Tomasz.Chudy@intel.com>
Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
2011-07-03 03:55:28 -07:00