From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
To: Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org>
Cc: Nishanth Menon <nm-l0cyMroinI0@public.gmane.org>,
lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org,
LKML <linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org>,
devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Keerthy <j-keerthy-l0cyMroinI0@public.gmane.org>,
Mark Brown <broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>,
Samuel Ortiz <sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>,
linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
LAK
<linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org>,
Kevin Hilman <khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Thu, 6 Nov 2014 12:46:30 -0800 [thread overview]
Message-ID: <20141106204629.GF31454@atomide.com> (raw)
In-Reply-To: <20141002034345.GH3122-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
Thomas,
Any comments on the patch below? Let me know if you want to keep the
devm stuff out of kernel/irq/manage.c.
* Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org> [141001 20:45]:
> Hi Thomas,
>
> * Thomas Gleixner <tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org> [140919 12:47]:
> >
> > The wakeup handler is supposed to bring the thing out of deep sleep
> > and nothing else. All you want it to do is to mask itself and save the
> > information that the real device irq is pending.
> >
> > A stub handler for the wakeup irq is enough. We can have that in the
> > irq/pm core and all it would do is simply:
>
> Here's a patch along the lines of what you described, hopefully that's
> fairly close to what you had in mind.
>
> I also did play with the replaying of the interrupts but I don't think
> that's needed. Well at least not for the omap case. I added some
> comments about that to the code.
>
> So far I've tested with the omap-serial and omap_hsmmc drivers. The
> serial driver does not have any status as the device is powered off.
> So replaying of the interrupt does not help there, we need to wait for
> the next event anyways.
>
> Then with omap_hsmmc the SDIO interrupt on dat1 line is level
> sensitive and is noticed after the MMC controller is powered on
> again. So no replaying of the device interrupt needed here either.
>
> I still have not tested the MMC remux lines to GPIO for wake-up
> events that's also needed for some omaps.
>
> Regards,
>
> Tony
>
> 8<-----------
> From: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
> Date: Wed, 1 Oct 2014 14:56:35 -0700
> Subject: [PATCH] genirq: Add support for wake-up interrupts to fix irq reentry issues in drivers
>
> As pointed out by Thomas Gleixner, at least omap wake-up interrupts
> have an issue with re-entrant interrupts because the wake-up interrupts
> are now handled as a secondary interrupt controller. Further, the
> wake-up interrupt just needs wake the system at least for omaps. So we
> should just make the wake-up interrupt handling generic.
>
> Note that at least initially we are keeping things simple by assuming the
> wake-up interrupt is level sensitive, and the device pm_runtime_resume()
> can deal with the situation, and no replaying of the lost device interrupts
> is needed.
>
> After tinkering with replaying of the lost device interrupts, my opinion is
> that it should be avoided because of the issues listed in the comments of
> this patch.
>
> Signed-off-by: Tony Lindgren <tony-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
>
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -139,11 +139,15 @@ extern int __must_check
> request_percpu_irq(unsigned int irq, irq_handler_t handler,
> const char *devname, void __percpu *percpu_dev_id);
>
> +struct device;
> +
> +extern int __must_check
> +request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void free_irq(unsigned int, void *);
> extern void free_percpu_irq(unsigned int, void __percpu *);
>
> -struct device;
> -
> extern int __must_check
> devm_request_threaded_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, irq_handler_t thread_fn,
> @@ -163,6 +167,10 @@ devm_request_any_context_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, unsigned long irqflags,
> const char *devname, void *dev_id);
>
> +extern int __must_check
> +devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
>
> /*
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -14,6 +14,7 @@
> #include <linux/module.h>
> #include <linux/random.h>
> #include <linux/interrupt.h>
> +#include <linux/pm_runtime.h>
> #include <linux/slab.h>
> #include <linux/sched.h>
> #include <linux/sched/rt.h>
> @@ -1578,6 +1579,111 @@ int request_any_context_irq(unsigned int irq, irq_handler_t handler,
> }
> EXPORT_SYMBOL_GPL(request_any_context_irq);
>
> +/**
> + * handle_wakeirq_thread - call device runtime pm calls on wake-up interrupt
> + * @wakeirq: device specific wake-up interrupt
> + * @dev_id: struct device entry
> + */
> +static irqreturn_t handle_wakeirq_thread(int wakeirq, void *dev_id)
> +{
> + struct device *dev = dev_id;
> + irqreturn_t ret = IRQ_NONE;
> +
> + if (pm_runtime_suspended(dev)) {
> + pm_runtime_mark_last_busy(dev);
> + pm_request_resume(dev);
> + ret = IRQ_HANDLED;
> + }
> +
> + return ret;
> +}
> +
> +/**
> + * setup_wakeirq - allocate a wake-up interrupt for a device
> + * @dev: device to wake up
> + * @wakeirq: interrupt that wakes up the device
> + * @wakeflags: flags to pass to the interrupt handler
> + * @devm: use devm
> + *
> + * Note that the wake-up interrupt starts disabled. The wake-up interrupt
> + * is typically enabled from the device pm_runtime_suspend() and disabled
> + * again in the device pm_runtime_resume(). For runtime PM, the wake-up
> + * interrupt should be always enabled, and for device suspend and resume,
> + * the wake-up interrupt should be enabled depending on the device specific
> + * configuration for device_can_wakeup().
> + *
> + * Note also that we are not resending the lost device interrupts.
> + * We assume that the wake-up interrupt just needs to wake-up the device,
> + * and then device pm_runtime_resume() can deal with the situation.
> + *
> + * There are at least the following reasons to not resend the lost device
> + * interrupts automatically based on the wake-up interrupt:
> + *
> + * 1. There can be interrupt reentry issues calling the device interrupt
> + * based on the wake-up interrupt if done in the device driver. It
> + * could be done with check_irq_resend() after checking the device
> + * interrupt mask if we really wanted to though.
> + *
> + * 2. The device interrupt handler would need to be set up properly with
> + * pm_runtime_irq_safe(). Ideally you don't want to call pm_runtime
> + * calls from the device interrupt handler at all.
> + *
> + * 3. The IRQ subsystem may not know if it's safe to call the device
> + * interrupt unless the driver updates the interrupt status with
> + * disable_irq() and enable_irq() in addition to just disabling the
> + * interrupt at the hardware level in the device registers.
> + *
> + * So if replaying the lost device interrupts is absolutely needed from the
> + * hardware point of view, it's probably best to set up a completely
> + * separate wake-up interrupt handler for the wake-up interrupt in the
> + * device driver because of the reasons above.
> + */
> +static int setup_wakeirq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags, bool devm)
> +{
> + int ret;
> +
> + if (!(dev && wakeirq)) {
> + pr_err("Missing device or wakeirq for %s irq %d\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + if (!(wakeflags &
> + (IRQF_TRIGGER_LOW | IRQF_TRIGGER_HIGH | IRQF_ONESHOT))) {
> + pr_err("Invalid wakeirq for %s irq %d, must be level oneshot\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + irq_set_status_flags(wakeirq, _IRQ_NOAUTOEN);
> +
> + if (devm)
> + ret = devm_request_threaded_irq(dev, wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> + else
> + ret = request_threaded_irq(wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> +
> + return ret;
> +}
> +
> +int request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(request_wake_irq);
> +
> +int devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(devm_request_wake_irq);
> +
> void enable_percpu_irq(unsigned int irq, unsigned int type)
> {
> unsigned int cpu = smp_processor_id();
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
WARNING: multiple messages have this Message-ID (diff)
From: tony@atomide.com (Tony Lindgren)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Thu, 6 Nov 2014 12:46:30 -0800 [thread overview]
Message-ID: <20141106204629.GF31454@atomide.com> (raw)
In-Reply-To: <20141002034345.GH3122@atomide.com>
Thomas,
Any comments on the patch below? Let me know if you want to keep the
devm stuff out of kernel/irq/manage.c.
* Tony Lindgren <tony@atomide.com> [141001 20:45]:
> Hi Thomas,
>
> * Thomas Gleixner <tglx@linutronix.de> [140919 12:47]:
> >
> > The wakeup handler is supposed to bring the thing out of deep sleep
> > and nothing else. All you want it to do is to mask itself and save the
> > information that the real device irq is pending.
> >
> > A stub handler for the wakeup irq is enough. We can have that in the
> > irq/pm core and all it would do is simply:
>
> Here's a patch along the lines of what you described, hopefully that's
> fairly close to what you had in mind.
>
> I also did play with the replaying of the interrupts but I don't think
> that's needed. Well at least not for the omap case. I added some
> comments about that to the code.
>
> So far I've tested with the omap-serial and omap_hsmmc drivers. The
> serial driver does not have any status as the device is powered off.
> So replaying of the interrupt does not help there, we need to wait for
> the next event anyways.
>
> Then with omap_hsmmc the SDIO interrupt on dat1 line is level
> sensitive and is noticed after the MMC controller is powered on
> again. So no replaying of the device interrupt needed here either.
>
> I still have not tested the MMC remux lines to GPIO for wake-up
> events that's also needed for some omaps.
>
> Regards,
>
> Tony
>
> 8<-----------
> From: Tony Lindgren <tony@atomide.com>
> Date: Wed, 1 Oct 2014 14:56:35 -0700
> Subject: [PATCH] genirq: Add support for wake-up interrupts to fix irq reentry issues in drivers
>
> As pointed out by Thomas Gleixner, at least omap wake-up interrupts
> have an issue with re-entrant interrupts because the wake-up interrupts
> are now handled as a secondary interrupt controller. Further, the
> wake-up interrupt just needs wake the system at least for omaps. So we
> should just make the wake-up interrupt handling generic.
>
> Note that at least initially we are keeping things simple by assuming the
> wake-up interrupt is level sensitive, and the device pm_runtime_resume()
> can deal with the situation, and no replaying of the lost device interrupts
> is needed.
>
> After tinkering with replaying of the lost device interrupts, my opinion is
> that it should be avoided because of the issues listed in the comments of
> this patch.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -139,11 +139,15 @@ extern int __must_check
> request_percpu_irq(unsigned int irq, irq_handler_t handler,
> const char *devname, void __percpu *percpu_dev_id);
>
> +struct device;
> +
> +extern int __must_check
> +request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void free_irq(unsigned int, void *);
> extern void free_percpu_irq(unsigned int, void __percpu *);
>
> -struct device;
> -
> extern int __must_check
> devm_request_threaded_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, irq_handler_t thread_fn,
> @@ -163,6 +167,10 @@ devm_request_any_context_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, unsigned long irqflags,
> const char *devname, void *dev_id);
>
> +extern int __must_check
> +devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
>
> /*
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -14,6 +14,7 @@
> #include <linux/module.h>
> #include <linux/random.h>
> #include <linux/interrupt.h>
> +#include <linux/pm_runtime.h>
> #include <linux/slab.h>
> #include <linux/sched.h>
> #include <linux/sched/rt.h>
> @@ -1578,6 +1579,111 @@ int request_any_context_irq(unsigned int irq, irq_handler_t handler,
> }
> EXPORT_SYMBOL_GPL(request_any_context_irq);
>
> +/**
> + * handle_wakeirq_thread - call device runtime pm calls on wake-up interrupt
> + * @wakeirq: device specific wake-up interrupt
> + * @dev_id: struct device entry
> + */
> +static irqreturn_t handle_wakeirq_thread(int wakeirq, void *dev_id)
> +{
> + struct device *dev = dev_id;
> + irqreturn_t ret = IRQ_NONE;
> +
> + if (pm_runtime_suspended(dev)) {
> + pm_runtime_mark_last_busy(dev);
> + pm_request_resume(dev);
> + ret = IRQ_HANDLED;
> + }
> +
> + return ret;
> +}
> +
> +/**
> + * setup_wakeirq - allocate a wake-up interrupt for a device
> + * @dev: device to wake up
> + * @wakeirq: interrupt that wakes up the device
> + * @wakeflags: flags to pass to the interrupt handler
> + * @devm: use devm
> + *
> + * Note that the wake-up interrupt starts disabled. The wake-up interrupt
> + * is typically enabled from the device pm_runtime_suspend() and disabled
> + * again in the device pm_runtime_resume(). For runtime PM, the wake-up
> + * interrupt should be always enabled, and for device suspend and resume,
> + * the wake-up interrupt should be enabled depending on the device specific
> + * configuration for device_can_wakeup().
> + *
> + * Note also that we are not resending the lost device interrupts.
> + * We assume that the wake-up interrupt just needs to wake-up the device,
> + * and then device pm_runtime_resume() can deal with the situation.
> + *
> + * There are at least the following reasons to not resend the lost device
> + * interrupts automatically based on the wake-up interrupt:
> + *
> + * 1. There can be interrupt reentry issues calling the device interrupt
> + * based on the wake-up interrupt if done in the device driver. It
> + * could be done with check_irq_resend() after checking the device
> + * interrupt mask if we really wanted to though.
> + *
> + * 2. The device interrupt handler would need to be set up properly with
> + * pm_runtime_irq_safe(). Ideally you don't want to call pm_runtime
> + * calls from the device interrupt handler at all.
> + *
> + * 3. The IRQ subsystem may not know if it's safe to call the device
> + * interrupt unless the driver updates the interrupt status with
> + * disable_irq() and enable_irq() in addition to just disabling the
> + * interrupt at the hardware level in the device registers.
> + *
> + * So if replaying the lost device interrupts is absolutely needed from the
> + * hardware point of view, it's probably best to set up a completely
> + * separate wake-up interrupt handler for the wake-up interrupt in the
> + * device driver because of the reasons above.
> + */
> +static int setup_wakeirq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags, bool devm)
> +{
> + int ret;
> +
> + if (!(dev && wakeirq)) {
> + pr_err("Missing device or wakeirq for %s irq %d\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + if (!(wakeflags &
> + (IRQF_TRIGGER_LOW | IRQF_TRIGGER_HIGH | IRQF_ONESHOT))) {
> + pr_err("Invalid wakeirq for %s irq %d, must be level oneshot\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + irq_set_status_flags(wakeirq, _IRQ_NOAUTOEN);
> +
> + if (devm)
> + ret = devm_request_threaded_irq(dev, wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> + else
> + ret = request_threaded_irq(wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> +
> + return ret;
> +}
> +
> +int request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(request_wake_irq);
> +
> +int devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(devm_request_wake_irq);
> +
> void enable_percpu_irq(unsigned int irq, unsigned int type)
> {
> unsigned int cpu = smp_processor_id();
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
WARNING: multiple messages have this Message-ID (diff)
From: Tony Lindgren <tony@atomide.com>
To: Thomas Gleixner <tglx@linutronix.de>
Cc: Nishanth Menon <nm@ti.com>,
lee.jones@linaro.org, LKML <linux-kernel@vger.kernel.org>,
devicetree@vger.kernel.org, Keerthy <j-keerthy@ti.com>,
Mark Brown <broonie@linaro.org>,
Samuel Ortiz <sameo@linux.intel.com>,
linux-omap@vger.kernel.org,
LAK <linux-arm-kernel@lists.infradead.org>,
Kevin Hilman <khilman@linaro.org>
Subject: Re: [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup
Date: Thu, 6 Nov 2014 12:46:30 -0800 [thread overview]
Message-ID: <20141106204629.GF31454@atomide.com> (raw)
In-Reply-To: <20141002034345.GH3122@atomide.com>
Thomas,
Any comments on the patch below? Let me know if you want to keep the
devm stuff out of kernel/irq/manage.c.
* Tony Lindgren <tony@atomide.com> [141001 20:45]:
> Hi Thomas,
>
> * Thomas Gleixner <tglx@linutronix.de> [140919 12:47]:
> >
> > The wakeup handler is supposed to bring the thing out of deep sleep
> > and nothing else. All you want it to do is to mask itself and save the
> > information that the real device irq is pending.
> >
> > A stub handler for the wakeup irq is enough. We can have that in the
> > irq/pm core and all it would do is simply:
>
> Here's a patch along the lines of what you described, hopefully that's
> fairly close to what you had in mind.
>
> I also did play with the replaying of the interrupts but I don't think
> that's needed. Well at least not for the omap case. I added some
> comments about that to the code.
>
> So far I've tested with the omap-serial and omap_hsmmc drivers. The
> serial driver does not have any status as the device is powered off.
> So replaying of the interrupt does not help there, we need to wait for
> the next event anyways.
>
> Then with omap_hsmmc the SDIO interrupt on dat1 line is level
> sensitive and is noticed after the MMC controller is powered on
> again. So no replaying of the device interrupt needed here either.
>
> I still have not tested the MMC remux lines to GPIO for wake-up
> events that's also needed for some omaps.
>
> Regards,
>
> Tony
>
> 8<-----------
> From: Tony Lindgren <tony@atomide.com>
> Date: Wed, 1 Oct 2014 14:56:35 -0700
> Subject: [PATCH] genirq: Add support for wake-up interrupts to fix irq reentry issues in drivers
>
> As pointed out by Thomas Gleixner, at least omap wake-up interrupts
> have an issue with re-entrant interrupts because the wake-up interrupts
> are now handled as a secondary interrupt controller. Further, the
> wake-up interrupt just needs wake the system at least for omaps. So we
> should just make the wake-up interrupt handling generic.
>
> Note that at least initially we are keeping things simple by assuming the
> wake-up interrupt is level sensitive, and the device pm_runtime_resume()
> can deal with the situation, and no replaying of the lost device interrupts
> is needed.
>
> After tinkering with replaying of the lost device interrupts, my opinion is
> that it should be avoided because of the issues listed in the comments of
> this patch.
>
> Signed-off-by: Tony Lindgren <tony@atomide.com>
>
> --- a/include/linux/interrupt.h
> +++ b/include/linux/interrupt.h
> @@ -139,11 +139,15 @@ extern int __must_check
> request_percpu_irq(unsigned int irq, irq_handler_t handler,
> const char *devname, void __percpu *percpu_dev_id);
>
> +struct device;
> +
> +extern int __must_check
> +request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void free_irq(unsigned int, void *);
> extern void free_percpu_irq(unsigned int, void __percpu *);
>
> -struct device;
> -
> extern int __must_check
> devm_request_threaded_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, irq_handler_t thread_fn,
> @@ -163,6 +167,10 @@ devm_request_any_context_irq(struct device *dev, unsigned int irq,
> irq_handler_t handler, unsigned long irqflags,
> const char *devname, void *dev_id);
>
> +extern int __must_check
> +devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long irqflags);
> +
> extern void devm_free_irq(struct device *dev, unsigned int irq, void *dev_id);
>
> /*
> --- a/kernel/irq/manage.c
> +++ b/kernel/irq/manage.c
> @@ -14,6 +14,7 @@
> #include <linux/module.h>
> #include <linux/random.h>
> #include <linux/interrupt.h>
> +#include <linux/pm_runtime.h>
> #include <linux/slab.h>
> #include <linux/sched.h>
> #include <linux/sched/rt.h>
> @@ -1578,6 +1579,111 @@ int request_any_context_irq(unsigned int irq, irq_handler_t handler,
> }
> EXPORT_SYMBOL_GPL(request_any_context_irq);
>
> +/**
> + * handle_wakeirq_thread - call device runtime pm calls on wake-up interrupt
> + * @wakeirq: device specific wake-up interrupt
> + * @dev_id: struct device entry
> + */
> +static irqreturn_t handle_wakeirq_thread(int wakeirq, void *dev_id)
> +{
> + struct device *dev = dev_id;
> + irqreturn_t ret = IRQ_NONE;
> +
> + if (pm_runtime_suspended(dev)) {
> + pm_runtime_mark_last_busy(dev);
> + pm_request_resume(dev);
> + ret = IRQ_HANDLED;
> + }
> +
> + return ret;
> +}
> +
> +/**
> + * setup_wakeirq - allocate a wake-up interrupt for a device
> + * @dev: device to wake up
> + * @wakeirq: interrupt that wakes up the device
> + * @wakeflags: flags to pass to the interrupt handler
> + * @devm: use devm
> + *
> + * Note that the wake-up interrupt starts disabled. The wake-up interrupt
> + * is typically enabled from the device pm_runtime_suspend() and disabled
> + * again in the device pm_runtime_resume(). For runtime PM, the wake-up
> + * interrupt should be always enabled, and for device suspend and resume,
> + * the wake-up interrupt should be enabled depending on the device specific
> + * configuration for device_can_wakeup().
> + *
> + * Note also that we are not resending the lost device interrupts.
> + * We assume that the wake-up interrupt just needs to wake-up the device,
> + * and then device pm_runtime_resume() can deal with the situation.
> + *
> + * There are at least the following reasons to not resend the lost device
> + * interrupts automatically based on the wake-up interrupt:
> + *
> + * 1. There can be interrupt reentry issues calling the device interrupt
> + * based on the wake-up interrupt if done in the device driver. It
> + * could be done with check_irq_resend() after checking the device
> + * interrupt mask if we really wanted to though.
> + *
> + * 2. The device interrupt handler would need to be set up properly with
> + * pm_runtime_irq_safe(). Ideally you don't want to call pm_runtime
> + * calls from the device interrupt handler at all.
> + *
> + * 3. The IRQ subsystem may not know if it's safe to call the device
> + * interrupt unless the driver updates the interrupt status with
> + * disable_irq() and enable_irq() in addition to just disabling the
> + * interrupt at the hardware level in the device registers.
> + *
> + * So if replaying the lost device interrupts is absolutely needed from the
> + * hardware point of view, it's probably best to set up a completely
> + * separate wake-up interrupt handler for the wake-up interrupt in the
> + * device driver because of the reasons above.
> + */
> +static int setup_wakeirq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags, bool devm)
> +{
> + int ret;
> +
> + if (!(dev && wakeirq)) {
> + pr_err("Missing device or wakeirq for %s irq %d\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + if (!(wakeflags &
> + (IRQF_TRIGGER_LOW | IRQF_TRIGGER_HIGH | IRQF_ONESHOT))) {
> + pr_err("Invalid wakeirq for %s irq %d, must be level oneshot\n",
> + dev_name(dev), wakeirq);
> + return -EINVAL;
> + }
> +
> + irq_set_status_flags(wakeirq, _IRQ_NOAUTOEN);
> +
> + if (devm)
> + ret = devm_request_threaded_irq(dev, wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> + else
> + ret = request_threaded_irq(wakeirq, NULL,
> + handle_wakeirq_thread,
> + wakeflags, dev_name(dev), dev);
> +
> + return ret;
> +}
> +
> +int request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(request_wake_irq);
> +
> +int devm_request_wake_irq(struct device *dev, unsigned int wakeirq,
> + unsigned long wakeflags)
> +{
> + return setup_wakeirq(dev, wakeirq, wakeflags, false);
> +}
> +EXPORT_SYMBOL(devm_request_wake_irq);
> +
> void enable_percpu_irq(unsigned int irq, unsigned int type)
> {
> unsigned int cpu = smp_processor_id();
> --
> To unsubscribe from this list: send the line "unsubscribe linux-omap" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
next prev parent reply other threads:[~2014-11-06 20:46 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-09-18 19:04 [PATCH V3 0/3] mfd: palmas: add optional wakeup irq Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` [PATCH V3 1/3] Documentation: dt-bindings: mfd: palmas: Fix example style of i2c peripheral Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` [PATCH V3 2/3] Documentation: dt-bindings: mfd: palmas: document optional wakeup IRQ Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
[not found] ` <1411067086-16613-1-git-send-email-nm-l0cyMroinI0@public.gmane.org>
2014-09-18 19:04 ` [PATCH V3 3/3] mfd: palmas: Add support for optional wakeup Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-18 19:04 ` Nishanth Menon
2014-09-19 0:57 ` Thomas Gleixner
2014-09-19 0:57 ` Thomas Gleixner
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 3:03 ` Nishanth Menon
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 15:37 ` Thomas Gleixner
2014-09-19 16:19 ` Nishanth Menon
2014-09-19 16:19 ` Nishanth Menon
2014-09-19 16:19 ` Nishanth Menon
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 17:36 ` Thomas Gleixner
2014-09-19 19:16 ` Tony Lindgren
2014-09-19 19:16 ` Tony Lindgren
2014-09-19 19:16 ` Tony Lindgren
[not found] ` <20140919191649.GQ14505-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:46 ` Thomas Gleixner
2014-09-19 19:57 ` Tony Lindgren
2014-09-19 19:57 ` Tony Lindgren
2014-09-19 19:57 ` Tony Lindgren
[not found] ` <20140919195738.GR14505-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 2:07 ` Thomas Gleixner
2014-09-20 14:07 ` Tony Lindgren
2014-09-20 14:07 ` Tony Lindgren
2014-09-20 14:07 ` Tony Lindgren
2014-10-02 3:43 ` Tony Lindgren
2014-10-02 3:43 ` Tony Lindgren
[not found] ` <20141002034345.GH3122-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-06 20:46 ` Tony Lindgren [this message]
2014-11-06 20:46 ` Tony Lindgren
2014-11-06 20:46 ` Tony Lindgren
[not found] ` <20141106204629.GF31454-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 10:03 ` Thomas Gleixner
2014-11-13 17:40 ` Tony Lindgren
2014-11-13 17:40 ` Tony Lindgren
[not found] ` <20141113174030.GM26481-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 22:25 ` Thomas Gleixner
2014-11-13 23:45 ` Tony Lindgren
2014-11-13 23:45 ` Tony Lindgren
2014-11-13 23:45 ` Tony Lindgren
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 16:19 ` Felipe Balbi
2014-11-14 17:08 ` Tony Lindgren
2014-11-14 17:08 ` Tony Lindgren
2014-11-14 17:08 ` Tony Lindgren
[not found] ` <20141114170816.GW26481-4v6yS6AI5VpBDgjK7y7TUQ@public.gmane.org>
2014-11-14 17:21 ` Felipe Balbi
2014-11-14 17:21 ` Felipe Balbi
2014-11-14 17:21 ` Felipe Balbi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20141106204629.GF31454@atomide.com \
--to=tony-4v6ys6ai5vpbdgjk7y7tuq@public.gmane.org \
--cc=broonie-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=j-keerthy-l0cyMroinI0@public.gmane.org \
--cc=khilman-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=lee.jones-QSEj5FYQhm4dnm+yROfE0A@public.gmane.org \
--cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
--cc=linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=linux-omap-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
--cc=nm-l0cyMroinI0@public.gmane.org \
--cc=sameo-VuQAYsv1563Yd54FQh9/CA@public.gmane.org \
--cc=tglx-hfZtesqFncYOwBW4kG4KsQ@public.gmane.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.