From: Bart Van Assche <bvanassche@acm.org>
To: Avri Altman <avri.altman@wdc.com>,
"Martin K . Petersen" <martin.petersen@oracle.com>
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] scsi: ufs: core: Do not hold any lock in ufshcd_hba_stop
Date: Mon, 25 Nov 2024 15:07:18 -0800 [thread overview]
Message-ID: <87f1bb6b-6a8e-4bfd-8c1f-d63c857a176e@acm.org> (raw)
In-Reply-To: <20241124110747.206651-1-avri.altman@wdc.com>
On 11/24/24 3:07 AM, Avri Altman wrote:
> This change is motivated by Bart's suggestion in [1], which enables to
> further reduce the scsi host lock usage in the ufs driver. The reason
> why it make sense, because although the legacy interrupt is disabled by
> some but not all ufshcd_hba_stop() callers, it is safe to nest
> disable_irq() calls as it checks the irq depth.
>
> [1] https://lore.kernel.org/linux-scsi/c58e4fce-0a74-4469-ad16-f1edbd670728@acm.org/
>
> Suggested-by: Bart Van Assche <bvanassche@acm.org>
> Signed-off-by: Avri Altman <avri.altman@wdc.com>
> ---
> drivers/ufs/core/ufshcd.c | 9 ++-------
> 1 file changed, 2 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/ufs/core/ufshcd.c b/drivers/ufs/core/ufshcd.c
> index acc3607bbd9c..09a5ff49da5a 100644
> --- a/drivers/ufs/core/ufshcd.c
> +++ b/drivers/ufs/core/ufshcd.c
> @@ -4811,16 +4811,11 @@ EXPORT_SYMBOL_GPL(ufshcd_make_hba_operational);
> */
> void ufshcd_hba_stop(struct ufs_hba *hba)
> {
> - unsigned long flags;
> int err;
>
> - /*
> - * Obtain the host lock to prevent that the controller is disabled
> - * while the UFS interrupt handler is active on another CPU.
> - */
> - spin_lock_irqsave(hba->host->host_lock, flags);
> + ufshcd_disable_irq(hba);
> ufshcd_writel(hba, CONTROLLER_DISABLE, REG_CONTROLLER_ENABLE);
> - spin_unlock_irqrestore(hba->host->host_lock, flags);
> + ufshcd_enable_irq(hba);
>
> err = ufshcd_wait_for_register(hba, REG_CONTROLLER_ENABLE,
> CONTROLLER_ENABLE, CONTROLLER_DISABLE,
Shouldn't the ufshcd_enable_irq() call be moved below the
ufshcd_wait_for_register() call? Otherwise a race condition could cause
the interrupt handler to be triggered while the controller is being
disabled.
Thanks,
Bart.
next prev parent reply other threads:[~2024-11-25 23:07 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-24 11:07 [PATCH] scsi: ufs: core: Do not hold any lock in ufshcd_hba_stop Avri Altman
2024-11-25 23:07 ` Bart Van Assche [this message]
2024-11-28 7:13 ` Avri Altman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87f1bb6b-6a8e-4bfd-8c1f-d63c857a176e@acm.org \
--to=bvanassche@acm.org \
--cc=avri.altman@wdc.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox