Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1293873

Re: [RFC PATCH V2 3/8] genirq: Add runtime power management support for IRQ chips

Path csiph.com!eternal-september.org!feeder.eternal-september.org!aioe.org!bofh.it!news.nic.it!robomod
From Linus Walleij <linus.walleij@linaro.org>
Newsgroups linux.kernel
Subject Re: [RFC PATCH V2 3/8] genirq: Add runtime power management support for IRQ chips
Date Thu, 17 Dec 2015 14:20:02 +0100
Message-ID <qGGDo-8kx-1@gated-at.bofh.it> (permalink)
References <qGErU-6H4-11@gated-at.bofh.it> <qGErV-6H4-27@gated-at.bofh.it>
X-Original-To Jon Hunter <jonathanh@nvidia.com>, "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>, "linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>
Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=Gpo+jJZ1GPDRV4gzv/MbgPbCpByl3e1PqGTgTemo6Dk=; b=fHYGd+U+mmX/yr/meqO4YAA7yYqSeEGDlXnqI6Eiva5/bFnseKl4yWNR7s4qcmAV5A 1B8d9MRsdvMPRYTT03BYXUvqcW3QfBoK22d30oPo9ipG3HR98C7kvMxMRgQBXO26Nh0E 6mWPqi5n3UWwfUuVIwr2ivwoQEEwWF6T18gBY=
X-Google-Dkim-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=Gpo+jJZ1GPDRV4gzv/MbgPbCpByl3e1PqGTgTemo6Dk=; b=EcFV2VxIhC5h1TaStiGeu7kzD1eM0QlCHkt7KxRTe7mq831q7UXT2fP9SkD8DgZHm5 Gj9JVTrY8Pat92pnnem53wCeyX61md8U4hqZSCt1RJbJmQljkxjfz0mk/8xigcgI8Ke7 mjaiGPOzq2CaMfthFQCdiF5vsJbwViAkSd+LSgLjr403ChRiWM7OSeyPH6DDKYH3lBy2 R0kKfAxE39uNea9WBP8Sz9M9Jf9Eccr9Ry2kMs024iBNWk8LMB6F6/QAg9gp4AaI9yOu 6y39lzHF4pB4mOIBToXNfmdVTEn5FbpbhER1bf3rnnRaYXIjOfsg8v35HIUNxdMgLR6M 7fPg==
X-Gm-Message-State ALoCoQmH6SkaDjVDtxYHC2fHk12GZyIV9qpeDB5YAVeyvwo4R/UE2B0UFvJ50aF+GhU9Eo+AGDAAniQpWsD5sIqLAYTtZbdottaBrMPtabuX4lR9pZ7l8WE=
MIME-Version 1.0
X-Received by 10.202.102.102 with SMTP id a99mr22441048oic.113.1450358388103; Thu, 17 Dec 2015 05:19:48 -0800 (PST)
Content-Type text/plain; charset=UTF-8
Sender robomod@news.nic.it
List-ID <linux-kernel.vger.kernel.org>
X-Mailing-List linux-kernel@vger.kernel.org
Approved robomod@news.nic.it
Lines 87
Organization linux.* mail to news gateway
X-Original-Cc Thomas Gleixner <tglx@linutronix.de>, Jason Cooper <jason@lakedaemon.net>, Marc Zyngier <marc.zyngier@arm.com>, Jiang Liu <jiang.liu@linux.intel.com>, Stephen Warren <swarren@wwwdotorg.org>, Thierry Reding <thierry.reding@gmail.com>, Kevin Hilman <khilman@kernel.org>, Geert Uytterhoeven <geert@linux-m68k.org>, Grygorii Strashko <grygorii.strashko@ti.com>, Lars-Peter Clausen <lars@metafoo.de>, Soren Brinkmann <soren.brinkmann@xilinx.com>, "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>, "linux-tegra@vger.kernel.org" <linux-tegra@vger.kernel.org>, Ulf Hansson <ulf.hansson@linaro.org>
X-Original-Date Thu, 17 Dec 2015 14:19:48 +0100
X-Original-Message-ID <CACRpkdZXBPQv0ftZJEyE_Q7X_nTpY=3Cd_PTCnK-nHMyqmmBqg@mail.gmail.com>
X-Original-References <1450349309-8107-1-git-send-email-jonathanh@nvidia.com> <1450349309-8107-4-git-send-email-jonathanh@nvidia.com>
X-Original-Sender linux-kernel-owner@vger.kernel.org
Xref csiph.com linux.kernel:1293873

Show key headers only | View raw


On Thu, Dec 17, 2015 at 11:48 AM, Jon Hunter <jonathanh@nvidia.com> wrote:

(Adding Rafael and linux-pm to To: list)

> Some IRQ chips may be located in a power domain outside of the CPU
> subsystem and hence will require device specific runtime power management.
> In order to support such IRQ chips, add a pointer for a device structure
> to the irq_chip structure, and if this pointer is populated by the IRQ
> chip driver and the flag CHIP_HAS_RPM is set, then the pm_runtime_get/put
> APIs for this chip will be called when an IRQ is requested/freed,
> respectively.
>
> Signed-off-by: Jon Hunter <jonathanh@nvidia.com>

Overall I like what you're trying to do. This will enable e.g. I2C
GPIO supplying expanders to power down if none of its lines are
used for IRQs. (Read below on the suspend() case for even
better stuff we can do!)

(...)
> @@ -307,6 +307,7 @@ static inline irq_hw_number_t irqd_to_hwirq(struct irq_data *d)
>  /**
>   * struct irq_chip - hardware interrupt chip descriptor
>   *
> + * @dev:               pointer to associated device
(...)
>  struct irq_chip {
> +       struct device   *dev;

In struct gpio_chip I just this merge window have to merge a gigantic
patch renaming this from "dev" to "parent" because we need to add
a *real* struct device dev; to gpio_chip.

So for the advent that we may in the future need a real struct device
inside irq_chip, name this .parent already today, please.

> +/* Inline functions for support of irq chips that require runtime pm */
> +static inline int chip_pm_get(struct irq_desc *desc)
> +{
> +       int retval = 0;
> +
> +       if (desc->irq_data.chip->dev &&
> +           desc->irq_data.chip->flags & IRQCHIP_HAS_RPM)
> +               retval = pm_runtime_get_sync(desc->irq_data.chip->dev);
> +
> +       return (retval < 0) ? retval : 0;
> +}

That is boiling all PM upward into the platform_device or whatever
it is containing this. But we're not just in it for runtime_pm_suspend()
and runtime_pm_resume(). We also have regular suspend() and
resume(). And ideally that should be handled by the same
callbacks.

First: what if the device contain any wakeup-flagged IRQs?
I think there is something missing here. The suspend() usecase
is not handled by this patch, but we need to think about that
here as well. I think irqchips on GPIO expanders (for example)
should be powered down on suspend() *unless* one or more of
its IRQs is flagged as wakeup, and in that case it should
*not* be powered down, instead it should just mask all
non-wakeup IRQs and restore them on resume().

Second: it's soo easy to get something wrong here. It'd be good
if the kernel was helpful. What about something like:

if (desc->irq_data.chip->dev) {
    if (desc->irq_data.chip->flags & IRQCHIP_HAS_RPM)
           retval = pm_runtime_get_sync(desc->irq_data.chip->dev)
    else if (pm_runtime_enabled(desc->irq_data.chip->dev))
           dev_warn_once(desc->irq_data.chip->dev, "irqchip not
flagged for RPM but has runtime PM enabled! weird.\n");
}

As I see it, a device that supplies an irqchip, has runtime PM but
is *NOT* setting IRQCHIP_HAS_RPM just *have* to be looked
at in detail, and deserve to have this littering its dmesg so we can
fix it. It just makes no real sense. It more sounds like a recepie for
missing interrupts otherwise.

Yours,
Linus Walleij
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

[RFC PATCH V2 3/8] genirq: Add runtime power management support for IRQ chips Jon Hunter <jonathanh@nvidia.com> - 2015-12-17 12:00 +0100
  Re: [RFC PATCH V2 3/8] genirq: Add runtime power management support  for IRQ chips Linus Walleij <linus.walleij@linaro.org> - 2015-12-17 14:20 +0100
    Re: [RFC PATCH V2 3/8] genirq: Add runtime power management support  for IRQ chips Jon Hunter <jonathanh@nvidia.com> - 2015-12-18 11:30 +0100

csiph-web