* [PATCH] Fix PCI resource mmaping on sparc64
[not found] <eed7af970810310513h6c466ce5h7ada2013ab4053b1@mail.gmail.com>
@ 2008-10-31 13:09 ` Max Dmitrichenko
2008-10-31 19:02 ` David Miller
0 siblings, 1 reply; 2+ messages in thread
From: Max Dmitrichenko @ 2008-10-31 13:09 UTC (permalink / raw)
To: linux-kernel
[-- Attachment #1: Type: text/plain, Size: 919 bytes --]
There is a problem discovered in recent versions of ATI Mach64 driver
in X.org on sparc64 architecture. In short, the driver fails to mmap
MMIO aperture (PCI resource #2).
I've found that kernel's __pci_mmap_make_offset() returns EINVAL. It
checks whether user attempts to mmap more than the resource length,
which is 0x1000 bytes in our case. But PAGE_SIZE on SPARC64 is 0x2000
and this is what actually is being mmaped. So __pci_mmap_make_offset()
failed for this PCI resource.
Signed-off-by: Max Dmitrichenko <dmitrmax@gmail.com>
Code seems to be rather old. At least it was the same in 2.6.24. I
have no explanation why this bug exposed only now. May be before X.org
used to use some other method to mmap PCI resource into userspace (now
it uses libpciaccess).
The patch is against 2.6.26. Greg, please consider to include it into
the stable trees.
Please put me in CC if you're replying this message.
--
Max
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: sparc64-pci-mmap-fix.patch --]
[-- Type: text/x-diff; name=sparc64-pci-mmap-fix.patch, Size: 1075 bytes --]
diff -uprN linux-source-2.6.26/arch/sparc64/kernel/pci.c linux-source-2.6.26.pci-fixed/arch/sparc64/kernel/pci.c
--- linux-source-2.6.26/arch/sparc64/kernel/pci.c 2008-07-14 01:51:29.000000000 +0400
+++ linux-source-2.6.26.pci-fixed/arch/sparc64/kernel/pci.c 2008-10-31 01:23:54.000000000 +0300
@@ -1017,6 +1017,7 @@ static int __pci_mmap_make_offset(struct
for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
struct resource *rp = &pdev->resource[i];
+ resource_size_t aligned_end;
/* Active? */
if (!rp->flags)
@@ -1034,8 +1035,15 @@ static int __pci_mmap_make_offset(struct
continue;
}
+ /* Align the resource end to the next page address.
+ * PAGE_SIZE intentionally added instead of (PAGE_SIZE - 1),
+ * because actually we need the address of the next byte
+ * after rp->end.
+ */
+ aligned_end = (rp->end + PAGE_SIZE) & PAGE_MASK;
+
if ((rp->start <= user_paddr) &&
- (user_paddr + user_size) <= (rp->end + 1UL))
+ (user_paddr + user_size) <= aligned_end)
break;
}
^ permalink raw reply [flat|nested] 2+ messages in thread