From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1072D38F928 for ; Thu, 9 Apr 2026 08:55:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775724943; cv=none; b=DjRLCqxFj2gHc2sRmsD1XMve7MZKhGsY/j8kQTEzPkdoFwVM7pf9HsrReCnFJjKFF5MGHeOnk2UhSDStEd9b2+45Tkz4dsSyRYipiqUhGtS37N/7xz3u9/sW9jHeaLjsTIs2/KqNkEBUAo089ZxFjRB+uaeSr5v3ZddzZ2twVus= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775724943; c=relaxed/simple; bh=FQwh7ifOeKNUZinqOs+C2D/V3SfMnaMEU4gnoF8mfF4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=OndYzJeE+kCXN3vUc3bLGbMwHTqyW2dX/aR4CEEBLt9EHkh0C5UpAyj8DLDIit9FVYKG+ElXZVl5dsWfmxI8kfzKju7djq9feiwslMlPdqH6+B3MNjVKKipyEKLX04Iw7VmvnHaOn+vX/Cugsyx7wgQi/5A203MFHX1bLab29PI= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b=JmOobXAu; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=arm.com header.i=@arm.com header.b="JmOobXAu" Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 51CC43517 for ; Thu, 9 Apr 2026 01:55:32 -0700 (PDT) Received: from [192.168.0.1] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id D16643F641 for ; Thu, 9 Apr 2026 01:55:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1775724938; bh=FQwh7ifOeKNUZinqOs+C2D/V3SfMnaMEU4gnoF8mfF4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=JmOobXAurSCLXCYMPzUyPEV3YLy/QW64a1PbE/GIL837iQ1SvYHCA5ldxDXKF6Eqm 5WtMJ6P6N/MDdhaIUY0QdjlRTq59enaet4JOqdjh4xm1gOYqVdXZocM5M7Ji1XRKuA zwYm7YU7k+GQDt5D7Yx3y9bIjlvR3lCZJleXkAks= Date: Thu, 9 Apr 2026 09:55:35 +0100 From: Liviu Dudau To: =?utf-8?Q?Adri=C3=A1n?= Larumbe Cc: linux-kernel@vger.kernel.org, dri-devel@lists.freedesktop.org, Steven Price , Boris Brezillon , kernel@collabora.com, Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter Subject: Re: [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Message-ID: References: <20260408191228.537625-1-adrian.larumbe@collabora.com> 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-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20260408191228.537625-1-adrian.larumbe@collabora.com> On Wed, Apr 08, 2026 at 08:12:23PM +0100, Adrián Larumbe wrote: > 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 Reviewed-by: Liviu Dudau Best regards, Liviu > --- > 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 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯