drm/lima: two driver cleanups
Subsystems (3)
cover drm/lima: two driver cleanups
Patch 1 is a fix for a crash which triggers on removing the module on kernels with CONFIG_DEBUG_SHIRQ enabled, such as the Fedora kernel.
Patch 2 is a fix to this warning:
drivers/gpu/drm/lima/lima_drv.c:387:13: error: cast to smaller integer type 'enum lima_gpu_id' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
which we have received as a repeated report from the kernel test bot to the lima mailing list.
The warning only reproduces with recent clang on aarch64, but the patch does get rid of it and there seem to be no more warnings for W=1.
Erico Nunes (2):
drm/lima: fix shared irq handling on driver remove drm/lima: fix void pointer to enum lima_gpu_id cast warning
drivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++++++++--- drivers/gpu/drm/lima/lima_drv.h | 5 +++++ drivers/gpu/drm/lima/lima_gp.c | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 5 +++++ drivers/gpu/drm/lima/lima_pp.c | 4 ++++ 5 files changed, 34 insertions(+), 3 deletions(-)
Signature · 1 line
2.44.0
PATCH 1/2 drm/lima: fix shared irq handling on driver remove
lima uses a shared interrupt, so the interrupt handlers must be prepared to be called at any time. At driver removal time, the clocks are disabled early and the interrupts stay registered until the very end of the remove process due to the devm usage.
This is potentially a bug as the interrupts access device registers which assumes clocks are enabled. A crash can be triggered by removing the driver in a kernel with CONFIG_DEBUG_SHIRQ enabled.
This patch frees the interrupts at each lima device finishing callback so that the handlers are already unregistered by the time we fully disable clocks.
--- drivers/gpu/drm/lima/lima_gp.c | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 5 +++++ drivers/gpu/drm/lima/lima_pp.c | 4 ++++ 3 files changed, 11 insertions(+)
drivers/gpu/drm/lima/lima_gp.c +2 -0
@@ -338,7 +338,9 @@ int lima_gp_init(struct lima_ip *ip)void lima_gp_fini (struct lima_ip *ip) { +struct lima_device *dev = ip->dev; +devm_free_irq (dev->dev, ip->irq, ip); }int lima_gp_pipe_init (struct lima_device *dev)
drivers/gpu/drm/lima/lima_mmu.c +5 -0
@@ -118,7 +118,12 @@ int lima_mmu_init(struct lima_ip *ip)void lima_mmu_fini (struct lima_ip *ip) { +struct lima_device *dev = ip->dev; + +if (ip->id == lima_ip_ppmmu_bcast) +return ; +devm_free_irq (dev->dev, ip->irq, ip); }void lima_mmu_flush_tlb (struct lima_ip *ip)
drivers/gpu/drm/lima/lima_pp.c +4 -0
@@ -286,7 +286,9 @@ int lima_pp_init(struct lima_ip *ip)void lima_pp_fini (struct lima_ip *ip) { +struct lima_device *dev = ip->dev; +devm_free_irq (dev->dev, ip->irq, ip); }int lima_pp_bcast_resume (struct lima_ip *ip)
@@ -319,7 +321,9 @@ int lima_pp_bcast_init(struct lima_ip *ip)void lima_pp_bcast_fini (struct lima_ip *ip) { +struct lima_device *dev = ip->dev; +devm_free_irq (dev->dev, ip->irq, ip); } static int lima_pp_task_validate(struct lima_sched_pipe *pipe,
Signature · 1 line
2.44.0
PATCH 2/2 drm/lima: fix void pointer to enum lima_gpu_id cast warning
In reply to Erico NunesCreate a simple data struct to hold compatible data so that we don't have to do the casts to void pointer to hold data.
Fixes the following warning:
drivers/gpu/drm/lima/lima_drv.c:387:13: error: cast to smaller integer type 'enum lima_gpu_id' from 'const void *'
--- drivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++++++++--- drivers/gpu/drm/lima/lima_drv.h | 5 +++++ 2 files changed, 23 insertions(+), 3 deletions(-)
drivers/gpu/drm/lima/lima_drv.c +18 -3
@@ -371,6 +371,7 @@ static int lima_pdev_probe(struct platform_device *pdev) {struct lima_device *ldev;struct drm_device *ddev; +const struct lima_compatible *comp;int err; err =lima_sched_slab_init ();
@@ -384,7 +385,13 @@ static int lima_pdev_probe(struct platform_device *pdev) } ldev->dev = &pdev->dev; - ldev->id = (enum lima_gpu_id )of_device_get_match_data (&pdev->dev); + comp =of_device_get_match_data (&pdev->dev); +if (!comp) { + err = -ENODEV ; + goto err_out0; + } + + ldev->id = comp->id;platform_set_drvdata (pdev, ldev);
@@ -459,9 +466,17 @@ static void lima_pdev_remove(struct platform_device *pdev)lima_sched_slab_fini (); } +static const struct lima_compatible lima_mali400_data = { + .id = lima_gpu_mali400, +}; + +static const struct lima_compatible lima_mali450_data = { + .id = lima_gpu_mali450, +}; +static const struct of_device_id dt_match[] = { - { .compatible ="arm,mali-400" , .data = (void *)lima_gpu_mali400 }, - { .compatible ="arm,mali-450" , .data = (void *)lima_gpu_mali450 }, + { .compatible ="arm,mali-400" , .data = &lima_mali400_data }, + { .compatible ="arm,mali-450" , .data = &lima_mali450_data }, {} };MODULE_DEVICE_TABLE (of, dt_match);
drivers/gpu/drm/lima/lima_drv.h +5 -0
@@ -7,6 +7,7 @@#include <drm/drm_file.h> #include "lima_ctx.h" +#include "lima_device.h" extern int lima_sched_timeout_ms;extern uint lima_heap_init_nr_pages;
@@ -39,6 +40,10 @@ struct lima_submit {struct lima_sched_task *task; }; +struct lima_compatible { +enum lima_gpu_id id; +}; +static inline struct lima_drm_priv *to_lima_drm_priv (struct drm_file *file) {
Signature · 1 line
2.44.0
Qiang Yu
maintainerSerial is Reviewed-by: Qiang Yu <[email protected]>
Quoted 27 lines · Erico Nunes
Patch 1 is a fix for a crash which triggers on removing the module on kernels with
CONFIG_DEBUG_SHIRQenabled, such as the Fedora kernel.Patch 2 is a fix to this warning:
drivers/gpu/drm/lima/lima_drv.c:387:13: error: cast to smaller integer type 'enumlima_gpu_id' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
which we have received as a repeated report from the kernel test bot to the lima mailing list.
The warning only reproduces with recent clang on aarch64, but the patch does get rid of it and there seem to be no more warnings for W=1.Erico Nunes (2):
drm/lima: fix shared irq handling on driver remove drm/lima: fix void pointer to enumlima_gpu_idcast warningdrivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++++++++--- drivers/gpu/drm/lima/lima_drv.h | 5 +++++ drivers/gpu/drm/lima/lima_gp.c | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 5 +++++ drivers/gpu/drm/lima/lima_pp.c | 4 ++++ 5 files changed, 34 insertions(+), 3 deletions(-)--
2.44.0
applied to drm-misc-next
Quoted 31 lines · Qiang Yu
Serial is Reviewed-by: Qiang Yu <[email protected]>
Quoted 27 lines · Erico Nunes
Patch 1 is a fix for a crash which triggers on removing the module on kernels with
CONFIG_DEBUG_SHIRQenabled, such as the Fedora kernel.Patch 2 is a fix to this warning:
drivers/gpu/drm/lima/lima_drv.c:387:13: error: cast to smaller integer type 'enumlima_gpu_id' from 'const void *' [-Werror,-Wvoid-pointer-to-enum-cast]
which we have received as a repeated report from the kernel test bot to the lima mailing list.
The warning only reproduces with recent clang on aarch64, but the patch does get rid of it and there seem to be no more warnings for W=1.Erico Nunes (2):
drm/lima: fix shared irq handling on driver remove drm/lima: fix void pointer to enumlima_gpu_idcast warningdrivers/gpu/drm/lima/lima_drv.c | 21 ++++++++++++++++++--- drivers/gpu/drm/lima/lima_drv.h | 5 +++++ drivers/gpu/drm/lima/lima_gp.c | 2 ++ drivers/gpu/drm/lima/lima_mmu.c | 5 +++++ drivers/gpu/drm/lima/lima_pp.c | 4 ++++ 5 files changed, 34 insertions(+), 3 deletions(-)--
2.44.0