From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (prime256v1) server-digest SHA256) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 58DA3606A322 for ; Fri, 4 Dec 2026 13:18:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key, unprotected) header.d=pixelcluster.dev header.i=@pixelcluster.dev header.a=rsa-sha256 header.s=ovhmo-selector-1 header.b=D020uGve Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 1CF9810E87A; Fri, 4 Dec 2026 13:17:58 +0000 (UTC) X-Greylist: delayed 321 seconds by postgrey-1.36 at gabe; Fri, 04 Dec 2026 13:17:51 UTC Received: from smtpout6.mo540.mail-out.ovh.net (smtpout6.mo540.mail-out.ovh.net [51.210.91.55]) by gabe.freedesktop.org (Postfix) with ESMTPS id 2115110EA96 for ; Fri, 4 Dec 2026 13:17:51 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net [79.137.60.36]) by mo540.mail-out.ovh.net (Postfix) with ESMTPS id 4jgsNW5yc0z45Hp; Fri, 4 Dec 2026 13:12:27 +0000 (UTC) Received: from director2.derp.mail-out.ovh.net (director2.derp.mail-out.ovh.net. [127.0.0.1]) by director2.derp.mail-out.ovh.net (inspect_sender_mail_agent) with SMTP for ; Fri, 4 Dec 2026 13:12:27 +0000 (UTC) Received: from mta11.priv.ovhmail-u1.ea.mail.ovh.net (unknown [10.110.0.63]) by director2.derp.mail-out.ovh.net (Postfix) with ESMTPS id 4jgsNW4zqjz1ykX; Fri, 4 Dec 2026 13:12:27 +0000 (UTC) Received: from pixelcluster.dev (unknown [10.1.6.6]) (Authenticated sender: nat@pixelcluster.dev) by mta11.priv.ovhmail-u1.ea.mail.ovh.net (Postfix) with ESMTPSA id E846A9A177B; Fri, 4 Dec 2026 13:12:26 +0000 (UTC) Authentication-Results: garm.ovh; auth=pass (GARM-114S008092c2954-4730-4e6b-9a21-e46fc43fb544, C72A8C269379148255D259EF506AD3C5C1B61040) smtp.auth=nat@pixelcluster.dev X-OVh-ClientIp: 141.95.41.139 From: Natalie Vock To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org, Matthew Brost Cc: Carlos Santa , Ryan Neph , Arun Pravin , Matthew Auld , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , linux-kernel@vger.kernel.org, Thomas =?UTF-8?B?SGVsbHN0csO2bQ==?= , Niranjana Vishwanathapura Subject: Re: [PATCH v6 02/35] drm/ttm/pool: Add ttm_pool_page_order_nodma() helper Date: Fri, 04 Dec 2026 14:12:26 +0100 Message-ID: In-Reply-To: <20261203202352.4153159-3-matthew.brost@intel.com> References: <20261203202352.4153159-1-matthew.brost@intel.com> <20261203202352.4153159-3-matthew.brost@intel.com> X-Archived-By: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" x-ovh-tracer-id: 13563434704198590780 X-VR-SPAMSTATE: OK X-VR-SPAMSCORE: -100 X-VR-SPAMCAUSE: dmFkZTGz6sL0E8IvN8pe+gz3Buklfz7vUr+W5KAUacCsKEs3jTWoqXOr2KHBYh0oRseSYPZ1czesvY31ufIf6BsVezssGj1sycGGJoSsSz8WFDkj9ubIS2rWWA82zQ+vvzIFx/fpssEncws/z6aGt15G39nQlxcFKHMMSuLPldCYgniyN4DzbPNKtVS8+jeosq4y3Q6NV064RbEcz/t5P+gkXKF2mlKYJ6m4n1vdGlpvTEIZKei1sNXNO0+6LpSFi0fTDgQroBil54NbufuZzB1UPx5/pwTtK+a7UI/hd0RYmefP/kzcBPIDroHpbI90ffHJwKzqUO1GyhP9mDZAvP90UxseO/kfo/jGCpGH2K3sf1JG82KAuSLNuC47gw+Y4oKaCJtFtVtXz6SFEi1tmrTwxApA4BNnw+O3tSbUdGBAtfTOgFOondqy4TUu3j+rJ64ZCiAq9qZO1jNPIQSrkg1Y5ORrc9l6O2uwfFJ5AfKIPYg0Ki8Run5gkeq0q8aWlhcG8NsBA73USHoCVXs0Ft6yzyRKDmlLQNQDsVwlLe03vbhjuTAvwmsG2ypptoaN1FROrgaSPqJdmsJzkzHskZ3hlIIWdTErvp5Cx2eIUNONd6vAtfMBwtHQqVHF5VNHlGJzFskNVzlsxGxaFF56U4PytSjEaXNVorB8HWtv9fdPxDEJSA DKIM-Signature: a=rsa-sha256; bh=H2JEliPioDvK/e1dDoG6khFwDHr0MqUAFXTHSGZ58Rs=; c=relaxed/relaxed; d=pixelcluster.dev; h=From; s=ovhmo-selector-1; t=1796389948; v=1; b=D020uGveJHdNvMCZCJXRdO7icRx94k8LmapueiyglhVaPDsWV4iRP978XcMNhBehtk/+HB5h SnN8++cGbZ34h91F+ONP5iTezDZDSGALlHc/R1PNIirCROKzTvnuJRYHVT5Fp8hpP6jn2ggdQyg vDgreYEvJsSh5jh4KOCOS1sWk2OAtnTdZuQAgDTYq77IPPc6rUTPc2cSoFsROWkuOgFCmaTiEkg wpPSKUFR/zGnqBhRsuKI6PnRWPtEVZFSxlaIlhBP+oP96WjgnxyB/g67rVmk2EAQQ08HY3sWzsL yxIsTtRnZ7UZdvDObIEvnPWt9KoVkxcuJS9mbznGtcRcQ== X-BeenThere: intel-xe@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel Xe graphics driver List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Intel-xe" X-Spam-Status: No, score=-16.0 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_CR_TRAILER,INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE, SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on aws-us-west-2-korg-listserv-alma10-1 On Thursday, 3 December 2026 21:23 Matthew Brost wrote: > TTM records the allocation order of a multi-order page in page->private at > allocation time. For pools that do not use dma_alloc the order is stored > directly, while dma_alloc pools store a struct ttm_pool_dma pointer there > instead. Drivers that do their own DMA mapping (e.g. Xe) need the per-page > order to walk a populated ttm_tt one chunk at a time, but cannot rely on > folio_order(): TTM allocates high-order pages with alloc_pages_node() > without __GFP_COMP, so they are not compound and folio_order() always > returns 0. I'm not completely sure why this is needed? Is the problem that you don't know the relevant ttm_pool at the callsite? AFAICT Xe never sets TTM_ALLOCATION_POOL_USE_DMA_ALLOC, so why isn't ttm_pool_page_order enough? Besides, why can't TTM know about the IOVA-based DMA mapping? Managing DMA mappings for pool pages sounds like a TTM responsibility, is there any reason why the logic needs to be hidden from it inside Xe? Thanks, Natalie >=20 > Expose ttm_pool_page_order_nodma(), a thin wrapper that returns the order > recorded in page->private. It is only valid for pages from a pool that do= es > not use dma_alloc; whether a TTM device uses dma_alloc is fixed at ttm > device init time, so callers know from their device configuration that th= is > helper applies. Use it from the existing internal ttm_pool_page_order() to > keep a single source of truth. >=20 > v4: > - const struct page (Niranjana) >=20 > Cc: Carlos Santa > Cc: Ryan Neph > Cc: Natalie Vock > Cc: Arun Pravin > Cc: Matthew Auld > Cc: Maarten Lankhorst > Cc: Maxime Ripard > Cc: Thomas Zimmermann > Cc: David Airlie > Cc: Simona Vetter > Cc: dri-devel@lists.freedesktop.org > Cc: linux-kernel@vger.kernel.org > Cc: Thomas Hellstr=C3=B6m > Signed-off-by: Matthew Brost > Reviewed-by: Matthew Auld > Reviewed-by: Niranjana Vishwanathapura > --- > drivers/gpu/drm/ttm/ttm_pool.c | 25 ++++++++++++++++++++++++- > include/drm/ttm/ttm_pool.h | 2 ++ > 2 files changed, 26 insertions(+), 1 deletion(-) >=20 > diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_poo= l.c > index 16fd125d7375..c6fbcdba9bdb 100644 > --- a/drivers/gpu/drm/ttm/ttm_pool.c > +++ b/drivers/gpu/drm/ttm/ttm_pool.c > @@ -477,6 +477,29 @@ static unsigned int ttm_pool_shrink(int nid, unsigne= d long num_to_free) > return num_pages; > } > =20 > +/** > + * ttm_pool_page_order_nodma() - Allocation order of a non-dma_alloc TTM= page > + * @p: The page to query. > + * > + * Return the allocation order that the TTM pool allocator recorded in > + * @p->private at allocation time. This only works for pages that were > + * allocated from a pool which does *not* use dma_alloc (i.e. pages back= ed by > + * alloc_pages_node()), where TTM stores the order directly in page->pri= vate. > + * > + * For dma_alloc pools, page->private instead holds a struct ttm_pool_dma > + * pointer and this helper must not be used. Whether a TTM device uses > + * dma_alloc is fixed at ttm device init time, so callers are expected t= o know > + * from their TTM device configuration that their pages are not dma_alloc > + * backed before using this helper. > + * > + * Return: The allocation order of the page. > + */ > +unsigned int ttm_pool_page_order_nodma(const struct page *p) > +{ > + return p->private; > +} > +EXPORT_SYMBOL(ttm_pool_page_order_nodma); > + > /* Return the allocation order based for a page */ > static unsigned int ttm_pool_page_order(struct ttm_pool *pool, struct pa= ge *p) > { > @@ -486,7 +509,7 @@ static unsigned int ttm_pool_page_order(struct ttm_po= ol *pool, struct page *p) > return dma->vaddr & ~PAGE_MASK; > } > =20 > - return p->private; > + return ttm_pool_page_order_nodma(p); > } > =20 > /* > diff --git a/include/drm/ttm/ttm_pool.h b/include/drm/ttm/ttm_pool.h > index bb6347e5b297..429f4f987a19 100644 > --- a/include/drm/ttm/ttm_pool.h > +++ b/include/drm/ttm/ttm_pool.h > @@ -94,6 +94,8 @@ long ttm_pool_backup(struct ttm_pool *pool, struct ttm_= tt *ttm, > int ttm_pool_restore_and_alloc(struct ttm_pool *pool, struct ttm_tt *tt, > const struct ttm_operation_ctx *ctx); > =20 > +unsigned int ttm_pool_page_order_nodma(const struct page *p); > + > int ttm_pool_mgr_init(void); > void ttm_pool_mgr_fini(void); > =20 >=20