RE: Re: [PATCH v4] PM / devfreq: Synchronize device_monitor_[start/stop]

From: MyungJoo Ham
Date: Mon Dec 11 2023 - 20:10:10 EST


On 11/25/2023 2:41 AM, Mukesh Ojha wrote:
> There is a chance if a frequent switch of the governor
> done in a loop result in timer list corruption where
> timer cancel being done from two place one from
> cancel_delayed_work_sync() and followed by expire_timers()
> can be seen from the traces[1].
>
> while true
> do
>          echo "simple_ondemand" > /sys/class/devfreq/1d84000.ufshc/governor
>          echo "performance" > /sys/class/devfreq/1d84000.ufshc/governor
> done
>
> It looks to be issue with devfreq driver where
> device_monitor_[start/stop] need to synchronized so that
> delayed work should get corrupted while it is either
> being queued or running or being cancelled.
>
> Let's use polling flag and devfreq lock to synchronize the
> queueing the timer instance twice and work data being
> corrupted.

Would you please identify the resources to be protected by this lock
and specify them in the devfreq->lock declaration?
(it seems the list of protected resources is growing, and
we need to track them.)

Acked-by: MyungJoo Ham <myungjoo.ham@xxxxxxxxxxx>