Intel-GFX Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula@intel.com>
To: intel-gfx@lists.freedesktop.org, intel-xe@lists.freedesktop.org
Cc: jani.nikula@intel.com
Subject: [PATCH 5/9] drm/xe/fbdev: abstract bo creation
Date: Wed,  3 Sep 2025 23:32:02 +0300	[thread overview]
Message-ID: <cc5bfc9b34d470cd17e7d2cf4ff71f76d3c2cef5.1756931441.git.jani.nikula@intel.com> (raw)
In-Reply-To: <cover.1756931441.git.jani.nikula@intel.com>

Separate fbdev bo creation into a separate function
intel_fbdev_fb_bo_create().

Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
 drivers/gpu/drm/xe/display/intel_fbdev_fb.c | 33 ++++++++++++++-------
 1 file changed, 23 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
index 8e2f338d36fa..9a5d14d5781a 100644
--- a/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
+++ b/drivers/gpu/drm/xe/display/intel_fbdev_fb.c
@@ -20,16 +20,11 @@ u32 intel_fbdev_fb_pitch_align(u32 stride)
 	return ALIGN(stride, XE_PAGE_SIZE);
 }
 
-struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_device *drm,
-					       struct drm_mode_fb_cmd2 *mode_cmd)
+struct drm_gem_object *intel_fbdev_fb_bo_create(struct drm_device *drm, int size)
 {
-	struct drm_framebuffer *fb;
 	struct xe_device *xe = to_xe_device(drm);
 	struct xe_bo *obj;
-	int size;
 
-	size = mode_cmd->pitches[0] * mode_cmd->height;
-	size = PAGE_ALIGN(size);
 	obj = ERR_PTR(-ENODEV);
 
 	if (!IS_DGFX(xe) && !XE_GT_WA(xe_root_mmio_gt(xe), 22019338487_display)) {
@@ -53,21 +48,39 @@ struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_device *drm,
 
 	if (IS_ERR(obj)) {
 		drm_err(&xe->drm, "failed to allocate framebuffer (%pe)\n", obj);
-		fb = ERR_PTR(-ENOMEM);
+		return ERR_PTR(-ENOMEM);
+	}
+
+	return &obj->ttm.base;
+}
+
+struct intel_framebuffer *intel_fbdev_fb_alloc(struct drm_device *drm,
+					       struct drm_mode_fb_cmd2 *mode_cmd)
+{
+	struct drm_framebuffer *fb;
+	struct drm_gem_object *obj;
+	int size;
+
+	size = mode_cmd->pitches[0] * mode_cmd->height;
+	size = PAGE_ALIGN(size);
+
+	obj = intel_fbdev_fb_bo_create(drm, size);
+	if (IS_ERR(obj)) {
+		fb = ERR_CAST(obj);
 		goto err;
 	}
 
-	fb = intel_framebuffer_create(&obj->ttm.base,
+	fb = intel_framebuffer_create(obj,
 				      drm_get_format_info(drm,
 							  mode_cmd->pixel_format,
 							  mode_cmd->modifier[0]),
 				      mode_cmd);
 	if (IS_ERR(fb)) {
-		xe_bo_unpin_map_no_vm(obj);
+		xe_bo_unpin_map_no_vm(gem_to_xe_bo(obj));
 		goto err;
 	}
 
-	drm_gem_object_put(&obj->ttm.base);
+	drm_gem_object_put(obj);
 
 	return to_intel_framebuffer(fb);
 
-- 
2.47.2


  parent reply	other threads:[~2025-09-03 20:32 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-03 20:31 [PATCH 0/9] drm/{i915,xe}/fbdev: refactor Jani Nikula
2025-09-03 20:31 ` [PATCH 1/9] drm/{i915, xe}/fbdev: pass struct drm_device to intel_fbdev_fb_alloc() Jani Nikula
2025-09-03 20:31 ` [PATCH 2/9] drm/{i915,xe}/fbdev: add intel_fbdev_fb_pitch_align() Jani Nikula
2025-09-05  9:23   ` [PATCH 2/9] drm/{i915, xe}/fbdev: " Ville Syrjälä
2025-09-08 12:55     ` Jani Nikula
2025-09-08 14:19       ` Lucas De Marchi
2025-09-08 16:10         ` Maarten Lankhorst
2025-09-08 16:27           ` Ville Syrjälä
2025-09-16 11:44             ` Jani Nikula
2025-09-16 19:19               ` Ville Syrjälä
2025-09-18  8:43                 ` Jani Nikula
2025-10-13 13:52                   ` Jani Nikula
2025-10-13 17:19                     ` Ville Syrjälä
2025-10-14  4:48                       ` Hogander, Jouni
2025-09-03 20:32 ` [PATCH 3/9] drm/{i915, xe}/fbdev: deduplicate struct drm_mode_fb_cmd2 init Jani Nikula
2025-09-03 20:32 ` [PATCH 4/9] drm/i915/fbdev: abstract bo creation Jani Nikula
2025-09-03 20:32 ` Jani Nikula [this message]
2025-09-03 20:32 ` [PATCH 6/9] drm/{i915,xe}/fbdev: add intel_fbdev_fb_bo_destroy() Jani Nikula
2025-09-04 14:37   ` Ville Syrjälä
2025-09-08 13:01     ` Jani Nikula
2025-09-17 12:33     ` Jani Nikula
2025-09-17 14:07       ` Ville Syrjälä
2025-09-18  8:46         ` Jani Nikula
2025-09-03 20:32 ` [PATCH 7/9] drm/{i915,xe}/fbdev: deduplicate fbdev creation Jani Nikula
2025-09-04 14:39   ` Ville Syrjälä
2025-09-08 12:57     ` Jani Nikula
2025-09-03 20:32 ` [PATCH 8/9] drm/{i915, xe}/fbdev: pass struct drm_device to intel_fbdev_fb_fill_info() Jani Nikula
2025-09-03 20:32 ` [PATCH 9/9] drm/i915/fbdev: drop dependency on display in i915 specific code Jani Nikula
2025-09-03 21:15 ` ✓ i915.CI.BAT: success for drm/{i915,xe}/fbdev: refactor Patchwork
2025-09-05  1:09 ` ✗ i915.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=cc5bfc9b34d470cd17e7d2cf4ff71f76d3c2cef5.1756931441.git.jani.nikula@intel.com \
    --to=jani.nikula@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --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