Skip to contentSkip to conversation

drm/amdgpu: fix vm_cpu_update hit NULL pointer

PATCH In review Monk Liu 2 participants 4 messages Mar 22, 2019 – Mar 25, 2019 3 messages not in the archive

Subsystems (2)
lore
Share & tools
lore

Monk Liu

author
#0 lore raw

PATCH 1/1 drm/amdgpu: fix vm_cpu_update hit NULL pointer

should use amdgpu_bo_map, otherwise you'll hit NULL pointer bug if with amdgpu_bo_kptr

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +3 -1
index 9d53982..1fb6295a 100644
@@ -76,8 +76,10 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
 {
 	unsigned int i;
 	uint64_t value;
+	void *ptr;
 
-	pe += (unsigned long)amdgpu_bo_kptr(bo);
+	amdgpu_bo_kmap(bo, &ptr);
+	pe += (unsigned long)ptr;
 
 	trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags);
 
Signature · 6 lines
2.7.4

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

A message that is not in the archive (sent off-list or not yet received): 1553232632-27710-1-git-send-email-Monk.Liu-5C7GfCeVMHo@public.gmane.org

#2 lore raw

Am 22.03.19 um 06:30 schrieb Monk Liu:

Quoted 2 lines

should use amdgpu_bo_map, otherwise you'll hit NULL pointer bug if with amdgpu_bo_kptr

Yeah that is a known problem. NAK to this one cause that would map the BO at the wrong time.

But in general I have a proper fix for this in the pipeline.

Christian.

Quoted 12 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
index 9d53982..1fb6295a 100644
@@ -76,8 +76,10 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
  {

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, · line 85

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +3 -1
  	unsigned int i;
  	uint64_t value;
+	void *ptr;
 
-	pe += (unsigned long)amdgpu_bo_kptr(bo);
+	amdgpu_bo_kmap(bo, &ptr);
+	pe += (unsigned long)ptr;
 
  	trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags);
 

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

A message that is not in the archive (sent off-list or not yet received): 583e1755-3c2a-8677-dda0-2f10ed8fc09a-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org

author
#4 lore raw

Hi Christian

Why it is the wrong time ? the pte/pd bo already reserved, some details maybe?

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, March 22, 2019 11:43 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix vm_cpu_update hit NULL pointer

Am 22.03.19 um 06:30 schrieb Monk Liu:

Quoted 2 lines

should use amdgpu_bo_map, otherwise you'll hit NULL pointer bug if with amdgpu_bo_kptr

Yeah that is a known problem. NAK to this one cause that would map the BO at the wrong time.

But in general I have a proper fix for this in the pipeline.

Christian.

Quoted 13 lines
---
  drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
index 9d53982..1fb6295a 100644
@@ -76,8 +76,10 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
  {

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, · line 85

Quoted 10 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +3 -1
  	unsigned int i;
  	uint64_t value;
+	void *ptr;
 
-	pe += (unsigned long)amdgpu_bo_kptr(bo);
+	amdgpu_bo_kmap(bo, &ptr);
+	pe += (unsigned long)ptr;
 
  	trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags);
 

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

A message that is not in the archive (sent off-list or not yet received): BYAPR12MB33014544E9805DC79F9E3EA1845D0-ZGDeBxoHBPmRc1D8ZEEGsgdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org

#6 lore raw

Hi Monk,

well it would certainly work, but for the error handling it's just not the best idea to do the mapping so late.

E.g. we should do the kmap for CPU based updates as well as the GTT map for SDMA based updates much more earlier to avoid rolling back all work again when we are interrupted by a signal for example.

Give me a moment to write a patch for this, it's basically the same thing as your patch just called from an earlier point.

Regards,
Christian.

Am 24.03.19 um 04:42 schrieb Liu, Monk:

Quoted 41 lines

Hi Christian

Why it is the wrong time ? the pte/pd bo already reserved, some details maybe?

Thanks
/Monk
-----Original Message-----
From: Christian König <[email protected]>
Sent: Friday, March 22, 2019 11:43 PM
To: Liu, Monk <[email protected]>; [email protected]
Subject: Re: [PATCH] drm/amdgpu: fix vm_cpu_update hit NULL pointer

Am 22.03.19 um 06:30 schrieb Monk Liu:

Quoted 2 lines

should use amdgpu_bo_map, otherwise you'll hit NULL pointer bug if with amdgpu_bo_kptr

Yeah that is a known problem. NAK to this one cause that would map the BO at the wrong time.

But in general I have a proper fix for this in the pipeline.

Christian.

Quoted 20 lines
---
   drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c | 4 +++-
   1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +3 -1
index 9d53982..1fb6295a 100644
@@ -76,8 +76,10 @@ static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p,
   {
   	unsigned int i;
   	uint64_t value;
+	void *ptr;
 
-	pe += (unsigned long)amdgpu_bo_kptr(bo);
+	amdgpu_bo_kmap(bo, &ptr);
+	pe += (unsigned long)ptr;
 
Quoted 6 lines

drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c static int amdgpu_vm_cpu_update(struct amdgpu_vm_update_params *p, · line 85

Quoted 2 lines
drivers/gpu/drm/amd/amdgpu/amdgpu_vm_cpu.c +0 -0
   	trace_amdgpu_vm_set_ptes(pe, addr, count, incr, flags);
 

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

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