From: Matthew Brost <matthew.brost@intel.com>
To: Francois Dugast <francois.dugast@intel.com>
Cc: <intel-xe@lists.freedesktop.org>, <dri-devel@lists.freedesktop.org>
Subject: Re: [PATCH v2 3/5] drm/pagemap: Add helper to access zone_device_data
Date: Mon, 5 Jan 2026 07:53:31 -0800 [thread overview]
Message-ID: <aVvee9P8lSE7m68G@lstrano-desk.jf.intel.com> (raw)
In-Reply-To: <20260105111945.73292-4-francois.dugast@intel.com>
On Mon, Jan 05, 2026 at 12:18:26PM +0100, Francois Dugast wrote:
> This new helper helps ensure all accesses to zone_device_data use the
> correct API whether the page is part of a folio or not.
>
> v2:
> - Move to drm_pagemap.h, stick to folio_zone_device_data (Matthew Brost)
> - Return struct drm_pagemap_zdd * (Matthew Brost)
>
> Suggested-by: Matthew Brost <matthew.brost@intel.com>
> Signed-off-by: Francois Dugast <francois.dugast@intel.com>
Reviewed-by: Matthew Brost <matthew.brost@intel.com>
> ---
> drivers/gpu/drm/drm_gpusvm.c | 7 +++++--
> drivers/gpu/drm/drm_pagemap.c | 21 ++++++++++++---------
> include/drm/drm_pagemap.h | 15 +++++++++++++++
> 3 files changed, 32 insertions(+), 11 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_gpusvm.c b/drivers/gpu/drm/drm_gpusvm.c
> index aa9a0b60e727..585d913d3d19 100644
> --- a/drivers/gpu/drm/drm_gpusvm.c
> +++ b/drivers/gpu/drm/drm_gpusvm.c
> @@ -1488,12 +1488,15 @@ int drm_gpusvm_get_pages(struct drm_gpusvm *gpusvm,
> order = drm_gpusvm_hmm_pfn_to_order(pfns[i], i, npages);
> if (is_device_private_page(page) ||
> is_device_coherent_page(page)) {
> + struct drm_pagemap_zdd *__zdd =
> + drm_pagemap_page_zone_device_data(page);
> +
> if (!ctx->allow_mixed &&
> - zdd != page->zone_device_data && i > 0) {
> + zdd != __zdd && i > 0) {
> err = -EOPNOTSUPP;
> goto err_unmap;
> }
> - zdd = page->zone_device_data;
> + zdd = __zdd;
> if (pagemap != page_pgmap(page)) {
> if (i > 0) {
> err = -EOPNOTSUPP;
> diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c
> index f63d72004a71..db3795f03aca 100644
> --- a/drivers/gpu/drm/drm_pagemap.c
> +++ b/drivers/gpu/drm/drm_pagemap.c
> @@ -252,7 +252,7 @@ static int drm_pagemap_migrate_map_pages(struct device *dev,
> order = folio_order(folio);
>
> if (is_device_private_page(page)) {
> - struct drm_pagemap_zdd *zdd = page->zone_device_data;
> + struct drm_pagemap_zdd *zdd = drm_pagemap_page_zone_device_data(page);
> struct drm_pagemap *dpagemap = zdd->dpagemap;
> struct drm_pagemap_addr addr;
>
> @@ -323,7 +323,7 @@ static void drm_pagemap_migrate_unmap_pages(struct device *dev,
> goto next;
>
> if (is_zone_device_page(page)) {
> - struct drm_pagemap_zdd *zdd = page->zone_device_data;
> + struct drm_pagemap_zdd *zdd = drm_pagemap_page_zone_device_data(page);
> struct drm_pagemap *dpagemap = zdd->dpagemap;
>
> dpagemap->ops->device_unmap(dpagemap, dev, pagemap_addr[i]);
> @@ -601,7 +601,8 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
>
> pages[i] = NULL;
> if (src_page && is_device_private_page(src_page)) {
> - struct drm_pagemap_zdd *src_zdd = src_page->zone_device_data;
> + struct drm_pagemap_zdd *src_zdd =
> + drm_pagemap_page_zone_device_data(src_page);
>
> if (page_pgmap(src_page) == pagemap &&
> !mdetails->can_migrate_same_pagemap) {
> @@ -721,8 +722,8 @@ static int drm_pagemap_migrate_populate_ram_pfn(struct vm_area_struct *vas,
> goto next;
>
> if (fault_page) {
> - if (src_page->zone_device_data !=
> - fault_page->zone_device_data)
> + if (drm_pagemap_page_zone_device_data(src_page) !=
> + drm_pagemap_page_zone_device_data(fault_page))
> goto next;
> }
>
> @@ -1063,7 +1064,7 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas,
> void *buf;
> int i, err = 0;
>
> - zdd = page->zone_device_data;
> + zdd = drm_pagemap_page_zone_device_data(page);
> if (time_before64(get_jiffies_64(), zdd->devmem_allocation->timeslice_expiration))
> return 0;
>
> @@ -1146,7 +1147,9 @@ static int __drm_pagemap_migrate_to_ram(struct vm_area_struct *vas,
> */
> static void drm_pagemap_folio_free(struct folio *folio)
> {
> - drm_pagemap_zdd_put(folio->page.zone_device_data);
> + struct page *page = folio_page(folio, 0);
> +
> + drm_pagemap_zdd_put(drm_pagemap_page_zone_device_data(page));
> }
>
> /**
> @@ -1162,7 +1165,7 @@ static void drm_pagemap_folio_free(struct folio *folio)
> */
> static vm_fault_t drm_pagemap_migrate_to_ram(struct vm_fault *vmf)
> {
> - struct drm_pagemap_zdd *zdd = vmf->page->zone_device_data;
> + struct drm_pagemap_zdd *zdd = drm_pagemap_page_zone_device_data(vmf->page);
> int err;
>
> err = __drm_pagemap_migrate_to_ram(vmf->vma,
> @@ -1228,7 +1231,7 @@ EXPORT_SYMBOL_GPL(drm_pagemap_devmem_init);
> */
> struct drm_pagemap *drm_pagemap_page_to_dpagemap(struct page *page)
> {
> - struct drm_pagemap_zdd *zdd = page->zone_device_data;
> + struct drm_pagemap_zdd *zdd = drm_pagemap_page_zone_device_data(page);
>
> return zdd->devmem_allocation->dpagemap;
> }
> diff --git a/include/drm/drm_pagemap.h b/include/drm/drm_pagemap.h
> index 46e9c58f09e0..736fb6cb7b33 100644
> --- a/include/drm/drm_pagemap.h
> +++ b/include/drm/drm_pagemap.h
> @@ -4,6 +4,7 @@
>
> #include <linux/dma-direction.h>
> #include <linux/hmm.h>
> +#include <linux/memremap.h>
> #include <linux/types.h>
>
> #define NR_PAGES(order) (1U << (order))
> @@ -359,4 +360,18 @@ int drm_pagemap_populate_mm(struct drm_pagemap *dpagemap,
> void drm_pagemap_destroy(struct drm_pagemap *dpagemap, bool is_atomic_or_reclaim);
>
> int drm_pagemap_reinit(struct drm_pagemap *dpagemap);
> +
> +/**
> + * drm_pagemap_page_zone_device_data() - Page to zone_device_data
> + * @page: Pointer to the page
> + *
> + * Return: Page's zone_device_data
> + */
> +static inline struct drm_pagemap_zdd *drm_pagemap_page_zone_device_data(struct page *page)
> +{
> + struct folio *folio = page_folio(page);
> +
> + return folio_zone_device_data(folio);
> +}
> +
> #endif
> --
> 2.43.0
>
next prev parent reply other threads:[~2026-01-05 15:53 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-05 11:18 [PATCH v2 0/5] Enable THP support in drm_pagemap Francois Dugast
2026-01-05 11:18 ` [PATCH v2 1/5] mm/migrate: Add migrate_device_split_page Francois Dugast
2026-01-05 11:18 ` [PATCH v2 2/5] drm/pagemap: Unlock and put folios when possible Francois Dugast
2026-01-05 11:18 ` [PATCH v2 3/5] drm/pagemap: Add helper to access zone_device_data Francois Dugast
2026-01-05 15:53 ` Matthew Brost [this message]
2026-01-05 11:18 ` [PATCH v2 4/5] DONOTMERGE drm/pagemap: Add drm_pagemap_cpages Francois Dugast
2026-01-05 16:51 ` Matthew Brost
2026-01-07 2:32 ` Matthew Brost
2026-01-05 11:18 ` [PATCH v2 5/5] drm/pagemap: Enable THP support for GPU memory migration Francois Dugast
2026-01-05 16:09 ` Matthew Brost
2026-01-06 12:47 ` Francois Dugast
2026-01-05 11:38 ` ✗ CI.checkpatch: warning for Enable THP support in drm_pagemap (rev2) Patchwork
2026-01-05 11:39 ` ✓ CI.KUnit: success " Patchwork
2026-01-05 11:58 ` ✗ CI.checksparse: warning " Patchwork
2026-01-05 12:19 ` ✓ Xe.CI.BAT: success " Patchwork
2026-01-05 14:04 ` ✗ Xe.CI.Full: failure " Patchwork
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aVvee9P8lSE7m68G@lstrano-desk.jf.intel.com \
--to=matthew.brost@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=francois.dugast@intel.com \
--cc=intel-xe@lists.freedesktop.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox