From 03decbe57ac6c9e632f7cde0f7d0a54bbcaf8464 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 29 Aug 2014 12:12:29 +0200 Subject: 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 Reviewed-by: Thierry Reding Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_vm.c | 76 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 76 insertions(+) (limited to 'drivers/gpu/drm/drm_vm.c') diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 24e045c4f53..352e3399d18 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -35,11 +35,18 @@ #include #include +#include #if defined(__ia64__) #include #include #endif +struct drm_vma_entry { + struct list_head head; + struct vm_area_struct *vma; + pid_t pid; +}; + static void drm_vm_open(struct vm_area_struct *vma); static void drm_vm_close(struct vm_area_struct *vma); @@ -662,3 +669,72 @@ int drm_mmap(struct file *filp, struct vm_area_struct *vma) return ret; } EXPORT_SYMBOL(drm_mmap); + +void drm_legacy_vma_flush(struct drm_device *dev) +{ + struct drm_vma_entry *vma, *vma_temp; + + /* Clear vma list (only needed for legacy drivers) */ + list_for_each_entry_safe(vma, vma_temp, &dev->vmalist, head) { + list_del(&vma->head); + kfree(vma); + } +} + +#if DRM_DEBUG_CODE + +int drm_vma_info(struct seq_file *m, void *data) +{ + struct drm_info_node *node = (struct drm_info_node *) m->private; + struct drm_device *dev = node->minor->dev; + struct drm_vma_entry *pt; + struct vm_area_struct *vma; + unsigned long vma_count = 0; +#if defined(__i386__) + unsigned int pgprot; +#endif + + mutex_lock(&dev->struct_mutex); + list_for_each_entry(pt, &dev->vmalist, head) + vma_count++; + + seq_printf(m, "vma use count: %lu, high_memory = %pK, 0x%pK\n", + vma_count, high_memory, + (void *)(unsigned long)virt_to_phys(high_memory)); + + list_for_each_entry(pt, &dev->vmalist, head) { + vma = pt->vma; + if (!vma) + continue; + seq_printf(m, + "\n%5d 0x%pK-0x%pK %c%c%c%c%c%c 0x%08lx000", + pt->pid, + (void *)vma->vm_start, (void *)vma->vm_end, + vma->vm_flags & VM_READ ? 'r' : '-', + vma->vm_flags & VM_WRITE ? 'w' : '-', + vma->vm_flags & VM_EXEC ? 'x' : '-', + vma->vm_flags & VM_MAYSHARE ? 's' : 'p', + vma->vm_flags & VM_LOCKED ? 'l' : '-', + vma->vm_flags & VM_IO ? 'i' : '-', + vma->vm_pgoff); + +#if defined(__i386__) + pgprot = pgprot_val(vma->vm_page_prot); + seq_printf(m, " %c%c%c%c%c%c%c%c%c", + pgprot & _PAGE_PRESENT ? 'p' : '-', + pgprot & _PAGE_RW ? 'w' : 'r', + pgprot & _PAGE_USER ? 'u' : 's', + pgprot & _PAGE_PWT ? 't' : 'b', + pgprot & _PAGE_PCD ? 'u' : 'c', + pgprot & _PAGE_ACCESSED ? 'a' : '-', + pgprot & _PAGE_DIRTY ? 'd' : '-', + pgprot & _PAGE_PSE ? 'm' : 'k', + pgprot & _PAGE_GLOBAL ? 'g' : 'l'); +#endif + seq_printf(m, "\n"); + } + mutex_unlock(&dev->struct_mutex); + return 0; +} + +#endif -- cgit v1.2.3-70-g09d2 From cc5ea5947a52b98cd9a03d4011a5a12b4e5a99c4 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 29 Aug 2014 12:12:32 +0200 Subject: drm: move AGP definitions harder Move drm_agp_head to drm_agpsupport.h and drm_agp_mem into drm_legacy.h. Unfortunately, drivers still heavily access drm_agp_head so we cannot move it to drm_legacy.h. However, at least it's no longer visible in drmP.h now (it's directly included from it, though). Signed-off-by: David Herrmann Reviewed-by: Thierry Reding Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_agpsupport.c | 1 + drivers/gpu/drm/drm_legacy.h | 15 +++++++++++++++ drivers/gpu/drm/drm_memory.c | 1 + drivers/gpu/drm/drm_vm.c | 1 + include/drm/drmP.h | 30 +----------------------------- include/drm/drm_agpsupport.h | 13 +++++++++++++ 6 files changed, 32 insertions(+), 29 deletions(-) (limited to 'drivers/gpu/drm/drm_vm.c') diff --git a/drivers/gpu/drm/drm_agpsupport.c b/drivers/gpu/drm/drm_agpsupport.c index dde205cef38..4b2b4aa5033 100644 --- a/drivers/gpu/drm/drm_agpsupport.c +++ b/drivers/gpu/drm/drm_agpsupport.c @@ -34,6 +34,7 @@ #include #include #include +#include "drm_legacy.h" #if __OS_HAS_AGP diff --git a/drivers/gpu/drm/drm_legacy.h b/drivers/gpu/drm/drm_legacy.h index 47cb9de98fb..f2d076823b2 100644 --- a/drivers/gpu/drm/drm_legacy.h +++ b/drivers/gpu/drm/drm_legacy.h @@ -28,6 +28,9 @@ * should no longer be using. They cannot be removed as legacy * drivers use them, and removing them are API breaks. */ +#include + +struct agp_memory; struct drm_device; struct drm_file; @@ -68,4 +71,16 @@ int drm_legacy_freebufs(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_mapbufs(struct drm_device *d, void *v, struct drm_file *f); int drm_legacy_dma_ioctl(struct drm_device *d, void *v, struct drm_file *f); +/* + * AGP Support + */ + +struct drm_agp_mem { + unsigned long handle; + struct agp_memory *memory; + unsigned long bound; + int pages; + struct list_head head; +}; + #endif /* __DRM_LEGACY_H__ */ diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c index 00c67c0f238..7888dad5ab7 100644 --- a/drivers/gpu/drm/drm_memory.c +++ b/drivers/gpu/drm/drm_memory.c @@ -36,6 +36,7 @@ #include #include #include +#include "drm_legacy.h" #if __OS_HAS_AGP static void *agp_remap(unsigned long offset, unsigned long size, diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 352e3399d18..be25174f10e 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -40,6 +40,7 @@ #include #include #endif +#include "drm_legacy.h" struct drm_vma_entry { struct list_head head; diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 0bf66f907f2..7a3c73c5375 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -80,6 +80,7 @@ struct module; struct drm_file; struct drm_device; +struct drm_agp_head; struct device_node; struct videomode; @@ -439,35 +440,6 @@ struct drm_device_dma { }; -/** - * AGP memory entry. Stored as a doubly linked list. - */ -struct drm_agp_mem { - unsigned long handle; /**< handle */ - struct agp_memory *memory; - unsigned long bound; /**< address */ - int pages; - struct list_head head; -}; - -/** - * AGP data. - * - * \sa drm_agp_init() and drm_device::agp. - */ -struct drm_agp_head { - struct agp_kern_info agp_info; /**< AGP device information */ - struct list_head memory; - unsigned long mode; /**< AGP mode */ - struct agp_bridge_data *bridge; - int enabled; /**< whether the AGP bus as been enabled */ - int acquired; /**< whether the AGP device has been acquired */ - unsigned long base; - int agp_mtrr; - int cant_use_aperture; - unsigned long page_mask; -}; - /** * Scatter-gather memory. */ diff --git a/include/drm/drm_agpsupport.h b/include/drm/drm_agpsupport.h index 86a02188074..3bebeb4af86 100644 --- a/include/drm/drm_agpsupport.h +++ b/include/drm/drm_agpsupport.h @@ -8,6 +8,19 @@ #include #include +struct drm_agp_head { + struct agp_kern_info agp_info; + struct list_head memory; + unsigned long mode; + struct agp_bridge_data *bridge; + int enabled; + int acquired; + unsigned long base; + int agp_mtrr; + int cant_use_aperture; + unsigned long page_mask; +}; + #if __OS_HAS_AGP void drm_free_agp(struct agp_memory * handle, int pages); -- cgit v1.2.3-70-g09d2 From 2791ee85e1e9805d600782e554f706458ec6c84e Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 29 Aug 2014 12:12:33 +0200 Subject: drm: replace weird conditional includes pte_wrprotect() is only used by drm_vm.c, so move the include there. Also include it unconditionally, all architectures provide this header! Furthermore, replace asm/current.h with sched.h, which includes asm/current.h unconditionally. This way we get the same effect and avoid direct asm/ includes. Furthermore, drop the weird __alpha__ protection. It's safe to include sched.h everywhere (and the wait.h comment doesn't apply, anyway). Signed-off-by: David Herrmann Reviewed-by: Thierry Reding Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_vm.c | 1 + include/drm/drmP.h | 10 +--------- 2 files changed, 2 insertions(+), 9 deletions(-) (limited to 'drivers/gpu/drm/drm_vm.c') diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index be25174f10e..967e570bb0d 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -40,6 +40,7 @@ #include #include #endif +#include #include "drm_legacy.h" struct drm_vma_entry { diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 7a3c73c5375..31fb3004777 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -36,12 +36,7 @@ #define _DRM_P_H_ #ifdef __KERNEL__ -#ifdef __alpha__ -/* add include of current.h so that "current" is defined - * before static inline funcs in wait.h. Doing this so we - * can build the DRM (part of PI DRI). 4/21/2000 S + B */ -#include -#endif /* __alpha__ */ +#include #include #include #include @@ -58,9 +53,6 @@ #include #include #include -#if defined(__alpha__) || defined(__powerpc__) -#include /* For pte_wrprotect */ -#endif #include #include #include -- cgit v1.2.3-70-g09d2 From edf0ac7c67ce596f43d66a781660889bbdcc9505 Mon Sep 17 00:00:00 2001 From: David Herrmann Date: Fri, 29 Aug 2014 12:12:38 +0200 Subject: drm: drop DRM_DEBUG_CODE DRM_DEBUG_CODE is currently always set, so distributions enable it. The only reason to keep support in code is if developers wanted to disable debug support. Sounds unlikely. All the DRM_DEBUG() printks are still guarded by a drm_debug read. So if its cacheline is read once, they're discarded pretty fast.. There should hardly be any performance penalty, it's even guarded by unlikely(). Signed-off-by: David Herrmann Reviewed-by: Thierry Reding Signed-off-by: Dave Airlie --- drivers/gpu/drm/drm_debugfs.c | 2 -- drivers/gpu/drm/drm_vm.c | 4 ---- drivers/gpu/drm/radeon/radeon.h | 17 ++++++++++++----- drivers/gpu/drm/radeon/radeon_ring.c | 21 --------------------- include/drm/drmP.h | 12 ------------ 5 files changed, 12 insertions(+), 44 deletions(-) (limited to 'drivers/gpu/drm/drm_vm.c') diff --git a/drivers/gpu/drm/drm_debugfs.c b/drivers/gpu/drm/drm_debugfs.c index 13bd42923dd..4491dbda653 100644 --- a/drivers/gpu/drm/drm_debugfs.c +++ b/drivers/gpu/drm/drm_debugfs.c @@ -49,9 +49,7 @@ static const struct drm_info_list drm_debugfs_list[] = { {"clients", drm_clients_info, 0}, {"bufs", drm_bufs_info, 0}, {"gem_names", drm_gem_name_info, DRIVER_GEM}, -#if DRM_DEBUG_CODE {"vma", drm_vma_info, 0}, -#endif }; #define DRM_DEBUGFS_ENTRIES ARRAY_SIZE(drm_debugfs_list) diff --git a/drivers/gpu/drm/drm_vm.c b/drivers/gpu/drm/drm_vm.c index 967e570bb0d..4b3e9c4754d 100644 --- a/drivers/gpu/drm/drm_vm.c +++ b/drivers/gpu/drm/drm_vm.c @@ -683,8 +683,6 @@ void drm_legacy_vma_flush(struct drm_device *dev) } } -#if DRM_DEBUG_CODE - int drm_vma_info(struct seq_file *m, void *data) { struct drm_info_node *node = (struct drm_info_node *) m->private; @@ -738,5 +736,3 @@ int drm_vma_info(struct seq_file *m, void *data) mutex_unlock(&dev->struct_mutex); return 0; } - -#endif diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h index d80dc547a10..79c988db79a 100644 --- a/drivers/gpu/drm/radeon/radeon.h +++ b/drivers/gpu/drm/radeon/radeon.h @@ -2776,18 +2776,25 @@ void radeon_atombios_fini(struct radeon_device *rdev); /* * RING helpers. */ -#if DRM_DEBUG_CODE == 0 + +/** + * radeon_ring_write - write a value to the ring + * + * @ring: radeon_ring structure holding ring information + * @v: dword (dw) value to write + * + * Write a value to the requested ring buffer (all asics). + */ static inline void radeon_ring_write(struct radeon_ring *ring, uint32_t v) { + if (ring->count_dw <= 0) + DRM_ERROR("radeon: writing more dwords to the ring than expected!\n"); + ring->ring[ring->wptr++] = v; ring->wptr &= ring->ptr_mask; ring->count_dw--; ring->ring_free_dw--; } -#else -/* With debugging this is just too big to inline */ -void radeon_ring_write(struct radeon_ring *ring, uint32_t v); -#endif /* * ASICs macro. diff --git a/drivers/gpu/drm/radeon/radeon_ring.c b/drivers/gpu/drm/radeon/radeon_ring.c index d6560790253..6f2a9bd6bb5 100644 --- a/drivers/gpu/drm/radeon/radeon_ring.c +++ b/drivers/gpu/drm/radeon/radeon_ring.c @@ -44,27 +44,6 @@ */ static int radeon_debugfs_ring_init(struct radeon_device *rdev, struct radeon_ring *ring); -/** - * radeon_ring_write - write a value to the ring - * - * @ring: radeon_ring structure holding ring information - * @v: dword (dw) value to write - * - * Write a value to the requested ring buffer (all asics). - */ -void radeon_ring_write(struct radeon_ring *ring, uint32_t v) -{ -#if DRM_DEBUG_CODE - if (ring->count_dw <= 0) { - DRM_ERROR("radeon: writing more dwords to the ring than expected!\n"); - } -#endif - ring->ring[ring->wptr++] = v; - ring->wptr &= ring->ptr_mask; - ring->count_dw--; - ring->ring_free_dw--; -} - /** * radeon_ring_supports_scratch_reg - check if the ring supports * writing to scratch registers diff --git a/include/drm/drmP.h b/include/drm/drmP.h index 8b3f3b7dc2f..8f55875dafb 100644 --- a/include/drm/drmP.h +++ b/include/drm/drmP.h @@ -140,9 +140,6 @@ int drm_err(const char *func, const char *format, ...); /** \name Begin the DRM... */ /*@{*/ -#define DRM_DEBUG_CODE 2 /**< Include debugging code if > 1, then - also include looping detection. */ - #define DRM_MAGIC_HASH_ORDER 4 /**< Size of key hash table. Must be power of 2. */ /*@}*/ @@ -188,7 +185,6 @@ int drm_err(const char *func, const char *format, ...); * \param fmt printf() like format string. * \param arg arguments */ -#if DRM_DEBUG_CODE #define DRM_DEBUG(fmt, args...) \ do { \ if (unlikely(drm_debug & DRM_UT_CORE)) \ @@ -210,12 +206,6 @@ int drm_err(const char *func, const char *format, ...); if (unlikely(drm_debug & DRM_UT_PRIME)) \ drm_ut_debug_printk(__func__, fmt, ##args); \ } while (0) -#else -#define DRM_DEBUG_DRIVER(fmt, args...) do { } while (0) -#define DRM_DEBUG_KMS(fmt, args...) do { } while (0) -#define DRM_DEBUG_PRIME(fmt, args...) do { } while (0) -#define DRM_DEBUG(fmt, arg...) do { } while (0) -#endif /*@}*/ @@ -1348,9 +1338,7 @@ void drm_prime_init_file_private(struct drm_prime_file_private *prime_fpriv); void drm_prime_destroy_file_private(struct drm_prime_file_private *prime_fpriv); void drm_prime_remove_buf_handle_locked(struct drm_prime_file_private *prime_fpriv, struct dma_buf *dma_buf); -#if DRM_DEBUG_CODE extern int drm_vma_info(struct seq_file *m, void *data); -#endif /* Scatter Gather Support (drm_scatter.h) */ extern void drm_legacy_sg_cleanup(struct drm_device *dev); -- cgit v1.2.3-70-g09d2