[RFC PATCH 2/3] drm/imagination: fix clock control on the J722S

Michael Walle posted 3 patches 2 months, 3 weeks ago
There is a newer version of this series
[RFC PATCH 2/3] drm/imagination: fix clock control on the J722S
Posted by Michael Walle 2 months, 3 weeks ago
The J722S won't let you set the clock frequency if there is no device
using it. Thus, the assigned-clocks property won't work per se.

As a workaround, set the clock again during the probing of the driver.

Signed-off-by: Michael Walle <mwalle@kernel.org>
---
 drivers/gpu/drm/imagination/pvr_device.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c
index 8b9ba4983c4c..e7a7cc1bdf93 100644
--- a/drivers/gpu/drm/imagination/pvr_device.c
+++ b/drivers/gpu/drm/imagination/pvr_device.c
@@ -16,6 +16,7 @@
 
 #include <linux/bitfield.h>
 #include <linux/clk.h>
+#include <linux/clk/clk-conf.h>
 #include <linux/compiler_attributes.h>
 #include <linux/compiler_types.h>
 #include <linux/dma-mapping.h>
@@ -641,6 +642,14 @@ pvr_device_init(struct pvr_device *pvr_dev)
 	if (err)
 		return err;
 
+	/* Set any 'assigned-clocks' properties again. This is a workaround for
+	 * the clock handling on k3 platforms. There, one cannot set the clock
+	 * frequency until there is at least one (enabled) user if it.
+	 */
+	err = of_clk_set_defaults(drm_dev->dev->of_node, true);
+	if (err)
+		return err;
+
 	/* Map the control registers into memory. */
 	err = pvr_device_reg_init(pvr_dev);
 	if (err)
-- 
2.39.5
Re: [RFC PATCH 2/3] drm/imagination: fix clock control on the J722S
Posted by Krzysztof Kozlowski 1 month, 3 weeks ago
On 16/07/2025 15:47, Michael Walle wrote:
> The J722S won't let you set the clock frequency if there is no device
> using it. Thus, the assigned-clocks property won't work per se.
> 
> As a workaround, set the clock again during the probing of the driver.
> 
> Signed-off-by: Michael Walle <mwalle@kernel.org>
> ---
>  drivers/gpu/drm/imagination/pvr_device.c | 9 +++++++++
>  1 file changed, 9 insertions(+)
> 
> diff --git a/drivers/gpu/drm/imagination/pvr_device.c b/drivers/gpu/drm/imagination/pvr_device.c
> index 8b9ba4983c4c..e7a7cc1bdf93 100644
> --- a/drivers/gpu/drm/imagination/pvr_device.c
> +++ b/drivers/gpu/drm/imagination/pvr_device.c
> @@ -16,6 +16,7 @@
>  
>  #include <linux/bitfield.h>
>  #include <linux/clk.h>
> +#include <linux/clk/clk-conf.h>
>  #include <linux/compiler_attributes.h>
>  #include <linux/compiler_types.h>
>  #include <linux/dma-mapping.h>
> @@ -641,6 +642,14 @@ pvr_device_init(struct pvr_device *pvr_dev)
>  	if (err)
>  		return err;
>  
> +	/* Set any 'assigned-clocks' properties again. This is a workaround for
> +	 * the clock handling on k3 platforms. There, one cannot set the clock
> +	 * frequency until there is at least one (enabled) user if it.
> +	 */
> +	err = of_clk_set_defaults(drm_dev->dev->of_node, true);
> +	if (err)
> +		return err;

+Cc Abel, Bjorn, Konrad, Stephan G. and Stephen B.,

Interesting stuff. This touches a bit similar problems we have (and had)
for Qualcomm Display PHYs, where assigned-clock-parents were called too
early - before the block (PHY) is being enabled.

The workaround we implemented so far was - last patch hook in:
https://web.git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=80dd5911cbfdc2f6ae904341d41a7a8bd8cc546c

I know Stephan G. is working on something better, so probably he will Cc
you once this is ready.

Best regards,
Krzysztof