drm/panthor: Extend VM locked region for remap case to be a superset
Subsystems (3)
PATCH v2 1/2 drm/panthor: Extend VM locked region for remap case to be a superset
In the event of an sm_step_remap() that leads to a partial unmap of a transparent huge page, the new locked region required by an extended unmap might not be a superset of the original one. Then, if it leaves a portion of the initially requested one out, the ensuing map will trigger a warning.
--- drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)
drivers/gpu/drm/panthor/panthor_mmu.c +19 -0
@@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size) start + size <= vm->locked_region.start + vm->locked_region.size)return 0 ; +/* sm_step_remap() may need a locked region that isn't a strict superset +* of the original one because of having to extend unmap boundaries beyond +* it to deal with partial unmaps of transparent huge pages. What we want +* in those cases is to lock the union of both regions. The new region must +* always overlap with the original one, because the upper and lower unmap +* boundaries in a remap operation can only shift up or down respectively, +* but never otherwise. +*/ +if (vm->locked_region.size) { +u64 end =max (vm->locked_region.start + vm->locked_region.size, + start + size); + +drm_WARN_ON_ONCE (&vm->ptdev->base, (start + size <= vm->locked_region.start) || + (start >= vm->locked_region.start + vm->locked_region.size)); + + start =min (start, vm->locked_region.start); + size = end - start; + } +mutex_lock (&ptdev->mmu->as.slots_lock);if (vm->as.id >=0 && size) {/* Lock the region that needs to be updated */
Signature · 1 line
2.53.0
PATCH v2 2/2 drm/panthor: Fix outdated function documentation
'vm' is no longer allowed to be NULL.
--- drivers/gpu/drm/panthor/panthor_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/panthor/panthor_gem.c +1 -1
@@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)/** * panthor_kernel_bo_create() - Create and map a GEM object to a VM * @ptdev: Device. -* @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped. +* @vm: VM to map the GEM to. * @size: Size of the buffer object. * @bo_flags: Combination of drm_panthor_bo_flags flags. * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
Signature · 1 line
2.53.0
Re: [PATCH v2 2/2] drm/panthor: Fix outdated function documentation
Quoted 4 lines · Adrián Larumbe
'vm' is no longer allowed to be NULL.
Signed-off-by Adrián Larumbe <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
Best regards,
Liviu
Quoted 20 lines
--- drivers/gpu/drm/panthor/panthor_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/panthor/panthor_gem.c +1
-1@@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)/** * panthor_kernel_bo_create() - Create and map a GEM object to a VM * @ptdev: Device. -* @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped. +* @vm: VM to map the GEM to. * @size: Size of the buffer object. * @bo_flags: Combination of drm_panthor_bo_flags flags. * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those Signature · 1 line
2.53.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Re: [PATCH v2 2/2] drm/panthor: Fix outdated function documentation
In reply to Adrián LarumbeQuoted 4 lines · Adrián Larumbe
'vm' is no longer allowed to be NULL.
Signed-off-by Adrián Larumbe <[email protected]>Reviewed-by Boris Brezillon <[email protected]>
And for completeness:
Thanks,
Steve
Quoted 17 lines
--- drivers/gpu/drm/panthor/panthor_gem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/gpu/drm/panthor/panthor_gem.c +1
-1@@ -1264,7 +1264,7 @@ void panthor_kernel_bo_destroy(struct panthor_kernel_bo *bo)/** * panthor_kernel_bo_create() - Create and map a GEM object to a VM * @ptdev: Device. -* @vm: VM to map the GEM to. If NULL, the kernel object is not GPU mapped. +* @vm: VM to map the GEM to. * @size: Size of the buffer object. * @bo_flags: Combination of drm_panthor_bo_flags flags. * @vm_map_flags: Combination of drm_panthor_vm_bind_op_flags (only those
Quoted 8 lines · Adrián Larumbe
In the event of an
sm_step_remap()that leads to a partial unmap of a transparent huge page, the new locked region required by an extended unmap might not be a superset of the original one. Then, if it leaves a portion of the initially requested one out, the ensuing map will trigger a warning.Signed-off-by Adrián Larumbe <[email protected]>Fixes 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")Reviewed-by Boris Brezillon <[email protected]>
Best regards,
Liviu
Quoted 37 lines
--- drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpu/drm/panthor/panthor_mmu.c +19
-0@@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size) start + size <= vm->locked_region.start + vm->locked_region.size)return 0 ; +/* sm_step_remap() may need a locked region that isn't a strict superset +* of the original one because of having to extend unmap boundaries beyond +* it to deal with partial unmaps of transparent huge pages. What we want +* in those cases is to lock the union of both regions. The new region must +* always overlap with the original one, because the upper and lower unmap +* boundaries in a remap operation can only shift up or down respectively, +* but never otherwise. +*/ +if (vm->locked_region.size) { +u64 end =max (vm->locked_region.start + vm->locked_region.size, + start + size); + +drm_WARN_ON_ONCE (&vm->ptdev->base, (start + size <= vm->locked_region.start) || + (start >= vm->locked_region.start + vm->locked_region.size)); + + start =min (start, vm->locked_region.start); + size = end - start; + } +mutex_lock (&ptdev->mmu->as.slots_lock);if (vm->as.id >=0 && size) {/* Lock the region that needs to be updated */ Signature · 1 line
2.53.0
Signature · 8 lines
====================
| I would like to |
| fix the world, |
| but they're not |
| giving me the |
\ source code! /
---------------
¯\_(ツ)_/¯Quoted 8 lines · Adrián Larumbe
In the event of an
sm_step_remap()that leads to a partial unmap of a transparent huge page, the new locked region required by an extended unmap might not be a superset of the original one. Then, if it leaves a portion of the initially requested one out, the ensuing map will trigger a warning.Signed-off-by Adrián Larumbe <[email protected]>Fixes 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")Reviewed-by Boris Brezillon <[email protected]>
Although I'm starting to wonder if we should split this into an "initial lock" and an "expand lock" function. Still as a minimal fix this is good.
Thanks,
Steve
Quoted 34 lines
--- drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpu/drm/panthor/panthor_mmu.c +19
-0@@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size) start + size <= vm->locked_region.start + vm->locked_region.size)return 0 ; +/* sm_step_remap() may need a locked region that isn't a strict superset +* of the original one because of having to extend unmap boundaries beyond +* it to deal with partial unmaps of transparent huge pages. What we want +* in those cases is to lock the union of both regions. The new region must +* always overlap with the original one, because the upper and lower unmap +* boundaries in a remap operation can only shift up or down respectively, +* but never otherwise. +*/ +if (vm->locked_region.size) { +u64 end =max (vm->locked_region.start + vm->locked_region.size, + start + size); + +drm_WARN_ON_ONCE (&vm->ptdev->base, (start + size <= vm->locked_region.start) || + (start >= vm->locked_region.start + vm->locked_region.size)); + + start =min (start, vm->locked_region.start); + size = end - start; + } +mutex_lock (&ptdev->mmu->as.slots_lock);if (vm->as.id >=0 && size) {/* Lock the region that needs to be updated */
Adrián Larumbe
AppliedQueued to drm-misc-fixes.
Quoted 43 lines · Adrián Larumbe
In the event of an
sm_step_remap()that leads to a partial unmap of a transparent huge page, the new locked region required by an extended unmap might not be a superset of the original one. Then, if it leaves a portion of the initially requested one out, the ensuing map will trigger a warning.Signed-off-by Adrián Larumbe <[email protected]>Fixes 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")Reviewed-by Boris Brezillon <[email protected]>--- drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+)drivers/gpu/drm/panthor/panthor_mmu.c +19
-1@@ -1709,6 +1709,25 @@ static int panthor_vm_lock_region(struct panthor_vm *vm, u64 start, u64 size) start + size <= vm->locked_region.start + vm->locked_region.size)return 0 ; +/* sm_step_remap() may need a locked region that isn't a strict superset +* of the original one because of having to extend unmap boundaries beyond +* it to deal with partial unmaps of transparent huge pages. What we want +* in those cases is to lock the union of both regions. The new region must +* always overlap with the original one, because the upper and lower unmap +* boundaries in a remap operation can only shift up or down respectively, +* but never otherwise. +*/ +if (vm->locked_region.size) { +u64 end =max (vm->locked_region.start + vm->locked_region.size, + start + size); + +drm_WARN_ON_ONCE (&vm->ptdev->base, (start + size <= vm->locked_region.start) || + (start >= vm->locked_region.start + vm->locked_region.size)); + + start =min (start, vm->locked_region.start); + size = end - start; + } +mutex_lock (&ptdev->mmu->as.slots_lock);if (vm->as.id >=0 && size) {/* Lock the region that needs to be updated */ --
Quoted 1 line
2.53.0
Adrian Larumbe