08 Apr, 2020

1 commit

  • During system resume from suspend, this can be observed on ASM1062 PMP
    controller:

    ata10.01: SATA link down (SStatus 0 SControl 330)
    ata10.02: hard resetting link
    ata10.02: SATA link down (SStatus 0 SControl 330)
    ata10.00: configured for UDMA/133
    Kernel panic - not syncing: stack-protector: Kernel
    in: sata_pmp_eh_recover+0xa2b/0xa40

    CPU: 2 PID: 230 Comm: scsi_eh_9 Tainted: P OE
    #49-Ubuntu
    Hardware name: System manufacturer System Product
    1001 12/10/2017
    Call Trace:
    dump_stack+0x63/0x8b
    panic+0xe4/0x244
    ? sata_pmp_eh_recover+0xa2b/0xa40
    __stack_chk_fail+0x19/0x20
    sata_pmp_eh_recover+0xa2b/0xa40
    ? ahci_do_softreset+0x260/0x260 [libahci]
    ? ahci_do_hardreset+0x140/0x140 [libahci]
    ? ata_phys_link_offline+0x60/0x60
    ? ahci_stop_engine+0xc0/0xc0 [libahci]
    sata_pmp_error_handler+0x22/0x30
    ahci_error_handler+0x45/0x80 [libahci]
    ata_scsi_port_error_handler+0x29b/0x770
    ? ata_scsi_cmd_error_handler+0x101/0x140
    ata_scsi_error+0x95/0xd0
    ? scsi_try_target_reset+0x90/0x90
    scsi_error_handler+0xd0/0x5b0
    kthread+0x121/0x140
    ? scsi_eh_get_sense+0x200/0x200
    ? kthread_create_worker_on_cpu+0x70/0x70
    ret_from_fork+0x22/0x40
    Kernel Offset: 0xcc00000 from 0xffffffff81000000
    (relocation range: 0xffffffff80000000-0xffffffffbfffffff)

    Since sata_pmp_eh_recover_pmp() doens't set rc when ATA_DFLAG_DETACH is
    set, sata_pmp_eh_recover() continues to run. During retry it triggers
    the stack protector.

    Set correct rc in sata_pmp_eh_recover_pmp() to let sata_pmp_eh_recover()
    jump to pmp_fail directly.

    BugLink: https://bugs.launchpad.net/bugs/1821434
    Cc: stable@vger.kernel.org
    Signed-off-by: Kai-Heng Feng
    Signed-off-by: Jens Axboe

    Kai-Heng Feng
     

05 Jun, 2019

1 commit

  • Based on 1 normalized pattern(s):

    this file is released under the gplv2

    extracted by the scancode license scanner the SPDX license identifier

    GPL-2.0-only

    has been chosen to replace the boilerplate/reference in 68 file(s).

    Signed-off-by: Thomas Gleixner
    Reviewed-by: Armijn Hemel
    Reviewed-by: Allison Randal
    Cc: linux-spdx@vger.kernel.org
    Link: https://lkml.kernel.org/r/20190531190114.292346262@linutronix.de
    Signed-off-by: Greg Kroah-Hartman

    Thomas Gleixner
     

13 Jun, 2018

1 commit

  • The kzalloc() function has a 2-factor argument form, kcalloc(). This
    patch replaces cases of:

    kzalloc(a * b, gfp)

    with:
    kcalloc(a * b, gfp)

    as well as handling cases of:

    kzalloc(a * b * c, gfp)

    with:

    kzalloc(array3_size(a, b, c), gfp)

    as it's slightly less ugly than:

    kzalloc_array(array_size(a, b), c, gfp)

    This does, however, attempt to ignore constant size factors like:

    kzalloc(4 * 1024, gfp)

    though any constants defined via macros get caught up in the conversion.

    Any factors with a sizeof() of "unsigned char", "char", and "u8" were
    dropped, since they're redundant.

    The Coccinelle script used for this was:

    // Fix redundant parens around sizeof().
    @@
    type TYPE;
    expression THING, E;
    @@

    (
    kzalloc(
    - (sizeof(TYPE)) * E
    + sizeof(TYPE) * E
    , ...)
    |
    kzalloc(
    - (sizeof(THING)) * E
    + sizeof(THING) * E
    , ...)
    )

    // Drop single-byte sizes and redundant parens.
    @@
    expression COUNT;
    typedef u8;
    typedef __u8;
    @@

    (
    kzalloc(
    - sizeof(u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * (COUNT)
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(__u8) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(char) * COUNT
    + COUNT
    , ...)
    |
    kzalloc(
    - sizeof(unsigned char) * COUNT
    + COUNT
    , ...)
    )

    // 2-factor product with sizeof(type/expression) and identifier or constant.
    @@
    type TYPE;
    expression THING;
    identifier COUNT_ID;
    constant COUNT_CONST;
    @@

    (
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_ID)
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_ID
    + COUNT_ID, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (COUNT_CONST)
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * COUNT_CONST
    + COUNT_CONST, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_ID)
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_ID
    + COUNT_ID, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (COUNT_CONST)
    + COUNT_CONST, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * COUNT_CONST
    + COUNT_CONST, sizeof(THING)
    , ...)
    )

    // 2-factor product, only identifiers.
    @@
    identifier SIZE, COUNT;
    @@

    - kzalloc
    + kcalloc
    (
    - SIZE * COUNT
    + COUNT, SIZE
    , ...)

    // 3-factor product with 1 sizeof(type) or sizeof(expression), with
    // redundant parens removed.
    @@
    expression THING;
    identifier STRIDE, COUNT;
    type TYPE;
    @@

    (
    kzalloc(
    - sizeof(TYPE) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(TYPE))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * (COUNT) * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * (STRIDE)
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    |
    kzalloc(
    - sizeof(THING) * COUNT * STRIDE
    + array3_size(COUNT, STRIDE, sizeof(THING))
    , ...)
    )

    // 3-factor product with 2 sizeof(variable), with redundant parens removed.
    @@
    expression THING1, THING2;
    identifier COUNT;
    type TYPE1, TYPE2;
    @@

    (
    kzalloc(
    - sizeof(TYPE1) * sizeof(TYPE2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(THING1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(THING1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * COUNT
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    |
    kzalloc(
    - sizeof(TYPE1) * sizeof(THING2) * (COUNT)
    + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
    , ...)
    )

    // 3-factor product, only identifiers, with redundant parens removed.
    @@
    identifier STRIDE, SIZE, COUNT;
    @@

    (
    kzalloc(
    - (COUNT) * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * STRIDE * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - (COUNT) * (STRIDE) * (SIZE)
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    |
    kzalloc(
    - COUNT * STRIDE * SIZE
    + array3_size(COUNT, STRIDE, SIZE)
    , ...)
    )

    // Any remaining multi-factor products, first at least 3-factor products,
    // when they're not all constants...
    @@
    expression E1, E2, E3;
    constant C1, C2, C3;
    @@

    (
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(
    - (E1) * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * E3
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - (E1) * (E2) * (E3)
    + array3_size(E1, E2, E3)
    , ...)
    |
    kzalloc(
    - E1 * E2 * E3
    + array3_size(E1, E2, E3)
    , ...)
    )

    // And then all remaining 2 factors products when they're not all constants,
    // keeping sizeof() as the second factor argument.
    @@
    expression THING, E1, E2;
    type TYPE;
    constant C1, C2, C3;
    @@

    (
    kzalloc(sizeof(THING) * C2, ...)
    |
    kzalloc(sizeof(TYPE) * C2, ...)
    |
    kzalloc(C1 * C2 * C3, ...)
    |
    kzalloc(C1 * C2, ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * (E2)
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(TYPE) * E2
    + E2, sizeof(TYPE)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * (E2)
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - sizeof(THING) * E2
    + E2, sizeof(THING)
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * E2
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - (E1) * (E2)
    + E1, E2
    , ...)
    |
    - kzalloc
    + kcalloc
    (
    - E1 * E2
    + E1, E2
    , ...)
    )

    Signed-off-by: Kees Cook

    Kees Cook
     

15 Jul, 2015

1 commit

  • This commit adds the necessary quirk to make the Marvell 4140 SATA PMP
    work properly. This PMP doesn't like SRST on port number 4 (the host
    port) so this commit marks this port as not supporting SRST.

    Signed-off-by: Lior Amsalem
    Reviewed-by: Nadav Haklai
    Signed-off-by: Thomas Petazzoni
    Signed-off-by: Tejun Heo
    Cc: stable@vger.kernel.org

    Lior Amsalem
     

31 Jan, 2014

1 commit

  • Without the patch the kernel generates the following error.

    ata11.15: SATA link up 1.5 Gbps (SStatus 113 SControl 310)
    ata11.15: Port Multiplier vendor mismatch '0x197b' != '0x123'
    ata11.15: PMP revalidation failed (errno=-19)
    ata11.15: failed to recover PMP after 5 tries, giving up

    This patch helps to bypass this error and the device becomes
    functional.

    Signed-off-by: Denis V. Lunev
    Signed-off-by: Tejun Heo
    Cc:
    Cc: stable@vger.kernel.org

    Denis V. Lunev
     

19 Aug, 2013

1 commit

  • Fixing support for the Silicon Image 3826 port multiplier, by applying
    to it the same quirks applied to the Silicon Image 3726. Specifically
    fixes the repeated timeout/reset process which previously afflicted
    the 3726, as described from line 290. Slightly based on notes from:

    https://bugzilla.redhat.com/show_bug.cgi?id=890237

    Signed-off-by: Terry Suereth
    Signed-off-by: Tejun Heo
    Cc: stable@vger.kernel.org

    Terry Suereth
     

11 Jun, 2013

1 commit

  • For some reason, a lot of port-multipliers have issues with softreset.
    SIMG [34]7x series port-multipliers have been quite erratic in this
    regard. I recall that it was better with some firmware revisions and
    the current list of quirks worked fine for a while. I think it got
    worse with later firmwares or maybe my test coverage wasn't good
    enough. Anyways, HPA is reporting that his 3726 setup suffers SRST
    failures and then the PMP gets confused and fails to probe the last
    port.

    The hope was that we try to stick to the standard as much as possible
    and soonish the PMPs and their firmwares will improve in quality, so
    the quirk list was kept to minimum. Well, it seems like that's never
    gonna happen.

    Let's set NO_SRST for all [34]7x PMPs so that whatever remaining
    userbase of the device suffer the least. Maybe we should do the same
    for 57xx's but unfortunately I don't have any device left to test and
    I'm not even sure 57xx's have ever been made widely available, so
    let's leave those alone for now.

    Signed-off-by: Tejun Heo
    Reported-by: "H. Peter Anvin"
    Cc: stable@vger.kernel.org

    Tejun Heo
     

29 Jun, 2012

1 commit

  • Now that we have the ability to directly glue the ACPI namespace to the
    driver model in libata, we don't need the custom code to handle the same
    thing. Remove it and migrate the functions over to the new code.

    Signed-off-by: Matthew Garrett
    Signed-off-by: Holger Macht
    Signed-off-by: Lin Ming
    Signed-off-by: Jeff Garzik

    Matthew Garrett
     

09 Nov, 2011

1 commit

  • Reenable sending SRST to devices connected behind a Sil3726 PMP.
    This allow staggered spinups and handles drives that spins up slowly.

    While the drives spin up, the PMP will not accept SRST.
    Most controller reissues the reset until the drive is ready, while
    some [Sil3124] returns an error.
    In ata_eh_error, wait 10s before reset the ATA port and try again.

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

    Gwendal Grignou
     

01 Nov, 2011

1 commit


24 Jul, 2011

1 commit

  • 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


22 Oct, 2010

2 commits

  • 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
     
  • 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
     

15 May, 2010

1 commit

  • In 2009, While running "cache read" performance test of drives behind
    SII PMP we encountered a "all 5 drives" timeout on more than 30% of the
    machines under test. This patch reduces the rate by a factor of about 70.
    Low enough that we didn't care to further investigate the issue.

    Performance impact with any sort of "normal" use was ~2%+ CPU and less
    than 1% throughput degradation. Worst case impact (cached read) was
    6% IOPS reduction. This is with NCQ off (q=1) but I believe FIS based
    switching enabled in the SATA driver.

    The patch disables "Early ACK" in the 3726 port multiplier.
    "Early ACK" is issued when device sends a FIS to the host (via PMP)
    and the PMP sends an ACK immediately back to the device - well before
    the host gets the response. Under worst case IOPs load (cached read
    test) and more than 2 PMPs connected to a 4-port SATA controller,
    I suspect the time to service all of the PMPs is exceeding the PMPs
    ability to keep track of outstanding FIS it owes the Host. Reducing
    the number of PMPs to 2 (or 1) reduces the frequency by several orders
    of magnitude. Kudos to Gwendal for initial debugging of this issue.
    [Any errors in the description are mine, not his.]

    Patch is currently in production on Google servers.

    Signed-off-by: Grant Grundler
    Signed-off-by: Gwendal Grignou
    Acked-by: Tejun Heo
    Signed-off-by: Jeff Garzik

    Grant Grundler
     

30 Mar, 2010

1 commit

  • …it slab.h inclusion from percpu.h

    percpu.h is included by sched.h and module.h and thus ends up being
    included when building most .c files. percpu.h includes slab.h which
    in turn includes gfp.h making everything defined by the two files
    universally available and complicating inclusion dependencies.

    percpu.h -> slab.h dependency is about to be removed. Prepare for
    this change by updating users of gfp and slab facilities include those
    headers directly instead of assuming availability. As this conversion
    needs to touch large number of source files, the following script is
    used as the basis of conversion.

    http://userweb.kernel.org/~tj/misc/slabh-sweep.py

    The script does the followings.

    * Scan files for gfp and slab usages and update includes such that
    only the necessary includes are there. ie. if only gfp is used,
    gfp.h, if slab is used, slab.h.

    * When the script inserts a new include, it looks at the include
    blocks and try to put the new include such that its order conforms
    to its surrounding. It's put in the include block which contains
    core kernel includes, in the same order that the rest are ordered -
    alphabetical, Christmas tree, rev-Xmas-tree or at the end if there
    doesn't seem to be any matching order.

    * If the script can't find a place to put a new include (mostly
    because the file doesn't have fitting include block), it prints out
    an error message indicating which .h file needs to be added to the
    file.

    The conversion was done in the following steps.

    1. The initial automatic conversion of all .c files updated slightly
    over 4000 files, deleting around 700 includes and adding ~480 gfp.h
    and ~3000 slab.h inclusions. The script emitted errors for ~400
    files.

    2. Each error was manually checked. Some didn't need the inclusion,
    some needed manual addition while adding it to implementation .h or
    embedding .c file was more appropriate for others. This step added
    inclusions to around 150 files.

    3. The script was run again and the output was compared to the edits
    from #2 to make sure no file was left behind.

    4. Several build tests were done and a couple of problems were fixed.
    e.g. lib/decompress_*.c used malloc/free() wrappers around slab
    APIs requiring slab.h to be added manually.

    5. The script was run on all .h files but without automatically
    editing them as sprinkling gfp.h and slab.h inclusions around .h
    files could easily lead to inclusion dependency hell. Most gfp.h
    inclusion directives were ignored as stuff from gfp.h was usually
    wildly available and often used in preprocessor macros. Each
    slab.h inclusion directive was examined and added manually as
    necessary.

    6. percpu.h was updated not to include slab.h.

    7. Build test were done on the following configurations and failures
    were fixed. CONFIG_GCOV_KERNEL was turned off for all tests (as my
    distributed build env didn't work with gcov compiles) and a few
    more options had to be turned off depending on archs to make things
    build (like ipr on powerpc/64 which failed due to missing writeq).

    * x86 and x86_64 UP and SMP allmodconfig and a custom test config.
    * powerpc and powerpc64 SMP allmodconfig
    * sparc and sparc64 SMP allmodconfig
    * ia64 SMP allmodconfig
    * s390 SMP allmodconfig
    * alpha SMP allmodconfig
    * um on x86_64 SMP allmodconfig

    8. percpu.h modifications were reverted so that it could be applied as
    a separate patch and serve as bisection point.

    Given the fact that I had only a couple of failures from tests on step
    6, I'm fairly confident about the coverage of this conversion patch.
    If there is a breakage, it's likely to be something in one of the arch
    headers which should be easily discoverable easily on most builds of
    the specific arch.

    Signed-off-by: Tejun Heo <tj@kernel.org>
    Guess-its-ok-by: Christoph Lameter <cl@linux-foundation.org>
    Cc: Ingo Molnar <mingo@redhat.com>
    Cc: Lee Schermerhorn <Lee.Schermerhorn@hp.com>

    Tejun Heo
     

09 Sep, 2009

1 commit


03 Feb, 2009

1 commit


29 Dec, 2008

1 commit

  • There currently are the following looping constructs.

    * __ata_port_for_each_link() for all available links
    * ata_port_for_each_link() for edge links
    * ata_link_for_each_dev() for all devices
    * ata_link_for_each_dev_reverse() for all devices in reverse order

    Now there's a need for looping construct which is similar to
    __ata_port_for_each_link() but iterates over PMP links before the host
    link. Instead of adding another one with long name, do the following
    cleanup.

    * Implement and export ata_link_next() and ata_dev_next() which take
    @mode parameter and can be used to build custom loop.
    * Implement ata_for_each_link() and ata_for_each_dev() which take
    looping mode explicitly.

    The following iteration modes are implemented.

    * ATA_LITER_EDGE : loop over edge links
    * ATA_LITER_HOST_FIRST : loop over all links, host link first
    * ATA_LITER_PMP_FIRST : loop over all links, PMP links first

    * ATA_DITER_ENABLED : loop over enabled devices
    * ATA_DITER_ENABLED_REVERSE : loop over enabled devices in reverse order
    * ATA_DITER_ALL : loop over all devices
    * ATA_DITER_ALL_REVERSE : loop over all devices in reverse order

    This change removes exlicit device enabledness checks from many loops
    and makes it clear which ones are iterated over in which direction.

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

    Tejun Heo
     

15 Jul, 2008

2 commits

  • EH retries were delayed by 5 seconds to ensure that resets don't occur
    back-to-back. However, this 5 second delay is superflous or excessive
    in many cases. For example, after IDENTIFY times out, there's no
    reason to wait five more seconds before retrying.

    This patch adds ehc->last_reset timestamp and record the timestamp for
    the last reset trial or success and uses it to space resets by
    ATA_EH_RESET_COOL_DOWN which is 5 secs and removes unconditional 5 sec
    sleeps.

    As this change makes inter-try waits often shorter and they're
    redundant in nature, this patch also removes the "retrying..."
    messages.

    While at it, convert explicit rounding up division to DIV_ROUND_UP().

    This change speeds up EH in many cases w/o sacrificing robustness.

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

    Tejun Heo
     
  • libata has been using mix of jiffies and msecs for time druations.
    This is getting confusing. As writing sub HZ values in jiffies is
    PITA and msecs_to_jiffies() can't be used as initializer, unify unit
    for all time durations to msecs. So, durations are in msecs and
    deadlines are in jiffies. ata_deadline() is added to compute deadline
    from a start time and duration in msecs.

    While at it, drop now superflous _msec suffix from arguments and
    rename @timeout to @deadline if it represents a fixed point in time
    rather than duration.

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

    Tejun Heo
     

31 May, 2008

1 commit


20 May, 2008

3 commits

  • PMP notification during reset can make some controllers fail reset
    processing and needs to be turned off during resets. PMP attach and
    full-revalidation path did this via sata_pmp_configure() but the quick
    revalidation wasn't. Move the notification disable code right above
    fan-out port recovery so that it's always turned off.

    This fixes obscure reset failures.

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

    Tejun Heo
     
  • This timeout was set low because previously PMP register access was
    done via polling and register access timeouts could stack up. This is
    no longer the case. One timeout will make all following accesses fail
    immediately.

    In rare cases both marvell and SIMG PMPs need almost a second. Bump
    it to 3s.

    While at it, rename it to SATA_PMP_RW_TIMEOUT. It's not specific to
    SCR access.

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

    Tejun Heo
     
  • Previously reset freeze/thaw handling lived outside of ata_eh_reset()
    mainly because the original PMP reset code needed the port frozen
    while resetting all the fan-out ports, which is no longer the case.

    This patch moves freeze/thaw handling into ata_eh_reset().
    @prereset() and @postreset() are now called w/o freezing the port
    although @prereset() an be called frozen if the port is frozen prior
    to entering ata_eh_reset().

    This makes code simpler and will help removing hotplug event related
    races.

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

    Tejun Heo
     

18 Apr, 2008

10 commits

  • Implement helpers to test whether PMP is supported, attached and
    determine pmp number to use when issuing SRST to a link. While at it,
    move ata_is_host_link() so that it's together with the two new PMP
    helpers.

    This change simplifies LLDs and helps making PMP support optional.

    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
     
  • If PMP fan-out reset fails and SCR isn't accessible, PMP should be
    reset. This used to be tested by sata_pmp_std_hardreset() and
    communicated to EH by -ERESTART. However, this logic is generic and
    doesn't really have much to do with specific hardreset implementation.

    This patch moves SCR access failure detection logic to ata_eh_reset()
    where it belongs. As this makes sata_pmp_std_hardreset() identical to
    sata_std_hardreset(), the function is killed and replaced with the
    standard method.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • SError used to be cleared in ->postreset. This has small hotplug race
    condition. If a device is plugged in after reset is complete but
    postreset hasn't run yet, its hotplug event gets lost when SError is
    cleared. This patch makes sata_link_resume() clear SError. This
    kills the race condition and makes a lot of sense as some PMP and host
    PHYs don't work properly without SError cleared.

    This change makes sata_pmp_std_{pre|post}_reset()'s unnecessary as
    they become identical to ata_std counterparts. It also simplifies
    sata_pmp_hardreset() and ahci_vt8251_hardreset().

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • sata_sff_hardreset() contains link readiness wait logic which isn't
    SFF specific. Move that part into sata_link_hardreset(), which now
    takes two more parameters - @online and @check_ready. Both are
    optional. The former is out parameter for link onlineness after
    reset. The latter is used to wait for link readiness after hardreset.

    Users of sata_link_hardreset() is updated to use new funtionality and
    ahci_hardreset() is updated to use sata_link_hardreset() instead of
    sata_sff_hardreset(). This doesn't really cause any behavior change.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Currently reset methods are not specified directly in the
    ata_port_operations table. If a LLD wants to use custom reset
    methods, it should construct and use a error_handler which uses those
    reset methods. It's done this way for two reasons.

    First, the ops table already contained too many methods and adding
    four more of them would noticeably increase the amount of necessary
    boilerplate code all over low level drivers.

    Second, as ->error_handler uses those reset methods, it can get
    confusing. ie. By overriding ->error_handler, those reset ops can be
    made useless making layering a bit hazy.

    Now that ops table uses inheritance, the first problem doesn't exist
    anymore. The second isn't completely solved but is relieved by
    providing default values - most drivers can just override what it has
    implemented and don't have to concern itself about higher level
    callbacks. In fact, there currently is no driver which actually
    modifies error handling behavior. Drivers which override
    ->error_handler just wraps the standard error handler only to prepare
    the controller for EH. I don't think making ops layering strict has
    any noticeable benefit.

    This patch makes ->prereset, ->softreset, ->hardreset, ->postreset and
    their PMP counterparts propoer ops. Default ops are provided in the
    base ops tables and drivers are converted to override individual reset
    methods instead of creating custom error_handler.

    * ata_std_error_handler() doesn't use sata_std_hardreset() if SCRs
    aren't accessible. sata_promise doesn't need to use separate
    error_handlers for PATA and SATA anymore.

    * softreset is broken for sata_inic162x and sata_sx4. As libata now
    always prefers hardreset, this doesn't really matter but the ops are
    forced to NULL using ATA_OP_NULL for documentation purpose.

    * pata_hpt374 needs to use different prereset for the first and second
    PCI functions. This used to be done by branching from
    hpt374_error_handler(). The proper way to do this is to use
    separate ops and port_info tables for each function. Converted.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • ata_ehi_schedule_probe() was created to hide details of link-resuming
    reset magic. Now that all the softreset workarounds are gone,
    scheduling probe is very simple - set probe_mask and request RESET.
    Kill ata_ehi_schedule_probe() and open code it. This also increases
    consistency as ata_ehi_schedule_probe() couldn't cover individual
    device probings so they were open-coded even when the helper existed.

    While at it, define ATA_ALL_DEVICES as mask of all possible devices on
    a link and always use it when requesting probe on link level for
    simplicity and consistency. Setting extra bits in the probe_mask
    doesn't hurt anybody.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • ATA_EHI_RESUME_LINK has two functions - promote reset to hardreset if
    ATA_LFLAG_HRST_TO_RESUME is set and preventing EH from shortcutting
    reset action when probing is requested. The former is gone now and
    the latter can easily be achieved by making EH to perform at least one
    reset if reset is requested, which also makes more sense than
    depending on RESUME_LINK flag.

    As ATA_EHI_RESUME_LINK was the only EHI reset modifier, this also
    kills reset modifier handling.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • Now that hardreset is the preferred method of resetting, there's no
    need for ATA_LFLAG_HRST_TO_RESUME flag. Kill it.

    Signed-off-by: Tejun Heo

    Tejun Heo
     
  • When both soft and hard resets are available, libata preferred
    softreset till now. The logic behind it was to be softer to devices;
    however, this doesn't really help much. Rationales for the change:

    * BIOS may freeze lock certain things during boot and softreset can't
    unlock those. This by itself is okay but during operation PHY event
    or other error conditions can trigger hardreset and the device may
    end up with different configuration.

    For example, after a hardreset, previously unlockable HPA can be
    unlocked resulting in different device size and thus revalidation
    failure. Similar condition can occur during or after resume.

    * Certain ATAPI devices require hardreset to recover after certain
    error conditions. On PATA, this is done by issuing the DEVICE RESET
    command. On SATA, COMRESET has equivalent effect. The problem is
    that DEVICE RESET needs its own execution protocol.

    For SFF controllers with bare TF access, it can be easily
    implemented but more advanced controllers (e.g. ahci and sata_sil24)
    require specialized implementations. Simply using hardreset solves
    the problem nicely.

    * COMRESET initialization sequence is the norm in SATA land and many
    SATA devices don't work properly if only SRST is used. For example,
    some PMPs behave this way and libata works around by always issuing
    hardreset if the host supports PMP.

    Like the above example, libata has developed a number of mechanisms
    aiming to promote softreset to hardreset if softreset is not going
    to work. This approach is time consuming and error prone.

    Also, note that, dependingon how you read the specs, it could be
    argued that PMP fan-out ports require COMRESET to start operation.
    In fact, all the PMPs on the market except one don't work properly
    if COMRESET is not issued to fan-out ports after PMP reset.

    * COMRESET is an integral part of SATA connection and any working
    device should be able to handle COMRESET properly. After all, it's
    the way to signal hardreset during reboot. This is the most used
    and recommended (at least by the ahci spec) method of resetting
    devices.

    So, this patch makes libata prefer hardreset over softreset by making
    the following changes.

    * Rename ATA_EH_RESET_MASK to ATA_EH_RESET and use it whereever
    ATA_EH_{SOFT|HARD}RESET used to be used. ATA_EH_{SOFT|HARD}RESET is
    now only used to tell prereset whether soft or hard reset will be
    issued.

    * Strip out now unneeded promote-to-hardreset logics from
    ata_eh_reset(), ata_std_prereset(), sata_pmp_std_prereset() and
    other places.

    Signed-off-by: Tejun Heo

    Tejun Heo
     

24 Feb, 2008

1 commit

  • >> Mark Lord wrote:
    >>> Tejun, I've added PMP to sata_mv, and am now trying to get it
    >>> to work with a Marvell PM attached.
    >>>
    >>> And the behaviour I see is very bizarre.
    >>>
    >>> After hard+soft resets, the PM signature is found,
    >>> and libata interrogates the PM registers.
    >>>
    >>> It successfully reads register 0, and then register 1.
    >>> But all subsequent registers read out (incorrectly) as zeros.
    ...

    This behavior has been confirmed by Marvell with a SATA analyzer.
    The Marvell port-multiplier apparently likes to see clean HOB
    information when accessing PMP registers.

    Since sata_mv uses PIO shadow register access, this doesn't happen
    automatically, as it might in a more purely FIS-based driver (eg. ahci).

    One way to fix this is to flag these commands with ATA_TFLAG_LBA48,
    forcing libata to write out the HOB fields with known (zero) values.

    Signed-off-by: Saeed Bishara
    Acked-by: Mark Lord
    Signed-off-by: Jeff Garzik

    Mark Lord
     

11 Jan, 2008

1 commit


13 Oct, 2007

3 commits

  • PMP registers used to be accessed with dedicated accessors ->pmp_read
    and ->pmp_write. During reset, those callbacks are called with the
    port frozen so they should be able to run without depending on
    interrupt delivery. To achieve this, they were implemented polling.

    However, as resetting the host port makes the PMP to isolate fan-out
    ports until SError.X is cleared, resetting fan-out ports while port is
    frozen doesn't buy much additional safety.

    This patch updates libata PMP support such that PMP registers are
    accessed using regular ata_exec_internal() mechanism and kills
    ->pmp_read/write() callbacks. The following changes are made.

    * PMP access helpers - sata_pmp_read_init_tf(), sata_pmp_read_val(),
    sata_pmp_write_init_tf() are folded into sata_pmp_read/write() which
    are now standalone PMP register access functions.

    * sata_pmp_read/write() returns err_mask instead of rc. This is
    consistent with other functions which issue internal commands and
    allows more detailed error reporting.

    * ahci interrupt handler is modified to ignore BAD_PMP and
    spurious/illegal completion IRQs while reset is in progress. These
    conditions are expected during reset.

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

    Tejun Heo
     
  • Implement sata_pmp_qc_defer_cmd_switch() - standard qc_defer for
    command switching PMP support.

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

    Tejun Heo
     
  • Extend ata_acpi_associate_sata_port() such that it can handle PMP and
    call it when PMP is attached and detached.

    Build breakage when !CONFIG_ATA_ACPI was spotted and fixed by Petr
    Vandrovec.

    Signed-off-by: Tejun Heo
    Cc: Petr Vandrovec
    Signed-off-by: Jeff Garzik

    Tejun Heo