diff mbox series

[PATCHv5,12/34] drm/komeda: Factor out object lookups for non-afbc case

Message ID 20191217145020.14645-13-andrzej.p@collabora.com (mailing list archive)
State New, archived
Headers show
Series Add AFBC support for Rockchip | expand

Commit Message

Andrzej Pietrasiewicz Dec. 17, 2019, 2:49 p.m. UTC
Ultimately we want lookups happening only once in komeda's fb_create
implementation.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
---
 .../arm/display/komeda/komeda_framebuffer.c   | 21 ++++++++++++-------
 1 file changed, 13 insertions(+), 8 deletions(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index 08f31478c6a8..2014cd843aeb 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
@@ -100,6 +100,7 @@  static int
 komeda_fb_none_afbc_size_check(struct komeda_dev *mdev,
 			       struct komeda_fb *kfb,
 			       const struct drm_format_info *info,
+			       struct drm_gem_object **objs,
 			       struct drm_file *file,
 			       const struct drm_mode_fb_cmd2 *mode_cmd)
 {
@@ -109,12 +110,7 @@  komeda_fb_none_afbc_size_check(struct komeda_dev *mdev,
 	u64 min_size;
 
 	for (i = 0; i < info->num_planes; i++) {
-		obj = drm_gem_object_lookup(file, mode_cmd->handles[i]);
-		if (!obj) {
-			DRM_DEBUG_KMS("Failed to lookup GEM object\n");
-			return -ENOENT;
-		}
-		fb->obj[i] = obj;
+		obj = objs[i];
 
 		block_h = drm_format_info_block_height(info, i);
 		if ((fb->pitches[i] * block_h) % mdev->chip.bus_width) {
@@ -174,14 +170,23 @@  komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 		}
 		ret = komeda_fb_afbc_size_check(kfb, info, file, mode_cmd);
 	} else {
+		struct drm_gem_object *objs[4];
+
 		if (komeda_fb_check_src_coords(kfb, 0, 0, kfb->base.width,
 					       kfb->base.height)) {
 			kfree(kfb);
 			return ERR_PTR(-EINVAL);
 		}
+		ret = drm_gem_fb_lookup(dev, file, mode_cmd, objs);
+		if (ret < 0) {
+			kfree(kfb);
+			return ERR_PTR(ret);
+		}
 
-		ret = komeda_fb_none_afbc_size_check(mdev, kfb, info, file,
-						     mode_cmd);
+		ret = komeda_fb_none_afbc_size_check(mdev, kfb, info, objs,
+						     file, mode_cmd);
+		for (i = 0; i < info->num_planes; ++i)
+			kfb->base.obj[i] = objs[i];
 	}
 	if (ret < 0)
 		goto err_cleanup;