Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id B0329FEA82F for ; Wed, 25 Mar 2026 08:13:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 3E4A910E81B; Wed, 25 Mar 2026 08:13:36 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=intel.com header.i=@intel.com header.b="Cg2rTR57"; dkim-atps=neutral Received: from mgamail.intel.com (mgamail.intel.com [192.198.163.8]) by gabe.freedesktop.org (Postfix) with ESMTPS id 0B5C510E817; Wed, 25 Mar 2026 08:13:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1774426414; x=1805962414; h=from:to:cc:subject:in-reply-to:references:date: message-id:mime-version:content-transfer-encoding; bh=SU8A5Ps2qh9d3a9SWduAruOPWhbVXyGVduYXZopaXHQ=; b=Cg2rTR57PdmDwCBXiyX70Mduj4G+hGF5AEJbylHa6jt1mBPRcUu5QK2h 35oS0o/CeL0gTnAC1PitTyB/pAd9xQcf5dZKxUqpfMhdyHswg+JTPXCQu nlyh4KKzo2PQCAGhqzpZjmdTLlj4QkCJ0CDlm6ydUuLegQ8t25tXJFoKX pblsbkX7rUr5pznGwwi6XW4h5HabYhn1ea3ihxQzidJ2R+zF3nZ0M1Xik TLq1oGN8/UZXbvmETycJUod4sLj3yPRPKR3Oo9z31SheeDGK4GNwUMW+4 px7hOCAWLvdnPoszKLSoQENbyev/Uih2DHUEWwPL8ISr0m8P27pM6jj4I w==; X-CSE-ConnectionGUID: 9ISlhvw7RLaxoRxiOVk4FQ== X-CSE-MsgGUID: c1VWCSiRQmKfCFEH4VAoXg== X-IronPort-AV: E=McAfee;i="6800,10657,11739"; a="93034071" X-IronPort-AV: E=Sophos;i="6.23,139,1770624000"; d="scan'208";a="93034071" Received: from fmviesa008.fm.intel.com ([10.60.135.148]) by fmvoesa102.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2026 01:13:34 -0700 X-CSE-ConnectionGUID: QjJCAj4SSRKlB66G/5fj6A== X-CSE-MsgGUID: GutfMSMBQgudSoSUzq2gJg== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="6.23,139,1770624000"; d="scan'208";a="221717028" Received: from slindbla-desk.ger.corp.intel.com (HELO localhost) ([10.245.246.119]) by fmviesa008-auth.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 25 Mar 2026 01:13:31 -0700 From: Jani Nikula To: =?utf-8?Q?Micha=C5=82?= Grzelak Cc: "intel-gfx@lists.freedesktop.org" , "intel-xe@lists.freedesktop.org" Subject: Re: [PATCH 3/5] drm/{i915, xe}: move fbdev fb calls to parent interface In-Reply-To: Organization: Intel Finland Oy - BIC 0357606-4 - c/o Alberga Business Park, 6 krs Bertel Jungin Aukio 5, 02600 Espoo, Finland References: <37ec4a959c375a9099b42d11aa9454c51a96aec2.1773840563.git.jani.nikula@intel.com> Date: Wed, 25 Mar 2026 10:13:28 +0200 Message-ID: <7f26ecaf1f47e36aebff7d8fe7904bb71f1c73a0@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-BeenThere: intel-gfx@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Intel graphics driver community testing & development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: intel-gfx-bounces@lists.freedesktop.org Sender: "Intel-gfx" On Wed, 25 Mar 2026, Micha=C5=82 Grzelak wrote: > On Wed, 18 Mar 2026, Jani Nikula wrote: >> Move the driver specific fbdev fb calls to the display parent >> interface. Reuse the existing struct intel_display_bo_interface, as this >> is mostly about gem objects. >> >> Put everything behind IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) to catch >> configuration issues at build or link time. >> >> Signed-off-by: Jani Nikula >> --- >> drivers/gpu/drm/i915/Makefile | 3 +- >> drivers/gpu/drm/i915/display/intel_bo.c | 27 ++++ >> drivers/gpu/drm/i915/display/intel_bo.h | 8 ++ >> drivers/gpu/drm/i915/display/intel_fbdev.c | 14 +-- >> drivers/gpu/drm/i915/display/intel_fbdev_fb.c | 118 ------------------ >> drivers/gpu/drm/i915/display/intel_fbdev_fb.h | 24 ---- >> drivers/gpu/drm/i915/i915_bo.c | 116 +++++++++++++++++ >> drivers/gpu/drm/i915/i915_bo.h | 6 + >> drivers/gpu/drm/i915/i915_initial_plane.c | 4 +- >> drivers/gpu/drm/xe/Makefile | 1 - >> drivers/gpu/drm/xe/display/intel_fbdev_fb.c | 116 ----------------- >> drivers/gpu/drm/xe/display/xe_display_bo.c | 117 +++++++++++++++++ >> drivers/gpu/drm/xe/display/xe_display_bo.h | 6 + >> drivers/gpu/drm/xe/display/xe_initial_plane.c | 4 +- >> include/drm/intel/display_parent_interface.h | 7 ++ >> 15 files changed, 299 insertions(+), 272 deletions(-) >> delete mode 100644 drivers/gpu/drm/i915/display/intel_fbdev_fb.c >> delete mode 100644 drivers/gpu/drm/i915/display/intel_fbdev_fb.h >> delete mode 100644 drivers/gpu/drm/xe/display/intel_fbdev_fb.c >> >> diff --git a/drivers/gpu/drm/i915/Makefile b/drivers/gpu/drm/i915/Makefi= le >> index be976a90c5a6..026614d74cc4 100644 >> --- a/drivers/gpu/drm/i915/Makefile >> +++ b/drivers/gpu/drm/i915/Makefile >> @@ -324,8 +324,7 @@ i915-$(CONFIG_ACPI) +=3D \ >> display/intel_acpi.o \ >> display/intel_opregion.o >> i915-$(CONFIG_DRM_FBDEV_EMULATION) +=3D \ >> - display/intel_fbdev.o \ >> - display/intel_fbdev_fb.o >> + display/intel_fbdev.o >> i915-$(CONFIG_DEBUG_FS) +=3D \ >> display/intel_display_debugfs.o \ >> display/intel_display_debugfs_params.o \ >> diff --git a/drivers/gpu/drm/i915/display/intel_bo.c b/drivers/gpu/drm/i= 915/display/intel_bo.c >> index 3b82d38a0504..8ecdbb7e39f3 100644 >> --- a/drivers/gpu/drm/i915/display/intel_bo.c >> +++ b/drivers/gpu/drm/i915/display/intel_bo.c >> @@ -85,3 +85,30 @@ struct drm_gem_object *intel_bo_framebuffer_lookup(st= ruct intel_display *display >> { >> return display->parent->bo->framebuffer_lookup(display->drm, filp, user= _mode_cmd); >> } >> + >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> +u32 intel_bo_fbdev_pitch_align(struct intel_display *display, u32 strid= e) >> +{ >> + return display->parent->bo->fbdev_pitch_align(stride); >> +} >> + >> +struct drm_gem_object *intel_bo_fbdev_create(struct intel_display *disp= lay, int size) >> +{ >> + return display->parent->bo->fbdev_create(display->drm, size); >> +} >> + >> +void intel_bo_fbdev_destroy(struct drm_gem_object *obj) >> +{ >> + struct intel_display *display =3D to_intel_display(obj->dev); >> + >> + display->parent->bo->fbdev_destroy(obj); >> +} >> + >> +int intel_bo_fbdev_fill_info(struct drm_gem_object *obj, struct fb_info= *info, >> + struct i915_vma *vma) >> +{ >> + struct intel_display *display =3D to_intel_display(obj->dev); >> + >> + return display->parent->bo->fbdev_fill_info(obj, info, vma); >> +} >> +#endif >> diff --git a/drivers/gpu/drm/i915/display/intel_bo.h b/drivers/gpu/drm/i= 915/display/intel_bo.h >> index aec188c706c2..348f7fa66960 100644 >> --- a/drivers/gpu/drm/i915/display/intel_bo.h >> +++ b/drivers/gpu/drm/i915/display/intel_bo.h >> @@ -10,6 +10,8 @@ struct drm_file; >> struct drm_gem_object; >> struct drm_mode_fb_cmd2; >> struct drm_scanout_buffer; >> +struct fb_info; >> +struct i915_vma; >> struct intel_display; >> struct intel_framebuffer; >> struct seq_file; >> @@ -31,4 +33,10 @@ struct drm_gem_object *intel_bo_framebuffer_lookup(st= ruct intel_display *display >> struct drm_file *filp, >> const struct drm_mode_fb_cmd2 *user_mode_cmd); >> >> +u32 intel_bo_fbdev_pitch_align(struct intel_display *display, u32 strid= e); >> +struct drm_gem_object *intel_bo_fbdev_create(struct intel_display *disp= lay, int size); >> +void intel_bo_fbdev_destroy(struct drm_gem_object *obj); >> +int intel_bo_fbdev_fill_info(struct drm_gem_object *obj, struct fb_info= *info, >> + struct i915_vma *vma); >> + >> #endif /* __INTEL_BO__ */ >> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev.c b/drivers/gpu/dr= m/i915/display/intel_fbdev.c >> index 6401aaaba199..14ac01c1b3eb 100644 >> --- a/drivers/gpu/drm/i915/display/intel_fbdev.c >> +++ b/drivers/gpu/drm/i915/display/intel_fbdev.c >> @@ -54,7 +54,6 @@ >> #include "intel_fb.h" >> #include "intel_fb_pin.h" >> #include "intel_fbdev.h" >> -#include "intel_fbdev_fb.h" >> #include "intel_frontbuffer.h" >> >> struct intel_fbdev { >> @@ -204,7 +203,8 @@ static const struct drm_fb_helper_funcs intel_fb_hel= per_funcs =3D { >> .fb_set_suspend =3D intelfb_set_suspend, >> }; >> >> -static void intel_fbdev_fill_mode_cmd(struct drm_fb_helper_surface_size= *sizes, >> +static void intel_fbdev_fill_mode_cmd(struct intel_display *display, >> + struct drm_fb_helper_surface_size *sizes, >> struct drm_mode_fb_cmd2 *mode_cmd) >> { >> /* we don't do packed 24bpp */ >> @@ -215,7 +215,7 @@ static void intel_fbdev_fill_mode_cmd(struct drm_fb_= helper_surface_size *sizes, >> mode_cmd->width =3D sizes->surface_width; >> mode_cmd->height =3D sizes->surface_height; >> >> - mode_cmd->pitches[0] =3D intel_fbdev_fb_pitch_align(mode_cmd->width * = DIV_ROUND_UP(sizes->surface_bpp, 8)); >> + mode_cmd->pitches[0] =3D intel_bo_fbdev_pitch_align(display, mode_cmd-= >width * DIV_ROUND_UP(sizes->surface_bpp, 8)); >> mode_cmd->pixel_format =3D drm_mode_legacy_fb_format(sizes->surface_bpp, >> sizes->surface_depth); >> mode_cmd->modifier[0] =3D DRM_FORMAT_MOD_LINEAR; >> @@ -230,12 +230,12 @@ __intel_fbdev_fb_alloc(struct intel_display *displ= ay, >> struct drm_gem_object *obj; >> int size; >> >> - intel_fbdev_fill_mode_cmd(sizes, &mode_cmd); >> + intel_fbdev_fill_mode_cmd(display, sizes, &mode_cmd); >> >> size =3D mode_cmd.pitches[0] * mode_cmd.height; >> size =3D PAGE_ALIGN(size); >> >> - obj =3D intel_fbdev_fb_bo_create(display->drm, size); >> + obj =3D intel_bo_fbdev_create(display, size); >> if (IS_ERR(obj)) { >> fb =3D ERR_CAST(obj); >> goto err; >> @@ -247,7 +247,7 @@ __intel_fbdev_fb_alloc(struct intel_display *display, >> mode_cmd.modifier[0]), >> &mode_cmd); >> if (IS_ERR(fb)) { >> - intel_fbdev_fb_bo_destroy(obj); >> + intel_bo_fbdev_destroy(obj); >> goto err; >> } >> >> @@ -327,7 +327,7 @@ int intel_fbdev_driver_fbdev_probe(struct drm_fb_hel= per *helper, >> >> obj =3D intel_fb_bo(&fb->base); >> >> - ret =3D intel_fbdev_fb_fill_info(obj, info, vma); >> + ret =3D intel_bo_fbdev_fill_info(obj, info, vma); >> if (ret) >> goto out_unpin; >> >> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c b/drivers/gpu= /drm/i915/display/intel_fbdev_fb.c >> deleted file mode 100644 >> index a696ce42d10b..000000000000 >> --- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.c >> +++ /dev/null >> @@ -1,118 +0,0 @@ >> -/* SPDX-License-Identifier: MIT */ >> -/* >> - * Copyright =C2=A9 2023 Intel Corporation >> - */ >> - >> -#include >> - >> -#include >> - >> -#include "gem/i915_gem_lmem.h" >> - >> -#include "i915_drv.h" >> -#include "intel_fbdev_fb.h" >> - >> -u32 intel_fbdev_fb_pitch_align(u32 stride) >> -{ >> - return ALIGN(stride, 64); >> -} >> - >> -bool intel_fbdev_fb_prefer_stolen(struct drm_device *drm, unsigned int = size) >> -{ >> - struct drm_i915_private *i915 =3D to_i915(drm); >> - >> - /* Skip stolen on MTL as Wa_22018444074 mitigation. */ >> - if (IS_METEORLAKE(i915)) >> - return false; >> - >> - /* >> - * If the FB is too big, just don't use it since fbdev is not very >> - * important and we should probably use that space with FBC or other >> - * features. >> - */ >> - return i915->dsm.usable_size >=3D size * 2; >> -} >> - >> -struct drm_gem_object *intel_fbdev_fb_bo_create(struct drm_device *drm,= int size) >> -{ >> - struct drm_i915_private *i915 =3D to_i915(drm); >> - struct drm_i915_gem_object *obj; >> - >> - obj =3D ERR_PTR(-ENODEV); >> - if (HAS_LMEM(i915)) { >> - obj =3D i915_gem_object_create_lmem(i915, size, >> - I915_BO_ALLOC_CONTIGUOUS | >> - I915_BO_ALLOC_USER); >> - } else { >> - if (intel_fbdev_fb_prefer_stolen(drm, size)) >> - obj =3D i915_gem_object_create_stolen(i915, size); >> - else >> - drm_info(drm, "Allocating fbdev: Stolen memory not preferred.\n"); >> - >> - if (IS_ERR(obj)) >> - obj =3D i915_gem_object_create_shmem(i915, size); >> - } >> - >> - if (IS_ERR(obj)) { >> - drm_err(drm, "failed to allocate framebuffer (%pe)\n", obj); >> - return ERR_PTR(-ENOMEM); >> - } >> - >> - return &obj->base; >> -} >> - >> -void intel_fbdev_fb_bo_destroy(struct drm_gem_object *obj) >> -{ >> - drm_gem_object_put(obj); >> -} >> - >> -int intel_fbdev_fb_fill_info(struct drm_gem_object *_obj, struct fb_inf= o *info, >> - struct i915_vma *vma) >> -{ >> - struct drm_i915_private *i915 =3D to_i915(_obj->dev); >> - struct drm_i915_gem_object *obj =3D to_intel_bo(_obj); >> - struct i915_gem_ww_ctx ww; >> - void __iomem *vaddr; >> - int ret; >> - >> - if (i915_gem_object_is_lmem(obj)) { >> - struct intel_memory_region *mem =3D obj->mm.region; >> - >> - /* Use fbdev's framebuffer from lmem for discrete */ >> - info->fix.smem_start =3D >> - (unsigned long)(mem->io.start + >> - i915_gem_object_get_dma_address(obj, 0) - >> - mem->region.start); >> - info->fix.smem_len =3D obj->base.size; >> - } else { >> - struct i915_ggtt *ggtt =3D to_gt(i915)->ggtt; >> - >> - /* Our framebuffer is the entirety of fbdev's system memory */ >> - info->fix.smem_start =3D >> - (unsigned long)(ggtt->gmadr.start + i915_ggtt_offset(vma)); >> - info->fix.smem_len =3D vma->size; >> - } >> - >> - for_i915_gem_ww(&ww, ret, false) { >> - ret =3D i915_gem_object_lock(vma->obj, &ww); >> - >> - if (ret) >> - continue; >> - >> - vaddr =3D i915_vma_pin_iomap(vma); >> - if (IS_ERR(vaddr)) { >> - drm_err(&i915->drm, >> - "Failed to remap framebuffer into virtual memory (%pe)\n", vaddr); >> - ret =3D PTR_ERR(vaddr); >> - continue; >> - } >> - } >> - >> - if (ret) >> - return ret; >> - >> - info->screen_base =3D vaddr; >> - info->screen_size =3D intel_bo_to_drm_bo(obj)->size; >> - >> - return 0; >> -} >> diff --git a/drivers/gpu/drm/i915/display/intel_fbdev_fb.h b/drivers/gpu= /drm/i915/display/intel_fbdev_fb.h >> deleted file mode 100644 >> index ddba45e9839d..000000000000 >> --- a/drivers/gpu/drm/i915/display/intel_fbdev_fb.h >> +++ /dev/null >> @@ -1,24 +0,0 @@ >> -/* SPDX-License-Identifier: MIT */ >> -/* >> - * Copyright =C2=A9 2023 Intel Corporation >> - */ >> - >> -#ifndef __INTEL_FBDEV_FB_H__ >> -#define __INTEL_FBDEV_FB_H__ >> - >> -#include >> - >> -struct drm_device; >> -struct drm_gem_object; >> -struct drm_mode_fb_cmd2; >> -struct fb_info; >> -struct i915_vma; >> - >> -u32 intel_fbdev_fb_pitch_align(u32 stride); >> -struct drm_gem_object *intel_fbdev_fb_bo_create(struct drm_device *drm,= int size); >> -void intel_fbdev_fb_bo_destroy(struct drm_gem_object *obj); >> -int intel_fbdev_fb_fill_info(struct drm_gem_object *obj, struct fb_info= *info, >> - struct i915_vma *vma); >> -bool intel_fbdev_fb_prefer_stolen(struct drm_device *drm, unsigned int = size); >> - >> -#endif >> diff --git a/drivers/gpu/drm/i915/i915_bo.c b/drivers/gpu/drm/i915/i915_= bo.c >> index 1789f7cab05c..7e38d002478e 100644 >> --- a/drivers/gpu/drm/i915/i915_bo.c >> +++ b/drivers/gpu/drm/i915/i915_bo.c >> @@ -1,11 +1,14 @@ >> // SPDX-License-Identifier: MIT >> /* Copyright =C2=A9 2024 Intel Corporation */ >> >> +#include >> + >> #include >> #include >> #include >> >> #include "display/intel_fb.h" >> +#include "gem/i915_gem_lmem.h" >> #include "gem/i915_gem_mman.h" >> #include "gem/i915_gem_object.h" >> #include "gem/i915_gem_object_frontbuffer.h" >> @@ -141,6 +144,113 @@ i915_bo_framebuffer_lookup(struct drm_device *drm, >> return intel_bo_to_drm_bo(obj); >> } >> >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> +static u32 i915_bo_fbdev_pitch_align(u32 stride) >> +{ >> + return ALIGN(stride, 64); >> +} >> + >> +bool i915_bo_fbdev_prefer_stolen(struct drm_device *drm, unsigned int s= ize) >> +{ >> + struct drm_i915_private *i915 =3D to_i915(drm); >> + >> + /* Skip stolen on MTL as Wa_22018444074 mitigation. */ >> + if (IS_METEORLAKE(i915)) >> + return false; >> + >> + /* >> + * If the FB is too big, just don't use it since fbdev is not very >> + * important and we should probably use that space with FBC or other >> + * features. >> + */ >> + return i915->dsm.usable_size >=3D size * 2; >> +} >> + >> +static struct drm_gem_object *i915_bo_fbdev_create(struct drm_device *d= rm, int size) >> +{ >> + struct drm_i915_private *i915 =3D to_i915(drm); > > Can we add same trick for i915_bo_fbdev_create() as we are doing > with i915_bo_fbdev_prefer_stolen() in patch [4/5]? Or e.g. add a > separate 6th patch for that? Up to patch reordering, of course. I don't know what you mean. BR, Jani. > >> + struct drm_i915_gem_object *obj; >> + >> + obj =3D ERR_PTR(-ENODEV); >> + if (HAS_LMEM(i915)) { >> + obj =3D i915_gem_object_create_lmem(i915, size, >> + I915_BO_ALLOC_CONTIGUOUS | >> + I915_BO_ALLOC_USER); >> + } else { >> + if (i915_bo_fbdev_prefer_stolen(drm, size)) >> + obj =3D i915_gem_object_create_stolen(i915, size); >> + else >> + drm_info(drm, "Allocating fbdev: Stolen memory not preferred.\n"); >> + >> + if (IS_ERR(obj)) >> + obj =3D i915_gem_object_create_shmem(i915, size); >> + } >> + >> + if (IS_ERR(obj)) { >> + drm_err(drm, "failed to allocate framebuffer (%pe)\n", obj); >> + return ERR_PTR(-ENOMEM); >> + } >> + >> + return &obj->base; >> +} >> + >> +static void i915_bo_fbdev_destroy(struct drm_gem_object *obj) >> +{ >> + drm_gem_object_put(obj); >> +} >> + >> +static int i915_bo_fbdev_fill_info(struct drm_gem_object *_obj, struct = fb_info *info, >> + struct i915_vma *vma) >> +{ >> + struct drm_i915_private *i915 =3D to_i915(_obj->dev); >> + struct drm_i915_gem_object *obj =3D to_intel_bo(_obj); >> + struct i915_gem_ww_ctx ww; >> + void __iomem *vaddr; >> + int ret; >> + >> + if (i915_gem_object_is_lmem(obj)) { >> + struct intel_memory_region *mem =3D obj->mm.region; >> + >> + /* Use fbdev's framebuffer from lmem for discrete */ >> + info->fix.smem_start =3D >> + (unsigned long)(mem->io.start + >> + i915_gem_object_get_dma_address(obj, 0) - >> + mem->region.start); >> + info->fix.smem_len =3D obj->base.size; >> + } else { >> + struct i915_ggtt *ggtt =3D to_gt(i915)->ggtt; >> + >> + /* Our framebuffer is the entirety of fbdev's system memory */ >> + info->fix.smem_start =3D >> + (unsigned long)(ggtt->gmadr.start + i915_ggtt_offset(vma)); >> + info->fix.smem_len =3D vma->size; >> + } >> + >> + for_i915_gem_ww(&ww, ret, false) { >> + ret =3D i915_gem_object_lock(vma->obj, &ww); >> + >> + if (ret) >> + continue; >> + >> + vaddr =3D i915_vma_pin_iomap(vma); >> + if (IS_ERR(vaddr)) { >> + drm_err(&i915->drm, >> + "Failed to remap framebuffer into virtual memory (%pe)\n", vaddr); >> + ret =3D PTR_ERR(vaddr); >> + continue; >> + } >> + } >> + >> + if (ret) >> + return ret; >> + >> + info->screen_base =3D vaddr; >> + info->screen_size =3D intel_bo_to_drm_bo(obj)->size; >> + >> + return 0; >> +} >> +#endif >> + >> const struct intel_display_bo_interface i915_display_bo_interface =3D { >> .is_tiled =3D i915_bo_is_tiled, >> .is_userptr =3D i915_bo_is_userptr, >> @@ -153,4 +263,10 @@ const struct intel_display_bo_interface i915_displa= y_bo_interface =3D { >> .framebuffer_init =3D i915_bo_framebuffer_init, >> .framebuffer_fini =3D i915_bo_framebuffer_fini, >> .framebuffer_lookup =3D i915_bo_framebuffer_lookup, >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> + .fbdev_create =3D i915_bo_fbdev_create, >> + .fbdev_destroy =3D i915_bo_fbdev_destroy, >> + .fbdev_fill_info =3D i915_bo_fbdev_fill_info, >> + .fbdev_pitch_align =3D i915_bo_fbdev_pitch_align, >> +#endif >> }; >> diff --git a/drivers/gpu/drm/i915/i915_bo.h b/drivers/gpu/drm/i915/i915_= bo.h >> index 57255d052dd9..2a0f3050dd42 100644 >> --- a/drivers/gpu/drm/i915/i915_bo.h >> +++ b/drivers/gpu/drm/i915/i915_bo.h >> @@ -4,6 +4,12 @@ >> #ifndef __I915_BO_H__ >> #define __I915_BO_H__ >> >> +#include >> + >> +struct drm_device; >> + >> +bool i915_bo_fbdev_prefer_stolen(struct drm_device *drm, unsigned int s= ize); >> + >> extern const struct intel_display_bo_interface i915_display_bo_interface; >> >> #endif /* __I915_BO_H__ */ >> diff --git a/drivers/gpu/drm/i915/i915_initial_plane.c b/drivers/gpu/drm= /i915/i915_initial_plane.c >> index 390a9248d631..f4d631a395d0 100644 >> --- a/drivers/gpu/drm/i915/i915_initial_plane.c >> +++ b/drivers/gpu/drm/i915/i915_initial_plane.c >> @@ -9,10 +9,10 @@ >> #include "display/intel_crtc.h" >> #include "display/intel_display_types.h" >> #include "display/intel_fb.h" >> -#include "display/intel_fbdev_fb.h" >> #include "gem/i915_gem_lmem.h" >> #include "gem/i915_gem_region.h" >> >> +#include "i915_bo.h" >> #include "i915_drv.h" >> #include "i915_initial_plane.h" >> >> @@ -118,7 +118,7 @@ initial_plane_vma(struct drm_i915_private *i915, >> if (IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) && >> IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) && >> mem =3D=3D i915->mm.stolen_region && >> - !intel_fbdev_fb_prefer_stolen(&i915->drm, size)) { >> + !i915_bo_fbdev_prefer_stolen(&i915->drm, size)) { >> drm_dbg_kms(&i915->drm, "Initial FB size exceeds half of stolen, disca= rding\n"); >> return NULL; >> } >> diff --git a/drivers/gpu/drm/xe/Makefile b/drivers/gpu/drm/xe/Makefile >> index dab979287a96..936eb79e9269 100644 >> --- a/drivers/gpu/drm/xe/Makefile >> +++ b/drivers/gpu/drm/xe/Makefile >> @@ -211,7 +211,6 @@ $(obj)/i915-display/%.o: $(srctree)/drivers/gpu/drm/= i915/display/%.c FORCE >> >> # Display code specific to xe >> xe-$(CONFIG_DRM_XE_DISPLAY) +=3D \ >> - display/intel_fbdev_fb.o \ >> display/xe_display.o \ >> display/xe_display_bo.o \ >> display/xe_display_pcode.o \ >> diff --git a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c b/drivers/gpu/d= rm/xe/display/intel_fbdev_fb.c >> deleted file mode 100644 >> index 2ad5e5a79287..000000000000 >> --- a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c >> +++ /dev/null >> @@ -1,116 +0,0 @@ >> -/* SPDX-License-Identifier: MIT */ >> -/* >> - * Copyright =C2=A9 2023 Intel Corporation >> - */ >> - >> -#include >> - >> -#include "intel_fbdev_fb.h" >> -#include "xe_bo.h" >> -#include "xe_ttm_stolen_mgr.h" >> -#include "xe_wa.h" >> - >> -#include >> - >> -/* >> - * FIXME: There shouldn't be any reason to have XE_PAGE_SIZE stride >> - * alignment. The same 64 as i915 uses should be fine, and we shouldn't= need to >> - * have driver specific values. However, dropping the stride alignment = to 64 >> - * leads to underflowing the bo pin count in the atomic cleanup work. >> - */ >> -u32 intel_fbdev_fb_pitch_align(u32 stride) >> -{ >> - return ALIGN(stride, XE_PAGE_SIZE); >> -} >> - >> -bool intel_fbdev_fb_prefer_stolen(struct drm_device *drm, unsigned int = size) >> -{ >> - struct xe_device *xe =3D to_xe_device(drm); >> - struct ttm_resource_manager *stolen; >> - >> - stolen =3D ttm_manager_type(&xe->ttm, XE_PL_STOLEN); >> - if (!stolen) >> - return false; >> - >> - if (IS_DGFX(xe)) >> - return false; >> - >> - if (XE_DEVICE_WA(xe, 22019338487_display)) >> - return false; >> - >> - /* >> - * If the FB is too big, just don't use it since fbdev is not very >> - * important and we should probably use that space with FBC or other >> - * features. >> - */ >> - return stolen->size >=3D size * 2; >> -} >> - >> -struct drm_gem_object *intel_fbdev_fb_bo_create(struct drm_device *drm,= int size) >> -{ >> - struct xe_device *xe =3D to_xe_device(drm); >> - struct xe_bo *obj; >> - >> - obj =3D ERR_PTR(-ENODEV); >> - >> - if (intel_fbdev_fb_prefer_stolen(drm, size)) { >> - obj =3D xe_bo_create_pin_map_novm(xe, xe_device_get_root_tile(xe), >> - size, >> - ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT | >> - XE_BO_FLAG_STOLEN | >> - XE_BO_FLAG_GGTT, false); >> - if (!IS_ERR(obj)) >> - drm_info(&xe->drm, "Allocated fbdev into stolen\n"); >> - else >> - drm_info(&xe->drm, "Allocated fbdev into stolen failed: %li\n", PTR_= ERR(obj)); >> - } else { >> - drm_info(&xe->drm, "Allocating fbdev: Stolen memory not preferred.\n"= ); >> - } >> - >> - if (IS_ERR(obj)) { >> - obj =3D xe_bo_create_pin_map_novm(xe, xe_device_get_root_tile(xe), si= ze, >> - ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT | >> - XE_BO_FLAG_VRAM_IF_DGFX(xe_device_get_root_tile(xe)) | >> - XE_BO_FLAG_GGTT, false); >> - } >> - >> - if (IS_ERR(obj)) { >> - drm_err(&xe->drm, "failed to allocate framebuffer (%pe)\n", obj); >> - return ERR_PTR(-ENOMEM); >> - } >> - >> - return &obj->ttm.base; >> -} >> - >> -void intel_fbdev_fb_bo_destroy(struct drm_gem_object *obj) >> -{ >> - xe_bo_unpin_map_no_vm(gem_to_xe_bo(obj)); >> -} >> - >> -int intel_fbdev_fb_fill_info(struct drm_gem_object *_obj, struct fb_inf= o *info, >> - struct i915_vma *vma) >> -{ >> - struct xe_bo *obj =3D gem_to_xe_bo(_obj); >> - struct pci_dev *pdev =3D to_pci_dev(_obj->dev->dev); >> - >> - if (!(obj->flags & XE_BO_FLAG_SYSTEM)) { >> - if (obj->flags & XE_BO_FLAG_STOLEN) >> - info->fix.smem_start =3D xe_ttm_stolen_io_offset(obj, 0); >> - else >> - info->fix.smem_start =3D >> - pci_resource_start(pdev, 2) + >> - xe_bo_addr(obj, 0, XE_PAGE_SIZE); >> - >> - info->fix.smem_len =3D obj->ttm.base.size; >> - } else { >> - /* XXX: Pure fiction, as the BO may not be physically accessible.. */ >> - info->fix.smem_start =3D 0; >> - info->fix.smem_len =3D obj->ttm.base.size; >> - } >> - XE_WARN_ON(iosys_map_is_null(&obj->vmap)); >> - >> - info->screen_base =3D obj->vmap.vaddr_iomem; >> - info->screen_size =3D obj->ttm.base.size; >> - >> - return 0; >> -} >> diff --git a/drivers/gpu/drm/xe/display/xe_display_bo.c b/drivers/gpu/dr= m/xe/display/xe_display_bo.c >> index a689f71e7b14..10436edecc35 100644 >> --- a/drivers/gpu/drm/xe/display/xe_display_bo.c >> +++ b/drivers/gpu/drm/xe/display/xe_display_bo.c >> @@ -1,6 +1,8 @@ >> // SPDX-License-Identifier: MIT >> /* Copyright =C2=A9 2024 Intel Corporation */ >> >> +#include >> + >> #include >> #include >> >> @@ -8,6 +10,10 @@ >> #include "xe_bo.h" >> #include "xe_display_bo.h" >> #include "xe_pxp.h" >> +#include "xe_ttm_stolen_mgr.h" >> +#include "xe_wa.h" >> + >> +#include >> >> static bool xe_display_bo_is_protected(struct drm_gem_object *obj) >> { >> @@ -101,6 +107,111 @@ xe_display_bo_framebuffer_lookup(struct drm_device= *drm, >> return gem; >> } >> >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> +/* >> + * FIXME: There shouldn't be any reason to have XE_PAGE_SIZE stride >> + * alignment. The same 64 as i915 uses should be fine, and we shouldn't= need to >> + * have driver specific values. However, dropping the stride alignment = to 64 >> + * leads to underflowing the bo pin count in the atomic cleanup work. >> + */ >> +static u32 xe_display_bo_fbdev_pitch_align(u32 stride) >> +{ >> + return ALIGN(stride, XE_PAGE_SIZE); >> +} >> + >> +bool xe_display_bo_fbdev_prefer_stolen(struct drm_device *drm, unsigned= int size) >> +{ >> + struct xe_device *xe =3D to_xe_device(drm); >> + struct ttm_resource_manager *stolen; >> + >> + stolen =3D ttm_manager_type(&xe->ttm, XE_PL_STOLEN); >> + if (!stolen) >> + return false; >> + >> + if (IS_DGFX(xe)) >> + return false; >> + >> + if (XE_DEVICE_WA(xe, 22019338487_display)) >> + return false; >> + >> + /* >> + * If the FB is too big, just don't use it since fbdev is not very >> + * important and we should probably use that space with FBC or other >> + * features. >> + */ >> + return stolen->size >=3D size * 2; >> +} >> + >> +static struct drm_gem_object *xe_display_bo_fbdev_create(struct drm_dev= ice *drm, int size) >> +{ >> + struct xe_device *xe =3D to_xe_device(drm); > > Same question here, but adding it in patch [5/5] or as new 7th patch. Up > to patch reordering of course. > > BR, > Micha=C5=82 > >> + struct xe_bo *obj; >> + >> + obj =3D ERR_PTR(-ENODEV); >> + >> + if (xe_display_bo_fbdev_prefer_stolen(drm, size)) { >> + obj =3D xe_bo_create_pin_map_novm(xe, xe_device_get_root_tile(xe), >> + size, >> + ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT | >> + XE_BO_FLAG_STOLEN | >> + XE_BO_FLAG_GGTT, false); >> + if (!IS_ERR(obj)) >> + drm_info(&xe->drm, "Allocated fbdev into stolen\n"); >> + else >> + drm_info(&xe->drm, "Allocated fbdev into stolen failed: %li\n", PTR_= ERR(obj)); >> + } else { >> + drm_info(&xe->drm, "Allocating fbdev: Stolen memory not preferred.\n"= ); >> + } >> + >> + if (IS_ERR(obj)) { >> + obj =3D xe_bo_create_pin_map_novm(xe, xe_device_get_root_tile(xe), si= ze, >> + ttm_bo_type_kernel, XE_BO_FLAG_SCANOUT | >> + XE_BO_FLAG_VRAM_IF_DGFX(xe_device_get_root_tile(xe)) | >> + XE_BO_FLAG_GGTT, false); >> + } >> + >> + if (IS_ERR(obj)) { >> + drm_err(&xe->drm, "failed to allocate framebuffer (%pe)\n", obj); >> + return ERR_PTR(-ENOMEM); >> + } >> + >> + return &obj->ttm.base; >> +} >> + >> +static void xe_display_bo_fbdev_destroy(struct drm_gem_object *obj) >> +{ >> + xe_bo_unpin_map_no_vm(gem_to_xe_bo(obj)); >> +} >> + >> +static int xe_display_bo_fbdev_fill_info(struct drm_gem_object *_obj, s= truct fb_info *info, >> + struct i915_vma *vma) >> +{ >> + struct xe_bo *obj =3D gem_to_xe_bo(_obj); >> + struct pci_dev *pdev =3D to_pci_dev(_obj->dev->dev); >> + >> + if (!(obj->flags & XE_BO_FLAG_SYSTEM)) { >> + if (obj->flags & XE_BO_FLAG_STOLEN) >> + info->fix.smem_start =3D xe_ttm_stolen_io_offset(obj, 0); >> + else >> + info->fix.smem_start =3D >> + pci_resource_start(pdev, 2) + >> + xe_bo_addr(obj, 0, XE_PAGE_SIZE); >> + >> + info->fix.smem_len =3D obj->ttm.base.size; >> + } else { >> + /* XXX: Pure fiction, as the BO may not be physically accessible.. */ >> + info->fix.smem_start =3D 0; >> + info->fix.smem_len =3D obj->ttm.base.size; >> + } >> + XE_WARN_ON(iosys_map_is_null(&obj->vmap)); >> + >> + info->screen_base =3D obj->vmap.vaddr_iomem; >> + info->screen_size =3D obj->ttm.base.size; >> + >> + return 0; >> +} >> +#endif >> + >> const struct intel_display_bo_interface xe_display_bo_interface =3D { >> .is_protected =3D xe_display_bo_is_protected, >> .key_check =3D xe_pxp_obj_key_check, >> @@ -109,4 +220,10 @@ const struct intel_display_bo_interface xe_display_= bo_interface =3D { >> .framebuffer_init =3D xe_display_bo_framebuffer_init, >> .framebuffer_fini =3D xe_display_bo_framebuffer_fini, >> .framebuffer_lookup =3D xe_display_bo_framebuffer_lookup, >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> + .fbdev_create =3D xe_display_bo_fbdev_create, >> + .fbdev_destroy =3D xe_display_bo_fbdev_destroy, >> + .fbdev_fill_info =3D xe_display_bo_fbdev_fill_info, >> + .fbdev_pitch_align =3D xe_display_bo_fbdev_pitch_align, >> +#endif >> }; >> diff --git a/drivers/gpu/drm/xe/display/xe_display_bo.h b/drivers/gpu/dr= m/xe/display/xe_display_bo.h >> index 6879c104b0b1..8980e6ecf54a 100644 >> --- a/drivers/gpu/drm/xe/display/xe_display_bo.h >> +++ b/drivers/gpu/drm/xe/display/xe_display_bo.h >> @@ -4,6 +4,12 @@ >> #ifndef __XE_DISPLAY_BO_H__ >> #define __XE_DISPLAY_BO_H__ >> >> +#include >> + >> +struct drm_device; >> + >> +bool xe_display_bo_fbdev_prefer_stolen(struct drm_device *drm, unsigned= int size); >> + >> extern const struct intel_display_bo_interface xe_display_bo_interface; >> >> #endif >> diff --git a/drivers/gpu/drm/xe/display/xe_initial_plane.c b/drivers/gpu= /drm/xe/display/xe_initial_plane.c >> index 730c6dc49522..6e0a22429184 100644 >> --- a/drivers/gpu/drm/xe/display/xe_initial_plane.c >> +++ b/drivers/gpu/drm/xe/display/xe_initial_plane.c >> @@ -12,8 +12,8 @@ >> #include "intel_display_types.h" >> #include "intel_fb.h" >> #include "intel_fb_pin.h" >> -#include "intel_fbdev_fb.h" >> #include "xe_bo.h" >> +#include "xe_display_bo.h" >> #include "xe_display_vma.h" >> #include "xe_ggtt.h" >> #include "xe_mmio.h" >> @@ -87,7 +87,7 @@ initial_plane_bo(struct xe_device *xe, >> >> if (IS_ENABLED(CONFIG_FRAMEBUFFER_CONSOLE) && >> IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) && >> - !intel_fbdev_fb_prefer_stolen(&xe->drm, plane_config->size)) { >> + !xe_display_bo_fbdev_prefer_stolen(&xe->drm, plane_config->size))= { >> drm_info(&xe->drm, "Initial FB size exceeds half of stolen, discardin= g\n"); >> return NULL; >> } >> diff --git a/include/drm/intel/display_parent_interface.h b/include/drm/= intel/display_parent_interface.h >> index 97ec94a2e749..2fc1794a3da4 100644 >> --- a/include/drm/intel/display_parent_interface.h >> +++ b/include/drm/intel/display_parent_interface.h >> @@ -15,6 +15,7 @@ struct drm_gem_object; >> struct drm_mode_fb_cmd2; >> struct drm_plane_state; >> struct drm_scanout_buffer; >> +struct fb_info; >> struct i915_vma; >> struct intel_dpt; >> struct intel_dsb_buffer; >> @@ -43,6 +44,12 @@ struct intel_display_bo_interface { >> struct drm_gem_object *(*framebuffer_lookup)(struct drm_device *drm, >> struct drm_file *filp, >> const struct drm_mode_fb_cmd2 *user_mode_cmd); >> +#if IS_ENABLED(CONFIG_DRM_FBDEV_EMULATION) >> + struct drm_gem_object *(*fbdev_create)(struct drm_device *drm, int siz= e); >> + void (*fbdev_destroy)(struct drm_gem_object *obj); >> + int (*fbdev_fill_info)(struct drm_gem_object *obj, struct fb_info *inf= o, struct i915_vma *vma); >> + u32 (*fbdev_pitch_align)(u32 stride); >> +#endif >> }; >> >> struct intel_display_dpt_interface { >> --=20 >> 2.47.3 >> >> --=20 Jani Nikula, Intel