linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] host1x: cdma: use completion instead of semaphore
@ 2018-12-10 21:51 Arnd Bergmann
  2018-12-11 10:08 ` Thierry Reding
  2019-02-01 14:16 ` Thierry Reding
  0 siblings, 2 replies; 5+ messages in thread
From: Arnd Bergmann @ 2018-12-10 21:51 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Arnd Bergmann, Mikko Perttunen, Dmitry Osipenko, Emil Goode,
	dri-devel, linux-tegra, linux-kernel

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 <arnd@arndb.de>
---
 drivers/gpu/host1x/cdma.c | 6 +++---
 drivers/gpu/host1x/cdma.h | 4 ++--
 2 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/host1x/cdma.c b/drivers/gpu/host1x/cdma.c
index 6bfb3e6f43d7..bdc80a303cec 100644
--- a/drivers/gpu/host1x/cdma.c
+++ b/drivers/gpu/host1x/cdma.c
@@ -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);
 
diff --git a/drivers/gpu/host1x/cdma.h b/drivers/gpu/host1x/cdma.h
index c628070b94d7..ba790f9bfebc 100644
--- a/drivers/gpu/host1x/cdma.h
+++ b/drivers/gpu/host1x/cdma.h
@@ -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 */
-- 
2.20.0


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

* Re: [PATCH] host1x: cdma: use completion instead of semaphore
  2018-12-10 21:51 [PATCH] host1x: cdma: use completion instead of semaphore Arnd Bergmann
@ 2018-12-11 10:08 ` Thierry Reding
  2018-12-11 10:11   ` Arnd Bergmann
  2019-02-01 14:16 ` Thierry Reding
  1 sibling, 1 reply; 5+ messages in thread
From: Thierry Reding @ 2018-12-11 10:08 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mikko Perttunen, Dmitry Osipenko, Emil Goode, dri-devel,
	linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 638 bytes --]

On Mon, Dec 10, 2018 at 10:51:04PM +0100, Arnd Bergmann wrote:
> 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 <arnd@arndb.de>
> ---
>  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

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] host1x: cdma: use completion instead of semaphore
  2018-12-11 10:08 ` Thierry Reding
@ 2018-12-11 10:11   ` Arnd Bergmann
  2018-12-11 10:27     ` Thierry Reding
  0 siblings, 1 reply; 5+ messages in thread
From: Arnd Bergmann @ 2018-12-11 10:11 UTC (permalink / raw)
  To: Thierry Reding
  Cc: Mikko Perttunen, Dmitry Osipenko, emil.fsw, dri-devel,
	open list:TEGRA ARCHITECTURE SUPPORT, Linux Kernel Mailing List

On Tue, Dec 11, 2018 at 11:08 AM Thierry Reding
<thierry.reding@gmail.com> wrote:
>
> On Mon, Dec 10, 2018 at 10:51:04PM +0100, Arnd Bergmann wrote:
> > 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 <arnd@arndb.de>
> > ---
> >  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?

Yes, it behaves the exact same way here.

       Arnd

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

* Re: [PATCH] host1x: cdma: use completion instead of semaphore
  2018-12-11 10:11   ` Arnd Bergmann
@ 2018-12-11 10:27     ` Thierry Reding
  0 siblings, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2018-12-11 10:27 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mikko Perttunen, Dmitry Osipenko, emil.fsw, dri-devel,
	open list:TEGRA ARCHITECTURE SUPPORT, Linux Kernel Mailing List

[-- Attachment #1: Type: text/plain, Size: 943 bytes --]

On Tue, Dec 11, 2018 at 11:11:38AM +0100, Arnd Bergmann wrote:
> On Tue, Dec 11, 2018 at 11:08 AM Thierry Reding
> <thierry.reding@gmail.com> wrote:
> >
> > On Mon, Dec 10, 2018 at 10:51:04PM +0100, Arnd Bergmann wrote:
> > > 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 <arnd@arndb.de>
> > > ---
> > >  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?
> 
> Yes, it behaves the exact same way here.

Great, I'll queue this for v4.22.

Thanks,
Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

* Re: [PATCH] host1x: cdma: use completion instead of semaphore
  2018-12-10 21:51 [PATCH] host1x: cdma: use completion instead of semaphore Arnd Bergmann
  2018-12-11 10:08 ` Thierry Reding
@ 2019-02-01 14:16 ` Thierry Reding
  1 sibling, 0 replies; 5+ messages in thread
From: Thierry Reding @ 2019-02-01 14:16 UTC (permalink / raw)
  To: Arnd Bergmann
  Cc: Mikko Perttunen, Dmitry Osipenko, Emil Goode, dri-devel,
	linux-tegra, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 453 bytes --]

On Mon, Dec 10, 2018 at 10:51:04PM +0100, Arnd Bergmann wrote:
> 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 <arnd@arndb.de>
> ---
>  drivers/gpu/host1x/cdma.c | 6 +++---
>  drivers/gpu/host1x/cdma.h | 4 ++--
>  2 files changed, 5 insertions(+), 5 deletions(-)

Applied, thanks.

Thierry

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]

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

end of thread, other threads:[~2019-02-01 14:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-12-10 21:51 [PATCH] host1x: cdma: use completion instead of semaphore Arnd Bergmann
2018-12-11 10:08 ` Thierry Reding
2018-12-11 10:11   ` Arnd Bergmann
2018-12-11 10:27     ` Thierry Reding
2019-02-01 14:16 ` Thierry Reding

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).