From mboxrd@z Thu Jan 1 00:00:00 1970 From: Kevin Hilman Subject: Re: [PATCH 7/7] ARM: OMAP2+: Fix omap_device for module reload on PM runtime forbid Date: Thu, 11 Feb 2016 17:13:37 -0800 Message-ID: <7hbn7m688u.fsf@baylibre.com> References: <1455145370-20301-1-git-send-email-tony@atomide.com> <1455145370-20301-8-git-send-email-tony@atomide.com> Mime-Version: 1.0 Content-Type: text/plain Return-path: In-Reply-To: <1455145370-20301-8-git-send-email-tony@atomide.com> (Tony Lindgren's message of "Wed, 10 Feb 2016 15:02:50 -0800") Sender: linux-mmc-owner@vger.kernel.org To: Tony Lindgren Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, Alan Stern , Nishanth Menon , "Rafael J . Wysocki" , Tero Kristo , Greg Kroah-Hartman , linux-i2c@vger.kernel.org, linux-mmc@vger.kernel.org, linux-serial@vger.kernel.org, linux-spi@vger.kernel.org, Mark Brown , Peter Hurley , Ulf Hansson , Wolfram Sang List-Id: linux-i2c@vger.kernel.org Tony Lindgren 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 > Cc: Kevin Hilman > Cc: Nishanth Menon > Cc: Rafael J. Wysocki > Cc: Tero Kristo > Reported-by: Ulf Hansson > Signed-off-by: Tony Lindgren Acked-by: Kevin Hilman > --- > 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); From mboxrd@z Thu Jan 1 00:00:00 1970 From: khilman@baylibre.com (Kevin Hilman) Date: Thu, 11 Feb 2016 17:13:37 -0800 Subject: [PATCH 7/7] ARM: OMAP2+: Fix omap_device for module reload on PM runtime forbid In-Reply-To: <1455145370-20301-8-git-send-email-tony@atomide.com> (Tony Lindgren's message of "Wed, 10 Feb 2016 15:02:50 -0800") References: <1455145370-20301-1-git-send-email-tony@atomide.com> <1455145370-20301-8-git-send-email-tony@atomide.com> Message-ID: <7hbn7m688u.fsf@baylibre.com> To: linux-arm-kernel@lists.infradead.org List-Id: linux-arm-kernel.lists.infradead.org Tony Lindgren 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 > Cc: Kevin Hilman > Cc: Nishanth Menon > Cc: Rafael J. Wysocki > Cc: Tero Kristo > Reported-by: Ulf Hansson > Signed-off-by: Tony Lindgren Acked-by: Kevin Hilman > --- > 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);