[PATCH v3 2/2] phy: mediatek: Add support for PCI-Express Gen4 S-PHY

sashiko-bot at kernel.org sashiko-bot at kernel.org
Mon Jul 20 08:37:36 PDT 2026


Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
- [Low] The driver emits a false-positive kernel error log when NVMEM is disabled or unsupported.
--

--- Patch [2]: [PATCH v3 2/2] phy: mediatek: Add support for PCI-Express Gen4 S-PHY ---
commit 93ce035a5e3a24b4c6f63697869bbcb5d8e50db4
Author: AngeloGioacchino Del Regno <angelogioacchino.delregno at collabora.com>
Subject: phy: mediatek: Add support for PCI-Express Gen4 S-PHY

This commit adds support for the PCI-Express Gen4 S-PHY found in the latest
MediaTek SoCs, including MT8196, MT8894 and similar.

[ ... ]
> diff --git a/drivers/phy/mediatek/phy-mtk-pcie-sphy.c b/drivers/phy/mediatek/phy-mtk-pcie-sphy.c
> new file mode 100644
> index 0000000000000..853aafa182597
> --- /dev/null
> +++ b/drivers/phy/mediatek/phy-mtk-pcie-sphy.c
[ ... ]
> +static int mtk_pcie_sphy_get_one_cal_para(struct device *dev, const char *name, u8 max_val)
> +{
> +	u16 buf;
> +	u8 tmp;
> +	int ret;
> +
> +	/*
> +	 * All of the calibrations are always max 8 bits long, but some may
> +	 * be split between two different 8-bits cells: handle this corner
> +	 * case by retrying reading as u16.
> +	 */
> +	ret = nvmem_cell_read_u8(dev, name, &tmp);
> +	if (ret == 0)
> +		buf = tmp;
> +	else
> +		ret = nvmem_cell_read_u16(dev, name, &buf);
> +
> +	if (ret == -ENOENT) {
> +		dev_info(dev, "No calibration for %s. Using defaults\n", name);
> +		return -ENOENT;
> +	} else if (ret)
> +		return dev_err_probe(dev, ret,
> +				     "Cannot get calibration data for %s\n", name);

[Severity: Low]
Does this emit a false-positive kernel error log when NVMEM is disabled or
unsupported?

If CONFIG_NVMEM=n, the NVMEM APIs return -EOPNOTSUPP, which will cause this
path to print an error with dev_err_probe(). However, the caller in
mtk_pcie_sphy_get_calibration_data() gracefully handles -EOPNOTSUPP as a
non-error condition:

	if (ret < 0) {
		/*
		 * If any of the calibration values is missing, or if there is
		 * no calibration at all in the eFuses, this is not a problem,
		 * as the PHY doesn't require one to actually work.
		 */
		if (ret == -ENOENT || ret == -EOPNOTSUPP) {
			cal->supported = false;
			return 0;
		}

Could -EOPNOTSUPP be handled silently here in mtk_pcie_sphy_get_one_cal_para()
to avoid spurious error messages during boot?

> +
> +	if (buf > max_val)
> +		return dev_err_probe(dev, -ERANGE,
> +				     "Bad value %u retrieved for %s.\n", buf, name);
> +
> +	return buf;
> +}

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260720152654.92216-1-angelogioacchino.delregno@collabora.com?part=2



More information about the linux-phy mailing list