From: Felipe Balbi <balbi@ti.com>
To: Tony Lindgren <tony@atomide.com>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
Felipe Balbi <balbi@ti.com>,
"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
Alan Stern <stern@rowland.harvard.edu>,
Andreas Fenkart <afenkart@gmail.com>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Huiquan Zhong <huiquan.zhong@intel.com>,
Kevin Hilman <khilman@kernel.org>, NeilBrown <neilb@suse.de>,
Mika Westerberg <mika.westerberg@linux.intel.com>,
Nishanth Menon <nm@ti.com>,
Peter Hurley <peter@hurleysoftware.com>,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Ulf Hansson <ulf.hansson@linaro.org>,
Thomas Gleixner <tglx@linutronix.de>, <linux-pm@vger.kernel.org>,
<linux-kernel@vger.kernel.org>, <linux-serial@vger.kernel.org>,
<linux-omap@vger.kernel.org>
Subject: Re: [PATCH 2/5] PM / Wakeirq: Add automated device wake IRQ handling
Date: Fri, 15 May 2015 20:56:51 -0500 [thread overview]
Message-ID: <20150516015651.GA7493@saruman.tx.rr.com> (raw)
In-Reply-To: <20150515222513.GB10274@atomide.com>
[-- Attachment #1: Type: text/plain, Size: 3777 bytes --]
Hi,
On Fri, May 15, 2015 at 03:25:13PM -0700, Tony Lindgren wrote:
<snip>
> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
> new file mode 100644
> index 0000000..1125481
> --- /dev/null
> +++ b/drivers/base/power/wakeirq.c
> @@ -0,0 +1,276 @@
> +/*
> + * wakeirq.c - Device wakeirq helper functions
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2 as
> + * published by the Free Software Foundation.
> + *
> + * This program is distributed "as is" WITHOUT ANY WARRANTY of any
> + * kind, whether express or implied; without even the implied warranty
> + * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
> + * GNU General Public License for more details.
> + */
> +
> +#include <linux/device.h>
> +#include <linux/interrupt.h>
> +#include <linux/irq.h>
> +#include <linux/slab.h>
> +#include <linux/pm_runtime.h>
> +#include <linux/pm_wakeirq.h>
> +
> +#include "power.h"
> +
> +/**
> + * dev_pm_attach_wake_irq - Attach device interrupt as a wake IRQ
> + * @dev: Device entry
> + * @irq: Device wake-up capable interrupt
> + * @wirq: Wake irq specific data
> + *
> + * Internal function to attach either a device IO interrupt or a
> + * dedicated wake-up interrupt as a wake IRQ.
> + */
> +static int dev_pm_attach_wake_irq(struct device *dev, int irq,
> + struct wake_irq *wirq)
> +{
> + unsigned long flags;
> + int err;
> +
> + if (!dev || !wirq)
> + return -EINVAL;
> +
> + if (!dev->power.wakeup) {
> + dev_err(dev, "forgot to call call device_init_wakeup?\n");
> + return -EINVAL;
> + }
> +
> + spin_lock_irqsave(&dev->power.lock, flags);
> + if (WARN_ON(dev->power.wakeirq)) {
> + dev_err(dev, "wake irq already initialized\n");
these two can be combined if you can live with a WARN_ONCE() instead:
if (dev_WARN_ONCE(dev, dev->power.wakeirq,
"wake irq already initialized\n")) {
spin_unlock_irqrestore(&dev->power.lock, flags);
return -EEXIST;
}
dev_WARN() needs to be fixed at some point to accept a "condition"
argument :s
But really, no strong feelings.
> +static irqreturn_t handle_threaded_wakeirq(int wakeirq, void *_wirq)
> +{
> + struct wake_irq *wirq = _wirq;
> +
> + /* We don't want RPM_ASYNC or RPM_NOWAIT here */
> + return pm_runtime_resume(wirq->dev) ? IRQ_NONE : IRQ_HANDLED;
I wonder if you should add a pm_runtime_mark_last_busy() here. I guess
not after your previous patch ?
> diff --git a/drivers/base/power/wakeup.c b/drivers/base/power/wakeup.c
> index 7726200..7191519 100644
> --- a/drivers/base/power/wakeup.c
> +++ b/drivers/base/power/wakeup.c
> @@ -238,6 +239,100 @@ int device_wakeup_enable(struct device *dev)
> }
> EXPORT_SYMBOL_GPL(device_wakeup_enable);
>
> +#ifdef CONFIG_PM_WAKEIRQ
> +
> +/**
> + * device_wakeup_attach_irq - Attach a wakeirq to a wakeup source
> + * @dev: Device to handle
> + * @irq: Device specific wakeirq entry
s/irq/wakeirq to match argument name below ?
> + * Attach a device specific wakeirq to the device specific
> + * wakeup source so the device wakeirq can be configured
> + * automatically for suspend and resume.
> + */
> +int device_wakeup_attach_irq(struct device *dev,
> + struct wake_irq *wakeirq)
> +{
> + struct wakeup_source *ws;
> + int ret = 0;
> +
> + spin_lock_irq(&dev->power.lock);
> + ws = dev->power.wakeup;
> + if (!ws) {
> + ret = -EINVAL;
> + goto unlock;
> + }
> +
> + if (ws->wakeirq) {
> + ret = -EEXIST;
> + goto unlock;
> + }
> +
> + ws->wakeirq = wakeirq;
> +
> +unlock:
> + spin_unlock_irq(&dev->power.lock);
> +
> + return ret;
> +}
<snip>
--
balbi
[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]
next prev parent reply other threads:[~2015-05-16 1:59 UTC|newest]
Thread overview: 43+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-05-13 23:36 [PATCHv3 0/5] Linux generic wakeirq handling Tony Lindgren
2015-05-13 23:36 ` [PATCH 1/5] PM / Runtime: Update last_busy in rpm_resume Tony Lindgren
2015-05-20 7:36 ` Ulf Hansson
2015-05-13 23:36 ` [PATCH 2/5] PM / Wakeirq: Add automated device wake IRQ handling Tony Lindgren
2015-05-14 2:06 ` Felipe Balbi
2015-05-14 15:51 ` Alan Stern
2015-05-14 15:54 ` Felipe Balbi
2015-05-14 15:59 ` Tony Lindgren
2015-05-14 16:09 ` Felipe Balbi
2015-05-14 16:28 ` Tony Lindgren
2015-05-14 17:51 ` Tony Lindgren
2015-05-14 21:15 ` Tony Lindgren
2015-05-14 21:25 ` Felipe Balbi
2015-05-14 22:00 ` Rafael J. Wysocki
2015-05-14 21:59 ` Tony Lindgren
2015-05-15 22:25 ` Tony Lindgren
2015-05-16 1:56 ` Felipe Balbi [this message]
2015-05-18 22:05 ` Tony Lindgren
2015-05-18 23:44 ` Tony Lindgren
2015-05-19 14:04 ` Rafael J. Wysocki
2015-05-19 14:26 ` Rafael J. Wysocki
2015-05-19 15:09 ` Tony Lindgren
2015-05-19 18:18 ` Tony Lindgren
2015-05-19 23:01 ` Rafael J. Wysocki
2015-05-19 22:41 ` Thomas Gleixner
2015-05-19 23:31 ` Rafael J. Wysocki
2015-05-19 23:27 ` Tony Lindgren
2015-05-20 0:25 ` Rafael J. Wysocki
2015-05-20 2:10 ` Tony Lindgren
2015-05-21 0:54 ` Rafael J. Wysocki
2015-05-21 0:35 ` Tony Lindgren
2015-05-21 1:40 ` Felipe Balbi
2015-05-19 15:15 ` Tony Lindgren
2015-05-13 23:36 ` [PATCH 3/5] serial: omap: Switch wake-up interrupt to generic wakeirq Tony Lindgren
2015-05-28 14:56 ` Tony Lindgren
2015-05-31 7:16 ` Greg Kroah-Hartman
2015-06-01 22:05 ` Tony Lindgren
2015-05-13 23:36 ` [PATCH 4/5] serial: 8250_omap: Move " Tony Lindgren
2015-05-13 23:36 ` [PATCH 5/5] mmc: omap_hsmmc: Change wake-up interrupt to use " Tony Lindgren
2015-05-25 8:38 ` Ulf Hansson
2015-05-27 22:42 ` Rafael J. Wysocki
2015-05-27 22:45 ` Tony Lindgren
2015-05-28 14:36 ` Tony Lindgren
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=20150516015651.GA7493@saruman.tx.rr.com \
--to=balbi@ti.com \
--cc=afenkart@gmail.com \
--cc=bigeasy@linutronix.de \
--cc=gregkh@linuxfoundation.org \
--cc=huiquan.zhong@intel.com \
--cc=khilman@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=linux-pm@vger.kernel.org \
--cc=linux-serial@vger.kernel.org \
--cc=mika.westerberg@linux.intel.com \
--cc=neilb@suse.de \
--cc=nm@ti.com \
--cc=peter@hurleysoftware.com \
--cc=rafael.j.wysocki@intel.com \
--cc=rjw@rjwysocki.net \
--cc=stern@rowland.harvard.edu \
--cc=tglx@linutronix.de \
--cc=tony@atomide.com \
--cc=ulf.hansson@linaro.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Powered by JetHome