From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=51.210.91.56 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796389957; b=meIJVXQDbCe3SfgY7uUbS2Jb1wyWJpvnnqwF00FI2qK0XM4yCQy95AEiNQwQSIyJ9wFJ rwEbEmtV+GEHl7ufztc1jEuKwkyJ5KTH/uyyESlZAOs1IFXa964Fhz2gmFLIr4tgo+jln JTrSQO9OQm2SIIOQlyhxqmyTasGC5LJJ2FL8N+1MVlYyDw2uWF4xhf3tgiCbkHkcnMCJY GUvnCyeh39QireslPXjq7ehrVawjEIkBJZOvIzoIyOdNfjSRRnSv7kfz1FbVNar94f5UT wurmkx9PT5+ALBol+9rBEB/QIKchKKJhgbaH8b3+nYnPuSs1vJw4awVSVsjTV8sudng== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796389957; h=DMARC-Filter:Received:Received:Received:Received:X-OVh-ClientIp:From: To:Cc:Subject:Date:Message-ID:In-Reply-To:References:MIME-Version: Content-Transfer-Encoding:Content-Type:x-ovh-tracer-id:X-VR-SPAMSTATE: X-VR-SPAMSCORE:X-VR-SPAMCAUSE:DKIM-Signature; bh=H2JEliPioDvK/e1dDoG6khFwDHr0MqUAFXTHSGZ58Rs=; b=GObx/tO3rSHWM+JXk2s61CUkykWPQArsNYStFUWmkUf8+3TAlRnl0GNXTbYLzU+9qkXB EOEQUCRqcoeT2W3QqD9WNvPnOGSdJmTWgHI/XgiqSbK1yVc8hxHZ7TRhtL0xnwCi3uccL R8ePF2y505a5m9vnrG/RMYEUeV8ompEKidjq4EzQQS+8LSZuzMjSyzP8CdmFHtPKEdFOv IJdz2V2a4x1a9adh6XhS+TLTA8iLMqvWlz39wX4z43ft3X/QhEvh3/ZJav0f3//89zqRa jV4cFLjKHMQMRQm8KcSIGFFvrRe9vD1k9dn1o6wslTdmJXA74FHNCiuhlOVpyXF+j0g== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=pixelcluster.dev; spf=pass smtp.mailfrom=pixelcluster.dev; dkim=pass header.d=pixelcluster.dev header.i=@pixelcluster.dev header.a=rsa-sha256 header.s=ovhmo-selector-1 header.b=D020uGve; arc=none smtp.remote-ip=51.210.91.56 Received: from smtpout7.mo540.mail-out.ovh.net (smtpout7.mo540.mail-out.ovh.net [51.210.91.56]) (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 A6B0F606A339 for ; Fri, 4 Dec 2026 13:12:35 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org A6B0F606A339 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pixelcluster.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pixelcluster.dev 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 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-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list 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== 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