Skip to contentSkip to conversation

libata: Introduce ata_platform_shutdown_one()

PATCH In review Nate Watterson 2 participants 4 messages Jul 3, 2017 – Jul 5, 2017

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 libata: Introduce ata_platform_shutdown_one()

In similar fashion to how ata_platform_remove_one() is used, this newly introduced method can be used by platform ata drivers to get basic shutdown functionality (stopping host DMA and interrupts).

---
 drivers/ata/libata-core.c | 20 ++++++++++++++++++++
 include/linux/libata.h    |  1 +
 2 files changed, 21 insertions(+)
drivers/ata/libata-core.c +20 -0
index e157a0e..537932e 100644
@@ -6702,6 +6702,25 @@ int ata_platform_remove_one(struct platform_device *pdev)
 	return 0;
 }
 
+/**
+ *	ata_platform_shutdown_one - Platform layer callback for device shutdown
+ *	@pdev: Platform device being shutdown
+ *
+ *	Platform layer indicates to libata via this hook that shutdown is
+ *	in progress and the input device should be quiesced. Functionally this
+ *	is equivalent to ata_platform_remove_one(), however devres_release_all()
+ *	is not called on the shutdown path as it is for remove so releasing the
+ *	resources associated with the device must instead be initiated directly.
+ */
+void ata_platform_shutdown_one(struct platform_device *pdev)
+{
+	struct ata_host *host = platform_get_drvdata(pdev);
+
+	ata_host_detach(host);
+	devres_release(&pdev->dev, ata_host_stop, NULL, NULL);
+	devres_release(&pdev->dev, ata_host_release, NULL, NULL);
+}
+
 static int __init ata_parse_force_one(char **cur,
 				      struct ata_force_ent *force_ent,
 				      const char **reason)
@@ -7222,6 +7241,7 @@ void ata_print_version(const struct device *dev, const char *version)
 #endif /* CONFIG_PCI */
 
 EXPORT_SYMBOL_GPL(ata_platform_remove_one);
+EXPORT_SYMBOL_GPL(ata_platform_shutdown_one);
 
 EXPORT_SYMBOL_GPL(__ata_ehi_push_desc);
 EXPORT_SYMBOL_GPL(ata_ehi_push_desc);
include/linux/libata.h +1 -0
index c9a69fc..6c01f23f 100644
@@ -1240,6 +1240,7 @@ struct pci_bits {
 struct platform_device;
 
 extern int ata_platform_remove_one(struct platform_device *pdev);
+extern void ata_platform_shutdown_one(struct platform_device *pdev);
 
 /*
  * ACPI - drivers/ata/libata-acpi.c
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux
Foundation Collaborative Project.
#1 lore raw

PATCH 2/2 ata: ahci_platform: Handle shutdown with ata_platform_shutdown_one()

To avoid interfering with a new kernel started using kexec, quiesce host controller DMA interrupts during driver shutdown with ata_platform_remove_one().

Change-Id Iedee7f7ba12172b3d34796a3e3b92dbb72d4ed9c
---
 drivers/ata/ahci_platform.c | 1 +
 1 file changed, 1 insertion(+)
drivers/ata/ahci_platform.c +1 -0
index 62a04c8..ca25b0d 100644
@@ -93,6 +93,7 @@ static SIMPLE_DEV_PM_OPS(ahci_pm_ops, ahci_platform_suspend,
 static struct platform_driver ahci_driver = {
 	.probe = ahci_probe,
 	.remove = ata_platform_remove_one,
+	.shutdown = ata_platform_shutdown_one,
 	.driver = {
 		.name = DRV_NAME,
 		.of_match_table = ahci_of_match,
Signature · 3 lines
Qualcomm Datacenter Technologies, Inc. on behalf of Qualcomm Technologies, Inc.
Qualcomm Technologies, Inc. is a member of the Code Aurora Forum, a Linux
Foundation Collaborative Project.
#3 lore raw
In reply to Nate Watterson
Quoted 15 lines · Nate Watterson

In similar fashion to how ata_platform_remove_one() is used, this newly introduced method can be used by platform ata drivers to get basic shutdown functionality (stopping host DMA and interrupts).

---
 drivers/ata/libata-core.c | 20 ++++++++++++++++++++
 include/linux/libata.h    |  1 +
 2 files changed, 21 insertions(+)
drivers/ata/libata-core.c +0 -0
index e157a0e..537932e 100644

drivers/ata/libata-core.c int ata_platform_remove_one(struct platform_device *pdev) · line 6710

Quoted 9 lines
drivers/ata/libata-core.c +6 -0
@@ -6702,6 +6702,25 @@ int ata_platform_remove_one(struct platform_device *pdev)
 	return 0;
 }
 
+/**
+ *	ata_platform_shutdown_one - Platform layer callback for device shutdown
+ *	@pdev: Platform device being shutdown
+ *
+ *	Platform layer indicates to libata via this hook that shutdown is
+ *	in progress and the input device should be quiesced. Functionally this
                            ^^^^^

drivers/ata/libata-core.c int ata_platform_remove_one(struct platform_device *pdev) · line 6713

Quoted 3 lines
drivers/ata/libata-core.c +3 -0
+ *	is equivalent to ata_platform_remove_one(), however devres_release_all()
+ *	is not called on the shutdown path as it is for remove so releasing the
+ *	resources associated with the device must instead be initiated directly.

I can't easily understand the above comment. Can you please try to rephrase it so that it's clear why and when it's used?

Thanks.

Signature · 1 line
tejun
#2 lore raw

Re: [PATCH 2/2] ata: ahci_platform: Handle shutdown with ata_platform_shutdown_one()

In reply to Nate Watterson
Quoted 6 lines · Nate Watterson

To avoid interfering with a new kernel started using kexec, quiesce host controller DMA interrupts during driver shutdown with ata_platform_remove_one().

Change-Id Iedee7f7ba12172b3d34796a3e3b92dbb72d4ed9c

Please drop the Change-Id when posting upstream. Also, it probably would be better to roll this into the previous patch.

Thanks.

Signature · 1 line
tejun