GitHub/moto-9609/android_kernel_motorola_exynos9610.git
13 years agoisci: fix ssp response iu buffer size in isci_tmf
Dan Williams [Wed, 15 Jun 2011 18:11:03 +0000 (11:11 -0700)]
isci: fix ssp response iu buffer size in isci_tmf

In isci_task_request_complete() we save the response/sense data from the
command.  Make sure isci_tmf has enough space to hold the full response.

[ it does not look like we actually use this data, and
  response_data_len/sense_data_len should be specifying the byte count,
  in any event do the simple fix first so we don't corrupt memory ]

Reported-by: Adam Gruchala <adam.gruchala@intel.com>
Tested-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: cleanup request allocation
Dan Williams [Mon, 13 Jun 2011 07:51:30 +0000 (00:51 -0700)]
isci: cleanup request allocation

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>
13 years agoisci: cleanup/optimize queue increment macros
Dan Williams [Thu, 9 Jun 2011 23:04:28 +0000 (16:04 -0700)]
isci: cleanup/optimize queue increment macros

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>
13 years agoisci: cleanup tag macros
Dan Williams [Thu, 9 Jun 2011 18:06:58 +0000 (11:06 -0700)]
isci: cleanup tag macros

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>
13 years agoisci: cleanup/optimize pool implementation
Dan Williams [Wed, 8 Jun 2011 01:50:55 +0000 (18:50 -0700)]
isci: cleanup/optimize pool implementation

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>
13 years agoisci: Disable link layer hang detection
Jeff Skirvin [Mon, 20 Jun 2011 21:09:31 +0000 (14:09 -0700)]
isci: Disable link layer hang detection

Some targets exceed the hang detect timer.  Use the OS timeout to
catch hung tasks.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Hard reset failure will link reset all phys in the port
Jeff Skirvin [Mon, 20 Jun 2011 21:09:26 +0000 (14:09 -0700)]
isci: Hard reset failure will link reset all phys in the port

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>
13 years agoisci: Explicitly decode remote node ready and suspended states
Jeff Skirvin [Mon, 20 Jun 2011 21:09:22 +0000 (14:09 -0700)]
isci: Explicitly decode remote node ready and suspended states

The remote node context should only signal a device reset condition
in a suspended state.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: fix isci_terminate_pending() list management
Dan Williams [Mon, 20 Jun 2011 22:11:22 +0000 (15:11 -0700)]
isci: fix isci_terminate_pending() list management

Walk through the list of pending requests being careful to consider that
multiple requests can be terminated when the lock is dropped (i.e.
invalidating the 'next' reference established by
list_for_each_entry_safe).

Also noticed that all callers to isci_terminate_pending_requests()
specifying terminating, so just drop the parameter.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Handle timed-out request terminations correctly
Jeff Skirvin [Mon, 20 Jun 2011 21:09:16 +0000 (14:09 -0700)]
isci: Handle timed-out request terminations correctly

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>
13 years agoisci: Requests that do not start must be set to "complete"
Jeff Skirvin [Mon, 20 Jun 2011 21:09:11 +0000 (14:09 -0700)]
isci: Requests that do not start must be set to "complete"

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>
13 years agoisci: Add decode for SMP request retry error condition
Jeff Skirvin [Mon, 20 Jun 2011 21:09:06 +0000 (14:09 -0700)]
isci: Add decode for SMP request retry error condition

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>
13 years agoisci: filter broadcast change notifications during SMP phy resets
Jeff Skirvin [Tue, 21 Jun 2011 19:16:33 +0000 (12:16 -0700)]
isci: filter broadcast change notifications during SMP phy resets

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>
13 years agoisci: Move the reset delay after the remote node resumption.
Jeff Skirvin [Mon, 20 Jun 2011 21:08:51 +0000 (14:08 -0700)]
isci: Move the reset delay after the remote node resumption.

Delay after bringing up the RNC to allow for resumption latency.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: remove 'min memory' infrastructure
Dan Williams [Wed, 1 Jun 2011 23:00:01 +0000 (16:00 -0700)]
isci: remove 'min memory' infrastructure

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>
13 years agoisci: Added support for C0 to SCU Driver
Adam Gruchala [Wed, 1 Jun 2011 22:31:03 +0000 (22:31 +0000)]
isci: Added support for C0 to SCU Driver

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>
13 years agoisci: additional state machine cleanup
Edmund Nadolski [Thu, 2 Jun 2011 00:10:50 +0000 (00:10 +0000)]
isci: additional state machine cleanup

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>
13 years agoisci: state machine cleanup
Edmund Nadolski [Thu, 2 Jun 2011 00:10:43 +0000 (00:10 +0000)]
isci: state machine cleanup

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>
13 years agoisci: Removing unused variables compiler warnings
Dave Jiang [Wed, 1 Jun 2011 09:03:08 +0000 (09:03 +0000)]
isci: Removing unused variables compiler warnings

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>
13 years agoisci: Retrieve the EFI variable for OEM parameter
Dave Jiang [Wed, 25 May 2011 05:04:35 +0000 (05:04 +0000)]
isci: Retrieve the EFI variable for OEM parameter

We can call the EFI get_variable service routine directly to retrieve
the EFI variable that holds the OEM parameters table.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: removing the kmalloc in smp request construct
Dave Jiang [Wed, 25 May 2011 02:21:57 +0000 (02:21 +0000)]
isci: removing the kmalloc in smp request construct

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>
13 years agoisci: remove isci_timer interface
Edmund Nadolski [Thu, 19 May 2011 12:00:22 +0000 (12:00 +0000)]
isci: remove isci_timer interface

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>
13 years agoisci: Remove tmf timeout_timer
Edmund Nadolski [Thu, 19 May 2011 12:00:15 +0000 (12:00 +0000)]
isci: Remove tmf timeout_timer

Replace the timeout_timer in the isci_tmf with a call to
wait_for_completion_timeout

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: convert phy_startup_timer to sci_timer
Edmund Nadolski [Fri, 20 May 2011 03:26:02 +0000 (20:26 -0700)]
isci: convert phy_startup_timer to sci_timer

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: convert scic_timeout_timer to sci_timer
Edmund Nadolski [Thu, 19 May 2011 11:59:56 +0000 (11:59 +0000)]
isci: convert scic_timeout_timer to sci_timer

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: convert power control timer to sci_timer
Edmund Nadolski [Fri, 20 May 2011 03:17:47 +0000 (20:17 -0700)]
isci: convert power control timer to sci_timer

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: convert phy sata_timeout_timer to sci_timer
Edmund Nadolski [Thu, 19 May 2011 11:59:36 +0000 (11:59 +0000)]
isci: convert phy sata_timeout_timer to sci_timer

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>
13 years agoisci: convert port config agent timer to sci_timer
Edmund Nadolski [Fri, 20 May 2011 03:00:51 +0000 (20:00 -0700)]
isci: convert port config agent timer to sci_timer

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
[squashed collateral cleanups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: replace isci_timer list with proper embedded timers
Edmund Nadolski [Thu, 19 May 2011 11:59:10 +0000 (11:59 +0000)]
isci: replace isci_timer list with proper embedded timers

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>
13 years agoisci: add some type safety to the state machine interface
Dan Williams [Thu, 12 May 2011 14:42:17 +0000 (07:42 -0700)]
isci: add some type safety to the state machine interface

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>
13 years agoisci: unify rnc start{io|task} handlers
Dan Williams [Thu, 12 May 2011 16:27:52 +0000 (09:27 -0700)]
isci: unify rnc start{io|task} handlers

Unify rnc start{io|task} handlers and delete the state handler
infrastructure.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify rnc suspend/resume handlers
Dan Williams [Thu, 12 May 2011 15:50:23 +0000 (08:50 -0700)]
isci: unify rnc suspend/resume handlers

Unify rnc suspend/resume handlers and delete the state handlers.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify rnc destruct handlers
Dan Williams [Thu, 12 May 2011 15:26:56 +0000 (08:26 -0700)]
isci: unify rnc destruct handlers

Unify rnc destruct handlers and delete the state handler.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify rnc event handlers
Dan Williams [Thu, 12 May 2011 14:46:59 +0000 (07:46 -0700)]
isci: unify rnc event handlers

Unify rnc event handlers and delete the state handler.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify port start_io and complete_io handlers
Dan Williams [Thu, 12 May 2011 14:16:06 +0000 (07:16 -0700)]
isci: unify port start_io and complete_io handlers

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>
13 years agoisci: unify port link_up and link_down handlers
Piotr Sawicki [Thu, 12 May 2011 19:10:14 +0000 (19:10 +0000)]
isci: unify port link_up and link_down handlers

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>
13 years agoisci: remove port frame and event handlers
Piotr Sawicki [Thu, 12 May 2011 19:10:08 +0000 (19:10 +0000)]
isci: remove port frame and event handlers

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>
13 years agoisci: unify port reset, add_phy, and remove_phy handlers
Piotr Sawicki [Thu, 12 May 2011 19:10:03 +0000 (19:10 +0000)]
isci: unify port reset, add_phy, and remove_phy handlers

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>
13 years agoisci: remove port destruct handler
Piotr Sawicki [Wed, 11 May 2011 23:52:37 +0000 (23:52 +0000)]
isci: remove port destruct handler

The handler was never used.

Signed-off-by: Piotr Sawicki <piotr.sawicki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify port stop handlers
Piotr Sawicki [Wed, 11 May 2011 23:52:31 +0000 (23:52 +0000)]
isci: unify port stop handlers

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>
13 years agoisci: remove port start handler
Piotr Sawicki [Wed, 11 May 2011 23:52:26 +0000 (23:52 +0000)]
isci: remove port start handler

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>
13 years agoisci: merge port ready substates into primary state machine
Piotr Sawicki [Wed, 11 May 2011 23:52:21 +0000 (23:52 +0000)]
isci: merge port ready substates into primary state machine

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>
13 years agoisci: c99 port state handlers
Piotr Sawicki [Wed, 11 May 2011 23:52:16 +0000 (23:52 +0000)]
isci: c99 port state handlers

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>
13 years agoisci: clarify phy to port lookups
Dan Williams [Thu, 12 May 2011 13:00:31 +0000 (06:00 -0700)]
isci: clarify phy to port lookups

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>
13 years agoisci: unify phy consume_power handlers
Dan Williams [Thu, 12 May 2011 11:51:41 +0000 (04:51 -0700)]
isci: unify phy consume_power handlers

Unify the implementations in scic_sds_phy_consume_power_handler(), and kill
the state handler plus infrastructure.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify phy event handlers
Dan Williams [Thu, 12 May 2011 11:27:29 +0000 (04:27 -0700)]
isci: unify phy event handlers

Unify the implementations in scic_sds_phy_event_handler(), and kill the state handler

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify phy frame handlers
Dan Williams [Thu, 12 May 2011 11:17:51 +0000 (04:17 -0700)]
isci: unify phy frame handlers

Unify the implementations in scic_sds_phy_frame_handler(), and kill the state handler

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: remove phy destruct handlers
Dan Williams [Thu, 12 May 2011 11:10:41 +0000 (04:10 -0700)]
isci: remove phy destruct handlers

Unused infrastructure.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify phy reset handlers
Dan Williams [Thu, 12 May 2011 11:02:07 +0000 (04:02 -0700)]
isci: unify phy reset handlers

Unify the implementations in scic_sds_phy_reset(), and kill the state handler

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify phy stop handlers
Dan Williams [Thu, 12 May 2011 11:01:03 +0000 (04:01 -0700)]
isci: unify phy stop handlers

Merge all implementations in scic_sds_phy_stop(), and kill the state handler

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify phy start handlers
Dan Williams [Thu, 12 May 2011 10:44:24 +0000 (03:44 -0700)]
isci: unify phy start handlers

Implement all handlers in scic_sds_phy_start(), and kill the state handler

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: merge phy substates
Adam Gruchala [Tue, 10 May 2011 23:54:23 +0000 (23:54 +0000)]
isci: merge phy substates

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>
13 years agoisci: remove the completion and event state handlers
Dan Williams [Wed, 11 May 2011 15:29:56 +0000 (08:29 -0700)]
isci: remove the completion and event state handlers

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>
13 years agoisci: remove request task context completion state handler
Dan Williams [Wed, 11 May 2011 15:27:47 +0000 (08:27 -0700)]
isci: remove request task context completion state handler

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>
13 years agoisci: unify request frame handlers
Dan Williams [Wed, 11 May 2011 15:27:47 +0000 (08:27 -0700)]
isci: unify request frame handlers

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>
13 years agoisci: unify request start handlers
Piotr Sawicki [Tue, 10 May 2011 23:50:32 +0000 (23:50 +0000)]
isci: unify request start handlers

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>
13 years agoisci: unify request abort handlers
Dan Williams [Tue, 10 May 2011 09:39:11 +0000 (02:39 -0700)]
isci: unify request abort handlers

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>
13 years agoisci: merge stp request substates into primary state machine
Dan Williams [Tue, 10 May 2011 09:28:49 +0000 (02:28 -0700)]
isci: merge stp request substates into primary state machine

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>
13 years agoisci: merge smp request substates into primary state machine
Dan Williams [Tue, 10 May 2011 09:28:48 +0000 (02:28 -0700)]
isci: merge smp request substates into primary state machine

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>
13 years agoisci: merge ssp task management substates into primary state machine
Dan Williams [Tue, 10 May 2011 09:28:47 +0000 (02:28 -0700)]
isci: merge ssp task management substates into primary state machine

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>
13 years agoisci: uplevel port infrastructure
Dan Williams [Tue, 10 May 2011 09:28:46 +0000 (02:28 -0700)]
isci: uplevel port infrastructure

* 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>
13 years agoisci: uplevel phy infrastructure
Dan Williams [Tue, 10 May 2011 09:28:45 +0000 (02:28 -0700)]
isci: uplevel phy infrastructure

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>
13 years agoisci: uplevel request infrastructure
Dan Williams [Tue, 10 May 2011 09:28:45 +0000 (02:28 -0700)]
isci: uplevel request infrastructure

* 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>
13 years agoisci: uplevel state machine
Dan Williams [Mon, 9 May 2011 05:15:10 +0000 (22:15 -0700)]
isci: uplevel state machine

unify core/sci_base_state.h and core/sci_base_state_machine.[ch] into
state_machine.[ch]

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: uplevel register hardware data structures and unsolicited frame handling
Dan Williams [Mon, 9 May 2011 04:36:46 +0000 (21:36 -0700)]
isci: uplevel register hardware data structures and unsolicited frame handling

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: move core/controller to host
Dan Williams [Mon, 9 May 2011 00:34:44 +0000 (17:34 -0700)]
isci: move core/controller to host

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>
13 years agoisci: unify constants
Dan Williams [Sun, 8 May 2011 22:49:15 +0000 (15:49 -0700)]
isci: unify constants

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>
13 years agoisci: unify request data structures
Dan Williams [Sun, 8 May 2011 18:47:15 +0000 (11:47 -0700)]
isci: unify request data structures

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>
13 years agoisci: make command/response iu explicit request object members
Dan Williams [Sun, 8 May 2011 09:35:32 +0000 (02:35 -0700)]
isci: make command/response iu explicit request object members

Final elimination of the anonymous data at the end of the request
structure.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: move task context alignment from run-time to compile time
Dan Williams [Sun, 8 May 2011 02:07:14 +0000 (19:07 -0700)]
isci: move task context alignment from run-time to compile time

Remove usage of PTR_ALIGN by arranging for the task context to be aligned by
the compiler.  Another step towards unifying isci_request and
scic_sds_request.  Once this is complete the task context in the request can
likely be removed in favor of building the task directly to tc memory (see:
scic_sds_controller_copy_task_context).  It's not clear why this needs to be
cacheline aligned if we just end up copying before submission...

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: make sgl explicit/aligned request object member
Dan Williams [Sun, 8 May 2011 08:56:57 +0000 (01:56 -0700)]
isci: make sgl explicit/aligned request object member

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>
13 years agoisci: move stp request info to scic_sds_request
Dan Williams [Sat, 7 May 2011 22:59:09 +0000 (15:59 -0700)]
isci: move stp request info to scic_sds_request

In preparation for unifying allocation of all request information make stp
data available in all requests.  Incidentally collapse indentation.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify port data structures
Dan Williams [Sat, 7 May 2011 17:11:43 +0000 (10:11 -0700)]
isci: unify port data structures

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>
13 years agoisci: unify phy data structures
Dan Williams [Sat, 7 May 2011 00:36:38 +0000 (17:36 -0700)]
isci: unify phy data structures

Make scic_sds_phy a member of isci_phy and merge their lifetimes which
means removing the phy table from scic_sds_controller in favor of the
one at that isci_host level.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: rnc state machine table c99 conversion
Jacek Danecki [Tue, 3 May 2011 04:21:07 +0000 (04:21 +0000)]
isci: rnc state machine table c99 conversion

This makes the subsequent patches to delete rnc->state_handler more
clear.

Signed-off-by: Jacek Danecki <Jacek.Danecki@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: remove scic_sds_port_increment_request_count
Edmund Nadolski [Thu, 5 May 2011 01:11:49 +0000 (01:11 +0000)]
isci: remove scic_sds_port_increment_request_count

Removes excessive encapsulation function.

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: kill scic_controller_get_port_handle function
Edmund Nadolski [Thu, 5 May 2011 01:11:43 +0000 (01:11 +0000)]
isci: kill scic_controller_get_port_handle function

This function is just overkill and its usage is inconsistent. Replace
with inlined code.

Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Removing unnecessary functions in request.c
Dave Jiang [Fri, 6 May 2011 02:17:37 +0000 (02:17 +0000)]
isci: Removing unnecessary functions in request.c

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>
13 years agoisci: unify isci_host data structures
Artur Wojcik [Wed, 4 May 2011 07:58:16 +0000 (07:58 +0000)]
isci: unify isci_host data structures

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>
13 years agoisci: implement I_T_nexus_reset
Dan Williams [Mon, 2 May 2011 20:59:25 +0000 (13:59 -0700)]
isci: implement I_T_nexus_reset

This is a requirement for 2.6.39's new libata eh.

Still some questions about lldd_dev_gone racing against dev->lldd_dev
lookups, but we are at least no more broken than mvsas in this regard.

We also short-circuit I_T_nexus_reset invocations from the device
discovery path (IDEV_EH similar to MVS_DEV_EH) to filter out the
resulting domain rediscoveries triggered by the reset.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: fix ata locking
Dan Williams [Fri, 6 May 2011 00:47:44 +0000 (17:47 -0700)]
isci: fix ata locking

Upstream commit a29b5dad "libata: fix locking for sas paths" switched
libsas ata locking to the ata_host lock.  We need to do the same when
returning ata tasks from the execute path.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: removing intel_*.h headers
Dave Jiang [Thu, 5 May 2011 02:01:01 +0000 (19:01 -0700)]
isci: removing intel_*.h headers

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Using Linux SSP frame header
Dave Jiang [Thu, 5 May 2011 01:45:05 +0000 (18:45 -0700)]
isci: Using Linux SSP frame header

Removing of struct sci_ssp_frame_header and migrate to struct ssp_frame_hdr.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Remove SCIC_SWAP_DWORD()
Dave Jiang [Thu, 5 May 2011 01:28:32 +0000 (18:28 -0700)]
isci: Remove SCIC_SWAP_DWORD()

Use Linux native swab32() call instead of SCIC_SWAP_DWORD().

We need to swab() because the hardware munges the data into a
"big-endian dword" stream which is byte-swapped from the sas definition
regardless of host endian.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: fixup SAS iaf protocols data structure
Dave Jiang [Thu, 5 May 2011 01:22:33 +0000 (18:22 -0700)]
isci: fixup SAS iaf protocols data structure

Moved the actual data structure that's read from the phy register to phy
header.  Removed the parsing of identify address frame protocol bits as
that seemed not necessary and we can use existing information.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: remove redundant copies of IAF
Dave Jiang [Thu, 5 May 2011 01:08:35 +0000 (18:08 -0700)]
isci: remove redundant copies of IAF

We need to remove the extra copies of identify address frame that's
being kept around. We only need the one copy that libsas is using.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
[further cleanups]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Converting smp_response to Linux native smp_resp
Dave Jiang [Thu, 5 May 2011 01:07:09 +0000 (18:07 -0700)]
isci: Converting smp_response to Linux native smp_resp

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Fixup of smp request
Dave Jiang [Thu, 5 May 2011 01:01:22 +0000 (18:01 -0700)]
isci: Fixup of smp request

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>
13 years agoisci: Convert of sci_ssp_response_iu to ssp_response_iu
Dave Jiang [Thu, 5 May 2011 00:53:24 +0000 (17:53 -0700)]
isci: Convert of sci_ssp_response_iu to ssp_response_iu

Converting to Linux native format. However the isci driver does a lot of
the calculation based on the max size of this data structure and the
Linux data structure only has a pointer to the response data. Thus the
sizeof(struct ssp_response_iu) will be incorrect and we need to define
the max size.

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Fixup SSP command IU and task IU
Dave Jiang [Thu, 5 May 2011 00:44:54 +0000 (17:44 -0700)]
isci: Fixup SSP command IU and task IU

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>
13 years agoisci: renaming sas_capabilities to scic_phy_cap
Dave Jiang [Wed, 4 May 2011 23:16:44 +0000 (16:16 -0700)]
isci: renaming sas_capabilities to scic_phy_cap

This seems to be a data structure that represents the phy capabilities
register from the hardware and has nothing to do with SAS data structs.
Moving and fixup

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Collapsing of phy_type data structure
Dave Jiang [Wed, 4 May 2011 23:13:17 +0000 (16:13 -0700)]
isci: Collapsing of phy_type data structure

Collapsing of struct scic_sds_phy phy_type data structure

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Convert SAS identify address frame to Linux Native format
Dave Jiang [Wed, 4 May 2011 22:37:52 +0000 (15:37 -0700)]
isci: Convert SAS identify address frame to Linux Native format

Convert struct sci_sas_identify_address_frame to struct sas_identify_frame

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Convert ATA defines to Linux native defines
Dave Jiang [Wed, 4 May 2011 22:02:03 +0000 (15:02 -0700)]
isci: Convert ATA defines to Linux native defines

* Removing all intel_sata and intel_ata defines
* Removing the usage of SAT_PROTOCOL_*. We can get everything from sas_task
* Moved SATA FIS types to local sas.h. These defines will have to go
  into include/scsi/sas.h eventually.
* Added offsets for SATA FIS header in order to grab the values

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Convert SATA fis data structures to Linux native
Dave Jiang [Wed, 4 May 2011 22:02:02 +0000 (15:02 -0700)]
isci: Convert SATA fis data structures to Linux native

Converting of sata_fis_reg_d2h to dev_to_host_fis
Converting of sata_fis_reg_h2d to host_to_dev_fis

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: remove compile-time (Kconfig) silicon configuration
Dan Williams [Wed, 4 May 2011 20:49:32 +0000 (13:49 -0700)]
isci: remove compile-time (Kconfig) silicon configuration

Pre-production silicon support is deprecated, and will be removed
completely in the future.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: Removing unused define SCIC_SDS_4_ENABLED
Dave Jiang [Fri, 22 Apr 2011 06:39:48 +0000 (06:39 +0000)]
isci: Removing unused define SCIC_SDS_4_ENABLED

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: kill scic_sds_remote_device.state_handlers
Dan Williams [Sun, 1 May 2011 23:58:46 +0000 (16:58 -0700)]
isci: kill scic_sds_remote_device.state_handlers

Remove the now unused state_handler infrastructure for remote_devices.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify remote_device frame_handlers
Dan Williams [Sun, 1 May 2011 23:51:11 +0000 (16:51 -0700)]
isci: unify remote_device frame_handlers

Implement all states in scic_sds_remote_device_frame() and delete
the state handler.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
13 years agoisci: unify remote_device event_handlers
Dan Williams [Sun, 1 May 2011 23:26:09 +0000 (16:26 -0700)]
isci: unify remote_device event_handlers

Implement all states in scic_sds_remote_device_event() and delete
the state handler.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>