Re: [PATCH v1] PM-runtime: Check supplier_preactivated before release supplier

From: Peter Wang
Date: Tue Aug 02 2022 - 09:33:26 EST



On 8/2/22 7:01 PM, Rafael J. Wysocki wrote:
On Tue, Aug 2, 2022 at 5:19 AM Peter Wang <peter.wang@xxxxxxxxxxxx> wrote:

Hi Rafael,

Yes, it is very clear!
I miss this important key point that usage_count is always >
rpm_active 1.
I think this patch could work.

Thanks.
Peter




Hi Rafael,

After test with commit ("887371066039011144b4a94af97d9328df6869a2 PM:
runtime: Fix supplier device management during consumer probe") past weeks,
The supplier still suspend when consumer is active "after"
pm_runtime_put_suppliers.
Do you have any idea about that?
Well, this means that the consumer probe doesn't bump up the
supplier's PM-runtime usage counter as appropriate.

You need to tell me more about what happens during the consumer probe.
Which driver is this?

Hi Rafael,

I have the same idea with you. But I still don't know how it could happen.

It is upstream ufs driver in scsi system. Here is call flow
do_scan_async (process 1)
    do_scsi_scan_host
        scsi_scan_host_selected
            scsi_scan_channel
                __scsi_scan_target
                    scsi_probe_and_add_lun
                        scsi_alloc_sdev
                            slave_alloc     -> setup link
                        scsi_add_lun
                            slave_configure    -> enable rpm
                            scsi_sysfs_add_sdev
                                scsi_autopm_get_device    <- get runtime pm
                                device_add                <- invoke sd_probe in process 2
                                scsi_autopm_put_device    <- put runtime pm, point 1

driver_probe_device (process 2)
    __driver_probe_device
        pm_runtime_get_suppliers
            really_probe
                sd_probe
                    scsi_autopm_get_device                <- get runtime pm, point 2
                    pm_runtime_set_autosuspend_delay    <- set rpm delay to 2s
                    scsi_autopm_put_device                <- put runtime pm
        pm_runtime_put_suppliers                        <- (link->rpm_active = 1)

After process 1 call scsi_autopm_put_device(point 1) let consumer enter suspend,
process 2 call scsi_autopm_get_device(point 2) may have chance resume consumer but not
bump up the supplier's PM-runtime usage counter as appropriate.

Thanks.
Peter