Skip to content

Commit 1896b15

Browse files
computersforpeaceJeff Garzik
authored andcommitted
ahci_platform: perform platform exit in host_stop() hook
AHCI platform devices may provide an exit() routine, via ahci_platform_data, that powers off the SATA core. Such a routine should be executed from the ata_port_operations host_stop() hook. That way, the ATA subsystem can perform any last-minute hardware cleanup (via devres, for example), then trigger the power-off at the appropriate time. This patch fixes bus errors triggered during module removal or device unbinding, seen on an SoC SATA core. Signed-off-by: Brian Norris <computersforpeace@gmail.com> Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
1 parent 9a99e47 commit 1896b15

1 file changed

Lines changed: 23 additions & 7 deletions

File tree

‎drivers/ata/ahci_platform.c‎

Lines changed: 23 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
#include <linux/ahci_platform.h>
2626
#include "ahci.h"
2727

28+
static void ahci_host_stop(struct ata_host *host);
29+
2830
enum ahci_type {
2931
AHCI, /* standard platform ahci */
3032
IMX53_AHCI, /* ahci on i.mx53 */
@@ -47,27 +49,36 @@ static struct platform_device_id ahci_devtype[] = {
4749
};
4850
MODULE_DEVICE_TABLE(platform, ahci_devtype);
4951

52+
struct ata_port_operations ahci_platform_ops = {
53+
.inherits = &ahci_ops,
54+
.host_stop = ahci_host_stop,
55+
};
56+
57+
struct ata_port_operations ahci_platform_retry_srst_ops = {
58+
.inherits = &ahci_pmp_retry_srst_ops,
59+
.host_stop = ahci_host_stop,
60+
};
5061

5162
static const struct ata_port_info ahci_port_info[] = {
5263
/* by features */
5364
[AHCI] = {
5465
.flags = AHCI_FLAG_COMMON,
5566
.pio_mask = ATA_PIO4,
5667
.udma_mask = ATA_UDMA6,
57-
.port_ops = &ahci_ops,
68+
.port_ops = &ahci_platform_ops,
5869
},
5970
[IMX53_AHCI] = {
6071
.flags = AHCI_FLAG_COMMON,
6172
.pio_mask = ATA_PIO4,
6273
.udma_mask = ATA_UDMA6,
63-
.port_ops = &ahci_pmp_retry_srst_ops,
74+
.port_ops = &ahci_platform_retry_srst_ops,
6475
},
6576
[STRICT_AHCI] = {
6677
AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE),
6778
.flags = AHCI_FLAG_COMMON,
6879
.pio_mask = ATA_PIO4,
6980
.udma_mask = ATA_UDMA6,
70-
.port_ops = &ahci_ops,
81+
.port_ops = &ahci_platform_ops,
7182
},
7283
};
7384

@@ -221,21 +232,26 @@ static int __devinit ahci_probe(struct platform_device *pdev)
221232
static int __devexit ahci_remove(struct platform_device *pdev)
222233
{
223234
struct device *dev = &pdev->dev;
224-
struct ahci_platform_data *pdata = dev_get_platdata(dev);
225235
struct ata_host *host = dev_get_drvdata(dev);
226-
struct ahci_host_priv *hpriv = host->private_data;
227236

228237
ata_host_detach(host);
229238

239+
return 0;
240+
}
241+
242+
static void ahci_host_stop(struct ata_host *host)
243+
{
244+
struct device *dev = host->dev;
245+
struct ahci_platform_data *pdata = dev_get_platdata(dev);
246+
struct ahci_host_priv *hpriv = host->private_data;
247+
230248
if (pdata && pdata->exit)
231249
pdata->exit(dev);
232250

233251
if (!IS_ERR(hpriv->clk)) {
234252
clk_disable_unprepare(hpriv->clk);
235253
clk_put(hpriv->clk);
236254
}
237-
238-
return 0;
239255
}
240256

241257
#ifdef CONFIG_PM_SLEEP

0 commit comments

Comments
 (0)