[PATCHv4 27/36] drm/komeda: Use special helper for afbc case size check

Andrzej Pietrasiewicz andrzej.p at collabora.com
Fri Dec 13 15:58:58 UTC 2019


Use generic helper code.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p at collabora.com>
---
 .../arm/display/komeda/komeda_framebuffer.c   | 22 +++++++------------
 1 file changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
index 6898407d1b63..e55ab6130e15 100644
--- a/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
+++ b/drivers/gpu/drm/arm/display/komeda/komeda_framebuffer.c
@@ -37,17 +37,15 @@ static const struct drm_framebuffer_funcs komeda_fb_funcs = {
 };
 
 static int
-komeda_fb_afbc_size_check(struct komeda_fb *kfb,
+komeda_fb_afbc_size_check(struct drm_device *dev,
+			  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)
 {
-	struct drm_gem_object *obj;
+	struct drm_size_check check = { 0 };
 	u32 alignment_w = 0, alignment_h = 0, alignment_header, n_blocks, bpp;
-	u64 min_size;
-
-	obj = objs[0];
 
 	if (!drm_afbc_get_superblock_wh(mode_cmd->modifier[0],
 					&alignment_w, &alignment_h))
@@ -78,14 +76,10 @@ komeda_fb_afbc_size_check(struct komeda_fb *kfb,
 	kfb->afbc_size = kfb->offset_payload + n_blocks *
 			 ALIGN(bpp * AFBC_SUPERBLK_PIXELS / 8,
 			       AFBC_SUPERBLK_ALIGNMENT);
-	min_size = kfb->afbc_size + mode_cmd->offsets[0];
-	if (min_size > obj->size) {
-		DRM_DEBUG_KMS("afbc size check failed, obj_size: 0x%zx. min_size 0x%llx.\n",
-			      obj->size, min_size);
-		return -EINVAL;
-	}
+	check.min_size[0] = kfb->afbc_size + mode_cmd->offsets[0];
+	check.use_min_size = true;
 
-	return 0;
+	return drm_gem_fb_size_check_special(dev, mode_cmd, &check, objs);
 }
 
 struct drm_framebuffer *
@@ -126,8 +120,8 @@ komeda_fb_create(struct drm_device *dev, struct drm_file *file,
 			goto err_cleanup;
 		}
 
-		ret = komeda_fb_afbc_size_check(kfb, info, objs, file,
-						mode_cmd);
+		ret = komeda_fb_afbc_size_check(dev, kfb, info, objs,
+						file, mode_cmd);
 	} else {
 		struct drm_size_check check = { 0 };
 
-- 
2.17.1



More information about the dri-devel mailing list