2006-10-16 15:24:48

by Alan

[permalink] [raw]
Subject: [PATCH] pci: x86-32/64 switch to pci_get API

Use pci_get_bus_and_slot to find the router (and lock it for the kernel
lifetime), also use pci_get_device_reverse() to walk the list finding
calgary IOMMUs

Signed-off-by: Alan Cox <[email protected]>

diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.19-rc1-mm1/arch/i386/pci/irq.c linux-2.6.19-rc1-mm1/arch/i386/pci/irq.c
--- linux.vanilla-2.6.19-rc1-mm1/arch/i386/pci/irq.c 2006-10-13 15:10:06.000000000 +0100
+++ linux-2.6.19-rc1-mm1/arch/i386/pci/irq.c 2006-10-13 17:14:40.000000000 +0100
@@ -758,7 +758,7 @@
DBG(KERN_DEBUG "PCI: Attempting to find IRQ router for %04x:%04x\n",
rt->rtr_vendor, rt->rtr_device);

- pirq_router_dev = pci_find_slot(rt->rtr_bus, rt->rtr_devfn);
+ pirq_router_dev = pci_get_bus_and_slot(rt->rtr_bus, rt->rtr_devfn);
if (!pirq_router_dev) {
DBG(KERN_DEBUG "PCI: Interrupt router not found at "
"%02x:%02x\n", rt->rtr_bus, rt->rtr_devfn);
@@ -778,6 +778,8 @@
pirq_router_dev->vendor,
pirq_router_dev->device,
pci_name(pirq_router_dev));
+
+ /* The device remains referenced for the kernel lifetime */
}

static struct irq_info *pirq_get_info(struct pci_dev *dev)
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c
--- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
+++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
@@ -879,7 +879,7 @@

error:
do {
- dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
+ dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
PCI_DEVICE_ID_IBM_CALGARY,
dev);
if (!dev)


2006-10-16 15:34:44

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

On Mon, Oct 16, 2006 at 04:51:32PM +0100, Alan Cox wrote:
> Use pci_get_bus_and_slot to find the router (and lock it for the kernel
> lifetime), also use pci_get_device_reverse() to walk the list finding
> calgary IOMMUs
>
> Signed-off-by: Alan Cox <[email protected]>
>
> diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c
> --- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
> +++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
> @@ -879,7 +879,7 @@
>
> error:
> do {
> - dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
> + dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
> PCI_DEVICE_ID_IBM_CALGARY,
> dev);
> if (!dev)

Looks good, this part is

Acked-By: Muli Ben-Yehuda <[email protected]>

Cheers,
Muli

2006-10-16 16:08:05

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

> --- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
> +++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
> @@ -879,7 +879,7 @@
>
> error:
> do {
> - dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
> + dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
> PCI_DEVICE_ID_IBM_CALGARY,
> dev);

No put call anywhere?

-Andi

2006-10-16 16:18:32

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

Ar Llu, 2006-10-16 am 18:07 +0200, ysgrifennodd Andi Kleen:
> > --- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
> > +++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
> > @@ -879,7 +879,7 @@
> >
> > error:
> > do {
> > - dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
> > + dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
> > PCI_DEVICE_ID_IBM_CALGARY,
> > dev);
>
> No put call anywhere?

You can't hot unplug your MMU

2006-10-16 16:24:29

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

On Mon, Oct 16, 2006 at 05:45:13PM +0100, Alan Cox wrote:
> Ar Llu, 2006-10-16 am 18:07 +0200, ysgrifennodd Andi Kleen:
> > > --- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
> > > +++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
> > > @@ -879,7 +879,7 @@
> > >
> > > error:
> > > do {
> > > - dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
> > > + dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
> > > PCI_DEVICE_ID_IBM_CALGARY,
> > > dev);
> >
> > No put call anywhere?
>
> You can't hot unplug your MMU

Not sure about that. Calgary is afaik in the bridges and since Summit
has pluggable PCI cages and nodes i would assume the MMU instances are also
hot pluggables.

-Andi

2006-10-16 16:38:54

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

Ar Llu, 2006-10-16 am 18:24 +0200, ysgrifennodd Andi Kleen:
> > You can't hot unplug your MMU
>
> Not sure about that. Calgary is afaik in the bridges and since Summit
> has pluggable PCI cages and nodes i would assume the MMU instances are also
> hot pluggables.

If so Linux doesn't currently support that and the patch keeps things as
they are except for using hotplug safe APIs (and since I want to
exterminate pci_find_device* shortly thats preferable)

Alan

2006-10-16 17:23:45

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

On Mon, Oct 16, 2006 at 06:07:59PM +0200, Andi Kleen wrote:
> > --- linux.vanilla-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 15:10:06.000000000 +0100
> > +++ linux-2.6.19-rc1-mm1/arch/x86_64/kernel/pci-calgary.c 2006-10-13 17:14:40.000000000 +0100
> > @@ -879,7 +879,7 @@
> >
> > error:
> > do {
> > - dev = pci_find_device_reverse(PCI_VENDOR_ID_IBM,
> > + dev = pci_get_device_reverse(PCI_VENDOR_ID_IBM,
> > PCI_DEVICE_ID_IBM_CALGARY,
> > dev);
>
> No put call anywhere?

The put is implicit in the call, since for each dev returned from
pci_get_device_reverse() we then call it with the same dev as the last
('from') parameter. We take a reference to dev elsewhere, just before
we start using it.

In any case these bridges can't be hot-plugged, so as long as the ref
count remains positive, we're fine.

Cheers,
Muli

2006-10-16 19:01:23

by Andi Kleen

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

On Mon, Oct 16, 2006 at 06:05:40PM +0100, Alan Cox wrote:
> Ar Llu, 2006-10-16 am 18:24 +0200, ysgrifennodd Andi Kleen:
> > > You can't hot unplug your MMU
> >
> > Not sure about that. Calgary is afaik in the bridges and since Summit
> > has pluggable PCI cages and nodes i would assume the MMU instances are also
> > hot pluggables.
>
> If so Linux doesn't currently support that and the patch keeps things as
> they are except for using hotplug safe APIs (and since I want to
> exterminate pci_find_device* shortly thats preferable)
>

Ok i applied the patch to -rc2, but it results in

arch/x86_64/pci/built-in.o: In function `pcibios_irq_init':
irq.c:(.init.text+0xc7e): undefined reference to `pci_get_bus_and_slot'

That function is also nowhere to be found:

% gid pci_get_bus_and_slot
%

So dropped again.

-Andi

2006-10-16 20:52:06

by Alan

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

Ar Llu, 2006-10-16 am 21:01 +0200, ysgrifennodd Andi Kleen:
> Ok i applied the patch to -rc2, but it results in
>
> arch/x86_64/pci/built-in.o: In function `pcibios_irq_init':
> irq.c:(.init.text+0xc7e): undefined reference to `pci_get_bus_and_slot'
>
> That function is also nowhere to be found:

I was just cc'ing you on a set of patches for -mm which included this
one and the other neccessary PCI changes. Sorry for any confusion.

2006-10-16 20:52:40

by Muli Ben-Yehuda

[permalink] [raw]
Subject: Re: [PATCH] pci: x86-32/64 switch to pci_get API

On Mon, Oct 16, 2006 at 09:01:15PM +0200, Andi Kleen wrote:
> On Mon, Oct 16, 2006 at 06:05:40PM +0100, Alan Cox wrote:
> > Ar Llu, 2006-10-16 am 18:24 +0200, ysgrifennodd Andi Kleen:
> > > > You can't hot unplug your MMU
> > >
> > > Not sure about that. Calgary is afaik in the bridges and since Summit
> > > has pluggable PCI cages and nodes i would assume the MMU instances are also
> > > hot pluggables.
> >
> > If so Linux doesn't currently support that and the patch keeps things as
> > they are except for using hotplug safe APIs (and since I want to
> > exterminate pci_find_device* shortly thats preferable)
> >
>
> Ok i applied the patch to -rc2, but it results in
>
> arch/x86_64/pci/built-in.o: In function `pcibios_irq_init':
> irq.c:(.init.text+0xc7e): undefined reference to `pci_get_bus_and_slot'
>
> That function is also nowhere to be found:
>
> % gid pci_get_bus_and_slot
> %
>
> So dropped again.

Alain submitted the patch to add that function roughly at the same
time. See
http://marc.theaimsgroup.com/?l=linux-kernel&m=116101265428620&w=2

Cheers,
Muli