From: Kevin Hilman <hidden> Date: 2012-07-10 23:02:02
Use the bus notifier to keep track of driver bound status by adding a
new internal field to struct omap_device: _driver_staus.
This will be useful for follow-up patches which need to know whether
or not a driver is bound in order to make intelligent omap_device
enable/idle decisions.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <redacted>
---
arch/arm/plat-omap/include/plat/omap_device.h | 2 ++
arch/arm/plat-omap/omap_device.c | 14 +++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
@@ -385,17 +385,21 @@ static int _omap_device_notifier_call(struct notifier_block *nb,unsignedlongevent,void*dev){structplatform_device*pdev=to_platform_device(dev);+structomap_device*od;switch(event){-caseBUS_NOTIFY_ADD_DEVICE:-if(pdev->dev.of_node)-omap_device_build_from_dt(pdev);-break;-caseBUS_NOTIFY_DEL_DEVICE:if(pdev->archdata.od)omap_device_delete(pdev->archdata.od);break;+caseBUS_NOTIFY_ADD_DEVICE:+if(pdev->dev.of_node)+omap_device_build_from_dt(pdev);+/* fall through */+default:+od=to_omap_device(pdev);+if(od)+od->_driver_status=event;}returnNOTIFY_DONE;
From: Kevin Hilman <hidden> Date: 2012-07-10 23:02:03
Currently, the omap_device PM domain layer uses the late suspend and
early resume callbacks to ensure devices are in their low power
states.
However, this is attempted even in cases where a driver probe has
failed. If a driver's ->probe() method fails, the driver is likely in
a state where it is not expecting its runtime PM callbacks to be
called, yet currently the omap_device PM domain code attempts to call
the drivers callbacks.
To fix, use the omap_device driver_status field to check whether a
driver is bound to the omap_device before attempting to trigger driver
callbacks.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <redacted>
---
arch/arm/plat-omap/omap_device.c | 4 ++++
1 file changed, 4 insertions(+)
@@ -756,6 +756,10 @@ static int _od_suspend_noirq(struct device *dev)structomap_device*od=to_omap_device(pdev);intret;+/* Don't attempt late suspend on a driver that is not bound */+if(od->_driver_status!=BUS_NOTIFY_BOUND_DRIVER)+return0;+ret=pm_generic_suspend_noirq(dev);if(!ret&&!pm_runtime_status_suspended(dev)){
From: Kevin Hilman <hidden> Date: 2012-07-10 23:02:04
Under some circumstances, drivers may leave an omap_device enabled due
to driver programming errors, or due to a failure in the drivers
probe method.
Using the recently added omap_device driver_status field, we can
detect conditions where an omap_device is enabled but has no driver
bound and then ensure that the device is properly idled until it can
be probed again.
The goal of this feature is not only to detect and warn on these error
conditions, but also to ensure that devices are properly put in
low-power states so they do not prevent SoC-wide low-power states.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <redacted>
---
arch/arm/plat-omap/omap_device.c | 30 ++++++++++++++++++++++++++++++
1 file changed, 30 insertions(+)
@@ -1133,3 +1133,33 @@ static int __init omap_device_init(void)return0;}core_initcall(omap_device_init);++staticint__initomap_device_late_idle(structdevice*dev,void*data)+{+structplatform_device*pdev=to_platform_device(dev);+structomap_device*od=to_omap_device(pdev);++if(!od)+return0;++/* +*Ifomap_devicestateisenabled,buthasnodriverbound,+*idleit.+*/+if(od->_driver_status!=BUS_NOTIFY_BOUND_DRIVER){+if(od->_state==OMAP_DEVICE_STATE_ENABLED){+dev_warn(dev,"%s: enabled but no driver. Idling\n",+__func__);+omap_device_idle(pdev);+}+}++return0;+}++staticint__initomap_device_late_init(void)+{+bus_for_each_dev(&platform_bus_type,NULL,NULL,omap_device_late_idle);+return0;+}+late_initcall(omap_device_late_init);
Hi Kevin
a couple of minor comments
On Tue, 10 Jul 2012, Kevin Hilman wrote:
Use the bus notifier to keep track of driver bound status by adding a
new internal field to struct omap_device: _driver_staus.
"_driver_status"
quoted hunk
This will be useful for follow-up patches which need to know whether
or not a driver is bound in order to make intelligent omap_device
enable/idle decisions.
Cc: Paul Walmsley <paul@pwsan.com>
Signed-off-by: Kevin Hilman <redacted>
---
arch/arm/plat-omap/include/plat/omap_device.h | 2 ++
arch/arm/plat-omap/omap_device.c | 14 +++++++++-----
2 files changed, 11 insertions(+), 5 deletions(-)
@@ -385,17 +385,21 @@ static int _omap_device_notifier_call(struct notifier_block *nb,unsignedlongevent,void*dev){structplatform_device*pdev=to_platform_device(dev);+structomap_device*od;switch(event){-caseBUS_NOTIFY_ADD_DEVICE:-if(pdev->dev.of_node)-omap_device_build_from_dt(pdev);-break;-caseBUS_NOTIFY_DEL_DEVICE:if(pdev->archdata.od)omap_device_delete(pdev->archdata.od);break;+caseBUS_NOTIFY_ADD_DEVICE:+if(pdev->dev.of_node)+omap_device_build_from_dt(pdev);+/* fall through */+default:+od=to_omap_device(pdev);+if(od)+od->_driver_status=event;
_driver_status is a u8, but event is an unsigned long. Might be worth
adding a WARN() to complain if event is greater than (2^8)-1.