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 A9D823AA503 for ; Thu, 9 Apr 2026 09:16:04 +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=1775726173; cv=none; b=eLt35TlBhqZBKfInnRL5gEnqCysitMZyhlpaZFTDMVFKPlQkfo1bELmI1xEee12mBFyoPfhQQhMwdpiblYYnOufv4XmN4PGmzEXSjQWHaVzCs073dAAps/xd4aqAIvk3skq7/Vos17HjFujF4A8tiJjwHOtm0tgTGedLPjGuum0= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775726173; c=relaxed/simple; bh=Pkk4wD3nozGv3YZCYGo6W2Lp4SEFTmUk5vfvxArMIB8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=EhLBY1PTWcu5Mjpakd9E1cI7csHeOtDJ8f69VYGRvYFRzlhsRGBtePV5uMrUkiMsnHdolZvNgd7NzZXf29dtIT+gPkTmzV32ddSL2LJcaWb7wQosnFBM56mG3NIV+BNFQ9ReCIfOXqEZO5aPtAj+UyCoHfzLGQVup0PdjNBJV+M= 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=atf9O2pC; 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="atf9O2pC" 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 B70273517; Thu, 9 Apr 2026 02:15:56 -0700 (PDT) Received: from [10.1.29.18] (e122027.cambridge.arm.com [10.1.29.18]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 746583F641; Thu, 9 Apr 2026 02:16:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1775726162; bh=Pkk4wD3nozGv3YZCYGo6W2Lp4SEFTmUk5vfvxArMIB8=; h=Date:Subject:To:Cc:References:From:In-Reply-To:From; b=atf9O2pCgckiJkdQlILE5ADJtggeCuRw48kf6GCzOKgnMh4x9w1hbx6SMNk+DuBjd rPKErN3Xm5y0GRkUwcryObEL5w/cI4bTGyGk24EYZzbhIdgc652l8Vpe5TLjrE+fOu 4R0wrb2/0ufWOxWrgDAMU/dfHZAd78RRf3ZWqsTM= Message-ID: Date: Thu, 9 Apr 2026 10:15:58 +0100 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 1/2] drm/panthor: Extend VM locked region for remap case to be a superset To: =?UTF-8?Q?Adri=C3=A1n_Larumbe?= , linux-kernel@vger.kernel.org Cc: dri-devel@lists.freedesktop.org, Boris Brezillon , kernel@collabora.com, Liviu Dudau , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter References: <20260408191228.537625-1-adrian.larumbe@collabora.com> From: Steven Price Content-Language: en-GB In-Reply-To: <20260408191228.537625-1-adrian.larumbe@collabora.com> Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit On 08/04/2026 20:12, 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: Steven Price 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 > --- > 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 */