From: Ville Syrjälä <[email protected]>

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.

Signed-off-by: Ville Syrjälä <[email protected]>
---
 drivers/gpu/drm/i915/display/intel_overlay.c | 31 ++++++++++++++------
 1 file changed, 22 insertions(+), 9 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_overlay.c 
b/drivers/gpu/drm/i915/display/intel_overlay.c
index e1707a678acb..5c4f8bf8ac44 100644
--- a/drivers/gpu/drm/i915/display/intel_overlay.c
+++ b/drivers/gpu/drm/i915/display/intel_overlay.c
@@ -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);
+       new_bo = i915_overlay_obj_lookup(dev, file_priv, params->bo_handle);
        if (!new_bo)
-               return -ENOENT;
+               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;
-- 
2.52.0

Reply via email to