aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Herrmann <dh.herrmann@gmail.com>2014-08-29 06:12:29 -0400
committerDave Airlie <airlied@redhat.com>2014-09-10 03:13:36 -0400
commit03decbe57ac6c9e632f7cde0f7d0a54bbcaf8464 (patch)
tree177436526b40cbc2c29c99ea9f6e14de248fd99b
parent9fc5cde7fb6699b0a75e90b7cbfee7c912dd94c2 (diff)
drm: move "struct drm_vma_entry" to drm_vm.c
Make all the drm_vma_entry handling local to drm_vm.c and hide it from global headers. This requires to extract the inlined legacy drm_vma_entry cleanup into a small helper and also move a weirdly placed drm_vma_info helper into drm_vm.c. Signed-off-by: David Herrmann <dh.herrmann@gmail.com> Reviewed-by: Thierry Reding <treding@nvidia.com> Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r--drivers/gpu/drm/drm_fops.c10
-rw-r--r--drivers/gpu/drm/drm_info.c59
-rw-r--r--drivers/gpu/drm/drm_vm.c76
-rw-r--r--include/drm/drmP.h8
4 files changed, 79 insertions, 74 deletions
diff --git a/drivers/gpu/drm/drm_fops.c b/drivers/gpu/drm/drm_fops.c
index 6dbbb0fd54eb..12e6a1cd804d 100644
--- a/drivers/gpu/drm/drm_fops.c
+++ b/drivers/gpu/drm/drm_fops.c
@@ -330,8 +330,6 @@ static void drm_legacy_dev_reinit(struct drm_device *dev)
330 */ 330 */
331int drm_lastclose(struct drm_device * dev) 331int drm_lastclose(struct drm_device * dev)
332{ 332{
333 struct drm_vma_entry *vma, *vma_temp;
334
335 DRM_DEBUG("\n"); 333 DRM_DEBUG("\n");
336 334
337 if (dev->driver->lastclose) 335 if (dev->driver->lastclose)
@@ -346,13 +344,7 @@ int drm_lastclose(struct drm_device * dev)
346 drm_agp_clear(dev); 344 drm_agp_clear(dev);
347 345
348 drm_legacy_sg_cleanup(dev); 346 drm_legacy_sg_cleanup(dev);
349 347 drm_legacy_vma_flush(dev);
350 /* Clear vma list (only built for debugging) */
351 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
352 list_del(&vma->head);
353 kfree(vma);
354 }
355
356 drm_legacy_dma_takedown(dev); 348 drm_legacy_dma_takedown(dev);
357 349
358 mutex_unlock(&dev->struct_mutex); 350 mutex_unlock(&dev->struct_mutex);
diff --git a/drivers/gpu/drm/drm_info.c b/drivers/gpu/drm/drm_info.c
index ecaf0fa2eec8..3c99f6f60818 100644
--- a/drivers/gpu/drm/drm_info.c
+++ b/drivers/gpu/drm/drm_info.c
@@ -223,62 +223,3 @@ int drm_gem_name_info(struct seq_file *m, void *data)
223 223
224 return 0; 224 return 0;
225} 225}
226
227#if DRM_DEBUG_CODE
228
229int drm_vma_info(struct seq_file *m, void *data)
230{
231 struct drm_info_node *node = (struct drm_info_node *) m->private;
232 struct drm_device *dev = node->minor->dev;
233 struct drm_vma_entry *pt;
234 struct vm_area_struct *vma;
235 unsigned long vma_count = 0;
236#if defined(__i386__)
237 unsigned int pgprot;
238#endif
239
240 mutex_lock(&dev->struct_mutex);
241 list_for_each_entry(pt, &dev->vmalist, head)
242 vma_count++;
243
244 seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n",
245 vma_count, high_memory,
246 (void *)(unsigned long)virt_to_phys(high_memory));
247
248 list_for_each_entry(pt, &dev->vmalist, head) {
249 vma = pt->vma;
250 if (!vma)
251 continue;
252 seq_printf(m,
253 "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000",
254 pt->pid,
255 (void *)vma->vm_start, (void *)vma->vm_end,
256 vma->vm_flags & VM_READ ? 'r' : '-',
257 vma->vm_flags & VM_WRITE ? 'w' : '-',
258 vma->vm_flags & VM_EXEC ? 'x' : '-',
259 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
260 vma->vm_flags & VM_LOCKED ? 'l' : '-',
261 vma->vm_flags & VM_IO ? 'i' : '-',
262 vma->vm_pgoff);
263
264#if defined(__i386__)
265 pgprot = pgprot_val(vma->vm_page_prot);
266 seq_printf(m, " %c%c%c%c%c%c%c%c%c",
267 pgprot & _PAGE_PRESENT ? 'p' : '-',
268 pgprot & _PAGE_RW ? 'w' : 'r',
269 pgprot & _PAGE_USER ? 'u' : 's',
270 pgprot & _PAGE_PWT ? 't' : 'b',
271 pgprot & _PAGE_PCD ? 'u' : 'c',
272 pgprot & _PAGE_ACCESSED ? 'a' : '-',
273 pgprot & _PAGE_DIRTY ? 'd' : '-',
274 pgprot & _PAGE_PSE ? 'm' : 'k',
275 pgprot & _PAGE_GLOBAL ? 'g' : 'l');
276#endif
277 seq_printf(m, "\n");
278 }
279 mutex_unlock(&dev->struct_mutex);
280 return 0;
281}
282
283#endif
284
diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c
index 24e045c4f531..352e3399d18f 100644
--- a/drivers/gpu/drm/drm_vm.c
+++ b/drivers/gpu/drm/drm_vm.c
@@ -35,11 +35,18 @@
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
42 43
44struct drm_vma_entry {
45 struct list_head head;
46 struct vm_area_struct *vma;
47 pid_t pid;
48};
49
43static void drm_vm_open(struct vm_area_struct *vma); 50static void drm_vm_open(struct vm_area_struct *vma);
44static void drm_vm_close(struct vm_area_struct *vma); 51static void drm_vm_close(struct vm_area_struct *vma);
45 52
@@ -662,3 +669,72 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma)
662 return ret; 669 return ret;
663} 670}
664EXPORT_SYMBOL(drm_mmap); 671EXPORT_SYMBOL(drm_mmap);
672
673void drm_legacy_vma_flush(struct drm_device *dev)
674{
675 struct drm_vma_entry *vma, *vma_temp;
676
677 /* Clear vma list (only needed for legacy drivers) */
678 list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) {
679 list_del(&vma->head);
680 kfree(vma);
681 }
682}
683
684#if DRM_DEBUG_CODE
685
686int drm_vma_info(struct seq_file *m, void *data)
687{
688 struct drm_info_node *node = (struct drm_info_node *) m->private;
689 struct drm_device *dev = node->minor->dev;
690 struct drm_vma_entry *pt;
691 struct vm_area_struct *vma;
692 unsigned long vma_count = 0;
693#if defined(__i386__)
694 unsigned int pgprot;
695#endif
696
697 mutex_lock(&dev->struct_mutex);
698 list_for_each_entry(pt, &dev->vmalist, head)
699 vma_count++;
700
701 seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n",
702 vma_count, high_memory,
703 (void *)(unsigned long)virt_to_phys(high_memory));
704
705 list_for_each_entry(pt, &dev->vmalist, head) {
706 vma = pt->vma;
707 if (!vma)
708 continue;
709 seq_printf(m,
710 "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000",
711 pt->pid,
712 (void *)vma->vm_start, (void *)vma->vm_end,
713 vma->vm_flags & VM_READ ? 'r' : '-',
714 vma->vm_flags & VM_WRITE ? 'w' : '-',
715 vma->vm_flags & VM_EXEC ? 'x' : '-',
716 vma->vm_flags & VM_MAYSHARE ? 's' : 'p',
717 vma->vm_flags & VM_LOCKED ? 'l' : '-',
718 vma->vm_flags & VM_IO ? 'i' : '-',
719 vma->vm_pgoff);
720
721#if defined(__i386__)
722 pgprot = pgprot_val(vma->vm_page_prot);
723 seq_printf(m, " %c%c%c%c%c%c%c%c%c",
724 pgprot & _PAGE_PRESENT ? 'p' : '-',
725 pgprot & _PAGE_RW ? 'w' : 'r',
726 pgprot & _PAGE_USER ? 'u' : 's',
727 pgprot & _PAGE_PWT ? 't' : 'b',
728 pgprot & _PAGE_PCD ? 'u' : 'c',
729 pgprot & _PAGE_ACCESSED ? 'a' : '-',
730 pgprot & _PAGE_DIRTY ? 'd' : '-',
731 pgprot & _PAGE_PSE ? 'm' : 'k',
732 pgprot & _PAGE_GLOBAL ? 'g' : 'l');
733#endif
734 seq_printf(m, "\n");
735 }
736 mutex_unlock(&dev->struct_mutex);
737 return 0;
738}
739
740#endif
diff --git a/include/drm/drmP.h b/include/drm/drmP.h
index cea7911265a3..11c357534581 100644
--- a/include/drm/drmP.h
+++ b/include/drm/drmP.h
@@ -296,12 +296,6 @@ struct drm_magic_entry {
296 struct drm_file *priv; 296 struct drm_file *priv;
297}; 297};
298 298
299struct drm_vma_entry {
300 struct list_head head;
301 struct vm_area_struct *vma;
302 pid_t pid;
303};
304
305/** 299/**
306 * DMA buffer. 300 * DMA buffer.
307 */ 301 */
@@ -1449,6 +1443,8 @@ struct drm_local_map *drm_legacy_getsarea(struct drm_device *dev);
1449int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req); 1443int drm_legacy_addbufs_agp(struct drm_device *d, struct drm_buf_desc *req);
1450int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req); 1444int drm_legacy_addbufs_pci(struct drm_device *d, struct drm_buf_desc *req);
1451 1445
1446void drm_legacy_vma_flush(struct drm_device *d);
1447
1452 /* sysfs support (drm_sysfs.c) */ 1448 /* sysfs support (drm_sysfs.c) */
1453struct drm_sysfs_class; 1449struct drm_sysfs_class;
1454extern struct class *drm_sysfs_create(struct module *owner, char *name); 1450extern struct class *drm_sysfs_create(struct module *owner, char *name);