Re: [PATCH v3 2/4] PM / QoS: add lockless read for flags
Kevin Hilman <[email protected]>
| Newsgroups | org.kernel.vger.linux-pm,org.kernel.vger.linux-kernel |
|---|---|
| Message-ID | <[email protected]> |
"Rafael J. Wysocki (Intel)" <[email protected]> writes: > On Thu, Jun 11, 2026 at 9:59 PM Kevin Hilman (TI) <[email protected]> wrote: >> >> Add a lockless read for QoS flags similar to the lockless read for >> resume latency (dev_pm_qos_raw_resume_latency) which may be called >> from atomic context (e.g. genpd governors running under a raw spinlock >> or in the syscore suspend path), where taking that sleeping lock would >> be invalid on PREEMPT_RT. >> >> Signed-off-by: Kevin Hilman (TI) <[email protected]> >> --- >> include/linux/pm_qos.h | 7 +++++++ >> 1 file changed, 7 insertions(+) >> >> diff --git a/include/linux/pm_qos.h b/include/linux/pm_qos.h >> index aededda52b6b..439a9e779d81 100644 >> --- a/include/linux/pm_qos.h >> +++ b/include/linux/pm_qos.h >> @@ -219,6 +219,12 @@ static inline s32 dev_pm_qos_raw_resume_latency(struct device *dev) >> PM_QOS_RESUME_LATENCY_NO_CONSTRAINT : >> pm_qos_read_value(&dev->power.qos->resume_latency); >> } >> + >> +static inline s32 dev_pm_qos_raw_flags(struct device *dev) >> +{ >> + return IS_ERR_OR_NULL(dev->power.qos) ? >> + 0 : READ_ONCE(dev->power.qos->flags.effective_flags); > > So if you add READ_ONCE() on the reader side, all updates of it need > to go under WRITE_ONCE(), or the READ_ONCE() may still not be > effective. > > I don't think they are under WRITE_ONCE() ATM. Ah, good catch. Thanks for the review, I'll fix that in v4. Kevin