host1x: cdma: use completion instead of semaphore
PATCH 1/1 host1x: cdma: use completion instead of semaphore
In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days.
--- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
drivers/gpu/host1x/cdma.c +3 -3
@@ -204,7 +204,7 @@ unsigned int host1x_cdma_wait_locked(struct host1x_cdma *cdma, cdma->event = event;mutex_unlock (&cdma->lock); -down (&cdma->sem); +wait_for_completion (&cdma->complete);mutex_lock (&cdma->lock); }
@@ -308,7 +308,7 @@ static void update_cdma_locked(struct host1x_cdma *cdma)if (signal) { cdma->event =CDMA_EVENT_NONE ; -up (&cdma->sem); +complete (&cdma->complete); } }
@@ -410,7 +410,7 @@ int host1x_cdma_init(struct host1x_cdma *cdma)int err;mutex_init (&cdma->lock); -sema_init (&cdma->sem,0 ); +init_completion (&cdma->complete);INIT_LIST_HEAD (&cdma->sync_queue);
drivers/gpu/host1x/cdma.h +2 -2
@@ -20,7 +20,7 @@#define __HOST1X_CDMA_H#include <linux/sched.h> -#include <linux/semaphore.h> +#include <linux/completion.h> #include <linux/list.h> struct host1x_syncpt ;
@@ -70,7 +70,7 @@ enum cdma_event {struct host1x_cdma {struct mutex lock;/* controls access to shared state */ -struct semaphore sem;/* signalled when event occurs */ +struct completion complete;/* signalled when event occurs */ enum cdma_event event;/* event that sem is waiting for */ unsigned int slots_used;/* pb slots used in current submit */ unsigned int slots_free;/* pb slots free in current submit */
Signature · 1 line
2.20.0
Quoted 9 lines · Arnd Bergmann
In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
My understanding is that potentially many userspace processes could be blocking on this, which I think is the reason for it being a semaphore. Is the completion going to work for those cases as well?
Thierry
Quoted 12 lines · Thierry Reding
Quoted 9 lines · Arnd Bergmann
In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Quoted 3 lines
My understanding is that potentially many userspace processes could be blocking on this, which I think is the reason for it being a semaphore. Is the completion going to work for those cases as well?
Yes, it behaves the exact same way here.
Arnd
Quoted 14 lines · Arnd Bergmann
Quoted 12 lines · Thierry Reding
Quoted 9 lines · Arnd Bergmann
In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Quoted 5 lines
Quoted 3 lines
My understanding is that potentially many userspace processes could be blocking on this, which I think is the reason for it being a semaphore. Is the completion going to work for those cases as well?
Yes, it behaves the exact same way here.
Great, I'll queue this for v4.22.
Thanks,
Thierry
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
Thierry Reding
AppliedQuoted 9 lines · Arnd Bergmann
In this usage, the two are completely equivalent, but the completion documents better what is going on, and we generally try to avoid semaphores these days.
Signed-off-by Arnd Bergmann <[email protected]>--- drivers/gpu/host1x/cdma.c | 6 +++--- drivers/gpu/host1x/cdma.h | 4 ++-- 2 files changed, 5 insertions(+), 5 deletions(-)
Applied, thanks.
Thierry