Skip to content

Commit

Permalink
sparc64: Fix PCI resource mapping on sparc64
Browse files Browse the repository at this point in the history
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Max Dmitrichenko authored and David S. Miller committed Nov 2, 2008
1 parent a1995a6 commit 5769907
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion arch/sparc64/kernel/pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -889,6 +889,7 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev,

for (i = 0; i <= PCI_ROM_RESOURCE; i++) {
struct resource *rp = &pdev->resource[i];
resource_size_t aligned_end;

/* Active? */
if (!rp->flags)
Expand All @@ -906,8 +907,15 @@ static int __pci_mmap_make_offset(struct pci_dev *pdev,
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;
}

Expand Down

0 comments on commit 5769907

Please sign in to comment.