Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Simon Glass" <sjg@chromium.org>
Cc: robh@kernel.org, conor+dt@kernel.org, devicetree@vger.kernel.org
Subject: Re: [PATCH 06/12] dt-bindings: serial: snps-dw-apb-uart: Add RV1106 compatible
Date: Mon, 06 Jul 2026 20:16:40 +0000	[thread overview]
Message-ID: <20260706201640.CF1CE1F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260706195818.3906949-7-sjg@chromium.org>

Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Invalid IOMUX register offsets for GPIO2 C and D pins cause memory corruption of GPIO1 A IOMUX settings.
- [Medium] The GRF MMC phase clock driver bypasses the syscon regmap, performing un-synchronized direct MMIO writes to the GRF.
--

commit 9eb9c18d0c1a4005a3ce42ce1798290561f0777d
Author: Simon Glass <sjg@chromium.org>

dt-bindings: serial: snps-dw-apb-uart: Add RV1106 compatible
    
Add the compatible for the UARTs of the Rockchip RV1106, which are
compatible with the Synopsys DesignWare APB UART.

> diff --git a/drivers/clk/rockchip/clk-rv1106.c b/drivers/clk/rockchip/clk-rv1106.c
> new file mode 100644
> index 0000000000000..88f043f34c233
> --- /dev/null
> +++ b/drivers/clk/rockchip/clk-rv1106.c
[ ... ]
> +static struct rockchip_clk_branch rv1106_grf_clk_branches[] __initdata = {
> +	MMC(SCLK_EMMC_DRV, "emmc_drv", "cclk_src_emmc", RV1106_EMMC_CON0, 1),
> +	MMC(SCLK_EMMC_SAMPLE, "emmc_sample", "cclk_src_emmc", RV1106_EMMC_CON1, 1),

[Severity: Medium]
Could this cause a regression by bypassing the syscon regmap and using direct
MMIO writes instead?

Registering phase clocks using the MMC macro rather than MMC_GRF passes a raw
MMIO pointer and a NULL regmap. While hardware-level data corruption might be
avoided due to the Rockchip GRF utilizing HIWORD_UPDATE bit masks, this
bypasses the syscon locking primitives and creates duplicate I/O mappings.

[ ... ]
> +static void __init rv1106_grf_clk_init(struct device_node *np)
> +{
> +	struct rockchip_clk_provider *ctx;
> +	struct device_node *parent_np;
> +	unsigned long clk_nr;
> +	void __iomem *reg_base;
> +
> +	clk_nr = rockchip_clk_find_max_clk_id(rv1106_grf_clk_branches,
> +					      ARRAY_SIZE(rv1106_grf_clk_branches)) + 1;
> +	parent_np = of_get_parent(np);
> +	reg_base = of_iomap(parent_np, 0);
> +	of_node_put(parent_np);

[Severity: Medium]
Is it safe to directly map the shared parent GRF syscon device here?

Mapping with of_iomap() circumvents the syscon regmap API instead of retrieving
its regmap via syscon_node_to_regmap(). This skips the expected synchronization
and creates duplicate I/O mappings.

> diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c
> index 7e0fcd45fd265..f9cbcb955853c 100644
> --- a/drivers/pinctrl/pinctrl-rockchip.c
> +++ b/drivers/pinctrl/pinctrl-rockchip.c
[ ... ]
> +static struct rockchip_pin_bank rv1106_pin_banks[] = {
> +	PIN_BANK_IOMUX_FLAGS(0, 32, "gpio0",
> +			     IOMUX_WIDTH_4BIT | IOMUX_SOURCE_PMU,
> +			     IOMUX_WIDTH_4BIT | IOMUX_SOURCE_PMU,
> +			     IOMUX_WIDTH_4BIT | IOMUX_SOURCE_PMU,
> +			     IOMUX_WIDTH_4BIT | IOMUX_SOURCE_PMU),
> +	PIN_BANK_IOMUX_FLAGS_OFFSET(1, 32, "gpio1",
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    0, 0x08, 0x10, 0x18),
> +	PIN_BANK_IOMUX_FLAGS_OFFSET(2, 32, "gpio2",
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    IOMUX_WIDTH_4BIT,
> +				    0x10020, 0x10028, 0, 0),

[Severity: High]
Does explicitly setting 0 as the offset for parts C and D cause memory
corruption of GPIO1 A IOMUX settings?

The gpio2 bank has 32 pins, but provides 0 as the explicit IOMUX offset for
parts C and D. During probe, this code evaluates iom->offset >= 0 (where 0 >= 0
is true):

drivers/pinctrl/pinctrl-rockchip.c:rockchip_pinctrl_get_soc_data() {
    ...
			/* preset iomux offset value, set new start value */
			if (iom->offset >= 0) {
    ...
}

This retains 0 as the offset for these pins rather than calculating them
sequentially. Since offset 0 of the IOC regmap is physically the IOMUX register
for GPIO1 A, any device tree configuration or runtime mux change for a GPIO2 C
or D pin will silently write to offset 0, corrupting the hardware IOMUX state
of GPIO1 A and B.

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260706195818.3906949-1-sjg@chromium.org?part=6

  reply	other threads:[~2026-07-06 20:16 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-06 19:57 [PATCH 00/12] Add support for the Rockchip RV1106 and RV1103 Simon Glass
2026-07-06 19:57 ` [PATCH 01/12] dt-bindings: clock: rockchip: Add RV1106 CRU support Simon Glass
2026-07-06 19:57 ` [PATCH 02/12] clk: rockchip: Add clock controller for the RV1106 Simon Glass
2026-07-06 20:15   ` sashiko-bot
2026-07-06 19:57 ` [PATCH 03/12] dt-bindings: pinctrl: rockchip: Add RV1106 compatible Simon Glass
2026-07-06 19:58 ` [PATCH 04/12] pinctrl: rockchip: Add RV1106 pinctrl support Simon Glass
2026-07-06 20:14   ` sashiko-bot
2026-07-06 19:58 ` [PATCH 05/12] dt-bindings: soc: rockchip: grf: Add RV1106 compatibles Simon Glass
2026-07-06 19:58 ` [PATCH 06/12] dt-bindings: serial: snps-dw-apb-uart: Add RV1106 compatible Simon Glass
2026-07-06 20:16   ` sashiko-bot [this message]
2026-07-06 19:58 ` [PATCH 07/12] dt-bindings: mmc: rockchip-dw-mshc: " Simon Glass
2026-07-06 19:58 ` [PATCH 08/12] dt-bindings: watchdog: snps,dw-wdt: " Simon Glass
2026-07-06 19:58 ` [PATCH 09/12] dt-bindings: iio: adc: rockchip-saradc: " Simon Glass
2026-07-07  2:09   ` Jonathan Cameron
2026-07-06 19:58 ` [PATCH 10/12] ARM: dts: rockchip: Add support for RV1106 and RV1103 Simon Glass
2026-07-06 20:17   ` sashiko-bot
2026-07-06 19:58 ` [PATCH 11/12] dt-bindings: arm: rockchip: Add Luckfox Pico Mini B Simon Glass
2026-07-06 20:18   ` sashiko-bot
2026-07-06 19:58 ` [PATCH 12/12] ARM: dts: " Simon Glass
2026-07-06 22:54 ` [PATCH 00/12] Add support for the Rockchip RV1106 and RV1103 Fabio Estevam
2026-07-07  7:41   ` Heiko Stübner

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=20260706201640.CF1CE1F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    --cc=sjg@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox