Re: [PATCH 1/4] drm/ttm: split no_wait argument in 2 GPU or reserve wait

2010-03-17 Thread Thomas Hellstrom
Jerome Glisse wrote:
 There is case where we want to be able to wait only for the
 GPU while not waiting for other buffer to be unreserved. This
 patch split the no_wait argument all the way down in the whole
 ttm path so that upper level can decide on what to wait on or
 not.

 This patch break the API to other modules, update to others
 driver are following in separate patches.

 Signed-off-by: Jerome Glisse jgli...@redhat.com
   
Acked-by: Thomas Hellstrom thellst...@vmware.com



 ---
  drivers/gpu/drm/ttm/ttm_bo.c  |   57 
  drivers/gpu/drm/ttm/ttm_bo_util.c |9 --
  include/drm/ttm/ttm_bo_api.h  |6 ++-
  include/drm/ttm/ttm_bo_driver.h   |   29 +++---
  4 files changed, 60 insertions(+), 41 deletions(-)

 diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
 index c7320ce..d2b2482 100644
 --- a/drivers/gpu/drm/ttm/ttm_bo.c
 +++ b/drivers/gpu/drm/ttm/ttm_bo.c
 @@ -357,7 +357,8 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, 
 bool zero_alloc)
  
  static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
 struct ttm_mem_reg *mem,
 -   bool evict, bool interruptible, bool no_wait)
 +   bool evict, bool interruptible,
 +   bool no_wait_reserve, bool no_wait_gpu)
  {
   struct ttm_bo_device *bdev = bo-bdev;
   bool old_is_pci = ttm_mem_reg_is_pci(bdev, bo-mem);
 @@ -402,12 +403,12 @@ static int ttm_bo_handle_move_mem(struct 
 ttm_buffer_object *bo,
  
   if (!(old_man-flags  TTM_MEMTYPE_FLAG_FIXED) 
   !(new_man-flags  TTM_MEMTYPE_FLAG_FIXED))
 - ret = ttm_bo_move_ttm(bo, evict, no_wait, mem);
 + ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, 
 mem);
   else if (bdev-driver-move)
   ret = bdev-driver-move(bo, evict, interruptible,
 -  no_wait, mem);
 +  no_wait_reserve, no_wait_gpu, mem);
   else
 - ret = ttm_bo_move_memcpy(bo, evict, no_wait, mem);
 + ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, 
 no_wait_gpu, mem);
  
   if (ret)
   goto out_err;
 @@ -606,7 +607,7 @@ void ttm_bo_unref(struct ttm_buffer_object **p_bo)
  EXPORT_SYMBOL(ttm_bo_unref);
  
  static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
 - bool no_wait)
 + bool no_wait_reserve, bool no_wait_gpu)
  {
   struct ttm_bo_device *bdev = bo-bdev;
   struct ttm_bo_global *glob = bo-glob;
 @@ -615,7 +616,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, 
 bool interruptible,
   int ret = 0;
  
   spin_lock(bo-lock);
 - ret = ttm_bo_wait(bo, false, interruptible, no_wait);
 + ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
   spin_unlock(bo-lock);
  
   if (unlikely(ret != 0)) {
 @@ -638,7 +639,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, 
 bool interruptible,
   placement.num_busy_placement = 0;
   bdev-driver-evict_flags(bo, placement);
   ret = ttm_bo_mem_space(bo, placement, evict_mem, interruptible,
 - no_wait);
 + no_wait_reserve, no_wait_gpu);
   if (ret) {
   if (ret != -ERESTARTSYS) {
   printk(KERN_ERR TTM_PFX
 @@ -650,7 +651,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, 
 bool interruptible,
   }
  
   ret = ttm_bo_handle_move_mem(bo, evict_mem, true, interruptible,
 -  no_wait);
 +  no_wait_reserve, no_wait_gpu);
   if (ret) {
   if (ret != -ERESTARTSYS)
   printk(KERN_ERR TTM_PFX Buffer eviction failed\n);
 @@ -670,7 +671,8 @@ out:
  
  static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
   uint32_t mem_type,
 - bool interruptible, bool no_wait)
 + bool interruptible, bool no_wait_reserve,
 + bool no_wait_gpu)
  {
   struct ttm_bo_global *glob = bdev-glob;
   struct ttm_mem_type_manager *man = bdev-man[mem_type];
 @@ -687,11 +689,11 @@ retry:
   bo = list_first_entry(man-lru, struct ttm_buffer_object, lru);
   kref_get(bo-list_kref);
  
 - ret = ttm_bo_reserve_locked(bo, false, true, false, 0);
 + ret = ttm_bo_reserve_locked(bo, false, no_wait_reserve, false, 0);
  
   if (unlikely(ret == -EBUSY)) {
   spin_unlock(glob-lru_lock);
 - if (likely(!no_wait))
 + if (likely(!no_wait_gpu))
   ret = ttm_bo_wait_unreserved(bo, interruptible);
  
   kref_put(bo-list_kref, ttm_bo_release_list);
 @@ -713,7 +715,7 @@ retry:
   while (put_count--)
   

[PATCH 1/4] drm/ttm: split no_wait argument in 2 GPU or reserve wait

2010-02-25 Thread Jerome Glisse
There is case where we want to be able to wait only for the
GPU while not waiting for other buffer to be unreserved. This
patch split the no_wait argument all the way down in the whole
ttm path so that upper level can decide on what to wait on or
not.

This patch break the API to other modules, update to others
driver are following in separate patches.

Signed-off-by: Jerome Glisse jgli...@redhat.com
---
 drivers/gpu/drm/ttm/ttm_bo.c  |   57 
 drivers/gpu/drm/ttm/ttm_bo_util.c |9 --
 include/drm/ttm/ttm_bo_api.h  |6 ++-
 include/drm/ttm/ttm_bo_driver.h   |   29 +++---
 4 files changed, 60 insertions(+), 41 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c7320ce..d2b2482 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -357,7 +357,8 @@ static int ttm_bo_add_ttm(struct ttm_buffer_object *bo, 
bool zero_alloc)
 
 static int ttm_bo_handle_move_mem(struct ttm_buffer_object *bo,
  struct ttm_mem_reg *mem,
- bool evict, bool interruptible, bool no_wait)
+ bool evict, bool interruptible,
+ bool no_wait_reserve, bool no_wait_gpu)
 {
struct ttm_bo_device *bdev = bo-bdev;
bool old_is_pci = ttm_mem_reg_is_pci(bdev, bo-mem);
@@ -402,12 +403,12 @@ static int ttm_bo_handle_move_mem(struct 
ttm_buffer_object *bo,
 
if (!(old_man-flags  TTM_MEMTYPE_FLAG_FIXED) 
!(new_man-flags  TTM_MEMTYPE_FLAG_FIXED))
-   ret = ttm_bo_move_ttm(bo, evict, no_wait, mem);
+   ret = ttm_bo_move_ttm(bo, evict, no_wait_reserve, no_wait_gpu, 
mem);
else if (bdev-driver-move)
ret = bdev-driver-move(bo, evict, interruptible,
-no_wait, mem);
+no_wait_reserve, no_wait_gpu, mem);
else
-   ret = ttm_bo_move_memcpy(bo, evict, no_wait, mem);
+   ret = ttm_bo_move_memcpy(bo, evict, no_wait_reserve, 
no_wait_gpu, mem);
 
if (ret)
goto out_err;
@@ -606,7 +607,7 @@ void ttm_bo_unref(struct ttm_buffer_object **p_bo)
 EXPORT_SYMBOL(ttm_bo_unref);
 
 static int ttm_bo_evict(struct ttm_buffer_object *bo, bool interruptible,
-   bool no_wait)
+   bool no_wait_reserve, bool no_wait_gpu)
 {
struct ttm_bo_device *bdev = bo-bdev;
struct ttm_bo_global *glob = bo-glob;
@@ -615,7 +616,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool 
interruptible,
int ret = 0;
 
spin_lock(bo-lock);
-   ret = ttm_bo_wait(bo, false, interruptible, no_wait);
+   ret = ttm_bo_wait(bo, false, interruptible, no_wait_gpu);
spin_unlock(bo-lock);
 
if (unlikely(ret != 0)) {
@@ -638,7 +639,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool 
interruptible,
placement.num_busy_placement = 0;
bdev-driver-evict_flags(bo, placement);
ret = ttm_bo_mem_space(bo, placement, evict_mem, interruptible,
-   no_wait);
+   no_wait_reserve, no_wait_gpu);
if (ret) {
if (ret != -ERESTARTSYS) {
printk(KERN_ERR TTM_PFX
@@ -650,7 +651,7 @@ static int ttm_bo_evict(struct ttm_buffer_object *bo, bool 
interruptible,
}
 
ret = ttm_bo_handle_move_mem(bo, evict_mem, true, interruptible,
-no_wait);
+no_wait_reserve, no_wait_gpu);
if (ret) {
if (ret != -ERESTARTSYS)
printk(KERN_ERR TTM_PFX Buffer eviction failed\n);
@@ -670,7 +671,8 @@ out:
 
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
uint32_t mem_type,
-   bool interruptible, bool no_wait)
+   bool interruptible, bool no_wait_reserve,
+   bool no_wait_gpu)
 {
struct ttm_bo_global *glob = bdev-glob;
struct ttm_mem_type_manager *man = bdev-man[mem_type];
@@ -687,11 +689,11 @@ retry:
bo = list_first_entry(man-lru, struct ttm_buffer_object, lru);
kref_get(bo-list_kref);
 
-   ret = ttm_bo_reserve_locked(bo, false, true, false, 0);
+   ret = ttm_bo_reserve_locked(bo, false, no_wait_reserve, false, 0);
 
if (unlikely(ret == -EBUSY)) {
spin_unlock(glob-lru_lock);
-   if (likely(!no_wait))
+   if (likely(!no_wait_gpu))
ret = ttm_bo_wait_unreserved(bo, interruptible);
 
kref_put(bo-list_kref, ttm_bo_release_list);
@@ -713,7 +715,7 @@ retry:
while (put_count--)
kref_put(bo-list_kref, ttm_bo_ref_bug);
 
-   ret = ttm_bo_evict(bo,