]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
ata: ahci_platform: Add shutdown handler
authorNate Watterson <nwatters@codeaurora.org>
Thu, 20 Jul 2017 19:26:24 +0000 (15:26 -0400)
committerTejun Heo <tj@kernel.org>
Fri, 4 Aug 2017 20:34:14 +0000 (13:34 -0700)
The newly introduced ahci_platform_shutdown() method is called during
system shutdown to disable host controller DMA and interrupts in order
to avoid potentially corrupting or otherwise interfering with a new
kernel being started with kexec.

Signed-off-by: Nate Watterson <nwatters@codeaurora.org>
Signed-off-by: Tejun Heo <tj@kernel.org>
drivers/ata/ahci_platform.c
drivers/ata/libahci_platform.c
include/linux/ahci_platform.h

index 62a04c8fb5c99c9ab0614bb6dc8f0146c47329e6..99f9a895a459a673d753bce6a3c00f912c5a7437 100644 (file)
@@ -93,6 +93,7 @@ MODULE_DEVICE_TABLE(acpi, ahci_acpi_match);
 static struct platform_driver ahci_driver = {
        .probe = ahci_probe,
        .remove = ata_platform_remove_one,
+       .shutdown = ahci_platform_shutdown,
        .driver = {
                .name = DRV_NAME,
                .of_match_table = ahci_of_match,
index cd2eab6aa92ea245e1a3dab839be7fe8aa938cdb..a270a1173c8cb6136bbbdfa63471d3a9f253aaaf 100644 (file)
@@ -602,6 +602,40 @@ static void ahci_host_stop(struct ata_host *host)
        ahci_platform_disable_resources(hpriv);
 }
 
+/**
+ * ahci_platform_shutdown - Disable interrupts and stop DMA for host ports
+ * @dev: platform device pointer for the host
+ *
+ * This function is called during system shutdown and performs the minimal
+ * deconfiguration required to ensure that an ahci_platform host cannot
+ * corrupt or otherwise interfere with a new kernel being started with kexec.
+ */
+void ahci_platform_shutdown(struct platform_device *pdev)
+{
+       struct ata_host *host = platform_get_drvdata(pdev);
+       struct ahci_host_priv *hpriv = host->private_data;
+       void __iomem *mmio = hpriv->mmio;
+       int i;
+
+       for (i = 0; i < host->n_ports; i++) {
+               struct ata_port *ap = host->ports[i];
+
+               /* Disable port interrupts */
+               if (ap->ops->freeze)
+                       ap->ops->freeze(ap);
+
+               /* Stop the port DMA engines */
+               if (ap->ops->port_stop)
+                       ap->ops->port_stop(ap);
+       }
+
+       /* Disable and clear host interrupts */
+       writel(readl(mmio + HOST_CTL) & ~HOST_IRQ_EN, mmio + HOST_CTL);
+       readl(mmio + HOST_CTL); /* flush */
+       writel(GENMASK(host->n_ports, 0), mmio + HOST_IRQ_STAT);
+}
+EXPORT_SYMBOL_GPL(ahci_platform_shutdown);
+
 #ifdef CONFIG_PM_SLEEP
 /**
  * ahci_platform_suspend_host - Suspend an ahci-platform host
index a270f25ee7c7c49890e2b902ceaccd80a5a05aa2..1b0a17b22cd3c8e224a7d3dd1fdaa155830ac49a 100644 (file)
@@ -36,6 +36,8 @@ int ahci_platform_init_host(struct platform_device *pdev,
                            const struct ata_port_info *pi_template,
                            struct scsi_host_template *sht);
 
+void ahci_platform_shutdown(struct platform_device *pdev);
+
 int ahci_platform_suspend_host(struct device *dev);
 int ahci_platform_resume_host(struct device *dev);
 int ahci_platform_suspend(struct device *dev);