diff options
Diffstat (limited to 'drivers/gpu/drm/drm_vm.c')
-rw-r--r-- | drivers/gpu/drm/drm_vm.c | 89 |
1 files changed, 79 insertions, 10 deletions
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 24e045c4f531..4a2c328959e5 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c | |||
@@ -35,10 +35,19 @@ | |||
35 | 35 | ||
36 | #include <drm/drmP.h> | 36 | #include <drm/drmP.h> |
37 | #include <linux/export.h> | 37 | #include <linux/export.h> |
38 | #include <linux/seq_file.h> | ||
38 | #if defined(__ia64__) | 39 | #if defined(__ia64__) |
39 | #include <linux/efi.h> | 40 | #include <linux/efi.h> |
40 | #include <linux/slab.h> | 41 | #include <linux/slab.h> |
41 | #endif | 42 | #endif |
43 | #include <asm/pgtable.h> | ||
44 | #include "drm_legacy.h" | ||
45 | |||
46 | struct drm_vma_entry { | ||
47 | struct list_head head; | ||
48 | struct vm_area_struct *vma; | ||
49 | pid_t pid; | ||
50 | }; | ||
42 | 51 | ||
43 | static void drm_vm_open(struct vm_area_struct *vma); | 52 | static void drm_vm_open(struct vm_area_struct *vma); |
44 | static void drm_vm_close(struct vm_area_struct *vma); | 53 | static void drm_vm_close(struct vm_area_struct *vma); |
@@ -48,15 +57,11 @@ static pgprot_t drm_io_prot(struct drm_local_map *map, | |||
48 | { | 57 | { |
49 | pgprot_t tmp = vm_get_page_prot(vma->vm_flags); | 58 | pgprot_t tmp = vm_get_page_prot(vma->vm_flags); |
50 | 59 | ||
51 | #if defined(__i386__) || defined(__x86_64__) | 60 | #if defined(__i386__) || defined(__x86_64__) || defined(__powerpc__) |
52 | if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) | 61 | if (map->type == _DRM_REGISTERS && !(map->flags & _DRM_WRITE_COMBINING)) |
53 | tmp = pgprot_noncached(tmp); | 62 | tmp = pgprot_noncached(tmp); |
54 | else | 63 | else |
55 | tmp = pgprot_writecombine(tmp); | 64 | tmp = pgprot_writecombine(tmp); |
56 | #elif defined(__powerpc__) | ||
57 | pgprot_val(tmp) |= _PAGE_NO_CACHE; | ||
58 | if (map->type == _DRM_REGISTERS) | ||
59 | pgprot_val(tmp) |= _PAGE_GUARDED; | ||
60 | #elif defined(__ia64__) | 65 | #elif defined(__ia64__) |
61 | if (efi_range_is_wc(vma->vm_start, vma->vm_end - | 66 | if (efi_range_is_wc(vma->vm_start, vma->vm_end - |
62 | vma->vm_start)) | 67 | vma->vm_start)) |
@@ -263,7 +268,7 @@ static void drm_vm_shm_close(struct vm_area_struct *vma) | |||
263 | dmah.vaddr = map->handle; | 268 | dmah.vaddr = map->handle; |
264 | dmah.busaddr = map->offset; | 269 | dmah.busaddr = map->offset; |
265 | dmah.size = map->size; | 270 | dmah.size = map->size; |
266 | __drm_pci_free(dev, &dmah); | 271 | __drm_legacy_pci_free(dev, &dmah); |
267 | break; | 272 | break; |
268 | } | 273 | } |
269 | kfree(map); | 274 | kfree(map); |
@@ -412,7 +417,6 @@ void drm_vm_open_locked(struct drm_device *dev, | |||
412 | list_add(&vma_entry->head, &dev->vmalist); | 417 | list_add(&vma_entry->head, &dev->vmalist); |
413 | } | 418 | } |
414 | } | 419 | } |
415 | EXPORT_SYMBOL_GPL(drm_vm_open_locked); | ||
416 | 420 | ||
417 | static void drm_vm_open(struct vm_area_struct *vma) | 421 | static void drm_vm_open(struct vm_area_struct *vma) |
418 | { | 422 | { |
@@ -532,7 +536,7 @@ static resource_size_t drm_core_get_reg_ofs(struct drm_device *dev) | |||
532 | * according to the mapping type and remaps the pages. Finally sets the file | 536 | * according to the mapping type and remaps the pages. Finally sets the file |
533 | * pointer and calls vm_open(). | 537 | * pointer and calls vm_open(). |
534 | */ | 538 | */ |
535 | int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) | 539 | static int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) |
536 | { | 540 | { |
537 | struct drm_file *priv = filp->private_data; | 541 | struct drm_file *priv = filp->private_data; |
538 | struct drm_device *dev = priv->minor->dev; | 542 | struct drm_device *dev = priv->minor->dev; |
@@ -646,7 +650,7 @@ int drm_mmap_locked(struct file *filp, struct vm_area_struct *vma) | |||
646 | return 0; | 650 | return 0; |
647 | } | 651 | } |
648 | 652 | ||
649 | int drm_mmap(struct file *filp, struct vm_area_struct *vma) | 653 | int drm_legacy_mmap(struct file *filp, struct vm_area_struct *vma) |
650 | { | 654 | { |
651 | struct drm_file *priv = filp->private_data; | 655 | struct drm_file *priv = filp->private_data; |
652 | struct drm_device *dev = priv->minor->dev; | 656 | struct drm_device *dev = priv->minor->dev; |
@@ -661,4 +665,69 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma) | |||
661 | 665 | ||
662 | return ret; | 666 | return ret; |
663 | } | 667 | } |
664 | EXPORT_SYMBOL(drm_mmap); | 668 | EXPORT_SYMBOL(drm_legacy_mmap); |
669 | |||
670 | void drm_legacy_vma_flush(struct drm_device *dev) | ||
671 | { | ||
672 | struct drm_vma_entry *vma, *vma_temp; | ||
673 | |||
674 | /* Clear vma list (only needed for legacy drivers) */ | ||
675 | list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { | ||
676 | list_del(&vma->head); | ||
677 | kfree(vma); | ||
678 | } | ||
679 | } | ||
680 | |||
681 | int drm_vma_info(struct seq_file *m, void *data) | ||
682 | { | ||
683 | struct drm_info_node *node = (struct drm_info_node *) m->private; | ||
684 | struct drm_device *dev = node->minor->dev; | ||
685 | struct drm_vma_entry *pt; | ||
686 | struct vm_area_struct *vma; | ||
687 | unsigned long vma_count = 0; | ||
688 | #if defined(__i386__) | ||
689 | unsigned int pgprot; | ||
690 | #endif | ||
691 | |||
692 | mutex_lock(&dev->struct_mutex); | ||
693 | list_for_each_entry(pt, &dev->vmalist, head) | ||
694 | vma_count++; | ||
695 | |||
696 | seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n", | ||
697 | vma_count, high_memory, | ||
698 | (void *)(unsigned long)virt_to_phys(high_memory)); | ||
699 | |||
700 | list_for_each_entry(pt, &dev->vmalist, head) { | ||
701 | vma = pt->vma; | ||
702 | if (!vma) | ||
703 | continue; | ||
704 | seq_printf(m, | ||
705 | "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000", | ||
706 | pt->pid, | ||
707 | (void *)vma->vm_start, (void *)vma->vm_end, | ||
708 | vma->vm_flags & VM_READ ? 'r' : '-', | ||
709 | vma->vm_flags & VM_WRITE ? 'w' : '-', | ||
710 | vma->vm_flags & VM_EXEC ? 'x' : '-', | ||
711 | vma->vm_flags & VM_MAYSHARE ? 's' : 'p', | ||
712 | vma->vm_flags & VM_LOCKED ? 'l' : '-', | ||
713 | vma->vm_flags & VM_IO ? 'i' : '-', | ||
714 | vma->vm_pgoff); | ||
715 | |||
716 | #if defined(__i386__) | ||
717 | pgprot = pgprot_val(vma->vm_page_prot); | ||
718 | seq_printf(m, " %c%c%c%c%c%c%c%c%c", | ||
719 | pgprot & _PAGE_PRESENT ? 'p' : '-', | ||
720 | pgprot & _PAGE_RW ? 'w' : 'r', | ||
721 | pgprot & _PAGE_USER ? 'u' : 's', | ||
722 | pgprot & _PAGE_PWT ? 't' : 'b', | ||
723 | pgprot & _PAGE_PCD ? 'u' : 'c', | ||
724 | pgprot & _PAGE_ACCESSED ? 'a' : '-', | ||
725 | pgprot & _PAGE_DIRTY ? 'd' : '-', | ||
726 | pgprot & _PAGE_PSE ? 'm' : 'k', | ||
727 | pgprot & _PAGE_GLOBAL ? 'g' : 'l'); | ||
728 | #endif | ||
729 | seq_printf(m, "\n"); | ||
730 | } | ||
731 | mutex_unlock(&dev->struct_mutex); | ||
732 | return 0; | ||
733 | } | ||