Re: [RFC PATCH 05/13] scsi: ufs: ufshpb: Disable HPB if no HPB-enabled luns

From: Bart Van Assche
Date: Fri May 15 2020 - 22:03:24 EST


On 2020-05-15 03:30, Avri Altman wrote:
> @@ -368,6 +390,8 @@ int ufshpb_probe(struct ufs_hba *hba)
> if (ret)
> goto out;
>
> + INIT_DELAYED_WORK(&hba->hpb_disable_work, ufshpb_disable_work);
> + schedule_delayed_work(&hba->hpb_disable_work, 60 * HZ);
> out:
> kfree(dev_desc);
> if (ret) {

Calling INIT_DELAYED_WORK() just before schedule_delayed_work() is a bad
practice. If cancel_delayed_work() gets called before
INIT_DELAYED_WORK() then it will encounter something that it not
expects. If cancel_delayed_work() and INIT_DELAYED_WORK() get called
concurrently than that will trigger a race condition. It is better to
call INIT_DELAYED_WORK() from the context that allocates the data
structure in which the work structure is embedded.

Thanks,

Bart.