History log of /drivers/scsi/isci/host.c
Revision Date Author Comments
b1124cd3ec97406c767b90bf7e93ecd2d2915592 20-Dec-2011 Dan Williams <dan.j.williams@intel.com> [SCSI] libsas: introduce sas_drain_work()

When an lldd invokes ->notify_port_event() it can trigger a chain of libsas
events to:

1/ form the port and find the direct attached device

2/ if the attached device is an expander perform domain discovery

A call to flush_workqueue() will only flush the initial port formation work.
Currently libsas users need to call scsi_flush_work() up to the max depth of
chain (which will grow from 2 to 3 when ata discovery is moved to its own
discovery event). Instead of open coding multiple calls switch to use
drain_workqueue() to flush sas work.

drain_workqueue() does not handle new work submitted during the drain so
libsas needs a bit of infrastructure to hold off unchained work submissions
while a drain is in flight. A lldd ->notify() event is considered 'unchained'
while a sas_discover_event() is 'chained'. As Tejun notes:

"For now, I think it would be best to add private wrapper in libsas to
support deferring unchained work items while draining."

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
e5cc6aa4b6ef34c3f054af8c61a4f73c157589c3 27-Jan-2012 Marcin Tomczak <marcin.tomczak@intel.com> [SCSI] isci: enable clock gating

Enabling clock gating for power savings on entry to controller ready
state. Disable SCU clock gating for power savings on exit from the
controller ready state.

The gating is fully automated by silicon after setting the mode.

Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
6d7938f46f89c9773f9396c1d13b20bbc5c6d95b 27-Jan-2012 Dave Jiang <dave.jiang@intel.com> [SCSI] isci: Fix NULL ptr dereference when no firmware is being loaded

NULL orom ptr passed in for verification which caused page fault.
We will set a default version when we don't have orom struct.

Reported-by: Dan Melnic <dan@seamicro.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
a2888ec985f36f8584609fedc916e5b1fd37aaac 05-Feb-2012 Jesper Juhl <jj@chaosbits.net> SCSI, ISCSI: Just #include "host.h" once in host.c

There's no need to include the header twice.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>
be778341812dc75b1c515fab6ebd39c0daf1e2bc 04-Jan-2012 Marcin Tomczak <marcin.tomczak@intel.com> [SCSI] isci: fix io failures while wide port links are coming up

When the first phy of a wide port comes up, don't report the port ready
yet, always wait for 250 miliseconds then config the port with all phys
added to the port. So that we can avoid reporting wide port device too
early to kernel, which caused the first IOs (report luns, inquirys)
failed due to not all the phys are configured into its port. Changes
also made that the phys in a wide port don't need to go through half
second wait time for consuming power.

Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
be168a3b89b43b8bb4ef71066e91439d400e20a6 04-Jan-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com> [SCSI] isci: link speeds default to gen 2

Gen-3 operation is marginal, default to gen-2 for now.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
6024d38b86ecc7943e398ef01b0dc2765870d444 04-Jan-2012 Marcin Tomczak <marcin.tomczak@intel.com> [SCSI] isci: performance-fix, shorten default "no outbound task" timeout

"No task timeout timer reduced from 20 to 2 This timer controls how
long the SCU hardware will hold open the TX side of the connection
before sending a DONE. The timer allows the hardware to attempt to
optimize the DONE/CLOSE behavior to allow for new COMMAND IU to be
posted. In practice closing the connection quicker is better."

Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
9fee607f0b29adabd72265a847b8e421dff10d66 04-Jan-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com> [SCSI] isci: oem parameter format v1.3 (cable select)

v1.3 allows the attenuation of the attached cables to be specified to
the driver in terms of 'short', 'medium', and 'long' (see probe_roms.h).
These settings (per phy) are retrieved from the platform oem-parameters
(BIOS rom) or via a module parameter override.

Reviewed-by: Jiangbi Liu <jiangbi.liu@intel.com>
Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
594e566ae5985e0cc3185ac21509a86e90aad577 04-Jan-2012 Dave Jiang <dave.jiang@intel.com> [SCSI] isci: oem parameter format v1.1 (ssc select)

v1.1 allows finer grained tuning of the SSC (spread-spectrum-clocking)
settings for SAS and SATA. See notes in probe_roms.h

Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
afd13a1f2b05157c7621d87dfe89ea6ea9061bd8 04-Jan-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com> [SCSI] isci: update afe (analog-front-end) recipe for C1

C1 silicon requires updates to the phy tuning recipe and also support
for user provided cable selects (per-phy) for short, medium, and long
cables. Default to 'short' awaiting support for selecting the cable via
oem parameters.

Reviewed-by: Jiangbi Liu <jiangbi.liu@intel.com>
Signed-off-by: Marcin Tomczak <marcin.tomczak@intel.com>
Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
2e5da889d44a3a9629f895de3488306e7f5ddf16 04-Jan-2012 Dan Williams <dan.j.williams@intel.com> [SCSI] isci: cleanup oem parameter and recipe handling

Before updating the code to support the latest platform updates and
silicon revision cleanup some of the long deref chains.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
7000f7c71e2457391e3249eac1ae53c91f49a8c0 28-Oct-2011 Andrzej Jakowski <andrzej.jakowski@intel.com> [SCSI] isci: overriding max_concurr_spinup oem parameter by max(oem, user)

Fixes bug where max_concurr_spinup oem parameter should be
overriden by max_concurr_spinup user parameter. Override should
happen only when max_concurr_spinup user parameter is specified
in command line (greater than 0). Also this fix shortens variables
representing max_conxurr_spinup for oem and user parameters.

Signed-off-by: Andrzej Jakowski <andrzej.jakowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
ad4f4c1de80abdda5d55315289505598aa78e355 02-Sep-2011 Dan Williams <dan.j.williams@intel.com> [SCSI] isci: initial sgpio write support

Basic support to initialize the gpio unit, accept an incomming
SAS_GPIO_REG_TX_GP bitstream, and translate it to the ODx.n fields in
the hardware registers. If register indexes outside the supported range
are specified in the SMP frame we simply accept the write and return how
many registers (SFF-8485) were written (libsas reports this as residue
in the request).

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
77cd72a53f6426f81b7f56a862402849ee903bda 30-Jul-2011 Dan Williams <dan.j.williams@intel.com> [SCSI] isci: fix event-get pointer increment

Hardware only increments the put pointer on event types >= 4. Do not
increment the get pointer for event type 3.

Reported-by: Kapil Karkra <kapil.karkra@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
9b4be528999483d70a1ffc0accd102e477d5a503 30-Jul-2011 Dan Williams <dan.j.williams@intel.com> [SCSI] isci: dynamic interrupt coalescing

Hardware allows both an outstanding number commands and a timeout value
(whichever occurs first) as a gate to the next interrupt generation. This
scheme at completion time looks at the remaining number of outstanding tasks
and sets the timeout to maximize small transaction operation. If transactions
are large (take more than a few 10s of microseconds to complete) then
performance is not interrupt processing bound, so the small timeouts this
scheme generates are overridden by the time it takes for a completion to
arrive.

Tested-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>
dc00c8b6940aa10ab1ce6a4d10b1bfe7b848781b 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: cleanup silicon revision detection

Perform checking per-pci device (even though all systems will only have
1 pci device in this generation), and delete support for silicon that
does not report a proper revision (i.e. A0).

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
4e4dca3de9658f364d34924e072f2b64e5c3d267 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: merge scu_unsolicited_frame.h into unsolicited_frame_control.h

Does not need its own file.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
34a991587a5cc9f78960c2c9beea217866458c41 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: kill 'get/set' macros

Most of these simple dereference macros are longer than their open coded
equivalent. Deleting enum sci_controller_mode is thrown in for good
measure.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
89a7301f21fb00e753089671eb9e4132aab8ea08 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: retire scic_sds_ and scic_ prefixes

The distinction between scic_sds_ scic_ and sci_ are no longer relevant
so just unify the prefixes on sci_. The distinction between isci_ and
sci_ is historically significant, and useful for comparing the old
'core' to the current Linux driver. 'sci_' represents the former core as
well as the routines that are closer to the hardware and protocol than
their 'isci_' brethren. sci == sas controller interface.

Also unwind the 'sds1' out of the parameter structs.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
d9dcb4ba791de2a06b19ac47cd61601cf3d4e208 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: unify isci_host and scic_sds_controller

Remove the distinction between these two implementations and unify on
isci_host (local instances named ihost). Hmmm, we had two
'oem_parameters' instances, one was unused... nice.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
78a6f06e0e82125787d7aa308fe28c2c8381540c 01-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: unify isci_remote_device and scic_sds_remote_device

Remove the distinction between these two implementations and unify on
isci_remote_device (local instances named idev).

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
ffe191c92ff195d73f9130b1490045ca2dd4c5e0 29-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: unify isci_port and scic_sds_port

Remove the distinction between these two implementations and unify on
isci_port (local instances named iport). The duplicate '->owning_port' and
'->isci_port' in both isci_phy and isci_remote_device will be fixed in a later
patch... this is just the straightforward rename/unification.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
852809559e4680ba4768262a6c3d21454fcd460e 29-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: unify isci_phy and scic_sds_phy

They are one in the same object so remove the distinction. The near
duplicate fields (owning_port, and isci_port) will be cleaned up
after the scic_sds_port isci_port unification.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
5076a1a97e2fa61c847a5fdd4b1991faf7716da6 27-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: unify isci_request and scic_sds_request

They are one in the same object so remove the distinction. The near
duplicate fields (owning_controller, and isci_host) will be cleaned up
after the scic_sds_contoller isci_host unification.

Reported-by: Christoph Hellwig <hch@lst.de>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
db0562509800a2d4cb5cb14a66413c30484f165c 17-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: preallocate requests

the dma_pool interface is optimized for object_size << page_size which
is not the case with isci_request objects and the dma_pool routines show
up in the top of the profile.

The old io_request_table which tracked whether tci slots were in-flight
or not is replaced with an IREQ_ACTIVE flag per request.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
312e0c2455c18716cf640d4336dcb1e9e5053818 28-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: unify can_queue tracking on the tci_pool, uplevel tag assignment

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>
f2088267514b39af1a94409168101527769a911c 16-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: kill isci_remote_device_change_state()

Now that "stopping/stopped" are one in the same and signalled by a NULL device
pointer the rest of the device status infrastructure can be removed (->status
and ->state_lock). The "not ready for i/o state" is replaced with a state
flag, and is evaluated under scic_lock so that we don't see transients from
taking the device reference to submitting the i/o.

This also fixes a potential leakage of can_queue slots in the rare case that
SAS_TASK_ABORTED is set at submission.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
209fae14fabfd48525e5630bebbbd4ca15090c60 14-Jun-2011 Dan Williams <dan.j.williams@intel.com> isci: atomic device lookup and reference counting

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>
994a9303d33f8238d57f58c26067b6d4ac9af222 10-Jun-2011 Dan Williams <dan.j.williams@intel.com> 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>
dd047c8e2bca22856050dbe0378a37cf44eecc97 09-Jun-2011 Dan Williams <dan.j.williams@intel.com> 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>
ac668c69709c7d927015c5cf3d9e87bf4eaaf57d 08-Jun-2011 Dan Williams <dan.j.williams@intel.com> 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>
7c78da3175177c905a75c54b5830029c778494ea 02-Jun-2011 Dan Williams <dan.j.williams@intel.com> 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>
dbb0743a58825d94f1b3fdfa90a8d61dfef88f7b 02-Jun-2011 Adam Gruchala <adam.gruchala@intel.com> 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>
12ef65444de9d387a383b9991960848bed5bbe74 02-Jun-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
e301370ac553a9a0ac0d1d25e769b86cf60395b3 02-Jun-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
8db02da52895285e99d7eb2fa825fd393e61d9c5 19-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
bb3dbdf6c835a145e46119ed18a920a774694583 20-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
6cb5853d3e252015eaf72d3761491e3da959556d 19-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
0473661a125905240879456567e117ed8a58cf5d 20-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
a628d478570d71fb8751ad09b8017139c5056002 19-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
ac0eeb4f774261d1da21a68169f7ddd4f6c082fc 20-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
5553ba2be0f3e3741e1a885a33d2b89921f9fd48 19-May-2011 Edmund Nadolski <edmund.nadolski@intel.com> 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>
9269e0e898594c65dee6b20d4ed48e33dbbd4eeb 12-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
8bc80d303063d9540493be623df1c9a8dee9ccb8 12-May-2011 Piotr Sawicki <piotr.sawicki@intel.com> 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>
d76f71d988ef48384593ad97ebc762d9257d96a8 12-May-2011 Piotr Sawicki <piotr.sawicki@intel.com> 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>
4f20ef4f57aa52fd3356c143a8f3d2bd18dc61fc 12-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
4a33c525f0e94b57602abd1e43644cbf6f5418f4 11-May-2011 Adam Gruchala <adam.gruchala@intel.com> 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>
e2f8db509fdd354bb7a68c86515e9d2d8909ccc9 10-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
f1f52e75939b56c40b3d153ae99faf2720250242 10-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
63a3a15fb00ef49e50e98ff675094afcd92f113a 09-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
cc9203bf381a465cd115762b9cf7c9a313c874bc 09-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
ce2b3261b6765c3b80fda95426c73e8d3bb1b035 09-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
67ea838d17acdad3331aeae848683c768df96aaa 08-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
b7645818cff1536038c0b21407eefb6b9d5755e6 08-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
e531381e2f8a68b8737c63c7bb890ad80b2470bd 07-May-2011 Dan Williams <dan.j.williams@intel.com> 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>
cc3dbd0a9178865d4444f8e28b51715808e9ac85 04-May-2011 Artur Wojcik <artur.wojcik@intel.com> 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>
d3757c3aeb75259e0b86a872e98841a2ea4cb5e8 29-Apr-2011 Maciej Patelczyk <maciej.patelczyk@intel.com> isci: Removed sci_base_object from scic_sds_controller.

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>
88f3b62ac131e2549b6c262cacbd47e8cca42d6e 23-Apr-2011 Dan Williams <dan.j.williams@intel.com> isci: move remote_device handling out of the core

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>
57f20f4ed6fb702339be2ef4dea9d15e6a7d0d07 22-Apr-2011 Dan Williams <dan.j.williams@intel.com> isci: unify remote_device data structures

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>
31e824ed0d8c84c5232405167b2338ffc071ae8a 19-Apr-2011 Dan Williams <dan.j.williams@intel.com> isci: rely on irq core for intx multiplexing, and silence screaming intx

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>
bc5c96748a5f2067193faa8131b2aa5f9775d309 02-Apr-2011 Christoph Hellwig <hch@infradead.org> isci: simplify dma coherent allocation

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>
ca841f0e862bccd61f537b76c94579c1bd391448 28-Mar-2011 Christoph Hellwig <hch@infradead.org> isci: remove base_controller abstraction

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>
4393aa4e6b9517a666f0ef6b774fd421a9dc4c68 31-Mar-2011 Dan Williams <dan.j.williams@intel.com> isci: fix fragile/conditional isci_host lookups

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>
b5f18a201ed82ed3776c9950646689b93713ae57 16-Mar-2011 Dave Jiang <dave.jiang@intel.com> isci: exposing user parameters via module params

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>
4711ba10b13891edf228944a9d0a21dfe7fe90f0 11-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
d044af17aacd03a1f4fced1af4b7570d205c8fd9 08-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
ec6c9638b0d0537430f78a3e20503b5e68a537b6 04-Mar-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com> 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>
11b00c194cfbd0eb0d90f32c096508b2bb8be6ec 04-Mar-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com> 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>
d9c37390c4f02153188a64a7a89fa6798dc3ffc2 04-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
6ad31fec306d532031b2f778f8656385df1b9d8f 04-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
b329aff107543c3c4db26c1572405034c3baf906 08-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
a8d4b9fe911c7d48f7a75c37eb1bfa3273547d97 25-Feb-2011 Tomasz Chudy <Tomasz.Chudy@intel.com> 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>
7c40a8035815479c7c12ab0cdcea71e0f4c3a9c8 02-Mar-2011 Dan Williams <dan.j.williams@intel.com> 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>
150fc6fc725055b400a8865e6785dc8dd0a2225d 25-Feb-2011 Dan Williams <dan.j.williams@intel.com> 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>
858d4aa741c80fb7579cda3517853f0cffc73772 22-Feb-2011 Dave Jiang <dave.jiang@intel.com> isci: Move firmware loading to per PCI device

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>
92f4f0f544a6a75979bace0c43fee9c4fb95830c 18-Feb-2011 Dan Williams <dan.j.williams@intel.com> isci: implement error isr

Add basic support for handling/reporting error interrupts.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
77950f51f5299c1b4f4fa4a19974128da720d199 18-Feb-2011 Edmund Nadolski <edmund.nadolski@intel.com> isci: enable interrupts during controller start, and flush discovery

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>
0cf89d1d27c1bdd0abf1714096f98ea44704dcff 18-Feb-2011 Dan Williams <dan.j.williams@intel.com> isci: cleanup "starting" state handling

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>
c7ef4031f01301298bbaba2666740183cd399f8c 18-Feb-2011 Dan Williams <dan.j.williams@intel.com> isci: bypass scic_controller_get_handler_methods()

The indirection is unecessary and broken in the current case that assigns the
handlers based on a not up-to-date pdev->msix_enabled value.

Route the handlers directly to the requisite core routines.

Todo: hook up error interrupt handling

Reported-by: Jeff Garzik <jeff@garzik.org>
Cc: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
6f231dda68080759f1aed3769896e94c73099f0f 03-Jul-2011 Dan Williams <dan.j.williams@intel.com> isci: Intel(R) C600 Series Chipset Storage Control Unit Driver

Support for the up to 2x4-port 6Gb/s SAS controllers embedded in the
chipset.

This is a snapshot of the first publicly available version of the driver,
commit 4c1db2d0 in the 'historical' branch.

git://git.kernel.org/pub/scm/linux/kernel/git/djbw/isci.git historical

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Edmund Nadolski <edmund.nadolski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>