18 Dec, 2014

1 commit


12 Dec, 2014

1 commit

  • Pull libata changes from Tejun Heo:
    "The only interesting piece is the support for shingled drives. The
    changes in libata layer are minimal. All it does is identifying the
    new class of device and report upwards accordingly"

    * 'for-3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata:
    libata: Remove FIXME comment in atapi_request_sense()
    sata_rcar: Document deprecated "renesas,rcar-sata"
    sata_rcar: Add clocks to sata_rcar bindings
    ahci_sunxi: Make AHCI_HFLAG_NO_PMP flag configurable with a module option
    libata-scsi: Update SATL for ZAC drives
    libata: Implement ATA_DEV_ZAC
    libsas: use ata_dev_classify()

    Linus Torvalds
     

04 Dec, 2014

1 commit

  • Since we got rid of ordered tag support in 2010 the prime use case of
    switching on and off ordered tags has been obsolete. The other function
    of enabling/disabling tagging entirely has only been correctly implemented
    by the 53c700 driver and isn't generally useful.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Bart Van Assche
    Reviewed-by: Martin K. Petersen

    Christoph Hellwig
     

27 Nov, 2014

1 commit

  • The task_collector mode (or "latency_injector", (C) Dan Willians) is an
    optional I/O path in libsas that queues up scsi commands instead of
    directly sending it to the hardware. It generall increases latencies
    to in the optiomal case slightly reduce mmio traffic to the hardware.

    Only the obsolete aic94xx driver and the mvsas driver allowed to use
    it without recompiling the kernel, and most drivers didn't support it
    at all.

    Remove the giant blob of code to allow better optimizations for scsi-mq
    in the future.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Hannes Reinecke
    Acked-by: Dan Williams

    Christoph Hellwig
     

24 Nov, 2014

1 commit

  • Drop the now unused reason argument from the ->change_queue_depth method.
    Also add a return value to scsi_adjust_queue_depth, and rename it to
    scsi_change_queue_depth now that it can be used as the default
    ->change_queue_depth implementation.

    Signed-off-by: Christoph Hellwig
    Reviewed-by: Mike Christie
    Reviewed-by: Hannes Reinecke

    Christoph Hellwig
     

06 Nov, 2014

1 commit

  • Use the ata device class from libata in libsas instead of checking
    the supported command set and switch to using ata_dev_classify()
    instead of our own method.

    Cc: Tejun Heo
    Cc: Dan Williams
    Acked-by: Christoph Hellwig
    Signed-off-by: Hannes Reinecke
    Signed-off-by: Tejun Heo

    Hannes Reinecke
     

19 Mar, 2014

1 commit

  • Tejun says:
    "At least for libata, worrying about suspend/resume failures don't make
    whole lot of sense. If suspend failed, just proceed with suspend. If
    the device can't be woken up afterwards, that's that. There isn't
    anything we could have done differently anyway. The same for resume, if
    spinup fails, the device is dud and the following commands will invoke
    EH actions and will eventually fail. Again, there really isn't any
    *choice* to make. Just making sure the errors are handled gracefully
    (ie. don't crash) and the following commands are handled correctly
    should be enough."

    The only libata user that actually cares about the result from a suspend
    operation is libsas. However, it only cares about whether queuing a new
    operation collides with an in-flight one. All libsas does with the
    error is retry, but we can just let libata wait for the previous
    operation before continuing.

    Other cleanups include:
    1/ Unifying all ata port pm operations on an ata_port_pm_ prefix
    2/ Marking all ata port pm helper routines as returning void, only
    ata_port_pm_ entry points need to fake a 0 return value.
    3/ Killing ata_port_{suspend|resume}_common() in favor of calling
    ata_port_request_pm() directly
    4/ Killing the wrappers that just do a to_ata_port() conversion
    5/ Clearly marking the entry points that do async operations with an
    _async suffix.

    Reference: http://marc.info/?l=linux-scsi&m=138995409532286&w=2

    Cc: Phillip Susi
    Cc: Alan Stern
    Suggested-by: Tejun Heo
    Signed-off-by: Todd Brandt
    Signed-off-by: Dan Williams
    Signed-off-by: Tejun Heo

    Dan Williams
     

05 Jun, 2013

1 commit

  • Remove the arbitrary expectation in libsas that all SCSI commands are 16 bytes
    or less. Instead do all copies via cmd->cmd_len (and use a pointer to this in
    the libsas task instead of a copy). Note that this still doesn't enable > 16
    byte CDB support in the underlying drivers because their internal format has
    to be fixed and the wire format of > 16 byte CDBs according to the SAS spec is
    different. the libsas drivers (isci, aic94xx, mvsas and pm8xxx are all
    updated for this change.

    Cc: Lukasz Dorau
    Cc: Maciej Patelczyk
    Cc: Dave Jiang
    Cc: Jack Wang
    Cc: Lindar Liu
    Cc: Xiangliang Yu
    Signed-off-by: James Bottomley

    James Bottomley
     

10 May, 2013

1 commit

  • These enums have been separate since the dawn of SAS, mainly because the
    latter is a procotol only enum and the former includes additional state
    for libsas. The dichotomy causes endless confusion about which one you
    should use where and leads to pointless warnings like this:

    drivers/scsi/mvsas/mv_sas.c: In function 'mvs_update_phyinfo':
    drivers/scsi/mvsas/mv_sas.c:1162:34: warning: comparison between 'enum sas_device_type' and 'enum sas_dev_type' [-Wenum-compare]

    Fix by eliminating one of them. The one kept is effectively the sas.h
    one, but call it sas_device_type and make sure the enums are all
    properly namespaced with the SAS_ prefix.

    Signed-off-by: James Bottomley

    James Bottomley
     

24 Aug, 2012

1 commit

  • libsas power management routines to suspend and recover the sas domain
    based on a model where the lldd is allowed and expected to be
    "forgetful".

    sas_suspend_ha - disable event processing allowing the lldd to take down
    links without concern for causing hotplug events.
    Regardless of whether the lldd actually posts link down
    messages libsas notifies the lldd that all
    domain_devices are gone.

    sas_prep_resume_ha - on the way back up before the lldd starts link
    training clean out any spurious events that were
    generated on the way down, and re-enable event
    processing

    sas_resume_ha - after the lldd has started and decided that all phys
    have posted link-up events this routine is called to let
    libsas start it's own timeout of any phys that did not
    resume. After the timeout an lldd can cancel the
    phy teardown by posting a link-up event.

    Storage for ex_change_count (u16) and phy_change_count (u8) are changed
    to int so they can be set to -1 to indicate 'invalidated'.

    Signed-off-by: Dan Williams
    Reviewed-by: Jacek Danecki
    Tested-by: Maciej Patelczyk
    Acked-by: Alan Stern
    Signed-off-by: James Bottomley

    Dan Williams
     

20 Jul, 2012

5 commits

  • The timer and the completion are only used for slow path tasks (smp, and
    lldd tmfs), yet we incur the allocation space and cpu setup time for
    every fast path task.

    Cc: Xiangliang Yu
    Acked-by: Jack Wang
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • On the way to add a new sata_device field, noticed that libsas is
    carrying port multiplier infrastructure that is explicitly disabled by
    sas_discover_sata(). The aic94xx touches the unused port_no, so leave
    that field in case there was some use for it.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • When recovering failed eh-cmnds let the lldd attempt an abort via
    scsi_abort_eh_cmnd before escalating.

    Reviewed-by: Jacek Danecki
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • The strategy handlers may be called in places that are problematic for
    libsas (i.e. sata resets outside of domain revalidation filtering /
    libata link recovery), or problematic for userspace (non-blocking ioctl
    to sleeping reset functions). However, these routines are also called
    for eh escalations and recovery of scsi_eh_prep_cmnd(), so permit them
    as long as we are running in the host's error handler, otherwise arrange
    for them to be triggered in eh_context.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • When managing shost->host_eh_scheduled libata assumes that there is a
    1:1 shost-to-ata_port relationship. libsas creates a 1:N relationship
    so it needs to manage host_eh_scheduled cumulatively at the host level.
    The sched_eh and end_eh port port ops allow libsas to track when domain
    devices enter/leave the "eh-pending" state under ha->lock (previously
    named ha->state_lock, but it is no longer just a lock for ha->state
    changes).

    Since host_eh_scheduled indicates eh without backing commands pinning
    the device it can be deallocated at any time. Move the taking of the
    domain_device reference under the port_lock to guarantee that the
    ata_port stays around for the duration of eh.

    Reviewed-by: Jacek Danecki
    Acked-by: Jeff Garzik
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

08 Jul, 2012

1 commit

  • fill_result_tf() grabs the taskfile flags from the originating qc which
    sas_ata_qc_fill_rtf() promptly overwrites. The presence of an
    ata_taskfile in the sata_device makes it tempting to just copy the full
    contents in sas_ata_qc_fill_rtf(). However, libata really only wants
    the fis contents and expects the other portions of the taskfile to not
    be touched by ->qc_fill_rtf. To that end store a fis buffer in the
    sata_device and use ata_tf_from_fis() like every other ->qc_fill_rtf()
    implementation.

    Cc:
    Reported-by: Praveen Murali
    Tested-by: Praveen Murali
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

23 Apr, 2012

1 commit

  • When requeuing work to a draining workqueue the last work instance may
    not be idle, so sas_queue_work() must not touch work->entry. Introduce
    sas_work with a drain_node list_head to have a private list for
    collecting work deferred due to drain collision.

    Fixes reports like:
    BUG: unable to handle kernel NULL pointer dereference at (null)
    IP: [] process_one_work+0x2e/0x338

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

01 Mar, 2012

5 commits

  • libata issues follow up srsts when the controller has a hard time
    recording the signature-fis after a reset, or if the link supports port
    multipliers. libsas does not support port multipliers and no current
    libsas lldds appear to need help retrieving the signature fis. Revert
    it for now to remove confusion.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • libsas ata error handling is already async but this does not help the
    scan case. Move initial link recovery out from under host->scan_mutex,
    and delay synchronization with eh until after all port probe/recovery
    work has been queued.

    Device ordering is maintained with scan order by still calling
    sas_rphy_add() in order of domain discovery.

    Since we now scan the domain list when invoking libata-eh we need to be
    careful to check for fully initialized ata ports.

    Acked-by: Jack Wang
    Acked-by: Jeff Garzik
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • If the top level expander is hot removed, mark all child devices as gone
    before unregistration to short circuit futile recovery.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • In the direct-attached case this routine returns the phy on which this
    device was first discovered. Which is broken if we want to support
    wide-targets, as this phy reference can become stale even though the
    port is still active.

    In the expander-attached case this routine tries to lookup the phy by
    scanning the attached sas addresses of the parent expander, and BUG_ONs
    if it can't find it. However since eh and the libsas workqueue run
    independently we can still be attempting device recovery via eh after
    libsas has recorded the device as detached. This is even easier to hit
    now that eh is blocked while device domain rediscovery takes place, and
    that libata is fed more timed out commands increasing the chances that
    it will try to recover the ata device.

    Arrange for dev->phy to always point to a last known good phy, it may be
    stale after the port is torn down, but it will catch up for wide port
    reconfigurations, and never be NULL.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Use ata_wait_after_reset() to poll for link recovery after a reset.
    This combined with sas_ha->eh_mutex prevents expander rediscovery from
    probing phys in an intermediate state. Local discovery does not have a
    mechanism to filter link status changes during this timeout, so it
    remains the responsibility of lldds to prevent premature port teardown.
    Although once all lldd's support ->lldd_ata_check_ready() that could be
    used as a gate to local port teardown.

    The signature fis is re-transmitted when the link comes back so we
    should be revalidating the ata device class, but that is left to a future
    patch.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

20 Feb, 2012

15 commits

  • SAS does not tag SMP requests, and at least one lldd (isci) does not permit
    more than one in-flight request at a time.

    [jejb: fix sas_init_dev tab issues while we're at it]
    Signed-off-by: Jeff Skirvin
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Jeff Skirvin
     
  • Execute the link-reset triggered by sas_phy_enable via
    transport_sas_phy_reset so that it can be managed by libata.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • libsas-eh if it successfully aborts an ata command will hide the timeout
    condition (AC_ERR_TIMEOUT) from libata. The command likely completes
    with the all-zero task->task_status it started with. Instead, interpret
    a TMF_RESP_FUNC_COMPLETE as the end of the sas_task but keep the scmd
    around for libata-eh to handle.

    Tested-by: Andrzej Jakowski
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Until we have told the lldd to forget a task a timed out operation can
    return from the hardware at any time. Since completion frees the task
    we need to make sure that no tasks run their normal completion handler
    once eh has decided to manage the task. Similar to
    ata_scsi_cmd_error_handler() freeze completions to let eh judge the
    outcome of the race.

    Task collector mode is problematic because it presents a situation where
    a task can be timed out and aborted before the lldd has even seen it.
    For this case we need to guarantee that a task that an lldd has been
    told to forget does not get queued after the lldd says "never seen it".
    With sas_scsi_timed_out we achieve this with the ->task_queue_flush
    mutex, rather than adding more time.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • We invoke task->task_done() to free the task in the eh case, but at this
    point we are prepared for scsi_eh_flush_done_q() to finish off the scmd.

    Introduce sas_end_task() to capture the final response status from the
    lldd and free the task.

    Also take the opportunity to kill this warning.
    drivers/scsi/libsas/sas_scsi_host.c: In function ‘sas_end_task’:
    drivers/scsi/libsas/sas_scsi_host.c:102:3: warning: case value ‘2’ not in enumerated type ‘enum exec_status’ [-Wswitch]

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Since sas_ata does not implement ->freeze(), completions for scmds and
    internal commands can still arrive concurrent with
    ata_scsi_cmd_error_handler() and sas_ata_post_internal() respectively.
    By the time either of those is called libata has committed to completing
    the qc, and the ATA_PFLAG_FROZEN flag tells sas_ata_task_done() it has
    lost the race.

    In the sas_ata_post_internal() case we take on the additional
    responsibility of freeing the sas_task to close the race with
    sas_ata_task_done() freeing the the task while sas_ata_post_internal()
    is in the process of invoking ->lldd_abort_task().

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • sas_discover_sata() notifies lldds of sata devices twice. Once to allow
    the 'identify' to be sent, and a second time to allow aic94xx (the only
    libsas driver that cares about sata_dev.identify) to setup NCQ
    parameters before the device becomes known to the midlayer. Replace
    this double notification and intervening 'identify' with an explicit
    ->lldd_ata_set_dmamode notification. With this change all ata internal
    commands are issued by libata, so we no longer need sas_issue_ata_cmd().

    The data from the identify command only needs to be cached in one
    location so ata_device.id replaces domain_device.sata_dev.identify.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • libata error handling provides for a timeout for link recovery. libsas
    must not rescan for previously known devices in this interval otherwise
    it may remove a device that is simply waiting for its link to recover.
    Let libata-eh make the determination of when the link is stable and
    prevent libsas (host workqueue) from taking action while this
    determination is pending.

    Using a mutex (ha->disco_mutex) to flush and disable revalidation while
    eh is running requires any discovery action that may block on eh be
    moved to its own context outside the lock. Probing ATA devices
    explicitly waits on ata-eh and the cache-flush-io issued during device
    removal may also pend awaiting eh completion. Essentially any rphy
    add/remove activity needs to run outside the lock.

    This adds two new cleanup states for sas_unregister_domain_devices()
    'allocated-but-not-probed', and 'flagged-for-destruction'. In the
    'allocated-but-not-probed' state dev->rphy points to a rphy that is
    known to have not been through a sas_rphy_add() event. At domain
    teardown check if this device is still pending probe and cleanup
    accordingly. Similarly if a device has already been queued for removal
    then sas_unregister_domain_devices has nothing to do.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • In preparation for adding tracking of another device state "destroy".

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • 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
    Signed-off-by: James Bottomley

    Dan Williams
     
  • In preparation for adding new states (SAS_HA_DRAINING, SAS_HA_FROZEN),
    convert ha->state into a set of flags.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • The locks only served to make sure the pending event bitmask was updated
    consistently.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Arrange for the deallocation of a struct domain_device object when it no
    longer has:
    1/ any children
    2/ references by any scsi_targets
    3/ references by a lldd

    The comment about domain_device lifetime in
    Documentation/scsi/libsas.txt is stale as it appears mainline never had
    a version of a struct domain_device that was registered as a kobject.
    We now manage domain_device reference counts on behalf of external
    agents.

    Reviewed-by: Jack Wang
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Per commit 3e4ec344 "libata: kill ATA_FLAG_DISABLED" needing to set
    ATA_DEV_NONE is a holdover from before libsas converted to the
    "new-style" ata-eh.

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • Commit 1e34c838 "[SCSI] libsas: remove spurious sata control register
    read/write" removed the routines to fake the presence of the sata
    control registers, now remove the unused data structure fields to kill
    any remaining confusion.

    Acked-by: Jack Wang
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

16 Oct, 2011

1 commit

  • port->dev_list maintains a list of devices attached to a given sas root port.
    It needs to be mutated under a lock as contexts outside of the
    single-threaded-libsas-workqueue access the list via sas_find_dev_by_rphy().
    Fixup locations where the list was being mutated without a lock.

    This is a follow-up to commit 5911e963 "[SCSI] libsas: remove expander
    from dev list on error", where Luben noted [1]:

    > 2/ We have unlocked list manipulations in sas_ex_discover_end_dev(),
    > sas_unregister_common_dev(), and sas_ex_discover_end_dev()

    Yes, I can see that and that is very unfortunate.

    [1]: http://marc.info/?l=linux-scsi&m=131480962006471&w=2

    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     

03 Oct, 2011

2 commits

  • Based on original implementation from Jiangbi Liu and Maciej Trela.

    ATAPI transfers happen in two-to-three stages. The two stage atapi
    commands are those that include a dma data transfer. The data transfer
    portion of these operations is handled by the hardware packet-dma
    acceleration. The three-stage commands do not have a data transfer and
    are handled without hardware assistance in raw frame mode.

    stage1: transmit host-to-device fis to notify the device of an incoming
    atapi cdb. Upon reception of the pio-setup-fis repost the task_context
    to perform the dma transfer of the cdb+data (go to stage3), or repost
    the task_context to transmit the cdb as a raw frame (go to stage 2).

    stage2: wait for hardware notification of the cdb transmission and then
    go to stage 3.

    stage3: wait for the arrival of the terminating device-to-host fis and
    terminate the command.

    To keep the implementation simple we only support ATAPI packet-dma
    protocol (for commands with data) to avoid needing to handle the data
    transfer manually (like we do for SATA-PIO). This may affect
    compatibility for a small number of devices (see
    ATA_HORKAGE_ATAPI_MOD16_DMA).

    If the data-transfer underruns, or encounters an error the
    device-to-host fis is expected to arrive in the unsolicited frame queue
    to pass to libata for disposition. However, in the DONE_UNEXP_FIS (data
    underrun) case it appears we need to craft a response. In the
    DONE_REG_ERR case we do receive the UF and propagate it to libsas.

    Signed-off-by: Maciej Trela
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams
     
  • If the user has disabled CONFIG_SCSI_SAS_HOST_SMP then libsas drivers
    will not be receiving smp-gpio frames and do not need this lookup code.

    Reported-by: Randy Dunlap
    Tested-by: Randy Dunlap
    Signed-off-by: Dan Williams
    Signed-off-by: James Bottomley

    Dan Williams