drm/etnaviv: Tidy up clocks handling
Subsystems (2)
v2 cover drm/etnaviv: Tidy up clocks handling
Hi,
please consider applying patches that are chained to this message.
They make getting/enabling the clocks in the etnaviv driver slightly nicer, first two also fix potential problems.
Compared to v1, patch 2/4 was fixed and patch 3/4 was added.
As it was pointed out in response to v1, the clocks documented as mandatory by the binding document are different from what the driver enforces. Moreover, there is no agreement on which clocks must be present in the device tree, so I'm leaving the binding document until it's cleared up.
In any case, the "core" clock is always present so it's safe to make it mandatory and regardless of what ends up happening to the binding documentation, the other clocks can't be enforced without regressions. At most a comment or a warning could be added. I'm leaving it as it is.
Thank you
Lubo
PATCH RESEND v2 1/4 drm/etnaviv: Fix error path on failure to enable bus clk
Since commit 65f037e8e908 ("drm/etnaviv: add support for slave interface clock") the reg clock is enabled before the bus clock and we need to undo its enablement on error.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +4 -1
@@ -1496,7 +1496,7 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu)if (gpu->clk_bus) { ret =clk_prepare_enable (gpu->clk_bus);if (ret) -return ret; + goto disable_clk_reg; }if (gpu->clk_core) {
@@ -1519,6 +1519,9 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) disable_clk_bus:if (gpu->clk_bus)clk_disable_unprepare (gpu->clk_bus); +disable_clk_reg: +if (gpu->clk_reg) +clk_disable_unprepare (gpu->clk_reg);return ret; }
Signature · 1 line
2.26.2
PATCH RESEND v2 2/4 drm/etnaviv: Don't ignore errors on getting clocks
In reply to Lubomir RintelThere might be good reasons why the getting a clock failed. To treat the clocks as optional we're specifically only interested in ignoring -ENOENT, and devm_clk_get_optional() does just that.
Note that this preserves the original behavior of all clocks being optional. The binding document mandates the "bus" clock while the dove machine only specifies "core".
---
Changes since v1:
- Fix the actual return value
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +8 -8
@@ -1786,26 +1786,26 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev) }/* Get Clocks: */ - gpu->clk_reg =devm_clk_get (&pdev->dev,"reg" ); + gpu->clk_reg =devm_clk_get_optional (&pdev->dev,"reg" );DBG ("clk_reg: %p" , gpu->clk_reg);if (IS_ERR (gpu->clk_reg)) - gpu->clk_reg =NULL ; +return PTR_ERR (gpu->clk_reg); - gpu->clk_bus =devm_clk_get (&pdev->dev,"bus" ); + gpu->clk_bus =devm_clk_get_optional (&pdev->dev,"bus" );DBG ("clk_bus: %p" , gpu->clk_bus);if (IS_ERR (gpu->clk_bus)) - gpu->clk_bus =NULL ; +return PTR_ERR (gpu->clk_bus); - gpu->clk_core =devm_clk_get (&pdev->dev,"core" ); + gpu->clk_core =devm_clk_get_optional (&pdev->dev,"core" );DBG ("clk_core: %p" , gpu->clk_core);if (IS_ERR (gpu->clk_core)) - gpu->clk_core =NULL ; +return PTR_ERR (gpu->clk_core); gpu->base_rate_core =clk_get_rate (gpu->clk_core); - gpu->clk_shader =devm_clk_get (&pdev->dev,"shader" ); + gpu->clk_shader =devm_clk_get_optional (&pdev->dev,"shader" );DBG ("clk_shader: %p" , gpu->clk_shader);if (IS_ERR (gpu->clk_shader)) - gpu->clk_shader =NULL ; +return PTR_ERR (gpu->clk_shader); gpu->base_rate_shader =clk_get_rate (gpu->clk_shader);/* TODO: figure out max mapped size */
Signature · 1 line
2.26.2
PATCH RESEND v2 3/4 drm/etnaviv: Make the "core" clock mandatory
In reply to Lubomir RintelIt is always present. It was documented as mandatory prior to commit 90aeca875f8a ("dt-bindings: display: Convert etnaviv to json-schema").
---
Changes since v1:
- Add this patch
drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +1 -1
@@ -1796,7 +1796,7 @@ static int etnaviv_gpu_platform_probe(struct platform_device *pdev)if (IS_ERR (gpu->clk_bus))return PTR_ERR (gpu->clk_bus); - gpu->clk_core =devm_clk_get_optional (&pdev->dev,"core" ); + gpu->clk_core =devm_clk_get (&pdev->dev,"core" );DBG ("clk_core: %p" , gpu->clk_core);if (IS_ERR (gpu->clk_core))return PTR_ERR (gpu->clk_core);
Signature · 1 line
2.26.2
PATCH RESEND v2 4/4 drm/etnaviv: Simplify clock enable/disable
In reply to Lubomir RintelAll the NULL checks are pointless, clk_*() routines already deal with NULL just fine.
--- drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 53 ++++++++++----------------- 1 file changed, 19 insertions(+), 34 deletions(-)
drivers/gpu/drm/etnaviv/etnaviv_gpu.c +19 -34
@@ -1487,55 +1487,40 @@ static int etnaviv_gpu_clk_enable(struct etnaviv_gpu *gpu) {int ret; -if (gpu->clk_reg) { - ret =clk_prepare_enable (gpu->clk_reg); -if (ret) -return ret; - } + ret =clk_prepare_enable (gpu->clk_reg); +if (ret) +return ret; -if (gpu->clk_bus) { - ret =clk_prepare_enable (gpu->clk_bus); -if (ret) - goto disable_clk_reg; - } + ret =clk_prepare_enable (gpu->clk_bus); +if (ret) + goto disable_clk_reg; -if (gpu->clk_core) { - ret =clk_prepare_enable (gpu->clk_core); -if (ret) - goto disable_clk_bus; - } + ret =clk_prepare_enable (gpu->clk_core); +if (ret) + goto disable_clk_bus; -if (gpu->clk_shader) { - ret =clk_prepare_enable (gpu->clk_shader); -if (ret) - goto disable_clk_core; - } + ret =clk_prepare_enable (gpu->clk_shader); +if (ret) + goto disable_clk_core;return 0 ; disable_clk_core: -if (gpu->clk_core) -clk_disable_unprepare (gpu->clk_core); +clk_disable_unprepare (gpu->clk_core); disable_clk_bus: -if (gpu->clk_bus) -clk_disable_unprepare (gpu->clk_bus); +clk_disable_unprepare (gpu->clk_bus); disable_clk_reg: -if (gpu->clk_reg) -clk_disable_unprepare (gpu->clk_reg); +clk_disable_unprepare (gpu->clk_reg);return ret; }static int etnaviv_gpu_clk_disable (struct etnaviv_gpu *gpu) { -if (gpu->clk_shader) -clk_disable_unprepare (gpu->clk_shader); -if (gpu->clk_core) -clk_disable_unprepare (gpu->clk_core); -if (gpu->clk_bus) -clk_disable_unprepare (gpu->clk_bus); -if (gpu->clk_reg) -clk_disable_unprepare (gpu->clk_reg); +clk_disable_unprepare (gpu->clk_shader); +clk_disable_unprepare (gpu->clk_core); +clk_disable_unprepare (gpu->clk_bus); +clk_disable_unprepare (gpu->clk_reg);return 0 ; }
Signature · 1 line
2.26.2
Lucas Stach
maintainerAm Dienstag, den 16.06.2020, 23:21 +0200 schrieb Lubomir Rintel:
Quoted 3 lines
Hi,
please consider applying patches that are chained to this message.
Thanks, I've applied all of them to etnaviv/next.
Regards,
Lucas
Quoted 24 lines
They make getting/enabling the clocks in the etnaviv driver slightly nicer, first two also fix potential problems.
Compared to v1, patch 2/4 was fixed and patch 3/4 was added.
As it was pointed out in response to v1, the clocks documented as mandatory by the binding document are different from what the driver enforces. Moreover, there is no agreement on which clocks must be present in the device tree, so I'm leaving the binding document until it's cleared up.
In any case, the "core" clock is always present so it's safe to make it mandatory and regardless of what ends up happening to the binding documentation, the other clocks can't be enforced without regressions. At most a comment or a warning could be added. I'm leaving it as it is.
Thank you
Lubo_______________________________________________
etnaviv mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/etnaviv