22 Nov, 2016

1 commit

  • Don't try to guess what the errors from pci_irq_alloc_vectors mean, as
    that's too fragile. Instead always try allocating a single vector
    when multi-MSI mode fails. This makes various intel Desktop and
    Laptop CPUs use MSI again.

    Signed-off-by: Christoph Hellwig
    Reported-by: Michael Marley
    Tested-by: Michael Marley
    Fixes: 0b9e2988ab22 ("ahci: use pci_alloc_irq_vectors")
    Signed-off-by: Tejun Heo

    Christoph Hellwig
     

25 Oct, 2016

1 commit

  • We need to make sure hpriv->irq is set properly if we don't use per-port
    vectors, so switch from blindly assigning pdev->irq to using
    pci_irq_vector, which handles all interrupt types correctly.

    Signed-off-by: Christoph Hellwig
    Reported-by: Robert Richter
    Tested-by: Robert Richter
    Tested-by: David Daney
    Fixes: 0b9e2988ab22 ("ahci: use pci_alloc_irq_vectors")
    Signed-off-by: Tejun Heo

    Christoph Hellwig
     

21 Oct, 2016

1 commit

  • commit 17a51f12 ("ahci: only try to use multi-MSI mode if there is more
    than 1 port") lead to a case where nvec isn't initialized before it's
    used. Fix this by moving the check into the n_ports conditional.

    Reported-and-reviewed-by Colin Ian King
    Signed-off-by: Christoph Hellwig
    Signed-off-by: Tejun Heo

    Christoph Hellwig
     

20 Oct, 2016

1 commit

  • We should only try to allocate multiple MSI or MSI-X vectors if the device
    actually has multiple ports. Otherwise pci_alloc_irq_vectors will return
    a single vector due to n_ports = 1, in which case we shouldn't set the
    AHCI_HFLAG_MULTI_MSI flag.

    Signed-off-by: Christoph Hellwig
    Fixes: 0b9e2988 ("ahci: use pci_alloc_irq_vectors")
    Reported-by: Emmanuel Benisty
    Tested-by: Emmanuel Benisty
    Signed-off-by: Tejun Heo

    Christoph Hellwig
     

07 Sep, 2016

1 commit

  • Use the new pci_alloc_irq_vectors API to allocate MSI-X and MSI vectors.
    The big advantage over the old code is that we can use the same API for
    MSI and MSI-X, and that we don't need to store the MSI-X vector mapping
    in driver-private data structures.

    This first conversion keeps the probe order as-is: MSI-X multi vector,
    MSI multi vector, MSI single vector, MSI-X single vector and last a
    single least legacy interrupt line. There is one small change of
    behavior: we now check the "MSI Revert to Single Message" flag for
    MSI-X in addition to MSI.

    Because the API to find the Linux IRQ number for a MSI/MSI-X vector
    is PCI specific, but libahaci is bus-agnostic I had to a
    get_irq_vector function pointer to struct ahci_host_priv. The
    alternative would be to move the multi-vector case of ahci_host_activate
    to ahci.c and just call ata_host_activate directly from the others
    users of ahci_host_activate.

    Signed-off-by: Christoph Hellwig
    Signed-off-by: Tejun Heo

    Christoph Hellwig
     

27 May, 2016

1 commit


12 Mar, 2016

2 commits


01 Mar, 2016

1 commit

  • Due to Errata in ThunderX, HOST_IRQ_STAT should be
    cleared before leaving the interrupt handler.
    The patch attempts to satisfy the need.

    Changes from V2:
    - removed newfile
    - code is now under CONFIG_ARM64

    Changes from V1:
    - Rebased on top of libata/for-4.6
    - Moved ThunderX intr handler to new file

    tj: Minor adjustments to comments.

    Signed-off-by: Tirumalesh Chalamarla
    Signed-off-by: Tejun Heo

    Tirumalesh Chalamarla
     

19 Feb, 2016

3 commits

  • This patch adds runtime PM support for the AHCI host controller driver so
    that the host controller is powered down when all SATA ports are runtime
    suspended. Powering down the AHCI host controller can reduce power
    consumption and possibly allow the CPU to enter lower power idle states
    (S0ix) during runtime.

    Runtime PM is blocked by default and needs to be unblocked from userspace
    as needed (via power/* sysfs nodes).

    Signed-off-by: Mika Westerberg
    Signed-off-by: Tejun Heo

    Mika Westerberg
     
  • In order to add support for runtime PM to the ahci driver we first need to
    convert the driver to use modern non-legacy system suspend hooks. There
    should be no functional changes.

    tj: Updated .driver.pm init for older compilers as suggested by Andy
    and Chrsitoph.

    Signed-off-by: Mika Westerberg
    Cc: Andy Shevchenko
    Cc: Christoph Hellwig
    Signed-off-by: Tejun Heo

    Mika Westerberg
     
  • This patch complements the list of device IDs previously
    added for lewisburg sata.

    Signed-off-by: Alexandra Yates
    Signed-off-by: Tejun Heo
    Cc: stable@vger.kernel.org

    Alexandra Yates
     

11 Feb, 2016

1 commit


17 Nov, 2015

3 commits

  • Some AHCI controllers support per-port MSI-X vectors. At the same time
    the Linux AHCI driver needs to support one-off architectures that
    implement a single MSI-X vector for all ports. The heuristic for
    enabling AHCI ports becomes, in order of preference:

    1/ per-port multi-MSI-X

    2/ per-port multi-MSI

    3/ single MSI

    4/ single MSI-X

    5/ legacy INTX

    This all depends on AHCI implementations with potentially broken MSI-X
    requesting less vectors than the number of ports. If this assumption is
    violated we will need to start explicitly white-listing AHCI-MSIX
    implementations.

    Reported-by: Ricardo Neri
    [ricardo: fix struct msix_entry handling]
    Reported-by: kernel test robot
    Signed-off-by: Dan Williams
    Signed-off-by: Tejun Heo

    Dan Williams
     
  • This change was to preserve the ascending order of device IDs.
    There was an exception with the first two Lewisburg device IDs to
    keep all device IDs of the same kind grouped by code name.

    Signed-off-by: Alexandra Yates
    signed-off-by: Tejun Heo

    Alexandra Yates
     
  • This patch adds missing AHCI RAID SATA Device IDs for the Intel Sunrise
    Point PCH.

    Signed-off-by: Nanda Kishore Chinna
    Signed-off-by: Charles Rose
    Signed-off-by: Tejun Heo

    Charles_Rose@Dell.com
     

04 Nov, 2015

1 commit


31 Oct, 2015

1 commit


25 Aug, 2015

1 commit

  • On multi-function JMicron SATA/PATA/AHCI devices, the PATA controller at
    function 1 doesn't work if it is powered on before the SATA controller at
    function 0. The result is that PATA doesn't work after resume, and we
    print messages like this:

    pata_jmicron 0000:02:00.1: Refused to change power state, currently in D3
    irq 17: nobody cared (try booting with the "irqpoll" option)

    Async resume was introduced in v3.15 by 76569faa62c4 ("PM / sleep:
    Asynchronous threads for resume_noirq"). Prior to that, we powered on
    the functions in order, so this problem shouldn't happen.

    e6b7e41cdd8c ("ata: Disabling the async PM for JMicron chip 363/361")
    solved the problem for JMicron 361 and 363 devices. With async suspend
    disabled, we always power on function 0 before function 1.

    Barto then reported the same problem with a JMicron 368 (see comment #57 in
    the bugzilla).

    Rather than extending the blacklist piecemeal, disable async suspend for
    all JMicron multi-function SATA/PATA/AHCI devices.

    This quirk could stay in the ahci and pata_jmicron drivers, but it's likely
    the problem will occur even if pata_jmicron isn't loaded until after the
    suspend/resume. Making it a PCI quirk ensures that we'll preserve the
    power-on order even if the drivers aren't loaded.

    [bhelgaas: changelog, limit to multi-function, limit to IDE/ATA]
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=81551
    Reported-and-tested-by: Barto
    Signed-off-by: Zhang Rui
    Signed-off-by: Bjorn Helgaas
    CC: stable@vger.kernel.org # v3.15+

    Zhang Rui
     

26 Jun, 2015

1 commit

  • Pull libata updates from Tejun Heo:

    - a number of libata core changes to better support NCQ TRIM.

    - ahci now supports MSI-X in single IRQ mode to support a new
    controller which doesn't implement MSI or INTX.

    - ahci now supports edge-triggered IRQ mode to support a new controller
    which for some odd reason did edge-triggered IRQ.

    - the usual controller support additions and changes.

    * 'for-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (27 commits)
    libata: Do not blacklist Micron M500DC
    ata: ahci_mvebu: add suspend/resume support
    ahci, msix: Fix build error for !PCI_MSI
    ahci: Add support for Cavium's ThunderX host controller
    ahci: Add generic MSI-X support for single interrupts to SATA PCI driver
    libata: finally use __initconst in ata_parse_force_one()
    drivers: ata: add support for Ceva sata host controller
    devicetree:bindings: add devicetree bindings for ceva ahci
    ahci: added support for Freescale AHCI sata
    ahci: Store irq number in struct ahci_host_priv
    ahci: Move interrupt enablement code to a separate function
    Doc: libata: Fix spelling typo found in libata.xml
    ata:sata_nv - Change 1 to true for bool type variable.
    ata: add Broadcom AHCI SATA3 driver for STB chips
    Documentation: devicetree: add Broadcom SATA binding
    libata: Fix regression when the NCQ Send and Receive log page is absent
    ata: hpt366: fix constant cast warning
    ata: ahci_xgene: potential NULL dereference in probe
    ata: ahci_xgene: Add AHCI Support for 2nd HW version of APM X-Gene SoC AHCI SATA Host controller.
    libahci: Add support to handle HOST_IRQ_STAT as edge trigger latch.
    ...

    Linus Torvalds
     

18 Jun, 2015

1 commit

  • It turned out the irq vector of the msix can be obtained from struct
    msix_entry. This makes the lookup function for msi_desc obsolete.

    This fixes a build error if PCI_MSI is unset:

    drivers/ata/ahci.c: In function ‘msix_get_desc’:
    drivers/ata/ahci.c:1210:2: error: ‘struct pci_dev’ has no member named ‘msi_list’

    Catched by Fengguang's build bot.

    Reported-by: kbuild test robot
    Signed-off-by: Robert Richter
    Signed-off-by: Tejun Heo

    Robert Richter
     

17 Jun, 2015

2 commits

  • This patch adds support for Cavium's ThunderX host controller. The
    controller resides on the SoC and is a AHCI compatible SATA controller
    with one port, compliant with Serial ATA 3.1 and AHCI Revision 1.31.
    There can exists multiple SATA controllers on the SoC.

    The controller depends on MSI-X support since the PCI ECAM controller
    on the SoC does not implement MSI nor lagacy intx interrupt support.
    Thus, during device initialization, if MSI fails MSI-X will be used to
    enable the device's interrupts.

    The controller uses non-standard BAR0 for its register range. The
    already existing device lookup (vendor and device id) that is already
    implemented for other host controllers is used to change the PCI BAR.

    Signed-off-by: Robert Richter
    Signed-off-by: Tejun Heo

    Robert Richter
     
  • This patch adds generic MSI-X support for single interrupts to the
    SATA PCI driver. MSI-X support is needed for host controller that only
    have MSI-X support implemented, but no MSI or intx. This patch only
    adds support for single interrupts, multiple per-port MSI-X interrupts
    are not yet implemented.

    The new implementation still initializes MSIs first. Only if that
    fails, the code tries to enable MSI-X. If that fails too, setup is
    continued with intx interrupts.

    To not break other chips by this generic code change, there are the
    following precautions:

    * Interrupt ranges are not enabled at all.

    * Only single interrupt mode is enabled for msix cap devices. Thus,
    only one interrupt will be setup.

    * During the discussion with Tejun we agreed to change the init
    sequence from msix-msi-intx to msi-msix-intx. Thus, if a device
    offers msi and init does not fail, the msix init code will not be
    executed. This is equivalent to current code.

    With this, the code only setups single mode msix as a last resort if
    msi fails. No interrupt range is enabled at all. Only one interrupt
    will be enabled.

    tj: comment edits.

    Changes of the patch series:

    v5:
    * updated patch subject that the patch only implements single IRQ
    * moved Cavium specific code to a separate patch
    * detect Cavium ThunderX device with PCI_CLASS_STORAGE_SATA_AHCI
    instead of vendor/dev id
    * added more comments to the code
    * enable single msix support for all kind of devices (removing strict
    check)
    * rebased onto update libata/for-4.2 with patch 1, 2 applied

    v4:
    * removed implementation of ahci_init_intx()
    * improved patch descriptions
    * rebased onto libata/for-4.2

    v3:
    * store irq number in struct ahci_host_priv
    * change initialization order from msix-msi-intx to msi-msix-intx
    * improve comments in ahci_init_msix()
    * improve error message in ahci_init_msix()
    * do not enable MSI-X if MSI is actively disabled for the device

    v2:
    * determine irq vector from pci_dev->msi_list

    Based on a patch from Sunil Goutham .

    Signed-off-by: Robert Richter
    Signed-off-by: Tejun Heo

    Robert Richter
     

03 Jun, 2015

2 commits

  • Currently, ahci supports only msi and intx. To also support msix the
    handling of the irq number need to be changed. The irq number for msix
    devices is taken from msi_list instead of pci_dev. Thus, the irq
    number of a device needs to be stored in struct ahci_host_priv now.
    This allows the host controller to be activated in a generic way.

    This change is only intended for ahci drivers. For that reason the irq
    number is stored in struct ahci_host_priv used only by ahci drivers.
    Thus, the ABI changes only for ahci_host_activate(), but existing ata
    drivers (about 50) are unaffected and keep unchanged. All users of
    ahci_host_activate() have been updated.

    While touching drivers/ata/libahci.c, doing a small code cleanup in
    ahci_port_start().

    Signed-off-by: Robert Richter
    Signed-off-by: Tejun Heo

    Robert Richter
     
  • This patch refactors ahci_init_interrupts() and moves msi code to a
    separate function. Need the split since we add msix initialization in
    a later patch. The initialization for msix will be done after msi but
    before intx.

    Signed-off-by: Robert Richter
    Signed-off-by: Tejun Heo

    Robert Richter
     

10 May, 2015

1 commit

  • Avoton AHCI occasionally sees drive probe timeouts at driver load time.
    When this happens SCR_STATUS indicates device detected, but no D2H FIS
    reception. Reset the internal link state machines by bouncing
    port-enable in the PCS register when this occurs.

    Cc:
    Signed-off-by: Dan Williams
    Signed-off-by: Tejun Heo

    Dan Williams
     

08 Apr, 2015

1 commit

  • Replace occurences of the pci api by appropriate call to the dma api.

    A simplified version of the semantic patch that finds this problem is as
    follows: (http://coccinelle.lip6.fr)

    @deprecated@
    idexpression id;
    position p;
    @@

    (
    pci_dma_supported@p ( id, ...)
    |
    pci_alloc_consistent@p ( id, ...)
    )

    @bad1@
    idexpression id;
    position deprecated.p;
    @@
    ...when != &id->dev
    when != pci_get_drvdata ( id )
    when != pci_enable_device ( id )
    (
    pci_dma_supported@p ( id, ...)
    |
    pci_alloc_consistent@p ( id, ...)
    )

    @depends on !bad1@
    idexpression id;
    expression direction;
    position deprecated.p;
    @@

    (
    - pci_dma_supported@p ( id,
    + dma_supported ( &id->dev,
    ...
    + , GFP_ATOMIC
    )
    |
    - pci_alloc_consistent@p ( id,
    + dma_alloc_coherent ( &id->dev,
    ...
    + , GFP_ATOMIC
    )
    )

    Signed-off-by: Quentin Lambert
    Signed-off-by: Tejun Heo

    Quentin Lambert
     

13 Jan, 2015

1 commit


05 Dec, 2014

1 commit

  • Just like 0x1600 which got blacklisted by 66a7cbc303f4 ("ahci: disable
    MSI instead of NCQ on Samsung pci-e SSDs on macbooks"), 0xa800 chokes
    on NCQ commands if MSI is enabled. Disable MSI.

    Signed-off-by: Tejun Heo
    Reported-by: Dominik Mierzejewski
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=89171
    Cc: stable@vger.kernel.org

    Tejun Heo
     

03 Dec, 2014

1 commit


05 Nov, 2014

1 commit

  • Changes into the AHCI subsystem have introduced a bug by not taking into
    account the force_port_map and mask_port_map parameters when using the
    ahci_pci_save_initial_config function. This commit fixes it by setting
    the internal parameters of the ahci_port_priv structure.

    Fixes: 725c7b570fda

    Reported-and-tested-by: Zlatko Calusic
    Signed-off-by: Antoine Tenart

    Antoine Tenart
     

28 Oct, 2014

2 commits

  • This patch adds the AHCI-mode SATA Device IDs for the Intel Sunrise Point PCH.

    Signed-off-by: James Ralston
    Signed-off-by: Tejun Heo
    Cc: stable@vger.kernel.org

    James Ralston
     
  • Samsung pci-e SSDs on macbooks failed miserably on NCQ commands, so
    67809f85d31e ("ahci: disable NCQ on Samsung pci-e SSDs on macbooks")
    disabled NCQ on them. It turns out that NCQ is fine as long as MSI is
    not used, so let's turn off MSI and leave NCQ on.

    Signed-off-by: Tejun Heo
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=60731
    Tested-by:
    Tested-by: Imre Kaloz
    Cc: stable@vger.kernel.org
    Fixes: 67809f85d31e ("ahci: disable NCQ on Samsung pci-e SSDs on macbooks")

    Tejun Heo
     

10 Oct, 2014

1 commit

  • Pull libata update from Tejun Heo:
    "AHCI is getting per-port irq handling and locks for better
    scalability. The gain is not huge but measureable with multiple high
    iops devices connected to the same host; however, the value of
    threaded IRQ handling seems negligible for AHCI and it likely will
    revert to non-threaded handling soon.

    Another noteworthy change is George Spelvin's "libata: Un-break ATA
    blacklist". During 3.17 devel cycle, the libata blacklist glob
    matching got generalized and rewritten; unfortunately, the patch
    forgot to swap arguments to match the new match function and ended up
    breaking blacklist matching completely. It got noticed only a couple
    days ago so it couldn't make for-3.17-fixes either. :(

    Other than the above two, nothing too interesting - the usual cleanup
    churns and device-specific changes"

    * 'for-3.18' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata: (22 commits)
    pata_serverworks: disable 64-KB DMA transfers on Broadcom OSB4 IDE Controller
    libata: Un-break ATA blacklist
    AHCI: Do not acquire ata_host::lock from single IRQ handler
    AHCI: Optimize single IRQ interrupt processing
    AHCI: Do not read HOST_IRQ_STAT reg in multi-MSI mode
    AHCI: Make few function names more descriptive
    AHCI: Move host activation code into ahci_host_activate()
    AHCI: Move ahci_host_activate() function to libahci.c
    AHCI: Pass SCSI host template as arg to ahci_host_activate()
    ata: pata_imx: Use the SIMPLE_DEV_PM_OPS() macro
    AHCI: Cleanup checking of multiple MSIs/SLM modes
    libata-sff: Fix controllers with no ctl port
    ahci_xgene: Fix the error print invalid resource for APM X-Gene SoC AHCI SATA Host Controller driver.
    libata: change ata__printk routines to return void
    ata: qcom: Add device tree bindings information
    ahci-platform: Bump max number of clocks to 5
    ahci: ahci_p5wdh_workaround - constify DMI table
    libahci_platform: Staticize ahci_platform_able_phys()
    pata_platform: Remove useless irq_flags field
    pata_of_platform: Remove "electra-ide" quirk
    ...

    Linus Torvalds
     

06 Oct, 2014

3 commits


28 Sep, 2014

1 commit


06 Sep, 2014

1 commit


01 Sep, 2014

1 commit

  • After enabled the PM feature that supporting async noirq(76569faa62
    (PM / sleep: Asynchronous threads for resume_noirq)),
    Jay hit the system resuming issue, that one of the JMicron controller
    can not be powered up.

    His device tree is like below:
    +-1c.4-[02]--+-00.0 JMicron Technology Corp. JMB363 SATA/IDE Controller
    | \-00.1 JMicron Technology Corp. JMB363 SATA/IDE Controller

    After investigation, we found the the Micron chip 363 included
    one SATA controller(0000:02:00.0) and one PATA controller(0000:02:00.1),
    these two controllers do not have parent-children relationship,
    but the PATA controller only can be powered on after the SATA controller
    has finished the powering on.

    If we enabled the async noirq(), then the below error is hit during noirq
    phase:
    pata_jmicron 0000:02:00.1: Refused to change power state, currently in D3

    Here for JMicron chip 363/361, we need forcedly to disable the async method.

    Bug detail: https://bugzilla.kernel.org/show_bug.cgi?id=81551

    Reported-by: Jay
    Signed-off-by: Chuansheng Liu
    Acked-by: Rafael J. Wysocki
    Signed-off-by: Tejun Heo

    Chuansheng Liu