Skip to contentSkip to conversation

clk: xilinx: vcu: Sequence update and couple of fixes

PATCH Superseded Rohit Visavalia 2 participants 9 messages Jan 2, 2025 – Jan 28, 2025

Subsystems (2)

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#0 lore raw

v2 cover clk: xilinx: vcu: Sequence update and couple of fixes

This patch series updates VCU init/reset sequence and does 2 driver fixes. patch1 fixes call trace related to pll_post clk.
Patch2 fixes VCU parent clock issue by preventing pll_ref to be changed. Patch3 adds optional reset-gpio support.

---
Changes in v2:
- Changed patches sequence to have patches with "Fixes" as preceding in order
- Used dev_err_probe()
- Moved warning to dev_dbg() and updated print with more detail
- Link to v1: https://lore.kernel.org/linux-clk/[email protected]

Rohit Visavalia (3):
clk: xilinx: vcu: unregister pll_post only if registered correctly
clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks
clk: xilinx: vcu: Update vcu init/reset sequence

 drivers/clk/xilinx/xlnx_vcu.c | 35 ++++++++++++++++++++++++++++++++---
 1 file changed, 32 insertions(+), 3 deletions(-)
Signature · 1 line
2.25.1
#1 lore raw

PATCH v2 1/3 clk: xilinx: vcu: unregister pll_post only if registered correctly

If registration of pll_post is failed, it will be set to NULL or ERR, unregistering same will fail with following call trace:

Unable to handle kernel NULL pointer dereference at virtual address 008
pc : clk_hw_unregister+0xc/0x20
lr : clk_hw_unregister_fixed_factor+0x18/0x30
sp : ffff800011923850
...
Call trace:
 clk_hw_unregister+0xc/0x20
 clk_hw_unregister_fixed_factor+0x18/0x30
 xvcu_unregister_clock_provider+0xcc/0xf4 [xlnx_vcu]
 xvcu_probe+0x2bc/0x53c [xlnx_vcu]
Fixes 4472e1849db7 ("soc: xilinx: vcu: make pll post divider explicit")

---
Changes in v2:
- Changed patches sequence to have patches with "Fixes" as preceding in order
- Added Fixes tag
- Link to v1: https://lore.kernel.org/linux-clk/[email protected]

---
 drivers/clk/xilinx/xlnx_vcu.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/clk/xilinx/xlnx_vcu.c +2 -2
index 81501b48412e..88b3fd8250c2 100644
@@ -587,8 +587,8 @@ static void xvcu_unregister_clock_provider(struct xvcu_device *xvcu)
 		xvcu_clk_hw_unregister_leaf(hws[CLK_XVCU_ENC_MCU]);
 	if (!IS_ERR_OR_NULL(hws[CLK_XVCU_ENC_CORE]))
 		xvcu_clk_hw_unregister_leaf(hws[CLK_XVCU_ENC_CORE]);
-
-	clk_hw_unregister_fixed_factor(xvcu->pll_post);
+	if (!IS_ERR_OR_NULL(xvcu->pll_post))
+		clk_hw_unregister_fixed_factor(xvcu->pll_post);
 }
 
 /**
Signature · 1 line
2.25.1
#2 lore raw

PATCH v2 2/3 clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

In reply to Rohit Visavalia

CCF will try to adjust parent clock to set desire clock frequency of child clock. So if pll_ref is not a fixed-clock then while setting rate of enc/dec clocks pll_ref may get change, which may make VCU malfunction.

---
Changes in v2:
- none
- Link to v1: https://lore.kernel.org/linux-clk/[email protected]

---
 drivers/clk/xilinx/xlnx_vcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/xilinx/xlnx_vcu.c +1 -1
index 88b3fd8250c2..c520ae1ba65e 100644
@@ -547,7 +547,7 @@ static int xvcu_register_clock_provider(struct xvcu_device *xvcu)
 		return PTR_ERR(hw);
 	xvcu->pll_post = hw;
 
-	parent_data[0].fw_name = "pll_ref";
+	parent_data[0].fw_name = "dummy_name";
 	parent_data[1].hw = xvcu->pll_post;
 
 	hws[CLK_XVCU_ENC_CORE] =
Signature · 1 line
2.25.1
#3 lore raw

Re: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

Hi Rohit,

Quoted 18 lines · Rohit Visavalia

CCF will try to adjust parent clock to set desire clock frequency of child clock. So if pll_ref is not a fixed-clock then while setting rate of enc/dec clocks pll_ref may get change, which may make VCU malfunction.

---
Changes in v2:
- none
- Link to v1: https://lore.kernel.org/linux-clk/[email protected]

---
 drivers/clk/xilinx/xlnx_vcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/clk/xilinx/xlnx_vcu.c +0 -0
index 88b3fd8250c2..c520ae1ba65e 100644

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_register_clock_provider(struct xvcu_device *xvcu) · line 553

Quoted 8 lines
drivers/clk/xilinx/xlnx_vcu.c +1 -1
@@ -547,7 +547,7 @@ static int xvcu_register_clock_provider(struct xvcu_device *xvcu)
                return PTR_ERR(hw);
        xvcu->pll_post = hw;
 
-       parent_data[0].fw_name = "pll_ref";
+       parent_data[0].fw_name = "dummy_name";
        parent_data[1].hw = xvcu->pll_post;
 
        hws[CLK_XVCU_ENC_CORE] =

You completely ignored Stephen's comment, which suggests to not pas CLK_SET_RATE_PARENT instead (see xvcu_clk_hw_register_leaf()).

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw

RE: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

Hi Geert,

Thank for the review.

Quoted 41 lines

-----Original Message-----
From: Geert Uytterhoeven <[email protected]>
Sent: Friday, January 3, 2025 12:58 AM
To: Visavalia, Rohit <[email protected]>
Cc: [email protected]; [email protected]; Simek, Michal <[email protected]>; Sagar, Vishal <[email protected]>; [email protected]; [email protected]; u.kleine- [email protected]; [email protected]; linux-arm- [email protected]; [email protected]
Subject: Re: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

Hi Rohit,

Quoted 3 lines · Rohit Visavalia

CCF will try to adjust parent clock to set desire clock frequency of child clock. So if pll_ref is not a fixed-clock then while setting rate of enc/dec clocks pll_ref may get change, which may make VCU

malfunction.

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_register_clock_provider(struct

Quoted 18 lines

---
Changes in v2:
- none
- Link to v1:
https://lore.kernel.org/linux-clk/20241226122023.3439559-3-rohit.visav
[email protected]

---
 drivers/clk/xilinx/xlnx_vcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/clk/xilinx/xlnx_vcu.c index 88b3fd8250c2..c520ae1ba65e 100644

drivers/clk/xilinx/xlnx_vcu.c +0 -0
@@ -547,7 +547,7 @@ static int xvcu_register_clock_provider(struct

xvcu_device *xvcu)

Quoted 3 lines
drivers/clk/xilinx/xlnx_vcu.c +0 -0
                return PTR_ERR(hw);
        xvcu->pll_post = hw;
 
Quoted 8 lines

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_register_clock_provider(struct xvcu_device *xvcu) · line 553

Quoted 5 lines
drivers/clk/xilinx/xlnx_vcu.c +1 -1
-       parent_data[0].fw_name = "pll_ref";
+       parent_data[0].fw_name = "dummy_name";
        parent_data[1].hw = xvcu->pll_post;
 
        hws[CLK_XVCU_ENC_CORE] =

You completely ignored Stephen's comment, which suggests to not pas CLK_SET_RATE_PARENT instead (see xvcu_clk_hw_register_leaf()).

Thanks for pointing this out. Let me take care this in v3 patch series.

Quoted 11 lines

Gr{oetje,eeting}s,

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Thanks
Rohit

#5 lore raw

RE: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

Hi @Geert Uytterhoeven, @Stephen Boyd <[email protected]>

Quoted 63 lines

-----Original Message-----
From: Visavalia, Rohit
Sent: Monday, January 6, 2025 3:34 PM
To: Geert Uytterhoeven <[email protected]>
Cc: [email protected]; [email protected]; Simek, Michal <[email protected]>; Sagar, Vishal <[email protected]>; [email protected]; [email protected]; u.kleine- [email protected]; [email protected]; linux-arm- [email protected]; [email protected]
Subject: RE: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of VCU(enc/dec) clocks

Hi Geert,

Thank for the review.

Quoted 47 lines

-----Original Message-----
From: Geert Uytterhoeven <[email protected]>
Sent: Friday, January 3, 2025 12:58 AM
To: Visavalia, Rohit <[email protected]>
Cc: [email protected]; [email protected]; Simek, Michal <[email protected]>; Sagar, Vishal <[email protected]>; [email protected]; [email protected]; u.kleine- [email protected]; [email protected]; linux-arm- [email protected]; [email protected]
Subject: Re: [PATCH v2 2/3] clk: xilinx: vcu: don't set pll_ref as parent of
VCU(enc/dec) clocks

Hi Rohit,

Quoted 3 lines · Rohit Visavalia

CCF will try to adjust parent clock to set desire clock frequency of child clock. So if pll_ref is not a fixed-clock then while setting rate of enc/dec clocks pll_ref may get change, which may make VCU

malfunction.

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_register_clock_provider(struct

Quoted 19 lines

---
Changes in v2:
- none
- Link to v1:
https://lore.kernel.org/linux-clk/20241226122023.3439559-3-rohit.visa
v
[email protected]

---
 drivers/clk/xilinx/xlnx_vcu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
(quoted diff) +0 -0

b/drivers/clk/xilinx/xlnx_vcu.c index 88b3fd8250c2..c520ae1ba65e 100644

drivers/clk/xilinx/xlnx_vcu.c +0 -0
@@ -547,7 +547,7 @@ static int xvcu_register_clock_provider(struct

xvcu_device *xvcu)

Quoted 7 lines
drivers/clk/xilinx/xlnx_vcu.c +1 -1
                return PTR_ERR(hw);
        xvcu->pll_post = hw;
 
-       parent_data[0].fw_name = "pll_ref";
+       parent_data[0].fw_name = "dummy_name";
        parent_data[1].hw = xvcu->pll_post;
 
Quoted 6 lines
Quoted 4 lines

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_register_clock_provider(struct xvcu_device *xvcu) · line 553

Quoted 1 line
drivers/clk/xilinx/xlnx_vcu.c +0 -0
        hws[CLK_XVCU_ENC_CORE] =

You completely ignored Stephen's comment, which suggests to not pas CLK_SET_RATE_PARENT instead (see xvcu_clk_hw_register_leaf()).

Thanks for pointing this out. Let me take care this in v3 patch series.

We can drop this patch[PATCH v2 2/3], as original issue was occurring when "pll_ref" clock is being changed to get the best desire clock rate for encoder and decoder. And now with recent changes in Xilinx clock driver(https://github.com/torvalds/linux/commit/b782921ddd7f84f524723090377903f399fdbbcb & https://github.com/torvalds/linux/commit/1fe15be1fb613534ecbac5f8c3f8744f757d237d) encoder and decoder are getting parent as "pll_post" to get best desire clock rate and not changing rate of "pll_ref".

Thanks
Rohit

Quoted 17 lines
Quoted 4 lines

Gr{oetje,eeting}s,

Quoted 8 lines

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something

like that.

Quoted 1 line

-- Linus Torvalds

Thanks
Rohit

#6 lore raw

PATCH v2 3/3 clk: xilinx: vcu: Update vcu init/reset sequence

In reply to Rohit Visavalia

Updated vcu init/reset sequence as per design changes.
If VCU reset GPIO is available then do assert and de-assert it before enabling/disabling gasket isolation.
This GPIO is added because gasket isolation will be removed during startup that requires access to SLCR register space. Post startup, the ownership of the register interface lies with logiCORE IP.

---
Changes in v2:
- Changed patches sequence to have patches with "Fixes" as preceding in order
- Used dev_err_probe()
- Moved warning to dev_dbg() and updated print with more detail
- Link to v1: https://lore.kernel.org/linux-clk/[email protected]/

---
 drivers/clk/xilinx/xlnx_vcu.c | 29 +++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
drivers/clk/xilinx/xlnx_vcu.c +29 -0
index c520ae1ba65e..50f7c3ecb07c 100644
@@ -11,6 +11,7 @@
 #include <linux/clk-provider.h>
 #include <linux/device.h>
 #include <linux/errno.h>
+#include <linux/gpio/consumer.h>
 #include <linux/io.h>
 #include <linux/mfd/syscon.h>
 #include <linux/mfd/syscon/xlnx-vcu.h>
@@ -51,6 +52,7 @@
  * @dev: Platform device
  * @pll_ref: pll ref clock source
  * @aclk: axi clock source
+ * @reset_gpio: vcu reset gpio
  * @logicore_reg_ba: logicore reg base address
  * @vcu_slcr_ba: vcu_slcr Register base address
  * @pll: handle for the VCU PLL
@@ -61,6 +63,7 @@ struct xvcu_device {
 	struct device *dev;
 	struct clk *pll_ref;
 	struct clk *aclk;
+	struct gpio_desc *reset_gpio;
 	struct regmap *logicore_reg_ba;
 	void __iomem *vcu_slcr_ba;
 	struct clk_hw *pll;
@@ -676,6 +679,24 @@ static int xvcu_probe(struct platform_device *pdev)
 	 * Bit 0 : Gasket isolation
 	 * Bit 1 : put VCU out of reset
 	 */
+	xvcu->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
+						   GPIOD_OUT_LOW);
+	if (IS_ERR(xvcu->reset_gpio)) {
+		ret = PTR_ERR(xvcu->reset_gpio);
+		dev_err_probe(&pdev->dev, ret, "failed to get reset gpio for vcu.\n");
+		goto error_get_gpio;
+	}
+
+	if (xvcu->reset_gpio) {
+		gpiod_set_value(xvcu->reset_gpio, 0);
+		/* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */
+		usleep_range(60, 120);
+		gpiod_set_value(xvcu->reset_gpio, 1);
+		usleep_range(60, 120);
+	} else {
+		dev_dbg(&pdev->dev, "No reset gpio info found in dts for VCU. This may result in incorrect functionality if VCU isolation is removed after initialization in designs where the VCU reset is driven by gpio.\n");
+	}
+
 	regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, VCU_GASKET_VALUE);
 
 	ret = xvcu_register_clock_provider(xvcu);
@@ -690,6 +711,7 @@ static int xvcu_probe(struct platform_device *pdev)
 
 error_clk_provider:
 	xvcu_unregister_clock_provider(xvcu);
+error_get_gpio:
 	clk_disable_unprepare(xvcu->aclk);
 	return ret;
 }
@@ -711,6 +733,13 @@ static void xvcu_remove(struct platform_device *pdev)
 	xvcu_unregister_clock_provider(xvcu);
 
 	/* Add the Gasket isolation and put the VCU in reset. */
+	if (xvcu->reset_gpio) {
+		gpiod_set_value(xvcu->reset_gpio, 0);
+		/* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */
+		usleep_range(60, 120);
+		gpiod_set_value(xvcu->reset_gpio, 1);
+		usleep_range(60, 120);
+	}
 	regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, 0);
 
 	clk_disable_unprepare(xvcu->aclk);
Signature · 1 line
2.25.1
#7 lore raw

Re: [PATCH v2 3/3] clk: xilinx: vcu: Update vcu init/reset sequence

Hi Rohit,

Quoted 7 lines · Rohit Visavalia

Updated vcu init/reset sequence as per design changes.
If VCU reset GPIO is available then do assert and de-assert it before enabling/disabling gasket isolation.
This GPIO is added because gasket isolation will be removed during startup that requires access to SLCR register space. Post startup, the ownership of the register interface lies with logiCORE IP.

Quoted 6 lines

---
Changes in v2:
- Changed patches sequence to have patches with "Fixes" as preceding in order
- Used dev_err_probe()
- Moved warning to dev_dbg() and updated print with more detail

Thanks for the update!

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_probe(struct platform_device *pdev) · line 683

Quoted 8 lines
drivers/clk/xilinx/xlnx_vcu.c +2 -0
@@ -676,6 +679,24 @@ static int xvcu_probe(struct platform_device *pdev)
         * Bit 0 : Gasket isolation
         * Bit 1 : put VCU out of reset
         */
+       xvcu->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
+                                                  GPIOD_OUT_LOW);

This requires updating the DT bindings _first_.

Quoted 9 lines
drivers/clk/xilinx/xlnx_vcu.c +9 -0
+       if (IS_ERR(xvcu->reset_gpio)) {
+               ret = PTR_ERR(xvcu->reset_gpio);
+               dev_err_probe(&pdev->dev, ret, "failed to get reset gpio for vcu.\n");
+               goto error_get_gpio;
+       }
+
+       if (xvcu->reset_gpio) {
+               gpiod_set_value(xvcu->reset_gpio, 0);
+               /* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_probe(struct platform_device *pdev) · line 702

Quoted 10 lines
drivers/clk/xilinx/xlnx_vcu.c +7 -0
+               usleep_range(60, 120);
+               gpiod_set_value(xvcu->reset_gpio, 1);
+               usleep_range(60, 120);
+       } else {
+               dev_dbg(&pdev->dev, "No reset gpio info found in dts for VCU. This may result in incorrect functionality if VCU isolation is removed after initialization in designs where the VCU reset is driven by gpio.\n");
+       }
+
        regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT, VCU_GASKET_VALUE);
 
        ret = xvcu_register_clock_provider(xvcu);

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#8 lore raw

RE: [PATCH v2 3/3] clk: xilinx: vcu: Update vcu init/reset sequence

Hi Geert,

Thanks for the review.

Quoted 30 lines

-----Original Message-----
From: Geert Uytterhoeven <[email protected]>
Sent: Friday, January 3, 2025 1:01 AM
To: Visavalia, Rohit <[email protected]>
Cc: [email protected]; [email protected]; Simek, Michal <[email protected]>; Sagar, Vishal <[email protected]>; [email protected]; [email protected]; u.kleine- [email protected]; [email protected]; linux-arm- [email protected]; [email protected]
Subject: Re: [PATCH v2 3/3] clk: xilinx: vcu: Update vcu init/reset sequence

Hi Rohit,

Quoted 7 lines · Rohit Visavalia

Updated vcu init/reset sequence as per design changes.
If VCU reset GPIO is available then do assert and de-assert it before enabling/disabling gasket isolation.
This GPIO is added because gasket isolation will be removed during startup that requires access to SLCR register space. Post startup, the ownership of the register interface lies with logiCORE IP.

Quoted 6 lines

---
Changes in v2:
- Changed patches sequence to have patches with "Fixes" as preceding in order
- Used dev_err_probe()
- Moved warning to dev_dbg() and updated print with more detail

Thanks for the update!

Quoted 10 lines

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_probe(struct platform_device *pdev) · line 683

Quoted 8 lines
drivers/clk/xilinx/xlnx_vcu.c +2 -0
@@ -676,6 +679,24 @@ static int xvcu_probe(struct platform_device *pdev)
         * Bit 0 : Gasket isolation
         * Bit 1 : put VCU out of reset
         */
+       xvcu->reset_gpio = devm_gpiod_get_optional(&pdev->dev, "reset",
+                                                  GPIOD_OUT_LOW);

This requires updating the DT bindings _first_.

Yes, shared patch for the same.

Quoted 26 lines
Quoted 5 lines
drivers/clk/xilinx/xlnx_vcu.c +4 -0
+       if (IS_ERR(xvcu->reset_gpio)) {
+               ret = PTR_ERR(xvcu->reset_gpio);
+               dev_err_probe(&pdev->dev, ret, "failed to get reset gpio for vcu.\n");
+               goto error_get_gpio;

drivers/clk/xilinx/xlnx_vcu.c static int xvcu_probe(struct platform_device *pdev)

Quoted 10 lines
drivers/clk/xilinx/xlnx_vcu.c +10 -0
+       }
+
+       if (xvcu->reset_gpio) {
+               gpiod_set_value(xvcu->reset_gpio, 0);
+               /* min 2 clock cycle of vcu pll_ref, slowest freq is 33.33KHz */
+               usleep_range(60, 120);
+               gpiod_set_value(xvcu->reset_gpio, 1);
+               usleep_range(60, 120);
+       } else {
+               dev_dbg(&pdev->dev, "No reset gpio info found in dts for VCU. This may

result in incorrect functionality if VCU isolation is removed after initialization in designs where the VCU reset is driven by gpio.\n");

Quoted 6 lines
drivers/clk/xilinx/xlnx_vcu.c +2 -0
+       }
+
        regmap_write(xvcu->logicore_reg_ba, VCU_GASKET_INIT,
 VCU_GASKET_VALUE);
 
        ret = xvcu_register_clock_provider(xvcu);

Gr{oetje,eeting}s,

Quoted 8 lines

Geert

--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds

Thanks
Rohit