Re: [PATCH 2/5] PM / Wakeirq: Add automated device wake IRQ handling

From: Tony Lindgren
Date: Thu May 14 2015 - 17:15:13 EST


* Tony Lindgren <tony@xxxxxxxxxxx> [150514 09:01]:
> * Felipe Balbi <balbi@xxxxxx> [150513 19:09]:
> > > +void dev_pm_enable_wake_irq(struct device *dev)
> > > +{
> > > + struct wake_irq *wirq = dev->power.wakeirq;
> > > +
> > > + if (wirq && wirq->manage_irq)
> > > + enable_irq(wirq->irq);
> > > +}
> > > +EXPORT_SYMBOL_GPL(dev_pm_enable_wake_irq);
> >
> > you probably want to enable dev_pm_enable_wake_irq() automatically for
> > from rpm_suspend(). According to runtime_pm documentation, wakeup should
> > always be enabled for runtime suspended devices. I didn't really look
> > through the whole thing yet to know if you did call it or not.
>
> Yes I think we can also automate that part, I've been playing with an
> additional patch doing that for pm runtime. Been still thinking if
> there's any need to manage that in the consomer driver, I guess not.

Here's what that would roughly look and now I also remember why
I did not include it. It adds currently extra checks also for
devices not using dedicated wakeirqs. But basically this would
allow leaving out the enable/disable PM runtime calls from drivers.

Regards,

Tony

8< -------------------
--- a/drivers/base/power/runtime.c
+++ b/drivers/base/power/runtime.c
@@ -10,6 +10,7 @@
#include <linux/sched.h>
#include <linux/export.h>
#include <linux/pm_runtime.h>
+#include <linux/pm_wakeirq.h>
#include <trace/events/rpm.h>
#include "power.h"

@@ -514,6 +515,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)

callback = RPM_GET_CALLBACK(dev, runtime_suspend);

+ dev_pm_enable_wake_irq(dev);
retval = rpm_callback(callback, dev);
if (retval)
goto fail;
@@ -552,6 +554,7 @@ static int rpm_suspend(struct device *dev, int rpmflags)
return retval;

fail:
+ dev_pm_disable_wake_irq(dev);
__update_runtime_status(dev, RPM_ACTIVE);
dev->power.deferred_resume = false;
wake_up_all(&dev->power.wait_queue);
@@ -734,10 +737,12 @@ static int rpm_resume(struct device *dev, int rpmflags)

callback = RPM_GET_CALLBACK(dev, runtime_resume);

+ dev_pm_disable_wake_irq(dev);
retval = rpm_callback(callback, dev);
if (retval) {
__update_runtime_status(dev, RPM_SUSPENDED);
pm_runtime_cancel_pending(dev);
+ dev_pm_enable_wake_irq(dev);
} else {
no_callback:
__update_runtime_status(dev, RPM_ACTIVE);
@@ -1427,6 +1432,7 @@ int pm_runtime_force_suspend(struct device *dev)
goto err;
}

+ dev_pm_enable_wake_irq(dev);
ret = callback(dev);
if (ret)
goto err;
@@ -1434,6 +1440,7 @@ int pm_runtime_force_suspend(struct device *dev)
pm_runtime_set_suspended(dev);
return 0;
err:
+ dev_pm_disable_wake_irq(dev);
pm_runtime_enable(dev);
return ret;
}
@@ -1463,6 +1470,7 @@ int pm_runtime_force_resume(struct device *dev)
goto out;
}

+ dev_pm_disable_wake_irq(dev);
ret = callback(dev);
if (ret)
goto out;
@@ -1470,6 +1478,7 @@ int pm_runtime_force_resume(struct device *dev)
pm_runtime_set_active(dev);
pm_runtime_mark_last_busy(dev);
out:
+ dev_pm_enable_wake_irq(dev);
pm_runtime_enable(dev);
return ret;
}
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/