All the mail mirrored from lore.kernel.org
 help / color / mirror / Atom feed
* Various TTM cleanups (v2)
@ 2018-01-29 13:55 Tom St Denis
  2018-01-29 13:55 ` [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2) Tom St Denis
                   ` (4 more replies)
  0 siblings, 5 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Various TTM cleanups (mostly no functional changes).

Notably patch #1 fixes a bug in the access_kmap() function.

The rest are either coding style fixes or simplifications.


_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2)
  2018-01-29 13:55 Various TTM cleanups (v2) Tom St Denis
@ 2018-01-29 13:55 ` Tom St Denis
       [not found]   ` <20180129135513.22538-2-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
  2018-01-29 13:55 ` [PATCH 08/12] drm/ttm: Remove unncessary retval from ttm_bo_vm_fault() Tom St Denis
                   ` (3 subsequent siblings)
  4 siblings, 1 reply; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx; +Cc: Tom St Denis, dri-devel

The buf pointer was not being incremented inside the loop
meaning the same block of data would be read or written
repeatedly.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>

(v2) Change 'buf' pointer to uint8_t* type
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 08a3c324242e..60fcef1593dd 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -316,7 +316,7 @@ static void ttm_bo_vm_close(struct vm_area_struct *vma)
 
 static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
 				 unsigned long offset,
-				 void *buf, int len, int write)
+				 uint8_t *buf, int len, int write)
 {
 	unsigned long page = offset >> PAGE_SHIFT;
 	unsigned long bytes_left = len;
@@ -345,6 +345,7 @@ static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo,
 		ttm_bo_kunmap(&map);
 
 		page++;
+		buf += bytes;
 		bytes_left -= bytes;
 		offset = 0;
 	} while (bytes_left);
-- 
2.14.3

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 02/12] drm/ttm: Fix coding style in ttm_bo.c
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 03/12] drm/ttm: Add a default BO destructor to simplify code (v2) Tom St Denis
                     ` (7 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Correct indentation and {} brace style.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index d33a6bb742a1..8cf89da7030d 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -149,9 +149,8 @@ static void ttm_bo_release_list(struct kref *list_kref)
 	mutex_destroy(&bo->wu_mutex);
 	if (bo->destroy)
 		bo->destroy(bo);
-	else {
+	else
 		kfree(bo);
-	}
 	ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
 }
 
@@ -163,7 +162,6 @@ void ttm_bo_add_to_lru(struct ttm_buffer_object *bo)
 	reservation_object_assert_held(bo->resv);
 
 	if (!(bo->mem.placement & TTM_PL_FLAG_NO_EVICT)) {
-
 		BUG_ON(!list_empty(&bo->lru));
 
 		man = &bdev->man[bo->mem.mem_type];
@@ -614,10 +612,9 @@ static void ttm_bo_delayed_workqueue(struct work_struct *work)
 	struct ttm_bo_device *bdev =
 	    container_of(work, struct ttm_bo_device, wq.work);
 
-	if (!ttm_bo_delayed_delete(bdev, false)) {
+	if (!ttm_bo_delayed_delete(bdev, false))
 		schedule_delayed_work(&bdev->wq,
 				      ((HZ / 100) < 1) ? 1 : HZ / 100);
-	}
 }
 
 static void ttm_bo_release(struct kref *kref)
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 03/12] drm/ttm: Add a default BO destructor to simplify code (v2)
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
  2018-01-29 13:55   ` [PATCH 02/12] drm/ttm: Fix coding style in ttm_bo.c Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 04/12] drm/ttm: Change ttm_tt page allocations to return errors Tom St Denis
                     ` (6 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>

(v2): Remove stray ; noticed by Felix
---
 drivers/gpu/drm/ttm/ttm_bo.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo.c b/drivers/gpu/drm/ttm/ttm_bo.c
index 8cf89da7030d..d90b1cf10b27 100644
--- a/drivers/gpu/drm/ttm/ttm_bo.c
+++ b/drivers/gpu/drm/ttm/ttm_bo.c
@@ -49,6 +49,12 @@ static struct attribute ttm_bo_count = {
 	.mode = S_IRUGO
 };
 
+/* default destructor */
+static void ttm_bo_default_destroy(struct ttm_buffer_object *bo)
+{
+	kfree(bo);
+}
+
 static inline int ttm_mem_type_from_place(const struct ttm_place *place,
 					  uint32_t *mem_type)
 {
@@ -147,10 +153,7 @@ static void ttm_bo_release_list(struct kref *list_kref)
 	dma_fence_put(bo->moving);
 	reservation_object_fini(&bo->ttm_resv);
 	mutex_destroy(&bo->wu_mutex);
-	if (bo->destroy)
-		bo->destroy(bo);
-	else
-		kfree(bo);
+	bo->destroy(bo);
 	ttm_mem_global_free(bdev->glob->mem_glob, acc_size);
 }
 
@@ -1176,7 +1179,7 @@ int ttm_bo_init_reserved(struct ttm_bo_device *bdev,
 		ttm_mem_global_free(mem_glob, acc_size);
 		return -EINVAL;
 	}
-	bo->destroy = destroy;
+	bo->destroy = destroy ? destroy : ttm_bo_default_destroy;
 
 	kref_init(&bo->kref);
 	kref_init(&bo->list_kref);
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 04/12] drm/ttm: Change ttm_tt page allocations to return errors
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
  2018-01-29 13:55   ` [PATCH 02/12] drm/ttm: Fix coding style in ttm_bo.c Tom St Denis
  2018-01-29 13:55   ` [PATCH 03/12] drm/ttm: Add a default BO destructor to simplify code (v2) Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 05/12] drm/ttm: Fix coding style in ttm_pool_store() Tom St Denis
                     ` (5 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Explicitly return errors in ttm_tt_alloc_page_directory() and
ttm_dma_tt_alloc_page_directory() instead of relying on
further logic to detect errors.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_tt.c | 16 ++++++++++------
 1 file changed, 10 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index 9e4d43d68e91..e90d3ed6283f 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -50,19 +50,25 @@
 /**
  * Allocates storage for pointers to the pages that back the ttm.
  */
-static void ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
+static int ttm_tt_alloc_page_directory(struct ttm_tt *ttm)
 {
 	ttm->pages = kvmalloc_array(ttm->num_pages, sizeof(void*),
 			GFP_KERNEL | __GFP_ZERO);
+	if (!ttm->pages)
+		return -ENOMEM;
+	return 0;
 }
 
-static void ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm)
+static int ttm_dma_tt_alloc_page_directory(struct ttm_dma_tt *ttm)
 {
 	ttm->ttm.pages = kvmalloc_array(ttm->ttm.num_pages,
 					  sizeof(*ttm->ttm.pages) +
 					  sizeof(*ttm->dma_address),
 					  GFP_KERNEL | __GFP_ZERO);
+	if (!ttm->ttm.pages)
+		return -ENOMEM;
 	ttm->dma_address = (void *) (ttm->ttm.pages + ttm->ttm.num_pages);
+	return 0;
 }
 
 #ifdef CONFIG_X86
@@ -197,8 +203,7 @@ int ttm_tt_init(struct ttm_tt *ttm, struct ttm_bo_device *bdev,
 	ttm->state = tt_unpopulated;
 	ttm->swap_storage = NULL;
 
-	ttm_tt_alloc_page_directory(ttm);
-	if (!ttm->pages) {
+	if (ttm_tt_alloc_page_directory(ttm)) {
 		ttm_tt_destroy(ttm);
 		pr_err("Failed allocating page table\n");
 		return -ENOMEM;
@@ -230,8 +235,7 @@ int ttm_dma_tt_init(struct ttm_dma_tt *ttm_dma, struct ttm_bo_device *bdev,
 	ttm->swap_storage = NULL;
 
 	INIT_LIST_HEAD(&ttm_dma->pages_list);
-	ttm_dma_tt_alloc_page_directory(ttm_dma);
-	if (!ttm->pages) {
+	if (ttm_dma_tt_alloc_page_directory(ttm_dma)) {
 		ttm_tt_destroy(ttm);
 		pr_err("Failed allocating page table\n");
 		return -ENOMEM;
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 05/12] drm/ttm: Fix coding style in ttm_pool_store()
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (2 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 04/12] drm/ttm: Change ttm_tt page allocations to return errors Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 06/12] drm/ttm: Simplify ttm_dma_find_pool() (v2) Tom St Denis
                     ` (4 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Correct missing {} style.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 9e90d0ebc773..647eb5f40ab9 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -210,6 +210,7 @@ static ssize_t ttm_pool_store(struct kobject *kobj, struct attribute *attr,
 		container_of(kobj, struct ttm_pool_manager, kobj);
 	int chars;
 	unsigned val;
+
 	chars = sscanf(buffer, "%u", &val);
 	if (chars == 0)
 		return size;
@@ -217,11 +218,11 @@ static ssize_t ttm_pool_store(struct kobject *kobj, struct attribute *attr,
 	/* Convert kb to number of pages */
 	val = val / (PAGE_SIZE >> 10);
 
-	if (attr == &ttm_page_pool_max)
+	if (attr == &ttm_page_pool_max) {
 		m->options.max_size = val;
-	else if (attr == &ttm_page_pool_small)
+	} else if (attr == &ttm_page_pool_small) {
 		m->options.small = val;
-	else if (attr == &ttm_page_pool_alloc_size) {
+	} else if (attr == &ttm_page_pool_alloc_size) {
 		if (val > NUM_PAGES_TO_ALLOC*8) {
 			pr_err("Setting allocation size to %lu is not allowed. Recommended size is %lu\n",
 			       NUM_PAGES_TO_ALLOC*(PAGE_SIZE >> 7),
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 06/12] drm/ttm: Simplify ttm_dma_find_pool() (v2)
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (3 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 05/12] drm/ttm: Fix coding style in ttm_pool_store() Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 07/12] drm/ttm: Fix coding style in ttm_bo_move_memcpy() Tom St Denis
                     ` (3 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Flip the logic of the comparison and remove
the redudant variable for the pool address.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>

(v2): Remove {} bracing.
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 15 ++++++---------
 1 file changed, 6 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 647eb5f40ab9..469e68e06be6 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -682,10 +682,10 @@ static struct dma_pool *ttm_dma_pool_init(struct device *dev, gfp_t flags,
 static struct dma_pool *ttm_dma_find_pool(struct device *dev,
 					  enum pool_type type)
 {
-	struct dma_pool *pool, *tmp, *found = NULL;
+	struct dma_pool *pool, *tmp;
 
 	if (type == IS_UNDEFINED)
-		return found;
+		return NULL;
 
 	/* NB: We iterate on the 'struct dev' which has no spinlock, but
 	 * it does have a kref which we have taken. The kref is taken during
@@ -698,13 +698,10 @@ static struct dma_pool *ttm_dma_find_pool(struct device *dev,
 	 * thing is at that point of time there are no pages associated with the
 	 * driver so this function will not be called.
 	 */
-	list_for_each_entry_safe(pool, tmp, &dev->dma_pools, pools) {
-		if (pool->type != type)
-			continue;
-		found = pool;
-		break;
-	}
-	return found;
+	list_for_each_entry_safe(pool, tmp, &dev->dma_pools, pools)
+		if (pool->type == type)
+			return pool;
+	return NULL;
 }
 
 /*
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 07/12] drm/ttm: Fix coding style in ttm_bo_move_memcpy()
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (4 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 06/12] drm/ttm: Simplify ttm_dma_find_pool() (v2) Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 09/12] drm/ttm: Simplify ttm_eu_reserve_buffers() Tom St Denis
                     ` (2 subsequent siblings)
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Add missing {} braces.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo_util.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_util.c b/drivers/gpu/drm/ttm/ttm_bo_util.c
index 153de1bf0232..33ffe286f3a5 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_util.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_util.c
@@ -402,8 +402,9 @@ int ttm_bo_move_memcpy(struct ttm_buffer_object *bo,
 						    PAGE_KERNEL);
 			ret = ttm_copy_io_ttm_page(ttm, old_iomap, page,
 						   prot);
-		} else
+		} else {
 			ret = ttm_copy_io_page(new_iomap, old_iomap, page);
+		}
 		if (ret)
 			goto out1;
 	}
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 08/12] drm/ttm: Remove unncessary retval from ttm_bo_vm_fault()
  2018-01-29 13:55 Various TTM cleanups (v2) Tom St Denis
  2018-01-29 13:55 ` [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2) Tom St Denis
@ 2018-01-29 13:55 ` Tom St Denis
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx; +Cc: Tom St Denis, dri-devel

The dual ret/retval was more complex than need be.  Now
we drop the retval variable and assign the appropriate VM
codes to ret instead.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 28 +++++++++++++---------------
 1 file changed, 13 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_bo_vm.c b/drivers/gpu/drm/ttm/ttm_bo_vm.c
index 60fcef1593dd..716e724ac710 100644
--- a/drivers/gpu/drm/ttm/ttm_bo_vm.c
+++ b/drivers/gpu/drm/ttm/ttm_bo_vm.c
@@ -118,7 +118,6 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 	int ret;
 	int i;
 	unsigned long address = vmf->address;
-	int retval = VM_FAULT_NOPAGE;
 	struct ttm_mem_type_manager *man =
 		&bdev->man[bo->mem.mem_type];
 	struct vm_area_struct cvma;
@@ -158,7 +157,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 	 * (if at all) by redirecting mmap to the exporter.
 	 */
 	if (bo->ttm && (bo->ttm->page_flags & TTM_PAGE_FLAG_SG)) {
-		retval = VM_FAULT_SIGBUS;
+		ret = VM_FAULT_SIGBUS;
 		goto out_unlock;
 	}
 
@@ -169,10 +168,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 			break;
 		case -EBUSY:
 		case -ERESTARTSYS:
-			retval = VM_FAULT_NOPAGE;
+			ret = VM_FAULT_NOPAGE;
 			goto out_unlock;
 		default:
-			retval = VM_FAULT_SIGBUS;
+			ret = VM_FAULT_SIGBUS;
 			goto out_unlock;
 		}
 	}
@@ -183,12 +182,10 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 	 */
 	ret = ttm_bo_vm_fault_idle(bo, vmf);
 	if (unlikely(ret != 0)) {
-		retval = ret;
-
-		if (retval == VM_FAULT_RETRY &&
+		if (ret == VM_FAULT_RETRY &&
 		    !(vmf->flags & FAULT_FLAG_RETRY_NOWAIT)) {
 			/* The BO has already been unreserved. */
-			return retval;
+			return ret;
 		}
 
 		goto out_unlock;
@@ -196,12 +193,12 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 
 	ret = ttm_mem_io_lock(man, true);
 	if (unlikely(ret != 0)) {
-		retval = VM_FAULT_NOPAGE;
+		ret = VM_FAULT_NOPAGE;
 		goto out_unlock;
 	}
 	ret = ttm_mem_io_reserve_vm(bo);
 	if (unlikely(ret != 0)) {
-		retval = VM_FAULT_SIGBUS;
+		ret = VM_FAULT_SIGBUS;
 		goto out_io_unlock;
 	}
 
@@ -211,7 +208,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		drm_vma_node_start(&bo->vma_node);
 
 	if (unlikely(page_offset >= bo->num_pages)) {
-		retval = VM_FAULT_SIGBUS;
+		ret = VM_FAULT_SIGBUS;
 		goto out_io_unlock;
 	}
 
@@ -238,7 +235,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 
 		/* Allocate all page at once, most common usage */
 		if (ttm->bdev->driver->ttm_tt_populate(ttm, &ctx)) {
-			retval = VM_FAULT_OOM;
+			ret = VM_FAULT_OOM;
 			goto out_io_unlock;
 		}
 	}
@@ -255,7 +252,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		} else {
 			page = ttm->pages[page_offset];
 			if (unlikely(!page && i == 0)) {
-				retval = VM_FAULT_OOM;
+				ret = VM_FAULT_OOM;
 				goto out_io_unlock;
 			} else if (unlikely(!page)) {
 				break;
@@ -280,7 +277,7 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		if (unlikely((ret == -EBUSY) || (ret != 0 && i > 0)))
 			break;
 		else if (unlikely(ret != 0)) {
-			retval =
+			ret =
 			    (ret == -ENOMEM) ? VM_FAULT_OOM : VM_FAULT_SIGBUS;
 			goto out_io_unlock;
 		}
@@ -289,11 +286,12 @@ static int ttm_bo_vm_fault(struct vm_fault *vmf)
 		if (unlikely(++page_offset >= page_last))
 			break;
 	}
+	ret = VM_FAULT_NOPAGE;
 out_io_unlock:
 	ttm_mem_io_unlock(man);
 out_unlock:
 	ttm_bo_unreserve(bo);
-	return retval;
+	return ret;
 }
 
 static void ttm_bo_vm_open(struct vm_area_struct *vma)
-- 
2.14.3

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 09/12] drm/ttm: Simplify ttm_eu_reserve_buffers()
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (5 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 07/12] drm/ttm: Fix coding style in ttm_bo_move_memcpy() Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 10/12] drm/ttm: Fix coding style in ttm_tt_swapout() Tom St Denis
  2018-01-29 13:55   ` [PATCH 12/12] drm/ttm: Simplify ttm_dma_page_put() Tom St Denis
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hoist the comparison of the ret to -EDEADLK above
the two code paths to simplify the function.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_execbuf_util.c | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_execbuf_util.c b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
index 373ced0b2fc2..fa44f7b15285 100644
--- a/drivers/gpu/drm/ttm/ttm_execbuf_util.c
+++ b/drivers/gpu/drm/ttm/ttm_execbuf_util.c
@@ -139,12 +139,14 @@ int ttm_eu_reserve_buffers(struct ww_acquire_ctx *ticket,
 		 */
 		ttm_eu_backoff_reservation_reverse(list, entry);
 
-		if (ret == -EDEADLK && intr) {
-			ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
-							       ticket);
-		} else if (ret == -EDEADLK) {
-			ww_mutex_lock_slow(&bo->resv->lock, ticket);
-			ret = 0;
+		if (ret == -EDEADLK) {
+			if (intr) {
+				ret = ww_mutex_lock_slow_interruptible(&bo->resv->lock,
+								       ticket);
+			} else {
+				ww_mutex_lock_slow(&bo->resv->lock, ticket);
+				ret = 0;
+			}
 		}
 
 		if (!ret && entry->shared)
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 10/12] drm/ttm: Fix coding style in ttm_tt_swapout()
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (6 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 09/12] drm/ttm: Simplify ttm_eu_reserve_buffers() Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  2018-01-29 13:55   ` [PATCH 12/12] drm/ttm: Simplify ttm_dma_page_put() Tom St Denis
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Add missing {} braces.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_tt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_tt.c b/drivers/gpu/drm/ttm/ttm_tt.c
index e90d3ed6283f..95a77dab8cc9 100644
--- a/drivers/gpu/drm/ttm/ttm_tt.c
+++ b/drivers/gpu/drm/ttm/ttm_tt.c
@@ -352,8 +352,9 @@ int ttm_tt_swapout(struct ttm_tt *ttm, struct file *persistent_swap_storage)
 			pr_err("Failed allocating swap storage\n");
 			return PTR_ERR(swap_storage);
 		}
-	} else
+	} else {
 		swap_storage = persistent_swap_storage;
+	}
 
 	swap_space = swap_storage->f_mapping;
 
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 11/12] drm/ttm: Fix coding style in ttm_dma_pool_alloc_new_pages()
  2018-01-29 13:55 Various TTM cleanups (v2) Tom St Denis
                   ` (2 preceding siblings ...)
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-29 13:55 ` Tom St Denis
  2018-01-29 21:22 ` Various TTM cleanups (v2) Felix Kuehling
  4 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx; +Cc: Tom St Denis, dri-devel

Add missing {} braces.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index 469e68e06be6..fcd16804c738 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -763,10 +763,9 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 		return -ENOMEM;
 	}
 
-	if (count > 1) {
+	if (count > 1)
 		pr_debug("%s: (%s:%d) Getting %d pages\n",
 			 pool->dev_name, pool->name, current->pid, count);
-	}
 
 	for (i = 0, cpages = 0; i < count; ++i) {
 		dma_p = __ttm_dma_alloc_page(pool);
-- 
2.14.3

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

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 12/12] drm/ttm: Simplify ttm_dma_page_put()
       [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
                     ` (7 preceding siblings ...)
  2018-01-29 13:55   ` [PATCH 10/12] drm/ttm: Fix coding style in ttm_tt_swapout() Tom St Denis
@ 2018-01-29 13:55   ` Tom St Denis
  8 siblings, 0 replies; 16+ messages in thread
From: Tom St Denis @ 2018-01-29 13:55 UTC (permalink / raw
  To: amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW
  Cc: Tom St Denis, dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Remove redundant store of return code.

Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
Reviewed-by: Christian König <christian.koenig@amd.com>
---
 drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
index fcd16804c738..b122f6eee94c 100644
--- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
+++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c
@@ -390,14 +390,12 @@ static void ttm_dma_page_put(struct dma_pool *pool, struct dma_page *d_page)
 {
 	struct page *page = d_page->p;
 	unsigned i, num_pages;
-	int ret;
 
 	/* Don't set WB on WB page pool. */
 	if (!(pool->type & IS_CACHED)) {
 		num_pages = pool->size / PAGE_SIZE;
 		for (i = 0; i < num_pages; ++i, ++page) {
-			ret = set_pages_array_wb(&page, 1);
-			if (ret) {
+			if (set_pages_array_wb(&page, 1)) {
 				pr_err("%s: Failed to set %d pages to wb!\n",
 				       pool->dev_name, 1);
 			}
-- 
2.14.3

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2)
       [not found]   ` <20180129135513.22538-2-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
@ 2018-01-29 14:31     ` Michel Dänzer
  2018-01-29 14:39       ` Christian König
  0 siblings, 1 reply; 16+ messages in thread
From: Michel Dänzer @ 2018-01-29 14:31 UTC (permalink / raw
  To: Tom St Denis
  Cc: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On 2018-01-29 02:55 PM, Tom St Denis wrote:
> The buf pointer was not being incremented inside the loop
> meaning the same block of data would be read or written
> repeatedly.
> 
> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
> Reviewed-by: Christian König <christian.koenig@amd.com>

Please add:

Cc: stable@vger.kernel.org
Fixes: 09ac4fcb3f25 ("drm/ttm: Implement vm_operations_struct.access v2")

so that it'll get backported to the relevant stable branches.


-- 
Earthling Michel Dänzer               |               http://www.amd.com
Libre software enthusiast             |             Mesa and X developer
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2)
  2018-01-29 14:31     ` Michel Dänzer
@ 2018-01-29 14:39       ` Christian König
  0 siblings, 0 replies; 16+ messages in thread
From: Christian König @ 2018-01-29 14:39 UTC (permalink / raw
  To: Michel Dänzer, Tom St Denis; +Cc: amd-gfx, dri-devel

Am 29.01.2018 um 15:31 schrieb Michel Dänzer:
> On 2018-01-29 02:55 PM, Tom St Denis wrote:
>> The buf pointer was not being incremented inside the loop
>> meaning the same block of data would be read or written
>> repeatedly.
>>
>> Signed-off-by: Tom St Denis <tom.stdenis@amd.com>
>> Reviewed-by: Christian König <christian.koenig@amd.com>
> Please add:
>
> Cc: stable@vger.kernel.org
> Fixes: 09ac4fcb3f25 ("drm/ttm: Implement vm_operations_struct.access v2")

What Michel meant here is that you should add the "Cc: " and "Fixes: " 
tags to the commit message and NOT send it manually to 
stable@vger.kernel.org.

The "Cc:" tag results in automatically backporting of the patch to 
stable kernels. Manually sending a patch to stable@vger.kernel.org is 
only necessary when the automated backport doesn't work.

Christian.

>
> so that it'll get backported to the relevant stable branches.
>
>

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: Various TTM cleanups (v2)
  2018-01-29 13:55 Various TTM cleanups (v2) Tom St Denis
                   ` (3 preceding siblings ...)
  2018-01-29 13:55 ` [PATCH 11/12] drm/ttm: Fix coding style in ttm_dma_pool_alloc_new_pages() Tom St Denis
@ 2018-01-29 21:22 ` Felix Kuehling
  4 siblings, 0 replies; 16+ messages in thread
From: Felix Kuehling @ 2018-01-29 21:22 UTC (permalink / raw
  To: amd-gfx, dri-devel

The series is Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>

Regards,
  Felix


On 2018-01-29 08:55 AM, Tom St Denis wrote:
> Various TTM cleanups (mostly no functional changes).
>
> Notably patch #1 fixes a bug in the access_kmap() function.
>
> The rest are either coding style fixes or simplifications.
>
>
> _______________________________________________
> amd-gfx mailing list
> amd-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2018-01-29 21:22 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-01-29 13:55 Various TTM cleanups (v2) Tom St Denis
2018-01-29 13:55 ` [PATCH 01/12] drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2) Tom St Denis
     [not found]   ` <20180129135513.22538-2-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2018-01-29 14:31     ` Michel Dänzer
2018-01-29 14:39       ` Christian König
2018-01-29 13:55 ` [PATCH 08/12] drm/ttm: Remove unncessary retval from ttm_bo_vm_fault() Tom St Denis
     [not found] ` <20180129135513.22538-1-tom.stdenis-5C7GfCeVMHo@public.gmane.org>
2018-01-29 13:55   ` [PATCH 02/12] drm/ttm: Fix coding style in ttm_bo.c Tom St Denis
2018-01-29 13:55   ` [PATCH 03/12] drm/ttm: Add a default BO destructor to simplify code (v2) Tom St Denis
2018-01-29 13:55   ` [PATCH 04/12] drm/ttm: Change ttm_tt page allocations to return errors Tom St Denis
2018-01-29 13:55   ` [PATCH 05/12] drm/ttm: Fix coding style in ttm_pool_store() Tom St Denis
2018-01-29 13:55   ` [PATCH 06/12] drm/ttm: Simplify ttm_dma_find_pool() (v2) Tom St Denis
2018-01-29 13:55   ` [PATCH 07/12] drm/ttm: Fix coding style in ttm_bo_move_memcpy() Tom St Denis
2018-01-29 13:55   ` [PATCH 09/12] drm/ttm: Simplify ttm_eu_reserve_buffers() Tom St Denis
2018-01-29 13:55   ` [PATCH 10/12] drm/ttm: Fix coding style in ttm_tt_swapout() Tom St Denis
2018-01-29 13:55   ` [PATCH 12/12] drm/ttm: Simplify ttm_dma_page_put() Tom St Denis
2018-01-29 13:55 ` [PATCH 11/12] drm/ttm: Fix coding style in ttm_dma_pool_alloc_new_pages() Tom St Denis
2018-01-29 21:22 ` Various TTM cleanups (v2) Felix Kuehling

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.