Commit 46d3fb56 authored by Jesse Barnes's avatar Jesse Barnes Committed by Tony Luck

[IA64] new api efi_range_is_wc()

Ok, here you go Tony.  This one fixes the loop and also fixes drm_vm.c.  All
of the bits aside from the efi.h bit are ia64 specific (either under
arch/ia64 or __ia64__), so your tree is probably the right place for all of
it.
 
This patch adds efi_range_is_wc() to efi.h.  It's used to determine whether an
address range can be mapped with the write coalescing attribute.  It also
fixes up some ia64 specific callers to use the new routine instead of
unconditionally calling pgprot_writecombined, which can be dangerous if used
on ranges that don't support it.
Signed-off-by: default avatarJesse Barnes <jbarnes@sgi.com>
Signed-off-by: default avatarTony Luck <tony.luck@intel.com>
parent becd2c6a
......@@ -539,7 +539,8 @@ pci_mmap_page_range (struct pci_dev *dev, struct vm_area_struct *vma,
*/
vma->vm_flags |= (VM_SHM | VM_RESERVED | VM_IO);
if (write_combine)
if (write_combine && efi_range_is_wc(vma->vm_start,
vma->vm_end - vma->vm_start))
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
......
......@@ -612,8 +612,13 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
vma->vm_flags |= VM_IO; /* not in core dump */
}
#if defined(__ia64__)
if (map->type != _DRM_AGP)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
if (efi_range_is_wc(vma->vm_start, vma->vm_end -
vma->vm_start))
vma->vm_page_prot =
pgprot_writecombine(vma->vm_page_prot);
else
vma->vm_page_prot =
pgprot_noncached(vma->vm_page_prot);
#endif
offset = dev->driver->get_reg_ofs(dev);
#ifdef __sparc__
......
......@@ -35,6 +35,7 @@
#include <linux/err.h>
#include <linux/kernel.h>
#include <linux/device.h>
#include <linux/efi.h>
#if defined(__mc68000__) || defined(CONFIG_APUS)
#include <asm/setup.h>
......@@ -967,9 +968,13 @@ fb_mmap(struct file *file, struct vm_area_struct * vma)
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
#elif defined(__hppa__)
pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE;
#elif defined(__ia64__) || defined(__arm__) || defined(__sh__) || \
defined(__m32r__)
#elif defined(__arm__) || defined(__sh__) || defined(__m32r__)
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
#elif defined(__ia64__)
if (efi_range_is_wc(vma->vm_start, vma->vm_end - vma->vm_start))
vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
else
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
#else
#warning What do we have to do here??
#endif
......
......@@ -305,6 +305,27 @@ extern unsigned long __init efi_get_time(void);
extern int __init efi_set_rtc_mmss(unsigned long nowtime);
extern struct efi_memory_map memmap;
/**
* efi_range_is_wc - check the WC bit on an address range
* @start: starting kvirt address
* @len: length of range
*
* Consult the EFI memory map and make sure it's ok to set this range WC.
* Returns true or false.
*/
static inline int efi_range_is_wc(unsigned long start, unsigned long len)
{
int i;
for (i = 0; i < len; i += (1UL << EFI_PAGE_SHIFT)) {
unsigned long paddr = __pa(start + i);
if (!(efi_mem_attributes(paddr) & EFI_MEMORY_WC))
return 0;
}
/* The range checked out */
return 1;
}
#ifdef CONFIG_EFI_PCDP
extern int __init efi_setup_pcdp_console(char *);
#endif
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment