diff options
author | Suresh Siddha <suresh.b.siddha@intel.com> | 2009-10-26 17:21:32 -0400 |
---|---|---|
committer | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-11-04 11:47:22 -0500 |
commit | 2992e545ea006992ec9dc91c4fa996ce1e15f921 (patch) | |
tree | 5e3760376716e96d97e7533c01ffb52c4fb66d31 /arch/x86/pci/i386.c | |
parent | 9a007b3791cdba3601d835ea10e68c14115b9afb (diff) |
x86/PCI/PAT: return EINVAL for pci mmap WC request for !pat_enabled
Thomas Schlichter reported:
> X.org uses libpciaccess which tries to mmap with write combining enabled via
> /sys/bus/pci/devices/*/resource0_wc. Currently, when PAT is not enabled, the
> kernel does fall back to uncached mmap. Then libpciaccess thinks it succeeded
> mapping with write combining enabled and does not set up suited MTRR entries.
> ;-(
Instead of silently mapping pci mmap region as UC minus in the case
of !pat_enabled and wc request, we can return error. Eric Anholt mentioned
that caller (like X) typically follows up with UC minus pci mmap request and
if there is a free mtrr slot, caller will manage adding WC mtrr.
Jesse Barnes says:
> Older versions of libpciaccess will behave better if we do it that way
> (iirc it only allocates an MTRR if the resource_wc file doesn't exist or
> fails to get mapped).
Reported-by: Thomas Schlichter <thomas.schlichter@web.de>
Signed-off-by: Thomas Schlichter <thomas.schlichter@web.de>
Signed-off-by: Suresh Siddha <suresh.b.siddha@intel.com>
Acked-by: Eric Anholt <eric@anholt.net>
Acked-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Diffstat (limited to 'arch/x86/pci/i386.c')
-rw-r--r-- | arch/x86/pci/i386.c | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/arch/x86/pci/i386.c b/arch/x86/pci/i386.c index a70a85de5e84..52e656f17781 100644 --- a/arch/x86/pci/i386.c +++ b/arch/x86/pci/i386.c | |||
@@ -280,6 +280,15 @@ int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma, | |||
280 | return -EINVAL; | 280 | return -EINVAL; |
281 | 281 | ||
282 | prot = pgprot_val(vma->vm_page_prot); | 282 | prot = pgprot_val(vma->vm_page_prot); |
283 | |||
284 | /* | ||
285 | * Return error if pat is not enabled and write_combine is requested. | ||
286 | * Caller can followup with UC MINUS request and add a WC mtrr if there | ||
287 | * is a free mtrr slot. | ||
288 | */ | ||
289 | if (!pat_enabled && write_combine) | ||
290 | return -EINVAL; | ||
291 | |||
283 | if (pat_enabled && write_combine) | 292 | if (pat_enabled && write_combine) |
284 | prot |= _PAGE_CACHE_WC; | 293 | prot |= _PAGE_CACHE_WC; |
285 | else if (pat_enabled || boot_cpu_data.x86 > 3) | 294 | else if (pat_enabled || boot_cpu_data.x86 > 3) |