Re: [PATCH 09/11] scsi: ufs: Fix a kernel crash during shutdown

Bart Van Assche
2021-11-15T18:47:35Z

On 11/10/21 11:48 PM, Avri Altman wrote:
>> @@ -1961,11 +1962,15 @@ static void ufshcd_exit_clk_gating(struct ufs_hba
>> *hba) {
>> if (!hba->clk_gating.is_initialized)
>> return;
>> +
>> ufshcd_remove_clk_gating_sysfs(hba);
>> - cancel_work_sync(&hba->clk_gating.ungate_work);
>> - cancel_delayed_work_sync(&hba->clk_gating.gate_work);
>> - destroy_workqueue(hba->clk_gating.clk_gating_workq);
>> +
>> + /* Ungate the clock if necessary. */
>> + ufshcd_hold(hba, false);
>> hba->clk_gating.is_initialized = false;
>> + ufshcd_release(hba);
>
> Not sure that the symmetry in calling ufshcd_release() is meaningful here?
> You don't really want to queue a new gate work, this is why you added !.is_initialized to release(),
> Or did I get it wrong?

Hi Avri,

The purpose of the above changes is as follows:
* Call ufshcd_hold() to ungate the clock and also to wait for any
pending work.
* Change hba->clk_gating.is_initialized from true to false to make sure
that the clock remains ungated and also that no new work is queued.
* Call ufshcd_release() to decrement hba->clk_gating.active_reqs.

Thanks,

Bart.