[PATCH 2/2] ata: ahci: Add shutdown handler

From: Hanna Hawa
Date: Mon Dec 09 2019 - 11:33:23 EST


An issue found while doing kexec on Annapurna Labs SoC: an AXI read
error occur due to an access from the interrupt handler of AHCI to the
AHCI controller.
This patch make sure that the interrupts are disabled for the controller
while doing kexec.

The shutdown handler 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: Hanna Hawa <hhhawa@xxxxxxxxxx>
---
drivers/ata/ahci.c | 9 +++++++++
1 file changed, 9 insertions(+)

diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index 05c2b32dcc4d..34ddc259343a 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -80,6 +80,7 @@ enum board_ids {

static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
static void ahci_remove_one(struct pci_dev *dev);
+static void ahci_shutdown(struct pci_dev *dev);
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,
@@ -593,6 +594,7 @@ static struct pci_driver ahci_pci_driver = {
.id_table = ahci_pci_tbl,
.probe = ahci_init_one,
.remove = ahci_remove_one,
+ .shutdown = ahci_shutdown,
.driver = {
.pm = &ahci_pci_pm_ops,
},
@@ -1870,6 +1872,13 @@ static void ahci_remove_one(struct pci_dev *pdev)
ata_pci_remove_one(pdev);
}

+static void ahci_shutdown(struct pci_dev *pdev)
+{
+ struct ata_host *host = pci_get_drvdata(pdev);
+
+ ahci_common_shutdown(host);
+}
+
module_pci_driver(ahci_pci_driver);

MODULE_AUTHOR("Jeff Garzik");
--
2.17.1