Re: [PATCH] PM: add: move warn message out of mutex lock.

From: David Wang
Date: Tue Sep 03 2024 - 12:17:15 EST


Hi,

At 2024-09-03 22:10:16, "Rafael J. Wysocki" <rafael@xxxxxxxxxx> wrote:
>On Tue, Sep 3, 2024 at 3:01 PM Rafael J. Wysocki <rafael@xxxxxxxxxx> wrote:
>>
>> On Mon, Sep 2, 2024 at 7:50 AM David Wang <00107082@xxxxxxx> wrote:
>> >
>> > dpm_list_mtx does not protect any data used by
>> > dev_warn for checking parent's power, move
>> > dev_warn out of mutex lock block make the
>> > lock more efficient, especially when the warn
>> > is triggered.
>>
>> It does protect the power.is_prepared flag of the parent.
>
>In fact, the update of it in device_resume() is racy with respect to
>the check in device_pm_add(), but the purpose of it is mostly to allow
>the device driver's resume callback to add children without triggering
>the warning.


Kind of confused by this... if dpm_list_mtx could protect power.is_prepared,
then codes that change power.is_prepared should also hold this lock, but normally
they only use device_lock(dev);


David