All of lore.kernel.org
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Michal Wilczynski" <m.wilczynski@samsung.com>
Cc: olteanv@gmail.com, conor+dt@kernel.org,
	dri-devel@lists.freedesktop.org, lee@kernel.org,
	neil.armstrong@linaro.org, linux-clk@vger.kernel.org,
	robh@kernel.org, mfd@lists.linux.dev,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	vkoul@kernel.org
Subject: Re: [PATCH v3 15/19] phy: Add common Innosilicon HDMI PHY helpers
Date: Fri, 04 Sep 2026 13:55:26 +0000	[thread overview]
Message-ID: <20260904135527.052AD1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-jh7110-clean-send-v3-15-484f9ae72715@samsung.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Kernel panic from division by zero in clock rate recalculation if regmap_read fails or registers are uninitialized.
- [High] Severe 32-bit integer overflows in VCO clock calculations on 32-bit architectures, leading to heavily truncated clock rates.
--

commit 3a039ecf7fc3d9336647b49a4ed8daf640a4fd42
Author: Michal Wilczynski <m.wilczynski@samsung.com>

phy: Add common Innosilicon HDMI PHY helpers

This commit extracts shared Innosilicon HDMI PHY logic into a common
library. It provides pre-PLL configuration, lookup, and clock rate
recalculation helpers for SoC drivers that instantiate this IP.

> diff --git a/drivers/phy/phy-inno-hdmi.c b/drivers/phy/phy-inno-hdmi.c
> new file mode 100644
> index 0000000000000..77e745a87d22b
> --- /dev/null
> +++ b/drivers/phy/phy-inno-hdmi.c

[ ... ]

> +static u8 inno_read(const struct inno_hdmi_phy_pre_pll *pll, unsigned int reg)
> +{
> +	unsigned int val;
> +	int ret;
> +
> +	ret = regmap_read(pll->regmap, inno_reg(pll, reg), &val);
> +	if (ret)
> +		return 0;

[Severity: High]
This isn't a bug introduced by this patch, but does explicitly returning 0
on a regmap read failure set up a deterministic kernel panic downstream?

If the registers are uninitialized or the read fails, the returned 0 will
propagate to the division operations in inno_hdmi_phy_pre_pll_recalc_rate().

[ ... ]

> +unsigned long
> +inno_hdmi_phy_pre_pll_recalc_rate(const struct inno_hdmi_phy_pre_pll *pll,
> +				  unsigned long parent_rate)
> +{
> +	u8 nd, no_a, no_b, no_d;
> +	unsigned long frac, rate;
> +	u64 vco, vco_rate;
> +	u16 nf;
> +
> +	nd = inno_read(pll, INNO_PRE_PLL_DIV_1) & INNO_PRE_PLL_PRE_DIV_MASK;
> +	nf = (inno_read(pll, INNO_PRE_PLL_DIV_2) &
> +	      INNO_PRE_PLL_FB_DIV_11_8_MASK) << 8;
> +	nf |= inno_read(pll, INNO_PRE_PLL_DIV_3);
> +	vco = parent_rate * nf;

[Severity: High]
This is a pre-existing issue, but on 32-bit architectures where
parent_rate is a 32-bit unsigned long, does this multiplication silently
overflow before being assigned to the 64-bit vco variable?

The nf variable can be up to 4095, which would severely truncate the
result if it exceeds the 32-bit limit. Should parent_rate be cast to
u64 here?

> +
> +	if (!(inno_read(pll, INNO_PRE_PLL_DIV_2) &
> +	      INNO_PRE_PLL_FRAC_DIV_DISABLE)) {
> +		frac = inno_read(pll, INNO_PRE_PLL_FRAC_DIV_7_0) |
> +		       (inno_read(pll, INNO_PRE_PLL_FRAC_DIV_15_8) << 8) |
> +		       (inno_read(pll, INNO_PRE_PLL_FRAC_DIV_23_16) << 16);
> +		vco += DIV_ROUND_CLOSEST(parent_rate * frac,
> +					 BIT(INNO_FRAC_DIV_WIDTH));

[Severity: High]
This isn't a bug introduced by this patch, but does the parent_rate * frac
multiplication silently overflow 32-bit limits as well?

If this calculation is upgraded to 64-bit to avoid the overflow, would it
also require switching DIV_ROUND_CLOSEST to DIV_ROUND_CLOSEST_ULL to prevent
__udivdi3 link errors on 32-bit systems?

> +	}
> +
> +	vco_rate = vco;
> +
> +	if (inno_read(pll, INNO_PRE_PLL_CONTROL) & INNO_PCLK_VCO_DIV_5_MASK) {
> +		do_div(vco, nd * 5);

[Severity: High]
This is a pre-existing issue, but if nd evaluates to 0 from a failed read,
will this do_div() trigger a divide by zero exception during probe?

> +	} else {
> +		no_a = inno_read(pll, INNO_PCLK_DIV_AB) & INNO_PCLK_DIV_A_MASK;
> +		no_b = FIELD_GET(INNO_PCLK_DIV_B_MASK,
> +				 inno_read(pll, INNO_PCLK_DIV_AB)) + 2;
> +		no_d = inno_read(pll, INNO_PCLK_DIV_CD) & INNO_PCLK_DIV_D_MASK;
> +
> +		do_div(vco, nd * (no_a == 1 ? no_b : no_a) * no_d * 2);

[Severity: High]
This is also a pre-existing issue, but similar to the above, if nd, no_a,
or no_d evaluate to 0 due to read failures, does this also cause a kernel
panic?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-jh7110-clean-send-v3-0-484f9ae72715@samsung.com?part=15

WARNING: multiple messages have this Message-ID (diff)
From: sashiko-bot@kernel.org
To: "Michal Wilczynski" <m.wilczynski@samsung.com>
Cc: olteanv@gmail.com, conor+dt@kernel.org,
	dri-devel@lists.freedesktop.org, lee@kernel.org,
	neil.armstrong@linaro.org, linux-clk@vger.kernel.org,
	robh@kernel.org, mfd@lists.linux.dev,
	linux-phy@lists.infradead.org, devicetree@vger.kernel.org,
	vkoul@kernel.org
Subject: Re: [PATCH v3 15/19] phy: Add common Innosilicon HDMI PHY helpers
Date: Fri, 04 Sep 2026 13:55:26 +0000	[thread overview]
Message-ID: <20260904135527.052AD1F00A3D@smtp.kernel.org> (raw)
In-Reply-To: <20260904-jh7110-clean-send-v3-15-484f9ae72715@samsung.com>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:

Pre-existing issues:
- [High] Kernel panic from division by zero in clock rate recalculation if regmap_read fails or registers are uninitialized.
- [High] Severe 32-bit integer overflows in VCO clock calculations on 32-bit architectures, leading to heavily truncated clock rates.
--

commit 3a039ecf7fc3d9336647b49a4ed8daf640a4fd42
Author: Michal Wilczynski <m.wilczynski@samsung.com>

phy: Add common Innosilicon HDMI PHY helpers

This commit extracts shared Innosilicon HDMI PHY logic into a common
library. It provides pre-PLL configuration, lookup, and clock rate
recalculation helpers for SoC drivers that instantiate this IP.

> diff --git a/drivers/phy/phy-inno-hdmi.c b/drivers/phy/phy-inno-hdmi.c
> new file mode 100644
> index 0000000000000..77e745a87d22b
> --- /dev/null
> +++ b/drivers/phy/phy-inno-hdmi.c

[ ... ]

> +static u8 inno_read(const struct inno_hdmi_phy_pre_pll *pll, unsigned int reg)
> +{
> +	unsigned int val;
> +	int ret;
> +
> +	ret = regmap_read(pll->regmap, inno_reg(pll, reg), &val);
> +	if (ret)
> +		return 0;

[Severity: High]
This isn't a bug introduced by this patch, but does explicitly returning 0
on a regmap read failure set up a deterministic kernel panic downstream?

If the registers are uninitialized or the read fails, the returned 0 will
propagate to the division operations in inno_hdmi_phy_pre_pll_recalc_rate().

[ ... ]

> +unsigned long
> +inno_hdmi_phy_pre_pll_recalc_rate(const struct inno_hdmi_phy_pre_pll *pll,
> +				  unsigned long parent_rate)
> +{
> +	u8 nd, no_a, no_b, no_d;
> +	unsigned long frac, rate;
> +	u64 vco, vco_rate;
> +	u16 nf;
> +
> +	nd = inno_read(pll, INNO_PRE_PLL_DIV_1) & INNO_PRE_PLL_PRE_DIV_MASK;
> +	nf = (inno_read(pll, INNO_PRE_PLL_DIV_2) &
> +	      INNO_PRE_PLL_FB_DIV_11_8_MASK) << 8;
> +	nf |= inno_read(pll, INNO_PRE_PLL_DIV_3);
> +	vco = parent_rate * nf;

[Severity: High]
This is a pre-existing issue, but on 32-bit architectures where
parent_rate is a 32-bit unsigned long, does this multiplication silently
overflow before being assigned to the 64-bit vco variable?

The nf variable can be up to 4095, which would severely truncate the
result if it exceeds the 32-bit limit. Should parent_rate be cast to
u64 here?

> +
> +	if (!(inno_read(pll, INNO_PRE_PLL_DIV_2) &
> +	      INNO_PRE_PLL_FRAC_DIV_DISABLE)) {
> +		frac = inno_read(pll, INNO_PRE_PLL_FRAC_DIV_7_0) |
> +		       (inno_read(pll, INNO_PRE_PLL_FRAC_DIV_15_8) << 8) |
> +		       (inno_read(pll, INNO_PRE_PLL_FRAC_DIV_23_16) << 16);
> +		vco += DIV_ROUND_CLOSEST(parent_rate * frac,
> +					 BIT(INNO_FRAC_DIV_WIDTH));

[Severity: High]
This isn't a bug introduced by this patch, but does the parent_rate * frac
multiplication silently overflow 32-bit limits as well?

If this calculation is upgraded to 64-bit to avoid the overflow, would it
also require switching DIV_ROUND_CLOSEST to DIV_ROUND_CLOSEST_ULL to prevent
__udivdi3 link errors on 32-bit systems?

> +	}
> +
> +	vco_rate = vco;
> +
> +	if (inno_read(pll, INNO_PRE_PLL_CONTROL) & INNO_PCLK_VCO_DIV_5_MASK) {
> +		do_div(vco, nd * 5);

[Severity: High]
This is a pre-existing issue, but if nd evaluates to 0 from a failed read,
will this do_div() trigger a divide by zero exception during probe?

> +	} else {
> +		no_a = inno_read(pll, INNO_PCLK_DIV_AB) & INNO_PCLK_DIV_A_MASK;
> +		no_b = FIELD_GET(INNO_PCLK_DIV_B_MASK,
> +				 inno_read(pll, INNO_PCLK_DIV_AB)) + 2;
> +		no_d = inno_read(pll, INNO_PCLK_DIV_CD) & INNO_PCLK_DIV_D_MASK;
> +
> +		do_div(vco, nd * (no_a == 1 ? no_b : no_a) * no_d * 2);

[Severity: High]
This is also a pre-existing issue, but similar to the above, if nd, no_a,
or no_d evaluate to 0 due to read failures, does this also cause a kernel
panic?

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260904-jh7110-clean-send-v3-0-484f9ae72715@samsung.com?part=15

-- 
linux-phy mailing list
linux-phy@lists.infradead.org
https://lists.infradead.org/mailman/listinfo/linux-phy

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

Thread overview: 161+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CGME20260904132708eucas1p1adfa26ef0fe5109eca63a3aeadf74915@eucas1p1.samsung.com>
2026-09-04 13:27 ` [PATCH v3 00/19] drm: starfive: jh7110: Enable display subsystem Michal Wilczynski
2026-09-04 13:27   ` Michal Wilczynski
2026-09-04 13:27   ` Michal Wilczynski
2026-09-04 13:27   ` Michal Wilczynski
2026-09-04 13:27   ` [PATCH v3 01/19] dt-bindings: phy: Add starfive,jh7110-inno-hdmi-phy Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:30     ` sashiko-bot
2026-09-04 13:30       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 02/19] dt-bindings: display: bridge: Add starfive,jh7110-inno-hdmi-controller Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:35     ` sashiko-bot
2026-09-04 13:35       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 03/19] dt-bindings: mfd: Add starfive,jh7110-hdmi-subsystem Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:37     ` sashiko-bot
2026-09-04 13:37       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 04/19] dt-bindings: soc: starfive: Add starfive,jh7110-vout-syscon Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:30     ` sashiko-bot
2026-09-04 13:30       ` sashiko-bot
2026-09-10  8:18     ` Krzysztof Kozlowski
2026-09-10  8:18       ` Krzysztof Kozlowski
2026-09-10  8:18       ` Krzysztof Kozlowski
2026-09-10  8:18       ` Krzysztof Kozlowski
2026-09-04 13:27   ` [PATCH v3 05/19] dt-bindings: soc: starfive: Add starfive,jh7110-vout-subsystem Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:36     ` sashiko-bot
2026-09-04 13:36       ` sashiko-bot
2026-09-10  8:21     ` Krzysztof Kozlowski
2026-09-10  8:21       ` Krzysztof Kozlowski
2026-09-10  8:21       ` Krzysztof Kozlowski
2026-09-10  8:21       ` Krzysztof Kozlowski
2026-09-04 13:27   ` [PATCH v3 06/19] dt-bindings: display: verisilicon: Add starfive,jh7110-dc8200 Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:31     ` sashiko-bot
2026-09-04 13:31       ` sashiko-bot
2026-09-10  8:34     ` Krzysztof Kozlowski
2026-09-10  8:34       ` Krzysztof Kozlowski
2026-09-10  8:34       ` Krzysztof Kozlowski
2026-09-10  8:34       ` Krzysztof Kozlowski
2026-09-04 13:27   ` [PATCH v3 07/19] drm/bridge: inno-hdmi: Split probe out of bind Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:42     ` sashiko-bot
2026-09-04 13:42       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 08/19] drm/bridge: inno-hdmi: Allow the register map to come from a parent Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:43     ` sashiko-bot
2026-09-04 13:43       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 09/19] drm/bridge: inno-hdmi: Add .disable platform operation Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:49     ` sashiko-bot
2026-09-04 13:49       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 10/19] drm/bridge: inno-hdmi: Add .mode_valid " Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:40     ` sashiko-bot
2026-09-04 13:40       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 11/19] soc: starfive: Add jh7110-hdmi-subsystem driver Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:52     ` sashiko-bot
2026-09-04 13:52       ` sashiko-bot
2026-09-07  8:23     ` Uwe Kleine-König
2026-09-07  8:23       ` Uwe Kleine-König
2026-09-07  8:23       ` Uwe Kleine-König
2026-09-07  8:23       ` Uwe Kleine-König
2026-09-04 13:27   ` [PATCH v3 12/19] soc: starfive: Add jh7110-vout-subsystem driver Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:47     ` sashiko-bot
2026-09-04 13:47       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 13/19] clk: starfive: jh7110-vout: Allow pixel clock rate propagation Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:44     ` sashiko-bot
2026-09-04 13:44       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 14/19] drm/bridge: starfive: Add JH7110 HDMI controller driver Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:39     ` Icenowy Zheng
2026-09-04 13:39       ` Icenowy Zheng
2026-09-04 13:39       ` Icenowy Zheng
2026-09-04 13:39       ` Icenowy Zheng
2026-09-04 13:57     ` sashiko-bot
2026-09-04 13:57       ` sashiko-bot
2026-09-07  3:51     ` Chaoyi Chen
2026-09-07  3:51       ` Chaoyi Chen
2026-09-07  3:51       ` Chaoyi Chen
2026-09-07  3:51       ` Chaoyi Chen
2026-09-04 13:27   ` [PATCH v3 15/19] phy: Add common Innosilicon HDMI PHY helpers Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:55     ` sashiko-bot [this message]
2026-09-04 13:55       ` sashiko-bot
2026-09-07  3:16     ` Chaoyi Chen
2026-09-07  3:16       ` Chaoyi Chen
2026-09-07  3:16       ` Chaoyi Chen
2026-09-07  3:16       ` Chaoyi Chen
2026-09-04 13:27   ` [PATCH v3 16/19] phy: rockchip: inno-hdmi: Use the common Innosilicon " Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:59     ` sashiko-bot
2026-09-04 13:59       ` sashiko-bot
2026-09-07  3:20     ` Chaoyi Chen
2026-09-07  3:20       ` Chaoyi Chen
2026-09-07  3:20       ` Chaoyi Chen
2026-09-07  3:20       ` Chaoyi Chen
2026-09-04 13:27   ` [PATCH v3 17/19] phy: starfive: Add jh7110-inno-hdmi-phy driver Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:57     ` sashiko-bot
2026-09-04 13:57       ` sashiko-bot
2026-09-04 13:27   ` [PATCH v3 18/19] riscv: dts: starfive: jh7110: Update DT for display subsystem Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 14:03     ` sashiko-bot
2026-09-04 14:03       ` sashiko-bot
2026-09-10  8:37     ` Krzysztof Kozlowski
2026-09-10  8:37       ` Krzysztof Kozlowski
2026-09-10  8:37       ` Krzysztof Kozlowski
2026-09-10  8:37       ` Krzysztof Kozlowski
2026-09-04 13:27   ` [PATCH v3 19/19] MAINTAINERS: Add StarFive JH7110 display subsystem entry Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 13:27     ` Michal Wilczynski
2026-09-04 15:13   ` [PATCH v3 00/19] drm: starfive: jh7110: Enable display subsystem Joshua Peisach
2026-09-04 15:13     ` Joshua Peisach
2026-09-04 15:13     ` Joshua Peisach
2026-09-04 15:13     ` Joshua Peisach
2026-09-05  5:21   ` Maud Spierings
2026-09-05  5:21     ` Maud Spierings
2026-09-05  5:21     ` Maud Spierings
2026-09-05  5:21     ` Maud Spierings
2026-09-06  3:55     ` Dominique Belhachemi

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=20260904135527.052AD1F00A3D@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=lee@kernel.org \
    --cc=linux-clk@vger.kernel.org \
    --cc=linux-phy@lists.infradead.org \
    --cc=m.wilczynski@samsung.com \
    --cc=mfd@lists.linux.dev \
    --cc=neil.armstrong@linaro.org \
    --cc=olteanv@gmail.com \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=vkoul@kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.