01 Nov, 2011

1 commit

  • Standardize the style for compiler based printf format verification.
    Standardized the location of __printf too.

    Done via script and a little typing.

    $ grep -rPl --include=*.[ch] -w "__attribute__" * | \
    grep -vP "^(tools|scripts|include/linux/compiler-gcc.h)" | \
    xargs perl -n -i -e 'local $/; while (<>) { s/\b__attribute__\s*\(\s*\(\s*format\s*\(\s*printf\s*,\s*(.+)\s*,\s*(.+)\s*\)\s*\)\s*\)/__printf($1, $2)/g ; print; }'

    [akpm@linux-foundation.org: revert arch bits]
    Signed-off-by: Joe Perches
    Cc: "Kirill A. Shutemov"
    Signed-off-by: Andrew Morton
    Signed-off-by: Linus Torvalds

    Joe Perches
     

03 Oct, 2011

1 commit

  • Pass queue_depth change requests to libata, and prevent queue_type
    changes for ATA devices.

    Otherwise:
    1/ we do not honor the libata specific restrictions on the queue depth
    2/ libsas drivers that do not set sdev->tagged_supported are unable to
    change the queue_depth of ata devices via sysfs

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

    Dan Williams
     

24 Jul, 2011

2 commits

  • Use a single mechanism to show driver version.
    Reduces text a tiny bit too.

    Remove uses of static int printed_version
    Add and use ata_print_version(const struct device *, const char *ver)
    and ata_print_version_once.

    $ size drivers/ata/built-in.*
    text data bss dec hex filename
    544969 73893 116584 735446 b38d6 drivers/ata/built-in.allyesconfig.ata.o
    543870 73893 116592 734355 b34ad drivers/ata/built-in.allyesconfig.print_once.o
    141328 14689 4220 160237 271ed drivers/ata/built-in.defconfig.ata.o
    141212 14689 4220 160121 27179 drivers/ata/built-in.defconfig.print_once.o

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     
  • Saves text by removing nearly duplicated text format strings by
    creating ata__printk functions and printf extension %pV.

    ata defconfig size shrinks ~5% (~8KB), allyesconfig ~2.5% (~13KB)

    Format string duplication comes from:

    #define ata_link_printk(link, lv, fmt, args...) do { \
    if (sata_pmp_attached((link)->ap) || (link)->ap->slave_link) \
    printk("%sata%u.%02u: "fmt, lv, (link)->ap->print_id, \
    (link)->pmp , ##args); \
    else \
    printk("%sata%u: "fmt, lv, (link)->ap->print_id , ##args); \
    } while(0)

    Coalesce long formats.

    $ size drivers/ata/built-in.*
    text data bss dec hex filename
    544969 73893 116584 735446 b38d6 drivers/ata/built-in.allyesconfig.ata.o
    558429 73893 117864 750186 b726a drivers/ata/built-in.allyesconfig.dev_level.o
    141328 14689 4220 160237 271ed drivers/ata/built-in.defconfig.ata.o
    149567 14689 4220 168476 2921c drivers/ata/built-in.defconfig.dev_level.o

    Signed-off-by: Joe Perches
    Signed-off-by: Jeff Garzik

    Joe Perches
     

20 May, 2011

1 commit

  • Give users the option of completely powering off unoccupied
    SATA ports using the existing min_power link_power_management_policy
    option. When the use selects this option on an empty port, we
    will power the port off by setting DET to off. For occupied ports,
    behavior is unchanged.

    Signed-off-by: Kristen Carlson Accardi
    Signed-off-by: Jeff Garzik

    Kristen Carlson Accardi
     

24 Apr, 2011

2 commits


31 Mar, 2011

1 commit


14 Mar, 2011

1 commit


02 Mar, 2011

5 commits

  • Commit 6b7ae9545ad9875a289f4191c0216b473e313cb9 (libata: reimplement link power
    management) removed the check of ATA_FLAG_LPM but neglected to remove the flag
    itself. Do it now...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Jeff Garzik

    Sergei Shtylyov
     
  • All checks of ATA_FLAG_NO_LEGACY have been removed by the commits
    c791c30670ea61f19eec390124128bf278e854fe ([libata] minor PCI IDE probe
    fixes and cleanups) and f0d36efdc624beb3d9e29b9ab9e9537bf0f25d5b (libata:
    update libata core layer to use devres), so I think it's time to finally
    get rid of this flag...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Jeff Garzik

    Sergei Shtylyov
     
  • Commit 0d5ff566779f894ca9937231a181eb31e4adff0e (libata: convert to iomap)
    removed all checks of ATA_FLAG_MMIO but neglected to remove the flag itself.
    Do it now, at last...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Jeff Garzik

    Sergei Shtylyov
     
  • These flags are marked as obsolete and the checks for them have been removed
    by commit 294440887b32c58d220fb54b73b7a58079b78f20 (libata-sff: kill unused
    ata_bus_reset()), so I think it's time to finally get rid of them...

    Signed-off-by: Sergei Shtylyov
    Signed-off-by: Jeff Garzik

    Sergei Shtylyov
     
  • Right at the moment, the libata error handler is incredibly
    monolithic. This makes it impossible to use from composite drivers
    like libsas and ipr which have to handle error themselves in the first
    instance.

    The essence of the change is to split the monolithic error handler
    into two components: one which handles a queue of ata commands for
    processing and the other which handles the back end of readying a
    port. This allows the upper error handler fine grained control in
    calling libsas functions (and making sure they only get called for ATA
    commands whose lower errors have been fixed up).

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

    James Bottomley
     

06 Jan, 2011

1 commit


17 Nov, 2010

1 commit

  • Move the mid-layer's ->queuecommand() invocation from being locked
    with the host lock to being unlocked to facilitate speeding up the
    critical path for drivers who don't need this lock taken anyway.

    The patch below presents a simple SCSI host lock push-down as an
    equivalent transformation. No locking or other behavior should change
    with this patch. All existing bugs and locking orders are preserved.

    Additionally, add one parameter to queuecommand,
    struct Scsi_Host *
    and remove one parameter from queuecommand,
    void (*done)(struct scsi_cmnd *)

    Scsi_Host* is a convenient pointer that most host drivers need anyway,
    and 'done' is redundant to struct scsi_cmnd->scsi_done.

    Minimal code disturbance was attempted with this change. Most drivers
    needed only two one-line modifications for their host lock push-down.

    Signed-off-by: Jeff Garzik
    Acked-by: James Bottomley
    Signed-off-by: Linus Torvalds

    Jeff Garzik
     

22 Oct, 2010

8 commits

  • Signed-off-by: Andrea Gelmini
    Signed-off-by: Jeff Garzik

    Andrea Gelmini
     
  • Reorder structure ata_queued_cmd to remove 8 bytes of alignment padding
    on 64 bit builds & therefore reduce the size of structure ata_port by
    256 bytes.

    Overall this will have little impact, other than reducing the amount of
    memory that is cleared when allocating ata_ports.

    Signed-off-by: Richard Kennedy
    Signed-off-by: Jeff Garzik

    Richard Kennedy
     
  • 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
     
  • Add optional @ap argument to ata_wait_register() and replace msleep()
    calls with ata_msleep() which take optional @ap in addition to the
    duration. These will be used to implement EH exclusion.

    This patch doesn't cause any behavior difference.

    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
     

10 Sep, 2010

2 commits

  • Keep track of the link on the which the current request is in progress.
    It allows support of links behind port multiplier.

    Not all libata-sff is PMP compliant. Code for native BMDMA controller
    does not take in accound PMP.

    Tested on Marvell 7042 and Sil7526.

    Signed-off-by: Gwendal Grignou
    Signed-off-by: Jeff Garzik

    Gwendal Grignou
     
  • For some mysterious reason, certain hardware reacts badly to usual EH
    actions while the system is going for suspend. As the devices won't
    be needed until the system is resumed, ask EH to skip usual autopsy
    and recovery and proceed directly to suspend.

    Signed-off-by: Tejun Heo
    Tested-by: Stephan Diestelhorst
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

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
     

03 Jun, 2010

1 commit

  • Implement ata_scsi_unlock_native_capacity() which will be called
    through SCSI layer when block layer notices that partitions on a
    device extend beyond the end of the device. It requests EH to unlock
    HPA, waits for completion and returns the current device capacity.

    This allows libata to unlock HPA on demand instead of having to decide
    whether to unlock upfront. Unlocking on demand is safer than
    unlocking by upfront because some BIOSes write private data to the
    area beyond HPA limit. This was suggested by Ben Hutchings.

    Signed-off-by: Tejun Heo
    Suggested-by: Ben Hutchings
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

26 May, 2010

5 commits

  • Add dump_id libata.force parameter. If specified, libata dumps full
    IDENTIFY data during device configuration. This is to aid debugging.

    Signed-off-by: Tejun Heo
    Cc: Larry Baker
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • Make BMDMA optional depending on new config variable CONFIG_ATA_BMDMA.
    In Kconfig, drivers are grouped into five groups - non-SFF native, SFF
    w/ custom DMA interface, SFF w/ BMDMA, PIO-only SFF, and generic
    fallback / legacy ones. Kconfig and Makefile are reorganized
    according to the groups and ordered alphabetically inside each group.

    ata_ioports.bmdma_addr and ata_port.bmdma_prd[_dma] are put into
    CONFIG_ATA_BMDMA, as are all bmdma related ops, variables and
    functions.

    This increase the binary size slightly when BMDMA is enabled but on
    both native-only and PIO-only configurations the size is slightly
    reduced. Either way, the size difference is insignificant. This
    change is more meaningful to signify the separation between SFF and
    BMDMA and as a tool to verify the separation.

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

    Tejun Heo
     
  • Separate out ata_pci_bmdma_prepare_host() and ata_pci_bmdma_init_one()
    from their SFF counterparts. SFF ones no longer try to initialize
    BMDMA or set PCI master.

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

    Tejun Heo
     
  • Separate out BMDMA irq handler from SFF irq handler. The misnamed
    host_intr() functions are renamed to ata_sff_port_intr() and
    ata_bmdma_port_intr(). Common parts are factored into
    __ata_sff_port_intr() and __ata_sff_interrupt() and used by sff and
    bmdma interrupt routines.

    All BMDMA drivers now use ata_bmdma_interrupt() or
    ata_bmdma_port_intr() while all non-BMDMA SFF ones use
    ata_sff_interrupt() or ata_sff_port_intr().

    For now, ata_pci_sff_init_one() uses ata_bmdma_interrupt() as it's
    used by both SFF and BMDMA drivers.

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

    Tejun Heo
     
  • ata_sff_irq_clear() is BMDMA specific. Rename it to
    ata_bmdma_irq_clear(), move it to ata_bmdma_port_ops and make
    ->sff_irq_clear() optional.

    Note: ata_bmdma_irq_clear() is actually only needed by ata_piix and
    possibly by sata_sil. This should be moved to respective low
    level drivers later.

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

    Tejun Heo
     

20 May, 2010

7 commits

  • Separate out ata_bmdma_qc_issue() from ata_sff_qc_issue() such that
    ata_sff_qc_issue() only deals with non-BMDMA SFF protocols (PIO and
    nodata) while ata_bmdma_qc_issue() deals with the BMDMA protocols and
    uses ata_sff_qc_issue() for non-DMA commands. All the users are
    updated accordingly.

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

    Tejun Heo
     
  • struct ata_prd and ap->prd are BMDMA specific. Add bmdma_ prefix to
    them and move them inside CONFIG_ATA_SFF.

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

    Tejun Heo
     
  • Both qc_prep functions deal only with BMDMA PRD setup and PIO only SFF
    drivers don't need them. Rename to ata_bmdma_[dumb_]qc_prep() and
    relocate.

    All usages are renamed except for pdc_adma and sata_qstor. Those two
    drivers are not BMDMA drivers and don't need to call BMDMA qc_prep
    functions. Calls to ata_sff_qc_prep() in the two drivers are removed.

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

    Tejun Heo
     
  • 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
     
  • ap->[last_]ctl are specific to SFF controllers. Put them inside
    CONFIG_ATA_SFF and move initialization into ata_sff_port_init().

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

    Tejun Heo
     
  • ->drain_fifo() is SFF specific. Rename and relocate it.

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

    Tejun Heo