Linux kernel and device drivers for NXP i.MX platforms
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Larisa Grigore" <larisa.grigore@oss.nxp.com>
Cc: linux-scsi@vger.kernel.org, imx@lists.linux.dev,
	devicetree@vger.kernel.org, robh@kernel.org, conor+dt@kernel.org,
	Frank.Li@kernel.org, wsa+renesas@sang-engineering.com
Subject: Re: [PATCH v12 13/14] ufs: s32n7: Add NXP S32N79 UFS host controller driver
Date: Fri, 04 Dec 2026 09:03:05 +0000	[thread overview]
Message-ID: <sashiko-outbox-249455@kernel.org> (raw)
In-Reply-To: <20261204-b4-ufs-s32n7-v12-13-4cf32fc871a0@oss.nxp.com>

Thank you for your contribution! Sashiko AI review found 2 potential
issues to consider:
- [Medium] ufs: s32n7: core clock validation deferred to ignored
  PRE_CHANGE callback
- [Medium] ufs: s32n7: missing rx_ack handshake poll and RMW on M-PHY CR
  registers
--

commit 71fbee8676eb46720c3c097be12d5179f583c74a
Author: Larisa Grigore <larisa.grigore@oss.nxp.com>

ufs: s32n7: Add NXP S32N79 UFS host controller driver

This patch adds a platform UFS host controller driver for the NXP S32N79
SoC built on top of the UFSHCD DWC and platform glue.

> diff --git a/drivers/ufs/host/ufs-nxp-s32n7.c b/drivers/ufs/host/ufs-nxp-s32n7.c
> new file mode 100644
> index 0000000000000..8d73a7179d992
> --- /dev/null
> +++ b/drivers/ufs/host/ufs-nxp-s32n7.c
> @@ -0,0 +1,546 @@

[ ... ]

> +static int ufs_s32n7_configure_clocks(struct ufs_hba *hba)
> +{
> +	struct s32n7_ufs *ufs = ufshcd_get_variant(hba);
> +	struct device *dev = hba->dev;
> +	struct ufs_clk_info *clki;
> +	unsigned long clk_rate = 0;
> +	unsigned long one_us_tick;
> +
> +	/*
> +	 * The core reference clock is managed by the UFS core (it is listed in
> +	 * the DT via clock-names as a fixed rate clock and added to
> +	 * hba->clk_list_head). Read its rate from there to derive
> +	 * ONE_US_TICK/HCLKDIV.
> +	 */
> +	list_for_each_entry(clki, &hba->clk_list_head, list) {
> +		if (!IS_ERR_OR_NULL(clki->clk) &&
> +		    !strcmp(clki->name, "core")) {
> +			clk_rate = clk_get_rate(clki->clk);
> +			break;
> +		}
> +	}
> +
> +	if (!clk_rate) {
> +		dev_err(dev, "Failed to get valid clock rate.\n");
> +		return -EINVAL;
> +	}
> +
> +	one_us_tick = clk_rate / USEC_PER_SEC;
> +	if (one_us_tick == 0 || one_us_tick > MAX_VALID_ONE_US_TICK) {
> +		dev_err(dev, "Invalid one_us_tick value: %lu (clk_rate: %lu Hz).\n",
> +			one_us_tick, clk_rate);
> +		return -EINVAL;
> +	}

[Severity: Medium]
Can an invalid or missing "core" clock slip past probe when validated here?

ufs_s32n7_configure_clocks() only runs from
ufs_s32n7_link_startup_pre_change(), and ufshcd_link_startup() ignores the
return value of ufshcd_vops_link_startup_notify(hba, PRE_CHANGE) before
calling ufshcd_dme_link_startup().

If the DT omits the "core" clock or reports an out-of-range rate, returning
-EINVAL skips SCM_ONE_US_TICK, DWC_UFS_REG_HCLKDIV, PHY reset, and M-PHY
calibration, yet link startup still runs and can silently succeed if
firmware left the PHY active.

Validating and caching one_us_tick in ufs_s32n7_init() (whose return value
aborts probe in ufshcd_hba_init()) while keeping the register writes in
ufs_s32n7_link_startup_pre_change() would reject bad clock setups cleanly.

[ ... ]

> +static int ufs_s32n7_pwr_change_pre_change(struct ufs_hba *hba,
> +					   const struct ufs_pa_layer_attr *pwr)
> +{
> +	/*
> +	 * RX rate-select override sequence: assert the override, then deassert
> +	 * the value, then drop the override enable so normal operation resumes.
> +	 */
> +	static const struct s32n7_phy_reg pwr_change_phy_regs[] = {
> +		{ RX_OVRD_IN_1(0), MPHY_RX_OVRD_EN | MPHY_RX_OVRD_VAL },
> +		{ RX_OVRD_IN_1(1), MPHY_RX_OVRD_EN | MPHY_RX_OVRD_VAL },
> +		{ RX_OVRD_IN_1(0), MPHY_RX_OVRD_EN },
> +		{ RX_OVRD_IN_1(1), MPHY_RX_OVRD_EN },
> +		{ RX_OVRD_IN_1(0), 0x0 },
> +		{ RX_OVRD_IN_1(1), 0x0 },
> +	};

[Severity: Medium]
Can writing RX_OVRD_IN_1 back-to-back without polling RX_PCS_OUT break the
RX rate-select handshake during HS power mode changes?

If the M-PHY RX PCS has not asserted rx_ack (MPHY_RX_ACK_MASK in
RX_PCS_OUT) before MPHY_RX_OVRD_VAL is cleared, or deasserted it before
MPHY_RX_OVRD_EN is dropped, the 4-phase rx_req/rx_ack handshake is
violated and the HS rate change can fail or leave RX PCS wedged.

In drivers/ufs/host/ufs-amd-versal2.c, ufs_versal2_phy_ratesel() operates
on the same shared RX_OVRD_IN_1 and RX_PCS_OUT registers using
read-modify-write and polling MPHY_RX_ACK_MASK for 1 and then 0.

Raw writes to RX_OVRD_IN_1 here, FAST_FLAGS in s32n79_calib_mphy_disabled[],
and FW_CALIB_CCFG in s32n79_calib_mphy_enabled[] also clear all other bits
in those 16-bit CR registers instead of preserving reset or ROM defaults
with read-modify-write as ufs_versal2_setup_phy() does.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261204-b4-ufs-s32n7-v12-0-4cf32fc871a0@oss.nxp.com?part=13

  reply	other threads:[~2026-12-04  9:03 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-12-04  8:35 [PATCH v12 00/14] Add S32N79RDB UFS support Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 01/14] ufs: core: Return a negative errno from WLUN suspend/resume Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 02/14] ufs: dwc: Return a negative error if the link is down Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 03/14] ufs: unipro: Move Tx/Rx FSM state definitions to unipro.h Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 04/14] ufs: unipro: Add TX/RX FSM state attributes Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 05/14] ufs: core: Add common Hibern8 TX FSM polling helper Larisa Grigore
2026-12-04  8:45   ` sashiko-bot
2026-12-04  8:35 ` [PATCH v12 06/14] ufs: dwc: Move Versal2 M-PHY CREG access helpers into ufshcd-dwc Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 07/14] ufs: dwc: Export common clock divider and link status helpers Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 08/14] ufs: dwc: Sort CBCRCTRL and CBREFCLKCTRL2 by offset Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 09/14] ufs: dwc: Move shared M-PHY CR bitfield macros to ufshcd-dwc.h Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 10/14] ufs: pltfrm: Add a flags argument to ufshcd_pltfrm_init() Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 11/14] ufs: pltfrm: Add a flag to manage fixed rate clocks Larisa Grigore
2026-12-04  8:35 ` [PATCH v12 12/14] dt-bindings: ufs: Add NXP S32N79 UFS host controller Larisa Grigore
2026-12-04  8:46   ` sashiko-bot
2026-12-04  8:35 ` [PATCH v12 13/14] ufs: s32n7: Add NXP S32N79 UFS host controller driver Larisa Grigore
2026-12-04  9:03   ` sashiko-bot [this message]
2026-12-04  8:35 ` [PATCH v12 14/14] MAINTAINERS: Add NXP S32N7 UFS host controller entry Larisa Grigore

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-249455@kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=Frank.Li@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=imx@lists.linux.dev \
    --cc=larisa.grigore@oss.nxp.com \
    --cc=linux-scsi@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=wsa+renesas@sang-engineering.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