2023-11-15 05:28:15

by SEO HOYOUNG

[permalink] [raw]
Subject: RE: [PATCH v2] scsi: ufs: core: fix racing issue during ufshcd_mcq_abort

> -----Original Message-----
> From: Bart Van Assche <[email protected]>
> Sent: Wednesday, November 15, 2023 2:55 AM
> To: SEO HOYOUNG <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH v2] scsi: ufs: core: fix racing issue during
> ufshcd_mcq_abort
>
> On 11/13/23 20:37, SEO HOYOUNG wrote:
> > diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> > index 9a730a794b66..55f4c0eeda7b 100644
> > --- a/drivers/ufs/core/ufshcd.c
> > +++ b/drivers/ufs/core/ufshcd.c
> > @@ -7574,6 +7574,10 @@ int ufshcd_try_to_abort_task(struct ufs_hba *hba,
> int tag)
> > goto out;
> > }
> >
> > + if (!ufshcd_cmd_inflight(lrbp->cmd) ||
> > + test_bit(SCMD_STATE_COMPLETE, &lrbp->cmd->state))
> > + goto out;
> > +
> > err = ufshcd_clear_cmd(hba, tag);
> > if (err)
> > dev_err(hba->dev, "%s: Failed clearing cmd at tag %d,
> err %d\n",
>
> The UFS driver must not set SCMD_STATE_COMPLETE itself. Only the SCSI core
> is allowed to set that bit.
>
> Thanks,
>
> Bart.

Hi,

The test_bit() function just check SCMD_STATE_COMPLETE bit state.
Do not set SCMD_STATE_COMPLETE field.
This function is also used in ufshcd_mcq_compl_pending_transfer()
to check the status of cmd.

Thanks.
BRs SEO.


2023-11-15 18:22:37

by Bart Van Assche

[permalink] [raw]
Subject: Re: [PATCH v2] scsi: ufs: core: fix racing issue during ufshcd_mcq_abort

On 11/14/23 21:27, hoyoung seo wrote:
> The test_bit() function just check SCMD_STATE_COMPLETE bit state.
> Do not set SCMD_STATE_COMPLETE field.
> This function is also used in ufshcd_mcq_compl_pending_transfer()
> to check the status of cmd.

Right, I misread your patch. Can you please take a look at the following
patch and verify whether it perhaps addresses the same issue that you want
to address: https://lore.kernel.org/linux-scsi/[email protected]/

Thanks,

Bart.

2023-11-16 01:56:47

by SEO HOYOUNG

[permalink] [raw]
Subject: RE: [PATCH v2] scsi: ufs: core: fix racing issue during ufshcd_mcq_abort

> -----Original Message-----
> From: Bart Van Assche <[email protected]>
> Sent: Thursday, November 16, 2023 3:22 AM
> To: hoyoung seo <[email protected]>; [email protected]; linux-
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]; [email protected];
> [email protected]; [email protected]
> Subject: Re: [PATCH v2] scsi: ufs: core: fix racing issue during
> ufshcd_mcq_abort
>
> On 11/14/23 21:27, hoyoung seo wrote:
> > The test_bit() function just check SCMD_STATE_COMPLETE bit state.
> > Do not set SCMD_STATE_COMPLETE field.
> > This function is also used in ufshcd_mcq_compl_pending_transfer()
> > to check the status of cmd.
>
> Right, I misread your patch. Can you please take a look at the following
> patch and verify whether it perhaps addresses the same issue that you want
> to address: https://lore.kernel.org/linux-scsi/20231115131024.15829-1-
> [email protected]/
>
> Thanks,
>
> Bart.

Hi, Bart.

It seem that not same issue.
That problem is that the try_to_abort_task() function has already been
processed.
So clear_cmd() has been processed.

However, this issue was already completed IO request before executing clear_cmd().
So can't get utag to clean up sq.
This patch to prevent access to utag for cmd that has already been completed.

Thanks
Seo.