Linux PCI subsystem development
 help / color / mirror / Atom feed
From: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
To: "Rafael J. Wysocki" <rafael@kernel.org>
Cc: Len Brown <lenb@kernel.org>, Pavel Machek <pavel@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Danilo Krummrich <dakr@kernel.org>,
	Bjorn Helgaas <bhelgaas@google.com>,
	Linus Walleij <linus.walleij@linaro.org>,
	Bartosz Golaszewski <brgl@bgdev.pl>,
	linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-pci@vger.kernel.org, linux-gpio@vger.kernel.org,
	quic_vbadigan@quicinc.com, quic_mrana@quicinc.com,
	sherry.sun@nxp.com
Subject: Re: [PATCH v5 1/2] PM: sleep: wakeirq: Add support for custom IRQ flags in dedicated wake IRQ setup
Date: Mon, 17 Nov 2025 09:58:33 +0530	[thread overview]
Message-ID: <4b04531b-64f9-4e42-b43b-bfcfa251b665@oss.qualcomm.com> (raw)
In-Reply-To: <CAJZ5v0jF2DG8Dki8+vVbOR20Z-=5=1XW2AjU05fzQPDJfzhLzA@mail.gmail.com>



On 11/14/2025 10:20 PM, Rafael J. Wysocki wrote:
> On Fri, Nov 7, 2025 at 10:22 AM Krishna Chaitanya Chundru
> <krishna.chundru@oss.qualcomm.com> wrote:
>> Some devices require more flexibility when configuring their dedicated
>> wake-up interrupts, such as support for IRQF_SHARED or other IRQ flags.
>> This is particularly useful in PCIe systems where multiple endpoints
>> (e.g., Wi-Fi and Bluetooth controllers) share a common WAKE# signal
>> line which requests platform to re-establish power and reference clocks
>> to the components. In such cases, drivers can use this API with IRQF_SHARED
>> to register a shared wake IRQ handler.
>>
>> Update the internal helper __dev_pm_set_dedicated_wake_irq() to accept an
>> irq_flags argument. Modify the existing dev_pm_set_dedicated_wake_irq()
>> and dev_pm_set_dedicated_wake_irq_reverse() to preserve current behavior
>> by passing default flags (IRQF_ONESHOT | IRQF_NO_AUTOEN).
>>
>> Introduce a new API, dev_pm_set_dedicated_wake_irq_flags(), to allow
>> callers to specify custom IRQ flags. If IRQF_SHARED is used, remove
>> IRQF_NO_AUTOEN and disable the IRQ after setup to prevent spurious wakeups.
>>
>> Signed-off-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
>> ---
>>   drivers/base/power/wakeirq.c | 43 ++++++++++++++++++++++++++++++++++++++-----
>>   include/linux/pm_wakeirq.h   |  6 ++++++
>>   2 files changed, 44 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/base/power/wakeirq.c b/drivers/base/power/wakeirq.c
>> index 8aa28c08b2891f3af490175362cc1a759069bd50..655c28d5fc6850f50fc2ed74c5fbc066a21ae7b3 100644
>> --- a/drivers/base/power/wakeirq.c
>> +++ b/drivers/base/power/wakeirq.c
>> @@ -168,7 +168,8 @@ static irqreturn_t handle_threaded_wake_irq(int irq, void *_wirq)
>>          return IRQ_HANDLED;
>>   }
>>
>> -static int __dev_pm_set_dedicated_wake_irq(struct device *dev, int irq, unsigned int flag)
>> +static int __dev_pm_set_dedicated_wake_irq(struct device *dev, int irq, unsigned int flag,
>> +                                          unsigned int irq_flags)
>>   {
>>          struct wake_irq *wirq;
>>          int err;
>> @@ -197,8 +198,7 @@ static int __dev_pm_set_dedicated_wake_irq(struct device *dev, int irq, unsigned
>>           * so we use a threaded irq.
>>           */
>>          err = request_threaded_irq(irq, NULL, handle_threaded_wake_irq,
>> -                                  IRQF_ONESHOT | IRQF_NO_AUTOEN,
>> -                                  wirq->name, wirq);
>> +                                  irq_flags, wirq->name, wirq);
> It looks like IRQF_ONESHOT will always be there in the flags, so maybe do
>
> +                                  IRQF_ONESHOT | irq_flags, wirq->name, wirq);
>
> here?
>
>>          if (err)
>>                  goto err_free_name;
>>
>> @@ -234,7 +234,7 @@ static int __dev_pm_set_dedicated_wake_irq(struct device *dev, int irq, unsigned
>>    */
>>   int dev_pm_set_dedicated_wake_irq(struct device *dev, int irq)
>>   {
>> -       return __dev_pm_set_dedicated_wake_irq(dev, irq, 0);
>> +       return __dev_pm_set_dedicated_wake_irq(dev, irq, 0, IRQF_ONESHOT | IRQF_NO_AUTOEN);
>>   }
>>   EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq);
>>
>> @@ -255,10 +255,43 @@ EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq);
>>    */
>>   int dev_pm_set_dedicated_wake_irq_reverse(struct device *dev, int irq)
>>   {
>> -       return __dev_pm_set_dedicated_wake_irq(dev, irq, WAKE_IRQ_DEDICATED_REVERSE);
>> +       return __dev_pm_set_dedicated_wake_irq(dev, irq, WAKE_IRQ_DEDICATED_REVERSE,
>> +                                              IRQF_ONESHOT | IRQF_NO_AUTOEN);
>>   }
>>   EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq_reverse);
>>
>> +/**
>> + * dev_pm_set_dedicated_wake_irq_flags - Request a dedicated wake-up interrupt
>> + *                                       with custom flags
>> + * @dev: Device entry
>> + * @irq: Device wake-up interrupt
>> + * @flags: IRQ flags (e.g., IRQF_SHARED)
>> + *
>> + * This API sets up a threaded interrupt handler for a device that has
>> + * a dedicated wake-up interrupt in addition to the device IO interrupt,
>> + * allowing the caller to specify custom IRQ flags such as IRQF_SHARED.
>> + *
>> + * Returns 0 on success or a negative error code on failure.
>> + */
>> +int dev_pm_set_dedicated_wake_irq_flags(struct device *dev, int irq, unsigned long flags)
>> +{
>> +       struct wake_irq *wirq;
>> +       int ret;
>> +
>> +       flags |= IRQF_ONESHOT;
>> +       if (!(flags & IRQF_SHARED))
>> +               flags |= IRQF_NO_AUTOEN;
>> +
>> +       ret =  __dev_pm_set_dedicated_wake_irq(dev, irq, 0, flags);
>> +       if (!ret && (flags & IRQF_SHARED)) {
>> +               wirq = dev->power.wakeirq;
>> +               disable_irq_nosync(wirq->irq);
>> +       }
>> +
>> +       return ret;
>> +}
>> +EXPORT_SYMBOL_GPL(dev_pm_set_dedicated_wake_irq_flags);
> Instead of this, I'd introduce
>
> int dev_pm_set_dedicated_shared_wake_irq(struct device *dev, int irq,
> unsigned long additional_flags)
>
> that would pass IRQF_SHARED combined with additional_flags to
> __dev_pm_set_dedicated_wake_irq() to avoid having two different helper
> functions that can be used for the same purpose.
>
> I think that it would be sufficient for your use case.
Ack.

- Krishna Chaitanya.



  reply	other threads:[~2025-11-17  4:28 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-07  9:22 [PATCH v5 0/2] PCI: Add support for PCIe WAKE# interrupt Krishna Chaitanya Chundru
2025-11-07  9:22 ` [PATCH v5 1/2] PM: sleep: wakeirq: Add support for custom IRQ flags in dedicated wake IRQ setup Krishna Chaitanya Chundru
2025-11-14 16:50   ` Rafael J. Wysocki
2025-11-17  4:28     ` Krishna Chaitanya Chundru [this message]
2025-11-07  9:22 ` [PATCH v5 2/2] PCI: Add support for PCIe WAKE# interrupt Krishna Chaitanya Chundru
2025-11-10 23:57   ` Linus Walleij

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=4b04531b-64f9-4e42-b43b-bfcfa251b665@oss.qualcomm.com \
    --to=krishna.chundru@oss.qualcomm.com \
    --cc=bhelgaas@google.com \
    --cc=brgl@bgdev.pl \
    --cc=dakr@kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=lenb@kernel.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pci@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=pavel@kernel.org \
    --cc=quic_mrana@quicinc.com \
    --cc=quic_vbadigan@quicinc.com \
    --cc=rafael@kernel.org \
    --cc=sherry.sun@nxp.com \
    /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