From: Matthew Brost <matthew.brost@intel.com>
To: intel-xe@lists.freedesktop.org, dri-devel@lists.freedesktop.org
Cc: kernel test robot <lkp@intel.com>, Jan Stancek <jstancek@redhat.com>
Subject: [PATCH] drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION
Date: Tue, 21 Jul 2026 15:32:44 -0700 [thread overview]
Message-ID: <20260721223244.1102276-1-matthew.brost@intel.com> (raw)
HPAGE_PMD_SHIFT expands to BUILD_BUG() when CONFIG_PGTABLE_HAS_HUGE_LEAVES
is not set, causing a compile error when both CONFIG_TRANSPARENT_HUGEPAGE
and CONFIG_HUGETLB_PAGE are disabled:
drivers/gpu/drm/drm_pagemap.c:480:12: error: call to '__compiletime_assert_458'
declared with 'error' attribute: BUILD_BUG failed
480 | order = HPAGE_PMD_ORDER;
| ^
include/linux/huge_mm.h:117:26: note: expanded from macro 'HPAGE_PMD_ORDER'
117 | #define HPAGE_PMD_ORDER (HPAGE_PMD_SHIFT-PAGE_SHIFT)
| ^
include/linux/huge_mm.h:113:28: note: expanded from macro 'HPAGE_PMD_SHIFT'
113 | #define HPAGE_PMD_SHIFT ({ BUILD_BUG(); 0; })
Define DRM_PAGEMAP_PMD_ORDER, which maps to HPAGE_PMD_ORDER when
CONFIG_ARCH_ENABLE_THP_MIGRATION is enabled and to -1 otherwise.
This is safe because all code paths that use DRM_PAGEMAP_PMD_ORDER are
reachable only when CONFIG_ARCH_ENABLE_THP_MIGRATION is enabled.
Fixes: 139ab31aea8a ("drm/pagemap: Correct cpages calculation for migrate_vma_setup")
Reported-by: kernel test robot <lkp@intel.com>
Closes: https://lore.kernel.org/r/202607201914.LpAGsbXs-lkp@intel.com/
Cc: Jan Stancek <jstancek@redhat.com>
Signed-off-by: Matthew Brost <matthew.brost@intel.com>
---
drivers/gpu/drm/drm_pagemap.c | 13 ++++++++++---
1 file changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_pagemap.c b/drivers/gpu/drm/drm_pagemap.c
index 15c78eca180b..951cd92c930c 100644
--- a/drivers/gpu/drm/drm_pagemap.c
+++ b/drivers/gpu/drm/drm_pagemap.c
@@ -12,6 +12,12 @@
#include <drm/drm_pagemap_util.h>
#include <drm/drm_print.h>
+#if IS_ENABLED(CONFIG_ARCH_ENABLE_THP_MIGRATION)
+#define DRM_PAGEMAP_PMD_ORDER HPAGE_PMD_ORDER
+#else
+#define DRM_PAGEMAP_PMD_ORDER (-1)
+#endif
+
/**
* DOC: Overview
*
@@ -579,7 +585,7 @@ static int drm_pagemap_cpages(unsigned long *migrate_pfn, unsigned long npages)
order = folio_order(folio);
cpages += NR_PAGES(order);
} else if (migrate_pfn[i] & MIGRATE_PFN_COMPOUND) {
- order = HPAGE_PMD_ORDER;
+ order = DRM_PAGEMAP_PMD_ORDER;
cpages += NR_PAGES(order);
}
@@ -765,10 +771,11 @@ int drm_pagemap_migrate_to_devmem(struct drm_pagemap_devmem *devmem_allocation,
if (migrate.src[i] & MIGRATE_PFN_COMPOUND) {
drm_WARN_ONCE(dpagemap->drm, src_page &&
- folio_order(page_folio(src_page)) != HPAGE_PMD_ORDER,
+ folio_order(page_folio(src_page)) !=
+ DRM_PAGEMAP_PMD_ORDER,
"Unexpected folio order\n");
- order = HPAGE_PMD_ORDER;
+ order = DRM_PAGEMAP_PMD_ORDER;
migrate.dst[i] |= MIGRATE_PFN_COMPOUND;
for (j = 1; j < NR_PAGES(order) && i + j < npages; j++)
--
2.34.1
next reply other threads:[~2026-07-21 22:32 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-21 22:32 Matthew Brost [this message]
2026-07-21 22:50 ` ✓ CI.KUnit: success for drm/pagemap: Guard HPAGE_PMD_ORDER use with CONFIG_ARCH_ENABLE_THP_MIGRATION Patchwork
2026-07-21 23:41 ` ✓ Xe.CI.BAT: " Patchwork
2026-07-22 5:21 ` [PATCH] " Jan Stancek
2026-07-22 5:32 ` Ghimiray, Himal Prasad
2026-07-22 14:46 ` ✗ Xe.CI.FULL: failure for " 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=20260721223244.1102276-1-matthew.brost@intel.com \
--to=matthew.brost@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=jstancek@redhat.com \
--cc=lkp@intel.com \
/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