Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Kartik Rajput" <kkartik@nvidia.com>
Cc: linux-scsi@vger.kernel.org, devicetree@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v3 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver
Date: Tue, 01 Dec 2026 11:45:15 +0000	[thread overview]
Message-ID: <sashiko-outbox-243213@kernel.org> (raw)
In-Reply-To: <20261201-tegra264-ufs-v3-4-1d04d40388a4@nvidia.com>

Thank you for your contribution! Sashiko AI review found 4 potential
issues to consider:
- [High] scsi: ufs: tegra: probe fails with -ENODEV in
  ufs_tegra_parse_clock_info()
- [High] scsi: ufs: tegra: missing prepare and complete callbacks in
  ufs_tegra_pm_ops
- [Medium] scsi: ufs: tegra: missing device_reset op leaves WriteBooster
  state stale
- [Medium] scsi: ufs: tegra: missing reset assertion and aux cleanup in
  ufs_tegra_exit()
--

commit 9955cb7a8be25d99221a19b3ca6c4dc209b70aaf
Author: Kartik Rajput <kkartik@nvidia.com>

scsi: ufs: tegra: Add Tegra264 UFS host controller driver

This commit adds a platform driver for the UFS host controller on NVIDIA
Tegra264 SoCs, handling Tegra-specific auxiliary registers, clocks,
resets, and M-PHY lane operations.

> diff --git a/drivers/ufs/host/ufs-tegra.c b/drivers/ufs/host/ufs-tegra.c
> new file mode 100644
> index 0000000000000..3819530e8371d
> --- /dev/null
> +++ b/drivers/ufs/host/ufs-tegra.c
> @@ -0,0 +1,696 @@

[ ... ]

> +static int ufs_tegra_parse_clock_info(struct ufs_hba *hba)
> +{
> +	struct ufs_tegra *ufs = ufshcd_get_variant(hba);
> +	struct ufs_clk_info *clki;
> +
> +	list_for_each_entry(clki, &hba->clk_list_head, list) {
> +		if (!strcmp(clki->name, "core"))
> +			ufs->core_clk = clki->clk;
> +
> +		if (!strcmp(clki->name, "hs"))
> +			ufs->hs_clk = clki->clk;
> +	}
> +
> +	if (!ufs->core_clk || !ufs->hs_clk)
> +		return -ENODEV;
> +
> +	return 0;
> +}

[Severity: High]
Does ufs_tegra_parse_clock_info() always fail probe with -ENODEV on a
Device Tree node matching Documentation/devicetree/bindings/ufs/nvidia,tegra264-ufs.yaml?

In drivers/ufs/host/ufshcd-pltfrm.c, ufshcd_parse_clock_info() returns
early without populating hba->clk_list_head unless the node specifies
freq-table-hz, and ufshcd_parse_operating_points() does the same unless
operating-points-v2 is present.  Neither property is defined in the
Tegra264 UFS binding (and UFS_TEGRA_HS_CLK_RATE_HZ at 5840000000UL does
not fit in a 32-bit freq-table-hz cell or u32 clki->max_freq), so
hba->clk_list_head stays empty, the controller clocks are never acquired
or enabled by UFSHCD, and ufs->core_clk and ufs->hs_clk remain NULL.

[ ... ]

> +static int ufs_tegra_init(struct ufs_hba *hba)
> +{

[ ... ]

> +	err = reset_control_bulk_deassert(ufs->num_resets, ufs->resets);
> +	if (err)
> +		return err;
> +
> +	ufs_tegra_aux_init(hba);
> +	ufs_tegra_update_hclk_div(hba);
> +
> +	return 0;
> +}

[ ... ]

> +static void ufs_tegra_exit(struct ufs_hba *hba)
> +{
> +	ufs_tegra_mphy_disable(hba);
> +}

[Severity: Medium]
Should ufs_tegra_exit() also clear DEV_CTRL_CLK_EN | DEV_CTRL_RESET in
UFSHC_AUX_DEV_CTRL and assert ufs->resets?

ufs_tegra_init() deasserts the exclusive bulk resets and enables the
auxiliary device clock and reset line via ufs_tegra_aux_init().  When
ufshcd_init() fails after ufshcd_hba_init() or the driver is unbound,
ufshcd_hba_exit() calls ufs_tegra_exit() and then turns off the clocks and
regulators while UFSHC_AUX_DEV_CTRL remains enabled and the controller
resets remain deasserted.

[ ... ]

> +static int ufs_tegra_hce_enable_notify(struct ufs_hba *hba, enum ufs_notify_change_status status)
> +{
> +	struct ufs_tegra *ufs = ufshcd_get_variant(hba);
> +	u32 value;
> +	int err;
> +
> +	switch (status) {
> +	case PRE_CHANGE:
> +		err = ufs_tegra_power_up_sequence(hba);
> +		if (err)
> +			return err;
> +
> +		/*
> +		 * Assert device reset; POST_CHANGE releases it via
> +		 * ufs_tegra_configure_aux() so the HCE toggle pulses it.
> +		 */
> +		value = readl(ufs->aux + UFSHC_AUX_DEV_CTRL);
> +		value &= ~DEV_CTRL_RESET;
> +		writel(value, ufs->aux + UFSHC_AUX_DEV_CTRL);
> +		break;
> +	case POST_CHANGE:
> +		value = readl(ufs->aux + UFSHC_AUX_SW_EN_CLK_SLCG);
> +		value &= ~CLK_OVR_ON;
> +		writel(value, ufs->aux + UFSHC_AUX_SW_EN_CLK_SLCG);
> +
> +		ufs_tegra_setup(hba);
> +		break;
> +	default:
> +		return -EINVAL;
> +	}
> +
> +	return 0;
> +}

[ ... ]

> +static const struct ufs_hba_variant_ops ufs_tegra_vops = {
> +	.name = "ufs-tegra",
> +	.init = ufs_tegra_init,
> +	.exit = ufs_tegra_exit,
> +	.suspend = ufs_tegra_suspend,
> +	.resume = ufs_tegra_resume,
> +	.hce_enable_notify = ufs_tegra_hce_enable_notify,
> +	.negotiate_pwr_mode = ufs_tegra_negotiate_pwr_mode,
> +	.pwr_change_notify = ufs_tegra_pwr_change_notify,
> +	.link_startup_notify = ufs_tegra_link_startup_notify,
> +	.set_dma_mask = ufs_tegra_set_dma_mask,
> +};

[Severity: Medium]
Does pulsing DEV_CTRL_RESET in ufs_tegra_hce_enable_notify() without
implementing .device_reset in ufs_tegra_vops leave WriteBooster disabled
after system resume or host error recovery?

ufs_tegra_set_caps() enables UFSHCD_CAP_WB_EN and sets hba->spm_lvl to
UFS_PM_LVL_5.  On resume from UFS_PM_LVL_5 (or during error recovery),
ufshcd_reset_and_restore() calls ufshcd_device_reset(), which only clears
hba->dev_info.wb_enabled and hba->dev_info.wb_buf_flush_enabled and marks
the device active when vops->device_reset is implemented:

drivers/ufs/core/ufshcd.c:ufshcd_device_reset() {
    ...
	err = ufshcd_vops_device_reset(hba);

	if (!err) {
		ufshcd_set_ufs_dev_active(hba);
		if (ufshcd_is_wb_allowed(hba)) {
			hba->dev_info.wb_enabled = false;
			hba->dev_info.wb_buf_flush_enabled = false;
		}
    ...
}

Because ufs_tegra_hce_enable_notify() then hardware-resets the UFS device
via DEV_CTRL_RESET, the volatile WriteBooster flags on the device are
cleared while hba->dev_info.wb_enabled stays true in software, causing
ufshcd_wb_toggle() to return early without re-enabling WriteBooster.
Leaving hba->curr_dev_pwr_mode at UFS_POWERDOWN_PWR_MODE also makes
ufshcd_link_startup() set link_startup_again = true and run link startup
twice.

[ ... ]

> +static const struct dev_pm_ops ufs_tegra_pm_ops = {
> +	SET_SYSTEM_SLEEP_PM_OPS(ufshcd_system_suspend, ufshcd_system_resume)
> +	SET_RUNTIME_PM_OPS(ufshcd_runtime_suspend, ufshcd_runtime_resume, NULL)
> +};

[Severity: High]
Does omitting .prepare = ufshcd_suspend_prepare and
.complete = ufshcd_resume_complete from ufs_tegra_pm_ops break system
suspend when the controller is already runtime-suspended?

ufs_tegra_set_caps() sets hba->spm_lvl = UFS_PM_LVL_5 (UIC_LINK_OFF_STATE)
while hba->rpm_lvl stays at the default UFS_PM_LVL_3
(UIC_LINK_HIBERN8_STATE), where ufs_tegra_suspend() leaves the M-PHY
powered on during runtime suspend.  When the UFS device W-LUN is already
runtime-suspended, ufshcd_wl_system_suspend() and ufshcd_system_suspend()
both return early without running __ufshcd_wl_suspend(hba, UFS_SYSTEM_PM)
unless ufshcd_suspend_prepare() first runtime-resumes the W-LUN because
rpm_lvl and spm_lvl differ.  As a result, ufs_tegra_suspend() is never
called for UFS_SYSTEM_PM, the M-PHY stays powered on during system sleep,
and hba->uic_link_state remains UIC_LINK_HIBERN8_STATE instead of
UIC_LINK_OFF_STATE.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201-tegra264-ufs-v3-0-1d04d40388a4@nvidia.com?part=4

      reply	other threads:[~2026-12-01 11:45 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-01 11:22 [PATCH v3 0/4] Add UFS host controller support for NVIDIA Tegra264 Kartik Rajput
2026-12-01 11:22 ` [PATCH v3 1/4] dt-bindings: ufs: Add nvidia,tegra264-ufs Kartik Rajput
2026-12-01 11:27   ` sashiko-bot
2026-12-01 11:22 ` [PATCH v3 2/4] scsi: ufs: Add UIC DEBUGSAVECONFIGTIME attribute and its field masks Kartik Rajput
2026-12-01 11:22 ` [PATCH v3 3/4] scsi: ufs: hisi: Use VS_DEBUGSAVECONFIGTIME instead of a literal address Kartik Rajput
2026-12-01 11:22 ` [PATCH v3 4/4] scsi: ufs: tegra: Add Tegra264 UFS host controller driver Kartik Rajput
2026-12-01 11:45   ` sashiko-bot [this message]

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=sashiko-outbox-243213@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=kkartik@nvidia.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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