Re: [PATCH 2/3] drm/ttm: add new function to check if bo is allowable to evict or swapout

2017-12-24 Thread Chunming Zhou

The series is Reviewed-by: Chuming Zhou 


On 2017年12月25日 14:17, He, Roger wrote:

+ Thomas

-Original Message-
From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Roger He
Sent: Monday, December 25, 2017 2:08 PM
To: dri-devel@lists.freedesktop.org
Cc: He, Roger ; Koenig, Christian 
Subject: [PATCH 2/3] drm/ttm: add new function to check if bo is allowable to 
evict or swapout

extract a function as ttm_bo_evict_swapout_allowable since eviction and swapout 
can share same logic.

v2: modify commit message and add description in the code

Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac
Signed-off-by: Roger He 
---
  drivers/gpu/drm/ttm/ttm_bo.c | 40 ++--
  1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 
e7595b4..5e64091 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -706,6 +706,34 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object 
*bo,  }  EXPORT_SYMBOL(ttm_bo_eviction_valuable);
  
+/**

+ * Check the target bo is allowable to be evicted or swapout, including cases:
+ *
+ * a. if share same reservation object with ctx->resv, have assumption
+ * reservation objects should already be locked, so not lock again and
+ * return true directly when either the opreation
+allow_reserved_eviction
+ * or the target bo already is in delayed free list;
+ *
+ * b. Otherwise, trylock it.
+ */
+static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
+   struct ttm_operation_ctx *ctx, bool *locked) {
+   bool ret = false;
+
+   *locked = false;
+   if (bo->resv == ctx->resv) {
+   reservation_object_assert_held(bo->resv);
+   if (ctx->allow_reserved_eviction || !list_empty(>ddestroy))
+   ret = true;
+   } else {
+   *locked = reservation_object_trylock(bo->resv);
+   ret = *locked;
+   }
+
+   return ret;
+}
+
  static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
   uint32_t mem_type,
   const struct ttm_place *place, @@ -721,21 
+749,13 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, >lru[i], lru) {
-   if (bo->resv == ctx->resv) {
-   if (!ctx->allow_reserved_eviction &&
-   list_empty(>ddestroy))
-   continue;
-   } else {
-   locked = reservation_object_trylock(bo->resv);
-   if (!locked)
-   continue;
-   }
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   continue;
  
  			if (place && !bdev->driver->eviction_valuable(bo,

  place)) {
if (locked)
reservation_object_unlock(bo->resv);
-   locked = false;
continue;
}
break;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 104275] Stoney Ridge laptop display goes blank after HDMI gets plugged/unplugged in extended mode.

2017-12-24 Thread bugzilla-daemon
https://bugs.freedesktop.org/show_bug.cgi?id=104275

--- Comment #10 from AceLan Kao  ---
Hi Harry,

I'm wondering if there is also an equivalence method to fix it on v4.13 kernel.

-- 
You are receiving this mail because:
You are the assignee for the bug.___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH 2/3] drm/ttm: add new function to check if bo is allowable to evict or swapout

2017-12-24 Thread He, Roger
+ Thomas 

-Original Message-
From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Roger He
Sent: Monday, December 25, 2017 2:08 PM
To: dri-devel@lists.freedesktop.org
Cc: He, Roger ; Koenig, Christian 
Subject: [PATCH 2/3] drm/ttm: add new function to check if bo is allowable to 
evict or swapout

extract a function as ttm_bo_evict_swapout_allowable since eviction and swapout 
can share same logic.

v2: modify commit message and add description in the code

Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac
Signed-off-by: Roger He 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c index 
e7595b4..5e64091 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -706,6 +706,34 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object 
*bo,  }  EXPORT_SYMBOL(ttm_bo_eviction_valuable);
 
+/**
+ * Check the target bo is allowable to be evicted or swapout, including cases:
+ *
+ * a. if share same reservation object with ctx->resv, have assumption
+ * reservation objects should already be locked, so not lock again and
+ * return true directly when either the opreation 
+allow_reserved_eviction
+ * or the target bo already is in delayed free list;
+ *
+ * b. Otherwise, trylock it.
+ */
+static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
+   struct ttm_operation_ctx *ctx, bool *locked) {
+   bool ret = false;
+
+   *locked = false;
+   if (bo->resv == ctx->resv) {
+   reservation_object_assert_held(bo->resv);
+   if (ctx->allow_reserved_eviction || !list_empty(>ddestroy))
+   ret = true;
+   } else {
+   *locked = reservation_object_trylock(bo->resv);
+   ret = *locked;
+   }
+
+   return ret;
+}
+
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
   uint32_t mem_type,
   const struct ttm_place *place, @@ -721,21 
+749,13 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, >lru[i], lru) {
-   if (bo->resv == ctx->resv) {
-   if (!ctx->allow_reserved_eviction &&
-   list_empty(>ddestroy))
-   continue;
-   } else {
-   locked = reservation_object_trylock(bo->resv);
-   if (!locked)
-   continue;
-   }
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   continue;
 
if (place && !bdev->driver->eviction_valuable(bo,
  place)) {
if (locked)
reservation_object_unlock(bo->resv);
-   locked = false;
continue;
}
break;
--
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 3/3] drm/ttm: enable swapout for reserved BOs during allocation

2017-12-24 Thread Roger He
if the bo shares same reservation object then not lock it again
at swapout time to make it possible to swap out.

v2: refine the commmit message

Change-Id: I1e87954564f38ad298bf6e4ff88c9f26f291a62d
Signed-off-by: Roger He 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 15 +++
 drivers/gpu/drm/ttm/ttm_memory.c | 12 
 include/drm/ttm/ttm_bo_api.h |  3 ++-
 3 files changed, 21 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 5e64091..ec42bb3 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -1697,18 +1697,20 @@ EXPORT_SYMBOL(ttm_bo_synccpu_write_release);
  * A buffer object shrink method that tries to swap out the first
  * buffer object on the bo_global::swap_lru list.
  */
-int ttm_bo_swapout(struct ttm_bo_global *glob)
+int ttm_bo_swapout(struct ttm_bo_global *glob, struct ttm_operation_ctx *ctx)
 {
struct ttm_buffer_object *bo;
int ret = -EBUSY;
+   bool locked;
unsigned i;
 
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, >swap_lru[i], swap) {
-   ret = reservation_object_trylock(bo->resv) ? 0 : -EBUSY;
-   if (!ret)
+   if (ttm_bo_evict_swapout_allowable(bo, ctx, )) {
+   ret = 0;
break;
+   }
}
if (!ret)
break;
@@ -1784,7 +1786,12 @@ EXPORT_SYMBOL(ttm_bo_swapout);
 
 void ttm_bo_swapout_all(struct ttm_bo_device *bdev)
 {
-   while (ttm_bo_swapout(bdev->glob) == 0)
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false
+   };
+
+   while (ttm_bo_swapout(bdev->glob, ) == 0)
;
 }
 EXPORT_SYMBOL(ttm_bo_swapout_all);
diff --git a/drivers/gpu/drm/ttm/ttm_memory.c b/drivers/gpu/drm/ttm/ttm_memory.c
index 102b326..aa0c381 100644
--- a/drivers/gpu/drm/ttm/ttm_memory.c
+++ b/drivers/gpu/drm/ttm/ttm_memory.c
@@ -211,7 +211,7 @@ static bool ttm_zones_above_swap_target(struct 
ttm_mem_global *glob,
  */
 
 static void ttm_shrink(struct ttm_mem_global *glob, bool from_wq,
-  uint64_t extra)
+   uint64_t extra, struct ttm_operation_ctx *ctx)
 {
int ret;
 
@@ -219,7 +219,7 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool 
from_wq,
 
while (ttm_zones_above_swap_target(glob, from_wq, extra)) {
spin_unlock(>lock);
-   ret = ttm_bo_swapout(glob->bo_glob);
+   ret = ttm_bo_swapout(glob->bo_glob, ctx);
spin_lock(>lock);
if (unlikely(ret != 0))
break;
@@ -230,10 +230,14 @@ static void ttm_shrink(struct ttm_mem_global *glob, bool 
from_wq,
 
 static void ttm_shrink_work(struct work_struct *work)
 {
+   struct ttm_operation_ctx ctx = {
+   .interruptible = false,
+   .no_wait_gpu = false
+   };
struct ttm_mem_global *glob =
container_of(work, struct ttm_mem_global, work);
 
-   ttm_shrink(glob, true, 0ULL);
+   ttm_shrink(glob, true, 0ULL, );
 }
 
 static int ttm_mem_init_kernel_zone(struct ttm_mem_global *glob,
@@ -520,7 +524,7 @@ static int ttm_mem_global_alloc_zone(struct ttm_mem_global 
*glob,
return -ENOMEM;
if (unlikely(count-- == 0))
return -ENOMEM;
-   ttm_shrink(glob, false, memory + (memory >> 2) + 16);
+   ttm_shrink(glob, false, memory + (memory >> 2) + 16, ctx);
}
 
return 0;
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index 24a8db7..f1c74c2 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -752,7 +752,8 @@ ssize_t ttm_bo_io(struct ttm_bo_device *bdev, struct file 
*filp,
  const char __user *wbuf, char __user *rbuf,
  size_t count, loff_t *f_pos, bool write);
 
-int ttm_bo_swapout(struct ttm_bo_global *glob);
+int ttm_bo_swapout(struct ttm_bo_global *glob,
+   struct ttm_operation_ctx *ctx);
 void ttm_bo_swapout_all(struct ttm_bo_device *bdev);
 int ttm_bo_wait_unreserved(struct ttm_buffer_object *bo);
 #endif
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 2/3] drm/ttm: add new function to check if bo is allowable to evict or swapout

2017-12-24 Thread Roger He
extract a function as ttm_bo_evict_swapout_allowable since eviction and
swapout can share same logic.

v2: modify commit message and add description in the code

Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac
Signed-off-by: Roger He 
---
 drivers/gpu/drm/ttm/ttm_bo.c | 40 ++--
 1 file changed, 30 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index e7595b4..5e64091 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -706,6 +706,34 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object *bo,
 }
 EXPORT_SYMBOL(ttm_bo_eviction_valuable);
 
+/**
+ * Check the target bo is allowable to be evicted or swapout, including cases:
+ *
+ * a. if share same reservation object with ctx->resv, have assumption
+ * reservation objects should already be locked, so not lock again and
+ * return true directly when either the opreation allow_reserved_eviction
+ * or the target bo already is in delayed free list;
+ *
+ * b. Otherwise, trylock it.
+ */
+static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
+   struct ttm_operation_ctx *ctx, bool *locked)
+{
+   bool ret = false;
+
+   *locked = false;
+   if (bo->resv == ctx->resv) {
+   reservation_object_assert_held(bo->resv);
+   if (ctx->allow_reserved_eviction || !list_empty(>ddestroy))
+   ret = true;
+   } else {
+   *locked = reservation_object_trylock(bo->resv);
+   ret = *locked;
+   }
+
+   return ret;
+}
+
 static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
   uint32_t mem_type,
   const struct ttm_place *place,
@@ -721,21 +749,13 @@ static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
spin_lock(>lru_lock);
for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
list_for_each_entry(bo, >lru[i], lru) {
-   if (bo->resv == ctx->resv) {
-   if (!ctx->allow_reserved_eviction &&
-   list_empty(>ddestroy))
-   continue;
-   } else {
-   locked = reservation_object_trylock(bo->resv);
-   if (!locked)
-   continue;
-   }
+   if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
+   continue;
 
if (place && !bdev->driver->eviction_valuable(bo,
  place)) {
if (locked)
reservation_object_unlock(bo->resv);
-   locked = false;
continue;
}
break;
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 1/3] drm/ttm: use an operation ctx for ttm_tt_bind

2017-12-24 Thread Roger He
forward the operation context to ttm_tt_bind as well,
and the ultimate goal is swapout enablement for reserved BOs.

v2: use common term rather than amd specific

Change-Id: I42a7df8c50e1ce3b527ee9cb78809f8e58136f07
Signed-off-by: Roger He 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 2 +-
 drivers/gpu/drm/nouveau/nouveau_bo.c| 2 +-
 drivers/gpu/drm/radeon/radeon_ttm.c | 2 +-
 drivers/gpu/drm/ttm/ttm_bo.c| 2 +-
 drivers/gpu/drm/ttm/ttm_bo_util.c   | 2 +-
 drivers/gpu/drm/ttm/ttm_tt.c| 9 +++--
 include/drm/ttm/ttm_bo_driver.h | 3 ++-
 7 files changed, 10 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 044f5b5..e4bb435 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -497,7 +497,7 @@ static int amdgpu_move_vram_ram(struct ttm_buffer_object 
*bo, bool evict,
goto out_cleanup;
}
 
-   r = ttm_tt_bind(bo->ttm, _mem);
+   r = ttm_tt_bind(bo->ttm, _mem, ctx);
if (unlikely(r)) {
goto out_cleanup;
}
diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index b141c27..a83ba6a 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1218,7 +1218,7 @@ nouveau_bo_move_flipd(struct ttm_buffer_object *bo, bool 
evict, bool intr,
if (ret)
return ret;
 
-   ret = ttm_tt_bind(bo->ttm, _reg);
+   ret = ttm_tt_bind(bo->ttm, _reg, );
if (ret)
goto out;
 
diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 9424b81..2b74ba1b 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -339,7 +339,7 @@ static int radeon_move_vram_ram(struct ttm_buffer_object 
*bo,
goto out_cleanup;
}
 
-   r = ttm_tt_bind(bo->ttm, _mem);
+   r = ttm_tt_bind(bo->ttm, _mem, );
if (unlikely(r)) {
goto out_cleanup;
}
diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index c59f572..e7595b4 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -300,7 +300,7 @@ static int ttm_bo_handle_move_mem(struct ttm_buffer_object 
*bo,
goto out_err;
 
if (mem->mem_type != TTM_PL_SYSTEM) {
-   ret = ttm_tt_bind(bo->ttm, mem);
+   ret = ttm_tt_bind(bo->ttm, mem, ctx);
if (ret)
goto out_err;
}
diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c 
b/drivers/gpu/drm/ttm/ttm_bo_util.c
index b7eb507..153de1b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -73,7 +73,7 @@ int ttm_bo_move_ttm(struct ttm_buffer_object *bo,
return ret;
 
if (new_mem->mem_type != TTM_PL_SYSTEM) {
-   ret = ttm_tt_bind(ttm, new_mem);
+   ret = ttm_tt_bind(ttm, new_mem, ctx);
if (unlikely(ret != 0))
return ret;
}
diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index b48d7a0..5a046a3 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -261,12 +261,9 @@ void ttm_tt_unbind(struct ttm_tt *ttm)
}
 }
 
-int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem)
+int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
+   struct ttm_operation_ctx *ctx)
 {
-   struct ttm_operation_ctx ctx = {
-   .interruptible = false,
-   .no_wait_gpu = false
-   };
int ret = 0;
 
if (!ttm)
@@ -275,7 +272,7 @@ int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg 
*bo_mem)
if (ttm->state == tt_bound)
return 0;
 
-   ret = ttm->bdev->driver->ttm_tt_populate(ttm, );
+   ret = ttm->bdev->driver->ttm_tt_populate(ttm, ctx);
if (ret)
return ret;
 
diff --git a/include/drm/ttm/ttm_bo_driver.h b/include/drm/ttm/ttm_bo_driver.h
index 84860ec..94064b1 100644
--- a/include/drm/ttm/ttm_bo_driver.h
+++ b/include/drm/ttm/ttm_bo_driver.h
@@ -650,7 +650,8 @@ void ttm_dma_tt_fini(struct ttm_dma_tt *ttm_dma);
  *
  * Bind the pages of @ttm to an aperture location identified by @bo_mem
  */
-int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem);
+int ttm_tt_bind(struct ttm_tt *ttm, struct ttm_mem_reg *bo_mem,
+   struct ttm_operation_ctx *ctx);
 
 /**
  * ttm_ttm_destroy:
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check bo is allowable to evict or swapout

2017-12-24 Thread He, Roger
-Original Message-
From: dri-devel [mailto:dri-devel-boun...@lists.freedesktop.org] On Behalf Of 
Thomas Hellstrom
Sent: Thursday, December 21, 2017 3:51 PM
To: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 6/7] drm/ttm: add ttm_bo_evict_swapout_allowable to check 
bo is allowable to evict or swapout

On 12/20/2017 11:35 AM, Roger He wrote:
> extract this function since eviction and swapout share same logic

But it's only used in eviction?

Yes, currently it only used in eviction. And will be used in Swapout.

>
> Change-Id: I80a475a93fceed8d66d74a1832c815a0756341ac
> Signed-off-by: Roger He 
> ---
>   drivers/gpu/drm/ttm/ttm_bo.c | 29 +++--
>   1 file changed, 19 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/ttm/ttm_bo.c 
> b/drivers/gpu/drm/ttm/ttm_bo.c index e7595b4..313925c 100644
> --- a/drivers/gpu/drm/ttm/ttm_bo.c
> +++ b/drivers/gpu/drm/ttm/ttm_bo.c
> @@ -706,6 +706,23 @@ bool ttm_bo_eviction_valuable(struct ttm_buffer_object 
> *bo,
>   }
>   EXPORT_SYMBOL(ttm_bo_eviction_valuable);
>   
> +static bool ttm_bo_evict_swapout_allowable(struct ttm_buffer_object *bo,
> + struct ttm_operation_ctx *ctx, bool *locked)

Could we have a description in the code what this function actually 
does? admittedly it checks whether a swapout or eviction is allowable, 
but it aso performs a recursive tryreserve(), and that is of value to any 
future code reader.?

Ok.

Thanks
Roger(Hongbo.He)

/Thomas


> +{
> + bool ret = false;
> +
> + *locked = false;
> + if (bo->resv == ctx->resv) {
> + if (ctx->allow_reserved_eviction || !list_empty(>ddestroy))
> + ret = true;
> + } else {
> + *locked = reservation_object_trylock(bo->resv);
> + ret = *locked;
> + }
> +
> + return ret;
> +}
> +
>   static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>  uint32_t mem_type,
>  const struct ttm_place *place, @@ -721,21 
> +738,13 @@ 
> static int ttm_mem_evict_first(struct ttm_bo_device *bdev,
>   spin_lock(>lru_lock);
>   for (i = 0; i < TTM_MAX_BO_PRIORITY; ++i) {
>   list_for_each_entry(bo, >lru[i], lru) {
> - if (bo->resv == ctx->resv) {
> - if (!ctx->allow_reserved_eviction &&
> - list_empty(>ddestroy))
> - continue;
> - } else {
> - locked = reservation_object_trylock(bo->resv);
> - if (!locked)
> - continue;
> - }
> + if (!ttm_bo_evict_swapout_allowable(bo, ctx, ))
> + continue;
>   
>   if (place && !bdev->driver->eviction_valuable(bo,
> place)) {
>   if (locked)
>   reservation_object_unlock(bo->resv);
> - locked = false;
>   continue;
>   }
>   break;


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 11/12] staging: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/staging/vboxvideo/vbox_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/staging/vboxvideo/vbox_ttm.c 
b/drivers/staging/vboxvideo/vbox_ttm.c
index 4eb410a..4da1723 100644
--- a/drivers/staging/vboxvideo/vbox_ttm.c
+++ b/drivers/staging/vboxvideo/vbox_ttm.c
@@ -241,7 +241,6 @@ static struct ttm_bo_driver vbox_bo_driver = {
.verify_access = vbox_bo_verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int vbox_mm_init(struct vbox_private *vbox)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 12/12] drm/ttm: remove ttm_bo_default_io_mem_pfn

2017-12-24 Thread Tan Xiaojun
No one will use this function except ttm_bo_io_mem_pfn() now, so move
the calculation of ttm_bo_default_io_mem_pfn() into ttm_bo_io_mem_pfn()
and do some cleanup.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 11 ++-
 include/drm/ttm/ttm_bo_api.h| 11 ---
 2 files changed, 2 insertions(+), 20 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 292d157..6edc19f 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -100,7 +100,8 @@ static unsigned long ttm_bo_io_mem_pfn(struct 
ttm_buffer_object *bo,
if (bdev->driver->io_mem_pfn)
return bdev->driver->io_mem_pfn(bo, page_offset);
 
-   return ttm_bo_default_io_mem_pfn(bo, page_offset);
+   return ((bo->mem.bus.base + bo->mem.bus.offset) >> PAGE_SHIFT)
+   + page_offset;
 }
 
 static int ttm_bo_vm_fault(struct vm_fault *vmf)
@@ -415,14 +416,6 @@ static struct ttm_buffer_object *ttm_bo_vm_lookup(struct 
ttm_bo_device *bdev,
return bo;
 }
 
-unsigned long ttm_bo_default_io_mem_pfn(struct ttm_buffer_object *bo,
-   unsigned long page_offset)
-{
-   return ((bo->mem.bus.base + bo->mem.bus.offset) >> PAGE_SHIFT)
-   + page_offset;
-}
-EXPORT_SYMBOL(ttm_bo_default_io_mem_pfn);
-
 int ttm_bo_mmap(struct file *filp, struct vm_area_struct *vma,
struct ttm_bo_device *bdev)
 {
diff --git a/include/drm/ttm/ttm_bo_api.h b/include/drm/ttm/ttm_bo_api.h
index fa07be1..0b1ce05 100644
--- a/include/drm/ttm/ttm_bo_api.h
+++ b/include/drm/ttm/ttm_bo_api.h
@@ -711,17 +711,6 @@ extern int ttm_fbdev_mmap(struct vm_area_struct *vma,
  struct ttm_buffer_object *bo);
 
 /**
- * ttm_bo_default_iomem_pfn - get a pfn for a page offset
- *
- * @bo: the BO we need to look up the pfn for
- * @page_offset: offset inside the BO to look up.
- *
- * Calculate the PFN for iomem based mappings during page fault
- */
-unsigned long ttm_bo_default_io_mem_pfn(struct ttm_buffer_object *bo,
-   unsigned long page_offset);
-
-/**
  * ttm_bo_mmap - mmap out of the ttm device address space.
  *
  * @filp:  filp as input from the mmap method.
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 07/12] drm/qxl: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/qxl/qxl_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/qxl/qxl_ttm.c b/drivers/gpu/drm/qxl/qxl_ttm.c
index ab48238..a86eaf9 100644
--- a/drivers/gpu/drm/qxl/qxl_ttm.c
+++ b/drivers/gpu/drm/qxl/qxl_ttm.c
@@ -393,7 +393,6 @@ static struct ttm_bo_driver qxl_bo_driver = {
.verify_access = _verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
.move_notify = _bo_move_notify,
 };
 
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 08/12] drm/radeon: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 6ada64d..8595c76 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -844,7 +844,6 @@ static struct ttm_bo_driver radeon_bo_driver = {
.fault_reserve_notify = _bo_fault_reserve_notify,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int radeon_ttm_init(struct radeon_device *rdev)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 06/12] drm/nouveau: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/nouveau/nouveau_bo.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/nouveau/nouveau_bo.c 
b/drivers/gpu/drm/nouveau/nouveau_bo.c
index 435ff86..8de82a3 100644
--- a/drivers/gpu/drm/nouveau/nouveau_bo.c
+++ b/drivers/gpu/drm/nouveau/nouveau_bo.c
@@ -1667,5 +1667,4 @@ struct ttm_bo_driver nouveau_bo_driver = {
.fault_reserve_notify = _ttm_fault_reserve_notify,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 09/12] drm/virtio: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/virtio/virtgpu_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_ttm.c 
b/drivers/gpu/drm/virtio/virtgpu_ttm.c
index cd389c5..4a12434 100644
--- a/drivers/gpu/drm/virtio/virtgpu_ttm.c
+++ b/drivers/gpu/drm/virtio/virtgpu_ttm.c
@@ -431,7 +431,6 @@ static struct ttm_bo_driver virtio_gpu_bo_driver = {
.verify_access = _gpu_verify_access,
.io_mem_reserve = _gpu_ttm_io_mem_reserve,
.io_mem_free = _gpu_ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
.move_notify = _gpu_bo_move_notify,
.swap_notify = _gpu_bo_swap_notify,
 };
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 10/12] drm/vmwgfx: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c 
b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
index c705632..828dd59 100644
--- a/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
+++ b/drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c
@@ -859,5 +859,4 @@ struct ttm_bo_driver vmw_bo_driver = {
.fault_reserve_notify = _ttm_fault_reserve_notify,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 03/12] drm/bochs: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/bochs/bochs_mm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/bochs/bochs_mm.c b/drivers/gpu/drm/bochs/bochs_mm.c
index c4cadb6..857755a 100644
--- a/drivers/gpu/drm/bochs/bochs_mm.c
+++ b/drivers/gpu/drm/bochs/bochs_mm.c
@@ -205,7 +205,6 @@ struct ttm_bo_driver bochs_bo_driver = {
.verify_access = bochs_bo_verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int bochs_mm_init(struct bochs_device *bochs)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 01/12] drm/ttm: add ttm_bo_io_mem_pfn to check io_mem_pfn

2017-12-24 Thread Tan Xiaojun
The io_mem_pfn field was added in commit ea642c3216cb ("drm/ttm: add
io_mem_pfn callback") and is called unconditionally. However, not all
drivers were updated to set it.

Use the ttm_bo_default_io_mem_pfn function if a driver did not set its
own. And add new function ttm_bo_io_mem_pfn() as wrapper.

Signed-off-by: Michal Srb 
Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index c8ebb75..292d157 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -92,6 +92,17 @@ static int ttm_bo_vm_fault_idle(struct ttm_buffer_object *bo,
return ret;
 }
 
+static unsigned long ttm_bo_io_mem_pfn(struct ttm_buffer_object *bo,
+  unsigned long page_offset)
+{
+   struct ttm_bo_device *bdev = bo->bdev;
+
+   if (bdev->driver->io_mem_pfn)
+   return bdev->driver->io_mem_pfn(bo, page_offset);
+
+   return ttm_bo_default_io_mem_pfn(bo, page_offset);
+}
+
 static int ttm_bo_vm_fault(struct vm_fault *vmf)
 {
struct vm_area_struct *vma = vmf->vma;
@@ -234,7 +245,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
if (bo->mem.bus.is_iomem) {
/* Iomem should not be marked encrypted */
cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
-   pfn = bdev->driver->io_mem_pfn(bo, page_offset);
+   pfn = ttm_bo_io_mem_pfn(bo, page_offset);
} else {
page = ttm->pages[page_offset];
if (unlikely(!page && i == 0)) {
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 05/12] drm/mgag200: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/mgag200/mgag200_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/mgag200/mgag200_ttm.c 
b/drivers/gpu/drm/mgag200/mgag200_ttm.c
index 3e7e1cd..89b550f 100644
--- a/drivers/gpu/drm/mgag200/mgag200_ttm.c
+++ b/drivers/gpu/drm/mgag200/mgag200_ttm.c
@@ -237,7 +237,6 @@ struct ttm_bo_driver mgag200_bo_driver = {
.verify_access = mgag200_bo_verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int mgag200_mm_init(struct mga_device *mdev)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 04/12] drm/cirrus: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/cirrus/cirrus_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/cirrus/cirrus_ttm.c 
b/drivers/gpu/drm/cirrus/cirrus_ttm.c
index 1ff1838..2c652af 100644
--- a/drivers/gpu/drm/cirrus/cirrus_ttm.c
+++ b/drivers/gpu/drm/cirrus/cirrus_ttm.c
@@ -237,7 +237,6 @@ struct ttm_bo_driver cirrus_bo_driver = {
.verify_access = cirrus_bo_verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int cirrus_mm_init(struct cirrus_device *cirrus)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 02/12] drm/ast: remove the default io_mem_pfn set

2017-12-24 Thread Tan Xiaojun
The default interface situation has been taken into the framework, so
remove the default set of each module.

Signed-off-by: Tan Xiaojun 
---
 drivers/gpu/drm/ast/ast_ttm.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/drivers/gpu/drm/ast/ast_ttm.c b/drivers/gpu/drm/ast/ast_ttm.c
index 696a15d..fdd521d 100644
--- a/drivers/gpu/drm/ast/ast_ttm.c
+++ b/drivers/gpu/drm/ast/ast_ttm.c
@@ -237,7 +237,6 @@ struct ttm_bo_driver ast_bo_driver = {
.verify_access = ast_bo_verify_access,
.io_mem_reserve = _ttm_io_mem_reserve,
.io_mem_free = _ttm_io_mem_free,
-   .io_mem_pfn = ttm_bo_default_io_mem_pfn,
 };
 
 int ast_mm_init(struct ast_private *ast)
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 00/12] drm: add check if io_mem_pfn is NULL and cleanup

2017-12-24 Thread Tan Xiaojun
I found an OOPS when I used the mainline kernel for graphical tests in Hisilicon
D05, I do not know how to solve this problem until I saw your discussion on this
issue a month ago:

https://lists.freedesktop.org/archives/dri-devel/2017-November/159046.html

And my problem can be solved perfectly by your solution.

This is important for me, I want to solve this problem as soon as possible. So
I follow the result of your discussion, make and send these patches below.

If anything is not good, please point it out, thanks.

Change logs of v2:
 * add new function to instead of ttm_bo_default_io_mem_pfn() and
   do some cleanup.

Tan Xiaojun (12):
  drm/ttm: add ttm_bo_io_mem_pfn to check io_mem_pfn
  drm/ast: remove the default io_mem_pfn set
  drm/bochs: remove the default io_mem_pfn set
  drm/cirrus: remove the default io_mem_pfn set
  drm/mgag200: remove the default io_mem_pfn set
  drm/nouveau: remove the default io_mem_pfn set
  drm/qxl: remove the default io_mem_pfn set
  drm/radeon: remove the default io_mem_pfn set
  drm/virtio: remove the default io_mem_pfn set
  drm/vmwgfx: remove the default io_mem_pfn set
  staging: remove the default io_mem_pfn set
  drm/ttm: remove ttm_bo_default_io_mem_pfn

 drivers/gpu/drm/ast/ast_ttm.c  |  1 -
 drivers/gpu/drm/bochs/bochs_mm.c   |  1 -
 drivers/gpu/drm/cirrus/cirrus_ttm.c|  1 -
 drivers/gpu/drm/mgag200/mgag200_ttm.c  |  1 -
 drivers/gpu/drm/nouveau/nouveau_bo.c   |  1 -
 drivers/gpu/drm/qxl/qxl_ttm.c  |  1 -
 drivers/gpu/drm/radeon/radeon_ttm.c|  1 -
 drivers/gpu/drm/ttm/ttm_bo_vm.c| 22 +-
 drivers/gpu/drm/virtio/virtgpu_ttm.c   |  1 -
 drivers/gpu/drm/vmwgfx/vmwgfx_buffer.c |  1 -
 drivers/staging/vboxvideo/vbox_ttm.c   |  1 -
 include/drm/ttm/ttm_bo_api.h   | 11 ---
 12 files changed, 13 insertions(+), 30 deletions(-)

-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 01/12] drm/ttm: Use ttm_bo_default_io_mem_pfn if io_mem_pfn is NULL

2017-12-24 Thread Tan Xiaojun
On 2017/12/24 17:27, Christian König wrote:
> Am 24.12.2017 um 07:14 schrieb Tan Xiaojun:
>> From: Michal Srb 
>>
>> The io_mem_pfn field was added in commit 
>> ea642c3216cb2a60d1c0e760ae47ee85c9c16447
>> and is called unconditionally. However, not all drivers were updated to set 
>> it.
>>
>> Use the ttm_bo_default_io_mem_pfn function if a driver did not set its own.
>>
>> Signed-off-by: Michal Srb 
>> ---
>>   drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 -
>>   1 file changed, 4 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c 
>> b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> index c8ebb75..e25a99b 100644
>> --- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> +++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
>> @@ -234,7 +234,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
>>   if (bo->mem.bus.is_iomem) {
>>   /* Iomem should not be marked encrypted */
>>   cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
>> -pfn = bdev->driver->io_mem_pfn(bo, page_offset);
>> +if (bdev->driver->io_mem_pfn)
>> +pfn = bdev->driver->io_mem_pfn(bo, page_offset);
>> +else
>> +pfn = ttm_bo_default_io_mem_pfn(bo, page_offset);
> 
> Please move this check into a new function ttm_bo_io_mem_pfn().
> 
> You can then move the calculation of ttm_bo_default_io_mem_pfn() into this 
> new function in patch #12 as well.
> 
> Regards,
> Christian.
> 

OK. Thank you for your reply. I will modify it and send v2.

Thanks.
Xiaojun.

>>   } else {
>>   page = ttm->pages[page_offset];
>>   if (unlikely(!page && i == 0)) {
> 
> 
> .
> 


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v1] drm/i915: Try EDID bitbanging on HDMI after failed read

2017-12-24 Thread Stefan Brüns
The ACK/NACK implementation as found in e.g. the G965 has the falling
clock edge and the release of the data line to ACK the received byte
happen at the same time.

Some HDMI-to-VGA converters apparently read the ACK not in the middle of
the clock high phase, but at the rising clock edge, so instead of an ACK
sometimes a NACK is read and the slave (i.e. the EDID ROM) ends the
transfer.

The bitbanging releases the data line for the ACK only 1/4 bit time after
the falling clock edge, so a slave will see the correct value no matter
if is samples at the rising or the falling clock edge or in the center.

Fallback to bitbanging is already done for the CRT connector.

Bug: https://bugs.freedesktop.org/show_bug.cgi?id=92685

Signed-off-by: Stefan Brüns 

---

 drivers/gpu/drm/i915/intel_hdmi.c | 14 +++---
 1 file changed, 11 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_hdmi.c 
b/drivers/gpu/drm/i915/intel_hdmi.c
index 4dea833f9d1b..847cda4c017c 100644
--- a/drivers/gpu/drm/i915/intel_hdmi.c
+++ b/drivers/gpu/drm/i915/intel_hdmi.c
@@ -1573,12 +1573,20 @@ intel_hdmi_set_edid(struct drm_connector *connector)
struct intel_hdmi *intel_hdmi = intel_attached_hdmi(connector);
struct edid *edid;
bool connected = false;
+   struct i2c_adapter *i2c;
 
intel_display_power_get(dev_priv, POWER_DOMAIN_GMBUS);
 
-   edid = drm_get_edid(connector,
-   intel_gmbus_get_adapter(dev_priv,
-   intel_hdmi->ddc_bus));
+   i2c = intel_gmbus_get_adapter(dev_priv, intel_hdmi->ddc_bus);
+
+   edid = drm_get_edid(connector, i2c);
+
+   if (!edid && !intel_gmbus_is_forced_bit(i2c)) {
+   DRM_DEBUG_KMS("HDMI GMBUS EDID read failed, retry using GPIO 
bit-banging\n");
+   intel_gmbus_force_bit(i2c, true);
+   edid = drm_get_edid(connector, i2c);
+   intel_gmbus_force_bit(i2c, false);
+   }
 
intel_hdmi_dp_dual_mode_detect(connector, edid != NULL);
 
-- 
2.15.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[git pull] amdkfd next 4.16

2017-12-24 Thread Oded Gabbay
Hi Dave,

amdkfd stuff for 4.16:

- Add CWSR (compute wave save restore) support for GFX8 (Carrizo)
- Fix SDMA user-mode queues support for GFX7 (Kaveri)
- Add SDMA user-mode queues support for GFX8 (Carrizo)
- Allow HWS (hardware scheduling) to schedule multiple processes concurrently
- Add debugfs support
- Simplify process locking and lock dependencies
- Refactoring topology code to prepare for dGPU support + fixes to that code
  - Add option to generate dummy/virtual CRAT table when its missing or deformed
  - Recognize CPUs other then APUs as compute entities
- Various clean ups and bug fixes

I have not yet sent the dGPU topology code because it depends on a patch
for the PCI subsystem that adds PCIe atomics support. Once that patch is
upstreamed we can continue with the rest of the dGPU code.

Thanks and happy new year,
Oded

The following changes since commit df2869abd92b740af141ee2eb081bfc69bd80877:

  Merge branch 'drm-next-4.16' of git://people.freedesktop.org/~agd5f/linux 
into drm-next (2017-12-21 11:17:45 +1000)

are available in the Git repository at:

  git://people.freedesktop.org/~gabbayo/linux tags/drm-amdkfd-next-2017-12-24

for you to fetch changes up to 9f0a0b41ffccf9a76b19ea263ae16d2d5888093e:

  drm/amdgpu: Add support for reporting VRAM usage (2017-12-08 23:09:05 -0500)


Amber Lin (1):
  drm/amdkfd: Add perf counters to topology

Ben Goz (1):
  drm/amdkfd: Add AQL Queue Memory flag on topology

Felix Kuehling (25):
  drm/amd: Update kgd_kfd interface for resuming SDMA queues
  drm/amdgpu: Add support for resuming SDMA queues w/o HWS
  drm/amdkfd: Use ASIC-specific SDMA MQD type
  drm/amdkfd: Hardware DWORD size is 4 bytes
  drm/amdkfd: Use order_base_2 to get log2 of buffes sizes
  drm/amdkfd: Cleanup qpd.pqm initialization
  drm/amdkfd: Add trap handler for CWSR
  drm/amdkfd: Add CWSR support
  drm/amdkfd: Add support for user-mode trap handlers
  drm/amdgpu: fix get_max_engine_clock_in_mhz
  drm/amdkfd: map multiple processes to HW scheduler
  drm/amdkfd: Fix oversubscription accounting
  drm/amdgpu: Fix definition of KFD_CIK_SDMA_QUEUE_OFFSET
  drm/amdgpu: Add kfd2kgd APIs for dumping HQDs
  drm/amdkfd: Add debugfs support to KFD
  drm/amdkfd: Get reference to lead_thread task struct
  drm/amdkfd: Make kfd_process reference counted
  drm/amdkfd: Use ref count to prevent kfd_process destruction
  drm/amdkfd: Reduce nesting in kfd_create_process_device_data
  drm/amdkfd: Factor PDD destruction out of kfd_process_wq_release
  drm/amdkfd: Group up CRAT related functions
  drm/amdkfd: Turn verbose topology messages into pr_debug
  drm/amdkfd: Simplify counting of memory banks
  drm/amdkfd: Add topology support for CPUs
  drm/amdkfd: Module option to disable CRAT table

Flora Cui (3):
  drm/amd: add new interface to query cu info
  drm/amdgpu: add amdgpu interface to query cu info
  drm/amdkfd: Update number of compute unit from KGD

Harish Kasiviswanathan (13):
  drm/amd: Add get_local_mem_info to KGD-KFD interface
  drm/amdgpu: Implement get_local_mem_info
  drm/amdkfd: Stop using get_vmem_size KGD-KFD interface
  drm/amdkfd: Remove deprecated get_vmem_size
  drm/amd: Remove get_vmem_size from KGD-KFD interface
  drm/amdkfd: Topology: Fix location_id
  drm/amdkfd: Reorganize CRAT fetching from ACPI
  drm/amdkfd: Decouple CRAT parsing from device list update
  drm/amdkfd: Support enumerating non-GPU devices
  drm/amdkfd: sync IOLINK defines to thunk spec
  drm/amdkfd: Fix sibling_map[] size
  drm/amdkfd: Add topology support for dGPUs
  drm/amdkfd: Ignore ACPI CRAT for non-APU systems

Kent Russell (2):
  drm/amdkfd: Fix printing pointer cast
  drm/amdgpu: Add support for reporting VRAM usage

Philip Cox (3):
  drm/amdgpu: Implement amdgpu SDMA functions for VI
  drm/amdkfd: Implement amdkfd SDMA functions for VI
  drm/amdkfd: Fixup incorrect info in the CZ CRAT table

Philip Yang (1):
  drm/amdkfd: Add crash protection in debugger register path

Yong Zhao (4):
  drm/amdkfd: Delete a useless parameter from create_queue function pointer
  drm/amdkfd: Return NULL if kfd_lookup_process_by_pasid fails
  drm/amdkfd: Simplify locking during process creation
  drm/amdkfd: Fix memory leaks in kfd topology

 drivers/gpu/drm/amd/amdgpu/amdgpu.h|1 +
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.c |   67 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd.h |5 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c  |  111 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c  |  184 ++-
 drivers/gpu/drm/amd/amdgpu/cikd.h  |2 +-
 drivers/gpu/drm/amd/amdgpu/gfx_v7_0.c  |7 +
 drivers/gpu/drm/amd/amdgpu/gfx_v8_0.c  |5 +
 

Re: [PATCH 01/12] drm/ttm: Use ttm_bo_default_io_mem_pfn if io_mem_pfn is NULL

2017-12-24 Thread Christian König

Am 24.12.2017 um 07:14 schrieb Tan Xiaojun:

From: Michal Srb 

The io_mem_pfn field was added in commit 
ea642c3216cb2a60d1c0e760ae47ee85c9c16447
and is called unconditionally. However, not all drivers were updated to set it.

Use the ttm_bo_default_io_mem_pfn function if a driver did not set its own.

Signed-off-by: Michal Srb 
---
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 5 -
  1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index c8ebb75..e25a99b 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -234,7 +234,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
if (bo->mem.bus.is_iomem) {
/* Iomem should not be marked encrypted */
cvma.vm_page_prot = pgprot_decrypted(cvma.vm_page_prot);
-   pfn = bdev->driver->io_mem_pfn(bo, page_offset);
+   if (bdev->driver->io_mem_pfn)
+   pfn = bdev->driver->io_mem_pfn(bo, page_offset);
+   else
+   pfn = ttm_bo_default_io_mem_pfn(bo, 
page_offset);


Please move this check into a new function ttm_bo_io_mem_pfn().

You can then move the calculation of ttm_bo_default_io_mem_pfn() into 
this new function in patch #12 as well.


Regards,
Christian.


} else {
page = ttm->pages[page_offset];
if (unlikely(!page && i == 0)) {


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel