* [PATCH 07/11] parisc: superio: do not use PCI resources before pci_enable_device()
@ 2010-08-03 15:44 Kulikov Vasiliy
2010-08-03 16:11 ` [PATCH 07/11] parisc: superio: do not use PCI resources before James Bottomley
0 siblings, 1 reply; 5+ messages in thread
From: Kulikov Vasiliy @ 2010-08-03 15:44 UTC (permalink / raw)
To: kernel-janitors
Cc: Kyle McMartin, Helge Deller, James E.J. Bottomley, Frans Pop,
Thomas Gleixner, linux-parisc, linux-kernel
IRQ and resource[] may not have correct values until
after PCI hotplug setup occurs at pci_enable_device() time.
The semantic match that finds this problem is as follows:
// <smpl>
@@
identifier x;
identifier request ~= "pci_request.*|pci_resource.*";
@@
(
* x->irq
|
* x->resource
|
* request(x, ...)
)
...
*pci_enable_device(x)
// </smpl>
Signed-off-by: Kulikov Vasiliy <segooon@gmail.com>
---
drivers/parisc/superio.c | 5 +++--
1 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
index f7806d8..c8a36a2 100644
--- a/drivers/parisc/superio.c
+++ b/drivers/parisc/superio.c
@@ -169,8 +169,6 @@ superio_init(struct pci_dev *pcidev)
/* ...then properly fixup the USB to point at suckyio PIC */
sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
- printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
- pci_name(pdev), pdev->irq);
pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
sio->sp1_base &= ~1;
@@ -204,6 +202,9 @@ superio_init(struct pci_dev *pcidev)
ret = pci_enable_device(pdev);
BUG_ON(ret < 0); /* not too much we can do about this... */
+ printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
+ pci_name(pdev), pdev->irq);
+
/*
* Next project is programming the onboard interrupt controllers.
* PDC hasn't done this for us, since it's using polled I/O.
--
1.7.0.4
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH 07/11] parisc: superio: do not use PCI resources before
2010-08-03 15:44 [PATCH 07/11] parisc: superio: do not use PCI resources before pci_enable_device() Kulikov Vasiliy
@ 2010-08-03 16:11 ` James Bottomley
2010-08-03 16:35 ` Vasiliy Kulikov
2010-08-03 16:36 ` Jesse Barnes
0 siblings, 2 replies; 5+ messages in thread
From: James Bottomley @ 2010-08-03 16:11 UTC (permalink / raw)
To: Kulikov Vasiliy
Cc: kernel-janitors, Kyle McMartin, Helge Deller,
James E.J. Bottomley, Frans Pop, Thomas Gleixner, linux-parisc,
linux-kernel
On Tue, 2010-08-03 at 19:44 +0400, Kulikov Vasiliy wrote:
> drivers/parisc/superio.c | 5 +++--
> 1 files changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
> index f7806d8..c8a36a2 100644
> --- a/drivers/parisc/superio.c
> +++ b/drivers/parisc/superio.c
> @@ -169,8 +169,6 @@ superio_init(struct pci_dev *pcidev)
> /* ...then properly fixup the USB to point at suckyio PIC */
> sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
>
> - printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> - pci_name(pdev), pdev->irq);
>
> pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
> sio->sp1_base &= ~1;
> @@ -204,6 +202,9 @@ superio_init(struct pci_dev *pcidev)
> ret = pci_enable_device(pdev);
> BUG_ON(ret < 0); /* not too much we can do about this... */
>
> + printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> + pci_name(pdev), pdev->irq);
> +
> /*
> * Next project is programming the onboard interrupt controllers.
> * PDC hasn't done this for us, since it's using polled I/O.
This really makes no sense; we want the information printed before we
start all the discovery prints, not after. I assume lots of
initialisers want this too, so it looks particularly silly not to have
pci_name() returning the correct value until enable time.
If this is just the name initially assigned may change, this definitely
isn't true for parisc, and even for other things, it would be better to
print something than nothing.
James
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 07/11] parisc: superio: do not use PCI resources before
2010-08-03 16:11 ` [PATCH 07/11] parisc: superio: do not use PCI resources before James Bottomley
@ 2010-08-03 16:35 ` Vasiliy Kulikov
2010-08-03 16:38 ` James Bottomley
2010-08-03 16:36 ` Jesse Barnes
1 sibling, 1 reply; 5+ messages in thread
From: Vasiliy Kulikov @ 2010-08-03 16:35 UTC (permalink / raw)
To: James Bottomley
Cc: kernel-janitors, Kyle McMartin, Helge Deller,
James E.J. Bottomley, Frans Pop, Thomas Gleixner, linux-parisc,
linux-kernel
On Tue, Aug 03, 2010 at 11:11 -0500, James Bottomley wrote:
> On Tue, 2010-08-03 at 19:44 +0400, Kulikov Vasiliy wrote:
> > drivers/parisc/superio.c | 5 +++--
> > 1 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
> > index f7806d8..c8a36a2 100644
> > --- a/drivers/parisc/superio.c
> > +++ b/drivers/parisc/superio.c
> > @@ -169,8 +169,6 @@ superio_init(struct pci_dev *pcidev)
> > /* ...then properly fixup the USB to point at suckyio PIC */
> > sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
> >
> > - printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > - pci_name(pdev), pdev->irq);
> >
> > pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
> > sio->sp1_base &= ~1;
> > @@ -204,6 +202,9 @@ superio_init(struct pci_dev *pcidev)
> > ret = pci_enable_device(pdev);
> > BUG_ON(ret < 0); /* not too much we can do about this... */
> >
> > + printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > + pci_name(pdev), pdev->irq);
> > +
> > /*
> > * Next project is programming the onboard interrupt controllers.
> > * PDC hasn't done this for us, since it's using polled I/O.
>
> This really makes no sense; we want the information printed before we
> start all the discovery prints, not after.
Right, I missed it.
> I assume lots of
> initialisers want this too, so it looks particularly silly not to have
> pci_name() returning the correct value until enable time.
>
> If this is just the name initially assigned may change, this definitely
> isn't true for parisc, and even for other things, it would be better to
> print something than nothing.
Not name, but pdev-irq. I was not searching for pci_name() as you can
see in coccinelle script :)
As it is only printing wrong value, the worst case is fooling user that
reads logs.
Is it OK to move pci_enable_device() just before this printk()?
>
> James
>
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 07/11] parisc: superio: do not use PCI resources before
2010-08-03 16:11 ` [PATCH 07/11] parisc: superio: do not use PCI resources before James Bottomley
2010-08-03 16:35 ` Vasiliy Kulikov
@ 2010-08-03 16:36 ` Jesse Barnes
1 sibling, 0 replies; 5+ messages in thread
From: Jesse Barnes @ 2010-08-03 16:36 UTC (permalink / raw)
To: James Bottomley
Cc: Kulikov Vasiliy, kernel-janitors, Kyle McMartin, Helge Deller,
James E.J. Bottomley, Frans Pop, Thomas Gleixner, linux-parisc,
linux-kernel
On Tue, 03 Aug 2010 11:11:20 -0500
James Bottomley <James.Bottomley@HansenPartnership.com> wrote:
> On Tue, 2010-08-03 at 19:44 +0400, Kulikov Vasiliy wrote:
> > drivers/parisc/superio.c | 5 +++--
> > 1 files changed, 3 insertions(+), 2 deletions(-)
> >
> > diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
> > index f7806d8..c8a36a2 100644
> > --- a/drivers/parisc/superio.c
> > +++ b/drivers/parisc/superio.c
> > @@ -169,8 +169,6 @@ superio_init(struct pci_dev *pcidev)
> > /* ...then properly fixup the USB to point at suckyio PIC */
> > sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
> >
> > - printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > - pci_name(pdev), pdev->irq);
> >
> > pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
> > sio->sp1_base &= ~1;
> > @@ -204,6 +202,9 @@ superio_init(struct pci_dev *pcidev)
> > ret = pci_enable_device(pdev);
> > BUG_ON(ret < 0); /* not too much we can do about this... */
> >
> > + printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > + pci_name(pdev), pdev->irq);
> > +
> > /*
> > * Next project is programming the onboard interrupt controllers.
> > * PDC hasn't done this for us, since it's using polled I/O.
>
> This really makes no sense; we want the information printed before we
> start all the discovery prints, not after. I assume lots of
> initialisers want this too, so it looks particularly silly not to have
> pci_name() returning the correct value until enable time.
>
> If this is just the name initially assigned may change, this definitely
> isn't true for parisc, and even for other things, it would be better to
> print something than nothing.
Right. Some of these "enable before use" patches are ok, for example
in some cases the IRQ may not be fully set up or resources may not be
enabled, so re-ordering things makes sense.
But just printing these values at init time should be harmless. So
perhaps a smarter static check script is in order.
--
Jesse Barnes, Intel Open Source Technology Center
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH 07/11] parisc: superio: do not use PCI resources before
2010-08-03 16:35 ` Vasiliy Kulikov
@ 2010-08-03 16:38 ` James Bottomley
0 siblings, 0 replies; 5+ messages in thread
From: James Bottomley @ 2010-08-03 16:38 UTC (permalink / raw)
To: Vasiliy Kulikov
Cc: kernel-janitors, Kyle McMartin, Helge Deller,
James E.J. Bottomley, Frans Pop, Thomas Gleixner, linux-parisc,
linux-kernel
On Tue, 2010-08-03 at 20:35 +0400, Vasiliy Kulikov wrote:
> On Tue, Aug 03, 2010 at 11:11 -0500, James Bottomley wrote:
> > On Tue, 2010-08-03 at 19:44 +0400, Kulikov Vasiliy wrote:
> > > drivers/parisc/superio.c | 5 +++--
> > > 1 files changed, 3 insertions(+), 2 deletions(-)
> > >
> > > diff --git a/drivers/parisc/superio.c b/drivers/parisc/superio.c
> > > index f7806d8..c8a36a2 100644
> > > --- a/drivers/parisc/superio.c
> > > +++ b/drivers/parisc/superio.c
> > > @@ -169,8 +169,6 @@ superio_init(struct pci_dev *pcidev)
> > > /* ...then properly fixup the USB to point at suckyio PIC */
> > > sio->usb_pdev->irq = superio_fixup_irq(sio->usb_pdev);
> > >
> > > - printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > > - pci_name(pdev), pdev->irq);
> > >
> > > pci_read_config_dword (pdev, SIO_SP1BAR, &sio->sp1_base);
> > > sio->sp1_base &= ~1;
> > > @@ -204,6 +202,9 @@ superio_init(struct pci_dev *pcidev)
> > > ret = pci_enable_device(pdev);
> > > BUG_ON(ret < 0); /* not too much we can do about this... */
> > >
> > > + printk(KERN_INFO PFX "Found NS87560 Legacy I/O device at %s (IRQ %i)\n",
> > > + pci_name(pdev), pdev->irq);
> > > +
> > > /*
> > > * Next project is programming the onboard interrupt controllers.
> > > * PDC hasn't done this for us, since it's using polled I/O.
> >
> > This really makes no sense; we want the information printed before we
> > start all the discovery prints, not after.
>
> Right, I missed it.
>
> > I assume lots of
> > initialisers want this too, so it looks particularly silly not to have
> > pci_name() returning the correct value until enable time.
> >
> > If this is just the name initially assigned may change, this definitely
> > isn't true for parisc, and even for other things, it would be better to
> > print something than nothing.
>
> Not name, but pdev-irq. I was not searching for pci_name() as you can
> see in coccinelle script :)
>
> As it is only printing wrong value, the worst case is fooling user that
> reads logs.
>
>
> Is it OK to move pci_enable_device() just before this printk()?
Not really ... we need the device set up before it gets enabled.
If it's only the irq, then just leave it ... the name is more important
and an uninitialised IRQ returns -1 which is a reasonable signal of not
being set up yet ... but I think you'll find it will be pre setup on all
platforms.
However,
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2010-08-03 16:38 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-08-03 15:44 [PATCH 07/11] parisc: superio: do not use PCI resources before pci_enable_device() Kulikov Vasiliy
2010-08-03 16:11 ` [PATCH 07/11] parisc: superio: do not use PCI resources before James Bottomley
2010-08-03 16:35 ` Vasiliy Kulikov
2010-08-03 16:38 ` James Bottomley
2010-08-03 16:36 ` Jesse Barnes
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox