public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/1] gpu: drm: aspeed: fix value check in aspeed_gfx_load()
@ 2023-07-27 17:03 Yuanjun Gong
  2023-07-27 17:57 ` Christophe JAILLET
  0 siblings, 1 reply; 3+ messages in thread
From: Yuanjun Gong @ 2023-07-27 17:03 UTC (permalink / raw)
  To: Joel Stanley, David Airlie, Daniel Vetter, Andrew Jeffery,
	dri-devel, linux-kernel
  Cc: Yuanjun Gong

in aspeed_gfx_load(), check the return value of clk_prepare_enable()
and return the error code if clk_prepare_enable() returns an
unexpected value.

Fixes: 4f2a8f5898ec ("drm: Add ASPEED GFX driver")
Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index c8c7f8215155..3bfa39bc4f7e 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -199,7 +199,11 @@ static int aspeed_gfx_load(struct drm_device *drm)
 			"missing or invalid clk device tree entry");
 		return PTR_ERR(priv->clk);
 	}
-	clk_prepare_enable(priv->clk);
+	ret = clk_prepare_enable(priv->clk);
+	if (ret) {
+		dev_err(&pdev->dev, "Failed to enable clock\n");
+		return ret;
+	}
 
 	/* Sanitize control registers */
 	writel(0, priv->base + CRT_CTRL1);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] gpu: drm: aspeed: fix value check in aspeed_gfx_load()
  2023-07-27 17:03 [PATCH 1/1] gpu: drm: aspeed: fix value check in aspeed_gfx_load() Yuanjun Gong
@ 2023-07-27 17:57 ` Christophe JAILLET
  2023-07-28  1:53   ` [PATCH v2 1/1] gpu: drm: aspeed: use devm_clk_get_enabled() " Yuanjun Gong
  0 siblings, 1 reply; 3+ messages in thread
From: Christophe JAILLET @ 2023-07-27 17:57 UTC (permalink / raw)
  To: Yuanjun Gong, Joel Stanley, David Airlie, Daniel Vetter,
	Andrew Jeffery, dri-devel, linux-kernel

Le 27/07/2023 à 19:03, Yuanjun Gong a écrit :
> in aspeed_gfx_load(), check the return value of clk_prepare_enable()
> and return the error code if clk_prepare_enable() returns an
> unexpected value.
> 
> Fixes: 4f2a8f5898ec ("drm: Add ASPEED GFX driver")
> Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
> ---
>   drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> index c8c7f8215155..3bfa39bc4f7e 100644
> --- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> +++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
> @@ -199,7 +199,11 @@ static int aspeed_gfx_load(struct drm_device *drm)
>   			"missing or invalid clk device tree entry");
>   		return PTR_ERR(priv->clk);
>   	}
> -	clk_prepare_enable(priv->clk);
> +	ret = clk_prepare_enable(priv->clk);
> +	if (ret) {
> +		dev_err(&pdev->dev, "Failed to enable clock\n");
> +		return ret;
> +	}
>   
>   	/* Sanitize control registers */
>   	writel(0, priv->base + CRT_CTRL1);

Hi,

the code also lacks a clk_disable_unprepare() in aspeed_gfx_unload().

So using devm_clk_get_enabled() a few lines above should fix both issue.

CJ

^ permalink raw reply	[flat|nested] 3+ messages in thread

* [PATCH v2 1/1] gpu: drm: aspeed: use devm_clk_get_enabled() in aspeed_gfx_load()
  2023-07-27 17:57 ` Christophe JAILLET
@ 2023-07-28  1:53   ` Yuanjun Gong
  0 siblings, 0 replies; 3+ messages in thread
From: Yuanjun Gong @ 2023-07-28  1:53 UTC (permalink / raw)
  To: christophe.jaillet
  Cc: airlied, andrew, daniel, dri-devel, joel, linux-kernel,
	ruc_gongyuanjun

in aspeed_gfx_load(), clk_prepare_enable() might return an
unexpected value. using devm_clk_get_enabled() instead of
devm_clk_get() and clk_prepare_enable() can avoid this problem.

Fixes: 4f2a8f5898ec ("drm: Add ASPEED GFX driver")
Signed-off-by: Yuanjun Gong <ruc_gongyuanjun@163.com>
---
 drivers/gpu/drm/aspeed/aspeed_gfx_drv.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
index c8c7f8215155..3d3ee70fb5ea 100644
--- a/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
+++ b/drivers/gpu/drm/aspeed/aspeed_gfx_drv.c
@@ -193,13 +193,12 @@ static int aspeed_gfx_load(struct drm_device *drm)
 	}
 	reset_control_deassert(priv->rst);
 
-	priv->clk = devm_clk_get(drm->dev, NULL);
+	priv->clk = devm_clk_get_enabled(drm->dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		dev_err(&pdev->dev,
 			"missing or invalid clk device tree entry");
 		return PTR_ERR(priv->clk);
 	}
-	clk_prepare_enable(priv->clk);
 
 	/* Sanitize control registers */
 	writel(0, priv->base + CRT_CTRL1);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-07-28  1:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-07-27 17:03 [PATCH 1/1] gpu: drm: aspeed: fix value check in aspeed_gfx_load() Yuanjun Gong
2023-07-27 17:57 ` Christophe JAILLET
2023-07-28  1:53   ` [PATCH v2 1/1] gpu: drm: aspeed: use devm_clk_get_enabled() " Yuanjun Gong

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox