]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
drm/i915/overlay: Introduce i915_overlay_obj_lookup()
authorVille Syrjälä <ville.syrjala@linux.intel.com>
Thu, 26 Feb 2026 10:07:25 +0000 (12:07 +0200)
committerVille Syrjälä <ville.syrjala@linux.intel.com>
Fri, 27 Feb 2026 08:41:34 +0000 (10:41 +0200)
Extract the BO lookup and tiling check into a new
helper called i915_overlay_obj_lookup(). This will have to
move to the i915 side of the parent vs. display driver split.

There is a slight change here in that we now do the tiling
check before taking the modeset locks, but those locks don't
protect the BO tiling stuff in any way, so nothing is really
different here.

Note that the hardware should support X-tiled scanout also
for the overlay, but I guess no one ever bothered to hook
it up and test it. So the check should stay at least for now.

v2: Correctly handle the ERR_PTR returned by
    i915_overlay_obj_lookup() (Jani)

Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Link: https://patch.msgid.link/20260226100738.29997-7-ville.syrjala@linux.intel.com
drivers/gpu/drm/i915/display/intel_overlay.c

index 8c6e9c19b3f53a7760239bf0476d0ac9091f0336..91398ee92042201be3b63be3678365bd33f5344f 100644 (file)
@@ -1125,6 +1125,26 @@ static int check_overlay_src(struct intel_display *display,
        return 0;
 }
 
+static struct drm_i915_gem_object *
+i915_overlay_obj_lookup(struct drm_device *drm,
+                       struct drm_file *file_priv,
+                       u32 handle)
+{
+       struct drm_i915_gem_object *bo;
+
+       bo = i915_gem_object_lookup(file_priv, handle);
+       if (!bo)
+               return ERR_PTR(-ENOENT);
+
+       if (i915_gem_object_is_tiled(bo)) {
+               drm_dbg(drm, "buffer used for overlay image can not be tiled\n");
+               i915_gem_object_put(bo);
+               return ERR_PTR(-EINVAL);
+       }
+
+       return bo;
+}
+
 int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
                                  struct drm_file *file_priv)
 {
@@ -1155,19 +1175,12 @@ int intel_overlay_put_image_ioctl(struct drm_device *dev, void *data,
                return -ENOENT;
        crtc = to_intel_crtc(drmmode_crtc);
 
-       new_bo = i915_gem_object_lookup(file_priv, params->bo_handle);
-       if (!new_bo)
-               return -ENOENT;
+       new_bo = i915_overlay_obj_lookup(dev, file_priv, params->bo_handle);
+       if (IS_ERR(new_bo))
+               return PTR_ERR(new_bo);
 
        drm_modeset_lock_all(dev);
 
-       if (i915_gem_object_is_tiled(new_bo)) {
-               drm_dbg_kms(display->drm,
-                           "buffer used for overlay image can not be tiled\n");
-               ret = -EINVAL;
-               goto out_unlock;
-       }
-
        ret = intel_overlay_recover_from_interrupt(overlay);
        if (ret != 0)
                goto out_unlock;