]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/commitdiff
libahci: Allow drivers to override stop_engine
authorEvan Wang <xswang@marvell.com>
Fri, 13 Apr 2018 04:32:30 +0000 (12:32 +0800)
committerStefan Bader <stefan.bader@canonical.com>
Mon, 1 Oct 2018 12:55:48 +0000 (14:55 +0200)
BugLink: http://bugs.launchpad.net/bugs/1794889
[ Upstream commit fa89f53bd7288d6aa7a982841119e7123faf5a53 ]

Marvell armada37xx, armada7k and armada8k share the same
AHCI sata controller IP, and currently there is an issue
(Errata Ref#226)that the SATA can not be detected via SATA
Port-MultiPlayer(PMP). After debugging, the reason is
found that the value of Port-x FIS-based Switching Control
(PxFBS@0x40) became wrong.
According to design, the bits[11:8, 0] of register PxFBS
are cleared when Port Command and Status (0x18) bit[0]
changes its value from 1 to 0, i.e. falling edge of Port
Command and Status bit[0] sends PULSE that resets PxFBS
bits[11:8; 0].
So it needs save the port PxFBS register before PxCMD
ST write and restore the port PxFBS register afterwards
in ahci_stop_engine().

This commit allows drivers to override ahci_stop_engine
behavior for use by the Marvell AHCI driver(and potentially
other drivers in the future).

Signed-off-by: Evan Wang <xswang@marvell.com>
Cc: Ofer Heifetz <oferh@marvell.com>
Cc: Tejun Heo <tj@kernel.org>
Cc: Thomas Petazzoni <thomas.petazzoni@bootlin.com>
Signed-off-by: Tejun Heo <tj@kernel.org>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Signed-off-by: Kamal Mostafa <kamal@canonical.com>
Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
drivers/ata/ahci.c
drivers/ata/ahci.h
drivers/ata/ahci_qoriq.c
drivers/ata/ahci_xgene.c
drivers/ata/libahci.c
drivers/ata/sata_highbank.c

index 2badef1271fd3a49fc79b9e9e4af9878cb62eb58..e3e69f5ec1570b711c760ecae495d3aa542ae970 100644 (file)
@@ -687,7 +687,7 @@ static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
 
        DPRINTK("ENTER\n");
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        rc = sata_link_hardreset(link, sata_ehc_deb_timing(&link->eh_context),
                                 deadline, &online, NULL);
@@ -713,7 +713,7 @@ static int ahci_p5wdh_hardreset(struct ata_link *link, unsigned int *class,
        bool online;
        int rc;
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        /* clear D2H reception area to properly wait for D2H FIS */
        ata_tf_init(link->device, &tf);
@@ -777,7 +777,7 @@ static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
 
        DPRINTK("ENTER\n");
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        for (i = 0; i < 2; i++) {
                u16 val;
index 749fd94441b034104bc9ac87738785c43337c876..9cc196b4474af2283d2cbe9bc92b11be0020ed64 100644 (file)
@@ -362,6 +362,13 @@ struct ahci_host_priv {
         * be overridden anytime before the host is activated.
         */
        void                    (*start_engine)(struct ata_port *ap);
+       /*
+        * Optional ahci_stop_engine override, if not set this gets set to the
+        * default ahci_stop_engine during ahci_save_initial_config, this can
+        * be overridden anytime before the host is activated.
+        */
+       int                     (*stop_engine)(struct ata_port *ap);
+
        irqreturn_t             (*irq_handler)(int irq, void *dev_instance);
 
        /* only required for per-port MSI(-X) support */
index 2685f28160f70764ee4013930239566031c9b058..cfdef4d44ae92cdf5a335c99a7d049df8a8cb5ae 100644 (file)
@@ -96,7 +96,7 @@ static int ahci_qoriq_hardreset(struct ata_link *link, unsigned int *class,
 
        DPRINTK("ENTER\n");
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        /*
         * There is a errata on ls1021a Rev1.0 and Rev2.0 which is:
index c2b5941d9184db2637604864baf4597d398c4911..ad58da7c9affd8e4ec381d8bb0fd7f23d6fa0310 100644 (file)
@@ -165,7 +165,7 @@ static int xgene_ahci_restart_engine(struct ata_port *ap)
                                    PORT_CMD_ISSUE, 0x0, 1, 100))
                  return -EBUSY;
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
        ahci_start_fis_rx(ap);
 
        /*
@@ -421,7 +421,7 @@ static int xgene_ahci_hardreset(struct ata_link *link, unsigned int *class,
        portrxfis_saved = readl(port_mmio + PORT_FIS_ADDR);
        portrxfishi_saved = readl(port_mmio + PORT_FIS_ADDR_HI);
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        rc = xgene_ahci_do_hardreset(link, deadline, &online);
 
index a0de7a38430c954b31c7b4e6e01a790ee98e85c2..edaba13edeb9886ed83f6b2e84734f9cdffa25db 100644 (file)
@@ -560,6 +560,9 @@ void ahci_save_initial_config(struct device *dev, struct ahci_host_priv *hpriv)
        if (!hpriv->start_engine)
                hpriv->start_engine = ahci_start_engine;
 
+       if (!hpriv->stop_engine)
+               hpriv->stop_engine = ahci_stop_engine;
+
        if (!hpriv->irq_handler)
                hpriv->irq_handler = ahci_single_level_irq_intr;
 }
@@ -887,9 +890,10 @@ static void ahci_start_port(struct ata_port *ap)
 static int ahci_deinit_port(struct ata_port *ap, const char **emsg)
 {
        int rc;
+       struct ahci_host_priv *hpriv = ap->host->private_data;
 
        /* disable DMA */
-       rc = ahci_stop_engine(ap);
+       rc = hpriv->stop_engine(ap);
        if (rc) {
                *emsg = "failed to stop engine";
                return rc;
@@ -1300,7 +1304,7 @@ int ahci_kick_engine(struct ata_port *ap)
        int busy, rc;
 
        /* stop engine */
-       rc = ahci_stop_engine(ap);
+       rc = hpriv->stop_engine(ap);
        if (rc)
                goto out_restart;
 
@@ -1539,7 +1543,7 @@ int ahci_do_hardreset(struct ata_link *link, unsigned int *class,
 
        DPRINTK("ENTER\n");
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        /* clear D2H reception area to properly wait for D2H FIS */
        ata_tf_init(link->device, &tf);
@@ -2065,14 +2069,14 @@ void ahci_error_handler(struct ata_port *ap)
 
        if (!(ap->pflags & ATA_PFLAG_FROZEN)) {
                /* restart engine */
-               ahci_stop_engine(ap);
+               hpriv->stop_engine(ap);
                hpriv->start_engine(ap);
        }
 
        sata_pmp_error_handler(ap);
 
        if (!ata_dev_enabled(ap->link.device))
-               ahci_stop_engine(ap);
+               hpriv->stop_engine(ap);
 }
 EXPORT_SYMBOL_GPL(ahci_error_handler);
 
@@ -2119,7 +2123,7 @@ static void ahci_set_aggressive_devslp(struct ata_port *ap, bool sleep)
                return;
 
        /* set DITO, MDAT, DETO and enable DevSlp, need to stop engine first */
-       rc = ahci_stop_engine(ap);
+       rc = hpriv->stop_engine(ap);
        if (rc)
                return;
 
@@ -2179,7 +2183,7 @@ static void ahci_enable_fbs(struct ata_port *ap)
                return;
        }
 
-       rc = ahci_stop_engine(ap);
+       rc = hpriv->stop_engine(ap);
        if (rc)
                return;
 
@@ -2212,7 +2216,7 @@ static void ahci_disable_fbs(struct ata_port *ap)
                return;
        }
 
-       rc = ahci_stop_engine(ap);
+       rc = hpriv->stop_engine(ap);
        if (rc)
                return;
 
index aafb8cc03523212dee4d8d3fe66434af2406ae76..e67815b896fcc40772ac45fdf8e8be7253cecafa 100644 (file)
@@ -410,7 +410,7 @@ static int ahci_highbank_hardreset(struct ata_link *link, unsigned int *class,
        int rc;
        int retry = 100;
 
-       ahci_stop_engine(ap);
+       hpriv->stop_engine(ap);
 
        /* clear D2H reception area to properly wait for D2H FIS */
        ata_tf_init(link->device, &tf);