Skip to contentSkip to conversation

drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2)

PATCH In review Tom St Denis 3 participants 3 messages Jan 29, 2018 1 message not in the archive

Subsystems (4)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/ttm: Fix 'buf' pointer update in ttm_bo_vm_access_kmap() (v2)

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

Fixes 09ac4fcb3f25 ("drm/ttm: Implement vm_operations_struct.access v2")

(v2) Change 'buf' pointer to uint8_t* type

---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +2 -1
index 08a3c324242e..60fcef1593dd 100644
@@ -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);
Signature · 1 line
2.14.3
#2 lore raw
In reply to a message not in the archive

Greg and other stable maintainers please ignore this one.

Tom just misunderstood, what to do with this patch.

Thanks,
Christian.

Am 29.01.2018 um 15:34 schrieb Tom St Denis:

Quoted 28 lines

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

Fixes 09ac4fcb3f25 ("drm/ttm: Implement vm_operations_struct.access v2")

(v2) Change 'buf' pointer to uint8_t* type

---
  drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
index 08a3c324242e..60fcef1593dd 100644
@@ -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;

drivers/gpu/drm/ttm/ttm_bo_vm.c static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo, · line 351

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -0
@@ -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);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

Reviewed-by
#3 lore raw
In reply to a message not in the archive
Quoted 8 lines · Tom St Denis

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

Fixes 09ac4fcb3f25 ("drm/ttm: Implement vm_operations_struct.access v2")
Quoted 20 lines

(v2) Change 'buf' pointer to uint8_t* type

---
 drivers/gpu/drm/ttm/ttm_bo_vm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -1
index 08a3c324242e..60fcef1593dd 100644
@@ -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;

drivers/gpu/drm/ttm/ttm_bo_vm.c static int ttm_bo_vm_access_kmap(struct ttm_buffer_object *bo, · line 351

Quoted 7 lines
drivers/gpu/drm/ttm/ttm_bo_vm.c +1 -0
@@ -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);

_______________________________________________
amd-gfx mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/amd-gfx