Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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.

Fixes: 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages")
Reviewed-by: Boris Brezillon <boris.brezillon@collabora.com>
Reviewed-by: Steven Price <steven.price@arm.com>
Reviewed-by: Liviu Dudau <liviu.dudau@arm.com>
Link: https://patch.msgid.link/20260408191228.537625-1-adrian.larumbe@collabora.com
Signed-off-by: Adrián Larumbe <adrian.larumbe@collabora.com>

+19
+19
drivers/gpu/drm/panthor/panthor_mmu.c
··· 1638 1638 start + size <= vm->locked_region.start + vm->locked_region.size) 1639 1639 return 0; 1640 1640 1641 + /* sm_step_remap() may need a locked region that isn't a strict superset 1642 + * of the original one because of having to extend unmap boundaries beyond 1643 + * it to deal with partial unmaps of transparent huge pages. What we want 1644 + * in those cases is to lock the union of both regions. The new region must 1645 + * always overlap with the original one, because the upper and lower unmap 1646 + * boundaries in a remap operation can only shift up or down respectively, 1647 + * but never otherwise. 1648 + */ 1649 + if (vm->locked_region.size) { 1650 + u64 end = max(vm->locked_region.start + vm->locked_region.size, 1651 + start + size); 1652 + 1653 + drm_WARN_ON_ONCE(&vm->ptdev->base, (start + size <= vm->locked_region.start) || 1654 + (start >= vm->locked_region.start + vm->locked_region.size)); 1655 + 1656 + start = min(start, vm->locked_region.start); 1657 + size = end - start; 1658 + } 1659 + 1641 1660 mutex_lock(&ptdev->mmu->as.slots_lock); 1642 1661 if (vm->as.id >= 0 && size) { 1643 1662 /* Lock the region that needs to be updated */