From: Maarten Lankhorst <maarten.lankhorst@linux.intel.com>
To: intel-xe@lists.freedesktop.org
Cc: Maarten Lankhorst <dev@lankhorst.se>
Subject: [Intel-xe] [PATCH 9/9] FIXME drm/i915/display: Make intel_fb.c code compatible with xe
Date: Thu, 9 Nov 2023 16:07:59 +0100 [thread overview]
Message-ID: <20231109150759.44549-10-maarten.lankhorst@linux.intel.com> (raw)
In-Reply-To: <20231109150759.44549-1-maarten.lankhorst@linux.intel.com>
From: Maarten Lankhorst <dev@lankhorst.se>
Again there are a few changes between Xe and i915, but in general code is similar for both
Signed-off-by: Maarten Lankhorst <dev@lankhorst.se>
---
drivers/gpu/drm/i915/display/intel_fb.c | 85 +++++++++++++++++--------
1 file changed, 57 insertions(+), 28 deletions(-)
diff --git a/drivers/gpu/drm/i915/display/intel_fb.c b/drivers/gpu/drm/i915/display/intel_fb.c
index f1cbd026f91f9..aa41e681e835d 100644
--- a/drivers/gpu/drm/i915/display/intel_fb.c
+++ b/drivers/gpu/drm/i915/display/intel_fb.c
@@ -17,6 +17,8 @@
#include "intel_fb.h"
#include "intel_frontbuffer.h"
+#include "gem/i915_gem_object.h"
+
#define check_array_bounds(i915, a, i) drm_WARN_ON(&(i915)->drm, (i) >= ARRAY_SIZE(a))
/*
@@ -737,7 +739,7 @@ intel_fb_align_height(const struct drm_framebuffer *fb,
return ALIGN(height, tile_height);
}
-static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
+__maybe_unused static unsigned int intel_fb_modifier_to_tiling(u64 fb_modifier)
{
u8 tiling_caps = lookup_modifier(fb_modifier)->plane_caps &
INTEL_PLANE_CAP_TILING_MASK;
@@ -1657,10 +1659,10 @@ int intel_fill_fb_info(struct drm_i915_private *i915, struct intel_framebuffer *
max_size = max(max_size, offset + size);
}
- if (mul_u32_u32(max_size, tile_size) > obj->base.size) {
+ if (mul_u32_u32(max_size, tile_size) > intel_bo_to_drm_bo(obj)->size) {
drm_dbg_kms(&i915->drm,
"fb too big for bo (need %llu bytes, have %zu bytes)\n",
- mul_u32_u32(max_size, tile_size), obj->base.size);
+ mul_u32_u32(max_size, tile_size), intel_bo_to_drm_bo(obj)->size);
return -EINVAL;
}
@@ -1907,7 +1909,7 @@ static int intel_user_framebuffer_create_handle(struct drm_framebuffer *fb,
unsigned int *handle)
{
struct drm_i915_gem_object *obj = intel_fb_obj(fb);
- struct drm_i915_private *i915 = to_i915(obj->base.dev);
+ struct drm_i915_private *i915 = to_i915(fb->dev);
if (i915_gem_object_is_userptr(obj)) {
drm_dbg(&i915->drm,
@@ -1915,7 +1917,7 @@ static int intel_user_framebuffer_create_handle(struct drm_framebuffer *fb,
return -EINVAL;
}
- return drm_gem_handle_create(file, &obj->base, handle);
+ return drm_gem_handle_create(file, intel_bo_to_drm_bo(obj), handle);
}
struct frontbuffer_fence_cb {
@@ -1948,10 +1950,10 @@ static int intel_user_framebuffer_dirty(struct drm_framebuffer *fb,
if (!atomic_read(&front->bits))
return 0;
- if (dma_resv_test_signaled(obj->base.resv, dma_resv_usage_rw(false)))
+ if (dma_resv_test_signaled(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false)))
goto flush;
- ret = dma_resv_get_singleton(obj->base.resv, dma_resv_usage_rw(false),
+ ret = dma_resv_get_singleton(intel_bo_to_drm_bo(obj)->resv, dma_resv_usage_rw(false),
&fence);
if (ret || !fence)
goto flush;
@@ -1993,10 +1995,10 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
struct drm_i915_gem_object *obj,
struct drm_mode_fb_cmd2 *mode_cmd)
{
- struct drm_i915_private *dev_priv = to_i915(obj->base.dev);
+ struct drm_i915_private *dev_priv = intel_bo_to_i915(obj);
struct drm_framebuffer *fb = &intel_fb->base;
u32 max_stride;
- unsigned int tiling, stride;
+ unsigned int tiling = I915_TILING_NONE, stride = 0;
int ret = -EINVAL;
int i;
@@ -2004,6 +2006,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
if (!intel_fb->frontbuffer)
return -ENOMEM;
+#ifdef I915
i915_gem_object_lock(obj, NULL);
tiling = i915_gem_object_get_tiling(obj);
stride = i915_gem_object_get_stride(obj);
@@ -2030,15 +2033,6 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
}
}
- if (!drm_any_plane_has_format(&dev_priv->drm,
- mode_cmd->pixel_format,
- mode_cmd->modifier[0])) {
- drm_dbg_kms(&dev_priv->drm,
- "unsupported pixel format %p4cc / modifier 0x%llx\n",
- &mode_cmd->pixel_format, mode_cmd->modifier[0]);
- goto err;
- }
-
/*
* gen2/3 display engine uses the fence if present,
* so the tiling mode must match the fb modifier exactly.
@@ -2049,6 +2043,36 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
"tiling_mode must match fb modifier exactly on gen2/3\n");
goto err;
}
+#else
+ ret = ttm_bo_reserve(&obj->ttm, true, false, NULL);
+ if (ret)
+ goto err;
+ ret = -EINVAL;
+
+ if (!(obj->flags & XE_BO_SCANOUT_BIT)) {
+ /*
+ * XE_BO_SCANOUT_BIT should ideally be set at creation, or is
+ * automatically set when creating FB. We cannot change caching
+ * mode when the object is VM_BINDed, so we can only set
+ * coherency with display when unbound.
+ */
+ if (XE_IOCTL_DBG(dev_priv, !list_empty(&obj->ttm.base.gpuva.list))) {
+ ttm_bo_unreserve(&obj->ttm);
+ goto err;
+ }
+ obj->flags |= XE_BO_SCANOUT_BIT;
+ }
+ ttm_bo_unreserve(&obj->ttm);
+#endif
+
+ if (!drm_any_plane_has_format(&dev_priv->drm,
+ mode_cmd->pixel_format,
+ mode_cmd->modifier[0])) {
+ drm_dbg_kms(&dev_priv->drm,
+ "unsupported pixel format %p4cc / modifier 0x%llx\n",
+ &mode_cmd->pixel_format, mode_cmd->modifier[0]);
+ goto err;
+ }
max_stride = intel_fb_max_stride(dev_priv, mode_cmd->pixel_format,
mode_cmd->modifier[0]);
@@ -2111,11 +2135,7 @@ int intel_framebuffer_init(struct intel_framebuffer *intel_fb,
}
}
-#ifdef I915
- fb->obj[i] = &obj->base;
-#else
- fb->obj[i] = &obj->ttm.base;
-#endif
+ fb->obj[i] = intel_bo_to_drm_bo(obj);
}
ret = intel_fill_fb_info(dev_priv, intel_fb);
@@ -2163,23 +2183,32 @@ intel_user_framebuffer_create(struct drm_device *dev,
struct drm_framebuffer *fb;
struct drm_i915_gem_object *obj;
struct drm_mode_fb_cmd2 mode_cmd = *user_mode_cmd;
- struct drm_i915_private *i915;
+ struct drm_i915_private *i915 = to_i915(dev);
+ struct drm_gem_object *gem = drm_gem_object_lookup(filp, mode_cmd.handles[0]);
- obj = i915_gem_object_lookup(filp, mode_cmd.handles[0]);
- if (!obj)
+ if (!gem)
return ERR_PTR(-ENOENT);
+ obj = to_intel_bo(gem);
+#ifdef I915
/* object is backed with LMEM for discrete */
- i915 = to_i915(obj->base.dev);
if (HAS_LMEM(i915) && !i915_gem_object_can_migrate(obj, INTEL_REGION_LMEM_0)) {
/* object is "remote", not in local memory */
i915_gem_object_put(obj);
drm_dbg_kms(&i915->drm, "framebuffer must reside in local memory\n");
return ERR_PTR(-EREMOTE);
}
+#else
+ /* Require vram placement or dma-buf import */
+ if (XE_IOCTL_DBG(i915, IS_DGFX(i915) && !xe_bo_can_migrate(obj, XE_PL_VRAM0) &&
+ obj->ttm.type != ttm_bo_type_sg)) {
+ drm_gem_object_put(gem);
+ return ERR_PTR(-EREMOTE);
+ }
+#endif
fb = intel_framebuffer_create(obj, &mode_cmd);
- i915_gem_object_put(obj);
+ drm_gem_object_put(gem);
return fb;
}
--
2.39.2
next prev parent reply other threads:[~2023-11-09 15:08 UTC|newest]
Thread overview: 18+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-11-09 15:07 [Intel-xe] [PATCH 0/9] Break up remaining changes to make xe compile Maarten Lankhorst
2023-11-09 15:07 ` [Intel-xe] [PATCH 1/9] drm/i915: Use drm_atomic_helper_wait_for_fences helper Maarten Lankhorst
2023-11-10 11:33 ` [Intel-xe] [1/9] " Hogander, Jouni
2023-11-09 15:07 ` [Intel-xe] [PATCH 2/9] fixup! drm/xe/display: Implement display support Maarten Lankhorst
2023-11-09 15:07 ` [Intel-xe] [PATCH 3/9] drm/i915/display: Revert all before remaining changes to make xe compile Maarten Lankhorst
2023-11-10 11:41 ` [Intel-xe] [3/9] " Hogander, Jouni
2023-11-09 15:07 ` [Intel-xe] [PATCH 4/9] drm/i915/display: Revert " Maarten Lankhorst
2023-11-09 15:07 ` [Intel-xe] [PATCH 5/9] drm/xe: Update headers to be more compatible with i915 Maarten Lankhorst
2023-11-09 15:07 ` [Intel-xe] [PATCH 6/9] FIXME drm/i915/display: add_dma_resv_fences is i915 only Maarten Lankhorst
2023-11-10 11:56 ` [Intel-xe] [6/9] " Hogander, Jouni
2023-11-09 15:07 ` [Intel-xe] [PATCH 7/9] drm/i915/display: Use i915_gem_object_get_dma_address to get dma address Maarten Lankhorst
2023-11-10 12:02 ` [Intel-xe] [7/9] " Hogander, Jouni
2023-11-09 15:07 ` [Intel-xe] [PATCH 8/9] FIXME drm/i915/display: Minimal changes to fbdev to make xe work Maarten Lankhorst
2023-11-09 15:07 ` Maarten Lankhorst [this message]
2023-11-09 15:14 ` [Intel-xe] ✗ CI.Patch_applied: failure for Break up remaining changes to make xe compile Patchwork
2023-11-15 23:31 ` [Intel-xe] ✗ CI.Patch_applied: failure for Break up remaining changes to make xe compile. (rev2) Patchwork
2023-11-17 21:37 ` Patchwork
-- strict thread matches above, loose matches on Subject: below --
2023-10-27 11:34 [Intel-xe] [PATCH 0/9] Cleaned up revert of remaining changes Maarten Lankhorst
2023-10-27 11:34 ` [Intel-xe] [PATCH 9/9] FIXME drm/i915/display: Make intel_fb.c code compatible with xe Maarten Lankhorst
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=20231109150759.44549-10-maarten.lankhorst@linux.intel.com \
--to=maarten.lankhorst@linux.intel.com \
--cc=dev@lankhorst.se \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.