FAILED: patch "[PATCH] can: rcar_canfd: change the initializing flow for clocks and" failed to apply to 6.1-stable tree
Subsystems (3)
[email protected]
maintainerThe patch below does not apply to the 6.1-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x bef9004c5b91debfceaea2841855a4ebe81ff2b3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026080504-effects-snap-d572@gregkh' --subject-prefix 'PATCH 6.1.y' 'HEAD^..'
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From bef9004c5b91debfceaea2841855a4ebe81ff2b3 Mon Sep 17 00:00:00 2001
From: Tu Nguyen <[email protected]>
Date: Thu, 25 Jun 2026 14:51:51 +0100
Subject: [PATCH] can: rcar_canfd: change the initializing flow for clocks and
resets
Testing CANFD on RZ/G3E shows that many registers do not reset to their initial values with the current flow of deasserting resets first and then enabling clocks.
Based on the HW manual, clocks should be supplied first and the resets deasserted afterward.
section 7.4.3 Procedure for Activating Modules: RZ/G2L section 4.4.9.3 Procedure for Starting up Units: RZ/G3E
So, update the order of the initializing flow for resets and clocks to match the hardware manual, resetting all CANFD registers to their initial values. Also update rcar_canfd_global_deinit() to assert resets before disabling clocks, so the teardown path mirrors the new init ordering.
drivers/net/can/rcar/rcar_canfd.c +16 -16
@@ -2003,20 +2003,12 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv)u32 ch, sts;int err; - err =reset_control_reset (gpriv->rstc1); -if (err) -return err; - - err =reset_control_reset (gpriv->rstc2); -if (err) - goto fail_reset1; -/* Enable peripheral clock for register access */ err =clk_prepare_enable (gpriv->clkp);if (err) {dev_err (dev,"failed to enable peripheral clock: %pe\n" ,ERR_PTR (err)); - goto fail_reset2; +return err; }/* Enable RAM clock */
@@ -2027,10 +2019,18 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) goto fail_clk; } + err =reset_control_reset (gpriv->rstc1); +if (err) + goto fail_ram_clk; + + err =reset_control_reset (gpriv->rstc2); +if (err) + goto fail_reset1; + err =rcar_canfd_reset_controller (gpriv);if (err) {dev_err (dev,"reset controller failed: %pe\n" ,ERR_PTR (err)); - goto fail_ram_clk; + goto fail_reset2; }/* Controller in Global reset & Channel reset mode */
@@ -2068,14 +2068,14 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) fail_mode:rcar_canfd_disable_global_interrupts (gpriv); -fail_ram_clk: -clk_disable_unprepare (gpriv->clk_ram); -fail_clk: -clk_disable_unprepare (gpriv->clkp); fail_reset2:reset_control_assert (gpriv->rstc2); fail_reset1:reset_control_assert (gpriv->rstc1); +fail_ram_clk: +clk_disable_unprepare (gpriv->clk_ram); +fail_clk: +clk_disable_unprepare (gpriv->clkp);return err; }
@@ -2090,10 +2090,10 @@ static void rcar_canfd_global_deinit(struct rcar_canfd_global *gpriv, bool full)rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR ); } -clk_disable_unprepare (gpriv->clk_ram); -clk_disable_unprepare (gpriv->clkp);reset_control_assert (gpriv->rstc2);reset_control_assert (gpriv->rstc1); +clk_disable_unprepare (gpriv->clk_ram); +clk_disable_unprepare (gpriv->clkp); }static int rcar_canfd_probe (struct platform_device *pdev)
Sasha Levin
maintainerPATCH 1/4 can: rcar_canfd: Invert reset assert order
From: Geert Uytterhoeven <[email protected]>
[ Upstream commit 41c13eaf39932fc79aa1ac245a9b97090fe23d5e ]
The two resets are asserted during cleanup in the same order as they were deasserted during probe. Invert the order to restore symmetry.
Stable-dep-of: bef9004c5b91 ("can: rcar_canfd: change the initializing flow for clocks and resets")
--- drivers/net/can/rcar/rcar_canfd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +2 -2
@@ -2035,8 +2035,8 @@ static int rcar_canfd_probe(struct platform_device *pdev) fail_clk:clk_disable_unprepare (gpriv->clkp); fail_reset: -reset_control_assert (gpriv->rstc1);reset_control_assert (gpriv->rstc2); +reset_control_assert (gpriv->rstc1); fail_dev:return err; }
@@ -2057,8 +2057,8 @@ static int rcar_canfd_remove(struct platform_device *pdev)/* Enter global sleep mode */ rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR );clk_disable_unprepare (gpriv->clkp); -reset_control_assert (gpriv->rstc1);reset_control_assert (gpriv->rstc2); +reset_control_assert (gpriv->rstc1);return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 2/4 can: rcar_canfd: Use devm_clk_get_optional() for RAM clk
From: Biju Das <[email protected]>
[ Upstream commit eda3d6c8d784835cec86f42b3f8118c9eb0cc58c ]
Replace devm_clk_get_optional_enabled()->devm_clk_get_optional() as the RAM clk needs to be enabled in resume for proper operation in STR mode for RZ/G3E SoC.
Stable-dep-of: bef9004c5b91 ("can: rcar_canfd: change the initializing flow for clocks and resets")
--- drivers/net/can/rcar/rcar_canfd.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-)
drivers/net/can/rcar/rcar_canfd.c +18 -1
@@ -542,6 +542,7 @@ struct rcar_canfd_global {struct platform_device *pdev;/* Respective platform device */ struct clk *clkp;/* Peripheral clock */ struct clk *can_clk;/* fCAN clock */ +struct clk *clk_ram;/* Clock RAM */ enum rcar_canfd_fcanclk fcan;/* CANFD or Ext clock */ unsigned long channels_mask;/* Enabled channels mask */ bool fdmode;/* CAN FD or Classical CAN only mode */
@@ -1915,6 +1916,11 @@ static int rcar_canfd_probe(struct platform_device *pdev)/* CANFD clock is further divided by (1/2) within the IP */ fcan_freq /=2 ; + gpriv->clk_ram =devm_clk_get_optional (&pdev->dev,"ram_clk" ); +if (IS_ERR (gpriv->clk_ram)) +return dev_err_probe (&pdev->dev,PTR_ERR (gpriv->clk_ram), +"cannot get ram clock\n" ); + addr =devm_platform_ioremap_resource (pdev,0 );if (IS_ERR (addr)) { err =PTR_ERR (addr);
@@ -1979,10 +1985,18 @@ static int rcar_canfd_probe(struct platform_device *pdev) goto fail_reset; } +/* Enable RAM clock */ + err =clk_prepare_enable (gpriv->clk_ram); +if (err) { +dev_err (&pdev->dev,"failed to enable RAM clock: %pe\n" , +ERR_PTR (err)); + goto fail_clk; + } + err =rcar_canfd_reset_controller (gpriv);if (err) {dev_err (&pdev->dev,"reset controller failed\n" ); - goto fail_clk; + goto fail_ram_clk; }/* Controller in Global reset & Channel reset mode */
@@ -2032,6 +2046,8 @@ static int rcar_canfd_probe(struct platform_device *pdev)rcar_canfd_channel_remove (gpriv, ch); fail_mode:rcar_canfd_disable_global_interrupts (gpriv); +fail_ram_clk: +clk_disable_unprepare (gpriv->clk_ram); fail_clk:clk_disable_unprepare (gpriv->clkp); fail_reset:
@@ -2056,6 +2072,7 @@ static int rcar_canfd_remove(struct platform_device *pdev)/* Enter global sleep mode */ rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR ); +clk_disable_unprepare (gpriv->clk_ram);clk_disable_unprepare (gpriv->clkp);reset_control_assert (gpriv->rstc2);reset_control_assert (gpriv->rstc1);
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 3/4 can: rcar_canfd: Extract rcar_canfd_global_{,de}init()
In reply to Sasha LevinFrom: Geert Uytterhoeven <[email protected]>
[ Upstream commit fa5f4ec8fff8bc587a2cbf7101303306e045c11f ]
Extract the code to (de)initialize global state into separate functions, for future reuse.
Stable-dep-of: bef9004c5b91 ("can: rcar_canfd: change the initializing flow for clocks and resets")
--- drivers/net/can/rcar/rcar_canfd.c | 182 +++++++++++++++++------------- 1 file changed, 104 insertions(+), 78 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +104 -78
@@ -1810,20 +1810,119 @@ static void rcar_canfd_channel_remove(struct rcar_canfd_global *gpriv, u32 ch) } } +static int rcar_canfd_global_init (struct rcar_canfd_global *gpriv) +{ +struct device *dev = &gpriv->pdev->dev; +u32 rule_entry =0 ; +u32 ch, sts; +int err; + + err =reset_control_reset (gpriv->rstc1); +if (err) +return err; + + err =reset_control_reset (gpriv->rstc2); +if (err) + goto fail_reset1; + +/* Enable peripheral clock for register access */ + err =clk_prepare_enable (gpriv->clkp); +if (err) { +dev_err (dev,"failed to enable peripheral clock: %pe\n" , +ERR_PTR (err)); + goto fail_reset2; + } + +/* Enable RAM clock */ + err =clk_prepare_enable (gpriv->clk_ram); +if (err) { +dev_err (dev, +"failed to enable RAM clock, error %d\n" , err); + goto fail_clk; + } + + err =rcar_canfd_reset_controller (gpriv); +if (err) { +dev_err (dev,"reset controller failed: %pe\n" ,ERR_PTR (err)); + goto fail_ram_clk; + } + +/* Controller in Global reset & Channel reset mode */ +rcar_canfd_configure_controller (gpriv); + +/* Configure per channel attributes */ +for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) { +/* Configure Channel's Rx fifo */ +rcar_canfd_configure_rx (gpriv, ch); + +/* Configure Channel's Tx (Common) fifo */ +rcar_canfd_configure_tx (gpriv, ch); + +/* Configure receive rules */ +rcar_canfd_configure_afl_rules (gpriv, ch, rule_entry); + rule_entry +=RCANFD_CHANNEL_NUMRULES ; + } + +/* Configure common interrupts */ +rcar_canfd_enable_global_interrupts (gpriv); + +/* Start Global operation mode */ +rcar_canfd_update_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GMDC_MASK , +RCANFD_GCTR_GMDC_GOPM ); + +/* Verify mode change */ + err =readl_poll_timeout ((gpriv->base +RCANFD_GSTS ), sts, + !(sts &RCANFD_GSTS_GNOPM ),2 ,500000 ); +if (err) { +dev_err (dev,"global operational mode failed\n" ); + goto fail_mode; + } + +return 0 ; + +fail_mode: +rcar_canfd_disable_global_interrupts (gpriv); +fail_ram_clk: +clk_disable_unprepare (gpriv->clk_ram); +fail_clk: +clk_disable_unprepare (gpriv->clkp); +fail_reset2: +reset_control_assert (gpriv->rstc2); +fail_reset1: +reset_control_assert (gpriv->rstc1); +return err; +} + +static void rcar_canfd_global_deinit (struct rcar_canfd_global *gpriv,bool full) +{ +rcar_canfd_disable_global_interrupts (gpriv); + +if (full) { +rcar_canfd_reset_controller (gpriv); + +/* Enter global sleep mode */ +rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR ); + } + +clk_disable_unprepare (gpriv->clk_ram); +clk_disable_unprepare (gpriv->clkp); +reset_control_assert (gpriv->rstc2); +reset_control_assert (gpriv->rstc1); +} +static int rcar_canfd_probe (struct platform_device *pdev) {void __iomem *addr; -u32 sts, ch, fcan_freq;struct rcar_canfd_global *gpriv;struct device_node *of_child;unsigned long channels_mask =0 ;int err, ch_irq, g_irq;int g_err_irq, g_recc_irq; -u32 rule_entry =0 ;bool fdmode = true;/* CAN FD only mode - default */ enum rcanfd_chip_id chip_id;int max_channels;char name[9 ] ="channelX" ; +u32 ch, fcan_freq;int i; chip_id = (uintptr_t )of_device_get_match_data (&pdev->dev);
@@ -1968,67 +2067,9 @@ static int rcar_canfd_probe(struct platform_device *pdev) } } - err =reset_control_reset (gpriv->rstc1); + err =rcar_canfd_global_init (gpriv);if (err) - goto fail_dev; - err =reset_control_reset (gpriv->rstc2); -if (err) { -reset_control_assert (gpriv->rstc1); - goto fail_dev; - } - -/* Enable peripheral clock for register access */ - err =clk_prepare_enable (gpriv->clkp); -if (err) { -dev_err (&pdev->dev, -"failed to enable peripheral clock, error %d\n" , err); - goto fail_reset; - } - -/* Enable RAM clock */ - err =clk_prepare_enable (gpriv->clk_ram); -if (err) { -dev_err (&pdev->dev,"failed to enable RAM clock: %pe\n" , -ERR_PTR (err)); - goto fail_clk; - } - - err =rcar_canfd_reset_controller (gpriv); -if (err) { -dev_err (&pdev->dev,"reset controller failed\n" ); - goto fail_ram_clk; - } - -/* Controller in Global reset & Channel reset mode */ -rcar_canfd_configure_controller (gpriv); - -/* Configure per channel attributes */ -for_each_set_bit (ch, &gpriv->channels_mask, max_channels) { -/* Configure Channel's Rx fifo */ -rcar_canfd_configure_rx (gpriv, ch); - -/* Configure Channel's Tx (Common) fifo */ -rcar_canfd_configure_tx (gpriv, ch); - -/* Configure receive rules */ -rcar_canfd_configure_afl_rules (gpriv, ch, rule_entry); - rule_entry +=RCANFD_CHANNEL_NUMRULES ; - } - -/* Configure common interrupts */ -rcar_canfd_enable_global_interrupts (gpriv); - -/* Start Global operation mode */ -rcar_canfd_update_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GMDC_MASK , -RCANFD_GCTR_GMDC_GOPM ); - -/* Verify mode change */ - err =readl_poll_timeout ((gpriv->base +RCANFD_GSTS ), sts, - !(sts &RCANFD_GSTS_GNOPM ),2 ,500000 ); -if (err) { -dev_err (&pdev->dev,"global operational mode failed\n" ); goto fail_mode; - }for_each_set_bit (ch, &gpriv->channels_mask, max_channels) { err =rcar_canfd_channel_probe (gpriv, ch, fcan_freq);
@@ -2045,14 +2086,7 @@ static int rcar_canfd_probe(struct platform_device *pdev)for_each_set_bit (ch, &gpriv->channels_mask, max_channels)rcar_canfd_channel_remove (gpriv, ch); fail_mode: -rcar_canfd_disable_global_interrupts (gpriv); -fail_ram_clk: -clk_disable_unprepare (gpriv->clk_ram); -fail_clk: -clk_disable_unprepare (gpriv->clkp); -fail_reset: -reset_control_assert (gpriv->rstc2); -reset_control_assert (gpriv->rstc1); +rcar_canfd_global_deinit (gpriv, false); fail_dev:return err; }
@@ -2062,20 +2096,12 @@ static int rcar_canfd_remove(struct platform_device *pdev)struct rcar_canfd_global *gpriv =platform_get_drvdata (pdev);u32 ch; -rcar_canfd_reset_controller (gpriv); -rcar_canfd_disable_global_interrupts (gpriv); -for_each_set_bit (ch, &gpriv->channels_mask, gpriv->max_channels) {rcar_canfd_disable_channel_interrupts (gpriv->ch[ch]);rcar_canfd_channel_remove (gpriv, ch); } -/* Enter global sleep mode */ -rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR ); -clk_disable_unprepare (gpriv->clk_ram); -clk_disable_unprepare (gpriv->clkp); -reset_control_assert (gpriv->rstc2); -reset_control_assert (gpriv->rstc1); +rcar_canfd_global_deinit (gpriv, true);return 0 ; }
Signature · 1 line
2.53.0
Sasha Levin
maintainerPATCH 4/4 can: rcar_canfd: change the initializing flow for clocks and resets
In reply to Sasha LevinFrom: Tu Nguyen <[email protected]>
[ Upstream commit bef9004c5b91debfceaea2841855a4ebe81ff2b3 ]
Testing CANFD on RZ/G3E shows that many registers do not reset to their initial values with the current flow of deasserting resets first and then enabling clocks.
Based on the HW manual, clocks should be supplied first and the resets deasserted afterward.
section 7.4.3 Procedure for Activating Modules: RZ/G2L section 4.4.9.3 Procedure for Starting up Units: RZ/G3E
So, update the order of the initializing flow for resets and clocks to match the hardware manual, resetting all CANFD registers to their initial values. Also update rcar_canfd_global_deinit() to assert resets before disabling clocks, so the teardown path mirrors the new init ordering.
--- drivers/net/can/rcar/rcar_canfd.c | 32 +++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-)
drivers/net/can/rcar/rcar_canfd.c +16 -16
@@ -1817,20 +1817,12 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv)u32 ch, sts;int err; - err =reset_control_reset (gpriv->rstc1); -if (err) -return err; - - err =reset_control_reset (gpriv->rstc2); -if (err) - goto fail_reset1; -/* Enable peripheral clock for register access */ err =clk_prepare_enable (gpriv->clkp);if (err) {dev_err (dev,"failed to enable peripheral clock: %pe\n" ,ERR_PTR (err)); - goto fail_reset2; +return err; }/* Enable RAM clock */
@@ -1841,10 +1833,18 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) goto fail_clk; } + err =reset_control_reset (gpriv->rstc1); +if (err) + goto fail_ram_clk; + + err =reset_control_reset (gpriv->rstc2); +if (err) + goto fail_reset1; + err =rcar_canfd_reset_controller (gpriv);if (err) {dev_err (dev,"reset controller failed: %pe\n" ,ERR_PTR (err)); - goto fail_ram_clk; + goto fail_reset2; }/* Controller in Global reset & Channel reset mode */
@@ -1882,14 +1882,14 @@ static int rcar_canfd_global_init(struct rcar_canfd_global *gpriv) fail_mode:rcar_canfd_disable_global_interrupts (gpriv); -fail_ram_clk: -clk_disable_unprepare (gpriv->clk_ram); -fail_clk: -clk_disable_unprepare (gpriv->clkp); fail_reset2:reset_control_assert (gpriv->rstc2); fail_reset1:reset_control_assert (gpriv->rstc1); +fail_ram_clk: +clk_disable_unprepare (gpriv->clk_ram); +fail_clk: +clk_disable_unprepare (gpriv->clkp);return err; }
@@ -1904,10 +1904,10 @@ static void rcar_canfd_global_deinit(struct rcar_canfd_global *gpriv, bool full)rcar_canfd_set_bit (gpriv->base,RCANFD_GCTR ,RCANFD_GCTR_GSLPR ); } -clk_disable_unprepare (gpriv->clk_ram); -clk_disable_unprepare (gpriv->clkp);reset_control_assert (gpriv->rstc2);reset_control_assert (gpriv->rstc1); +clk_disable_unprepare (gpriv->clk_ram); +clk_disable_unprepare (gpriv->clkp); }static int rcar_canfd_probe (struct platform_device *pdev)
Signature · 1 line
2.53.0