Skip to content

Commit 10a663a

Browse files
Prabhakar Kushwahaaxboe
authored andcommitted
ata: ahci: Add shutdown to freeze hardware resources of ahci
device_shutdown() called from reboot or power_shutdown expect all devices to be shutdown. Same is true for even ahci pci driver. As no ahci shutdown function is implemented, the ata subsystem always remains alive with DMA & interrupt support. File system related calls should not be honored after device_shutdown(). So defining ahci pci driver shutdown to freeze hardware (mask interrupt, stop DMA engine and free DMA resources). Signed-off-by: Prabhakar Kushwaha <[email protected]> Signed-off-by: Jens Axboe <[email protected]>
1 parent 73e4eab commit 10a663a

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed

drivers/ata/ahci.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ enum board_ids {
8181

8282
static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent);
8383
static void ahci_remove_one(struct pci_dev *dev);
84+
static void ahci_shutdown_one(struct pci_dev *dev);
8485
static int ahci_vt8251_hardreset(struct ata_link *link, unsigned int *class,
8586
unsigned long deadline);
8687
static int ahci_avn_hardreset(struct ata_link *link, unsigned int *class,
@@ -606,6 +607,7 @@ static struct pci_driver ahci_pci_driver = {
606607
.id_table = ahci_pci_tbl,
607608
.probe = ahci_init_one,
608609
.remove = ahci_remove_one,
610+
.shutdown = ahci_shutdown_one,
609611
.driver = {
610612
.pm = &ahci_pci_pm_ops,
611613
},
@@ -1877,6 +1879,11 @@ static int ahci_init_one(struct pci_dev *pdev, const struct pci_device_id *ent)
18771879
return 0;
18781880
}
18791881

1882+
static void ahci_shutdown_one(struct pci_dev *pdev)
1883+
{
1884+
ata_pci_shutdown_one(pdev);
1885+
}
1886+
18801887
static void ahci_remove_one(struct pci_dev *pdev)
18811888
{
18821889
pm_runtime_get_noresume(&pdev->dev);

drivers/ata/libata-core.c

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6767,6 +6767,26 @@ void ata_pci_remove_one(struct pci_dev *pdev)
67676767
ata_host_detach(host);
67686768
}
67696769

6770+
void ata_pci_shutdown_one(struct pci_dev *pdev)
6771+
{
6772+
struct ata_host *host = pci_get_drvdata(pdev);
6773+
int i;
6774+
6775+
for (i = 0; i < host->n_ports; i++) {
6776+
struct ata_port *ap = host->ports[i];
6777+
6778+
ap->pflags |= ATA_PFLAG_FROZEN;
6779+
6780+
/* Disable port interrupts */
6781+
if (ap->ops->freeze)
6782+
ap->ops->freeze(ap);
6783+
6784+
/* Stop the port DMA engines */
6785+
if (ap->ops->port_stop)
6786+
ap->ops->port_stop(ap);
6787+
}
6788+
}
6789+
67706790
/* move to PCI subsystem */
67716791
int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits)
67726792
{
@@ -7387,6 +7407,7 @@ EXPORT_SYMBOL_GPL(ata_timing_cycle2mode);
73877407

73887408
#ifdef CONFIG_PCI
73897409
EXPORT_SYMBOL_GPL(pci_test_config_bits);
7410+
EXPORT_SYMBOL_GPL(ata_pci_shutdown_one);
73907411
EXPORT_SYMBOL_GPL(ata_pci_remove_one);
73917412
#ifdef CONFIG_PM
73927413
EXPORT_SYMBOL_GPL(ata_pci_device_do_suspend);

include/linux/libata.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1221,6 +1221,7 @@ struct pci_bits {
12211221
};
12221222

12231223
extern int pci_test_config_bits(struct pci_dev *pdev, const struct pci_bits *bits);
1224+
extern void ata_pci_shutdown_one(struct pci_dev *pdev);
12241225
extern void ata_pci_remove_one(struct pci_dev *pdev);
12251226

12261227
#ifdef CONFIG_PM

0 commit comments

Comments
 (0)