Commit f435046d authored by Andy Lutomirski's avatar Andy Lutomirski Committed by Dave Airlie

drm, agpgart: Use pgprot_writecombine for AGP maps and make the MTRR optional

I'm not sure I understand the intent of the previous behavior.  mmap
on /dev/agpgart and DRM_AGP maps had no cache flags set, so they
would be fully cacheable.  But the DRM code (most of the time) would
add a write-combining MTRR that would change the effective memory
type to WC.

The new behavior just requests WC explicitly for all AGP maps.

If there is any code out there that expects cacheable access to the
AGP aperture (because the drm driver doesn't request an MTRR or
because it's using /dev/agpgart directly), then it will now end up
with a UC or WC mapping, depending on the architecture and PAT
availability.  But cacheable access to the aperture seems like it's
asking for trouble, because, AIUI, the aperture is an alias of RAM.
Reviewed-by: default avatarDaniel Vetter <daniel.vetter@ffwll.ch>
Signed-off-by: default avatarAndy Lutomirski <luto@amacapital.net>
Signed-off-by: default avatarDave Airlie <airlied@redhat.com>
parent ff47eaf2
...@@ -603,7 +603,8 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -603,7 +603,8 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
vma->vm_ops = kerninfo.vm_ops; vma->vm_ops = kerninfo.vm_ops;
} else if (io_remap_pfn_range(vma, vma->vm_start, } else if (io_remap_pfn_range(vma, vma->vm_start,
(kerninfo.aper_base + offset) >> PAGE_SHIFT, (kerninfo.aper_base + offset) >> PAGE_SHIFT,
size, vma->vm_page_prot)) { size,
pgprot_writecombine(vma->vm_page_prot))) {
goto out_again; goto out_again;
} }
mutex_unlock(&(agp_fe.agp_mutex)); mutex_unlock(&(agp_fe.agp_mutex));
...@@ -618,8 +619,9 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma) ...@@ -618,8 +619,9 @@ static int agp_mmap(struct file *file, struct vm_area_struct *vma)
if (kerninfo.vm_ops) { if (kerninfo.vm_ops) {
vma->vm_ops = kerninfo.vm_ops; vma->vm_ops = kerninfo.vm_ops;
} else if (io_remap_pfn_range(vma, vma->vm_start, } else if (io_remap_pfn_range(vma, vma->vm_start,
kerninfo.aper_base >> PAGE_SHIFT, kerninfo.aper_base >> PAGE_SHIFT,
size, vma->vm_page_prot)) { size,
pgprot_writecombine(vma->vm_page_prot))) {
goto out_again; goto out_again;
} }
mutex_unlock(&(agp_fe.agp_mutex)); mutex_unlock(&(agp_fe.agp_mutex));
......
...@@ -278,10 +278,10 @@ static int drm_pci_agp_init(struct drm_device *dev) ...@@ -278,10 +278,10 @@ static int drm_pci_agp_init(struct drm_device *dev)
} }
if (drm_core_has_MTRR(dev)) { if (drm_core_has_MTRR(dev)) {
if (dev->agp) if (dev->agp)
dev->agp->agp_mtrr = dev->agp->agp_mtrr = arch_phys_wc_add(
mtrr_add(dev->agp->agp_info.aper_base, dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size * dev->agp->agp_info.aper_size *
1024 * 1024, MTRR_TYPE_WRCOMB, 1); 1024 * 1024);
} }
} }
return 0; return 0;
......
...@@ -451,14 +451,8 @@ void drm_put_dev(struct drm_device *dev) ...@@ -451,14 +451,8 @@ void drm_put_dev(struct drm_device *dev)
drm_lastclose(dev); drm_lastclose(dev);
if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && if (drm_core_has_MTRR(dev) && drm_core_has_AGP(dev) && dev->agp)
dev->agp && dev->agp->agp_mtrr >= 0) { arch_phys_wc_del(dev->agp->agp_mtrr);
int retval;
retval = mtrr_del(dev->agp->agp_mtrr,
dev->agp->agp_info.aper_base,
dev->agp->agp_info.aper_size * 1024 * 1024);
DRM_DEBUG("mtrr_del=%d\n", retval);
}
if (dev->driver->unload) if (dev->driver->unload)
dev->driver->unload(dev); dev->driver->unload(dev);
......
...@@ -49,13 +49,10 @@ static pgprot_t drm_io_prot(struct drm_local_map *map, ...@@ -49,13 +49,10 @@ static pgprot_t drm_io_prot(struct drm_local_map *map,
pgprot_t tmp = vm_get_page_prot(vma->vm_flags); pgprot_t tmp = vm_get_page_prot(vma->vm_flags);
#if defined(__i386__) || defined(__x86_64__) #if defined(__i386__) || defined(__x86_64__)
if (map->type != _DRM_AGP) { if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING))
if (map->type == _DRM_FRAME_BUFFER || tmp = pgprot_noncached(tmp);
map->flags & _DRM_WRITE_COMBINING) else
tmp = pgprot_writecombine(tmp); tmp = pgprot_writecombine(tmp);
else
tmp = pgprot_noncached(tmp);
}
#elif defined(__powerpc__) #elif defined(__powerpc__)
pgprot_val(tmp) |= _PAGE_NO_CACHE; pgprot_val(tmp) |= _PAGE_NO_CACHE;
if (map->type == _DRM_REGISTERS) if (map->type == _DRM_REGISTERS)
......
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