]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
Merge branch 'for-4.2' of git://git.kernel.org/pub/scm/linux/kernel/git/tj/libata
authorLinus Torvalds <torvalds@linux-foundation.org>
Thu, 25 Jun 2015 23:49:21 +0000 (16:49 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Thu, 25 Jun 2015 23:49:21 +0000 (16:49 -0700)
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.
  ...

1  2 
Documentation/kernel-parameters.txt
drivers/ata/Kconfig
drivers/ata/ahci.c
drivers/ata/ahci_mvebu.c
drivers/ata/libahci.c
drivers/ata/libata-core.c
drivers/ata/libata-eh.c
include/linux/libata.h

index fd66d220c115f11fba4ab26a5a2898eb687a2bb9,14a4be114cdcc286ab6df2e3b95f1d1a81826740..c84d078a6376159f4d28ea71b2550a20abdb8c63
@@@ -165,7 -165,7 +165,7 @@@ multipliers 'Kilo', 'Mega', and 'Giga'
  bytes respectively. Such letter suffixes can also be entirely omitted.
  
  
 -      acpi=           [HW,ACPI,X86]
 +      acpi=           [HW,ACPI,X86,ARM64]
                        Advanced Configuration and Power Interface
                        Format: { force | off | strict | noirq | rsdt }
                        force -- enable ACPI if default was off
                                strictly ACPI specification compliant.
                        rsdt -- prefer RSDT over (default) XSDT
                        copy_dsdt -- copy DSDT to memory
 +                      For ARM64, ONLY "acpi=off" or "acpi=force" are available
  
                        See also Documentation/power/runtime_pm.txt, pci=noacpi
  
 -      acpi_rsdp=      [ACPI,EFI,KEXEC]
 -                      Pass the RSDP address to the kernel, mostly used
 -                      on machines running EFI runtime service to boot the
 -                      second kernel for kdump.
 -
        acpi_apic_instance=     [ACPI, IOAPIC]
                        Format: <int>
                        2: use 2nd APIC table, if available
                        (e.g. thinkpad_acpi, sony_acpi, etc.) instead
                        of the ACPI video.ko driver.
  
 +      acpica_no_return_repair [HW, ACPI]
 +                      Disable AML predefined validation mechanism
 +                      This mechanism can repair the evaluation result to make
 +                      the return objects more ACPI specification compliant.
 +                      This option is useful for developers to identify the
 +                      root cause of an AML interpreter issue when the issue
 +                      has something to do with the repair mechanism.
 +
        acpi.debug_layer=       [HW,ACPI,ACPI_DEBUG]
        acpi.debug_level=       [HW,ACPI,ACPI_DEBUG]
                        Format: <int>
                        unusable.  The "log_buf_len" parameter may be useful
                        if you need to capture more output.
  
 +      acpi_enforce_resources= [ACPI]
 +                      { strict | lax | no }
 +                      Check for resource conflicts between native drivers
 +                      and ACPI OperationRegions (SystemIO and SystemMemory
 +                      only). IO ports and memory declared in ACPI might be
 +                      used by the ACPI subsystem in arbitrary AML code and
 +                      can interfere with legacy drivers.
 +                      strict (default): access to resources claimed by ACPI
 +                      is denied; legacy drivers trying to access reserved
 +                      resources will fail to bind to device using them.
 +                      lax: access to resources claimed by ACPI is allowed;
 +                      legacy drivers trying to access reserved resources
 +                      will bind successfully but a warning message is logged.
 +                      no: ACPI OperationRegions are not marked as reserved,
 +                      no further checks are performed.
 +
        acpi_force_table_verification   [HW,ACPI]
                        Enable table checksum verification during early stage.
                        By default, this is disabled due to x86 early mapping
                        This feature is enabled by default.
                        This option allows to turn off the feature.
  
 +      acpi_no_memhotplug [ACPI] Disable memory hotplug.  Useful for kdump
 +                         kernels.
 +
        acpi_no_static_ssdt     [HW,ACPI]
                        Disable installation of static SSDTs at early boot time
                        By default, SSDTs contained in the RSDT/XSDT will be
                        dynamic table installation which will install SSDT
                        tables to /sys/firmware/acpi/tables/dynamic.
  
 -      acpica_no_return_repair [HW, ACPI]
 -                      Disable AML predefined validation mechanism
 -                      This mechanism can repair the evaluation result to make
 -                      the return objects more ACPI specification compliant.
 -                      This option is useful for developers to identify the
 -                      root cause of an AML interpreter issue when the issue
 -                      has something to do with the repair mechanism.
 +      acpi_rsdp=      [ACPI,EFI,KEXEC]
 +                      Pass the RSDP address to the kernel, mostly used
 +                      on machines running EFI runtime service to boot the
 +                      second kernel for kdump.
  
        acpi_os_name=   [HW,ACPI] Tell ACPI BIOS the name of the OS
                        Format: To spoof as Windows 98: ="Microsoft Windows"
                        Use timer override. For some broken Nvidia NF5 boards
                        that require a timer override, but don't have HPET
  
 -      acpi_enforce_resources= [ACPI]
 -                      { strict | lax | no }
 -                      Check for resource conflicts between native drivers
 -                      and ACPI OperationRegions (SystemIO and SystemMemory
 -                      only). IO ports and memory declared in ACPI might be
 -                      used by the ACPI subsystem in arbitrary AML code and
 -                      can interfere with legacy drivers.
 -                      strict (default): access to resources claimed by ACPI
 -                      is denied; legacy drivers trying to access reserved
 -                      resources will fail to bind to device using them.
 -                      lax: access to resources claimed by ACPI is allowed;
 -                      legacy drivers trying to access reserved resources
 -                      will bind successfully but a warning message is logged.
 -                      no: ACPI OperationRegions are not marked as reserved,
 -                      no further checks are performed.
 -
 -      acpi_no_memhotplug [ACPI] Disable memory hotplug.  Useful for kdump
 -                         kernels.
 -
        add_efi_memmap  [EFI; X86] Include EFI memory map in
                        kernel's map of available physical RAM.
  
  
                uart[8250],io,<addr>[,options]
                uart[8250],mmio,<addr>[,options]
 +              uart[8250],mmio32,<addr>[,options]
 +              uart[8250],0x<addr>[,options]
                        Start an early, polled-mode console on the 8250/16550
                        UART at the specified I/O port or MMIO address,
 -                      switching to the matching ttyS device later.  The
 -                      options are the same as for ttyS, above.
 +                      switching to the matching ttyS device later.
 +                      MMIO inter-register address stride is either 8-bit
 +                      (mmio) or 32-bit (mmio32).
 +                      If none of [io|mmio|mmio32], <addr> is assumed to be
 +                      equivalent to 'mmio'. 'options' are specified in the
 +                      same format described for ttyS above; if unspecified,
 +                      the h/w is not re-initialized.
 +
                hvc<n>  Use the hypervisor console device <n>. This is for
                        both Xen and PowerPC hypervisors.
  
        cpuidle.off=1   [CPU_IDLE]
                        disable the cpuidle sub-system
  
 +      cpu_init_udelay=N
 +                      [X86] Delay for N microsec between assert and de-assert
 +                      of APIC INIT to start processors.  This delay occurs
 +                      on every CPU online, such as boot, and resume from suspend.
 +                      Default: 10000
 +
        cpcihp_generic= [HW,PCI] Generic port I/O CompactPCI driver
                        Format:
                        <first_slot>,<last_slot>,<port>,<enum_bit>[,<debug>]
                        Enable debug messages at boot time.  See
                        Documentation/dynamic-debug-howto.txt for details.
  
 +      nompx           [X86] Disables Intel Memory Protection Extensions.
 +                      See Documentation/x86/intel_mpx.txt for more
 +                      information about the feature.
 +
 +      eagerfpu=       [X86]
 +                      on      enable eager fpu restore
 +                      off     disable eager fpu restore
 +                      auto    selects the default scheme, which automatically
 +                              enables eagerfpu restore for xsaveopt.
 +
        early_ioremap_debug [KNL]
                        Enable debug messages in early_ioremap support. This
                        is useful for tracking down temporary early mappings
                uart[8250],io,<addr>[,options]
                uart[8250],mmio,<addr>[,options]
                uart[8250],mmio32,<addr>[,options]
 +              uart[8250],0x<addr>[,options]
                        Start an early, polled-mode console on the 8250/16550
                        UART at the specified I/O port or MMIO address.
                        MMIO inter-register address stride is either 8-bit
                        (mmio) or 32-bit (mmio32).
 -                      The options are the same as for ttyS, above.
 +                      If none of [io|mmio|mmio32], <addr> is assumed to be
 +                      equivalent to 'mmio'. 'options' are specified in the
 +                      same format described for "console=ttyS<n>"; if
 +                      unspecified, the h/w is not initialized.
  
                pl011,<addr>
                        Start an early, polled-mode console on a pl011 serial
                        earlyprintk=serial[,0x...[,baudrate]]
                        earlyprintk=ttySn[,baudrate]
                        earlyprintk=dbgp[debugController#]
 +                      earlyprintk=pciserial,bus:device.function[,baudrate]
  
                        earlyprintk is useful when the kernel crashes before
                        the normal console is initialized. It is not enabled by
                        By default, super page will be supported if Intel IOMMU
                        has the capability. With this option, super page will
                        not be supported.
 +              ecs_off [Default Off]
 +                      By default, extended context tables will be supported if
 +                      the hardware advertises that it has support both for the
 +                      extended tables themselves, and also PASID support. With
 +                      this option set, extended tables will not be used even
 +                      on hardware which claims to support them.
  
        intel_idle.max_cstate=  [KNL,HW,ACPI,X86]
                        0       disables intel_idle and fall back on acpi_idle.
  
                        * [no]ncq: Turn on or off NCQ.
  
+                       * [no]ncqtrim: Turn off queued DSM TRIM.
                        * nohrst, nosrst, norst: suppress hard, soft
                            and both resets.
  
                                 or
                                 memmap=0x10000$0x18690000
  
 +      memmap=nn[KMG]!ss[KMG]
 +                      [KNL,X86] Mark specific memory as protected.
 +                      Region of memory to be used, from ss to ss+nn.
 +                      The memory region may be marked as e820 type 12 (0xc)
 +                      and is NVDIMM or ADR memory.
 +
        memory_corruption_check=0/1 [X86]
                        Some BIOSes seem to corrupt the first 64k of
                        memory when doing things like suspend/resume.
                        seconds.  Use this parameter to check at some
                        other rate.  0 disables periodic checking.
  
 -      memtest=        [KNL,X86] Enable memtest
 +      memtest=        [KNL,X86,ARM] Enable memtest
                        Format: <integer>
                        default : 0 <disable>
                        Specifies the number of memtest passes to be
  
        nmi_watchdog=   [KNL,BUGS=X86] Debugging features for SMP kernels
                        Format: [panic,][nopanic,][num]
 -                      Valid num: 0
 +                      Valid num: 0 or 1
                        0 - turn nmi_watchdog off
 +                      1 - turn nmi_watchdog on
                        When panic is specified, panic when an NMI watchdog
                        timeout occurs (or 'nopanic' to override the opposite
                        default).
                        noexec32=off: disable non-executable mappings
                                read implies executable mappings
  
 -      nofpu           [SH] Disable hardware FPU at boot time.
 +      nofpu           [MIPS,SH] Disable hardware FPU at boot time.
  
        nofxsr          [BUGS=X86-32] Disables x86 floating point extended
                        register save and restore. The kernel will only save
                        legacy floating-point registers on task switch.
  
 +      nohugeiomap     [KNL,x86] Disable kernel huge I/O mappings.
 +
        noxsave         [BUGS=X86] Disables x86 extended register state save
                        and restore using xsave. The kernel will fallback to
                        enabling legacy floating-point and sse state.
                        parameter, xsave area per process might occupy more
                        memory on xsaves enabled systems.
  
 -      eagerfpu=       [X86]
 -                      on      enable eager fpu restore
 -                      off     disable eager fpu restore
 -                      auto    selects the default scheme, which automatically
 -                              enables eagerfpu restore for xsaveopt.
 -
        nohlt           [BUGS=ARM,SH] Tells the kernel that the sleep(SH) or
                        wfi(ARM) instruction doesn't work correctly and not to
                        use it. This is also useful when using JTAG debugger.
  
        nomca           [IA-64] Disable machine check abort handling
  
 -      nomce           [X86-32] Machine Check Exception
 +      nomce           [X86-32] Disable Machine Check Exception
  
        nomfgpt         [X86-32] Disable Multi-Function General Purpose
                        Timer usage (for AMD Geode machines).
  
        nousb           [USB] Disable the USB subsystem
  
 -      nowatchdog      [KNL] Disable the lockup detector (NMI watchdog).
 +      nowatchdog      [KNL] Disable both lockup detectors, i.e.
 +                        soft-lockup and NMI watchdog (hard-lockup).
  
        nowb            [ARM]
  
                        Set maximum number of finished RCU callbacks to
                        process in one batch.
  
 +      rcutree.dump_tree=      [KNL]
 +                      Dump the structure of the rcu_node combining tree
 +                      out at early boot.  This is used for diagnostic
 +                      purposes, to verify correct tree setup.
 +
 +      rcutree.gp_cleanup_delay=       [KNL]
 +                      Set the number of jiffies to delay each step of
 +                      RCU grace-period cleanup.  This only has effect
 +                      when CONFIG_RCU_TORTURE_TEST_SLOW_CLEANUP is set.
 +
 +      rcutree.gp_init_delay=  [KNL]
 +                      Set the number of jiffies to delay each step of
 +                      RCU grace-period initialization.  This only has
 +                      effect when CONFIG_RCU_TORTURE_TEST_SLOW_INIT
 +                      is set.
 +
 +      rcutree.gp_preinit_delay=       [KNL]
 +                      Set the number of jiffies to delay each step of
 +                      RCU grace-period pre-initialization, that is,
 +                      the propagation of recent CPU-hotplug changes up
 +                      the rcu_node combining tree.  This only has effect
 +                      when CONFIG_RCU_TORTURE_TEST_SLOW_PREINIT is set.
 +
 +      rcutree.rcu_fanout_exact= [KNL]
 +                      Disable autobalancing of the rcu_node combining
 +                      tree.  This is used by rcutorture, and might
 +                      possibly be useful for architectures having high
 +                      cache-to-cache transfer latencies.
 +
        rcutree.rcu_fanout_leaf= [KNL]
                        Increase the number of CPUs assigned to each
                        leaf rcu_node structure.  Useful for very large
                        value is one, and maximum value is HZ.
  
        rcutree.kthread_prio=    [KNL,BOOT]
 -                      Set the SCHED_FIFO priority of the RCU
 -                      per-CPU kthreads (rcuc/N). This value is also
 -                      used for the priority of the RCU boost threads
 -                      (rcub/N). Valid values are 1-99 and the default
 -                      is 1 (the least-favored priority).
 +                      Set the SCHED_FIFO priority of the RCU per-CPU
 +                      kthreads (rcuc/N). This value is also used for
 +                      the priority of the RCU boost threads (rcub/N)
 +                      and for the RCU grace-period kthreads (rcu_bh,
 +                      rcu_preempt, and rcu_sched). If RCU_BOOST is
 +                      set, valid values are 1-99 and the default is 1
 +                      (the least-favored priority).  Otherwise, when
 +                      RCU_BOOST is not set, valid values are 0-99 and
 +                      the default is zero (non-realtime operation).
  
        rcutree.rcu_nocb_leader_stride= [KNL]
                        Set the number of NOCB kthread groups, which
                        test, hence the "fake".
  
        rcutorture.nreaders= [KNL]
 -                      Set number of RCU readers.
 +                      Set number of RCU readers.  The value -1 selects
 +                      N-1, where N is the number of CPUs.  A value
 +                      "n" less than -1 selects N-n-2, where N is again
 +                      the number of CPUs.  For example, -2 selects N
 +                      (the number of CPUs), -3 selects N+1, and so on.
  
        rcutorture.object_debug= [KNL]
                        Enable debug-object double-call_rcu() testing.
                        improve throughput, but will also increase the
                        amount of memory reserved for use by the client.
  
 +      suspend.pm_test_delay=
 +                      [SUSPEND]
 +                      Sets the number of seconds to remain in a suspend test
 +                      mode before resuming the system (see
 +                      /sys/power/pm_test). Only available when CONFIG_PM_DEBUG
 +                      is set. Default value is 5.
 +
        swapaccount=[0|1]
                        [KNL] Enable accounting of swap in memory resource
                        controller if no parameter or 1 is given or disable
                                        READ_CAPACITY_16 command);
                                f = NO_REPORT_OPCODES (don't use report opcodes
                                        command, uas only);
 +                              g = MAX_SECTORS_240 (don't transfer more than
 +                                      240 sectors at a time, uas only);
                                h = CAPACITY_HEURISTICS (decrease the
                                        reported device capacity by one
                                        sector if the number is odd);
diff --combined drivers/ata/Kconfig
index 9dca4b995be0792b6c4f1920b9786cb6517a2b5f,a987d6f86f6ed6173b972bb8f96c2ad0fb4b1b71..b11470a7bd8f870912b44fce0bdff1eba8ebd7c7
@@@ -98,6 -98,15 +98,15 @@@ config SATA_AHCI_PLATFOR
  
          If unsure, say N.
  
+ config AHCI_BRCMSTB
+       tristate "Broadcom STB AHCI SATA support"
+       depends on ARCH_BRCMSTB
+       help
+         This option enables support for the AHCI SATA3 controller found on
+         STB SoC's.
+         If unsure, say N.
  config AHCI_DA850
        tristate "DaVinci DA850 AHCI SATA support"
        depends on ARCH_DAVINCI_DA850
@@@ -124,6 -133,15 +133,15 @@@ config AHCI_IM
  
          If unsure, say N.
  
+ config AHCI_CEVA
+       tristate "CEVA AHCI SATA support"
+       depends on OF
+       help
+         This option enables support for the CEVA AHCI SATA.
+         It can be found on the Xilinx Zynq UltraScale+ MPSoC.
+         If unsure, say N.
  config AHCI_MVEBU
        tristate "Marvell EBU AHCI SATA support"
        depends on ARCH_MVEBU
@@@ -270,7 -288,6 +288,7 @@@ config ATA_PII
  config SATA_DWC
        tristate "DesignWare Cores SATA support"
        depends on 460EX
 +      select DW_DMAC
        help
          This option enables support for the on-chip SATA controller of the
          AppliedMicro processor 460EX.
diff --combined drivers/ata/ahci.c
index 65ee94454bbd2c92f1879386b19a346a5632794f,c478a40e32c69657d83e17ad3679abd27ac590c8..7e62751abfacce2aaca99c7b08834f2464b46498
@@@ -42,6 -42,7 +42,7 @@@
  #include <linux/device.h>
  #include <linux/dmi.h>
  #include <linux/gfp.h>
+ #include <linux/msi.h>
  #include <scsi/scsi_host.h>
  #include <scsi/scsi_cmnd.h>
  #include <linux/libata.h>
@@@ -52,6 -53,7 +53,7 @@@
  
  enum {
        AHCI_PCI_BAR_STA2X11    = 0,
+       AHCI_PCI_BAR_CAVIUM     = 0,
        AHCI_PCI_BAR_ENMOTUS    = 2,
        AHCI_PCI_BAR_STANDARD   = 5,
  };
@@@ -66,7 -68,6 +68,7 @@@ enum board_ids 
        board_ahci_yes_fbs,
  
        /* board IDs for specific chipsets in alphabetical order */
 +      board_ahci_avn,
        board_ahci_mcp65,
        board_ahci_mcp77,
        board_ahci_mcp89,
@@@ -85,8 -86,6 +87,8 @@@
  static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
  static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
                                 unsigned long deadline);
 +static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
 +                            unsigned long deadline);
  static void ahci_mcp89_apple_enable(struct pci_dev *pdev);
  static bool is_mcp89_apple(struct pci_dev *pdev);
  static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
@@@ -110,11 -109,6 +112,11 @@@ static struct ata_port_operations ahci_
        .hardreset              = ahci_p5wdh_hardreset,
  };
  
 +static struct ata_port_operations ahci_avn_ops = {
 +      .inherits               = &ahci_ops,
 +      .hardreset              = ahci_avn_hardreset,
 +};
 +
  static const struct ata_port_info ahci_port_info[] = {
        /* by features */
        [board_ahci] = {
                .port_ops       = &ahci_ops,
        },
        /* by chipsets */
 +      [board_ahci_avn] = {
 +              .flags          = AHCI_FLAG_COMMON,
 +              .pio_mask       = ATA_PIO4,
 +              .udma_mask      = ATA_UDMA6,
 +              .port_ops       = &ahci_avn_ops,
 +      },
        [board_ahci_mcp65] = {
                AHCI_HFLAGS     (AHCI_HFLAG_NO_FPDMA_AA | AHCI_HFLAG_NO_PMP |
                                 AHCI_HFLAG_YES_NCQ),
@@@ -304,14 -292,14 +306,14 @@@ static const struct pci_device_id ahci_
        { PCI_VDEVICE(INTEL, 0x1f27), board_ahci }, /* Avoton RAID */
        { PCI_VDEVICE(INTEL, 0x1f2e), board_ahci }, /* Avoton RAID */
        { PCI_VDEVICE(INTEL, 0x1f2f), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f32), board_ahci }, /* Avoton AHCI */
 -      { PCI_VDEVICE(INTEL, 0x1f33), board_ahci }, /* Avoton AHCI */
 -      { PCI_VDEVICE(INTEL, 0x1f34), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f35), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f36), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f37), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci }, /* Avoton RAID */
 -      { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f32), board_ahci_avn }, /* Avoton AHCI */
 +      { PCI_VDEVICE(INTEL, 0x1f33), board_ahci_avn }, /* Avoton AHCI */
 +      { PCI_VDEVICE(INTEL, 0x1f34), board_ahci_avn }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f35), board_ahci_avn }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f36), board_ahci_avn }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f37), board_ahci_avn }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f3e), board_ahci_avn }, /* Avoton RAID */
 +      { PCI_VDEVICE(INTEL, 0x1f3f), board_ahci_avn }, /* Avoton RAID */
        { PCI_VDEVICE(INTEL, 0x2823), board_ahci }, /* Wellsburg RAID */
        { PCI_VDEVICE(INTEL, 0x2827), board_ahci }, /* Wellsburg RAID */
        { PCI_VDEVICE(INTEL, 0x8d02), board_ahci }, /* Wellsburg AHCI */
@@@ -684,79 -672,6 +686,79 @@@ static int ahci_p5wdh_hardreset(struct 
        return rc;
  }
  
 +/*
 + * ahci_avn_hardreset - attempt more aggressive recovery of Avoton ports.
 + *
 + * It has been observed with some SSDs that the timing of events in the
 + * link synchronization phase can leave the port in a state that can not
 + * be recovered by a SATA-hard-reset alone.  The failing signature is
 + * SStatus.DET stuck at 1 ("Device presence detected but Phy
 + * communication not established").  It was found that unloading and
 + * reloading the driver when this problem occurs allows the drive
 + * connection to be recovered (DET advanced to 0x3).  The critical
 + * component of reloading the driver is that the port state machines are
 + * reset by bouncing "port enable" in the AHCI PCS configuration
 + * register.  So, reproduce that effect by bouncing a port whenever we
 + * see DET==1 after a reset.
 + */
 +static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
 +                            unsigned long deadline)
 +{
 +      const unsigned long *timing = sata_ehc_deb_timing(&link->eh_context);
 +      struct ata_port *ap = link->ap;
 +      struct ahci_port_priv *pp = ap->private_data;
 +      struct ahci_host_priv *hpriv = ap->host->private_data;
 +      u8 *d2h_fis = pp->rx_fis + RX_FIS_D2H_REG;
 +      unsigned long tmo = deadline - jiffies;
 +      struct ata_taskfile tf;
 +      bool online;
 +      int rc, i;
 +
 +      DPRINTK("ENTER\n");
 +
 +      ahci_stop_engine(ap);
 +
 +      for (i = 0; i < 2; i++) {
 +              u16 val;
 +              u32 sstatus;
 +              int port = ap->port_no;
 +              struct ata_host *host = ap->host;
 +              struct pci_dev *pdev = to_pci_dev(host->dev);
 +
 +              /* clear D2H reception area to properly wait for D2H FIS */
 +              ata_tf_init(link->device, &tf);
 +              tf.command = ATA_BUSY;
 +              ata_tf_to_fis(&tf, 0, 0, d2h_fis);
 +
 +              rc = sata_link_hardreset(link, timing, deadline, &online,
 +                              ahci_check_ready);
 +
 +              if (sata_scr_read(link, SCR_STATUS, &sstatus) != 0 ||
 +                              (sstatus & 0xf) != 1)
 +                      break;
 +
 +              ata_link_printk(link, KERN_INFO, "avn bounce port%d\n",
 +                              port);
 +
 +              pci_read_config_word(pdev, 0x92, &val);
 +              val &= ~(1 << port);
 +              pci_write_config_word(pdev, 0x92, val);
 +              ata_msleep(ap, 1000);
 +              val |= 1 << port;
 +              pci_write_config_word(pdev, 0x92, val);
 +              deadline += tmo;
 +      }
 +
 +      hpriv->start_engine(ap);
 +
 +      if (online)
 +              *class = ahci_dev_classify(ap);
 +
 +      DPRINTK("EXIT, rc=%d, class=%u\n", rc, *class);
 +      return rc;
 +}
 +
 +
  #ifdef CONFIG_PM
  static int ahci_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)
  {
@@@ -1288,17 -1203,60 +1290,60 @@@ static inline void ahci_gtf_filter_work
  {}
  #endif
  
- static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
-                               struct ahci_host_priv *hpriv)
+ /*
+  * ahci_init_msix() only implements single MSI-X support, not multiple
+  * MSI-X per-port interrupts. This is needed for host controllers that only
+  * have MSI-X support implemented, but no MSI or intx.
+  */
+ static int ahci_init_msix(struct pci_dev *pdev, unsigned int n_ports,
+                         struct ahci_host_priv *hpriv)
  {
        int rc, nvec;
+       struct msix_entry entry = {};
  
+       /* Do not init MSI-X if MSI is disabled for the device */
        if (hpriv->flags & AHCI_HFLAG_NO_MSI)
-               goto intx;
+               return -ENODEV;
+       nvec = pci_msix_vec_count(pdev);
+       if (nvec < 0)
+               return nvec;
+       if (!nvec) {
+               rc = -ENODEV;
+               goto fail;
+       }
+       /*
+        * There can be more than one vector (e.g. for error detection or
+        * hdd hotplug). Only the first vector (entry.entry = 0) is used.
+        */
+       rc = pci_enable_msix_exact(pdev, &entry, 1);
+       if (rc < 0)
+               goto fail;
+       hpriv->irq = entry.vector;
+       return 1;
+ fail:
+       dev_err(&pdev->dev,
+               "failed to enable MSI-X with error %d, # of vectors: %d\n",
+               rc, nvec);
+       return rc;
+ }
+ static int ahci_init_msi(struct pci_dev *pdev, unsigned int n_ports,
+                       struct ahci_host_priv *hpriv)
+ {
+       int rc, nvec;
+       if (hpriv->flags & AHCI_HFLAG_NO_MSI)
+               return -ENODEV;
  
        nvec = pci_msi_vec_count(pdev);
        if (nvec < 0)
-               goto intx;
+               return nvec;
  
        /*
         * If number of MSIs is less than number of ports then Sharing Last
        rc = pci_enable_msi_exact(pdev, nvec);
        if (rc == -ENOSPC)
                goto single_msi;
-       else if (rc < 0)
-               goto intx;
+       if (rc < 0)
+               return rc;
  
        /* fallback to single MSI mode if the controller enforced MRSM mode */
        if (readl(hpriv->mmio + HOST_CTL) & HOST_MRSM) {
        if (nvec > 1)
                hpriv->flags |= AHCI_HFLAG_MULTI_MSI;
  
-       return nvec;
+       goto out;
  
  single_msi:
-       if (pci_enable_msi(pdev))
-               goto intx;
-       return 1;
+       nvec = 1;
+       rc = pci_enable_msi(pdev);
+       if (rc < 0)
+               return rc;
+ out:
+       hpriv->irq = pdev->irq;
+       return nvec;
+ }
+ static int ahci_init_interrupts(struct pci_dev *pdev, unsigned int n_ports,
+                               struct ahci_host_priv *hpriv)
+ {
+       int nvec;
+       nvec = ahci_init_msi(pdev, n_ports, hpriv);
+       if (nvec >= 0)
+               return nvec;
+       /*
+        * Currently, MSI-X support only implements single IRQ mode and
+        * exists for controllers which can't do other types of IRQ. Only
+        * set it up if MSI fails.
+        */
+       nvec = ahci_init_msix(pdev, n_ports, hpriv);
+       if (nvec >= 0)
+               return nvec;
  
- intx:
+       /* lagacy intx interrupts */
        pci_intx(pdev, 1);
+       hpriv->irq = pdev->irq;
        return 0;
  }
  
@@@ -1371,11 -1356,13 +1443,13 @@@ static int ahci_init_one(struct pci_de
                dev_info(&pdev->dev,
                         "PDC42819 can only drive SATA devices with this driver\n");
  
-       /* Both Connext and Enmotus devices use non-standard BARs */
+       /* Some devices use non-standard BARs */
        if (pdev->vendor == PCI_VENDOR_ID_STMICRO && pdev->device == 0xCC06)
                ahci_pci_bar = AHCI_PCI_BAR_STA2X11;
        else if (pdev->vendor == 0x1c44 && pdev->device == 0x8000)
                ahci_pci_bar = AHCI_PCI_BAR_ENMOTUS;
+       else if (pdev->vendor == 0x177d && pdev->device == 0xa01c)
+               ahci_pci_bar = AHCI_PCI_BAR_CAVIUM;
  
        /*
         * The JMicron chip 361/363 contains one SATA controller and one
         */
        n_ports = max(ahci_nr_ports(hpriv->cap), fls(hpriv->port_map));
  
-       ahci_init_interrupts(pdev, n_ports, hpriv);
        host = ata_host_alloc_pinfo(&pdev->dev, ppi, n_ports);
        if (!host)
                return -ENOMEM;
        host->private_data = hpriv;
  
+       ahci_init_interrupts(pdev, n_ports, hpriv);
        if (!(hpriv->cap & HOST_CAP_SSS) || ahci_ignore_sss)
                host->flags |= ATA_HOST_PARALLEL_SCAN;
        else
  
        pci_set_master(pdev);
  
-       return ahci_host_activate(host, pdev->irq, &ahci_sht);
+       return ahci_host_activate(host, &ahci_sht);
  }
  
  module_pci_driver(ahci_pci_driver);
diff --combined drivers/ata/ahci_mvebu.c
index 5928d0746a270e7b6b2ee12a022b19ed731f03fe,8cbbedebadbbd3fabd36aad6be63a3551c39d9cf..8490d37aee2a466809c2634e51e8b96386e2eecb
@@@ -45,7 -45,7 +45,7 @@@ static void ahci_mvebu_mbus_config(stru
                writel((cs->mbus_attr << 8) |
                       (dram->mbus_dram_target_id << 4) | 1,
                       hpriv->mmio + AHCI_WINDOW_CTRL(i));
 -              writel(cs->base, hpriv->mmio + AHCI_WINDOW_BASE(i));
 +              writel(cs->base >> 16, hpriv->mmio + AHCI_WINDOW_BASE(i));
                writel(((cs->size - 1) & 0xffff0000),
                       hpriv->mmio + AHCI_WINDOW_SIZE(i));
        }
@@@ -62,6 -62,26 +62,26 @@@ static void ahci_mvebu_regret_option(st
        writel(0x80, hpriv->mmio + AHCI_VENDOR_SPECIFIC_0_DATA);
  }
  
+ static int ahci_mvebu_suspend(struct platform_device *pdev, pm_message_t state)
+ {
+       return ahci_platform_suspend_host(&pdev->dev);
+ }
+ static int ahci_mvebu_resume(struct platform_device *pdev)
+ {
+       struct ata_host *host = platform_get_drvdata(pdev);
+       struct ahci_host_priv *hpriv = host->private_data;
+       const struct mbus_dram_target_info *dram;
+       dram = mv_mbus_dram_info();
+       if (dram)
+               ahci_mvebu_mbus_config(hpriv, dram);
+       ahci_mvebu_regret_option(hpriv);
+       return ahci_platform_resume_host(&pdev->dev);
+ }
  static const struct ata_port_info ahci_mvebu_port_info = {
        .flags     = AHCI_FLAG_COMMON,
        .pio_mask  = ATA_PIO4,
@@@ -120,6 -140,8 +140,8 @@@ MODULE_DEVICE_TABLE(of, ahci_mvebu_of_m
  static struct platform_driver ahci_mvebu_driver = {
        .probe = ahci_mvebu_probe,
        .remove = ata_platform_remove_one,
+       .suspend = ahci_mvebu_suspend,
+       .resume = ahci_mvebu_resume,
        .driver = {
                .name = DRV_NAME,
                .of_match_table = ahci_mvebu_of_match,
diff --combined drivers/ata/libahci.c
index 287c4ba0219f7ced8c76af999dd1eeb3e5ed2639,1c99402a1017a3d6209746b6c2059525fa672262..d256a66158be838bb7b312dcda96f6ecad97e332
@@@ -1707,7 -1707,8 +1707,7 @@@ static void ahci_handle_port_interrupt(
        if (unlikely(resetting))
                status &= ~PORT_IRQ_BAD_PMP;
  
 -      /* if LPM is enabled, PHYRDY doesn't mean anything */
 -      if (ap->link.lpm_policy > ATA_LPM_MAX_POWER) {
 +      if (sata_lpm_ignore_phy_events(&ap->link)) {
                status &= ~PORT_IRQ_PHYRDY;
                ahci_scr_write(&ap->link, SCR_ERROR, SERR_PHYRDY_CHG);
        }
@@@ -1825,11 -1826,38 +1825,38 @@@ static irqreturn_t ahci_multi_irqs_intr
        return IRQ_WAKE_THREAD;
  }
  
- static irqreturn_t ahci_single_irq_intr(int irq, void *dev_instance)
+ static u32 ahci_handle_port_intr(struct ata_host *host, u32 irq_masked)
+ {
+       unsigned int i, handled = 0;
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap;
+               if (!(irq_masked & (1 << i)))
+                       continue;
+               ap = host->ports[i];
+               if (ap) {
+                       ahci_port_intr(ap);
+                       VPRINTK("port %u\n", i);
+               } else {
+                       VPRINTK("port %u (no irq)\n", i);
+                       if (ata_ratelimit())
+                               dev_warn(host->dev,
+                                        "interrupt on disabled port %u\n", i);
+               }
+               handled = 1;
+       }
+       return handled;
+ }
+ static irqreturn_t ahci_single_edge_irq_intr(int irq, void *dev_instance)
  {
        struct ata_host *host = dev_instance;
        struct ahci_host_priv *hpriv;
-       unsigned int i, handled = 0;
+       unsigned int rc = 0;
        void __iomem *mmio;
        u32 irq_stat, irq_masked;
  
  
        spin_lock(&host->lock);
  
-       for (i = 0; i < host->n_ports; i++) {
-               struct ata_port *ap;
+       /*
+        * HOST_IRQ_STAT behaves as edge triggered latch meaning that
+        * it should be cleared before all the port events are cleared.
+        */
+       writel(irq_stat, mmio + HOST_IRQ_STAT);
  
-               if (!(irq_masked & (1 << i)))
-                       continue;
+       rc = ahci_handle_port_intr(host, irq_masked);
  
-               ap = host->ports[i];
-               if (ap) {
-                       ahci_port_intr(ap);
-                       VPRINTK("port %u\n", i);
-               } else {
-                       VPRINTK("port %u (no irq)\n", i);
-                       if (ata_ratelimit())
-                               dev_warn(host->dev,
-                                        "interrupt on disabled port %u\n", i);
-               }
+       spin_unlock(&host->lock);
  
-               handled = 1;
-       }
+       VPRINTK("EXIT\n");
+       return IRQ_RETVAL(rc);
+ }
+ static irqreturn_t ahci_single_level_irq_intr(int irq, void *dev_instance)
+ {
+       struct ata_host *host = dev_instance;
+       struct ahci_host_priv *hpriv;
+       unsigned int rc = 0;
+       void __iomem *mmio;
+       u32 irq_stat, irq_masked;
+       VPRINTK("ENTER\n");
+       hpriv = host->private_data;
+       mmio = hpriv->mmio;
+       /* sigh.  0xffffffff is a valid return from h/w */
+       irq_stat = readl(mmio + HOST_IRQ_STAT);
+       if (!irq_stat)
+               return IRQ_NONE;
+       irq_masked = irq_stat & hpriv->port_map;
+       spin_lock(&host->lock);
+       rc = ahci_handle_port_intr(host, irq_masked);
  
        /* HOST_IRQ_STAT behaves as level triggered latch meaning that
         * it should be cleared after all the port events are cleared;
  
        VPRINTK("EXIT\n");
  
-       return IRQ_RETVAL(handled);
+       return IRQ_RETVAL(rc);
  }
  
  unsigned int ahci_qc_issue(struct ata_queued_cmd *qc)
@@@ -2297,7 -2344,7 +2343,7 @@@ static int ahci_port_start(struct ata_p
        /*
         * Switch to per-port locking in case each port has its own MSI vector.
         */
-       if ((hpriv->flags & AHCI_HFLAG_MULTI_MSI)) {
+       if (hpriv->flags & AHCI_HFLAG_MULTI_MSI) {
                spin_lock_init(&pp->lock);
                ap->lock = &pp->lock;
        }
@@@ -2425,7 -2472,10 +2471,10 @@@ static int ahci_host_activate_multi_irq
        rc = ata_host_start(host);
        if (rc)
                return rc;
+       /*
+        * Requests IRQs according to AHCI-1.1 when multiple MSIs were
+        * allocated. That is one MSI per port, starting from @irq.
+        */
        for (i = 0; i < host->n_ports; i++) {
                struct ahci_port_priv *pp = host->ports[i]->private_data;
  
@@@ -2464,29 -2514,27 +2513,27 @@@ out_free_irqs
  /**
   *    ahci_host_activate - start AHCI host, request IRQs and register it
   *    @host: target ATA host
-  *    @irq: base IRQ number to request
   *    @sht: scsi_host_template to use when registering the host
   *
-  *    Similar to ata_host_activate, but requests IRQs according to AHCI-1.1
-  *    when multiple MSIs were allocated. That is one MSI per port, starting
-  *    from @irq.
-  *
   *    LOCKING:
   *    Inherited from calling layer (may sleep).
   *
   *    RETURNS:
   *    0 on success, -errno otherwise.
   */
- int ahci_host_activate(struct ata_host *host, int irq,
-                      struct scsi_host_template *sht)
+ int ahci_host_activate(struct ata_host *host, struct scsi_host_template *sht)
  {
        struct ahci_host_priv *hpriv = host->private_data;
+       int irq = hpriv->irq;
        int rc;
  
        if (hpriv->flags & AHCI_HFLAG_MULTI_MSI)
                rc = ahci_host_activate_multi_irqs(host, irq, sht);
+       else if (hpriv->flags & AHCI_HFLAG_EDGE_IRQ)
+               rc = ata_host_activate(host, irq, ahci_single_edge_irq_intr,
+                                      IRQF_SHARED, sht);
        else
-               rc = ata_host_activate(host, irq, ahci_single_irq_intr,
+               rc = ata_host_activate(host, irq, ahci_single_level_irq_intr,
                                       IRQF_SHARED, sht);
        return rc;
  }
index 577849c6611ac5efa2c948c7b274dc894a19890d,0ed3cb8c0f36c75bf2cf860c2913f2c0fb5ec880..e83fc3d0da9c9c60a99a6dec56cc568a97a0a851
@@@ -3654,7 -3654,7 +3654,7 @@@ int sata_link_resume(struct ata_link *l
   *    EH context.
   *
   *    RETURNS:
-  *    0 on succes, -errno otherwise.
+  *    0 on success, -errno otherwise.
   */
  int sata_link_scr_lpm(struct ata_link *link, enum ata_lpm_policy policy,
                      bool spm_wakeup)
@@@ -4225,7 -4225,7 +4225,7 @@@ static const struct ata_blacklist_entr
        { "PIONEER DVD-RW  DVR-216D",   NULL,   ATA_HORKAGE_NOSETXFER },
  
        /* devices that don't properly handle queued TRIM commands */
-       { "Micron_M500*",               NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
+       { "Micron_M500_*",              NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
                                                ATA_HORKAGE_ZERO_AFTER_TRIM, },
        { "Crucial_CT*M500*",           NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
                                                ATA_HORKAGE_ZERO_AFTER_TRIM, },
                                                ATA_HORKAGE_ZERO_AFTER_TRIM, },
        { "Crucial_CT*MX100*",          "MU01", ATA_HORKAGE_NO_NCQ_TRIM |
                                                ATA_HORKAGE_ZERO_AFTER_TRIM, },
 -      { "Samsung SSD 850 PRO*",       NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
 +      { "Samsung SSD 8*",             NULL,   ATA_HORKAGE_NO_NCQ_TRIM |
                                                ATA_HORKAGE_ZERO_AFTER_TRIM, },
  
        /*
@@@ -6456,12 -6456,7 +6456,7 @@@ static int __init ata_parse_force_one(c
                                      struct ata_force_ent *force_ent,
                                      const char **reason)
  {
-       /* FIXME: Currently, there's no way to tag init const data and
-        * using __initdata causes build failure on some versions of
-        * gcc.  Once __initdataconst is implemented, add const to the
-        * following structure.
-        */
-       static struct ata_force_param force_tbl[] __initdata = {
+       static const struct ata_force_param force_tbl[] __initconst = {
                { "40c",        .cbl            = ATA_CBL_PATA40 },
                { "80c",        .cbl            = ATA_CBL_PATA80 },
                { "short40c",   .cbl            = ATA_CBL_PATA40_SHORT },
                { "3.0Gbps",    .spd_limit      = 2 },
                { "noncq",      .horkage_on     = ATA_HORKAGE_NONCQ },
                { "ncq",        .horkage_off    = ATA_HORKAGE_NONCQ },
+               { "noncqtrim",  .horkage_on     = ATA_HORKAGE_NO_NCQ_TRIM },
+               { "ncqtrim",    .horkage_off    = ATA_HORKAGE_NO_NCQ_TRIM },
                { "dump_id",    .horkage_on     = ATA_HORKAGE_DUMP_ID },
                { "pio0",       .xfer_mask      = 1 << (ATA_SHIFT_PIO + 0) },
                { "pio1",       .xfer_mask      = 1 << (ATA_SHIFT_PIO + 1) },
@@@ -6752,38 -6749,6 +6749,38 @@@ u32 ata_wait_register(struct ata_port *
        return tmp;
  }
  
 +/**
 + *    sata_lpm_ignore_phy_events - test if PHY event should be ignored
 + *    @link: Link receiving the event
 + *
 + *    Test whether the received PHY event has to be ignored or not.
 + *
 + *    LOCKING:
 + *    None:
 + *
 + *    RETURNS:
 + *    True if the event has to be ignored.
 + */
 +bool sata_lpm_ignore_phy_events(struct ata_link *link)
 +{
 +      unsigned long lpm_timeout = link->last_lpm_change +
 +                                  msecs_to_jiffies(ATA_TMOUT_SPURIOUS_PHY);
 +
 +      /* if LPM is enabled, PHYRDY doesn't mean anything */
 +      if (link->lpm_policy > ATA_LPM_MAX_POWER)
 +              return true;
 +
 +      /* ignore the first PHY event after the LPM policy changed
 +       * as it is might be spurious
 +       */
 +      if ((link->flags & ATA_LFLAG_CHANGED) &&
 +          time_before(jiffies, lpm_timeout))
 +              return true;
 +
 +      return false;
 +}
 +EXPORT_SYMBOL_GPL(sata_lpm_ignore_phy_events);
 +
  /*
   * Dummy port_ops
   */
diff --combined drivers/ata/libata-eh.c
index cf0022ec07f2420c37fb8a52dc904530f0df2e38,2b370ee0ae863f3d20ebc85b2b0d9fb1822e8f1a..7465031a893c60c9e61f2c911abf218b39c81d2e
@@@ -1507,16 -1507,21 +1507,21 @@@ unsigned int ata_read_log_page(struct a
  {
        struct ata_taskfile tf;
        unsigned int err_mask;
+       bool dma = false;
  
        DPRINTK("read log page - log 0x%x, page 0x%x\n", log, page);
  
+ retry:
        ata_tf_init(dev, &tf);
-       if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id)) {
+       if (dev->dma_mode && ata_id_has_read_log_dma_ext(dev->id) &&
+           !(dev->horkage & ATA_HORKAGE_NO_NCQ_LOG)) {
                tf.command = ATA_CMD_READ_LOG_DMA_EXT;
                tf.protocol = ATA_PROT_DMA;
+               dma = true;
        } else {
                tf.command = ATA_CMD_READ_LOG_EXT;
                tf.protocol = ATA_PROT_PIO;
+               dma = false;
        }
        tf.lbal = log;
        tf.lbam = page;
        err_mask = ata_exec_internal(dev, &tf, NULL, DMA_FROM_DEVICE,
                                     buf, sectors * ATA_SECT_SIZE, 0);
  
+       if (err_mask && dma) {
+               dev->horkage |= ATA_HORKAGE_NO_NCQ_LOG;
+               ata_dev_warn(dev, "READ LOG DMA EXT failed, trying unqueued\n");
+               goto retry;
+       }
        DPRINTK("EXIT, err_mask=%x\n", err_mask);
        return err_mask;
  }
@@@ -3597,9 -3608,6 +3608,9 @@@ static int ata_eh_set_lpm(struct ata_li
                }
        }
  
 +      link->last_lpm_change = jiffies;
 +      link->flags |= ATA_LFLAG_CHANGED;
 +
        return 0;
  
  fail:
diff --combined include/linux/libata.h
index 51cb312d9bb9786682d3255f8a0cac6d9f670ce0,c3ef58014b33cbbc0d68ab487376e59c24158d63..36ce37bcc963c270548989d658caa4f3ce832045
@@@ -134,6 -134,7 +134,6 @@@ enum 
        ATA_ALL_DEVICES         = (1 << ATA_MAX_DEVICES) - 1,
  
        ATA_SHT_EMULATED        = 1,
 -      ATA_SHT_CMD_PER_LUN     = 1,
        ATA_SHT_THIS_ID         = -1,
        ATA_SHT_USE_CLUSTERING  = 1,
  
        ATA_LFLAG_SW_ACTIVITY   = (1 << 7), /* keep activity stats */
        ATA_LFLAG_NO_LPM        = (1 << 8), /* disable LPM on this link */
        ATA_LFLAG_RST_ONCE      = (1 << 9), /* limit recovery to one reset */
 +      ATA_LFLAG_CHANGED       = (1 << 10), /* LPM state changed on this link */
  
        /* struct ata_port flags */
        ATA_FLAG_SLAVE_POSS     = (1 << 0), /* host supports slave dev */
         */
        ATA_TMOUT_PMP_SRST_WAIT = 5000,
  
 +      /* When the LPM policy is set to ATA_LPM_MAX_POWER, there might
 +       * be a spurious PHY event, so ignore the first PHY event that
 +       * occurs within 10s after the policy change.
 +       */
 +      ATA_TMOUT_SPURIOUS_PHY  = 10000,
 +
        /* ATA bus states */
        BUS_UNKNOWN             = 0,
        BUS_DMA                 = 1,
        ATA_HORKAGE_NOLPM       = (1 << 20),    /* don't use LPM */
        ATA_HORKAGE_WD_BROKEN_LPM = (1 << 21),  /* some WDs have broken LPM */
        ATA_HORKAGE_ZERO_AFTER_TRIM = (1 << 22),/* guarantees zero after trim */
+       ATA_HORKAGE_NO_NCQ_LOG  = (1 << 23),    /* don't use NCQ for log read */
  
         /* DMA mask for user DMA control: User visible values; DO NOT
            renumber */
@@@ -794,8 -789,6 +795,8 @@@ struct ata_link 
        struct ata_eh_context   eh_context;
  
        struct ata_device       device[ATA_MAX_DEVICES];
 +
 +      unsigned long           last_lpm_change; /* when last LPM change happened */
  };
  #define ATA_LINK_CLEAR_BEGIN          offsetof(struct ata_link, active_tag)
  #define ATA_LINK_CLEAR_END            offsetof(struct ata_link, device[0])
@@@ -1209,7 -1202,6 +1210,7 @@@ extern struct ata_device *ata_dev_pair(
  extern int ata_do_set_mode(struct ata_link *link, struct ata_device **r_failed_dev);
  extern void ata_scsi_port_error_handler(struct Scsi_Host *host, struct ata_port *ap);
  extern void ata_scsi_cmd_error_handler(struct Scsi_Host *host, struct ata_port *ap, struct list_head *eh_q);
 +extern bool sata_lpm_ignore_phy_events(struct ata_link *link);
  
  extern int ata_cable_40wire(struct ata_port *ap);
  extern int ata_cable_80wire(struct ata_port *ap);
@@@ -1363,6 -1355,7 +1364,6 @@@ extern struct device_attribute *ata_com
        .can_queue              = ATA_DEF_QUEUE,                \
        .tag_alloc_policy       = BLK_TAG_ALLOC_RR,             \
        .this_id                = ATA_SHT_THIS_ID,              \
 -      .cmd_per_lun            = ATA_SHT_CMD_PER_LUN,          \
        .emulated               = ATA_SHT_EMULATED,             \
        .use_clustering         = ATA_SHT_USE_CLUSTERING,       \
        .proc_name              = drv_name,                     \