Re: [RESEND PATCH v3 0/2] change UIC command handling

From: Adrian Hunter
Date: Mon Sep 11 2023 - 03:10:45 EST


On 11/09/23 09:32, Kiwoong Kim wrote:
>>>> ufs: poll HCS.UCRDY before issuing a UIC command
>>>
>>> [ 4671.226480] [3: kworker/u20:29:17140] BUG: scheduling while atomic:
>>> kworker/u20:29/17140/0x00000002
>>> ..
>>> [ 4671.228723] [3: kworker/u20:29:17140] panic+0x16c/0x388 [
>>> 4671.228745] [3: kworker/u20:29:17140] check_panic_on_warn+0x60/0x94
>>> [ 4671.228764] [3: kworker/u20:29:17140] __schedule_bug+0x6c/0x94 [
>>> 4671.228786] [3: kworker/u20:29:17140] __schedule+0x6f4/0xa64 [
>>> 4671.228806] [3: kworker/u20:29:17140] schedule+0x7c/0xe8 [
>>> 4671.228824] [3: kworker/u20:29:17140]
>>> schedule_hrtimeout_range_clock+0x98/0x114
>>> [ 4671.228841] [3: kworker/u20:29:17140]
>>> schedule_hrtimeout_range+0x14/0x24
>>> [ 4671.228856] [3: kworker/u20:29:17140] usleep_range_state+0x60/0x94
>>> [ 4671.228871] [3: kworker/u20:29:17140]
>>> __ufshcd_send_uic_cmd+0xa0/0x1c4 [ 4671.228893] [3:
>>> kworker/u20:29:17140] ufshcd_uic_pwr_ctrl+0x15c/0x390 [ 4671.228908]
>>> [3: kworker/u20:29:17140] ufshcd_uic_hibern8_enter+0x9c/0x25c
>>> [ 4671.228922] [3: kworker/u20:29:17140]
>>> ufshcd_link_state_transition+0x34/0xb0
>>> [ 4671.228939] [3: kworker/u20:29:17140]
>>> __ufshcd_wl_suspend+0x3f0/0x4b4
>>
>> Do you know what is in that path that makes it an atomic context?
>
> Hi,
> This made that.
>
> static int ufshcd_uic_pwr_ctrl(struct ufs_hba *hba, struct uic_command *cmd)
> ..
> bool reenable_intr = false;
>
> mutex_lock(&hba->uic_cmd_mutex); <<<<

It is OK to schedule while holding a mutex. Are you sure
this is the problem?

>
>
> At first, I was willing to post together w/ the following patch but I've got a suggestion to split the patch set because of different topic and I split the patch set.
> - This patch removes the mutex, so it can fix the issue.
> https://lore.kernel.org/linux-scsi/1694051306-172962-1-git-send-email-kwmad.kim@xxxxxxxxxxx/
>
>
> But now I'm thinking again that simply removing the mutex could hurt atomicity of UIC command process
> that the original code intended for the first time.
> So I think this polling UCRDY should be modified rather than applying removal of the mutex.
>
>
>