09 Jan, 2012

1 commit


02 Mar, 2011

1 commit

  • The function ata_sas_port_init() has always really done its own thing.
    However, as a precursor to moving to the libata new eh, it has to be
    properly using the standard libata scan paths. This means separating
    the current libata scan paths into pieces which can be shared with
    libsas and pieces which cant (really just the async call and the host
    scan).

    Signed-off-by: James Bottomley
    Signed-off-by: Jeff Garzik

    James Bottomley
     

22 Oct, 2010

6 commits

  • In libata, the non-EH code paths should always take and release
    ap->lock explicitly when accessing hardware or shared data structures.
    However, once EH is active, it's assumed that the port is owned by EH
    and EH methods don't explicitly take ap->lock unless race from irq
    handler or other code paths are expected. However, libata EH didn't
    guarantee exclusion among EHs for ports of the same host. IOW,
    multiple EHs may execute in parallel on multiple ports of the same
    controller.

    In many cases, especially in SATA, the ports are completely
    independent of each other and this doesn't cause problems; however,
    there are cases where different ports share the same resource, which
    lead to obscure timing related bugs such as the one fixed by commit
    213373cf (ata_piix: fix locking around SIDPR access).

    This patch implements exclusion among EHs of the same host. When EH
    begins, it acquires per-host EH ownership by calling ata_eh_acquire().
    When EH finishes, the ownership is released by calling
    ata_eh_release(). EH ownership is also released whenever the EH
    thread goes to sleep from ata_msleep() or explicitly and reacquired
    after waking up.

    This ensures that while EH is actively accessing the hardware, it has
    exclusive access to it while allowing EHs to interleave and progress
    in parallel as they hit waiting stages, which dominate the time spent
    in EH. This achieves cross-port EH exclusion without pervasive and
    fragile changes while still allowing parallel EH for the most part.

    This was first reported by yuanding02@gmail.com more than three years
    ago in the following bugzilla. :-)

    https://bugzilla.kernel.org/show_bug.cgi?id=8223

    Signed-off-by: Tejun Heo
    Cc: Alan Cox
    Reported-by: yuanding02@gmail.com
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Port multipliers can do DIPM on fan-out links fine. Implement support
    for it. Tested w/ SIMG 57xx and marvell PMPs. Both the host and
    fan-out links enter power save modes nicely.

    SIMG 37xx and 47xx report link offline on SStatus causing EH to detach
    the devices. Blacklisted.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • The current LPM implementation has the following issues.

    * Operation order isn't well thought-out. e.g. HIPM should be
    configured after IPM in SControl is properly configured. Not the
    other way around.

    * Suspend/resume paths call ata_lpm_enable/disable() which must only
    be called from EH context directly. Also, ata_lpm_enable/disable()
    were called whether LPM was in use or not.

    * Implementation is per-port when it should be per-link. As a result,
    it can't be used for controllers with slave links or PMP.

    * LPM state isn't managed consistently. After a link reset for
    whatever reason including suspend/resume the actual LPM state would
    be reset leaving ap->lpm_policy inconsistent.

    * Generic/driver-specific logic boundary isn't clear. Currently,
    libahci has to mangle stuff which libata EH proper should be
    handling. This makes the implementation unnecessarily complex and
    fragile.

    * Tied to ALPM. Doesn't consider DIPM only cases and doesn't check
    whether the device allows HIPM.

    * Error handling isn't implemented.

    Given the extent of mismatch with the rest of libata, I don't think
    trying to fix it piecewise makes much sense. This patch reimplements
    LPM support.

    * The new implementation is per-link. The target policy is still
    port-wide (ap->target_lpm_policy) but all the mechanisms and states
    are per-link and integrate well with the rest of link abstraction
    and can work with slave and PMP links.

    * Core EH has proper control of LPM state. LPM state is reconfigured
    when and only when reconfiguration is necessary. It makes sure that
    LPM state is reset when probing for new device on the link.
    Controller agnostic logic is now implemented in libata EH proper and
    driver implementation only has to deal with controller specifics.

    * Proper error handling. LPM config failure is attributed to the
    device on the link and LPM is disabled for the link if it fails
    repeatedly.

    * ops->enable/disable_pm() are replaced with single ops->set_lpm()
    which takes @policy and @hints. This simplifies driver specific
    implementation.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Link power management is about to be reimplemented. Prepare for it.

    * Implement sata_link_scr_lpm().

    * Drop static from ata_dev_set_feature() and make it available to
    other libata files.

    * Trivial whitespace adjustments.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Link power management related symbols are in confusing state w/ mixed
    usages of lpm, ipm and pm. This patch cleans up lpm related symbols
    and sysfs show/store functions as follows.

    * lpm states - NOT_AVAILABLE, MIN_POWER, MAX_PERFORMANCE and
    MEDIUM_POWER are renamed to ATA_LPM_UNKNOWN and
    ATA_LPM_{MIN|MAX|MED}_POWER.

    * Pre/postfixes are unified to lpm.

    * sysfs show/store functions for link_power_management_policy were
    curiously named get/put and unnecessarily complex. Renamed to
    show/store and simplified.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • This is a scheleton for libata transport class.
    All information is read only, exporting information from libata:
    - ata_port class: one per ATA port
    - ata_link class: one per ATA port or 15 for SATA Port Multiplier
    - ata_device class: up to 2 for PATA link, usually one for SATA.

    Signed-off-by: Gwendal Grignou
    Reviewed-by: Grant Grundler
    Signed-off-by: Jeff Garzik

    Gwendal Grignou
     

02 Jul, 2010

1 commit

  • libata has two concurrency related limitations.

    a. ata_wq which is used for polling PIO has single thread per CPU. If
    there are multiple devices doing polling PIO on the same CPU, they
    can't be executed simultaneously.

    b. ata_aux_wq which is used for SCSI probing has single thread. In
    cases where SCSI probing is stalled for extended period of time
    which is possible for ATAPI devices, this will stall all probing.

    #a is solved by increasing maximum concurrency of ata_wq. Please note
    that polling PIO might be used under allocation path and thus needs to
    be served by a separate wq with a rescuer.

    #b is solved by using the default wq instead and achieving exclusion
    via per-port mutex.

    Signed-off-by: Tejun Heo
    Acked-by: Jeff Garzik

    Tejun Heo
     

20 May, 2010

3 commits

  • Some of error handling logic in ata_sff_error_handler() and all of
    ata_sff_post_internal_cmd() are for BMDMA. Create
    ata_bmdma_error_handler() and ata_bmdma_post_internal_cmd() and move
    BMDMA part into those.

    While at it, change DMA protocol check to ata_is_dma(), fix
    post_internal_cmd to call ap->ops->bmdma_stop instead of directly
    calling ata_bmdma_stop() and open code hardreset selection so that
    ata_std_error_handler() doesn't have to know about sff hardreset.

    As these two functions are BMDMA specific, there's no reason to check
    for bmdma_addr before calling bmdma methods if the protocol of the
    failed command is DMA. sata_mv and pata_mpc52xx now don't need to set
    .post_internal_cmd to ATA_OP_NULL and pata_icside and sata_qstor don't
    need to set it to their bmdma_stop routines.

    ata_sff_post_internal_cmd() becomes noop and is removed.

    This fixes p3 described in clean-up-BMDMA-initialization patch.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • port_task is tightly bound to the standard SFF PIO HSM implementation.
    Using it for any other purpose would be error-prone and there's no
    such user and if some drivers need such feature, it would be much
    better off using its own. Move it inside CONFIG_ATA_SFF and rename it
    to sff_pio_task.

    The only function which is exposed to the core layer is
    ata_sff_flush_pio_task() which is renamed from ata_port_flush_task()
    and now also takes care of resetting hsm_task_state to HSM_ST_IDLE,
    which is possible as it's now specific to PIO HSM.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • In preparation of proper SFF/BMDMA separation, introduce
    ata_sff_init/exit() and ata_sff_port_init(). These functions
    currently don't do anything.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

15 May, 2010

1 commit


06 Oct, 2009

1 commit

  • Add ->gtf_filter to ata_device and set it to ata_acpi_gtf_filter when
    initializing ata_link. This is to allow quirks which apply different
    gtf filters.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

02 Sep, 2009

1 commit

  • This patch improve libata's output for error/notification messages
    to allow easier comprehension and debugging:

    When ATAPI commands issued through the SCSI layer fail, use SCSI
    functions to print the CDB in human-readable form instead of just
    dumping out the CDB in hex.

    Print out the name of the failed command (as defined by the ATA
    specification) in error handling output along with the raw register
    contents.

    When reporting status of ACPI taskfile commands executed on resume,
    also output the names of the commands being executed (or not) in
    readable form.

    Since the extra data for printing command names increases kernel
    size slightly, a config option has been added to allow disabling
    command name output (as well as some of the error register parsing)
    for those highly sensitive to kernel text size.

    Signed-off-by: Robert Hancock
    Signed-off-by: Jeff Garzik

    Robert Hancock
     

25 Mar, 2009

1 commit


03 Feb, 2009

2 commits


11 Nov, 2008

1 commit

  • This patch reverts the following three commits which convert libata to
    use block layer tagging.

    43a49cbdf31e812c0d8f553d433b09b421f5d52c
    e013e13bf605b9e6b702adffbe2853cfc60e7806
    2fca5ccf97d2c28bcfce44f5b07d85e74e3cd18e

    Although using block layer tagging is the right direction, due to the
    tight coupling among tag number, data structure allocation and
    hardware command slot allocation, libata doesn't work correctly with
    the current conversion.

    The biggest problem is guaranteeing that tag 0 is always used for
    non-NCQ commands. Due to the way blk-tag is implemented and how SCSI
    starts and finishes requests, such guarantee can't be made. I'm not
    sure whether this would actually break any low level driver but it
    doesn't look like a good idea to break such assumption given the
    frailty of ATA controllers.

    So, for the time being, keep using the old dumb in-libata qc
    allocation.

    Signed-off-by: Tejun Heo
    Cc: Jens Axobe
    Cc: Jeff Garzik
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

24 Oct, 2008

1 commit

  • libata currently has a pretty dumb ATA_MAX_QUEUE loop for finding
    a free tag to use. Instead of fixing that up, convert libata to
    using block layer tagging - gets rid of code in libata, and is also
    much faster.

    Signed-off-by: Jens Axboe
    Acked-by: Tejun Heo
    Signed-off-by: Linus Torvalds

    Jens Axboe
     

11 Oct, 2008

1 commit

  • * 'for-2.6.28' of git://git.kernel.dk/linux-2.6-block: (132 commits)
    doc/cdrom: Trvial documentation error, file not present
    block_dev: fix kernel-doc in new functions
    block: add some comments around the bio read-write flags
    block: mark bio_split_pool static
    block: Find bio sector offset given idx and offset
    block: gendisk integrity wrapper
    block: Switch blk_integrity_compare from bdev to gendisk
    block: Fix double put in blk_integrity_unregister
    block: Introduce integrity data ownership flag
    block: revert part of d7533ad0e132f92e75c1b2eb7c26387b25a583c1
    bio.h: Remove unused conditional code
    block: remove end_{queued|dequeued}_request()
    block: change elevator to use __blk_end_request()
    gdrom: change to use __blk_end_request()
    memstick: change to use __blk_end_request()
    virtio_blk: change to use __blk_end_request()
    blktrace: use BLKTRACE_BDEV_SIZE as the name size for setup structure
    block: add lld busy state exporting interface
    block: Fix blk_start_queueing() to not kick a stopped queue
    include blktrace_api.h in headers_install
    ...

    Linus Torvalds
     

09 Oct, 2008

1 commit

  • Right now SCSI and others do their own command timeout handling.
    Move those bits to the block layer.

    Instead of having a timer per command, we try to be a bit more clever
    and simply have one per-queue. This avoids the overhead of having to
    tear down and setup a timer for each command, so it will result in a lot
    less timer fiddling.

    Signed-off-by: Mike Anderson
    Signed-off-by: Jens Axboe

    Jens Axboe
     

29 Sep, 2008

1 commit

  • Explanation taken from the comment of ata_slave_link_init().

    In libata, a port contains links and a link contains devices. There
    is single host link but if a PMP is attached to it, there can be
    multiple fan-out links. On SATA, there's usually a single device
    connected to a link but PATA and SATA controllers emulating TF based
    interface can have two - master and slave.

    However, there are a few controllers which don't fit into this
    abstraction too well - SATA controllers which emulate TF interface
    with both master and slave devices but also have separate SCR
    register sets for each device. These controllers need separate links
    for physical link handling (e.g. onlineness, link speed) but should
    be treated like a traditional M/S controller for everything else
    (e.g. command issue, softreset).

    slave_link is libata's way of handling this class of controllers
    without impacting core layer too much. For anything other than
    physical link handling, the default host link is used for both master
    and slave. For physical link handling, separate @ap->slave_link is
    used. All dirty details are implemented inside libata core layer.
    From LLD's POV, the only difference is that prereset, hardreset and
    postreset are called once more for the slave link, so the reset
    sequence looks like the following.

    prereset(M) -> prereset(S) -> hardreset(M) -> hardreset(S) ->
    softreset(M) -> postreset(M) -> postreset(S)

    Note that softreset is called only for the master. Softreset resets
    both M/S by definition, so SRST on master should handle both (the
    standard method will work just fine).

    As slave_link excludes PMP support and only code paths which deal with
    the attributes of physical link are affected, all the changes are
    localized to libata.h, libata-core.c and libata-eh.c.

    * ata_is_host_link() updated so that slave_link is considered as host
    link too.

    * iterator extended to iterate over the slave_link when using the
    underbarred version.

    * force param handling updated such that devno 16 is mapped to the
    slave link/device.

    * ata_link_on/offline() updated to return the combined result from
    master and slave link. ata_phys_link_on/offline() are the direct
    versions.

    * EH autopsy and report are performed separately for master slave
    links. Reset is udpated to implement the above described reset
    sequence.

    Except for reset update, most changes are minor, many of them just
    modifying dev->link to ata_dev_phys_link(dev) or using phys online
    test instead.

    After this update, LLDs can take full advantage of per-dev SCR
    registers by simply turning on slave link.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

31 Jul, 2008

1 commit

  • Global and per-LLD ATAPI disable checks were done in the command issue
    path probably because it was left out during EH conversion. On
    affected machines, this can cause lots of warning messages. Move them
    to where they belong - the probing path.

    Reported by Chunbo Luo.

    Signed-off-by: Tejun Heo
    Cc: Chunbo Luo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

15 Jul, 2008

1 commit

  • ATA_TMOUT_INTERNAL which was 30secs were used for all internal
    commands which is way too long when something goes wrong. This patch
    implements command type based stepped timeouts. Different command
    types can use different timeouts and each command type can use
    different timeout values after timeouts.

    ie. the initial timeout is set to a value which should cover most of
    the cases but not too long so that run away cases don't delay things
    too much. After the first try times out, the second try can use
    longer timeout and if that one times out too, it can go for full 30sec
    timeout.

    IDENTIFYs use 5s - 10s - 30s timeout and all other commands use 5s -
    10s timeouts.

    This patch significantly cuts down the needed time to handle failure
    cases while still allowing libata to work with nut job devices through
    retries.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

19 Jun, 2008

1 commit


29 Apr, 2008

1 commit


25 Apr, 2008

1 commit


18 Apr, 2008

8 commits

  • Make PMP support optional by adding CONFIG_SATA_PMP and leaving out
    libata-pmp.c if it isn't set. PMP helpers return constant values if
    PMP support is not enabled and PMP declarations alias non-PMP
    counterparts. This makes the compiler to leave out PMP related part
    out and LLDs to use non-PMP counterparts automatically.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Most of PMP support code is already in libata-pmp.c. All that are in
    libata-core.c are sata_pmp_port_ops and EXPORTs. Move them to
    libata-pmp.c. Also, collect PMP related prototypes and declarations
    in header files and move them right above of SFF stuff.

    This change is to make PMP support optional.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Now that SFF support is completely separated out from the core layer,
    it can be made optional. Add CONFIG_ATA_SFF and let SFF drivers
    depend on it. If CONFIG_ATA_SFF isn't set, all codes in libata-sff.c
    and data structures for SFF support are disabled. This saves good
    number of bytes for small systems.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Implement sata_std_hardreset(), which simply wraps around
    sata_link_hardreset(). sata_std_hardreset() becomes new standard
    hardreset method for sata_port_ops and sata_sff_hardreset() moves from
    ata_base_port_ops to ata_sff_port_ops, which is where it really
    belongs.

    ata_is_builtin_hardreset() is added so that both
    ata_std_error_handler() and ata_sff_error_handler() skip both builtin
    hardresets if SCR isn't accessible.

    piix_sidpr_hardreset() in ata_piix.c is identical to
    sata_std_hardreset() in functionality and got replaced with the
    standard function.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Factor out waiting logic (which is common to all ATA controllers) from
    ata_sff_wait_ready() into ata_wait_ready(). ata_wait_ready() takes
    @check_ready function pointer and uses it to poll for readiness. This
    allows non-SFF controllers to use ata_wait_ready() to wait for link
    readiness.

    This patch also implements ata_wait_after_reset() - generic version of
    ata_sff_wait_after_reset() - using ata_wait_ready().

    ata_sff_wait_ready() is reimplemented using ata_wait_ready() and
    ata_sff_check_ready(). Functionality remains the same.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • ata_flush_code() hasn't been in use for quite some time now. Kill it.

    Signed-off-by: Tejun Heo
    Cc: Alan Cox
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • ata_tf_to_lba[48]() currently return LBA in tf + 1 for
    ata_read_native_max_address(). Make them return LBA and make it
    global so that it can be used to read LBA off TF for other purposes.
    ata_read_native_max_address() now adds 1 itself.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • * Move SFF related functions from libata-core.c to libata-sff.c.

    ata_[bmdma_]sff_port_ops, ata_devchk(), ata_dev_try_classify(),
    ata_std_dev_select(), ata_tf_to_host(), ata_busy_sleep(),
    ata_wait_after_reset(), ata_wait_ready(), ata_bus_post_reset(),
    ata_bus_softreset(), ata_bus_reset(), ata_std_softreset(),
    sata_std_hardreset(), ata_fill_sg(), ata_fill_sg_dumb(),
    ata_qc_prep(), ata_dump_qc_prep(), ata_data_xfer(),
    ata_data_xfer_noirq(), ata_pio_sector(), ata_pio_sectors(),
    atapi_send_cdb(), __atapi_pio_bytes(), atapi_pio_bytes(),
    ata_hsm_ok_in_wq(), ata_hsm_qc_complete(), ata_hsm_move(),
    ata_pio_task(), ata_qc_issue_prot(), ata_host_intr(),
    ata_interrupt(), ata_std_ports()

    * Make ata_pio_queue_task() global as it's now called from
    libata-sff.c.

    * Move SFF related stuff in include/linux/libata.h and
    drivers/ata/libata.h into one place. While at it, move timing
    constants into the global enum definition and fortify comments a
    bit.

    This patch strictly moves stuff around and as such doesn't cause any
    functional difference.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

26 Feb, 2008

1 commit


21 Feb, 2008

1 commit

  • This patch implements libata.force module parameter which can
    selectively override ATA port, link and device configurations
    including cable type, SATA PHY SPD limit, transfer mode and NCQ.

    For example, you can say "use 1.5Gbps for all fan-out ports attached
    to the second port but allow 3.0Gbps for the PMP device itself, oh,
    the device attached to the third fan-out port chokes on NCQ and
    shouldn't go over UDMA4" by the following.

    libata.force=2:1.5g,2.15:3.0g,2.03:noncq,udma4

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

23 Jan, 2008

2 commits

  • Move ata_set_mode() to libata-eh.c. ata_set_mode() is surely an EH
    action and will be more tightly coupled with the rest of error
    handling. Move it to libata-eh.c.

    Signed-off-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • ACPI spec (ver 3.0a, p289) requires IDE power on/off executes ACPI _PSx
    methods. As recently most PATA drivers use libata, this patch adds _PSx
    method support in libata. ACPI spec doesn't mention if SATA requires the
    same _PSx method.

    Signed-off-by: Shaohua Li
    Acked-by: Len Brown
    Signed-off-by: Jeff Garzik

    Shaohua Li