<feed xmlns='http://www.w3.org/2005/Atom'>
<title>kernel/drivers/base/power/wakeirq.c, branch linux-rolling-stable</title>
<subtitle>Hosts the 0x221E linux distro kernel.</subtitle>
<id>https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable</id>
<link rel='self' href='https://universe.0xinfinity.dev/distro/kernel/atom?h=linux-rolling-stable'/>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/'/>
<updated>2026-02-26T22:59:01Z</updated>
<entry>
<title>PM: sleep: wakeirq: harden dev_pm_clear_wake_irq() against races</title>
<updated>2026-02-26T22:59:01Z</updated>
<author>
<name>Gui-Dong Han</name>
<email>hanguidong02@gmail.com</email>
</author>
<published>2026-02-03T03:19:43Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=af5b0854fba03ce47c09ada29d535a9f702bd2ab'/>
<id>urn:sha1:af5b0854fba03ce47c09ada29d535a9f702bd2ab</id>
<content type='text'>
[ Upstream commit 5c9ecd8e6437cd55a38ea4f1e1d19cee8e226cb8 ]

dev_pm_clear_wake_irq() currently uses a dangerous pattern where
dev-&gt;power.wakeirq is read and checked for NULL outside the lock.
If two callers invoke this function concurrently, both might see
a valid pointer and proceed. This could result in a double-free
when the second caller acquires the lock and tries to release the
same object.

Address this by removing the lockless check of dev-&gt;power.wakeirq.
Instead, acquire dev-&gt;power.lock immediately to ensure the check and
the subsequent operations are atomic. If dev-&gt;power.wakeirq is NULL
under the lock, simply unlock and return. This guarantees that
concurrent calls cannot race to free the same object.

Based on a quick scan of current users, I did not find an actual bug as
drivers seem to rely on their own synchronization. However, since
asynchronous usage patterns exist (e.g., in
drivers/net/wireless/ti/wlcore), I believe a race is theoretically
possible if the API is used less carefully in the future. This change
hardens the API to be robust against such cases.

Fixes: 4990d4fe327b ("PM / Wakeirq: Add automated device wake IRQ handling")
Signed-off-by: Gui-Dong Han &lt;hanguidong02@gmail.com&gt;
Link: https://patch.msgid.link/20260203031943.1924-1-hanguidong02@gmail.com
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Sasha Levin &lt;sashal@kernel.org&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeirq: Introduce device-managed variant of dev_pm_set_wake_irq()</title>
<updated>2025-01-17T19:27:46Z</updated>
<author>
<name>Peng Fan</name>
<email>peng.fan@nxp.com</email>
</author>
<published>2025-01-03T08:41:13Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=fd8318a32573d73eb20637a0c80689de0dc98169'/>
<id>urn:sha1:fd8318a32573d73eb20637a0c80689de0dc98169</id>
<content type='text'>
Add device-managed variant of dev_pm_set_wake_irq which automatically
clear the wake irq on device destruction to simplify error handling
and resource management in drivers.

Signed-off-by: Peng Fan &lt;peng.fan@nxp.com&gt;
Link: https://patch.msgid.link/20250103-wake_irq-v2-1-e3aeff5e9966@nxp.com
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeirq: fix wake irq warning in system suspend</title>
<updated>2024-03-05T11:39:05Z</updated>
<author>
<name>Qingliang Li</name>
<email>qingliang.li@mediatek.com</email>
</author>
<published>2024-03-01T09:26:57Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e7a7681c859643f3f2476b2a28a494877fd89442'/>
<id>urn:sha1:e7a7681c859643f3f2476b2a28a494877fd89442</id>
<content type='text'>
When driver uses pm_runtime_force_suspend() as the system suspend callback
function and registers the wake irq with reverse enable ordering, the wake
irq will be re-enabled when entering system suspend, triggering an
'Unbalanced enable for IRQ xxx' warning. In this scenario, the call
sequence during system suspend is as follows:
  suspend_devices_and_enter()
    -&gt; dpm_suspend_start()
      -&gt; dpm_run_callback()
        -&gt; pm_runtime_force_suspend()
          -&gt; dev_pm_enable_wake_irq_check()
          -&gt; dev_pm_enable_wake_irq_complete()

    -&gt; suspend_enter()
      -&gt; dpm_suspend_noirq()
        -&gt; device_wakeup_arm_wake_irqs()
          -&gt; dev_pm_arm_wake_irq()

To fix this issue, complete the setting of WAKE_IRQ_DEDICATED_ENABLED flag
in dev_pm_enable_wake_irq_complete() to avoid redundant irq enablement.

Fixes: 8527beb12087 ("PM: sleep: wakeirq: fix wake irq arming")
Reviewed-by: Dhruva Gole &lt;d-gole@ti.com&gt;
Signed-off-by: Qingliang Li &lt;qingliang.li@mediatek.com&gt;
Reviewed-by: Johan Hovold &lt;johan+linaro@kernel.org&gt;
Cc: 5.16+ &lt;stable@vger.kernel.org&gt; # 5.16+
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeirq: drop unused enable helpers</title>
<updated>2023-07-24T07:51:51Z</updated>
<author>
<name>Johan Hovold</name>
<email>johan+linaro@kernel.org</email>
</author>
<published>2023-07-13T14:57:40Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=e7b915219baa4b2bf30afe1dbaca7a24ff627ad2'/>
<id>urn:sha1:e7b915219baa4b2bf30afe1dbaca7a24ff627ad2</id>
<content type='text'>
Drop the wake-irq enable and disable helpers which have not been used
since commit bed570307ed7 ("PM / wakeirq: Fix dedicated wakeirq for
drivers not using autosuspend").

Note that these functions are essentially just leftovers from the first
iteration of the wake-irq implementation where device drivers were
supposed to call these functions themselves instead of PM core (as
is also indicated by the bogus kernel doc comments).

Signed-off-by: Johan Hovold &lt;johan+linaro@kernel.org&gt;
Reviewed-by: Tony Lindgren &lt;tony@atomide.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeirq: fix wake irq arming</title>
<updated>2023-07-24T07:51:51Z</updated>
<author>
<name>Johan Hovold</name>
<email>johan+linaro@kernel.org</email>
</author>
<published>2023-07-13T14:57:39Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=8527beb12087238d4387607597b4020bc393c4b4'/>
<id>urn:sha1:8527beb12087238d4387607597b4020bc393c4b4</id>
<content type='text'>
The decision whether to enable a wake irq during suspend can not be done
based on the runtime PM state directly as a driver may use wake irqs
without implementing runtime PM. Such drivers specifically leave the
state set to the default 'suspended' and the wake irq is thus never
enabled at suspend.

Add a new wake irq flag to track whether a dedicated wake irq has been
enabled at runtime suspend and therefore must not be enabled at system
suspend.

Note that pm_runtime_enabled() can not be used as runtime PM is always
disabled during late suspend.

Fixes: 69728051f5bf ("PM / wakeirq: Fix unbalanced IRQ enable for wakeirq")
Cc: 4.16+ &lt;stable@vger.kernel.org&gt; # 4.16+
Signed-off-by: Johan Hovold &lt;johan+linaro@kernel.org&gt;
Reviewed-by: Tony Lindgren &lt;tony@atomide.com&gt;
Tested-by: Tony Lindgren &lt;tony@atomide.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeup: Fix typos in comments</title>
<updated>2022-03-01T15:17:32Z</updated>
<author>
<name>Tom Rix</name>
<email>trix@redhat.com</email>
</author>
<published>2022-02-11T16:10:27Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=7dfe105dfc724c82ed3d79a4c47439c516a2410b'/>
<id>urn:sha1:7dfe105dfc724c82ed3d79a4c47439c516a2410b</id>
<content type='text'>
Remove the second 'the'.
Replace the second 'of' with 'the'.
Replace 'couter' with 'counter'.

Signed-off-by: Tom Rix &lt;trix@redhat.com&gt;
Acked-by: Randy Dunlap &lt;rdunlap@infradead.org&gt;
Acked-by: Pavel Machek &lt;pavel@ucw.cz&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM / wakeirq: support enabling wake-up irq after runtime_suspend called</title>
<updated>2021-10-27T18:49:32Z</updated>
<author>
<name>Chunfeng Yun</name>
<email>chunfeng.yun@mediatek.com</email>
</author>
<published>2021-10-25T07:01:53Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=259714100d98b50bf04d36a21bf50ca8b829fc11'/>
<id>urn:sha1:259714100d98b50bf04d36a21bf50ca8b829fc11</id>
<content type='text'>
When the dedicated wake IRQ is level trigger, and it uses the
device's low-power status as the wakeup source, that means if the
device is not in low-power state, the wake IRQ will be triggered
if enabled; For this case, need enable the wake IRQ after running
the device's -&gt;runtime_suspend() which make it enter low-power state.

e.g.
Assume the wake IRQ is a low level trigger type, and the wakeup
signal comes from the low-power status of the device.
The wakeup signal is low level at running time (0), and becomes
high level when the device enters low-power state (runtime_suspend
(1) is called), a wakeup event at (2) make the device exit low-power
state, then the wakeup signal also becomes low level.

                ------------------
               |           ^     ^|
----------------           |     | --------------
 |&lt;---(0)---&gt;|&lt;--(1)--|   (3)   (2)    (4)

if enable the wake IRQ before running runtime_suspend during (0),
a wake IRQ will arise, it causes resume immediately;
it works if enable wake IRQ ( e.g. at (3) or (4)) after running
-&gt;runtime_suspend().

This patch introduces a new status WAKE_IRQ_DEDICATED_REVERSE to
optionally support enabling wake IRQ after running -&gt;runtime_suspend().

Suggested-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
Signed-off-by: Chunfeng Yun &lt;chunfeng.yun@mediatek.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: sleep: wakeirq: drop useless parameter from dev_pm_attach_wake_irq()</title>
<updated>2021-09-07T19:10:09Z</updated>
<author>
<name>Sergey Shtylyov</name>
<email>s.shtylyov@omp.ru</email>
</author>
<published>2021-09-02T20:57:29Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=d216bfb4d7984a510e984d2c94ae6d2251d76aee'/>
<id>urn:sha1:d216bfb4d7984a510e984d2c94ae6d2251d76aee</id>
<content type='text'>
This function has the 'irq' parameter which isn't ever used, so drop it.

Signed-off-by: Sergey Shtylyov &lt;s.shtylyov@omp.ru&gt;
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM: wakeirq: Set IRQF_NO_AUTOEN when requesting the IRQ</title>
<updated>2021-05-24T14:06:17Z</updated>
<author>
<name>Tian Tao</name>
<email>tiantao6@hisilicon.com</email>
</author>
<published>2021-05-20T07:34:58Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=558642bccede3d0e6ffebe4106b0719e29b9e4a8'/>
<id>urn:sha1:558642bccede3d0e6ffebe4106b0719e29b9e4a8</id>
<content type='text'>
request_irq() after setting IRQ_NOAUTOEN as below
irq_set_status_flags(irq, IRQ_NOAUTOEN);
request_irq(dev, irq...);
can be replaced by request_irq() with IRQF_NO_AUTOEN flag.

This change is just to simplify the code, no actual functional
changes.

Signed-off-by: Tian Tao &lt;tiantao6@hisilicon.com&gt;
Reviewed-by: Tony Lindgren &lt;tony@atomide.com&gt;
[ rjw: Subject ]
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
<entry>
<title>PM / wakeirq: remove unnecessary parentheses</title>
<updated>2019-11-13T10:31:08Z</updated>
<author>
<name>Xiaofei Tan</name>
<email>tanxiaofei@huawei.com</email>
</author>
<published>2019-10-15T08:31:30Z</published>
<link rel='alternate' type='text/html' href='https://universe.0xinfinity.dev/distro/kernel/commit/?id=01ca4827a7481ee0f92faec05db1e7d6a5097282'/>
<id>urn:sha1:01ca4827a7481ee0f92faec05db1e7d6a5097282</id>
<content type='text'>
Remove unnecessary parentheses found by code review.

Signed-off-by: Xiaofei Tan &lt;tanxiaofei@huawei.com&gt;
Signed-off-by: Rafael J. Wysocki &lt;rafael.j.wysocki@intel.com&gt;
</content>
</entry>
</feed>
