Skip to content

Commit fcaca5d

Browse files
committed
Merge branch 'etnaviv/fixes' of https://git.pengutronix.de/git/lst/linux into drm-fixes
Lucas wrote: "a couple of small fixes: - 2 patches from Fabio to fix module reloading - one patch to fix a userspace visible regression, where the job timeout is a bit too eager and kills legitimate jobs" Signed-off-by: Dave Airlie <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
2 parents 1e4b044 + 2c83a72 commit fcaca5d

File tree

3 files changed

+47
-4
lines changed

3 files changed

+47
-4
lines changed

drivers/gpu/drm/etnaviv/etnaviv_drv.c

Lines changed: 20 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -631,8 +631,11 @@ static struct platform_driver etnaviv_platform_driver = {
631631
},
632632
};
633633

634+
static struct platform_device *etnaviv_drm;
635+
634636
static int __init etnaviv_init(void)
635637
{
638+
struct platform_device *pdev;
636639
int ret;
637640
struct device_node *np;
638641

@@ -644,7 +647,7 @@ static int __init etnaviv_init(void)
644647

645648
ret = platform_driver_register(&etnaviv_platform_driver);
646649
if (ret != 0)
647-
platform_driver_unregister(&etnaviv_gpu_driver);
650+
goto unregister_gpu_driver;
648651

649652
/*
650653
* If the DT contains at least one available GPU device, instantiate
@@ -653,20 +656,33 @@ static int __init etnaviv_init(void)
653656
for_each_compatible_node(np, NULL, "vivante,gc") {
654657
if (!of_device_is_available(np))
655658
continue;
656-
657-
platform_device_register_simple("etnaviv", -1, NULL, 0);
659+
pdev = platform_device_register_simple("etnaviv", -1,
660+
NULL, 0);
661+
if (IS_ERR(pdev)) {
662+
ret = PTR_ERR(pdev);
663+
of_node_put(np);
664+
goto unregister_platform_driver;
665+
}
666+
etnaviv_drm = pdev;
658667
of_node_put(np);
659668
break;
660669
}
661670

671+
return 0;
672+
673+
unregister_platform_driver:
674+
platform_driver_unregister(&etnaviv_platform_driver);
675+
unregister_gpu_driver:
676+
platform_driver_unregister(&etnaviv_gpu_driver);
662677
return ret;
663678
}
664679
module_init(etnaviv_init);
665680

666681
static void __exit etnaviv_exit(void)
667682
{
668-
platform_driver_unregister(&etnaviv_gpu_driver);
683+
platform_device_unregister(etnaviv_drm);
669684
platform_driver_unregister(&etnaviv_platform_driver);
685+
platform_driver_unregister(&etnaviv_gpu_driver);
670686
}
671687
module_exit(etnaviv_exit);
672688

drivers/gpu/drm/etnaviv/etnaviv_gpu.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,9 @@ struct etnaviv_gpu {
131131
struct work_struct sync_point_work;
132132
int sync_point_event;
133133

134+
/* hang detection */
135+
u32 hangcheck_dma_addr;
136+
134137
void __iomem *mmio;
135138
int irq;
136139

drivers/gpu/drm/etnaviv/etnaviv_sched.c

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
#include "etnaviv_gem.h"
1111
#include "etnaviv_gpu.h"
1212
#include "etnaviv_sched.h"
13+
#include "state.xml.h"
1314

1415
static int etnaviv_job_hang_limit = 0;
1516
module_param_named(job_hang_limit, etnaviv_job_hang_limit, int , 0444);
@@ -85,6 +86,29 @@ static void etnaviv_sched_timedout_job(struct drm_sched_job *sched_job)
8586
{
8687
struct etnaviv_gem_submit *submit = to_etnaviv_submit(sched_job);
8788
struct etnaviv_gpu *gpu = submit->gpu;
89+
u32 dma_addr;
90+
int change;
91+
92+
/*
93+
* If the GPU managed to complete this jobs fence, the timout is
94+
* spurious. Bail out.
95+
*/
96+
if (fence_completed(gpu, submit->out_fence->seqno))
97+
return;
98+
99+
/*
100+
* If the GPU is still making forward progress on the front-end (which
101+
* should never loop) we shift out the timeout to give it a chance to
102+
* finish the job.
103+
*/
104+
dma_addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
105+
change = dma_addr - gpu->hangcheck_dma_addr;
106+
if (change < 0 || change > 16) {
107+
gpu->hangcheck_dma_addr = dma_addr;
108+
schedule_delayed_work(&sched_job->work_tdr,
109+
sched_job->sched->timeout);
110+
return;
111+
}
88112

89113
/* block scheduler */
90114
kthread_park(gpu->sched.thread);

0 commit comments

Comments
 (0)