DriverDev-Devel Archive on lore.kernel.org
 help / color / Atom feed
* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
       [not found] ` <576df522-f012-9dd1-9dcc-b7e444e82ac6@gmx.net>
@ 2019-10-28 15:21   ` Davidlohr Bueso
  2019-10-28 15:37     ` Greg KH
  0 siblings, 1 reply; 10+ messages in thread
From: Davidlohr Bueso @ 2019-10-28 15:21 UTC (permalink / raw)
  To: Stefan Wahren; +Cc: devel, eric, linux-kernel, gregkh

On Mon, 28 Oct 2019, Stefan Wahren wrote:

>Hi Davidlohr,
>
>Am 27.10.19 um 23:15 schrieb Davidlohr Bueso:
>> There seems no need to be using a semaphore, or a sleeping lock
>> in the first place: critical region is extremely short, does not
>> call into any blocking calls and furthermore lock and unlocking
>> operations occur in the same context.
>>
>> Get rid of another semaphore user by replacing it with a spinlock.
>>
>> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
>> ---
>> This is in an effort to further reduce semaphore users in the kernel.
>>
>thanks for this. Could please also send this to devel@driverdev.osuosl.org?

Ccing.

>
>I only need to know, has this been tested on the Raspberry Pi?

No testing has been done, I have no hardware to test this.

Thanks,
Davidlohr
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 15:21   ` [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock Davidlohr Bueso
@ 2019-10-28 15:37     ` Greg KH
  0 siblings, 0 replies; 10+ messages in thread
From: Greg KH @ 2019-10-28 15:37 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: devel, eric, Stefan Wahren, linux-kernel

On Mon, Oct 28, 2019 at 08:21:08AM -0700, Davidlohr Bueso wrote:
> On Mon, 28 Oct 2019, Stefan Wahren wrote:
> 
> > Hi Davidlohr,
> > 
> > Am 27.10.19 um 23:15 schrieb Davidlohr Bueso:
> > > There seems no need to be using a semaphore, or a sleeping lock
> > > in the first place: critical region is extremely short, does not
> > > call into any blocking calls and furthermore lock and unlocking
> > > operations occur in the same context.
> > > 
> > > Get rid of another semaphore user by replacing it with a spinlock.
> > > 
> > > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> > > ---
> > > This is in an effort to further reduce semaphore users in the kernel.
> > > 
> > thanks for this. Could please also send this to devel@driverdev.osuosl.org?
> 
> Ccing.

I don't see a patch here :(

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
       [not found] <20191027221530.12080-1-dave@stgolabs.net>
       [not found] ` <576df522-f012-9dd1-9dcc-b7e444e82ac6@gmx.net>
@ 2019-10-28 15:53 ` Davidlohr Bueso
  2019-10-28 16:24   ` Greg KH
  1 sibling, 1 reply; 10+ messages in thread
From: Davidlohr Bueso @ 2019-10-28 15:53 UTC (permalink / raw)
  To: eric, wahrenst; +Cc: devel, gregkh, linux-kernel

Cc devel@driverdev.osuosl.org

On Sun, 27 Oct 2019, Bueso wrote:

>There seems no need to be using a semaphore, or a sleeping lock
>in the first place: critical region is extremely short, does not
>call into any blocking calls and furthermore lock and unlocking
>operations occur in the same context.
>
>Get rid of another semaphore user by replacing it with a spinlock.
>
>Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
>---
>This is in an effort to further reduce semaphore users in the kernel.
>
> .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
>diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>index 8dc730cfe7a6..710d21654128 100644
>--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
>@@ -63,7 +63,7 @@ static char *g_free_fragments;
> static struct semaphore g_free_fragments_sema;
> static struct device *g_dev;
>
>-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
>+static DEFINE_SPINLOCK(g_free_fragments_lock);
>
> static irqreturn_t
> vchiq_doorbell_irq(int irq, void *dev_id);
>@@ -528,11 +528,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
>
> 		WARN_ON(g_free_fragments == NULL);
>
>-		down(&g_free_fragments_mutex);
>+		spin_lock(&g_free_fragments_lock);
> 		fragments = g_free_fragments;
> 		WARN_ON(fragments == NULL);
> 		g_free_fragments = *(char **) g_free_fragments;
>-		up(&g_free_fragments_mutex);
>+		spin_unlock(&g_free_fragments_lock);
> 		pagelist->type = PAGELIST_READ_WITH_FRAGMENTS +
> 			(fragments - g_fragments_base) / g_fragments_size;
> 	}
>@@ -591,10 +591,10 @@ free_pagelist(struct vchiq_pagelist_info *pagelistinfo,
> 			kunmap(pages[num_pages - 1]);
> 		}
>
>-		down(&g_free_fragments_mutex);
>+		spin_lock(&g_free_fragments_lock);
> 		*(char **)fragments = g_free_fragments;
> 		g_free_fragments = fragments;
>-		up(&g_free_fragments_mutex);
>+		spin_unlock(&g_free_fragments_lock);
> 		up(&g_free_fragments_sema);
> 	}
>
>-- 
>2.16.4
>
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 15:53 ` Davidlohr Bueso
@ 2019-10-28 16:24   ` Greg KH
  2019-10-28 16:35     ` Davidlohr Bueso
  0 siblings, 1 reply; 10+ messages in thread
From: Greg KH @ 2019-10-28 16:24 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: devel, eric, wahrenst, linux-kernel

On Mon, Oct 28, 2019 at 08:53:54AM -0700, Davidlohr Bueso wrote:
> Cc devel@driverdev.osuosl.org
> 
> On Sun, 27 Oct 2019, Bueso wrote:
> 
> > There seems no need to be using a semaphore, or a sleeping lock
> > in the first place: critical region is extremely short, does not
> > call into any blocking calls and furthermore lock and unlocking
> > operations occur in the same context.
> > 
> > Get rid of another semaphore user by replacing it with a spinlock.
> > 
> > Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> > ---
> > This is in an effort to further reduce semaphore users in the kernel.
> > 
> > .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
> > 1 file changed, 5 insertions(+), 5 deletions(-)
> > 
> > diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > index 8dc730cfe7a6..710d21654128 100644
> > --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> > @@ -63,7 +63,7 @@ static char *g_free_fragments;
> > static struct semaphore g_free_fragments_sema;
> > static struct device *g_dev;
> > 
> > -static DEFINE_SEMAPHORE(g_free_fragments_mutex);
> > +static DEFINE_SPINLOCK(g_free_fragments_lock);
> > 
> > static irqreturn_t
> > vchiq_doorbell_irq(int irq, void *dev_id);
> > @@ -528,11 +528,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
> > 
> > 		WARN_ON(g_free_fragments == NULL);
> > 
> > -		down(&g_free_fragments_mutex);
> > +		spin_lock(&g_free_fragments_lock);
> > 		fragments = g_free_fragments;
> > 		WARN_ON(fragments == NULL);
> > 		g_free_fragments = *(char **) g_free_fragments;
> > -		up(&g_free_fragments_mutex);
> > +		spin_unlock(&g_free_fragments_lock);
> > 		pagelist->type = PAGELIST_READ_WITH_FRAGMENTS +
> > 			(fragments - g_fragments_base) / g_fragments_size;
> > 	}
> > @@ -591,10 +591,10 @@ free_pagelist(struct vchiq_pagelist_info *pagelistinfo,
> > 			kunmap(pages[num_pages - 1]);
> > 		}
> > 
> > -		down(&g_free_fragments_mutex);
> > +		spin_lock(&g_free_fragments_lock);
> > 		*(char **)fragments = g_free_fragments;
> > 		g_free_fragments = fragments;
> > -		up(&g_free_fragments_mutex);
> > +		spin_unlock(&g_free_fragments_lock);
> > 		up(&g_free_fragments_sema);
> > 	}
> > 
> > -- 
> > 2.16.4
> > 

This is obviously not in a format I can apply it in :(
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 16:24   ` Greg KH
@ 2019-10-28 16:35     ` Davidlohr Bueso
  2019-10-28 16:59       ` Greg KH
  2019-10-28 19:08       ` [PATCH] " Dan Carpenter
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2019-10-28 16:35 UTC (permalink / raw)
  To: Greg KH; +Cc: devel, eric, wahrenst, linux-kernel

On Mon, 28 Oct 2019, Greg KH wrote:
>This is obviously not in a format I can apply it in :(

What are you talking about? I sent you the original patch,
then Cc'ed the drivers mailing list. So you still have a
patch you can apply... this is quite a common way of doing
things (Ccing for future references to someone or another
ml). I don't understand why you are hairsplitting over this
patch.

Thanks,
Davidlohr
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 16:35     ` Davidlohr Bueso
@ 2019-10-28 16:59       ` Greg KH
  2019-11-01 18:29         ` [PATCH resend] " Davidlohr Bueso
  2019-10-28 19:08       ` [PATCH] " Dan Carpenter
  1 sibling, 1 reply; 10+ messages in thread
From: Greg KH @ 2019-10-28 16:59 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: devel, eric, wahrenst, linux-kernel

On Mon, Oct 28, 2019 at 09:35:37AM -0700, Davidlohr Bueso wrote:
> On Mon, 28 Oct 2019, Greg KH wrote:
> > This is obviously not in a format I can apply it in :(
> 
> What are you talking about? I sent you the original patch,
> then Cc'ed the drivers mailing list. So you still have a
> patch you can apply... this is quite a common way of doing
> things (Ccing for future references to someone or another
> ml). I don't understand why you are hairsplitting over this
> patch.

I don't understand what is going on at all.  Is this patch already
applied?  If not, then yes, I need it in a format I can apply it in.  If
it's already applied to my tree/branch, then there's no need to send it
at all.

totally confused,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 16:35     ` Davidlohr Bueso
  2019-10-28 16:59       ` Greg KH
@ 2019-10-28 19:08       ` " Dan Carpenter
  1 sibling, 0 replies; 10+ messages in thread
From: Dan Carpenter @ 2019-10-28 19:08 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: devel, Greg KH, wahrenst, linux-kernel, eric

On Mon, Oct 28, 2019 at 09:35:37AM -0700, Davidlohr Bueso wrote:
> On Mon, 28 Oct 2019, Greg KH wrote:
> > This is obviously not in a format I can apply it in :(
> 
> What are you talking about? I sent you the original patch,
> then Cc'ed the drivers mailing list.  So you still have a
> patch you can apply... this is quite a common way of doing
> things (Ccing for future references to someone or another
> ml). I don't understand why you are hairsplitting over this
> patch.
> 

I don't have the original patch either.  Only the corrupted one...  Maybe
you did it as html and it was rejected?

regards,
dan carpenter

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* [PATCH resend] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-10-28 16:59       ` Greg KH
@ 2019-11-01 18:29         ` " Davidlohr Bueso
  2019-11-02 10:33           ` Stefan Wahren
  2019-11-02 10:35           ` Greg KH
  0 siblings, 2 replies; 10+ messages in thread
From: Davidlohr Bueso @ 2019-11-01 18:29 UTC (permalink / raw)
  To: eric, wahrenst; +Cc: devel, gregkh, dave, linux-kernel

There is no need to be using a semaphore, or a sleeping lock
in the first place: critical region is extremely short, does not
call into any blocking calls and furthermore lock and unlocking
operations occur in the same context.

Get rid of another semaphore user by replacing it with a spinlock.

Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
---
This is in an effort to further reduce semaphore users in the kernel.

This is a resend, which just seems simpler given the confusions.

 .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
index 8dc730cfe7a6..710d21654128 100644
--- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
+++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
@@ -63,7 +63,7 @@ static char *g_free_fragments;
 static struct semaphore g_free_fragments_sema;
 static struct device *g_dev;
 
-static DEFINE_SEMAPHORE(g_free_fragments_mutex);
+static DEFINE_SPINLOCK(g_free_fragments_lock);
 
 static irqreturn_t
 vchiq_doorbell_irq(int irq, void *dev_id);
@@ -528,11 +528,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
 
 		WARN_ON(g_free_fragments == NULL);
 
-		down(&g_free_fragments_mutex);
+		spin_lock(&g_free_fragments_lock);
 		fragments = g_free_fragments;
 		WARN_ON(fragments == NULL);
 		g_free_fragments = *(char **) g_free_fragments;
-		up(&g_free_fragments_mutex);
+		spin_unlock(&g_free_fragments_lock);
 		pagelist->type = PAGELIST_READ_WITH_FRAGMENTS +
 			(fragments - g_fragments_base) / g_fragments_size;
 	}
@@ -591,10 +591,10 @@ free_pagelist(struct vchiq_pagelist_info *pagelistinfo,
 			kunmap(pages[num_pages - 1]);
 		}
 
-		down(&g_free_fragments_mutex);
+		spin_lock(&g_free_fragments_lock);
 		*(char **)fragments = g_free_fragments;
 		g_free_fragments = fragments;
-		up(&g_free_fragments_mutex);
+		spin_unlock(&g_free_fragments_lock);
 		up(&g_free_fragments_sema);
 	}
 
-- 
2.16.4

_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH resend] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-11-01 18:29         ` [PATCH resend] " Davidlohr Bueso
@ 2019-11-02 10:33           ` Stefan Wahren
  2019-11-02 10:35           ` Greg KH
  1 sibling, 0 replies; 10+ messages in thread
From: Stefan Wahren @ 2019-11-02 10:33 UTC (permalink / raw)
  To: Davidlohr Bueso, eric; +Cc: devel, gregkh, linux-kernel

Hi Davidlohr,

Am 01.11.19 um 19:29 schrieb Davidlohr Bueso:
> There is no need to be using a semaphore, or a sleeping lock
> in the first place: critical region is extremely short, does not
> call into any blocking calls and furthermore lock and unlocking
> operations occur in the same context.
>
> Get rid of another semaphore user by replacing it with a spinlock.
>
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
> This is in an effort to further reduce semaphore users in the kernel.
>
> This is a resend, which just seems simpler given the confusions.
>
>  .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> index 8dc730cfe7a6..710d21654128 100644
> --- a/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> +++ b/drivers/staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c
> @@ -63,7 +63,7 @@ static char *g_free_fragments;
>  static struct semaphore g_free_fragments_sema;
>  static struct device *g_dev;
>
> -static DEFINE_SEMAPHORE(g_free_fragments_mutex);
> +static DEFINE_SPINLOCK(g_free_fragments_lock);
>
>  static irqreturn_t
>  vchiq_doorbell_irq(int irq, void *dev_id);
> @@ -528,11 +528,11 @@ create_pagelist(char __user *buf, size_t count, unsigned short type)
>
>  		WARN_ON(g_free_fragments == NULL);
>
> -		down(&g_free_fragments_mutex);
> +		spin_lock(&g_free_fragments_lock);
>  		fragments = g_free_fragments;
>  		WARN_ON(fragments == NULL);
>  		g_free_fragments = *(char **) g_free_fragments;
> -		up(&g_free_fragments_mutex);
> +		spin_unlock(&g_free_fragments_lock);
>

the reason why Greg cannot apply this patch is that you are using an old
or the wrong git tree.

Please make sure you use the following one (or a mirror):

https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/staging.git

and operate on the branch staging-next

Please fix this up and send a new version.

Regards
Stefan


_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

* Re: [PATCH resend] staging: vc04_services: replace g_free_fragments_mutex with spinlock
  2019-11-01 18:29         ` [PATCH resend] " Davidlohr Bueso
  2019-11-02 10:33           ` Stefan Wahren
@ 2019-11-02 10:35           ` Greg KH
  1 sibling, 0 replies; 10+ messages in thread
From: Greg KH @ 2019-11-02 10:35 UTC (permalink / raw)
  To: Davidlohr Bueso; +Cc: devel, eric, wahrenst, linux-kernel

On Fri, Nov 01, 2019 at 11:29:49AM -0700, Davidlohr Bueso wrote:
> There is no need to be using a semaphore, or a sleeping lock
> in the first place: critical region is extremely short, does not
> call into any blocking calls and furthermore lock and unlocking
> operations occur in the same context.
> 
> Get rid of another semaphore user by replacing it with a spinlock.
> 
> Signed-off-by: Davidlohr Bueso <dave@stgolabs.net>
> ---
> This is in an effort to further reduce semaphore users in the kernel.
> 
> This is a resend, which just seems simpler given the confusions.
> 
>  .../staging/vc04_services/interface/vchiq_arm/vchiq_2835_arm.c | 10 +++++-----
>  1 file changed, 5 insertions(+), 5 deletions(-)

This patch does not apply to my tree at all, what did you make it
against?

Please fix up and resend.

thanks,

greg k-h
_______________________________________________
devel mailing list
devel@linuxdriverproject.org
http://driverdev.linuxdriverproject.org/mailman/listinfo/driverdev-devel

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

end of thread, back to index

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <20191027221530.12080-1-dave@stgolabs.net>
     [not found] ` <576df522-f012-9dd1-9dcc-b7e444e82ac6@gmx.net>
2019-10-28 15:21   ` [PATCH] staging: vc04_services: replace g_free_fragments_mutex with spinlock Davidlohr Bueso
2019-10-28 15:37     ` Greg KH
2019-10-28 15:53 ` Davidlohr Bueso
2019-10-28 16:24   ` Greg KH
2019-10-28 16:35     ` Davidlohr Bueso
2019-10-28 16:59       ` Greg KH
2019-11-01 18:29         ` [PATCH resend] " Davidlohr Bueso
2019-11-02 10:33           ` Stefan Wahren
2019-11-02 10:35           ` Greg KH
2019-10-28 19:08       ` [PATCH] " Dan Carpenter

DriverDev-Devel Archive on lore.kernel.org

Archives are clonable:
	git clone --mirror https://lore.kernel.org/driverdev-devel/0 driverdev-devel/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 driverdev-devel driverdev-devel/ https://lore.kernel.org/driverdev-devel \
		driverdev-devel@linuxdriverproject.org devel@driverdev.osuosl.org
	public-inbox-index driverdev-devel

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://nntp.lore.kernel.org/org.linuxdriverproject.driverdev-devel


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git