From: sashiko-bot@kernel.org
To: "Maarten Lankhorst" <dev@lankhorst.se>, intel-xe@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: Re: [PATCH v5 5/5] drm/i915: Introduce intel_bo_fbdev_bios_fb_takeover()
Date: Mon, 16 Nov 2026 13:59:10 +0000 [thread overview]
Message-ID: <sashiko-outbox-217123@kernel.org> (raw)
In-Reply-To: <20261116131349.333818-12-dev@lankhorst.se>
Thank you for your contribution! Sashiko AI review found 7 potential
issues to consider:
- [High] drm/xe: unmasked PTE PAT bits and stolen underflow in
initial_plane_bo()
- [High] drm/xe: emit_pte() omits stolen base offset for pre-12.70
stolen BOs
- [Medium] drm/xe: unconditional return false in
xe_display_bo_fbdev_prefer_stolen()
- [Medium] drm/i915: deferred BIOS FB takeover in bios_fb_pick() breaks
FBC and drm_panic
- [Medium] drm/i915/fbdev: double unpin on error in
__intel_fbdev_fb_realloc()
- [Medium] drm/xe/display: missing fence wait in
xe_display_bo_fbdev_bios_fb_takeover()
- [Low] drm/i915: commit message mismatch on bios_fb_pick() and
initial_plane_bo()
--
commit 9503bd0192927fbc3fe3b1c40cd72de52b1ba89d
Author: Maarten Lankhorst <dev@lankhorst.se>
drm/i915: Introduce intel_bo_fbdev_bios_fb_takeover()
This commit defers the stolen-memory suitability check for the BIOS
framebuffer from initial plane readout to fbdev probing via a new
intel_bo_fbdev_bios_fb_takeover() callback, and copies the stolen BIOS
framebuffer to system memory on Xe when stolen memory is not preferred.
> Additionally, bios_fb_ok() was renamed
> to bios_fb_takeover() with a different function signature.
[Severity: Low]
This isn't a bug, but the patch renames bios_fb_ok() to bios_fb_pick()
(while introducing intel_bo_fbdev_bios_fb_takeover() as the BO helper),
and the changelog also does not mention the phys_base calculation change
in initial_plane_bo().
> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/drm/i915/display/intel_fbdev.c
> index 219ee17de3f68..97d5e1279dbc1 100644
> --- a/drivers/gpu/drm/i915/display/intel_fbdev.c
> +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c
[ ... ]
> @@ -262,32 +262,68 @@ __intel_fbdev_fb_alloc(struct intel_display *display,
>
> }
>
> -static bool bios_fb_ok(const struct intel_framebuffer *fb,
> - const struct drm_fb_helper_surface_size *sizes)
> +static struct intel_framebuffer *
> +__intel_fbdev_fb_realloc(struct intel_display *display,
> + const struct drm_framebuffer *orig_fb,
> + struct drm_gem_object *obj)
> +{
> + struct drm_framebuffer *new_fb;
> + struct drm_mode_fb_cmd2 mode_cmd = {
> + .flags = DRM_MODE_FB_MODIFIERS,
> + .width = orig_fb->width,
> + .height = orig_fb->height,
> + .pitches[0] = orig_fb->pitches[0],
> + .offsets[0] = orig_fb->offsets[0],
> + .pixel_format = orig_fb->format->format,
> + .modifier[0] = orig_fb->modifier,
> + };
> +
> + new_fb = intel_framebuffer_create(obj, orig_fb->format, &mode_cmd);
> +
> + if (IS_ERR(new_fb)) {
> + intel_bo_fbdev_destroy(obj);
> + return ERR_CAST(new_fb);
> + }
[Severity: Medium]
Can intel_bo_fbdev_destroy(obj) double-unpin obj on Xe if
intel_framebuffer_create() fails after intel_bo_framebuffer_init()?
On Xe, xe_display_bo_fbdev_bios_fb_takeover() creates copy_bo with
XE_BO_FLAG_PINNED (pin_count == 1). If intel_framebuffer_init() fails at
a later step such as drm_framebuffer_init(), its error unwind calls
intel_bo_framebuffer_fini() -> xe_display_bo_framebuffer_fini(), which
sees XE_BO_FLAG_PINNED and calls xe_bo_unpin(bo) even though
xe_display_bo_framebuffer_init() only took a reference:
drivers/gpu/drm/xe/display/xe_display_bo.c:xe_display_bo_framebuffer_fini() {
struct xe_bo *bo = gem_to_xe_bo(obj);
if (bo->flags & XE_BO_FLAG_PINNED) {
/* Unpin our kernel fb first */
xe_bo_lock(bo, false);
xe_bo_unpin(bo);
xe_bo_unlock(bo);
}
xe_bo_put(bo);
}
Calling intel_bo_fbdev_destroy(obj) -> xe_bo_unpin_map_no_vm(copy_bo)
then unpins copy_bo a second time when pin_count is already 0, triggering
xe_assert() and WARN_ON_ONCE(!bo->pin_count) in ttm_bo_unpin().
[ ... ]
> @@ -305,13 +341,23 @@ int intel_fbdev_driver_fbdev_probe(struct drm_fb_helper *helper,
>
> ifbdev->fb = NULL;
>
> - if (fb && !bios_fb_ok(fb, sizes)) {
> - drm_framebuffer_put(&fb->base);
> - fb = NULL;
> - }
> -
> wakeref = intel_display_rpm_get(display);
>
> + if (fb) {
> + struct intel_framebuffer *bios_fb =
> + bios_fb_pick(fb, sizes);
> +
> + if (IS_ERR(bios_fb)) {
> + drm_dbg_kms(display->drm, "Re-using BIOS fb failed (%pe).", bios_fb);
> + bios_fb = NULL;
> + }
> +
> + if (fb != bios_fb) {
> + drm_framebuffer_put(&fb->base);
> + fb = bios_fb;
> + }
> + }
[Severity: Medium]
Does deferring the prefer_stolen check to intel_fbdev_driver_fbdev_probe()
break FBC allocation during initial commit and leave the stolen BIOS
framebuffer active on the hardware plane when fbcon takeover does not run
immediately?
First, removing the prefer_stolen check from initial_plane_vma() and
initial_plane_bo() keeps the BIOS framebuffer allocated in stolen memory
across intel_initial_commit(), which runs before intel_fbdev_setup().
When the BIOS framebuffer occupies more than half of stolen memory,
intel_fbc_alloc_cfb() -> find_compression_limit() during initial commit
either fails with -ENOSPC or permanently degrades the FBC compression
ratio (as intel_fbc_is_cfb_ok() does not reallocate a 1:1 CFB once the
initial FB is freed).
Second, when fb != bios_fb here, drm_framebuffer_put(&fb->base) only drops
ifbdev's reference while the primary plane's plane_state->hw.fb still
scans out the original stolen framebuffer until a modeset commit flips the
plane. When CONFIG_FRAMEBUFFER_CONSOLE_DEFERRED_TAKEOVER=y (during a
quiet boot) or CONFIG_FRAMEBUFFER_CONSOLE=n, register_framebuffer() does
not immediately call fb_set_par(), so the hardware plane continues
scanning out the stolen BO while ifbdev->fb points to the new system
memory FB. Aside from keeping the stolen BO active despite workarounds
(such as Wa_22018444074 on MTL and Wa_22019338487_display on Xe), a panic
in that window causes intel_get_scanout_buffer() to see
plane_state->hw.fb != intel_fbdev_framebuffer() and call
intel_parent_panic_setup() on the stolen BIOS BO, which fails on both
i915 (-EOPNOTSUPP) and Xe (ttm_bo_kmap_try_from_panic() returns NULL for
stolen memory).
> diff --git a/drivers/gpu/drm/xe/display/xe_display_bo.c b/drivers/gpu/drm/xe/display/xe_display_bo.c
> index d78d893210c4f..43d05a58bcb47 100644
> --- a/drivers/gpu/drm/xe/display/xe_display_bo.c
> +++ b/drivers/gpu/drm/xe/display/xe_display_bo.c
> @@ -120,7 +121,7 @@ static u32 xe_display_bo_fbdev_pitch_align(u32 stride)
> return ALIGN(stride, XE_PAGE_SIZE);
> }
>
> -bool xe_display_bo_fbdev_prefer_stolen(struct xe_device *xe, unsigned int size)
> +static bool xe_display_bo_fbdev_prefer_stolen(struct xe_device *xe, unsigned int size)
> {
> struct ttm_resource_manager *stolen;
>
> @@ -152,6 +153,64 @@ bool xe_display_bo_fbdev_prefer_stolen(struct xe_device *xe, unsigned int size)
> return stolen->size >= (size * 2) >> PAGE_SHIFT;
> }
[Severity: Medium]
Does xe_display_bo_fbdev_prefer_stolen() still have an unconditional
"return false;" right above the size check (introduced in earlier series
commit "HACK: Always fallback")? That makes the stolen->size check
unreachable and forces xe_display_bo_fbdev_bios_fb_takeover() to always
reject stolen memory and copy the BIOS framebuffer to system memory on
every integrated platform.
> +
> +static struct drm_gem_object *xe_display_bo_fbdev_bios_fb_takeover(struct drm_gem_object *obj)
> +{
> + struct xe_bo *orig_bo = gem_to_xe_bo(obj), *copy_bo;
> + struct xe_device *xe = xe_bo_device(orig_bo);
> + struct xe_validation_ctx ctx;
> + struct drm_exec exec;
> + int err;
> +
> + if (IS_DGFX(xe) ||
> + xe_display_bo_fbdev_prefer_stolen(xe, xe_bo_size(orig_bo)))
> + return obj;
> +
> + copy_bo = xe_bo_create_pin_map_novm(xe, xe_device_get_root_tile(xe), xe_bo_size(orig_bo),
> + ttm_bo_type_kernel,
> + XE_BO_FLAG_FORCE_WC | XE_BO_FLAG_SYSTEM | XE_BO_FLAG_GGTT,
> + false);
> + if (IS_ERR(copy_bo))
> + return ERR_CAST(copy_bo);
> +
> + xe_validation_guard(&ctx, &xe->val, &exec, (struct xe_val_flags) {}, err) {
> + struct dma_fence *fence;
> +
> + err = drm_exec_lock_obj(&exec, &orig_bo->ttm.base);
> + drm_exec_retry_on_contention(&exec);
> + if (err)
> + break;
> +
> + err = drm_exec_lock_obj(&exec, ©_bo->ttm.base);
> + drm_exec_retry_on_contention(&exec);
> + if (err)
> + break;
> +
> + err = dma_resv_reserve_fences(orig_bo->ttm.base.resv, 1);
> + if (err)
> + break;
> +
> + err = dma_resv_reserve_fences(copy_bo->ttm.base.resv, 1);
> + if (err)
> + break;
> +
> + fence = xe_migrate_copy(xe_device_get_root_tile(xe)->migrate, orig_bo, copy_bo,
> + orig_bo->ttm.resource, copy_bo->ttm.resource, false);
[Severity: High]
Does xe_migrate_copy() copy from physical address 0 instead of stolen
memory when orig_bo is in XE_PL_STOLEN on pre-12.70 integrated platforms
(such as TGL, ADL, or RPL)?
In __xe_migrate_copy(), src_is_vram is determined by is_devmem(), which
returns false for XE_PL_STOLEN when
xe_ttm_stolen_cpu_access_needs_ggtt(xe) is true (GRAPHICS_VERx100(xe) <
1270):
drivers/gpu/drm/xe/xe_migrate.c:is_devmem() {
if (res->mem_type != XE_PL_STOLEN ||
xe_ttm_stolen_cpu_access_needs_ggtt(xe_bo_device(bo)))
return false;
return true;
}
When is_vram is false, emit_pte() uses xe_res_dma(cur) & PAGE_MASK
(which is the 0-based offset within stolen memory) and skips adding
vram_region_gpu_offset(res) (xe_ttm_stolen_gpu_offset(xe)):
drivers/gpu/drm/xe/xe_migrate.c:emit_pte() {
...
addr = xe_res_dma(cur) & PAGE_MASK;
if (is_vram) {
...
addr += vram_region_gpu_offset(res);
devmem = true;
}
...
}
As a result, the migration PTEs map physical address 0x0 + offset instead
of stolen_base + offset, causing an IOMMU fault or copying low host RAM
into the fbdev framebuffer.
> + if (IS_ERR(fence)) {
> + err = PTR_ERR(fence);
> + break;
> + }
> +
> + dma_resv_add_fence(copy_bo->ttm.base.resv, fence, DMA_RESV_USAGE_KERNEL);
> + dma_resv_add_fence(orig_bo->ttm.base.resv, fence, DMA_RESV_USAGE_BOOKKEEP);
> + dma_fence_put(fence);
> +
> + return ©_bo->ttm.base;
[Severity: Medium]
Can CPU accesses to info->screen_base race with the asynchronous
xe_migrate_copy() blit when ©_bo->ttm.base is returned without waiting
for fence to signal?
In intel_fbdev_driver_fbdev_probe(), intel_bo_fbdev_fill_info() exposes
copy_bo->vmap.vaddr_iomem as info->screen_base without waiting on
copy_bo's reservation fences. If fb_set_par()'s modeset commit does not
run before CPU access (for instance under deferred console takeover or
when a DRM master is active), CPU writes to info->screen_base can be
overwritten by the in-flight GPU copy from orig_bo.
> diff --git a/drivers/gpu/drm/xe/display/xe_initial_plane.c b/drivers/gpu/drm/xe/display/xe_initial_plane.c
> index 0f86b73036d03..1c70ade960e86 100644
> --- a/drivers/gpu/drm/xe/display/xe_initial_plane.c
> +++ b/drivers/gpu/drm/xe/display/xe_initial_plane.c
> @@ -100,15 +99,8 @@ initial_plane_bo(struct xe_device *xe,
> return NULL;
> }
>
> - phys_base = base;
> + phys_base = (pte - xe_ttm_stolen_gpu_offset(xe)) & PAGE_MASK;
> flags |= XE_BO_FLAG_STOLEN;
[Severity: High]
Does masking with PAGE_MASK leave the upper GGTT PTE PAT bits (bits 52:53)
set in phys_base on Xe_LPG+ platforms?
On 64-bit kernels, PAGE_MASK is GENMASK_ULL(63, 12), whereas GGTT PTEs on
GRAPHICS_VERx100(xe) >= 1270 store XELPG_GGTT_PTE_PAT0 (BIT_ULL(52)) and
XELPG_GGTT_PTE_PAT1 (BIT_ULL(53)) above the physical address in
XE_PAGE_ADDR_MASK(PAGE_SHIFT) (GENMASK_ULL(51, 12)). When the BIOS/GOP
sets a non-zero PAT index in the GGTT PTE, phys_base retains bits 52:53,
and passing it as start to xe_bo_create_pin_map_at_novm() ->
__xe_bo_create_locked() calls:
drivers/gpu/drm/xe/xe_bo.c:__xe_bo_create_locked() {
...
if (flags & XE_BO_FLAG_FIXED_PLACEMENT) {
err = xe_ggtt_insert_bo_at(t->mem.ggtt, bo,
start + xe_bo_size(bo), U64_MAX,
exec);
}
...
}
Because start >= BIT_ULL(52) exceeds the GGTT size, xe_ggtt_insert_bo_at()
fails with -ENOSPC and breaks BIOS framebuffer takeover. In addition,
pte is not checked against XE_PAGE_PRESENT or bounds-checked against
xe_ttm_stolen_gpu_offset(xe) before subtraction (which can underflow
phys_base on pre-12.70 platforms where need_pte_local(xe) is false), and
passing the stolen offset phys_base (often 0) as start to
__xe_bo_create_locked() no longer tells xe_ggtt_insert_bo_at() to avoid
the active BIOS GGTT range at plane_config->base.
--
Sashiko AI review · https://sashiko.dev/#/patchset/20261116131349.333818-7-dev@lankhorst.se?part=5
next prev parent reply other threads:[~2026-11-16 13:59 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-16 13:13 [PATCH v5 0/5] drm/xe/display: Transparant fallback from stolen to sysmem Maarten Lankhorst
2026-11-16 13:13 ` [PATCH v5 1/5] drm/xe/display: Avoid using stolen memory for framebuffer when media gt exists Maarten Lankhorst
2026-11-16 13:13 ` [PATCH v5 2/5] drm/xe/migrate: Support copying between sysmem and stolen Maarten Lankhorst
2026-11-16 13:29 ` sashiko-bot
2026-11-16 13:13 ` [PATCH v5 3/5] drm/xe: Raise gt frequency slightly earlier Maarten Lankhorst
2026-11-16 13:13 ` [PATCH v5 4/5] HACK: Always fallback Maarten Lankhorst
2026-11-16 13:25 ` sashiko-bot
2026-11-16 13:13 ` [PATCH v5 5/5] drm/i915: Introduce intel_bo_fbdev_bios_fb_takeover() Maarten Lankhorst
2026-11-16 13:26 ` Ville Syrjälä
2026-11-16 13:59 ` sashiko-bot [this message]
2026-11-16 15:53 ` ✗ CI.checkpatch: warning for drm/xe/display: Transparant fallback from stolen to sysmem. (rev6) Patchwork
2026-11-16 15:55 ` ✓ CI.KUnit: success " Patchwork
-- strict thread matches above, loose matches on Subject: below --
2026-11-13 12:44 [PATCH v5 0/5] drm/xe/display: Transparant fallback from stolen to sysmem Maarten Lankhorst
2026-11-13 12:44 ` [PATCH v5 5/5] drm/i915: Introduce intel_bo_fbdev_bios_fb_takeover() Maarten Lankhorst
2026-11-13 13:21 ` Ville Syrjälä
2026-11-15 12:17 ` Maarten Lankhorst
2026-11-13 13:22 ` sashiko-bot
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=sashiko-outbox-217123@kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dev@lankhorst.se \
--cc=intel-gfx@lists.freedesktop.org \
--cc=intel-xe@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
/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