* [PATCH v4 1/7] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3S SoC
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 2/7] can: rcar_canfd: Fix typos in macro names Claudiu Beznea
` (5 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The CAN FD controller found on the Renesas RZ/G3S SoC is largely compatible
with the variant present on the RZ/G3E SoC. The main differences are:
- the RZ/G3S provides only two CAN FD channels
- the RZ/G3S supports only CAN FD operation; the Channel n CAN FD
Configuration Register does not implement the bits used to select
classical CAN-only mode (bit 30) or CAN FD-only mode (bit 28);
consequently, bit 31 (CAN FD Frame Distinction Enable) of the same
register is also not implemented
- some bits in several registers (mainly reserved or status bits) are
read-write on the RZ/G3S but read-only on the RZ/G3E; their behavior is
otherwise identical: the bits read back as 0 on both SoCs and software
is allowed to write only 0 to them on the RZ/G3S
- the RZ/G3S provides 256 acceptance filters, compared to 768 on the
RZ/G3E
- the RZ/G3S can use PCLK clock as the CAN FD clock source through an
internal clock divider, while also supporting an external CAN FD clock
source
Since:
- the SoC clock generator provides to the CAN IP only the peripheral and
the RAM clocks
- when sourced from the peripheral clock, the CAN-FD clock is obtained
inside the IP itself by dividing the peripheral clock
- the assigned-clocks and assigned-clock-rates properties are specific to
the CAN-FD clock
the assigned-clocks and assigned-clock-rates properties were dropped from
the required properties list of the Renesas RZ/G3S SoC.
Add documentation for the Renesas RZ/G3S SoC.
Reviewed-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
Changes in v3:
- updated the patch description to reflect RZ/G3S has 256 acceptance
filters and RZ/G3E has 768 acceptance filters
- kept compatibles alphanumerically sorted
Changes in v2:
- forbid renesas,no-can-fd and renesas,fd-only since the IP supports
only CAN-FD; for this didn't collect Biju's tag
.../bindings/net/can/renesas,rcar-canfd.yaml | 20 +++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
index b9d9dd7a7967..bbaaef8f4282 100644
--- a/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
+++ b/Documentation/devicetree/bindings/net/can/renesas,rcar-canfd.yaml
@@ -13,6 +13,7 @@ properties:
compatible:
oneOf:
- enum:
+ - renesas,r9a08g045-canfd # RZ/G3S
- renesas,r9a09g047-canfd # RZ/G3E
- renesas,r9a09g077-canfd # RZ/T2H
@@ -185,8 +186,6 @@ required:
- clocks
- clock-names
- power-domains
- - assigned-clocks
- - assigned-clock-rates
- channel0
- channel1
@@ -198,6 +197,7 @@ allOf:
compatible:
contains:
enum:
+ - renesas,r9a08g045-canfd
- renesas,rzg2l-canfd
then:
properties:
@@ -266,6 +266,7 @@ allOf:
compatible:
contains:
enum:
+ - renesas,r9a08g045-canfd
- renesas,r9a09g077-canfd
- renesas,rcar-gen3-canfd
- renesas,rzg2l-canfd
@@ -330,6 +331,7 @@ allOf:
compatible:
contains:
enum:
+ - renesas,r9a08g045-canfd
- renesas,r9a09g047-canfd
- renesas,rzg2l-canfd
then:
@@ -350,6 +352,20 @@ allOf:
properties:
reset-names: false
+ - if:
+ properties:
+ compatible:
+ contains:
+ const: renesas,r9a08g045-canfd
+ then:
+ properties:
+ renesas,no-can-fd: false
+ renesas,fd-only: false
+ else:
+ required:
+ - assigned-clocks
+ - assigned-clock-rates
+
unevaluatedProperties: false
examples:
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 2/7] can: rcar_canfd: Fix typos in macro names
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 1/7] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3S SoC Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 3/7] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck Claudiu Beznea
` (4 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The bits 1..0 of the Channel n Control Register are named CHMDC (Channel
Mode select). Fix typos in macro names by replacing DMC with MDC.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
Changes in v3:
- none
Changes in v2:
- collected tags
drivers/net/can/rcar/rcar_canfd.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index fcc37b73ed43..b7c4fe3477ac 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -132,9 +132,9 @@
#define RCANFD_CCTR_BEIE BIT(8)
#define RCANFD_CCTR_CSLPR BIT(2)
#define RCANFD_CCTR_CHMDC_MASK (0x3)
-#define RCANFD_CCTR_CHDMC_COPM (0x0)
-#define RCANFD_CCTR_CHDMC_CRESET (0x1)
-#define RCANFD_CCTR_CHDMC_CHLT (0x2)
+#define RCANFD_CCTR_CHMDC_COPM (0x0)
+#define RCANFD_CCTR_CHMDC_CRESET (0x1)
+#define RCANFD_CCTR_CHMDC_CHLT (0x2)
/* RSCFDnCFDCmSTS / RSCFDnCmSTS */
#define RCANFD_CSTS_COMSTS BIT(7)
@@ -828,7 +828,7 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
rcar_canfd_update_bit(gpriv->base, RCANFD_CCTR(ch),
RCANFD_CCTR_CHMDC_MASK,
- RCANFD_CCTR_CHDMC_CRESET);
+ RCANFD_CCTR_CHMDC_CRESET);
/* Ensure Channel reset mode */
err = readl_poll_timeout((gpriv->base + RCANFD_CSTS(ch)), sts,
@@ -1504,7 +1504,7 @@ static int rcar_canfd_start(struct net_device *ndev)
/* Set channel to Operational mode */
rcar_canfd_update_bit(priv->base, RCANFD_CCTR(ch),
- RCANFD_CCTR_CHMDC_MASK, RCANFD_CCTR_CHDMC_COPM);
+ RCANFD_CCTR_CHMDC_MASK, RCANFD_CCTR_CHMDC_COPM);
/* Verify channel mode change */
err = readl_poll_timeout((priv->base + RCANFD_CSTS(ch)), sts,
@@ -1578,7 +1578,7 @@ static void rcar_canfd_stop(struct net_device *ndev)
/* Transition to channel reset mode */
rcar_canfd_update_bit(priv->base, RCANFD_CCTR(ch),
- RCANFD_CCTR_CHMDC_MASK, RCANFD_CCTR_CHDMC_CRESET);
+ RCANFD_CCTR_CHMDC_MASK, RCANFD_CCTR_CHMDC_CRESET);
/* Check Channel reset mode */
err = readl_poll_timeout((priv->base + RCANFD_CSTS(ch)), sts,
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 3/7] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 1/7] dt-bindings: can: renesas,rcar-canfd: Document RZ/G3S SoC Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 2/7] can: rcar_canfd: Fix typos in macro names Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode Claudiu Beznea
` (3 subsequent siblings)
6 siblings, 0 replies; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
On the Renesas RZ/G3S, the CAN FD clock can be sourced either from fck
(the peripheral clock) or from an external clock (can_clk). When fck is
used, it is divided internally by the CAN FD controller.
Adjust the existing canfd clock handling code to support the RZ/G3S CAN.
The existing struct rcar_canfd_hw_info instances were updated to address
the request in the Link discussion.
Link: https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
Changes in v3:
- set gpriv->can_clk = NULL if info->fcan_pclk
Changes in v2:
- changed the logic to request canfd only if info->fcan_pclk and contrary
get the fcan clock from pclk; for this didn't collect the Rb tag
drivers/net/can/rcar/rcar_canfd.c | 23 ++++++++++++++++++-----
1 file changed, 18 insertions(+), 5 deletions(-)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index b7c4fe3477ac..f9173774387f 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -444,6 +444,7 @@ struct rcar_canfd_hw_info {
unsigned ch_interface_mode:1; /* Has channel interface mode */
unsigned shared_can_regs:1; /* Has shared classical can registers */
unsigned external_clk:1; /* Has external clock */
+ unsigned fcan_pclk:1; /* Has fcan sourced from pclk. */
};
/* Channel priv data */
@@ -617,6 +618,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
.ch_interface_mode = 0,
.shared_can_regs = 0,
.external_clk = 1,
+ .fcan_pclk = 0,
};
static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
@@ -634,6 +636,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
.ch_interface_mode = 1,
.shared_can_regs = 1,
.external_clk = 1,
+ .fcan_pclk = 0,
};
static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -651,6 +654,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
.ch_interface_mode = 0,
.shared_can_regs = 0,
.external_clk = 1,
+ .fcan_pclk = 0,
};
static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
@@ -668,6 +672,7 @@ static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
.ch_interface_mode = 1,
.shared_can_regs = 1,
.external_clk = 0,
+ .fcan_pclk = 0,
};
static const struct rcar_canfd_hw_info r9a09g077_hw_info = {
@@ -685,6 +690,7 @@ static const struct rcar_canfd_hw_info r9a09g077_hw_info = {
.ch_interface_mode = 1,
.shared_can_regs = 1,
.external_clk = 1,
+ .fcan_pclk = 0,
};
/* Helper functions */
@@ -2190,13 +2196,20 @@ static int rcar_canfd_probe(struct platform_device *pdev)
*/
gpriv->can_clk = devm_clk_get(dev, "can_clk");
if (IS_ERR(gpriv->can_clk) || (clk_get_rate(gpriv->can_clk) == 0)) {
- gpriv->can_clk = devm_clk_get(dev, "canfd");
- if (IS_ERR(gpriv->can_clk))
- return dev_err_probe(dev, PTR_ERR(gpriv->can_clk),
- "cannot get canfd clock\n");
+ if (info->fcan_pclk) {
+ fcan_freq = clk_get_rate(gpriv->clkp);
+ gpriv->can_clk = NULL;
+ } else {
+ gpriv->can_clk = devm_clk_get(dev, "canfd");
+ if (IS_ERR(gpriv->can_clk))
+ return dev_err_probe(dev, PTR_ERR(gpriv->can_clk),
+ "cannot get canfd clock\n");
+
+ fcan_freq = clk_get_rate(gpriv->can_clk);
+ }
/* CANFD clock may be further divided within the IP */
- fcan_freq = clk_get_rate(gpriv->can_clk) / info->postdiv;
+ fcan_freq /= info->postdiv;
} else {
fcan_freq = clk_get_rate(gpriv->can_clk);
gpriv->extclk = gpriv->info->external_clk;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
` (2 preceding siblings ...)
2026-09-02 14:15 ` [PATCH v4 3/7] can: rcar_canfd: Allow the CAN FD clock to be sourced from fck Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:29 ` sashiko-bot
2026-09-02 14:15 ` [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
` (2 subsequent siblings)
6 siblings, 1 reply; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The bits 30 (classical CAN-only mode) and 28 (FD-only enable) of the
Channel n CAN-FD Configuration Register of the Renesas RZ/G3S SoC are not
available. The IP supports only CAN-FD mode. RZ/G3S HW manual (revision
1.30) specify the bits are read as zero and the write value should always
be zero.
Add the mode_select_na flag in struct rcar_canfd_hw_info to cover RZ/G3S
and avoid writing to unavailable bits.
The existing struct rcar_canfd_hw_info instances were updated to address
the request in the Link discussion.
Commit prepares for the addition of the Renesas RZ/G3S SoC.
Link: https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
- s/mode_select_na/fixed_canfd/g
Changes in v3:
- none
Changes in v2:
- collected the tags
- updated patch description to reflect this is a preparatory commit
drivers/net/can/rcar/rcar_canfd.c | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index f9173774387f..ac5d5959d8e4 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -445,6 +445,7 @@ struct rcar_canfd_hw_info {
unsigned shared_can_regs:1; /* Has shared classical can registers */
unsigned external_clk:1; /* Has external clock */
unsigned fcan_pclk:1; /* Has fcan sourced from pclk. */
+ unsigned fixed_canfd:1; /* Has mode fixed to canfd. */
};
/* Channel priv data */
@@ -619,6 +620,7 @@ static const struct rcar_canfd_hw_info rcar_gen3_hw_info = {
.shared_can_regs = 0,
.external_clk = 1,
.fcan_pclk = 0,
+ .fixed_canfd = 0,
};
static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
@@ -637,6 +639,7 @@ static const struct rcar_canfd_hw_info rcar_gen4_hw_info = {
.shared_can_regs = 1,
.external_clk = 1,
.fcan_pclk = 0,
+ .fixed_canfd = 0,
};
static const struct rcar_canfd_hw_info rzg2l_hw_info = {
@@ -655,6 +658,7 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
.shared_can_regs = 0,
.external_clk = 1,
.fcan_pclk = 0,
+ .fixed_canfd = 0,
};
static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
@@ -673,6 +677,7 @@ static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
.shared_can_regs = 1,
.external_clk = 0,
.fcan_pclk = 0,
+ .fixed_canfd = 0,
};
static const struct rcar_canfd_hw_info r9a09g077_hw_info = {
@@ -691,6 +696,7 @@ static const struct rcar_canfd_hw_info r9a09g077_hw_info = {
.shared_can_regs = 1,
.external_clk = 1,
.fcan_pclk = 0,
+ .fixed_canfd = 0,
};
/* Helper functions */
@@ -846,6 +852,9 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
}
/* Set the controller into appropriate mode */
+ if (gpriv->info->fixed_canfd)
+ continue;
+
if (gpriv->info->ch_interface_mode) {
/* Do not set CLOE and FDOE simultaneously */
if (!gpriv->fdmode) {
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode
2026-09-02 14:15 ` [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode Claudiu Beznea
@ 2026-09-02 14:29 ` sashiko-bot
0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-09-02 14:29 UTC (permalink / raw)
To: Claudiu Beznea
Cc: conor+dt, robh, Oleksij Rempel, linux-can, Marc Kleine-Budde,
Vincent Mailhol, wsa+renesas, devicetree, Oliver Hartkopp
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Software state diverges from fixed hardware capabilities due to unvalidated device tree overrides, causing silent data corruption and CAN protocol violations.
Pre-existing issues:
- [High] Race condition on write-0-to-clear status register causes lost TX completion interrupts and permanently frozen TX queues.
--
commit f5c5dd93cfcd4bdec86a8b0c4bc20cba21d7f4dc
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
can: rcar_canfd: Do not set registers selecting the CAN mode
This commit adds a fixed_canfd flag to struct rcar_canfd_hw_info to handle
hardware like the Renesas RZ/G3S SoC that only supports CAN-FD mode. It skips
writing to unavailable CAN mode configuration bits during the reset controller
sequence.
Link: https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index 2e84dc5dfa34d..bed7cde1aa01b 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
[ ... ]
> @@ -846,6 +852,9 @@ static int rcar_canfd_reset_controller(struct rcar_canfd_global *gpriv)
> }
>
> /* Set the controller into appropriate mode */
> + if (gpriv->info->fixed_canfd)
> + continue;
> +
[Severity: High]
Does bypassing the hardware mode setup here create a state mismatch if
the software interface is forced into Classical CAN mode?
If the device tree contains the "renesas,no-can-fd" property, the probe
function sets fdmode = false in rcar_canfd_probe():
drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_probe() {
...
if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
fdmode = false; /* Classical CAN only mode */
...
}
With this patch, if a device with fixed_canfd uses that DT override, the
hardware remains fixed in CAN-FD mode but the software expects Classical CAN.
Could this cause the driver to silently truncate 64-byte CAN-FD frames to
8 bytes while acknowledging CAN-FD frames on the bus?
> if (gpriv->info->ch_interface_mode) {
> /* Do not set CLOE and FDOE simultaneously */
> if (!gpriv->fdmode) {
[ ... ]
This isn't a bug introduced by this patch, but I also noticed a pre-existing
issue in the transmit completion path:
[Severity: High]
Can writing back the stale status mask unintentionally clear newly asserted
interrupt flags?
In rcar_canfd_tx_done():
drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_tx_done() {
...
/* Clear interrupt */
rcar_canfd_write(priv->base, RCANFD_CFSTS(gpriv, ch, RCANFD_CFFIFO_IDX),
sts & ~RCANFD_CFSTS_CFTXIF);
...
}
If a new interrupt (like another TX completion or message lost flag) is
asserted by the hardware immediately after the status register is read but
before this write-back, writing the stale sts value with a bitwise AND to
a write-0-to-clear register will write '0' to the newly asserted flag.
Could this cause lost TX completion interrupts and permanently frozen
TX queues?
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902141544.565763-1-claudiu.beznea+renesas@tuxon.dev?part=4
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
` (3 preceding siblings ...)
2026-09-02 14:15 ` [PATCH v4 4/7] can: rcar_canfd: Do not set registers selecting the CAN mode Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:30 ` sashiko-bot
2026-09-02 14:15 ` [PATCH v4 6/7] arm64: dts: renesas: r9a08g045: Add CAN-FD node Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 7/7] arm64: dts: renesas: rzg3s-smarc: Enable CAN-FD Claudiu Beznea
6 siblings, 1 reply; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
Add support for Renesas RZ/G3S
The Renesas RZ/G3S CAN-FD controller is largely compatible with the
variant found on the Renesas RZ/G3E. The main differences are:
- the RZ/G3S provides 16 AFL pages
- the RZ/G3S supports only two channels
- the RZ/G3S supports only CAN-FD operation and does not implement the
bits used to select between classical CAN-only and CAN FD-only modes.
- the RZ/G3S includes an internal divider that allows the peripheral
clock to be used as the CAN FD clock source.
Add support for the Renesas RZ/G3S.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
Changes in v3:
- updated max_aflpn as it refers to the number of available pages
that could be used to access the acceptance filters; updated the
patch description for this change
Changes in v2:
- initialized shared_global_irqs = 0 for RZ/G3S, to follow the request
from https://lore.kernel.org/all/1d9719e3-10ff-4cd8-b729-55fea93c37ce@wanadoo.fr
- collected tags
drivers/net/can/rcar/rcar_canfd.c | 21 +++++++++++++++++++++
1 file changed, 21 insertions(+)
diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
index ac5d5959d8e4..74c3c3f20991 100644
--- a/drivers/net/can/rcar/rcar_canfd.c
+++ b/drivers/net/can/rcar/rcar_canfd.c
@@ -661,6 +661,26 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
.fixed_canfd = 0,
};
+static const struct rcar_canfd_hw_info r9a08g045_hw_info = {
+ .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const,
+ .data_bittiming = &rcar_canfd_gen4_data_bittiming_const,
+ .tdc_const = &rcar_canfd_gen4_tdc_const,
+ .regs = &rcar_gen4_regs,
+ .sh = &rcar_gen4_shift_data,
+ .rnc_field_width = 16,
+ .max_aflpn = 15,
+ .max_cftml = 31,
+ .max_channels = 2,
+ .postdiv = 2,
+ .shared_global_irqs = 0,
+ .multi_channel_irqs = 1,
+ .ch_interface_mode = 1,
+ .shared_can_regs = 1,
+ .external_clk = 1,
+ .fcan_pclk = 1,
+ .fixed_canfd = 1,
+};
+
static const struct rcar_canfd_hw_info r9a09g047_hw_info = {
.nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const,
.data_bittiming = &rcar_canfd_gen4_data_bittiming_const,
@@ -2383,6 +2403,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend,
static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = {
{ .compatible = "renesas,r8a779a0-canfd", .data = &rcar_gen4_hw_info },
+ { .compatible = "renesas,r9a08g045-canfd", .data = &r9a08g045_hw_info },
{ .compatible = "renesas,r9a09g047-canfd", .data = &r9a09g047_hw_info },
{ .compatible = "renesas,r9a09g077-canfd", .data = &r9a09g077_hw_info },
{ .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info },
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* Re: [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S
2026-09-02 14:15 ` [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
@ 2026-09-02 14:30 ` sashiko-bot
0 siblings, 0 replies; 10+ messages in thread
From: sashiko-bot @ 2026-09-02 14:30 UTC (permalink / raw)
To: Claudiu Beznea
Cc: robh, Oliver Hartkopp, conor+dt, Oleksij Rempel, devicetree,
Marc Kleine-Budde, linux-can, Vincent Mailhol, wsa+renesas
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
New issues:
- [High] Lack of validation for Classical CAN mode on CAN FD-only hardware.
Pre-existing issues:
- [High] Dangling pointer in global array leads to double free when register_candev fails.
--
commit 1c2240055c546ef67856ad4716f6c425dbce01c6
Author: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
can: rcar_canfd: Add support for Renesas RZ/G3S
This commit adds support for the Renesas RZ/G3S CAN-FD controller.
The RZ/G3S controller supports two channels, 16 AFL pages, and operates
exclusively in CAN-FD mode.
> diff --git a/drivers/net/can/rcar/rcar_canfd.c b/drivers/net/can/rcar/rcar_canfd.c
> index bed7cde1aa01b..48e0573a73a44 100644
> --- a/drivers/net/can/rcar/rcar_canfd.c
> +++ b/drivers/net/can/rcar/rcar_canfd.c
[ ... ]
> @@ -661,6 +661,26 @@ static const struct rcar_canfd_hw_info rzg2l_hw_info = {
> .fixed_canfd = 0,
> };
>
> +static const struct rcar_canfd_hw_info r9a08g045_hw_info = {
> + .nom_bittiming = &rcar_canfd_gen4_nom_bittiming_const,
> + .data_bittiming = &rcar_canfd_gen4_data_bittiming_const,
> + .tdc_const = &rcar_canfd_gen4_tdc_const,
> + .regs = &rcar_gen4_regs,
> + .sh = &rcar_gen4_shift_data,
> + .rnc_field_width = 16,
> + .max_aflpn = 15,
> + .max_cftml = 31,
> + .max_channels = 2,
> + .postdiv = 2,
> + .shared_global_irqs = 0,
> + .multi_channel_irqs = 1,
> + .ch_interface_mode = 1,
> + .shared_can_regs = 1,
> + .external_clk = 1,
> + .fcan_pclk = 1,
> + .fixed_canfd = 1,
[Severity: High]
If the device tree specifies the "renesas,no-can-fd" property, could this
lead to a silent mismatch between the software network stack configuration
and the hardware state?
In drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_probe(), if the property is
present, the driver will set fdmode = false:
if (of_property_read_bool(dev->of_node, "renesas,no-can-fd"))
fdmode = false;
However, when rcar_canfd_configure_controller() runs, it skips the
controller mode update because fixed_canfd is true:
if (gpriv->info->fixed_canfd)
continue;
This effectively leaves the hardware locked in CAN FD mode, while the rest of
the driver initializes the software stack for Classical CAN. For example,
rcar_canfd_channel_probe() initializes a max MTU of 16 bytes, and
rcar_canfd_configure_rx() restricts the physical hardware Rx FIFO payload
size to 8 bytes.
If the hardware receives a 64-byte CAN FD frame, will it attempt to write
64 bytes into an Rx FIFO configured for 8 bytes, causing a buffer overflow?
> +};
> +
[ ... ]
> @@ -2383,6 +2403,7 @@ static DEFINE_SIMPLE_DEV_PM_OPS(rcar_canfd_pm_ops, rcar_canfd_suspend,
>
> static const __maybe_unused struct of_device_id rcar_canfd_of_table[] = {
> { .compatible = "renesas,r8a779a0-canfd", .data = &rcar_gen4_hw_info },
> + { .compatible = "renesas,r9a08g045-canfd", .data = &r9a08g045_hw_info },
[Severity: High]
This is a pre-existing issue, but does probe failure on this newly added
hardware expose a potential double-free?
In drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_channel_probe(), the global
array is populated before device registration:
gpriv->ch[priv->channel] = priv;
...
err = register_candev(ndev);
if (err) {
...
goto fail_candev;
}
If register_candev() fails, the error path calls free_candev(ndev), which
also frees the embedded priv structure, but leaves the dangling pointer in
gpriv->ch[priv->channel].
When the failure propagates back to rcar_canfd_probe(), the cleanup block
iterates over all configured channels and calls rcar_canfd_channel_remove()
for each, including the one that just failed:
drivers/net/can/rcar/rcar_canfd.c:rcar_canfd_channel_remove() {
...
unregister_candev(priv->ndev);
...
free_candev(priv->ndev);
}
Could this lead to memory corruption when it attempts to unregister and free
the already freed dangling pointer?
> { .compatible = "renesas,r9a09g047-canfd", .data = &r9a09g047_hw_info },
> { .compatible = "renesas,r9a09g077-canfd", .data = &r9a09g077_hw_info },
> { .compatible = "renesas,rcar-gen3-canfd", .data = &rcar_gen3_hw_info },
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260902141544.565763-1-claudiu.beznea+renesas@tuxon.dev?part=5
^ permalink raw reply [flat|nested] 10+ messages in thread
* [PATCH v4 6/7] arm64: dts: renesas: r9a08g045: Add CAN-FD node
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
` (4 preceding siblings ...)
2026-09-02 14:15 ` [PATCH v4 5/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
2026-09-02 14:15 ` [PATCH v4 7/7] arm64: dts: renesas: rzg3s-smarc: Enable CAN-FD Claudiu Beznea
6 siblings, 0 replies; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The Renesas RZ/G3S SoC includes a CAN-FD controller with two channels.
Add the corresponding device tree node.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
Changes in v3:
- none
Changes in v2:
- collected tags
arch/arm64/boot/dts/renesas/r9a08g045.dtsi | 39 ++++++++++++++++++++++
1 file changed, 39 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
index b98ad375a3e9..eaebf5b40fee 100644
--- a/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
+++ b/arch/arm64/boot/dts/renesas/r9a08g045.dtsi
@@ -29,6 +29,13 @@ audio_clk2: audio2-clk {
clock-frequency = <0>;
};
+ can_clk: can-clk {
+ compatible = "fixed-clock";
+ #clock-cells = <0>;
+ /* This value must be overridden by boards that provide it. */
+ clock-frequency = <0>;
+ };
+
cluster0_opp: opp-table-0 {
compatible = "operating-points-v2";
opp-shared;
@@ -498,6 +505,38 @@ ssi3: ssi@100a8c00 {
status = "disabled";
};
+ canfd: can@100c0000 {
+ compatible = "renesas,r9a08g045-canfd";
+ reg = <0 0x100c0000 0 0x20000>;
+ interrupts = <GIC_SPI 373 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 374 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 377 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 375 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 379 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 378 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 376 IRQ_TYPE_LEVEL_HIGH>,
+ <GIC_SPI 380 IRQ_TYPE_LEVEL_HIGH>;
+ interrupt-names = "g_err", "g_recc",
+ "ch0_err", "ch0_rec", "ch0_trx",
+ "ch1_err", "ch1_rec", "ch1_trx";
+ clocks = <&cpg CPG_MOD R9A08G045_CANFD_PCLK>,
+ <&cpg CPG_MOD R9A08G045_CANFD_CLK_RAM>,
+ <&can_clk>;
+ clock-names = "fck", "ram_clk", "can_clk";
+ resets = <&cpg R9A08G045_CANFD_RSTP_N>,
+ <&cpg R9A08G045_CANFD_RSTC_N>;
+ reset-names = "rstp_n", "rstc_n";
+ power-domains = <&cpg>;
+ status = "disabled";
+
+ channel0 {
+ status = "disabled";
+ };
+ channel1 {
+ status = "disabled";
+ };
+ };
+
cpg: clock-controller@11010000 {
compatible = "renesas,r9a08g045-cpg";
reg = <0 0x11010000 0 0x10000>;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread* [PATCH v4 7/7] arm64: dts: renesas: rzg3s-smarc: Enable CAN-FD
2026-09-02 14:15 [PATCH v4 0/7] can: rcar_canfd: Add support for Renesas RZ/G3S Claudiu Beznea
` (5 preceding siblings ...)
2026-09-02 14:15 ` [PATCH v4 6/7] arm64: dts: renesas: r9a08g045: Add CAN-FD node Claudiu Beznea
@ 2026-09-02 14:15 ` Claudiu Beznea
6 siblings, 0 replies; 10+ messages in thread
From: Claudiu Beznea @ 2026-09-02 14:15 UTC (permalink / raw)
To: mkl, mailhol, robh, krzk+dt, conor+dt, geert+renesas, magnus.damm,
biju.das.jz, fabrizio.castro.jz
Cc: claudiu.beznea, linux-can, devicetree, linux-renesas-soc,
linux-kernel, Claudiu Beznea
From: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
The two CAN FD channels available on the Renesas RZ/G3S SoC are routed
through the Renesas SMARC Carrier II board when used with the Renesas
RZ/G3S SMARC Module.
The CAN transceiver on the Carrier II board has its standby pins connected
to GPIOs that are selected through the SW_GPIO_CAN_PMOD switches. By
default, these switches route the GPIOs to the PMOD interfaces.
Enable the CAN FD controller and its two available channels.
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Geert Uytterhoeven <geert+renesas@glider.be>
Signed-off-by: Claudiu Beznea <claudiu.beznea.uj@bp.renesas.com>
---
Changes in v4:
- collected tags
- used ti,tcan1046 compatible
- adjusted the standby-gpio property along with CAN PHY node name and label
- adjusted the CAN channels phy phandles
Changes in v3:
- none
Changes in v2:
- collected tags
.../boot/dts/renesas/rzg3s-smarc-switches.h | 12 +++++
arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi | 45 +++++++++++++++++++
2 files changed, 57 insertions(+)
diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc-switches.h b/arch/arm64/boot/dts/renesas/rzg3s-smarc-switches.h
index 9cccc87da057..d3fd18626773 100644
--- a/arch/arm64/boot/dts/renesas/rzg3s-smarc-switches.h
+++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc-switches.h
@@ -41,4 +41,16 @@
*/
#define SW_OPT_MUX4 SW_ON
+/*
+ * SW_GPIO_CAN_PMOD[x] switches' states:
+ * @SW_GPIO_CAN_PMOD1:
+ * SW_OFF - GPIO8 connected to CAN0_STB (position 1-2)
+ * SW_ON - GPIO8 connected to PMOD1 (position 2-3)
+ * @SW_GPIO_CAN_PMOD2:
+ * SW_OFF - GPIO9 connected to CAN1_STB (position 4-5)
+ * SW_ON - GPIO9 connected to PMOD1 (position 5-6)
+ */
+#define SW_GPIO_CAN_PMOD1 SW_ON
+#define SW_GPIO_CAN_PMOD2 SW_ON
+
#endif /* __RZG3S_SMARC_SWITCHES_H__ */
diff --git a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
index e3821d8c01e3..ef24b6cbd690 100644
--- a/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
+++ b/arch/arm64/boot/dts/renesas/rzg3s-smarc.dtsi
@@ -68,6 +68,23 @@ codec_dai: simple-audio-card,codec {
};
};
+ can_transceiver: can-phy {
+ compatible = "ti,tcan1046", "nxp,tja1048";
+ #phy-cells = <1>;
+ max-bitrate = <8000000>;
+ standby-gpios =
+#if SW_GPIO_CAN_PMOD1 == SW_OFF
+ <&pinctrl RZG2L_GPIO(13, 0) GPIO_ACTIVE_HIGH>,
+#else
+ <0>,
+#endif
+#if SW_GPIO_CAN_PMOD2 == SW_OFF
+ <&pinctrl RZG2L_GPIO(13, 1) GPIO_ACTIVE_HIGH>;
+#else
+ <0>;
+#endif
+ };
+
vcc_sdhi1: regulator-vcc-sdhi1 {
compatible = "regulator-fixed";
regulator-name = "SDHI1 Vcc";
@@ -92,6 +109,22 @@ &audio_clk2 {
clock-frequency = <12288000>;
};
+&canfd {
+ pinctrl-0 = <&canfd_pins>;
+ pinctrl-names = "default";
+ status = "okay";
+
+ channel0 {
+ phys = <&can_transceiver 0>;
+ status = "okay";
+ };
+
+ channel1 {
+ phys = <&can_transceiver 1>;
+ status = "okay";
+ };
+};
+
&ehci0 {
dr_mode = "otg";
status = "okay";
@@ -171,6 +204,18 @@ audio_clock_pins: audio-clock {
input-enable;
};
+ canfd_pins: canfd {
+ can0_pins: can0 {
+ pinmux = <RZG2L_PORT_PINMUX(6, 1, 3)>, /* CAN0_TX */
+ <RZG2L_PORT_PINMUX(6, 2, 3)>; /* CAN0_RX */
+ };
+
+ can1_pins: can1 {
+ pinmux = <RZG2L_PORT_PINMUX(17, 0, 3)>, /* CAN1_TX */
+ <RZG2L_PORT_PINMUX(17, 1, 3)>; /* CAN1_RX */
+ };
+ };
+
key-1-gpio-hog {
gpio-hog;
gpios = <RZG2L_GPIO(18, 0) GPIO_ACTIVE_LOW>;
--
2.43.0
^ permalink raw reply related [flat|nested] 10+ messages in thread