drm/ttm: remove some bo->mutex remains
Subsystems (3)
PATCH 1/2 drm/ttm: remove some bo->mutex remains
- A few comments existed here and there that referred to a bo->mutex.
--- drivers/gpu/drm/ttm/ttm_bo.c | 6 +----- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_api.h | 3 +-- include/drm/ttm/ttm_bo_driver.h | 1 + 4 files changed, 4 insertions(+), 8 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +1 -5
@@ -46,7 +46,6 @@#include <linux/file.h> #include <linux/module.h> -#define TTM_ASSERT_LOCKED (param) #define TTM_DEBUG(fmt, arg...)#define TTM_BO_HASH_ORDER 13
@@ -306,9 +305,6 @@ void ttm_bo_unreserve(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_unreserve); -/* -* Call bo->mutex locked. -*/ static int ttm_bo_add_ttm (struct ttm_buffer_object *bo,bool zero_alloc) {struct ttm_bo_device *bdev = bo->bdev;
@@ -316,7 +312,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)int ret =0 ;uint32_t page_flags =0 ; -TTM_ASSERT_LOCKED (&bo->mutex); +BUG_ON (!atomic_read (&bo->reserved)); bo->ttm =NULL ;if (bdev->need_dma32)
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
@@ -146,7 +146,7 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)* since the mmap_sem is only held in read mode. However, we * modify only the caching bits of vma->vm_page_prot and * consider those bits protected by -* the bo->mutex, as we should be the only writers. +* bo->reserved, as we should be the only writers. * There shouldn't really be any readers of these bits except * within vm_insert_mixed()? fork? *
include/drm/ttm/ttm_bo_api.h +1 -2
@@ -35,7 +35,6 @@#include <linux/kref.h> #include <linux/list.h> #include <linux/wait.h> -#include <linux/mutex.h> #include <linux/mm.h> #include <linux/rbtree.h> #include <linux/bitmap.h>
@@ -298,7 +297,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo)* @interruptible: Use interruptible wait. * @no_wait: Return immediately if buffer is busy. * -* This function must be called with the bo::mutex held, and makes +* This function must be called with bo->reserved held, and makes * sure any previous rendering to the buffer is completed. * Note: It might be necessary to block validations before the * wait by reserving the buffer.
include/drm/ttm/ttm_bo_driver.h +1 -0
@@ -37,6 +37,7 @@#include "linux/workqueue.h" #include "linux/fs.h" #include "linux/spinlock.h" +#include <linux/mutex.h> struct ttm_backend ;
Signature · 10 lines
1.7.0 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
PATCH 2/2 drm/ttm: don't write to bo->reserved without holding glob->lru_lock
- The headerfile says you can't write to it without holding the lock.
--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)
drivers/gpu/drm/ttm/ttm_bo.c +7 -1
@@ -476,9 +476,9 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)drm_mm_put_block (bo->mem.mm_node); bo->mem.mm_node =NULL ; } -spin_unlock (&glob->lru_lock);atomic_set (&bo->reserved,0 ); +spin_unlock (&glob->lru_lock);while (put_count--)kref_put (&bo->list_kref, ttm_bo_ref_bug);
@@ -1707,8 +1707,12 @@ EXPORT_SYMBOL(ttm_bo_wait);void ttm_bo_unblock_reservation (struct ttm_buffer_object *bo) { +struct ttm_bo_global *glob = bo->glob; + +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock); } int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,
@@ -1849,8 +1853,10 @@ out:* already swapped buffer. */ +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock);kref_put (&bo->list_kref, ttm_bo_release_list);return ret; }
Signature · 10 lines
1.7.0 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev --
Jerome Glisse
NAKRe: [PATCH 2/2] drm/ttm: don't write to bo->reserved without holding glob->lru_lock
Quoted 3 lines · Maarten Maathuis
- The headerfile says you can't write to it without holding the lock.
Signed-off-by Maarten Maathuis <[email protected]>
NAK, from my POV as we always use atomic_* on reserved it's useless to protect it with spinlock.
Cheers,
Jerome
Quoted 59 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +7
-1@@ -476,9 +476,9 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)drm_mm_put_block (bo->mem.mm_node); bo->mem.mm_node =NULL ; } -spin_unlock (&glob->lru_lock);atomic_set (&bo->reserved,0 ); +spin_unlock (&glob->lru_lock);while (put_count--)kref_put (&bo->list_kref, ttm_bo_ref_bug);@@ -1707,8 +1707,12 @@ EXPORT_SYMBOL(ttm_bo_wait);void ttm_bo_unblock_reservation (struct ttm_buffer_object *bo) { +struct ttm_bo_global *glob = bo->glob; + +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock); } int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,@@ -1849,8 +1853,10 @@ out:* already swapped buffer. */ +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock);kref_put (&bo->list_kref, ttm_bo_release_list);return ret; }Signature · 14 lines
1.7.0 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev -- _______________________________________________ Dri-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Thomas Hellstrom
NAKRe: [PATCH 2/2] drm/ttm: don't write to bo->reserved without holding glob->lru_lock
In reply to Maarten MaathuisQuoted 2 lines · Maarten Maathuis
- The headerfile says you can't write to it without holding the lock.
NAK.
The header-file is incorrect. It should say that the lru_lock needs to be held only when we transition from 0 to 1.
That guarantees that if the lru lock is held, and we read 0, we can safely assume that we're the only ones trying to lock.
/Thomas
Quoted 35 lines
Signed-off-by Maarten Maathuis <[email protected]>--- drivers/gpu/drm/ttm/ttm_bo.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +5
-1@@ -476,9 +476,9 @@ static int ttm_bo_cleanup_refs(struct ttm_buffer_object *bo, bool remove_all)drm_mm_put_block (bo->mem.mm_node); bo->mem.mm_node =NULL ; } -spin_unlock (&glob->lru_lock);atomic_set (&bo->reserved,0 ); +spin_unlock (&glob->lru_lock);while (put_count--)kref_put (&bo->list_kref, ttm_bo_ref_bug);@@ -1707,8 +1707,12 @@ EXPORT_SYMBOL(ttm_bo_wait);void ttm_bo_unblock_reservation (struct ttm_buffer_object *bo) { +struct ttm_bo_global *glob = bo->glob; + +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock); } int ttm_bo_block_reservation(struct ttm_buffer_object *bo, bool interruptible,
drivers/gpu/drm/ttm/ttm_bo.c out: · line 1862
Quoted 10 lines
drivers/gpu/drm/ttm/ttm_bo.c +2
-0@@ -1849,8 +1853,10 @@ out:* already swapped buffer. */ +spin_lock (&glob->lru_lock);atomic_set (&bo->reserved,0 );wake_up_all (&bo->event_queue); +spin_unlock (&glob->lru_lock);kref_put (&bo->list_kref, ttm_bo_release_list);return ret; }
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Quoted 3 lines · Maarten Maathuis
- A few comments existed here and there that referred to a
bo->mutex.Signed-off-by Maarten Maathuis <[email protected]>
Quoted 100 lines
--- drivers/gpu/drm/ttm/ttm_bo.c | 6 +----- drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +- include/drm/ttm/ttm_bo_api.h | 3 +-- include/drm/ttm/ttm_bo_driver.h | 1 + 4 files changed, 4 insertions(+), 8 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-5@@ -46,7 +46,6 @@#include <linux/file.h> #include <linux/module.h> -#define TTM_ASSERT_LOCKED (param) #define TTM_DEBUG(fmt, arg...)#define TTM_BO_HASH_ORDER 13@@ -306,9 +305,6 @@ void ttm_bo_unreserve(struct ttm_buffer_object *bo) }EXPORT_SYMBOL (ttm_bo_unreserve); -/* -* Call bo->mutex locked. -*/ static int ttm_bo_add_ttm (struct ttm_buffer_object *bo,bool zero_alloc) {struct ttm_bo_device *bdev = bo->bdev;@@ -316,7 +312,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc)int ret =0 ;uint32_t page_flags =0 ; -TTM_ASSERT_LOCKED (&bo->mutex); +BUG_ON (!atomic_read (&bo->reserved)); bo->ttm =NULL ;if (bdev->need_dma32)drivers/gpu/drm/ttm/ttm_bo_vm.c +1
-1@@ -146,7 +146,7 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf)* since the mmap_sem is only held in read mode. However, we * modify only the caching bits of vma->vm_page_prot and * consider those bits protected by -* the bo->mutex, as we should be the only writers. +* bo->reserved, as we should be the only writers. * There shouldn't really be any readers of these bits except * within vm_insert_mixed()? fork? * include/drm/ttm/ttm_bo_api.h +1
-2@@ -35,7 +35,6 @@#include <linux/kref.h> #include <linux/list.h> #include <linux/wait.h> -#include <linux/mutex.h> #include <linux/mm.h> #include <linux/rbtree.h> #include <linux/bitmap.h> @@ -298,7 +297,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo)* @interruptible: Use interruptible wait. * @no_wait: Return immediately if buffer is busy. * -* This function must be called with the bo::mutex held, and makes +* This function must be called with bo->reserved held, and makes * sure any previous rendering to the buffer is completed. * Note: It might be necessary to block validations before the * wait by reserving the buffer. include/drm/ttm/ttm_bo_driver.h +1
-0@@ -37,6 +37,7 @@#include "linux/workqueue.h" #include "linux/fs.h" #include "linux/spinlock.h" +#include <linux/mutex.h> struct ttm_backend ;Signature · 14 lines
1.7.0 ------------------------------------------------------------------------------ Download Intel® Parallel Studio Eval Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta. http://p.sf.net/sfu/intel-sw-dev -- _______________________________________________ Dri-devel mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
Ping?
Quoted 95 lines · Jerome Glisse
Quoted 3 lines · Maarten Maathuis
- A few comments existed here and there that referred to a
bo->mutex.Signed-off-by Maarten Maathuis <[email protected]>Reviewed-by Jerome Glisse <[email protected]>Quoted 88 lines
---
drivers/gpu/drm/ttm/ttm_bo.c | 6 +-----
drivers/gpu/drm/ttm/ttm_bo_vm.c | 2 +-
include/drm/ttm/ttm_bo_api.h | 3 +--
include/drm/ttm/ttm_bo_driver.h | 1 +4 files changed, 4 insertions(+), 8 deletions(-)drivers/gpu/drm/ttm/ttm_bo.c +1
-5@@ -46,7 +46,6 @@ #include <linux/file.h> #include <linux/module.h> -#define TTM_ASSERT_LOCKED (param) #define TTM_DEBUG(fmt, arg...) #define TTM_BO_HASH_ORDER 13@@ -306,9 +305,6 @@ void ttm_bo_unreserve(struct ttm_buffer_object *bo) } EXPORT_SYMBOL(ttm_bo_unreserve); -/* -* Call bo->mutex locked. -*/ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc) { struct ttm_bo_device *bdev = bo->bdev;@@ -316,7 +312,7 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, bool zero_alloc) int ret = 0; uint32_t page_flags = 0; - TTM_ASSERT_LOCKED(&bo->mutex); + BUG_ON(!atomic_read(&bo->reserved)); bo->ttm = NULL; if (bdev->need_dma32)drivers/gpu/drm/ttm/ttm_bo_vm.c +1
-1@@ -146,7 +146,7 @@ static int ttm_bo_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) * since the mmap_sem is only held in read mode. However, we * modify only the caching bits of vma->vm_page_prot and * consider those bits protected by - * the bo->mutex, as we should be the only writers. + * bo->reserved, as we should be the only writers. * There shouldn't really be any readers of these bits except * within vm_insert_mixed()? fork? *include/drm/ttm/ttm_bo_api.h +1
-2@@ -35,7 +35,6 @@ #include <linux/kref.h> #include <linux/list.h> #include <linux/wait.h> -#include <linux/mutex.h> #include <linux/mm.h> #include <linux/rbtree.h> #include <linux/bitmap.h>@@ -298,7 +297,7 @@ ttm_bo_reference(struct ttm_buffer_object *bo) * @interruptible: Use interruptible wait. * @no_wait: Return immediately if buffer is busy. * - * This function must be called with the bo::mutex held, and makes + * This function must be called with bo->reserved held, and makes * sure any previous rendering to the buffer is completed. * Note: It might be necessary to block validations before the * wait by reserving the buffer.include/drm/ttm/ttm_bo_driver.h +1
-1@@ -37,6 +37,7 @@ #include "linux/workqueue.h" #include "linux/fs.h" #include "linux/spinlock.h" +#include <linux/mutex.h> struct ttm_backend; --1.7.0
Quoted 13 lines
Quoted 12 lines
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--
_______________________________________________
Dri-devel mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/dri-devel
------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs proactively, and fine-tune applications for parallel performance. See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
--