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 93EAB3A7F67 for ; Tue, 7 Apr 2026 10:24:54 +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=1775557496; cv=none; b=svMOmYwugyC3OIepwNV+IzV9dotrvNgnSovTNk7YvlLXMf57vAGqj/A+/TtKV3OhpdM5P8MeGCpBTugIL91yVlv/5xHM8/wgNe8l2yWOEHk/gBR8Tun8zTLwz9zuC3hu4oJ/qp53Wv3PKYxW4csTxxmkc1rxZ7Ax27yjYaJYBz4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775557496; c=relaxed/simple; bh=P84J4DpPHfNA1XgiSG9LfalCjiIJ7nZCSsvpmJp37fI=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=VOfFp7iw/VKDRuxL+jF0M9eX1YNlH+2+fVLfOJ7xbq5H0QhV/hBewrFdbBy9taSdanhnwhqeDMtL0hZG8Ohnr3H6ltlI6BONFQPIYqRGk9ARrRo4PRd6PgYr62Nu+zl93CQqkKZQ+JyNqdZnB83rbfiovxSE/M7elpFjnf8Zxj0= 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=d/uUepr+; 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="d/uUepr+" 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 2168F1C14 for ; Tue, 7 Apr 2026 03:24:48 -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 AA6653F641 for ; Tue, 7 Apr 2026 03:24:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1775557493; bh=P84J4DpPHfNA1XgiSG9LfalCjiIJ7nZCSsvpmJp37fI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=d/uUepr+3nALw5G1KApd/B5g7awHDIq3wCOxJ+nn32jRP9pbXGORkfC9c1ZfCkRBR r2d4H5KdjHPaCuT7V2tVDrfVyJU+/74oVZeNmnOQtDlgApABz/zHCKDSOD7Mr7MgSN pnh6oi+rODTCg2CmH48QRkUou8h5PvI2KBwGYrnM= Date: Tue, 7 Apr 2026 11:24:52 +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 1/2] drm/panthor: Extend VM locked region for remap case to be a superset Message-ID: References: <20260403172116.3424075-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: <20260403172116.3424075-1-adrian.larumbe@collabora.com> On Fri, Apr 03, 2026 at 06:21:11PM +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") > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 13 +++++++++++++ > 1 file changed, 13 insertions(+) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index fa8b31df85c9..2b96359d3b94 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -1709,6 +1709,19 @@ 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. > + */ > + if (vm->locked_region.size) { Why is this check needed? We're updating the vm->locked_region.size later anyway, and I think we can cope with a locked region being of zero size when we are called, unless we consider that to be a bug and we should check earlier for a zero value. > + u64 end = start + size; Like Boris pointed out, the calculations can be optimized so that we don't need this line. > + > + start = min(start, vm->locked_region.start); > + size = max(vm->locked_region.start + > + vm->locked_region.size, end) - start; If we have something like: ..... [start .. start+size] ...... [vm->locked_region.start .. vm->locked_region.start + vm->locked_region.size] .... we end up locking ..... [start ................................................. vm->locked_region.start + vm->locked_region.size] .... is that intended? Best regards, Liviu > + } > + > mutex_lock(&ptdev->mmu->as.slots_lock); > if (vm->as.id >= 0 && size) { > /* Lock the region that needs to be updated */ > > base-commit: fb42964e2a76f68a5fb581d382b5d2be2d5bda9b > -- > 2.53.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯