All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/etnaviv: fix GPU vs sync point race
@ 2017-10-19 13:10 Lucas Stach
  2017-10-19 15:19 ` Christian Gmeiner
  0 siblings, 1 reply; 2+ messages in thread
From: Lucas Stach @ 2017-10-19 13:10 UTC (permalink / raw)
  To: dri-devel; +Cc: etnaviv, patchwork-lst, kernel, Russell King, Chris Healy

If the FE is restarted before the sync point event is cleared, the GPU
might trigger a completion IRQ for the next sync point before corrupting
the state of the currently running worker.

Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
---
 drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 16 ++++++----------
 1 file changed, 6 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 93a103eb1083..8ff5d01e776d 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -1484,22 +1484,18 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
 	return ret;
 }
 
-static void etnaviv_process_sync_point(struct etnaviv_gpu *gpu,
-	struct etnaviv_event *event)
-{
-	u32 addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
-
-	event->sync_point(gpu, event);
-	etnaviv_gpu_start_fe(gpu, addr + 2, 2);
-}
-
 static void sync_point_worker(struct work_struct *work)
 {
 	struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
 					       sync_point_work);
+	struct etnaviv_event *event = &gpu->event[gpu->sync_point_event];
+	u32 addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
 
-	etnaviv_process_sync_point(gpu, &gpu->event[gpu->sync_point_event]);
+	event->sync_point(gpu, event);
 	event_free(gpu, gpu->sync_point_event);
+
+	/* restart FE last to avoid GPU and IRQ racing against this worker */
+	etnaviv_gpu_start_fe(gpu, addr + 2, 2);
 }
 
 /*
-- 
2.11.0

_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

* Re: [PATCH] drm/etnaviv: fix GPU vs sync point race
  2017-10-19 13:10 [PATCH] drm/etnaviv: fix GPU vs sync point race Lucas Stach
@ 2017-10-19 15:19 ` Christian Gmeiner
  0 siblings, 0 replies; 2+ messages in thread
From: Christian Gmeiner @ 2017-10-19 15:19 UTC (permalink / raw)
  To: Lucas Stach
  Cc: The etnaviv authors, DRI mailing list, patchwork-lst,
	Sascha Hauer, Russell King, Chris Healy

2017-10-19 15:10 GMT+02:00 Lucas Stach <l.stach@pengutronix.de>:
> If the FE is restarted before the sync point event is cleared, the GPU
> might trigger a completion IRQ for the next sync point before corrupting
> the state of the currently running worker.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 16 ++++++----------
>  1 file changed, 6 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 93a103eb1083..8ff5d01e776d 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -1484,22 +1484,18 @@ int etnaviv_gpu_submit(struct etnaviv_gpu *gpu,
>         return ret;
>  }
>
> -static void etnaviv_process_sync_point(struct etnaviv_gpu *gpu,
> -       struct etnaviv_event *event)
> -{
> -       u32 addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
> -
> -       event->sync_point(gpu, event);
> -       etnaviv_gpu_start_fe(gpu, addr + 2, 2);
> -}
> -
>  static void sync_point_worker(struct work_struct *work)
>  {
>         struct etnaviv_gpu *gpu = container_of(work, struct etnaviv_gpu,
>                                                sync_point_work);
> +       struct etnaviv_event *event = &gpu->event[gpu->sync_point_event];
> +       u32 addr = gpu_read(gpu, VIVS_FE_DMA_ADDRESS);
>
> -       etnaviv_process_sync_point(gpu, &gpu->event[gpu->sync_point_event]);
> +       event->sync_point(gpu, event);
>         event_free(gpu, gpu->sync_point_event);
> +
> +       /* restart FE last to avoid GPU and IRQ racing against this worker */
> +       etnaviv_gpu_start_fe(gpu, addr + 2, 2);
>  }
>
>  /*
> --
> 2.11.0
>


greets
--
Christian Gmeiner, MSc

https://christian-gmeiner.info
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2017-10-19 15:19 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-10-19 13:10 [PATCH] drm/etnaviv: fix GPU vs sync point race Lucas Stach
2017-10-19 15:19 ` Christian Gmeiner

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.