diff mbox series

[1/3] drm/etnaviv: remove unnecessary local irq disable

Message ID 20181217153644.17046-1-l.stach@pengutronix.de (mailing list archive)
State New, archived
Headers show
Series [1/3] drm/etnaviv: remove unnecessary local irq disable | expand

Commit Message

Lucas Stach Dec. 17, 2018, 3:36 p.m. UTC
The only event function that is called from IRQ context is event_free,
which is already using atomic bitmap operations, so we can avoid taking
the event spinlock in this function completely. As other the other
functions still using the event spinlock are all called from normal
process context, we can avoid disabling IRQs while holding the spinlock.

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

Comments

Christian Gmeiner Dec. 17, 2018, 4:04 p.m. UTC | #1
Am Mo., 17. Dez. 2018 um 16:36 Uhr schrieb Lucas Stach <l.stach@pengutronix.de>:
>
> The only event function that is called from IRQ context is event_free,
> which is already using atomic bitmap operations, so we can avoid taking
> the event spinlock in this function completely. As other the other
> functions still using the event spinlock are all called from normal
> process context, we can avoid disabling IRQs while holding the spinlock.
>
> Signed-off-by: Lucas Stach <l.stach@pengutronix.de>

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

> ---
>  drivers/gpu/drm/etnaviv/etnaviv_gpu.c | 18 +++++-------------
>  1 file changed, 5 insertions(+), 13 deletions(-)
>
> diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> index 8fbe77cae810..293e248e1b29 100644
> --- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> +++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
> @@ -976,7 +976,6 @@ int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
>
>  void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
>  {
> -       unsigned long flags;
>         unsigned int i = 0;
>
>         dev_err(gpu->dev, "recover hung GPU!\n");
> @@ -989,11 +988,11 @@ void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
>         etnaviv_hw_reset(gpu);
>
>         /* complete all events, the GPU won't do it after the reset */
> -       spin_lock_irqsave(&gpu->event_spinlock, flags);
> +       spin_lock(&gpu->event_spinlock);
>         for_each_set_bit_from(i, gpu->event_bitmap, ETNA_NR_EVENTS)
>                 complete(&gpu->event_free);
>         bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
> -       spin_unlock_irqrestore(&gpu->event_spinlock, flags);
> +       spin_unlock(&gpu->event_spinlock);
>
>         etnaviv_gpu_hw_init(gpu);
>         gpu->lastctx = NULL;
> @@ -1083,7 +1082,7 @@ static inline bool fence_after(u32 a, u32 b)
>  static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
>         unsigned int *events)
>  {
> -       unsigned long flags, timeout = msecs_to_jiffies(10 * 10000);
> +       unsigned long timeout = msecs_to_jiffies(10 * 10000);
>         unsigned i, acquired = 0;
>
>         for (i = 0; i < nr_events; i++) {
> @@ -1100,7 +1099,7 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
>                 timeout = ret;
>         }
>
> -       spin_lock_irqsave(&gpu->event_spinlock, flags);
> +       spin_lock(&gpu->event_spinlock);
>
>         for (i = 0; i < nr_events; i++) {
>                 int event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
> @@ -1110,7 +1109,7 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
>                 set_bit(event, gpu->event_bitmap);
>         }
>
> -       spin_unlock_irqrestore(&gpu->event_spinlock, flags);
> +       spin_unlock(&gpu->event_spinlock);
>
>         return 0;
>
> @@ -1123,18 +1122,11 @@ static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
>
>  static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
>  {
> -       unsigned long flags;
> -
> -       spin_lock_irqsave(&gpu->event_spinlock, flags);
> -
>         if (!test_bit(event, gpu->event_bitmap)) {
>                 dev_warn(gpu->dev, "event %u is already marked as free",
>                          event);
> -               spin_unlock_irqrestore(&gpu->event_spinlock, flags);
>         } else {
>                 clear_bit(event, gpu->event_bitmap);
> -               spin_unlock_irqrestore(&gpu->event_spinlock, flags);
> -
>                 complete(&gpu->event_free);
>         }
>  }
> --
> 2.19.1
>
diff mbox series

Patch

diff --git a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
index 8fbe77cae810..293e248e1b29 100644
--- a/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
+++ b/drivers/gpu/drm/etnaviv/etnaviv_gpu.c
@@ -976,7 +976,6 @@  int etnaviv_gpu_debugfs(struct etnaviv_gpu *gpu, struct seq_file *m)
 
 void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
 {
-	unsigned long flags;
 	unsigned int i = 0;
 
 	dev_err(gpu->dev, "recover hung GPU!\n");
@@ -989,11 +988,11 @@  void etnaviv_gpu_recover_hang(struct etnaviv_gpu *gpu)
 	etnaviv_hw_reset(gpu);
 
 	/* complete all events, the GPU won't do it after the reset */
-	spin_lock_irqsave(&gpu->event_spinlock, flags);
+	spin_lock(&gpu->event_spinlock);
 	for_each_set_bit_from(i, gpu->event_bitmap, ETNA_NR_EVENTS)
 		complete(&gpu->event_free);
 	bitmap_zero(gpu->event_bitmap, ETNA_NR_EVENTS);
-	spin_unlock_irqrestore(&gpu->event_spinlock, flags);
+	spin_unlock(&gpu->event_spinlock);
 
 	etnaviv_gpu_hw_init(gpu);
 	gpu->lastctx = NULL;
@@ -1083,7 +1082,7 @@  static inline bool fence_after(u32 a, u32 b)
 static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 	unsigned int *events)
 {
-	unsigned long flags, timeout = msecs_to_jiffies(10 * 10000);
+	unsigned long timeout = msecs_to_jiffies(10 * 10000);
 	unsigned i, acquired = 0;
 
 	for (i = 0; i < nr_events; i++) {
@@ -1100,7 +1099,7 @@  static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 		timeout = ret;
 	}
 
-	spin_lock_irqsave(&gpu->event_spinlock, flags);
+	spin_lock(&gpu->event_spinlock);
 
 	for (i = 0; i < nr_events; i++) {
 		int event = find_first_zero_bit(gpu->event_bitmap, ETNA_NR_EVENTS);
@@ -1110,7 +1109,7 @@  static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 		set_bit(event, gpu->event_bitmap);
 	}
 
-	spin_unlock_irqrestore(&gpu->event_spinlock, flags);
+	spin_unlock(&gpu->event_spinlock);
 
 	return 0;
 
@@ -1123,18 +1122,11 @@  static int event_alloc(struct etnaviv_gpu *gpu, unsigned nr_events,
 
 static void event_free(struct etnaviv_gpu *gpu, unsigned int event)
 {
-	unsigned long flags;
-
-	spin_lock_irqsave(&gpu->event_spinlock, flags);
-
 	if (!test_bit(event, gpu->event_bitmap)) {
 		dev_warn(gpu->dev, "event %u is already marked as free",
 			 event);
-		spin_unlock_irqrestore(&gpu->event_spinlock, flags);
 	} else {
 		clear_bit(event, gpu->event_bitmap);
-		spin_unlock_irqrestore(&gpu->event_spinlock, flags);
-
 		complete(&gpu->event_free);
 	}
 }