Thread (17 messages) 17 messages, 5 authors, 2012-06-21

Re: [PATCH] PPC: PCI: Fix pcibios_io_space_offset() so it works for 32-bit ptr/64-bit rsrcs

flat view

From: Bjorn Helgaas <bhelgaas@google.com>
Date: 2012-06-18 15:23:55

On Tue, Jun 5, 2012 at 11:15 PM, Benjamin Herrenschmidt
[off-list ref] wrote:
On Tue, 2012-06-05 at 23:50 -0400, Ben Collins wrote:
quoted
The commit introducing pcibios_io_space_offset() was ignoring 32-bit to
64-bit sign extention, which is the case on ppc32 with 64-bit resource
addresses. This only seems to have shown up while running under QEMU for
e500mc target. It may or may be suboptimal that QEMU has an IO base
address > 32-bits for the e500-pci implementation, but 1) it's still a
regression and 2) it's more correct to handle things this way.
See Bjorn, we both did end up getting it wrong :-)
Ooh, sorry about that.  Who's going to push this fix?  I don't see it
in Linus' tree yet.  If you want me to, please forward me the original
patch.
quoted
Signed-off-by: Ben Collins <redacted>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
Acked-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
quoted
=A0arch/powerpc/kernel/pci-common.c | =A0 =A08 +++++++-
=A01 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/kernel/pci-common.c b/arch/powerpc/kernel/pci-=
common.c
quoted
index 8e78e93..be9ced7 100644
--- a/arch/powerpc/kernel/pci-common.c
+++ b/arch/powerpc/kernel/pci-common.c
@@ -1477,9 +1477,15 @@ int pcibios_enable_device(struct pci_dev *dev, in=
t mask)
quoted
=A0 =A0 =A0 return pci_enable_resources(dev, mask);
=A0}

+/* Before assuming too much here, take care to realize that we need sig=
n
quoted
+ * extension from 32-bit pointers to 64-bit resource addresses to work.
+ */
=A0resource_size_t pcibios_io_space_offset(struct pci_controller *hose)
=A0{
- =A0 =A0 return (unsigned long) hose->io_base_virt - _IO_BASE;
+ =A0 =A0 long vbase =3D (long)hose->io_base_virt;
+ =A0 =A0 long io_base =3D _IO_BASE;
+
+ =A0 =A0 return (resource_size_t)(vbase - io_base);
=A0}

=A0static void __devinit pcibios_setup_phb_resources(struct pci_controll=
er *hose, struct list_head *resources)
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help