ahci/libata: clean up platform device removal
Subsystems (2)
cover ahci/libata: clean up platform device removal
Hi,
This is a revision and extension of an RFC series I sent out a few times. Here are links to the previous patches, discussion, and questions.
http://article.gmane.org/gmane.linux.ide/53159 http://article.gmane.org/gmane.linux.ide/53143 http://article.gmane.org/gmane.linux.ide/52951
The major change from RFC v2 is that I rebased to the current libata/NEXT, then added new patches (PATCH 04/14 through PATCH 14/14).
This series does the following:
(1) Allows ahci_platform to unbind a device from the driver. This is useful for allowing total power-off of the device, for instance.
(2) Adds ahci_platform ata_port_operations.host_stop() hook, so that platform-device exit() can power down the device at the appropriate point in the removal sequence.
(3) Adds a common ata_platform_remove_one() function so that we don't re-implement a simple host detach across many platform drivers
(4) Switches many platform drivers to the new .remove function from (3)
Thanks to Tejun for the comments, which suggested that ahci_platform (not libata-core) was broken.
Note that patch 13 provides untested new functionality to the pata_octeon_cf driver. It was missing a .remove function, so I took the liberty to add the common one. Feel free to exclude this patch.
Thanks,
Brian
P.S. A related but distinct issue: someting is still broken in the ata_host_detach() function, for shutting down the host, spinning down disks, etc. When I rmmod the driver or unbind the device, I get the following failures, and the HDD doesn't spin down:
# echo strict-ahci.0 > /sys/bus/platform/drivers/ahci/unbind ata2.00: disabled sd 1:0:0:0: [sda] Synchronizing SCSI cache sd 1:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00 sd 1:0:0:0: [sda] Stopping disk sd 1:0:0:0: [sda] START_STOP FAILED sd 1:0:0:0: [sda] Result: hostbyte=0x04 driverbyte=0x00
This is reproducible on my laptop (v3.2 kernel, AHCI PCI driver) and on my SoC AHCI core (v3.3 kernel, AHCI platform driver). I haven't been able to try a more recent kernel, but nothing I see in the changelogs suggests that there would be any difference.
I have narrowed down the error messages to the following info, although I am not yet familiar enough with these codepaths to make a recommendation:
ata_host_detach
|_ ata_port_detach
|_ ata_port_schedule_eh => SCSI error handler calls ata_dev_disable()
| ...
|_scsi_remove_host()
| ...
|__..._ sd_start_stop_device() => failure!Brian Norris (14):
ahci_platform: enable hotplug unbinding
ahci_platform: convert to module_platform_driver
ahci_platform: perform platform exit in host_stop() hook
libata: implement ata_platform_remove_one()
ahci_platform: utilize common ata_platform_remove_one()
pata_ixp4xx_cf: utilize common ata_platform_remove_one()
pata_mpc52xx: utilize common ata_platform_remove_one()
pata_of_platform: utilize common ata_platform_remove_one()
pata_platform: utilize common ata_platform_remove_one()
ata_platform: remove unused remove function
pata_palmld: utilize common ata_platform_remove_one()
sata_highbank: utilize common ata_platform_remove_one()
pata_octeon_cf: perform host detach, removal on exit
libata: use pci_get_drvdata() helper
drivers/ata/ahci_platform.c | 44 +++++++++++++++++++----------------------- drivers/ata/libata-core.c | 30 ++++++++++++++++++++++++---- drivers/ata/pata_ixp4xx_cf.c | 11 +---------- drivers/ata/pata_mpc52xx.c | 17 +++------------- drivers/ata/pata_octeon_cf.c | 1 + drivers/ata/pata_of_platform.c | 7 +------ drivers/ata/pata_palmld.c | 4 +--- drivers/ata/pata_platform.c | 24 +---------------------- drivers/ata/sata_highbank.c | 12 +----------- include/linux/ata_platform.h | 2 -- include/linux/libata.h | 4 ++++ 11 files changed, 59 insertions(+), 97 deletions(-)
Signature · 1 line
1.7.11.3
PATCH 1/14 ahci_platform: enable hotplug unbinding
platform_driver_probe() should be used for registering this driver only if we want to
"...remove its run-once probe() infrastructure from memory after the driver has bound to the device."
However, we may want to leave the probe infrastructure in place in order to support binding/unbinding a device dynamically. This is useful, for instance, as a power management mechanism, where a device can be totally powered down when unbound (whereas with runtime power management, powering down the SATA core would incur unacceptable loss of functionality).
Thus, convert this driver to use platform_driver_register().
--- drivers/ata/ahci_platform.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/ata/ahci_platform.c +3 -2
@@ -75,7 +75,7 @@ static struct scsi_host_template ahci_platform_sht = { AHCI_SHT("ahci_platform"), }; -static int __init ahci_probe (struct platform_device *pdev) +static int __devinit ahci_probe (struct platform_device *pdev) {struct device *dev = &pdev->dev;struct ahci_platform_data *pdata =dev_get_platdata (dev);
@@ -326,6 +326,7 @@ static const struct of_device_id ahci_of_match[] = {MODULE_DEVICE_TABLE (of, ahci_of_match);static struct platform_driver ahci_driver = { + .probe = ahci_probe, .remove =__devexit_p (ahci_remove), .driver = { .name ="ahci" ,
@@ -338,7 +339,7 @@ static struct platform_driver ahci_driver = {static int __init ahci_init (void ) { -return platform_driver_probe (&ahci_driver, ahci_probe); +return platform_driver_register (&ahci_driver); }module_init (ahci_init);
Signature · 1 line
1.7.11.3
PATCH 2/14 ahci_platform: convert to module_platform_driver
In reply to Brian NorrisThe ahci_platform driver can now use the module_platform_driver() macro.
--- drivers/ata/ahci_platform.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-)
drivers/ata/ahci_platform.c +1 -12
@@ -336,18 +336,7 @@ static struct platform_driver ahci_driver = { }, .id_table = ahci_devtype, }; - -static int __init ahci_init (void ) -{ -return platform_driver_register (&ahci_driver); -} -module_init (ahci_init); - -static void __exit ahci_exit(void) -{ -platform_driver_unregister (&ahci_driver); -} -module_exit (ahci_exit); +module_platform_driver (ahci_driver);MODULE_DESCRIPTION ("AHCI SATA platform driver" );MODULE_AUTHOR ("Anton Vorontsov <[email protected]>" );
Signature · 1 line
1.7.11.3
PATCH 3/14 ahci_platform: perform platform exit in host_stop() hook
In reply to Brian NorrisAHCI 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.
--- drivers/ata/ahci_platform.c | 30 +++++++++++++++++++++++------- 1 file changed, 23 insertions(+), 7 deletions(-)
drivers/ata/ahci_platform.c +23 -7
@@ -25,6 +25,8 @@#include <linux/ahci_platform.h> #include "ahci.h" +static void ahci_host_stop (struct ata_host *host); +enum ahci_type {AHCI ,/* standard platform ahci */ IMX53_AHCI ,/* ahci on i.mx53 */
@@ -47,6 +49,15 @@ static struct platform_device_id ahci_devtype[] = { };MODULE_DEVICE_TABLE (platform, ahci_devtype); +struct ata_port_operations ahci_platform_ops = { + .inherits = &ahci_ops, + .host_stop = ahci_host_stop, +}; + +struct ata_port_operations ahci_platform_retry_srst_ops = { + .inherits = &ahci_pmp_retry_srst_ops, + .host_stop = ahci_host_stop, +};static const struct ata_port_info ahci_port_info[] = {/* by features */
@@ -54,20 +65,20 @@ static const struct ata_port_info ahci_port_info[] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, [IMX53_AHCI] = { .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_pmp_retry_srst_ops, + .port_ops = &ahci_platform_retry_srst_ops, }, [STRICT_AHCI] = { AHCI_HFLAGS (AHCI_HFLAG_DELAY_ENGINE), .flags = AHCI_FLAG_COMMON, .pio_mask = ATA_PIO4, .udma_mask = ATA_UDMA6, - .port_ops = &ahci_ops, + .port_ops = &ahci_platform_ops, }, };
@@ -221,12 +232,19 @@ free_clk: static int __devexit ahci_remove(struct platform_device *pdev) {struct device *dev = &pdev->dev; -struct ahci_platform_data *pdata =dev_get_platdata (dev);struct ata_host *host =dev_get_drvdata (dev); -struct ahci_host_priv *hpriv = host->private_data;ata_host_detach (host); +return 0 ; +} + +static void ahci_host_stop (struct ata_host *host) +{ +struct device *dev = host->dev; +struct ahci_platform_data *pdata =dev_get_platdata (dev); +struct ahci_host_priv *hpriv = host->private_data; +if (pdata && pdata->exit) pdata->exit (dev);
@@ -234,8 +252,6 @@ static int __devexit ahci_remove(struct platform_device *pdev)clk_disable_unprepare (hpriv->clk);clk_put (hpriv->clk); } - -return 0 ; }#ifdef CONFIG_PM
Signature · 1 line
1.7.11.3
PATCH 4/14 libata: implement ata_platform_remove_one()
In reply to Brian NorrisThis relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
--- drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)
drivers/ata/libata-core.c +23 -0
@@ -67,6 +67,7 @@#include <linux/cdrom.h> #include <linux/ratelimit.h> #include <linux/pm_runtime.h> +#include <linux/platform_device.h> #include "libata.h" #include "libata-transport.h"
@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal +* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource +* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/ +int ata_platform_remove_one (struct platform_device *pdev) +{ +struct ata_host *host =platform_get_drvdata (pdev); + +ata_host_detach (host); + +return 0 ; +} +static int __init ata_parse_force_one (char **cur,struct ata_force_ent *force_ent,const char **reason)
@@ -6844,6 +6865,8 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +EXPORT_SYMBOL_GPL (ata_platform_remove_one); +EXPORT_SYMBOL_GPL (__ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_clear_desc);
include/linux/libata.h +4 -0
@@ -1103,6 +1103,10 @@ extern int ata_pci_device_resume(struct pci_dev *pdev);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +struct platform_device ; + +extern int ata_platform_remove_one (struct platform_device *pdev); +/* * ACPI - drivers/ata/libata-acpi.c */
Signature · 1 line
1.7.11.3
Re: [PATCH 04/14] libata: implement ata_platform_remove_one()
Hello.
Quoted 13 lines · Brian Norris
This relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
Signed-off-by Brian Norris <[email protected]>--- drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)drivers/ata/libata-core.c +0
-0
[...]
Quoted 10 lines
drivers/ata/libata-core.c +6
-0@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal +* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6369
Quoted 10 lines
drivers/ata/libata-core.c +10
-0+* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/ +int ata_platform_remove_one (struct platform_device *pdev) +{ +struct ata_host *host =platform_get_drvdata (pdev); + +ata_host_detach (host);
Indent with tabs, not spaces, as below.
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6376
Quoted 7 lines
drivers/ata/libata-core.c +4
-0+ +return 0 ; +} +static int __init ata_parse_force_one (char **cur,struct ata_force_ent *force_ent,const char **reason)
MBR, Sergei
Re: [PATCH 04/14] libata: implement ata_platform_remove_one()
Quoted 37 lines · Sergei Shtylyov
Quoted 15 lines · Brian Norris
This relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
Signed-off-by Brian Norris <[email protected]>--- drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)drivers/ata/libata-core.c +0
-0[...]
Quoted 17 lines
drivers/ata/libata-core.c +2
-0@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal
+ * @pdev: Platform device that was removed
+ *
+ * Platform layer indicates to libata via this hook that hot-unplug
or
+ * module unload event has occurred. Detach all ports. Resource
+ * release is handled via devres.
+ *
+ * LOCKING:
+ * Inherited from platform layer (may sleep).
+ */
Quoted 8 lines
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6369
Quoted 5 lines
drivers/ata/libata-core.c +5
-0+int ata_platform_remove_one (struct platform_device *pdev) +{ +struct ata_host *host =platform_get_drvdata (pdev); + +ata_host_detach (host);Indent with tabs, not spaces, as below.
I need to remind myself to run checkpatch.pl more often. Thanks for pointing this out. Will send v2. (Also, patch 12 had a pre-existing indentation problem; I'll fix it for the line I change.)
Brian
PATCH v2 4/14 libata: implement ata_platform_remove_one()
In reply to Brian NorrisThis relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
---
v2: fix whitespace
drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)
drivers/ata/libata-core.c +23 -0
@@ -67,6 +67,7 @@#include <linux/cdrom.h> #include <linux/ratelimit.h> #include <linux/pm_runtime.h> +#include <linux/platform_device.h> #include "libata.h" #include "libata-transport.h"
@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal +* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource +* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/ +int ata_platform_remove_one (struct platform_device *pdev) +{ +struct ata_host *host =platform_get_drvdata (pdev); + +ata_host_detach (host); + +return 0 ; +} +static int __init ata_parse_force_one (char **cur,struct ata_force_ent *force_ent,const char **reason)
@@ -6844,6 +6865,8 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +EXPORT_SYMBOL_GPL (ata_platform_remove_one); +EXPORT_SYMBOL_GPL (__ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_clear_desc);
include/linux/libata.h +4 -0
@@ -1103,6 +1103,10 @@ extern int ata_pci_device_resume(struct pci_dev *pdev);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +struct platform_device ; + +extern int ata_platform_remove_one (struct platform_device *pdev); +/* * ACPI - drivers/ata/libata-acpi.c */
Signature · 1 line
1.7.11.3
Re: [PATCH v2 04/14] libata: implement ata_platform_remove_one()
Quoted 15 lines · Brian Norris
This relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
Signed-off-by Brian Norris <[email protected]>---
v2: fix whitespacedrivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)drivers/ata/libata-core.c +0
-0
[...]
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6355
Quoted 6 lines
drivers/ata/libata-core.c +2
-0@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal
A space before hyphen is needed.
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6364
Quoted 9 lines
drivers/ata/libata-core.c +9
-0+* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource +* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/
I actually meant indenting with tabs within the comment too. :-)
WBR, Sergei
Re: [PATCH v2 04/14] libata: implement ata_platform_remove_one()
Quoted 20 lines · Sergei Shtylyov
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6355
Quoted 6 lines · Brian Norris
drivers/ata/libata-core.c +2
-0@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one- Platform layer callback for device removal A space before hyphen is needed.
drivers/ata/libata-core.c int ata_pci_device_resume(struct pci_dev *pdev) · line 6364
Quoted 9 lines
drivers/ata/libata-core.c +9
-0+* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource +* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/
Quoted 1 line
I actually meant indenting with tabs within the comment too. :-)
Ugh, more sloppiness, due to a bad copy&paste job, from ata_pci_remove_one(). Thanks for keeping your eyes open. v3 coming...
Brian
PATCH v3 4/14 libata: implement ata_platform_remove_one()
In reply to Brian NorrisThis relatively simple boiler-plate code is repeated in several platform drivers. We should implement a common version in libata.
---
v2: fix whitespace
v3: really fix whitespace. Thanks Sergei.
drivers/ata/libata-core.c | 23 +++++++++++++++++++++++ include/linux/libata.h | 4 ++++ 2 files changed, 27 insertions(+)
drivers/ata/libata-core.c +23 -0
@@ -67,6 +67,7 @@#include <linux/cdrom.h> #include <linux/ratelimit.h> #include <linux/pm_runtime.h> +#include <linux/platform_device.h> #include "libata.h" #include "libata-transport.h"
@@ -6350,6 +6351,26 @@ int ata_pci_device_resume(struct pci_dev *pdev)#endif /* CONFIG_PCI */ +/** +* ata_platform_remove_one - Platform layer callback for device removal +* @pdev: Platform device that was removed +* +* Platform layer indicates to libata via this hook that hot-unplug or +* module unload event has occurred. Detach all ports. Resource +* release is handled via devres. +* +* LOCKING: +* Inherited from platform layer (may sleep). +*/ +int ata_platform_remove_one (struct platform_device *pdev) +{ +struct ata_host *host =platform_get_drvdata (pdev); + +ata_host_detach (host); + +return 0 ; +} +static int __init ata_parse_force_one (char **cur,struct ata_force_ent *force_ent,const char **reason)
@@ -6844,6 +6865,8 @@ EXPORT_SYMBOL_GPL(ata_pci_device_resume);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +EXPORT_SYMBOL_GPL (ata_platform_remove_one); +EXPORT_SYMBOL_GPL (__ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_push_desc);EXPORT_SYMBOL_GPL (ata_ehi_clear_desc);
include/linux/libata.h +4 -0
@@ -1103,6 +1103,10 @@ extern int ata_pci_device_resume(struct pci_dev *pdev);#endif /* CONFIG_PM */ #endif /* CONFIG_PCI */ +struct platform_device ; + +extern int ata_platform_remove_one (struct platform_device *pdev); +/* * ACPI - drivers/ata/libata-acpi.c */
Signature · 1 line
1.7.11.3
PATCH 5/14 ahci_platform: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/ahci_platform.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/ata/ahci_platform.c +1 -11
@@ -229,16 +229,6 @@ free_clk:return rc; } -static int __devexit ahci_remove(struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -struct ata_host *host =dev_get_drvdata (dev); - -ata_host_detach (host); - -return 0 ; -} -static void ahci_host_stop (struct ata_host *host) {struct device *dev = host->dev;
@@ -343,7 +333,7 @@ MODULE_DEVICE_TABLE(of, ahci_of_match);static struct platform_driver ahci_driver = { .probe = ahci_probe, - .remove =__devexit_p (ahci_remove), + .remove = ata_platform_remove_one, .driver = { .name ="ahci" , .owner =THIS_MODULE ,
Signature · 1 line
1.7.11.3
PATCH 6/14 pata_ixp4xx_cf: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/pata_ixp4xx_cf.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-)
drivers/ata/pata_ixp4xx_cf.c +1 -10
@@ -187,22 +187,13 @@ static __devinit int ixp4xx_pata_probe(struct platform_device *pdev)return ata_host_activate (host, irq, ata_sff_interrupt,0 , &ixp4xx_sht); } -static __devexit int ixp4xx_pata_remove(struct platform_device *dev) -{ -struct ata_host *host =platform_get_drvdata (dev); - -ata_host_detach (host); - -return 0 ; -} -static struct platform_driver ixp4xx_pata_platform_driver = { .driver = { .name =DRV_NAME , .owner =THIS_MODULE , }, .probe = ixp4xx_pata_probe, - .remove =__devexit_p (ixp4xx_pata_remove), + .remove = ata_platform_remove_one, };module_platform_driver (ixp4xx_pata_platform_driver);
Signature · 1 line
1.7.11.3
PATCH 7/14 pata_mpc52xx: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/pata_mpc52xx.c | 17 +++-------------- 1 file changed, 3 insertions(+), 14 deletions(-)
drivers/ata/pata_mpc52xx.c +3 -14
@@ -663,18 +663,6 @@ mpc52xx_ata_init_one(struct device *dev, struct mpc52xx_ata_priv *priv, &mpc52xx_ata_sht); } -static struct mpc52xx_ata_priv * -mpc52xx_ata_remove_one (struct device *dev) -{ -struct ata_host *host =dev_get_drvdata (dev); -struct mpc52xx_ata_priv *priv = host->private_data; - -ata_host_detach (host); - -return priv; -} - -/* ======================================================================== */ /* OF Platform driver */ /* ======================================================================== */
@@ -815,11 +803,12 @@ mpc52xx_ata_probe(struct platform_device *op)static int mpc52xx_ata_remove (struct platform_device *op) { -struct mpc52xx_ata_priv *priv; +struct ata_host *host =platform_get_drvdata (op); +struct mpc52xx_ata_priv *priv = host->private_data;int task_irq;/* Deregister the ATA interface */ - priv =mpc52xx_ata_remove_one (&op->dev); +ata_platform_remove_one (op);/* Clean up DMA */ task_irq =bcom_get_task_irq (priv->dmatsk);
Signature · 1 line
1.7.11.3
PATCH 8/14 pata_of_platform: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/pata_of_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/ata/pata_of_platform.c +1 -6
@@ -76,11 +76,6 @@ static int __devinit pata_of_platform_probe(struct platform_device *ofdev) reg_shift, pio_mask); } -static int __devexit pata_of_platform_remove(struct platform_device *ofdev) -{ -return __pata_platform_remove (&ofdev->dev); -} -static struct of_device_id pata_of_platform_match[] = { { .compatible ="ata-generic" , }, { .compatible ="electra-ide" , },
@@ -95,7 +90,7 @@ static struct platform_driver pata_of_platform_driver = { .of_match_table = pata_of_platform_match, }, .probe = pata_of_platform_probe, - .remove = __devexit_p(pata_of_platform_remove), + .remove = ata_platform_remove_one, };module_platform_driver (pata_of_platform_driver);
Signature · 1 line
1.7.11.3
PATCH 9/14 pata_platform: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/pata_platform.c | 7 +------ 1 file changed, 1 insertion(+), 6 deletions(-)
drivers/ata/pata_platform.c +1 -6
@@ -242,14 +242,9 @@ static int __devinit pata_platform_probe(struct platform_device *pdev) pio_mask); } -static int __devexit pata_platform_remove(struct platform_device *pdev) -{ -return __pata_platform_remove (&pdev->dev); -} -static struct platform_driver pata_platform_driver = { .probe = pata_platform_probe, - .remove =__devexit_p (pata_platform_remove), + .remove = ata_platform_remove_one, .driver = { .name =DRV_NAME , .owner =THIS_MODULE ,
Signature · 1 line
1.7.11.3
PATCH 10/14 ata_platform: remove unused remove function
In reply to Brian NorrisAll users of __pata_platform_remove() have been converted to utilize the common ata_platform_remove_one().
--- drivers/ata/pata_platform.c | 17 ----------------- include/linux/ata_platform.h | 2 -- 2 files changed, 19 deletions(-)
drivers/ata/pata_platform.c +0 -17
@@ -178,23 +178,6 @@ int __devinit __pata_platform_probe(struct device *dev, }EXPORT_SYMBOL_GPL (__pata_platform_probe); -/** -* __pata_platform_remove - unplug a platform interface -* @dev: device -* -* A platform bus ATA device has been unplugged. Perform the needed -* cleanup. Also called on module unload for any active devices. -*/ -int __pata_platform_remove (struct device *dev) -{ -struct ata_host *host =dev_get_drvdata (dev); - -ata_host_detach (host); - -return 0 ; -} -EXPORT_SYMBOL_GPL (__pata_platform_remove); -static int __devinit pata_platform_probe (struct platform_device *pdev) {struct resource *io_res;
include/linux/ata_platform.h +0 -2
@@ -22,8 +22,6 @@ extern int __devinit __pata_platform_probe(struct device *dev,unsigned int ioport_shift, int __pio_mask); -extern int __devexit __pata_platform_remove(struct device *dev); -/* * Marvell SATA private data */
Signature · 1 line
1.7.11.3
PATCH 11/14 pata_palmld: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/pata_palmld.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
drivers/ata/pata_palmld.c +1 -3
@@ -111,9 +111,7 @@ err1: static __devexit int palmld_pata_remove(struct platform_device *dev) { -struct ata_host *host =platform_get_drvdata (dev); - -ata_host_detach (host); +ata_platform_remove_one (dev);/* power down the HDD */ gpio_set_value (GPIO_NR_PALMLD_IDE_PWEN ,0 );
Signature · 1 line
1.7.11.3
PATCH 12/14 sata_highbank: utilize common ata_platform_remove_one()
In reply to Brian Norris--- drivers/ata/sata_highbank.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/ata/sata_highbank.c +1 -11
@@ -368,16 +368,6 @@ err0:return rc; } -static int __devexit ahci_highbank_remove(struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -struct ata_host *host =dev_get_drvdata (dev); - -ata_host_detach (host); - -return 0 ; -} -#ifdef CONFIG_PM static int ahci_highbank_suspend (struct device *dev) {
@@ -432,7 +422,7 @@ SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, ahci_highbank_suspend, ahci_highbank_resume);static struct platform_driver ahci_highbank_driver = { - .remove =__devexit_p (ahci_highbank_remove), + .remove = ata_platform_remove_one, .driver = { .name ="highbank-ahci" , .owner =THIS_MODULE ,
Signature · 1 line
1.7.11.3
PATCH v2 12/14 sata_highbank: utilize common ata_platform_remove_one()
---
v2: fix whitespace
drivers/ata/sata_highbank.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
drivers/ata/sata_highbank.c +1 -11
@@ -368,16 +368,6 @@ err0:return rc; } -static int __devexit ahci_highbank_remove(struct platform_device *pdev) -{ -struct device *dev = &pdev->dev; -struct ata_host *host =dev_get_drvdata (dev); - -ata_host_detach (host); - -return 0 ; -} -#ifdef CONFIG_PM static int ahci_highbank_suspend (struct device *dev) {
@@ -432,7 +422,7 @@ SIMPLE_DEV_PM_OPS(ahci_highbank_pm_ops, ahci_highbank_suspend, ahci_highbank_resume);static struct platform_driver ahci_highbank_driver = { - .remove =__devexit_p (ahci_highbank_remove), + .remove = ata_platform_remove_one, .driver = { .name ="highbank-ahci" , .owner =THIS_MODULE ,
Signature · 1 line
1.7.11.3
Re: [PATCH v2 12/14] sata_highbank: utilize common ata_platform_remove_one()
Quoted 6 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>---
v2: fix whitespacedrivers/ata/sata_highbank.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)
applied patches 1-11
patch #12 failed to apply (even manually), so I stopped there
Re: [PATCH v2 12/14] sata_highbank: utilize common ata_platform_remove_one()
Quoted 11 lines · Jeff Garzik
Quoted 7 lines · Brian Norris
Signed-off-by Brian Norris <[email protected]>---
v2: fix whitespacedrivers/ata/sata_highbank.c | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-)applied patches 1-11
Thanks.
Quoted 1 line
patch #12 failed to apply (even manually), so I stopped there
There was just a trivial change to the #ifdef next to the (unrelated, but adjacent) ahci_highbank_suspend function. I'll resend 12-14, as a v2 series, plus a (new) compile-error fix for pata_of_platform.
BTW, Tejun posted his "Ack" in reply to the original series. I'll include it in my version 2 of the original patches, but I noticed you didn't add it in libata-dev.git.
Brian
PATCH 13/14 pata_octeon_cf: perform host detach, removal on exit
In reply to Brian NorrisThis driver does not detach and remove its ata_host properly on device removal. Add the common .remove helper.
Note: I do not know this driver well enough to ensure this is the right thing to do. Merge this patch with caution.
--- drivers/ata/pata_octeon_cf.c | 1 + 1 file changed, 1 insertion(+)
drivers/ata/pata_octeon_cf.c +1 -0
@@ -921,6 +921,7 @@ free_cf_port:static struct platform_driver octeon_cf_driver = { .probe = octeon_cf_probe, + .remove = ata_platform_remove_one, .driver = { .name =DRV_NAME , .owner =THIS_MODULE ,
Signature · 1 line
1.7.11.3
PATCH 14/14 libata: use pci_get_drvdata() helper
In reply to Brian Norris--- drivers/ata/libata-core.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-)
drivers/ata/libata-core.c +3 -4
@@ -6255,8 +6255,7 @@ void ata_host_detach(struct ata_host *host)*/ void ata_pci_remove_one (struct pci_dev *pdev) { -struct device *dev = &pdev->dev; -struct ata_host *host =dev_get_drvdata (dev); +struct ata_host *host =pci_get_drvdata (pdev);ata_host_detach (host); }
@@ -6325,7 +6324,7 @@ int ata_pci_device_do_resume(struct pci_dev *pdev)int ata_pci_device_suspend (struct pci_dev *pdev,pm_message_t mesg) { -struct ata_host *host =dev_get_drvdata (&pdev->dev); +struct ata_host *host =pci_get_drvdata (pdev);int rc =0 ; rc =ata_host_suspend (host, mesg);
@@ -6339,7 +6338,7 @@ int ata_pci_device_suspend(struct pci_dev *pdev, pm_message_t mesg)int ata_pci_device_resume (struct pci_dev *pdev) { -struct ata_host *host =dev_get_drvdata (&pdev->dev); +struct ata_host *host =pci_get_drvdata (pdev);int rc; rc =ata_pci_device_do_resume (pdev);
Signature · 1 line
1.7.11.3
Hello,
Quoted 8 lines · Brian Norris
(1) Allows
ahci_platformto unbind a device from the driver. This is useful for allowing total power-off of the device, for instance.
(2) Addsahci_platformata_port_operations.host_stop()hook, so that platform-deviceexit()can power down the device at the appropriate point in the removal sequence.
(3) Adds a commonata_platform_remove_one()function so that we don't re-implement a simple host detach across many platform drivers
(4) Switches many platform drivers to the new .remove function from (3)
I personally would have converted all drivers in one patch but I think either way is fine. Other than the indentation thing, for all patches in this series.
Quoted 4 lines
P.S. A related but distinct issue: someting is still broken in theata_host_detach()function, for shutting down the host, spinning down disks, etc. When I rmmod the driver or unbind the device, I get the following failures, and the HDD doesn't spin down:
That's because detaching the driver is handled basically as controller hot unplug. By the time SCSI is noticing the SCSI devices are going away, the corresponding ATA devices are already away. It's kinda natural to implement that way. Is this an actual problem?
Thanks.
Signature · 1 line
tejun
Quoted 10 lines · Tejun Heo
Quoted 8 lines · Brian Norris
(1) Allows
ahci_platformto unbind a device from the driver. This is useful for allowing total power-off of the device, for instance.
(2) Addsahci_platformata_port_operations.host_stop()hook, so that platform-deviceexit()can power down the device at the appropriate point in the removal sequence.
(3) Adds a commonata_platform_remove_one()function so that we don't re-implement a simple host detach across many platform drivers
(4) Switches many platform drivers to the new .remove function from (3)
Quoted 5 lines
I personally would have converted all drivers in one patch but I think either way is fine. Other than the indentation thing, for all patches in this series.
Acked-by Tejun Heo <[email protected]>
Thanks. I'll reply to the indentation patch with a v2.
Quoted 9 lines
Quoted 4 lines
P.S. A related but distinct issue: someting is still broken in theata_host_detach()function, for shutting down the host, spinning down disks, etc. When I rmmod the driver or unbind the device, I get the following failures, and the HDD doesn't spin down:That's because detaching the driver is handled basically as controller hot unplug. By the time SCSI is noticing the SCSI devices are going away, the corresponding ATA devices are already away. It's kinda natural to implement that way. Is this an actual problem?
Yes. The HDD doesn't spin down. I'm removing the device because I want some power savings, so I would expect to spin down the disk.
Brian
Hello,
Quoted 7 lines · Brian Norris
Quoted 4 lines
That's because detaching the driver is handled basically as controller hot unplug. By the time SCSI is noticing the SCSI devices are going away, the corresponding ATA devices are already away. It's kinda natural to implement that way. Is this an actual problem?
Yes. The HDD doesn't spin down. I'm removing the device because I want some power savings, so I would expect to spin down the disk.
Detach the hdds first then. You're essentially yanking out the controller. The high level driver naturally loses control of the device before it can do anything about it.
Thanks.
Signature · 1 line
tejun