mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Peter Wang <peter.wang@mediatek.com>
To: Naomi Chu <naomi.chu@mediatek.com>, <linux-scsi@vger.kernel.org>,
	<mkp@kernel.org>, <avri.altman@sandisk.com>,
	<alim.akhtar@samsung.com>,
	<James.Bottomley@HansenPartnership.com>, <bvanassche@acm.org>
Cc: <wsd_upstream@mediatek.com>, <alice.chao@mediatek.com>,
	<chun-hung.wu@mediatek.com>, <linux-mediatek@lists.infradead.org>,
	<linux-kernel@vger.kernel.org>, <ed.tsai@mediatek.com>
Subject: Re: [PATCH v1] scsi: ufs: core: Hold a clock reference across the probe
Date: Mon, 21 Sep 2026 21:21:00 +0800	[thread overview]
Message-ID: <21231fed9487b88316da067d9a7f6fbb812e7f98.camel@mediatek.com> (raw)
In-Reply-To: <20260909091045.1134956-1-naomi.chu@mediatek.com>

On Wed, 2026-09-09 at 17:10 +0800, Naomi Chu wrote:
> Clock gating becomes possible as soon as ufshcd_init_clk_gating() has
> run, and from that point on the probe keeps accessing host registers
> without ever taking a clock reference. This has been safe only
> because
> of the state check in __ufshcd_release(): gate_work is not queued
> unless hba->ufshcd_state is UFSHCD_STATE_OPERATIONAL, and the
> promotion
> to that state used to happen after the last register access of the
> probe, at the end of ufshcd_probe_hba().
> 
> That is fragile: it only works while the promotion happens after the
> register accesses. Commit a390e6677f41 ("scsi: ufs: core: Expand the
> ufshcd_device_init(hba, true) call") changed that ordering by moving
> the promotion into ufshcd_init(), which schedules ufshcd_async_scan()
> afterwards. ufshcd_probe_hba() therefore now runs with the state
> already promoted, and it accesses host registers without holding a
> clock reference:
> 
>  - on hosts with UFSHCD_QUIRK_REINIT_AFTER_MAX_GEAR_SWITCH it calls
>    ufshcd_hba_stop() and ufshcd_hba_enable() before
>    ufshcd_device_init() sets the state back to UFSHCD_STATE_RESET,
> and
>    both read REG_CONTROLLER_ENABLE, so gated clocks stall there
> instead
>    of just losing a write.
>  - it ends with an ufshcd_configure_auto_hibern8() write, which its
>    other callers do take a clock reference for.
> 
> Take a clock reference as soon as clock gating has been initialised
> and
> keep it until the probe is over. It then does not matter who drops a
> clock reference while the probe is running, and the register accesses
> of the probe no longer depend on hba->ufshcd_state. The reference is
> dropped by ufshcd_async_scan() once the scan has finished, or by the
> new out_release label if the probe fails after it was taken.
> 
> Fixes: a390e6677f41 ("scsi: ufs: core: Expand the
> ufshcd_device_init(hba, true) call")
> Signed-off-by: Naomi Chu <naomi.chu@mediatek.com>
> ---

Reviewed-by: Peter Wang <peter.wang@mediatek.com>

  reply	other threads:[~2026-09-21 13:21 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-09-09  9:10 Naomi Chu
2026-09-21 13:21 ` Peter Wang [this message]
2026-10-01  8:41 ` Stanley Jhu
2026-10-06  2:43 ` Martin K. Petersen (Oracle)

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=21231fed9487b88316da067d9a7f6fbb812e7f98.camel@mediatek.com \
    --to=peter.wang@mediatek.com \
    --cc=James.Bottomley@HansenPartnership.com \
    --cc=alice.chao@mediatek.com \
    --cc=alim.akhtar@samsung.com \
    --cc=avri.altman@sandisk.com \
    --cc=bvanassche@acm.org \
    --cc=chun-hung.wu@mediatek.com \
    --cc=ed.tsai@mediatek.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=linux-scsi@vger.kernel.org \
    --cc=mkp@kernel.org \
    --cc=naomi.chu@mediatek.com \
    --cc=wsd_upstream@mediatek.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

all inboxes | Powered by JetHome®