Skip to content

Commit 8eede5b

Browse files
Nate Wattersonhtejun
authored andcommitted
ata: ahci_platform: Add shutdown handler
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>
1 parent afbd39a commit 8eede5b

3 files changed

Lines changed: 37 additions & 0 deletions

File tree

‎drivers/ata/ahci_platform.c‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ MODULE_DEVICE_TABLE(acpi, ahci_acpi_match);
9393
static struct platform_driver ahci_driver = {
9494
.probe = ahci_probe,
9595
.remove = ata_platform_remove_one,
96+
.shutdown = ahci_platform_shutdown,
9697
.driver = {
9798
.name = DRV_NAME,
9899
.of_match_table = ahci_of_match,

‎drivers/ata/libahci_platform.c‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -602,6 +602,40 @@ static void ahci_host_stop(struct ata_host *host)
602602
ahci_platform_disable_resources(hpriv);
603603
}
604604

605+
/**
606+
* ahci_platform_shutdown - Disable interrupts and stop DMA for host ports
607+
* @dev: platform device pointer for the host
608+
*
609+
* This function is called during system shutdown and performs the minimal
610+
* deconfiguration required to ensure that an ahci_platform host cannot
611+
* corrupt or otherwise interfere with a new kernel being started with kexec.
612+
*/
613+
void ahci_platform_shutdown(struct platform_device *pdev)
614+
{
615+
struct ata_host *host = platform_get_drvdata(pdev);
616+
struct ahci_host_priv *hpriv = host->private_data;
617+
void __iomem *mmio = hpriv->mmio;
618+
int i;
619+
620+
for (i = 0; i < host->n_ports; i++) {
621+
struct ata_port *ap = host->ports[i];
622+
623+
/* Disable port interrupts */
624+
if (ap->ops->freeze)
625+
ap->ops->freeze(ap);
626+
627+
/* Stop the port DMA engines */
628+
if (ap->ops->port_stop)
629+
ap->ops->port_stop(ap);
630+
}
631+
632+
/* Disable and clear host interrupts */
633+
writel(readl(mmio + HOST_CTL) & ~HOST_IRQ_EN, mmio + HOST_CTL);
634+
readl(mmio + HOST_CTL); /* flush */
635+
writel(GENMASK(host->n_ports, 0), mmio + HOST_IRQ_STAT);
636+
}
637+
EXPORT_SYMBOL_GPL(ahci_platform_shutdown);
638+
605639
#ifdef CONFIG_PM_SLEEP
606640
/**
607641
* ahci_platform_suspend_host - Suspend an ahci-platform host

‎include/linux/ahci_platform.h‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ int ahci_platform_init_host(struct platform_device *pdev,
3636
const struct ata_port_info *pi_template,
3737
struct scsi_host_template *sht);
3838

39+
void ahci_platform_shutdown(struct platform_device *pdev);
40+
3941
int ahci_platform_suspend_host(struct device *dev);
4042
int ahci_platform_resume_host(struct device *dev);
4143
int ahci_platform_suspend(struct device *dev);

0 commit comments

Comments
 (0)