09 Jan, 2012

1 commit

  • This is another attempt at fixing the same problem that 270dac35c2
    (libata: ahci_start_engine compliant to AHCI spec) tried to solve.
    Unfortunately, 270dac35c2 created regressions for a lot more common
    controllers and got reverted.

    This specific AHCI IP block becomes a brick if the DMA engine is
    started while DRQ is set. It is not possible to avoid the condition
    completely but the most common occurrence is caused by spurious use of
    ahci_start_engine() from ahci_start_port() during init sequence.

    DMA engine is started after both soft and hard resets and
    ahci_start_port() is always followed by resets, so there is no reason
    to start DMA engine from ahci_start_port().

    This patch removes ahci_start_engine() invocation from
    ahci_start_port(). This change makes failure path of
    ahci_port_suspend() leave engine stopped without following resets.
    This is resolved by replacing ahci_start_port() call with
    ata_port_freeze() which forces resets afterwards, which is the better
    behavior anyway.

    Signed-off-by: Tejun Heo
    Reported-by: Brian Norris
    Reported-by: Jian Peng
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

24 Jul, 2011

3 commits

  • ahci_sb600_softreset was in ahci.c. This function is used
    to fix soft reset failure and renames as ahci_pmp_retry_softreset
    in libahci.c.

    Signed-off-by: Yuan-Hsin Chen
    Signed-off-by: Jeff Garzik

    Yuan-Hsin Chen
     
  • 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
     
  • Saves a bit of text as the call takes fewer args.

    Coalesce a few formats.
    Convert a few bare printks to pr_cont.

    $ size drivers/ata/built-in.o*
    text data bss dec hex filename
    558429 73893 117864 750186 b726a drivers/ata/built-in.o.allyesconfig.new
    559574 73893 117888 751355 b76fb drivers/ata/built-in.o.allyesconfig.old
    149567 14689 4220 168476 2921c drivers/ata/built-in.o.defconfig.new
    149851 14689 4220 168760 29338 drivers/ata/built-in.o.defconfig.old

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

    Joe Perches
     

30 Jun, 2011

1 commit

  • It's not so much an error as a warning about normal Marvell crazines.
    So don't use KERN_ERR that ends up spamming the console even in quiet
    mode, it's not _that_ critical.

    Explained by Jeff:

    "Long explanation, it's a mess:

    Marvell took standard AHCI, and bastardized it to include a weird mode
    whereby PATA devices appear inside the AHCI DMA and interrupt
    infrastructure you're familiar with.

    So, PATA devices appear via pata_marvell driver, using basic legacy
    IDE programming interface. But SATA devices, which might also be
    attached to this chip, either work in under-performing mode or
    simply don't work at all (e.g. newer 6 Gbps devices or port
    multiplier attachments, NCQ, ...)

    On the other hand, 'ahci' driver loads and works with the chip's
    attached SATA devices quite beautifully, but is completely unable to
    drive any attached PATA devices, due to the Marvell-specific
    PATA-under-AHCI interface.

    The "masking port_map 0x7 -> 0x3" message is the ahci driver "hiding"
    the PATA port(s) from itself, making sure it will only drive the SATA
    ports it knows how to drive."

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

    Linus Torvalds
     

15 May, 2011

1 commit

  • This reverts commit 270dac35c26433d06a89150c51e75ca0181ca7e4.

    The commits causes command timeouts on AC plug/unplug. It isn't yet
    clear why. As the commit was for a single rather obscure controller,
    revert the change for now.

    The problem was reported and bisected by Gu Rui in bug#34692.

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

    Also, reported by Rafael and Michael in the following thread.

    http://thread.gmane.org/gmane.linux.kernel/1138771

    Signed-off-by: Tejun Heo
    Reported-by: Gu Rui
    Reported-by: Rafael J. Wysocki
    Reported-by: Michael Leun
    Cc: Jian Peng
    Cc: Jeff Garzik
    Signed-off-by: Linus Torvalds

    Tejun Heo
     

24 Apr, 2011

3 commits

  • At the end of section 10.1 of AHCI spec (rev 1.3), it states

    Software shall not set PxCMD.ST to 1 until it is determined that
    a functoinal device is present on the port as determined by
    PxTFD.STS.BSY=0, PxTFD.STS.DRQ=0 and PxSSTS.DET=3h

    Even though most AHCI host controller works without this check,
    specific controller will fail under this condition.

    Signed-off-by: Jian Peng
    Signed-off-by: Jeff Garzik

    Jian Peng
     
  • The ahci_pmp_attach() & ahci_pmp_detach() unmask port irqs, but they
    are also called during port initialization, before ahci host irq
    handler is registered. On ce4100 platform, this sometimes triggers
    "irq 4: nobody cared" message when loading driver.

    Fixed this by not touching the register if the port is in frozen
    state, and mark all uninitialized port as frozen.

    Signed-off-by: Maxime Bizon
    Acked-by: Tejun Heo
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Maxime Bizon
     
  • This patch adds an sysfs attribute 'em_message_supported' to the
    ahci host device which prints out the supported enclosure management
    message types.

    Signed-off-by: Hannes Reinecke
    Signed-off-by: Jeff Garzik

    Hannes Reinecke
     

06 Jan, 2011

1 commit


22 Oct, 2010

4 commits

  • ATA devices don't send D2H Reg FIS after an successful ATA PIO data-in
    command. The host is supposed to take the TF and E_Status of the
    preceding PIO Setup FIS. Update ahci_qc_fill_rtf() such that it takes
    TF + E_Status from PIO Setup FIS after a successful ATA PIO data-in
    command.

    Without this patch, result_tf for such a command is filled with the
    content of the previous D2H Reg FIS which belongs to a previous
    command, which can make the command incorrectly seen as failed.

    * Patch updated to grab the whole TF + E_Status from PIO Setup FIS
    instead of just E_Status as suggested by Robert Hancock.

    Signed-off-by: Tejun Heo
    Reported-by: Mark Lord
    Cc: Robert Hancock
    Cc: stable@kernel.org
    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 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
     

29 Sep, 2010

1 commit

  • libata depends on scsi_host_template for module reference counting and
    sht's should be owned by each low level driver. During libahci split,
    the sht was left with libahci.ko leaving the actual low level drivers
    not reference counted. This made ahci and ahci_platform always
    unloadable even while they're being actively used.

    Fix it by defining AHCI_SHT() macro in ahci.h and defining a sht for
    each low level ahci driver.

    stable: only applicable to 2.6.35.

    Signed-off-by: Tejun Heo
    Reported-by: Pedro Francisco
    Tested-by: Michael Tokarev
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

10 Sep, 2010

1 commit

  • ahci_do_softreset() compared the current time and deadline in reverse
    when calculating timeout for SRST issue. The result is that if
    @deadline is in future, SRST is issued with 0 timeout, which hasn't
    caused any problem because it later waits for DRDY with the correct
    timeout. If deadline is already exceeded by the time SRST is about to
    be issued, the timeout calculation underflows and if the device
    doesn't respond, timeout doesn't trigger for a _very_ long time.

    Reverse the incorrect comparison order.

    Signed-off-by: Tejun Heo
    Reported-by: Anssi Hannula
    Tested-by: Gwendal Grignou
    Cc: stable@kernel.org
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

26 Aug, 2010

1 commit


02 Jul, 2010

1 commit


08 Jun, 2010

1 commit

  • Commit 96d60303fd (ahci: Turn off DMA engines when there's no device)
    implemented stopping DMA engines on empty ports but it used single
    sampling of status registers to determine device presence which led to
    disabling of DMA engines on occupied ports. Do it after all EH
    actions are complete using device presence state determined by EH.
    This avoids spurious disabling of DMA engines and simplifies the code.

    Signed-off-by: Tejun Heo
    Tested-by: Marc Dionne
    Cc: Matthew Garrett
    Cc: Robert Hancock
    Signed-off-by: Jeff Garzik

    Tejun Heo
     

15 May, 2010

5 commits

  • Add "em_buffer" attribute for SATA AHCI hosts to provide a way for
    userland to access AHCI EM (enclosure management) buffer directly if the
    host supports EM.

    AHCI driver should support SGPIO EM messages. However the SATA/AHCI
    specs did not define the SGPIO message format filled in EM buffer.
    Different HW vendors may have different definitions. The mainly purpose
    of this attribute is to solve this issue by allowing HW vendors to
    provide userland drivers and tools for their SGPIO initiators.

    Signed-off-by: Harry Zhang
    Signed-off-by: Jeff Garzik

    Harry Zhang
     
  • Detect enclosure management message type automatically at driver
    initialization, instead of using module parameter "ahci_em_messages".

    Signed-off-by: Harry Zhang
    Signed-off-by: Jeff Garzik

    Harry Zhang
     
  • Implicit slab.h inclusion via percpu.h is about to go away. Make sure
    gfp.h or slab.h is included as necessary.

    Signed-off-by: Tejun Heo
    Cc: Stephen Rothwell
    Cc: Jeff Garzik
    Signed-off-by: Jeff Garzik

    Tejun Heo
     
  • According to section 10.3.1 of the AHCI spec, PxCMD.ST must not be set
    unless there's a device attached. Following this saves us a measurable
    quantity of power and does not impair hotplug support. Based on a patch
    by Kristen Carlson Accardi.

    Signed-off-by: Matthew Garrett
    Cc: Kristen Carlson Accardi
    Signed-off-by: Jeff Garzik

    Matthew Garrett
     
  • This patch should contain no functional changes, just moves code
    around.

    Signed-off-by: Anton Vorontsov
    Signed-off-by: Jeff Garzik

    Anton Vorontsov