diff mbox

[7/7] ARM: OMAP2+: Fix omap_device for module reload on PM runtime forbid

Message ID 1455145370-20301-8-git-send-email-tony@atomide.com (mailing list archive)
State New, archived
Headers show

Commit Message

Tony Lindgren Feb. 10, 2016, 11:02 p.m. UTC
If a driver PM runtime is disabled via sysfs, and the module is
unloaded, PM runtime can't do anything to disable the device. Let's
let the interconnect disable the device on BUS_NOTIFY_UNBOUND_DRIVER.

Otherwise omap_device will produce and error on the following module
reload. This can be easily tested with something like:

# modprobe omap_hsmmc
# echo on > /sys/devices/platform/68000000.ocp/4809c000.mmc/power/control
# rmmod omap_hsmmc
# modprobe omap_hsmmc

Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Kevin Hilman <khilman@baylibre.com>
Cc: Nishanth Menon <nm@ti.com>
Cc: Rafael J. Wysocki <rafael@kernel.org>
Cc: Tero Kristo <t-kristo@ti.com>
Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
Signed-off-by: Tony Lindgren <tony@atomide.com>
---
 arch/arm/mach-omap2/omap_device.c | 10 ++++++++++
 1 file changed, 10 insertions(+)

Comments

Kevin Hilman Feb. 12, 2016, 1:13 a.m. UTC | #1
Tony Lindgren <tony@atomide.com> writes:

> If a driver PM runtime is disabled via sysfs, and the module is
> unloaded, PM runtime can't do anything to disable the device. Let's
> let the interconnect disable the device on BUS_NOTIFY_UNBOUND_DRIVER.
>
> Otherwise omap_device will produce and error on the following module
> reload. This can be easily tested with something like:
>
> # modprobe omap_hsmmc
> # echo on > /sys/devices/platform/68000000.ocp/4809c000.mmc/power/control
> # rmmod omap_hsmmc
> # modprobe omap_hsmmc
>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Rafael J. Wysocki <rafael@kernel.org>
> Cc: Tero Kristo <t-kristo@ti.com>
> Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Acked-by: Kevin Hilman <khilman@baylibre.com>

> ---
>  arch/arm/mach-omap2/omap_device.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
> index ebd8369..f7ff3b9 100644
> --- a/arch/arm/mach-omap2/omap_device.c
> +++ b/arch/arm/mach-omap2/omap_device.c
> @@ -191,12 +191,22 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
>  {
>  	struct platform_device *pdev = to_platform_device(dev);
>  	struct omap_device *od;
> +	int err;
>  
>  	switch (event) {
>  	case BUS_NOTIFY_DEL_DEVICE:
>  		if (pdev->archdata.od)
>  			omap_device_delete(pdev->archdata.od);
>  		break;
> +	case BUS_NOTIFY_UNBOUND_DRIVER:
> +		od = to_omap_device(pdev);
> +		if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED)) {
> +			dev_info(dev, "enabled after unload, idling\n");
> +			err = omap_device_idle(pdev);
> +			if (err)
> +				dev_err(dev, "failed to idle\n");
> +		}
> +		break;
>  	case BUS_NOTIFY_ADD_DEVICE:
>  		if (pdev->dev.of_node)
>  			omap_device_build_from_dt(pdev);
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Ulf Hansson Feb. 12, 2016, 12:54 p.m. UTC | #2
On 11 February 2016 at 00:02, Tony Lindgren <tony@atomide.com> wrote:
> If a driver PM runtime is disabled via sysfs, and the module is
> unloaded, PM runtime can't do anything to disable the device. Let's
> let the interconnect disable the device on BUS_NOTIFY_UNBOUND_DRIVER.
>
> Otherwise omap_device will produce and error on the following module
> reload. This can be easily tested with something like:
>
> # modprobe omap_hsmmc
> # echo on > /sys/devices/platform/68000000.ocp/4809c000.mmc/power/control
> # rmmod omap_hsmmc
> # modprobe omap_hsmmc
>
> Cc: Alan Stern <stern@rowland.harvard.edu>
> Cc: Kevin Hilman <khilman@baylibre.com>
> Cc: Nishanth Menon <nm@ti.com>
> Cc: Rafael J. Wysocki <rafael@kernel.org>
> Cc: Tero Kristo <t-kristo@ti.com>
> Reported-by: Ulf Hansson <ulf.hansson@linaro.org>
> Signed-off-by: Tony Lindgren <tony@atomide.com>

Acked-by: Ulf Hansson <ulf.hansson@linaro.org>

Kind regards
Uffe


> ---
>  arch/arm/mach-omap2/omap_device.c | 10 ++++++++++
>  1 file changed, 10 insertions(+)
>
> diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
> index ebd8369..f7ff3b9 100644
> --- a/arch/arm/mach-omap2/omap_device.c
> +++ b/arch/arm/mach-omap2/omap_device.c
> @@ -191,12 +191,22 @@ static int _omap_device_notifier_call(struct notifier_block *nb,
>  {
>         struct platform_device *pdev = to_platform_device(dev);
>         struct omap_device *od;
> +       int err;
>
>         switch (event) {
>         case BUS_NOTIFY_DEL_DEVICE:
>                 if (pdev->archdata.od)
>                         omap_device_delete(pdev->archdata.od);
>                 break;
> +       case BUS_NOTIFY_UNBOUND_DRIVER:
> +               od = to_omap_device(pdev);
> +               if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED)) {
> +                       dev_info(dev, "enabled after unload, idling\n");
> +                       err = omap_device_idle(pdev);
> +                       if (err)
> +                               dev_err(dev, "failed to idle\n");
> +               }
> +               break;
>         case BUS_NOTIFY_ADD_DEVICE:
>                 if (pdev->dev.of_node)
>                         omap_device_build_from_dt(pdev);
> --
> 2.7.0
>
--
To unsubscribe from this list: send the line "unsubscribe linux-mmc" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c
index ebd8369..f7ff3b9 100644
--- a/arch/arm/mach-omap2/omap_device.c
+++ b/arch/arm/mach-omap2/omap_device.c
@@ -191,12 +191,22 @@  static int _omap_device_notifier_call(struct notifier_block *nb,
 {
 	struct platform_device *pdev = to_platform_device(dev);
 	struct omap_device *od;
+	int err;
 
 	switch (event) {
 	case BUS_NOTIFY_DEL_DEVICE:
 		if (pdev->archdata.od)
 			omap_device_delete(pdev->archdata.od);
 		break;
+	case BUS_NOTIFY_UNBOUND_DRIVER:
+		od = to_omap_device(pdev);
+		if (od && (od->_state == OMAP_DEVICE_STATE_ENABLED)) {
+			dev_info(dev, "enabled after unload, idling\n");
+			err = omap_device_idle(pdev);
+			if (err)
+				dev_err(dev, "failed to idle\n");
+		}
+		break;
 	case BUS_NOTIFY_ADD_DEVICE:
 		if (pdev->dev.of_node)
 			omap_device_build_from_dt(pdev);