From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 54885364924 for ; Wed, 8 Apr 2026 19:12:57 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=pass smtp.client-ip=136.143.188.112 ARC-Seal:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775675578; cv=pass; b=G8mp7OuQfZRTJ1RMDPxKwChJyefDylstTYHI05e9/kzJHxe4hOz0axl7WPUJHtHQFZgLaK2OrTEwgcIZfiVnaa7EZkiNHNL2IxQeH+vPQojKCYvccUTrTAvKXUAcdZlN9aUTJrcAFDxZ/oulvWBqOo3x0DRkrnErEeQ2L+ytIW8= ARC-Message-Signature:i=2; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775675578; c=relaxed/simple; bh=Hq2a0vO/Fwm5rQhojWnlKJ9aoQB7R08k9Qwpran8/Sk=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version:Content-Type; b=suJm0/PMkbwPrJ7XqiE9Spo4F5ZCeiY8/jDtIJNv5Rz9WYUU+h2D1EzPj/elZIUSCYTt7R+qnIqIo72F4vHISW5xbgJg+dXMVRd+vbbWY/OtjpPbdnxTQJQnNPMk8pZ7V4TgQZ1mjoBS+ROCpbMr6IlIQgi/kvTWrMPvrPs6iHg= ARC-Authentication-Results:i=2; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com; spf=pass smtp.mailfrom=collabora.com; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b=UyxCxFqL; arc=pass smtp.client-ip=136.143.188.112 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=collabora.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=collabora.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="UyxCxFqL" ARC-Seal: i=1; a=rsa-sha256; t=1775675560; cv=none; d=zohomail.com; s=zohoarc; b=jyZ7FVih1h6YIdu9PPkqF0tOHH93y/UiwNZPSqDMr/Lt4A0+1BNjqHAqHQdKGbIkBQvYeYiIv0GEP/hgQYfYJyxorv/91tmqjkPYztYTShcKCsMh3Sw/LBDbYJaf1rh4yIoDU5tHCR78W8I2ABvTCoSDMDitWjtgpN1aucIhw7U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775675560; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=n/Zee9Hhj/2+a1a4DheluHV0HFn0a57HKQZdQjLdj/s=; b=HqXATlXymJmts2l8U3qt35y/Oj3w3+8A4oBfqJBTCvlyR9C47C0snqNeoCzBXDnWTeHzz+tyBztO1VkH1wcgMhxqbffZqZOAIFfAeoTmPa9+/E5oO5nORw4myc8rIAnhDJFQFkJZEQUnEMHE+gprEP5cicCkqzPAxettmLCroTQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1775675560; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=n/Zee9Hhj/2+a1a4DheluHV0HFn0a57HKQZdQjLdj/s=; b=UyxCxFqLjBspujCzVkyZZ4eSGVJtDNt4QAs06D31oDPQrKvg8zUGs1sUgMMsGWd8 vrjFuyFpP6uITezIf01bkF5sdwcg6C5j1xFCx8fA61837exN3VpDHXFn5aICv+tWZ40 hKNUVQBDcWUcEVqn+Ve+3W2CIErrgA5hF7H5mE7g= Received: by mx.zohomail.com with SMTPS id 1775675559570760.2920810435542; Wed, 8 Apr 2026 12:12:39 -0700 (PDT) From: =?UTF-8?q?Adri=C3=A1n=20Larumbe?= To: linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Steven Price , Boris Brezillon , kernel@collabora.com, =?UTF-8?q?Adri=C3=A1n=20Larumbe?= , Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Subject: [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Date: Wed, 8 Apr 2026 20:12:23 +0100 Message-ID: <20260408191228.537625-1-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 Fixes: 8e7460eac786 ("drm/panthor: Support partial unmaps of huge pages") Reviewed-by: Boris Brezillon --- drivers/gpu/drm/panthor/panthor_mmu.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c index fa8b31df85c9..bd41c892beb7 100644 --- a/drivers/gpu/drm/panthor/panthor_mmu.c +++ b/drivers/gpu/drm/panthor/panthor_mmu.c @@ -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 */ -- 2.53.0