History log of /linux-master/drivers/scsi/isci/port.c
Revision Date Author Comments
# 7292a8b0 17-Mar-2021 Lee Jones <lee.jones@linaro.org>

scsi: isci: port: Fix a bunch of kernel-doc issues

Fixes the following W=1 kernel build warning(s):

drivers/scsi/isci/port.c:130: warning: Function parameter or member 'iport' not described in 'sci_port_get_properties'
drivers/scsi/isci/port.c:130: warning: Function parameter or member 'prop' not described in 'sci_port_get_properties'
drivers/scsi/isci/port.c:130: warning: Excess function parameter 'port' description in 'sci_port_get_properties'
drivers/scsi/isci/port.c:130: warning: Excess function parameter 'properties' description in 'sci_port_get_properties'
drivers/scsi/isci/port.c:243: warning: Function parameter or member 'isci_phy' not described in 'isci_port_link_down'
drivers/scsi/isci/port.c:243: warning: Function parameter or member 'isci_port' not described in 'isci_port_link_down'
drivers/scsi/isci/port.c:243: warning: Excess function parameter 'phy' description in 'isci_port_link_down'
drivers/scsi/isci/port.c:243: warning: Excess function parameter 'port' description in 'isci_port_link_down'
drivers/scsi/isci/port.c:318: warning: Function parameter or member 'isci_port' not described in 'isci_port_hard_reset_complete'
drivers/scsi/isci/port.c:318: warning: Excess function parameter 'port' description in 'isci_port_hard_reset_complete'
drivers/scsi/isci/port.c:398: warning: Cannot understand *
drivers/scsi/isci/port.c:544: warning: Function parameter or member 'iport' not described in 'sci_port_construct_dummy_rnc'
drivers/scsi/isci/port.c:544: warning: Excess function parameter 'sci_port' description in 'sci_port_construct_dummy_rnc'
drivers/scsi/isci/port.c:692: warning: Function parameter or member 'iport' not described in 'sci_port_general_link_up_handler'
drivers/scsi/isci/port.c:692: warning: Function parameter or member 'iphy' not described in 'sci_port_general_link_up_handler'
drivers/scsi/isci/port.c:692: warning: Excess function parameter 'sci_port' description in 'sci_port_general_link_up_handler'
drivers/scsi/isci/port.c:692: warning: Excess function parameter 'sci_phy' description in 'sci_port_general_link_up_handler'
drivers/scsi/isci/port.c:719: warning: wrong kernel-doc identifier on line:
drivers/scsi/isci/port.c:756: warning: Function parameter or member 'iport' not described in 'sci_port_link_detected'
drivers/scsi/isci/port.c:756: warning: Function parameter or member 'iphy' not described in 'sci_port_link_detected'
drivers/scsi/isci/port.c:756: warning: expecting prototype for if the(). Prototype was for sci_port_link_detected() instead
drivers/scsi/isci/port.c:821: warning: wrong kernel-doc identifier on line:
drivers/scsi/isci/port.c:885: warning: Function parameter or member 'iport' not described in 'sci_port_post_dummy_request'
drivers/scsi/isci/port.c:885: warning: Excess function parameter 'sci_port' description in 'sci_port_post_dummy_request'
drivers/scsi/isci/port.c:909: warning: Function parameter or member 'iport' not described in 'sci_port_abort_dummy_request'
drivers/scsi/isci/port.c:909: warning: expecting prototype for This will alow the hardware to(). Prototype was for sci_port_abort_dummy_request() instead
drivers/scsi/isci/port.c:926: warning: Cannot understand *
drivers/scsi/isci/port.c:1017: warning: Cannot understand *
drivers/scsi/isci/port.c:1199: warning: Function parameter or member 'iport' not described in 'sci_port_add_phy'
drivers/scsi/isci/port.c:1199: warning: Function parameter or member 'iphy' not described in 'sci_port_add_phy'
drivers/scsi/isci/port.c:1199: warning: Excess function parameter 'sci_port' description in 'sci_port_add_phy'
drivers/scsi/isci/port.c:1199: warning: Excess function parameter 'sci_phy' description in 'sci_port_add_phy'
drivers/scsi/isci/port.c:1270: warning: Function parameter or member 'iport' not described in 'sci_port_remove_phy'
drivers/scsi/isci/port.c:1270: warning: Function parameter or member 'iphy' not described in 'sci_port_remove_phy'
drivers/scsi/isci/port.c:1270: warning: Excess function parameter 'sci_port' description in 'sci_port_remove_phy'
drivers/scsi/isci/port.c:1270: warning: Excess function parameter 'sci_phy' description in 'sci_port_remove_phy'

[mkp: fixed typo alow->allow]

Link: https://lore.kernel.org/r/20210317091230.2912389-29-lee.jones@linaro.org
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 72444bbd 17-Mar-2021 Lee Jones <lee.jones@linaro.org>

scsi: isci: Make local function port_state_name() static

Fixes the following W=1 kernel build warning(s):

drivers/scsi/isci/port.c:65:13: warning: no previous prototype for ‘port_state_name’ [-Wmissing-prototypes]

Link: https://lore.kernel.org/r/20210317091125.2910058-8-lee.jones@linaro.org
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Cc: "James E.J. Bottomley" <jejb@linux.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Lee Jones <lee.jones@linaro.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# c1220866 18-Jan-2021 Ahmed S. Darwish <a.darwish@linutronix.de>

scsi: isci: Switch back to original libsas event notifiers

libsas event notifiers required an extension where gfp_t flags must be
explicitly passed. For bisectability, a temporary _gfp() variant of such
functions were added. All call sites then got converted use the _gfp()
variants and explicitly pass GFP context. Having no callers left, the
original libsas notifiers were then modified to accept gfp_t flags by
default.

Switch back to the original libas API, while still passing GFP context.
The libsas _gfp() variants will be removed afterwards.

Link: https://lore.kernel.org/r/20210118100955.1761652-18-a.darwish@linutronix.de
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 71dca553 18-Jan-2021 Ahmed S. Darwish <a.darwish@linutronix.de>

scsi: isci: Pass gfp_t flags in isci_port_bc_change_received()

Use the new libsas event notifiers API, which requires callers to
explicitly pass the gfp_t memory allocation flags.

libsas sas_notify_port_event() is called from
isci_port_bc_change_received(). Below is the context analysis for all of
its call chains:

host.c: sci_controller_error_handler(): atomic, irq handler (*)
OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
-> sci_controller_process_completions()
-> sci_controller_event_completion()
-> phy.c: sci_phy_event_handler()
-> port.c: sci_port_broadcast_change_received()
-> isci_port_bc_change_received()

host.c: isci_host_init() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_initialize(), atomic (*)
-> port_config.c: sci_port_configuration_agent_initialize()
-> sci_mpc_agent_validate_phy_configuration()
-> port.c: sci_port_add_phy()
-> sci_port_set_phy()
-> phy.c: sci_phy_set_port()
-> port.c: sci_port_broadcast_change_received()
-> isci_port_bc_change_received()

port_config.c: apc_agent_timeout(), atomic, timer callback (*)
-> sci_apc_agent_configure_ports()
-> port.c: sci_port_add_phy()
-> sci_port_set_phy()
-> phy.c: sci_phy_set_port()
-> port.c: sci_port_broadcast_change_received()
-> isci_port_bc_change_received()

phy.c: enter SCI state: *SCI_PHY_STOPPED* # Cont. from [1]
-> sci_phy_stopped_state_enter()
-> host.c: sci_controller_link_down()
-> ->link_down_handler()
== port_config.c: sci_apc_agent_link_down()
-> port.c: sci_port_remove_phy()
-> sci_port_clear_phy()
-> phy.c: sci_phy_set_port()
-> port.c: sci_port_broadcast_change_received()
-> isci_port_bc_change_received()

phy.c: enter SCI state: *SCI_PHY_STARTING* # Cont. from [2]
-> sci_phy_starting_state_enter()
-> host.c: sci_controller_link_down()
-> ->link_down_handler()
== port_config.c: sci_apc_agent_link_down()
-> port.c: sci_port_remove_phy()
-> sci_port_clear_phy()
-> phy.c: sci_phy_set_port()
-> port.c: sci_port_broadcast_change_received()
-> isci_port_bc_change_received()

[1] Call chains for entering state: *SCI_PHY_STOPPED*
-----------------------------------------------------

host.c: isci_host_init() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_initialize(), atomic (*)
-> phy.c: sci_phy_initialize()
-> phy.c: sci_phy_link_layer_initialization()
-> phy.c: sci_change_state(SCI_PHY_STOPPED)

init.c: PCI ->remove() || PM_OPS ->suspend, process context (+)
-> host.c: isci_host_deinit()
-> sci_controller_stop_phys()
-> phy.c: sci_phy_stop()
-> sci_change_state(SCI_PHY_STOPPED)

phy.c: isci_phy_control()
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_phy_stop(), atomic (*)
-> sci_change_state(SCI_PHY_STOPPED)

[2] Call chains for entering state: *SCI_PHY_STARTING*
------------------------------------------------------

phy.c: phy_sata_timeout(), atimer, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_change_state(SCI_PHY_STARTING)

host.c: phy_startup_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

host.c: isci_host_start() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_start(), atomic (*)
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

phy.c: Enter SCI state *SCI_PHY_SUB_FINAL* # Cont. from [2A]
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_phy_starting_final_substate_enter()
-> sci_change_state(SCI_PHY_READY)
-> Enter SCI state: *SCI_PHY_READY*
-> sci_phy_ready_state_enter()
-> host.c: sci_controller_link_up()
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

phy.c: sci_phy_event_handler(), atomic, discussed earlier (*)
-> sci_change_state(SCI_PHY_STARTING), 11 instances

port.c: isci_port_perform_hard_reset()
spin_lock_irqsave(isci_host::scic_lock, )
-> port.c: sci_port_hard_reset(), atomic (*)
-> phy.c: sci_phy_reset()
-> sci_change_state(SCI_PHY_RESETTING)
-> enter SCI PHY state: *SCI_PHY_RESETTING*
-> sci_phy_resetting_state_enter()
-> sci_change_state(SCI_PHY_STARTING)

[2A] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
------------------------------------------------------------

host.c: power_control_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> phy.c: sci_phy_consume_power_handler()
-> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)

host.c: sci_controller_error_handler(): atomic, irq handler (*)
OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
-> sci_controller_process_completions()
-> sci_controller_unsolicited_frame()
-> phy.c: sci_phy_frame_handler()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
-> sci_phy_starting_await_sas_power_substate_enter()
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_controller_event_completion()
-> phy.c: sci_phy_event_handler()
-> sci_phy_start_sata_link_training()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
-> sci_phy_starting_await_sata_power_substate_enter
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)

As can be seen from the "(*)" markers above, almost all the call-chains are
atomic. The only exception, marked with "(+)", is a PCI ->remove() and
PM_OPS ->suspend() cold path. Thus, pass GFP_ATOMIC to the libsas port
event notifier.

Note, the now-replaced libsas APIs used in_interrupt() to implicitly decide
which memory allocation type to use. This was only partially correct, as
it fails to choose the correct GFP flags when just preemption or interrupts
are disabled. Such buggy code paths are marked with "(@)" in the call
chains above.

Link: https://lore.kernel.org/r/20210118100955.1761652-8-a.darwish@linutronix.de
Fixes: 1c393b970e0f ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 5ce79029 18-Jan-2021 Ahmed S. Darwish <a.darwish@linutronix.de>

scsi: isci: Pass gfp_t flags in isci_port_link_up()

Use the new libsas event notifiers API, which requires callers to
explicitly pass the gfp_t memory allocation flags.

libsas sas_notify_port_event() is called from isci_port_link_up(). Below
is the context analysis for all of its call chains:

host.c: isci_host_init() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_initialize(), atomic (*)
-> port_config.c: sci_port_configuration_agent_initialize()
-> sci_mpc_agent_validate_phy_configuration()
-> port.c: sci_port_add_phy()
-> sci_port_general_link_up_handler()
-> sci_port_activate_phy()
-> isci_port_link_up()

port_config.c: apc_agent_timeout(), atomic, timer callback (*)
-> sci_apc_agent_configure_ports()
-> port.c: sci_port_add_phy()
-> sci_port_general_link_up_handler()
-> sci_port_activate_phy()
-> isci_port_link_up()

phy.c: enter SCI state: *SCI_PHY_SUB_FINAL* # Cont. from [1]
-> phy.c: sci_phy_starting_final_substate_enter()
-> phy.c: sci_change_state(SCI_PHY_READY)
-> enter SCI state: *SCI_PHY_READY*
-> phy.c: sci_phy_ready_state_enter()
-> host.c: sci_controller_link_up()
-> .link_up_handler()
== port_config.c: sci_apc_agent_link_up()
-> port.c: sci_port_link_up()
-> (continue at [A])
== port_config.c: sci_mpc_agent_link_up()
-> port.c: sci_port_link_up()
-> (continue at [A])

port_config.c: mpc_agent_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> ->link_up_handler()
== port_config.c: sci_apc_agent_link_up()
-> port.c: sci_port_link_up()
-> (continue at [A])
== port_config.c: sci_mpc_agent_link_up()
-> port.c: sci_port_link_up()
-> (continue at [A])

[A] port.c: sci_port_link_up()
-> sci_port_activate_phy()
-> isci_port_link_up()
-> sci_port_general_link_up_handler()
-> sci_port_activate_phy()
-> isci_port_link_up()

[1] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
-----------------------------------------------------------

host.c: power_control_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> phy.c: sci_phy_consume_power_handler()
-> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)

host.c: sci_controller_error_handler(): atomic, irq handler (*)
OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
-> sci_controller_process_completions()
-> sci_controller_unsolicited_frame()
-> phy.c: sci_phy_frame_handler()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
-> sci_phy_starting_await_sas_power_substate_enter()
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_controller_event_completion()
-> phy.c: sci_phy_event_handler()
-> sci_phy_start_sata_link_training()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
-> sci_phy_starting_await_sata_power_substate_enter
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)

As can be seen from the "(*)" markers above, all the call-chains are
atomic. Pass GFP_ATOMIC to libsas port event notifier.

Note, the now-replaced libsas APIs used in_interrupt() to implicitly decide
which memory allocation type to use. This was only partially correct, as
it fails to choose the correct GFP flags when just preemption or interrupts
are disabled. Such buggy code paths are marked with "(@)" in the call
chains above.

Link: https://lore.kernel.org/r/20210118100955.1761652-7-a.darwish@linutronix.de
Fixes: 1c393b970e0f ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 885ab3b8 18-Jan-2021 Ahmed S. Darwish <a.darwish@linutronix.de>

scsi: isci: Pass gfp_t flags in isci_port_link_down()

Use the new libsas event notifiers API, which requires callers to
explicitly pass the gfp_t memory allocation flags.

sas_notify_phy_event() is exclusively called by isci_port_link_down().
Below is the context analysis for all of its call chains:

port.c: port_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> port_state_machine_change(..., SCI_PORT_FAILED)
-> enter SCI port state: *SCI_PORT_FAILED*
-> sci_port_failed_state_enter()
-> isci_port_hard_reset_complete()
-> isci_port_link_down()

port.c: isci_port_perform_hard_reset()
spin_lock_irqsave(isci_host::scic_lock, )
-> port.c: sci_port_hard_reset(), atomic (*)
-> phy.c: sci_phy_reset()
-> sci_change_state(SCI_PHY_RESETTING)
-> enter SCI PHY state: *SCI_PHY_RESETTING*
-> sci_phy_resetting_state_enter()
-> port.c: sci_port_deactivate_phy()
-> isci_port_link_down()

port.c: enter SCI port state: *SCI_PORT_READY* # Cont. from [1]
-> sci_port_ready_state_enter()
-> isci_port_hard_reset_complete()
-> isci_port_link_down()

phy.c: enter SCI state: *SCI_PHY_STOPPED* # Cont. from [2]
-> sci_phy_stopped_state_enter()
-> host.c: sci_controller_link_down()
-> ->link_down_handler()
== port_config.c: sci_apc_agent_link_down()
-> port.c: sci_port_remove_phy()
-> sci_port_deactivate_phy()
-> isci_port_link_down()
== port_config.c: sci_mpc_agent_link_down()
-> port.c: sci_port_link_down()
-> sci_port_deactivate_phy()
-> isci_port_link_down()

phy.c: enter SCI state: *SCI_PHY_STARTING* # Cont. from [3]
-> sci_phy_starting_state_enter()
-> host.c: sci_controller_link_down()
-> ->link_down_handler()
== port_config.c: sci_apc_agent_link_down()
-> port.c: sci_port_remove_phy()
-> isci_port_link_down()
== port_config.c: sci_mpc_agent_link_down()
-> port.c: sci_port_link_down()
-> sci_port_deactivate_phy()
-> isci_port_link_down()

[1] Call chains for 'enter SCI port state: *SCI_PORT_READY*'
------------------------------------------------------------

host.c: isci_host_init() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_initialize(), atomic (*)
-> port_config.c: sci_port_configuration_agent_initialize()
-> sci_mpc_agent_validate_phy_configuration()
-> port.c: sci_port_add_phy()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*

host.c: isci_host_start() (@)
spin_lock_irq(isci_host::scic_lock)
-> host.c: sci_controller_start(), atomic (*)
-> host.c: sci_port_start()
-> port.c: port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*

port_config.c: apc_agent_timeout(), atomic, timer callback (*)
-> sci_apc_agent_configure_ports()
-> port.c: sci_port_add_phy()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*

port_config.c: mpc_agent_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> ->link_up_handler()
== port.c: sci_apc_agent_link_up()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*
== port.c: sci_mpc_agent_link_up()
-> port.c: sci_port_link_up()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*

phy.c: enter SCI state: SCI_PHY_SUB_FINAL # Cont. from [1A]
-> sci_phy_starting_final_substate_enter()
-> sci_change_state(SCI_PHY_READY)
-> enter SCI state: *SCI_PHY_READY*
-> sci_phy_ready_state_enter()
-> host.c: sci_controller_link_up()
-> port_agent.link_up_handler()
== port_config.c: sci_apc_agent_link_up()
-> port.c: sci_port_link_up()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*
== port_config.c: sci_mpc_agent_link_up()
-> port.c: sci_port_link_up()
-> sci_port_general_link_up_handler()
-> port_state_machine_change(, SCI_PORT_READY)
-> enter port state *SCI_PORT_READY*

[1A] Call chains for entering SCI state: *SCI_PHY_SUB_FINAL*
------------------------------------------------------------

host.c: power_control_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> phy.c: sci_phy_consume_power_handler()
-> phy.c: sci_change_state(SCI_PHY_SUB_FINAL)

host.c: sci_controller_error_handler(): atomic, irq handler (*)
OR host.c: sci_controller_completion_handler(), atomic, tasklet (*)
-> sci_controller_process_completions()
-> sci_controller_unsolicited_frame()
-> phy.c: sci_phy_frame_handler()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SAS_POWER)
-> sci_phy_starting_await_sas_power_substate_enter()
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_controller_event_completion()
-> phy.c: sci_phy_event_handler()
-> sci_phy_start_sata_link_training()
-> sci_change_state(SCI_PHY_SUB_AWAIT_SATA_POWER)
-> sci_phy_starting_await_sata_power_substate_enter
-> host.c: sci_controller_power_control_queue_insert()
-> phy.c: sci_phy_consume_power_handler()
-> sci_change_state(SCI_PHY_SUB_FINAL)

[2] Call chains for entering state: *SCI_PHY_STOPPED*
-----------------------------------------------------

host.c: isci_host_init() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_initialize(), atomic (*)
-> phy.c: sci_phy_initialize()
-> phy.c: sci_phy_link_layer_initialization()
-> phy.c: sci_change_state(SCI_PHY_STOPPED)

init.c: PCI ->remove() || PM_OPS ->suspend, process context (+)
-> host.c: isci_host_deinit()
-> sci_controller_stop_phys()
-> phy.c: sci_phy_stop()
-> sci_change_state(SCI_PHY_STOPPED)

phy.c: isci_phy_control()
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_phy_stop(), atomic (*)
-> sci_change_state(SCI_PHY_STOPPED)

[3] Call chains for entering state: *SCI_PHY_STARTING*
------------------------------------------------------

phy.c: phy_sata_timeout(), atimer, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_change_state(SCI_PHY_STARTING)

host.c: phy_startup_timeout(), atomic, timer callback (*)
spin_lock_irqsave(isci_host::scic_lock, )
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

host.c: isci_host_start() (@)
spin_lock_irq(isci_host::scic_lock)
-> sci_controller_start(), atomic (*)
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

phy.c: Enter SCI state *SCI_PHY_SUB_FINAL*, atomic, check above (*)
-> sci_change_state(SCI_PHY_SUB_FINAL)
-> sci_phy_starting_final_substate_enter()
-> sci_change_state(SCI_PHY_READY)
-> Enter SCI state: *SCI_PHY_READY*
-> sci_phy_ready_state_enter()
-> host.c: sci_controller_link_up()
-> sci_controller_start_next_phy()
-> sci_phy_start()
-> sci_change_state(SCI_PHY_STARTING)

phy.c: sci_phy_event_handler(), atomic, discussed earlier (*)
-> sci_change_state(SCI_PHY_STARTING), 11 instances

phy.c: enter SCI state: *SCI_PHY_RESETTING*, atomic, discussed (*)
-> sci_phy_resetting_state_enter()
-> sci_change_state(SCI_PHY_STARTING)

As can be seen from the "(*)" markers above, almost all the call-chains are
atomic. The only exception, marked with "(+)", is a PCI ->remove() and
PM_OPS ->suspend() cold path. Thus, pass GFP_ATOMIC to the libsas phy event
notifier.

Note, The now-replaced libsas APIs used in_interrupt() to implicitly decide
which memory allocation type to use. This was only partially correct, as
it fails to choose the correct GFP flags when just preemption or interrupts
are disabled. Such buggy code paths are marked with "(@)" in the call
chains above.

Link: https://lore.kernel.org/r/20210118100955.1761652-6-a.darwish@linutronix.de
Fixes: 1c393b970e0f ("scsi: libsas: Use dynamic alloced work to avoid sas event lost")
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Reviewed-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# 121181f3 18-Jan-2021 John Garry <john.garry@huawei.com>

scsi: libsas: Remove notifier indirection

LLDDs report events to libsas with .notify_port_event and .notify_phy_event
callbacks.

These callbacks are fixed and so there is no reason why the functions
cannot be called directly, so do that.

This neatens the code slightly, makes it more obvious, and reduces function
pointer usage, which is generally a good thing. Downside is that there are
2x more symbol exports.

[a.darwish@linutronix.de: Remove the now unused "sas_ha" local variables]

Link: https://lore.kernel.org/r/20210118100955.1761652-3-a.darwish@linutronix.de
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Jack Wang <jinpu.wang@cloud.ionos.com>
Signed-off-by: John Garry <john.garry@huawei.com>
Signed-off-by: Ahmed S. Darwish <a.darwish@linutronix.de>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>


# b0a2dc66 02-Sep-2017 Kees Cook <keescook@chromium.org>

scsi: isci: Convert timers to use timer_setup()

In preparation for unconditionally passing the struct timer_list pointer to
all timer callbacks, switch to using the new timer_setup() and from_timer()
to pass the timer pointer explicitly.

Cc: Intel SCU Linux support <intel-linux-scu@intel.com>
Cc: Artur Paszkiewicz <artur.paszkiewicz@intel.com>
Cc: "James E.J. Bottomley" <jejb@linux.vnet.ibm.com>
Cc: "Martin K. Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org
Signed-off-by: Kees Cook <keescook@chromium.org>
Reviewed-by: Artur Paszkiewicz <artur.paszkiewicz@intel.com>


# c19ca6cb 08-Feb-2016 Masanari Iida <standby24x7@gmail.com>

treewide: Fix typos in printk

This patch fix spelling typos found in printk
within various part of the kernel sources.

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Acked-by: Randy Dunlap <rdunlap@infradead.org>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 59e13d48 24-Apr-2012 Masanari Iida <standby24x7@gmail.com>

scsi: fix various printk and comment typos

Correct spelling typo within drivers/scsi

Signed-off-by: Masanari Iida <standby24x7@gmail.com>
Signed-off-by: Jiri Kosina <jkosina@suse.cz>


# 397497dd 09-Mar-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

isci: Check IDEV_GONE before performing abort path operations.

In the link fail path, set IDEV_GONE for every device on the domain
when the last link in the port fails.

In the abort path functions like isci_reset_device, make sure that
there has not already been a detected domain failure with the device
by checking IDEV_GONE, before performing any kind of hard reset, SMP
phy control, or TMF operation.

The check for IDEV_GONE makes sure that the device in the abort path
really has control of the port with which it is associated. This
prevents starting hard resets at incorrect times and scheduling
unnecessary LUN resets for SATA devices.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 033751f6 08-Mar-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

isci: Only set IDEV_GONE in the device stop path.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 59e35396 08-Mar-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

isci: Add suspension cases for RNC INVALIDATING, POSTING states.

The RNC can be any of the states in the loop from suspended to
ready when the API "suspend" or "resume" are called. This change
adds destination states parameters that control the suspension /
resumption action of the RNC statemachine for those transition states.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 6f48844e 08-Mar-2012 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

isci: Manage the link layer hang detect timer for RNC suspensions.

For STP devices under certain protocol conditions, an RNC will not
suspend until the current transfer state is broken with a SYNC/ESC
sequence from the SCU. The SYNC/ESC driven by expiration of the
SCU link layer hang detect timer, which has too small a dynamic
range to support slow SATA devices, so normally it is disabled.

This change enables the timer with the minimum period at the point
when the suspension is requested.

Note that there is potential collateral damage to other open
connections to slow SATA devices on the same port, since there
is no alternative but to enable the LLHANG timer on every phy in
the port for the current suspension request - there is no way to
tell on which phy the RNC in question is currently active.

Signed-off-by: Jeff Skirvin <jeffrey.d.skirvin@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 08e73be5 12-Mar-2012 Maciej Trela <maciej.trela@intel.com>

isci: enable BCN in sci_port_add_phy()

Ensure we enable receiving BCN's from the
hardware when adding phy to isci_port.
Otherwise if we get BCN before the port is
created we won't see any BCN

Signed-off-by: Maciej Trela <maciej.trela@intel.com>
Reported-by: Richard Boyd <richard.g.boyd@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# ae904d15 17-Feb-2012 Dan Williams <dan.j.williams@intel.com>

isci: kill isci_port.domain_dev_list

Another unused field, and isci_port_init is overkill.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# c79dd80d 01-Feb-2012 Dan Williams <dan.j.williams@intel.com>

isci: kill sci_phy_protocol and sci_request_protocol

Holdovers from the initial driver cleanup, replace with enum sas_protocol.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# d7a0ccdd 10-Feb-2012 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: debug, provide state-enum-to-string conversions

Debugging the driver requires tracing the state transtions and tracing
state names is less work than decoding numbers.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 687833a0 17-Nov-2011 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: ->lldd_ata_check_ready handler

Report to libata whether the link to the given domain_device is up and the
signature fis has been received.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 92776991 30-Nov-2011 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: fix interpretation of "hard" reset

A hard reset to isci in the direct-attached case is one where the driver
internally manages debouncing the link. In the sas-expander-attached
case a hard reset is one that clears affiliations. The driver should
not be prematurely dropping affiliations at run time, that decision (to
force expander hard resets to ata devices) is left to userspace to
manage. So, arrange for I_T_nexus resets to be sas-link-resets in the
expander-attached case and isci-hard-resets in the direct-attached case.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# fca4ecbd 04-Jan-2012 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: kill isci_port->status

It only tracks whether the port is stopping in order to gate new devices
being discovered while the port is stopping. However, since the check
and subsequent handling is unlocked there is nothing to stop the port
from going down immediately after the check.

Driver is already prepared to handle devices arriving on stale ports,
and those will be cleaned up by an eventual ->lldd_dev_gone()
notification.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# c132f692 04-Jan-2012 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: kill iphy->isci_port lookups

This field is a holdover from the OS abstraction conversion. The stable
phy to port lookups are done via iphy->ownining_port under scic_lock.
After this conversion to use port->lldd_port the only volatile lookup is
the initial lookup in isci_port_formed(). After that point any lookup
via a successfully notified domain_device is guaranteed to be valid
until the domain_device is destroyed.

Delete ->start_complete as it is only set once and is set as a
consequence of the port going link up, by definition of getting a port
formed event the port is "ready".

While we are correcting port lookups also move the asd_sas_port table
out from under the isci_port. This is to preclude any temptation to use
container_of() to convert an asd_sas_port to an isci_port, the
association is dynamic and under libsas control.

Tested-by: Maciej Trela <maciej.trela@intel.com>
[dmilburn@redhat.com: fix i686 compile error]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 05b080fc 04-Jan-2012 Marcin Tomczak <marcin.tomczak@intel.com>

[SCSI] isci: fix, prevent port from getting stuck in the 'configuring' state

When expander connected in x2 or x4 mode and with IO runnning, if
a cable from wideport is plugged out from the phy, IO's start failing
on all the targets.

Observed that when cable is pulled with IO running, cominit is
happening on all the links and IO's start dropping to 0 and eventually
the whole IO fails. Second observation, target is trying to open and
SCU is responding with "Open reject no destination".

A cause of the problem is when the port went from the "ready
configuring substate" back to "ready configuring substate" as a result
of phy being pulled off, scic suspended the port task scheduler
register. As a result no IO was allowed and in the "substate
configuring enter" routine the IO never goes back to 0. As a result
the port never comes out of "ready substate configuring".

The patch adds a mechanism of activate and deactivate phy when a port
link up, which fixes the problem.

Signed-off-by: Bartek Nowakowski <bartek.nowakowski@intel.com>
Signed-off-by: Maciej Trela <maciej.trela@intel.com>
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>


# 7e629841 04-Jan-2012 Bartek Nowakowski <bartek.nowakowski@intel.com>

[SCSI] isci: enable wide port targets

Arrange for task_contexts prepared for the wide targets to account for
all the attached phys in the port.

Signed-off-by: Bartek Nowakowski <bartek.nowakowski@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# d4ec1cf6 04-Jan-2012 Marcin Tomczak <marcin.tomczak@intel.com>

[SCSI] isci: Fix IO fails when pull cable from phy in x4 wideport in MPC mode.

Failure seen pulling a cable from a x4 port configured in manual port
configuration (MPC) mode (MPC mode is set by the the OEM paramaters
provided by the platform or isci_firmware.bin). While IO running to
devices behind and expander, plugging out the cable from phy is causing
IO failures and IO drops on disks and never recover.

It happens because during link up/down the phy were being taken out of
the port.

Fix: during link down the phy is kept in the same logical port.

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>


# 52d74634 27-Oct-2011 Dan Williams <dan.j.williams@intel.com>

[SCSI] isci: revert bcn filtering

The initial bcn filtering implementation was validated on a kernel
baseline that predated the switch to new libata error handling. Also,
prior to that conversion we borrowed the mvsas MVS_DEV_EH approach to
prevent the unwanted extra ap->ops->phy_reset(ap) that occurred in the
ata_bus_probe() path.

After the conversion to new libata eh resets at discovery are more
frequent and get filtered prematurely by IDEV_EH. The result is that
our bcn filtering has been blocked from running and at discovery and it
appears to stall discovery completion to the point of triggering hung
task timeouts. So, revert the implementation for now. When it returns
it will go into libsas proper.

The domain rediscovery that takes place due to ->lldd_I_T_nexus_reset()
events should now be properly waited for by the ata_port_wait_eh() call
in ata_port_probe(). So the hard coded delay in the isci
->lldd_I_T_nexus_reset() and other libsas drivers should help debounce
the libsas thread from seeing temporary device removals.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
Signed-off-by: James Bottomley <JBottomley@Parallels.com>


# 8e35a139 27-Oct-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

[SCSI] isci: Fix hard reset timeout conditions.

A hard reset can timeout before or after the last phy in the
port goes away. If after, then notify the OS that the last
phy has failed.

The recovery for the failed hard reset has been removed.
This recovery code was unecessary in that the link would
recover from the failure normally by a new link reset sequence
or hotplug of the remote device.

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>


# cdd05f05 28-Sep-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

[SCSI] isci: The port state should be set to stopping on the last phy.

Fixes a bug where any phy removed from the port set the port
state to "stopping" - do this only when the last phy removed
from the port.

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>


# 34a99158 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>


# 89a7301f 30-Jun-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>


# d9dcb4ba 30-Jun-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>


# 78a6f06e 30-Jun-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>


# ffe191c9 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>


# 85280955 28-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>


# 5076a1a9 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>


# 312e0c24 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>


# 209fae14 13-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>


# dd047c8e 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>


# fd0527ab 20-Jun-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

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>


# 61aaff49 21-Jun-2011 Jeff Skirvin <jeffrey.d.skirvin@intel.com>

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>


# 12ef6544 01-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>


# e301370a 01-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>


# 8db02da5 18-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>


# 5553ba2b 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>


# 9269e0e8 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>


# 6813820c 12-May-2011 Dan Williams <dan.j.williams@intel.com>

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>


# 051266ca 12-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# 13721e18 12-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# bd6713b4 12-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# e6ec5afd 11-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# 8bc80d30 11-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>


# d76f71d9 11-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>


# e91f41ef 11-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# c777c26c 11-May-2011 Piotr Sawicki <piotr.sawicki@intel.com>

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>


# 4f20ef4f 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>


# e2f8db50 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>


# d35bc1bd 10-May-2011 Dan Williams <dan.j.williams@intel.com>

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>


# f1f52e75 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>


# cc9203bf 08-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>


# e531381e 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>


# 4b33981a 06-May-2011 Dan Williams <dan.j.williams@intel.com>

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>


# ed30c275 04-May-2011 Edmund Nadolski <edmund.nadolski@intel.com>

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>


# cc3dbd0a 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>


# d7b90fc3 04-May-2011 Dave Jiang <dave.jiang@intel.com>

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>


# f700ad43 04-May-2011 Dave Jiang <dave.jiang@intel.com>

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>


# 4b7ebd05 04-May-2011 Dave Jiang <dave.jiang@intel.com>

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>


# f2f30080 04-May-2011 Dave Jiang <dave.jiang@intel.com>

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>


# 115bd1f9 28-Apr-2011 Maciej Patelczyk <maciej.patelczyk@intel.com>

isci: Removed sci_base_object from scic_sds_port.

The 'struct sci_base_object' was removed from the struct
scic_sds_port and was replaced by a pointer to
struct isci_port.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# e1e72a00 28-Apr-2011 Maciej Patelczyk <maciej.patelczyk@intel.com>

isci: Removed sci_base_object from scic_sds_phy.

The 'struct sci_base_object' was removed from the struct
scic_sds_phy and was replaced by a pointer to
struct isci_phy.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# d3757c3a 28-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>


# 88f3b62a 22-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>


# 6cb4d6b3 12-Apr-2011 Bartosz Barcinski <Bartosz.Barcinski@intel.com>

isci: audit usage of BUG_ON macro in isci driver

Removes unnecessary usage of BUG_ON macro, excluding core directory.
In some cases macro is unnecesary, check is done in caller function.
In other cases macro is replaced by if construction with
appropriate warning.

Signed-off-by: Maciej Patelczyk <maciej.patelczyk@intel.com>
[changed some survivable bug conditions to WARN_ONCE]
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 4393aa4e 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>


# 35173d57 26-Mar-2011 Dan Williams <dan.j.williams@intel.com>

isci: namespacecheck cleanups

* mark needlessly global routines static
* delete unused functions
* move kernel-doc blocks from header files to source
* reorder some functions to delete declarations
* more default handler cleanups phy

Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 09d7da13 26-Mar-2011 Dave Jiang <dave.jiang@intel.com>

isci: Remove event_* calls as they are just wrappers

Removed isci_event_* calls and call those functions directly.

Reported-by: Christoph Hellwig <hch@infradead.org>
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 1a38045b 03-Mar-2011 Dan Williams <dan.j.williams@intel.com>

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>


# 150fc6fc 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>


# 83e51430 18-Feb-2011 Dan Williams <dan.j.williams@intel.com>

isci: advertise linkrate

Inform libsas of the linkrate of direct attached links.

Reported-by: Haavard Skinnemoen <hskinnemoen@gmail.com>
Signed-off-by: Dan Williams <dan.j.williams@intel.com>


# 6f231dda 02-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>