linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
@ 2012-03-02 19:45 Myron Stowe
  2012-03-02 20:00 ` Greg KH
  2012-03-02 20:04 ` Jesse Barnes
  0 siblings, 2 replies; 7+ messages in thread
From: Myron Stowe @ 2012-03-02 19:45 UTC (permalink / raw)
  To: jbarnes; +Cc: linux-pci, linux-kernel

'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
values for reinstatement when normal resource assignment attempts
fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
held.

This patch adds a WARN_ON notification if the spinlock is not currently
held by the caller.

Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
---

 arch/x86/pci/i386.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
index 33e6a0b..831971e 100644
--- a/arch/x86/pci/i386.c
+++ b/arch/x86/pci/i386.c
@@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
 {
 	struct pcibios_fwaddrmap *map;
 
+	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
+
 	list_for_each_entry(map, &pcibios_fwaddrmappings, list)
 		if (map->dev == dev)
 			return map;


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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 19:45 [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()' Myron Stowe
@ 2012-03-02 20:00 ` Greg KH
  2012-03-02 20:18   ` Myron Stowe
  2012-03-02 20:24   ` Jesse Barnes
  2012-03-02 20:04 ` Jesse Barnes
  1 sibling, 2 replies; 7+ messages in thread
From: Greg KH @ 2012-03-02 20:00 UTC (permalink / raw)
  To: Myron Stowe; +Cc: jbarnes, linux-pci, linux-kernel

On Fri, Mar 02, 2012 at 12:45:01PM -0700, Myron Stowe wrote:
> 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> values for reinstatement when normal resource assignment attempts
> fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> held.
> 
> This patch adds a WARN_ON notification if the spinlock is not currently
> held by the caller.
> 
> Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> ---
> 
>  arch/x86/pci/i386.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> index 33e6a0b..831971e 100644
> --- a/arch/x86/pci/i386.c
> +++ b/arch/x86/pci/i386.c
> @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
>  {
>  	struct pcibios_fwaddrmap *map;
>  
> +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> +

What is this going to help with?  How can someone then recover from this
issue?  Just adding a warning message isn't going to fix any problems
here, why not fix the root cause?

thanks,

greg k-h

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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 19:45 [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()' Myron Stowe
  2012-03-02 20:00 ` Greg KH
@ 2012-03-02 20:04 ` Jesse Barnes
  1 sibling, 0 replies; 7+ messages in thread
From: Jesse Barnes @ 2012-03-02 20:04 UTC (permalink / raw)
  To: Myron Stowe; +Cc: linux-pci, linux-kernel

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

On Fri, 02 Mar 2012 12:45:01 -0700
Myron Stowe <myron.stowe@redhat.com> wrote:

> 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> values for reinstatement when normal resource assignment attempts
> fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> held.
> 
> This patch adds a WARN_ON notification if the spinlock is not currently
> held by the caller.
> 
> Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> ---
> 
>  arch/x86/pci/i386.c |    2 ++
>  1 files changed, 2 insertions(+), 0 deletions(-)
> 
> diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> index 33e6a0b..831971e 100644
> --- a/arch/x86/pci/i386.c
> +++ b/arch/x86/pci/i386.c
> @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
>  {
>  	struct pcibios_fwaddrmap *map;
>  
> +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> +
>  	list_for_each_entry(map, &pcibios_fwaddrmappings, list)
>  		if (map->dev == dev)
>  			return map;
> 
> 

Applied, thanks.

-- 
Jesse Barnes, Intel Open Source Technology Center

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

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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 20:00 ` Greg KH
@ 2012-03-02 20:18   ` Myron Stowe
  2012-03-02 20:24   ` Jesse Barnes
  1 sibling, 0 replies; 7+ messages in thread
From: Myron Stowe @ 2012-03-02 20:18 UTC (permalink / raw)
  To: Greg KH; +Cc: Myron Stowe, jbarnes, linux-pci, linux-kernel

On Fri, 2012-03-02 at 12:00 -0800, Greg KH wrote:
> On Fri, Mar 02, 2012 at 12:45:01PM -0700, Myron Stowe wrote:
> > 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> > values for reinstatement when normal resource assignment attempts
> > fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> > held.
> > 
> > This patch adds a WARN_ON notification if the spinlock is not currently
> > held by the caller.
> > 
> > Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> > ---
> > 
> >  arch/x86/pci/i386.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> > index 33e6a0b..831971e 100644
> > --- a/arch/x86/pci/i386.c
> > +++ b/arch/x86/pci/i386.c
> > @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
> >  {
> >  	struct pcibios_fwaddrmap *map;
> >  
> > +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> > +
> 
> What is this going to help with?  How can someone then recover from this
> issue?  Just adding a warning message isn't going to fix any problems
> here, why not fix the root cause?

Greg:

We have not seen any issues.  Jesse just asked me to consider adding
such as a sanity check (I believe he said something to the effect: "I
had to read the code a couple of times to assure myself that the lock
was held" - but I should let Jesse comment himself).

Myron
> 
> thanks,
> 
> greg k-h



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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 20:00 ` Greg KH
  2012-03-02 20:18   ` Myron Stowe
@ 2012-03-02 20:24   ` Jesse Barnes
  2012-03-02 20:41     ` Greg KH
  1 sibling, 1 reply; 7+ messages in thread
From: Jesse Barnes @ 2012-03-02 20:24 UTC (permalink / raw)
  To: Greg KH; +Cc: Myron Stowe, linux-pci, linux-kernel

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

On Fri, 2 Mar 2012 12:00:27 -0800
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Fri, Mar 02, 2012 at 12:45:01PM -0700, Myron Stowe wrote:
> > 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> > values for reinstatement when normal resource assignment attempts
> > fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> > held.
> > 
> > This patch adds a WARN_ON notification if the spinlock is not currently
> > held by the caller.
> > 
> > Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> > ---
> > 
> >  arch/x86/pci/i386.c |    2 ++
> >  1 files changed, 2 insertions(+), 0 deletions(-)
> > 
> > diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> > index 33e6a0b..831971e 100644
> > --- a/arch/x86/pci/i386.c
> > +++ b/arch/x86/pci/i386.c
> > @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
> >  {
> >  	struct pcibios_fwaddrmap *map;
> >  
> > +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> > +
> 
> What is this going to help with?  How can someone then recover from this
> issue?  Just adding a warning message isn't going to fix any problems
> here, why not fix the root cause?

It's just a self-documenting assert; doesn't trigger anything and has
more functionality than
  /* Must hold the fwaddrmap_lock here */


-- 
Jesse Barnes, Intel Open Source Technology Center

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

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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 20:24   ` Jesse Barnes
@ 2012-03-02 20:41     ` Greg KH
  2012-03-02 21:09       ` Jesse Barnes
  0 siblings, 1 reply; 7+ messages in thread
From: Greg KH @ 2012-03-02 20:41 UTC (permalink / raw)
  To: Jesse Barnes; +Cc: Myron Stowe, linux-pci, linux-kernel

On Fri, Mar 02, 2012 at 12:24:05PM -0800, Jesse Barnes wrote:
> On Fri, 2 Mar 2012 12:00:27 -0800
> Greg KH <gregkh@linuxfoundation.org> wrote:
> 
> > On Fri, Mar 02, 2012 at 12:45:01PM -0700, Myron Stowe wrote:
> > > 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> > > values for reinstatement when normal resource assignment attempts
> > > fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> > > held.
> > > 
> > > This patch adds a WARN_ON notification if the spinlock is not currently
> > > held by the caller.
> > > 
> > > Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> > > ---
> > > 
> > >  arch/x86/pci/i386.c |    2 ++
> > >  1 files changed, 2 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> > > index 33e6a0b..831971e 100644
> > > --- a/arch/x86/pci/i386.c
> > > +++ b/arch/x86/pci/i386.c
> > > @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
> > >  {
> > >  	struct pcibios_fwaddrmap *map;
> > >  
> > > +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> > > +
> > 
> > What is this going to help with?  How can someone then recover from this
> > issue?  Just adding a warning message isn't going to fix any problems
> > here, why not fix the root cause?
> 
> It's just a self-documenting assert; doesn't trigger anything and has
> more functionality than
>   /* Must hold the fwaddrmap_lock here */

Don't we have sparse markups that we can use to verify this instead
somehow?  Adding asserts isn't the nicest, as what will a user really do
about this if it ever gets hit?  And if a user isn't supposed to do
anything, then yes, a comment would be best I would think.

But I didn't realize you had asked for this, so no big deal, I'll go
back to lurking :)

greg k-h

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

* Re: [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()'
  2012-03-02 20:41     ` Greg KH
@ 2012-03-02 21:09       ` Jesse Barnes
  0 siblings, 0 replies; 7+ messages in thread
From: Jesse Barnes @ 2012-03-02 21:09 UTC (permalink / raw)
  To: Greg KH; +Cc: Myron Stowe, linux-pci, linux-kernel

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

On Fri, 2 Mar 2012 12:41:36 -0800
Greg KH <gregkh@linuxfoundation.org> wrote:

> On Fri, Mar 02, 2012 at 12:24:05PM -0800, Jesse Barnes wrote:
> > On Fri, 2 Mar 2012 12:00:27 -0800
> > Greg KH <gregkh@linuxfoundation.org> wrote:
> > 
> > > On Fri, Mar 02, 2012 at 12:45:01PM -0700, Myron Stowe wrote:
> > > > 'pcibios_fwaddrmap_lookup()' is used to maintain FW-assigned BIOS BAR
> > > > values for reinstatement when normal resource assignment attempts
> > > > fail and must be called with the 'pcibios_fwaddrmap_lock' spinlock
> > > > held.
> > > > 
> > > > This patch adds a WARN_ON notification if the spinlock is not currently
> > > > held by the caller.
> > > > 
> > > > Signed-off-by: Myron Stowe <myron.stowe@redhat.com>
> > > > ---
> > > > 
> > > >  arch/x86/pci/i386.c |    2 ++
> > > >  1 files changed, 2 insertions(+), 0 deletions(-)
> > > > 
> > > > diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c
> > > > index 33e6a0b..831971e 100644
> > > > --- a/arch/x86/pci/i386.c
> > > > +++ b/arch/x86/pci/i386.c
> > > > @@ -57,6 +57,8 @@ static struct pcibios_fwaddrmap *pcibios_fwaddrmap_lookup(struct pci_dev *dev)
> > > >  {
> > > >  	struct pcibios_fwaddrmap *map;
> > > >  
> > > > +	WARN_ON(!spin_is_locked(&pcibios_fwaddrmap_lock));
> > > > +
> > > 
> > > What is this going to help with?  How can someone then recover from this
> > > issue?  Just adding a warning message isn't going to fix any problems
> > > here, why not fix the root cause?
> > 
> > It's just a self-documenting assert; doesn't trigger anything and has
> > more functionality than
> >   /* Must hold the fwaddrmap_lock here */
> 
> Don't we have sparse markups that we can use to verify this instead
> somehow?  Adding asserts isn't the nicest, as what will a user really do
> about this if it ever gets hit?  And if a user isn't supposed to do
> anything, then yes, a comment would be best I would think.

The user is supposed to report a bug, but it likely won't cause a
crash, just a worrying message in the log.

And yeah I think we have some sparse bits for this, and at one point I
thought we had an assert_spin_is_locked or somesuch.

I like the idea of self-documenting code checks better than just
comments.  Sparse annotations are a good second solution, but not as
nice since sparse isn't always run, and has a harder time with control
flow dependent stuff like this.

-- 
Jesse Barnes, Intel Open Source Technology Center

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

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

end of thread, other threads:[~2012-03-02 21:09 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-02 19:45 [PATCH] x86/PCI: add spinlock held check to 'pcibios_fwaddrmap_lookup()' Myron Stowe
2012-03-02 20:00 ` Greg KH
2012-03-02 20:18   ` Myron Stowe
2012-03-02 20:24   ` Jesse Barnes
2012-03-02 20:41     ` Greg KH
2012-03-02 21:09       ` Jesse Barnes
2012-03-02 20:04 ` Jesse Barnes

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).