dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: "Souza, Jose" <jose.souza@intel.com>
To: "contact@emersion.fr" <contact@emersion.fr>
Cc: "intel-gfx@lists.freedesktop.org"
	<intel-gfx@lists.freedesktop.org>,
	"drawat@vmware.com" <drawat@vmware.com>,
	"seanpaul@chromium.org" <seanpaul@chromium.org>,
	"dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"Mun, Gwan-gyeong" <gwan-gyeong.mun@intel.com>
Subject: Re: [PATCH] drm/damage_helper: Check if damage clips has valid values
Date: Sun, 13 Dec 2020 17:36:28 +0000	[thread overview]
Message-ID: <ea52f21e89f437ca88c3f5fdbbc0ff6116cc8bb4.camel@intel.com> (raw)
In-Reply-To: <N8LaQsFFQKXyJWEc_Abvsw7vF3HIkLo4H7wsMHwL0DoHw6zLpYEhvb7tb8AFpH_0fC8whnF_R8uBwlAHc2aBKcYhgHOZ-V76qhgS2L8YPfU=@emersion.fr>

On Sun, 2020-12-13 at 17:22 +0000, Simon Ser wrote:
> Can you add some drm_dbg_atomic logs when the damage is invalid, to make it
> easier for user-space to understand why an atomic commit failed?

sure, this is enough? will wait for a couple of more days before send another version.


diff --git a/drivers/gpu/drm/drm_damage_helper.c b/drivers/gpu/drm/drm_damage_helper.c
index 9adb369440ba..b598b137d27f 100644
--- a/drivers/gpu/drm/drm_damage_helper.c
+++ b/drivers/gpu/drm/drm_damage_helper.c
@@ -33,6 +33,7 @@
 #include <drm/drm_atomic.h>
 #include <drm/drm_damage_helper.h>
 #include <drm/drm_device.h>
+#include <drm/drm_print.h>

 /**
  * DOC: overview
@@ -152,16 +153,25 @@ int drm_atomic_helper_check_plane_damage(struct drm_atomic_state *state,

        for (; num_clips; num_clips--, damaged_clips++) {
                if (damaged_clips->x1 < 0 || damaged_clips->x2 < 0 ||
-                   damaged_clips->y1 < 0 || damaged_clips->y2 < 0)
+                   damaged_clips->y1 < 0 || damaged_clips->y2 < 0) {
+                       drm_dbg_atomic(state->dev,
+                                      "Invalid damage clip, negative coordinate\n");
                        return -EINVAL;
+               }

                if (damaged_clips->x2 < damaged_clips->x1 ||
-                   damaged_clips->y2 < damaged_clips->y1)
+                   damaged_clips->y2 < damaged_clips->y1) {
+                       drm_dbg_atomic(state->dev,
+                                      "Invalid damage clip, negative width or height\n");
                        return -EINVAL;
+               }

                if ((damaged_clips->x2 - damaged_clips->x1) > w ||
-                   (damaged_clips->y2 - damaged_clips->y1) > h)
+                   (damaged_clips->y2 - damaged_clips->y1) > h) {
+                       drm_dbg_atomic(state->dev,
+                                      "Invalid damage clip, width or height larger than plane\n");
                        return -EINVAL;
+               }
        }

        return 0;


_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

      reply	other threads:[~2020-12-13 17:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-13 17:07 [PATCH] drm/damage_helper: Check if damage clips has valid values José Roberto de Souza
2020-12-13 17:22 ` Simon Ser
2020-12-13 17:36   ` Souza, Jose [this message]

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=ea52f21e89f437ca88c3f5fdbbc0ff6116cc8bb4.camel@intel.com \
    --to=jose.souza@intel.com \
    --cc=contact@emersion.fr \
    --cc=drawat@vmware.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=gwan-gyeong.mun@intel.com \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=seanpaul@chromium.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox