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 2C30256B871 for ; Tue, 22 Sep 2026 16:43:37 +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=1790095421; cv=none; b=Riwmnd+U/x5rrserdDnyqqoor75XWHCBpZGL88LgdBPlNhQfAfT1G7ACbXFIrDBG0fSRL1l8J2y9RypG9jkUmd9lvG7WgiYZRZYeFJ5uKQHBabpRn4uy5ngY7lXWgmBDSuoB4wV/ueZKNpprUQ8sNHxVjlRlbeNaV3u44ORTo7I= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1790095421; c=relaxed/simple; bh=oZodBLOvhWZnhGBhFyedqhlpKfrMwQq9wmTh3Vz6cE4=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=EAcSaNBqtqunzeAPeZO1X0fpdbc3zn6Geej0xF3OYjDsV8iiXLm3hnm9dclAYJpu57v1FkLZ43INBAd2xeak3Cr2QwarknfP5xAA0VOm01weSZPzMfOBw/TdD5N/s2aJQ1TCcG3euupN31U8bThFd7+s/UkRX17PCvuLP6TDA7o= 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=Z1fijE0f; 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="Z1fijE0f" 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 300461BC0 for ; Tue, 22 Sep 2026 09:43:33 -0700 (PDT) Received: from [10.2.11.34] (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id 7D0DE3F632 for ; Tue, 22 Sep 2026 09:43:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=arm.com; s=foss; t=1790095416; bh=oZodBLOvhWZnhGBhFyedqhlpKfrMwQq9wmTh3Vz6cE4=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=Z1fijE0fZDuEwmgSdEF42GE4nu+1yQZ6o/TkrrnSKPasqvdej1bKzf6EGEZbKm6dG e7bGw4A82NMjCrTnltnBRFdWDMvaalQZOBMkau+tTHb/WzNxT6DFPxwBxzJVQgaNzi sijy1YaiAJd8Bj1ovvy5iFg0bYr03A+i2qVR+E8A= Date: Tue, 22 Sep 2026 17:43:16 +0100 From: Liviu Dudau To: Boris Brezillon Cc: Steven Price , =?utf-8?Q?Adri=C3=A1n?= Larumbe , Akash Goel , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH 4/4] drm/panthor: Actually check huge-page mapping on sparse regions Message-ID: References: <20260917-panthor-fix-partial-unmap-v1-0-c7008f15fea3@collabora.com> <20260917-panthor-fix-partial-unmap-v1-4-c7008f15fea3@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: <20260917-panthor-fix-partial-unmap-v1-4-c7008f15fea3@collabora.com> On Thu, Sep 17, 2026 at 02:33:46PM +0200, Boris Brezillon wrote: > With the recent changes to iova_mapped_as_huge_page(), the check for > huge-page mapping of sparse BOs is actually simple: > > - for a sparse mapping, we know the BO offset any VA in this regions is > va & (SZ_2M - 1) > - the VA we're searching the BO offset for is the 2M-aligned > aligned_va value > > This guarantees that the BO offset to check is always zero in that case. > > This is simple enough to let the code check if page 0 is a huge page > and save the unmap+map dance when the dummy BO is not backed by a > a huge page. So let's do that and kill the comment that says it's too > complicated. > > Signed-off-by: Boris Brezillon Reviewed-by: Liviu Dudau Best regards, Liviu > --- > drivers/gpu/drm/panthor/panthor_mmu.c | 15 ++++++++------- > 1 file changed, 8 insertions(+), 7 deletions(-) > > diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c > index d2897099763e..01564d250adf 100644 > --- a/drivers/gpu/drm/panthor/panthor_mmu.c > +++ b/drivers/gpu/drm/panthor/panthor_mmu.c > @@ -2337,18 +2337,18 @@ iova_mapped_as_huge_page(struct drm_gpuva *mapping, u64 va) > > return false; > } else { > - const struct page *pg = bo->backing.pages[bo_offset >> PAGE_SHIFT]; > struct panthor_vma *vma = container_of(mapping, struct panthor_vma, base); > bool is_sparse = vma->flags & DRM_PANTHOR_VM_BIND_OP_MAP_SPARSE; > + const struct page *pg; > > - /* If the unmapped VMA stands for a sparse mapping, always > - * assume the backing storage is a THP, since the overhead of > - * unmapping 2MiB worth of 4KiB pages and remapping some of > - * them is offset by the logic of working out whether it's > - * the opposite case right below. > + /* BO offset on a sparse mapping is chosen so that 2M-aligned > + * VAs point to the start of the BO. Since aligned_va (the > + * address we check huge-page against) is 2M-aligned, the BO > + * offset is guaranteed to be zero. > + * Check panthor_fix_sparse_map_offset() for more details. > */ > if (is_sparse) > - return true; > + bo_offset = 0; > > /* In case of shmem backing, we know we can only have a huge > * mapping if the bo_offset is 2M aligned, meaning we can skip > @@ -2357,6 +2357,7 @@ iova_mapped_as_huge_page(struct drm_gpuva *mapping, u64 va) > if (!IS_ALIGNED(bo_offset, SZ_2M)) > return false; > > + pg = bo->backing.pages[bo_offset >> PAGE_SHIFT]; > return folio_size(page_folio(pg)) >= SZ_2M; > } > } > > -- > 2.55.0 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯