aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/char/drm/drm_vm.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@starflyer.(none)>2005-08-05 08:11:22 -0400
committerDave Airlie <airlied@linux.ie>2005-08-05 08:11:22 -0400
commitd1f2b55ad2c11f46e30547a9f7754e99b478348e (patch)
treecabf9060c4f6cb419c7ed7fdcbcc6b6a91a83ac1 /drivers/char/drm/drm_vm.c
parentc73681e77b40697d16ada777adf2c6dc4db05917 (diff)
drm: updated DRM map patch for 32/64 bit systems
I basically combined Paul's patches with additions that I had made for PCI scatter gather. I also tried more carefully to avoid problems with the same token assigned multiple times while trying to use the base address in the token if possible to gain as much backward compatibility as possible for broken DRI clients. From: Paul Mackerras <paulus@samba.org> and Egbert Eich <eich@suse.de> Signed-off-by: Dave Airlie <airlied@linux.ie>
Diffstat (limited to 'drivers/char/drm/drm_vm.c')
-rw-r--r--drivers/char/drm/drm_vm.c20
1 files changed, 10 insertions, 10 deletions
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c
index 675d2397def..99b5c86f751 100644
--- a/drivers/char/drm/drm_vm.c
+++ b/drivers/char/drm/drm_vm.c
@@ -73,12 +73,13 @@ static __inline__ struct page *drm_do_vm_nopage(struct vm_area_struct *vma,
73 r_list = list_entry(list, drm_map_list_t, head); 73 r_list = list_entry(list, drm_map_list_t, head);
74 map = r_list->map; 74 map = r_list->map;
75 if (!map) continue; 75 if (!map) continue;
76 if (map->offset == VM_OFFSET(vma)) break; 76 if (r_list->user_token == VM_OFFSET(vma))
77 break;
77 } 78 }
78 79
79 if (map && map->type == _DRM_AGP) { 80 if (map && map->type == _DRM_AGP) {
80 unsigned long offset = address - vma->vm_start; 81 unsigned long offset = address - vma->vm_start;
81 unsigned long baddr = VM_OFFSET(vma) + offset; 82 unsigned long baddr = map->offset + offset;
82 struct drm_agp_mem *agpmem; 83 struct drm_agp_mem *agpmem;
83 struct page *page; 84 struct page *page;
84 85
@@ -304,7 +305,7 @@ static __inline__ struct page *drm_do_vm_sg_nopage(struct vm_area_struct *vma,
304 305
305 306
306 offset = address - vma->vm_start; 307 offset = address - vma->vm_start;
307 map_offset = map->offset - dev->sg->handle; 308 map_offset = map->offset - (unsigned long)dev->sg->virtual;
308 page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT); 309 page_offset = (offset >> PAGE_SHIFT) + (map_offset >> PAGE_SHIFT);
309 page = entry->pagelist[page_offset]; 310 page = entry->pagelist[page_offset];
310 get_page(page); 311 get_page(page);
@@ -568,13 +569,12 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
568 for performance, even if the list was a 569 for performance, even if the list was a
569 bit longer. */ 570 bit longer. */
570 list_for_each(list, &dev->maplist->head) { 571 list_for_each(list, &dev->maplist->head) {
571 unsigned long off;
572 572
573 r_list = list_entry(list, drm_map_list_t, head); 573 r_list = list_entry(list, drm_map_list_t, head);
574 map = r_list->map; 574 map = r_list->map;
575 if (!map) continue; 575 if (!map) continue;
576 off = dev->driver->get_map_ofs(map); 576 if (r_list->user_token == VM_OFFSET(vma))
577 if (off == VM_OFFSET(vma)) break; 577 break;
578 } 578 }
579 579
580 if (!map || ((map->flags&_DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN))) 580 if (!map || ((map->flags&_DRM_RESTRICTED) && !capable(CAP_SYS_ADMIN)))
@@ -613,7 +613,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
613 /* fall through to _DRM_FRAME_BUFFER... */ 613 /* fall through to _DRM_FRAME_BUFFER... */
614 case _DRM_FRAME_BUFFER: 614 case _DRM_FRAME_BUFFER:
615 case _DRM_REGISTERS: 615 case _DRM_REGISTERS:
616 if (VM_OFFSET(vma) >= __pa(high_memory)) { 616 if (map->offset >= __pa(high_memory)) {
617#if defined(__i386__) || defined(__x86_64__) 617#if defined(__i386__) || defined(__x86_64__)
618 if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) { 618 if (boot_cpu_data.x86 > 3 && map->type != _DRM_AGP) {
619 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD; 619 pgprot_val(vma->vm_page_prot) |= _PAGE_PCD;
@@ -636,12 +636,12 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
636 offset = dev->driver->get_reg_ofs(dev); 636 offset = dev->driver->get_reg_ofs(dev);
637#ifdef __sparc__ 637#ifdef __sparc__
638 if (io_remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start, 638 if (io_remap_pfn_range(DRM_RPR_ARG(vma) vma->vm_start,
639 (VM_OFFSET(vma) + offset) >> PAGE_SHIFT, 639 (map->offset + offset) >> PAGE_SHIFT,
640 vma->vm_end - vma->vm_start, 640 vma->vm_end - vma->vm_start,
641 vma->vm_page_prot)) 641 vma->vm_page_prot))
642#else 642#else
643 if (io_remap_pfn_range(vma, vma->vm_start, 643 if (io_remap_pfn_range(vma, vma->vm_start,
644 (VM_OFFSET(vma) + offset) >> PAGE_SHIFT, 644 (map->offset + offset) >> PAGE_SHIFT,
645 vma->vm_end - vma->vm_start, 645 vma->vm_end - vma->vm_start,
646 vma->vm_page_prot)) 646 vma->vm_page_prot))
647#endif 647#endif
@@ -649,7 +649,7 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
649 DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx," 649 DRM_DEBUG(" Type = %d; start = 0x%lx, end = 0x%lx,"
650 " offset = 0x%lx\n", 650 " offset = 0x%lx\n",
651 map->type, 651 map->type,
652 vma->vm_start, vma->vm_end, VM_OFFSET(vma) + offset); 652 vma->vm_start, vma->vm_end, map->offset + offset);
653 vma->vm_ops = &drm_vm_ops; 653 vma->vm_ops = &drm_vm_ops;
654 break; 654 break;
655 case _DRM_SHM: 655 case _DRM_SHM: