linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PPC: PCI: Fix pcibios_io_space_offset() so it works for 32-bit ptr/64-bit rsrcs
@ 2012-06-06  3:50 Ben Collins
  2012-06-06  5:15 ` Benjamin Herrenschmidt
                   ` (2 more replies)
  0 siblings, 3 replies; 17+ messages in thread
From: Ben Collins @ 2012-06-06  3:50 UTC (permalink / raw)
  To: linuxppc-dev

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.

Signed-off-by: Ben Collins <bcollins@ubuntu.com>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/powerpc/kernel/pci-common.c |    8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/kernel/pci-common.c =
b/arch/powerpc/kernel/pci-common.c
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, =
int mask)
 	return pci_enable_resources(dev, mask);
 }
=20
+/* Before assuming too much here, take care to realize that we need =
sign
+ * extension from 32-bit pointers to 64-bit resource addresses to work.
+ */
 resource_size_t pcibios_io_space_offset(struct pci_controller *hose)
 {
-	return (unsigned long) hose->io_base_virt - _IO_BASE;
+	long vbase =3D (long)hose->io_base_virt;
+	long io_base =3D _IO_BASE;
+
+	return (resource_size_t)(vbase - io_base);
 }
=20
 static void __devinit pcibios_setup_phb_resources(struct pci_controller =
*hose, struct list_head *resources)
--=20
1.7.9.5

--
Ben Collins
Servergy, Inc.
(757) 243-7557

CONFIDENTIALITY NOTICE: This communication contains privileged and/or =
confidential information; and should be maintained with the strictest =
confidence. It is intended solely for the use of the person or entity in =
which it is addressed. If you are not the intended recipient, you are =
STRICTLY PROHIBITED from disclosing, copying, distributing or using any =
of this information. If you received this communication in error, please =
contact the sender immediately and destroy the material in its entirety, =
whether electronic or hard copy.

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

end of thread, other threads:[~2012-06-21  2:46 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-06-06  3:50 [PATCH] PPC: PCI: Fix pcibios_io_space_offset() so it works for 32-bit ptr/64-bit rsrcs Ben Collins
2012-06-06  5:15 ` Benjamin Herrenschmidt
2012-06-18 15:23   ` Bjorn Helgaas
2012-06-18 20:39     ` Benjamin Herrenschmidt
2012-06-18 21:04       ` Ben Collins
2012-06-18 22:45         ` Benjamin Herrenschmidt
2012-06-21  0:20       ` Bjorn Helgaas
2012-06-06 21:15 ` Scott Wood
2012-06-06 22:21   ` Benjamin Herrenschmidt
2012-06-07  0:37     ` Scott Wood
2012-06-06 23:35   ` Ben Collins
2012-06-07  9:30     ` Benjamin Herrenschmidt
2012-06-07 15:38       ` Ben Collins
2012-06-07 21:32         ` Benjamin Herrenschmidt
2012-06-08 18:38           ` Ben Collins
2012-06-08 22:48             ` Benjamin Herrenschmidt
2012-06-21  2:46 ` Benjamin Herrenschmidt

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