public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/panthor: Fix handling of partial GPU mapping of BOs
@ 2024-11-11 13:47 Akash Goel
  2024-11-12  9:08 ` Boris Brezillon
  0 siblings, 1 reply; 2+ messages in thread
From: Akash Goel @ 2024-11-11 13:47 UTC (permalink / raw)
  To: boris.brezillon, liviu.dudau, steven.price
  Cc: dri-devel, linux-kernel, mihail.atanassov, ketil.johnsen,
	maarten.lankhorst, mripard, tzimmermann, airlied, daniel, nd,
	Akash Goel

This commit fixes the bug in the handling of partial mapping of the
buffer objects to the GPU, which caused kernel warnings.

Panthor didn't correctly handle the case where the partial mapping
spanned multiple scatterlists and the mapping offset didn't point
to the 1st page of starting scatterlist. The offset variable was
not cleared after reaching the starting scatterlist.

Following warning messages were seen.
WARNING: CPU: 1 PID: 650 at drivers/iommu/io-pgtable-arm.c:659 __arm_lpae_unmap+0x254/0x5a0
<snip>
pc : __arm_lpae_unmap+0x254/0x5a0
lr : __arm_lpae_unmap+0x2cc/0x5a0
<snip>
Call trace:
 __arm_lpae_unmap+0x254/0x5a0
 __arm_lpae_unmap+0x108/0x5a0
 __arm_lpae_unmap+0x108/0x5a0
 __arm_lpae_unmap+0x108/0x5a0
 arm_lpae_unmap_pages+0x80/0xa0
 panthor_vm_unmap_pages+0xac/0x1c8 [panthor]
 panthor_gpuva_sm_step_unmap+0x4c/0xc8 [panthor]
 op_unmap_cb.isra.23.constprop.30+0x54/0x80
 __drm_gpuvm_sm_unmap+0x184/0x1c8
 drm_gpuvm_sm_unmap+0x40/0x60
 panthor_vm_exec_op+0xa8/0x120 [panthor]
 panthor_vm_bind_exec_sync_op+0xc4/0xe8 [panthor]
 panthor_ioctl_vm_bind+0x10c/0x170 [panthor]
 drm_ioctl_kernel+0xbc/0x138
 drm_ioctl+0x210/0x4b0
 __arm64_sys_ioctl+0xb0/0xf8
 invoke_syscall+0x4c/0x110
 el0_svc_common.constprop.1+0x98/0xf8
 do_el0_svc+0x24/0x38
 el0_svc+0x34/0xc8
 el0t_64_sync_handler+0xa0/0xc8
 el0t_64_sync+0x174/0x178
<snip>
panthor : [drm] drm_WARN_ON(unmapped_sz != pgsize * pgcount)
WARNING: CPU: 1 PID: 650 at drivers/gpu/drm/panthor/panthor_mmu.c:922 panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
<snip>
pc : panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
lr : panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
<snip>
panthor : [drm] *ERROR* failed to unmap range ffffa388f000-ffffa3890000 (requested range ffffa388c000-ffffa3890000)

Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block")
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Signed-off-by: Akash Goel <akash.goel@arm.com>
---
 drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index d8cc9e7d064e..8d05124793f5 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -989,6 +989,8 @@ panthor_vm_map_pages(struct panthor_vm *vm, u64 iova, int prot,
 
 		if (!size)
 			break;
+
+		offset = 0;
 	}
 
 	return panthor_vm_flush_range(vm, start_iova, iova - start_iova);
-- 
2.25.1


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

* Re: [PATCH v2] drm/panthor: Fix handling of partial GPU mapping of BOs
  2024-11-11 13:47 [PATCH v2] drm/panthor: Fix handling of partial GPU mapping of BOs Akash Goel
@ 2024-11-12  9:08 ` Boris Brezillon
  0 siblings, 0 replies; 2+ messages in thread
From: Boris Brezillon @ 2024-11-12  9:08 UTC (permalink / raw)
  To: Akash Goel
  Cc: liviu.dudau, steven.price, dri-devel, linux-kernel,
	mihail.atanassov, ketil.johnsen, maarten.lankhorst, mripard,
	tzimmermann, airlied, daniel, nd

On Mon, 11 Nov 2024 13:47:20 +0000
Akash Goel <akash.goel@arm.com> wrote:

> This commit fixes the bug in the handling of partial mapping of the
> buffer objects to the GPU, which caused kernel warnings.
> 
> Panthor didn't correctly handle the case where the partial mapping
> spanned multiple scatterlists and the mapping offset didn't point
> to the 1st page of starting scatterlist. The offset variable was
> not cleared after reaching the starting scatterlist.
> 
> Following warning messages were seen.
> WARNING: CPU: 1 PID: 650 at drivers/iommu/io-pgtable-arm.c:659 __arm_lpae_unmap+0x254/0x5a0
> <snip>
> pc : __arm_lpae_unmap+0x254/0x5a0
> lr : __arm_lpae_unmap+0x2cc/0x5a0
> <snip>
> Call trace:
>  __arm_lpae_unmap+0x254/0x5a0
>  __arm_lpae_unmap+0x108/0x5a0
>  __arm_lpae_unmap+0x108/0x5a0
>  __arm_lpae_unmap+0x108/0x5a0
>  arm_lpae_unmap_pages+0x80/0xa0
>  panthor_vm_unmap_pages+0xac/0x1c8 [panthor]
>  panthor_gpuva_sm_step_unmap+0x4c/0xc8 [panthor]
>  op_unmap_cb.isra.23.constprop.30+0x54/0x80
>  __drm_gpuvm_sm_unmap+0x184/0x1c8
>  drm_gpuvm_sm_unmap+0x40/0x60
>  panthor_vm_exec_op+0xa8/0x120 [panthor]
>  panthor_vm_bind_exec_sync_op+0xc4/0xe8 [panthor]
>  panthor_ioctl_vm_bind+0x10c/0x170 [panthor]
>  drm_ioctl_kernel+0xbc/0x138
>  drm_ioctl+0x210/0x4b0
>  __arm64_sys_ioctl+0xb0/0xf8
>  invoke_syscall+0x4c/0x110
>  el0_svc_common.constprop.1+0x98/0xf8
>  do_el0_svc+0x24/0x38
>  el0_svc+0x34/0xc8
>  el0t_64_sync_handler+0xa0/0xc8
>  el0t_64_sync+0x174/0x178
> <snip>
> panthor : [drm] drm_WARN_ON(unmapped_sz != pgsize * pgcount)
> WARNING: CPU: 1 PID: 650 at drivers/gpu/drm/panthor/panthor_mmu.c:922 panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
> <snip>
> pc : panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
> lr : panthor_vm_unmap_pages+0x124/0x1c8 [panthor]
> <snip>
> panthor : [drm] *ERROR* failed to unmap range ffffa388f000-ffffa3890000 (requested range ffffa388c000-ffffa3890000)
> 
> Fixes: 647810ec2476 ("drm/panthor: Add the MMU/VM logical block")
> Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
> Reviewed-by: Steven Price <steven.price@arm.com>
> Signed-off-by: Akash Goel <akash.goel@arm.com>

Oops, sorry, didn't notice the v2 before adding my R-b on v1.

Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>

> ---
>  drivers/gpu/drm/panthor/panthor_mmu.c | 2 ++
>  1 file changed, 2 insertions(+)
> 
> diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
> index d8cc9e7d064e..8d05124793f5 100644
> --- a/drivers/gpu/drm/panthor/panthor_mmu.c
> +++ b/drivers/gpu/drm/panthor/panthor_mmu.c
> @@ -989,6 +989,8 @@ panthor_vm_map_pages(struct panthor_vm *vm, u64 iova, int prot,
>  
>  		if (!size)
>  			break;
> +
> +		offset = 0;
>  	}
>  
>  	return panthor_vm_flush_range(vm, start_iova, iova - start_iova);


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

end of thread, other threads:[~2024-11-12  9:08 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-11 13:47 [PATCH v2] drm/panthor: Fix handling of partial GPU mapping of BOs Akash Goel
2024-11-12  9:08 ` Boris Brezillon

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox