All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [PATCH v2 5/6] drm: Validate encoder->possible_clones
Date: Fri,  7 Feb 2020 15:59:49 +0200	[thread overview]
Message-ID: <20200207135950.6655-6-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200207135950.6655-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Many drivers are populating encoder->possible_clones wrong. Let's
persuade them to get it right by adding some loud WARNs.

We'll cross check the bits between any two encoders. So either
both encoders can clone with the other, or neither can.

We'll also complain about effectively empty possible_clones, and
possible_clones containing bits for encoders that don't exist.

TODO: Or should we just silently filter out any bits for non-existing
encoders?

v2: encoder->possible_clones now includes the encoder itelf

Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_encoder.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index f761d9306028..bc2246f27e0d 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -79,6 +79,34 @@ static void fixup_possible_clones(struct drm_device *dev)
 		encoder->possible_clones |= drm_encoder_mask(encoder);
 }
 
+static void validate_possible_clones(struct drm_encoder *encoder)
+{
+	struct drm_device *dev = encoder->dev;
+	struct drm_encoder *other;
+	u32 encoder_mask = 0;
+
+	drm_for_each_encoder(other, dev) {
+		encoder_mask |= drm_encoder_mask(other);
+
+		WARN(!(encoder->possible_clones & drm_encoder_mask(other)) !=
+		     !(other->possible_clones & drm_encoder_mask(encoder)),
+		     "possible_clones mismatch: "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x vs. "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x\n",
+		     encoder->base.id, encoder->name,
+		     drm_encoder_mask(encoder), encoder->possible_clones,
+		     other->base.id, other->name,
+		     drm_encoder_mask(other), other->possible_clones);
+	}
+
+	WARN((encoder->possible_clones & drm_encoder_mask(encoder)) == 0 ||
+	     (encoder->possible_clones & ~encoder_mask) != 0,
+	     "Bogus possible_clones: "
+	     "[ENCODER:%d:%s] possible_clones=0x%x (full encoder mask=0x%x)\n",
+	     encoder->base.id, encoder->name,
+	     encoder->possible_clones, encoder_mask);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -87,6 +115,8 @@ int drm_encoder_register_all(struct drm_device *dev)
 	fixup_possible_clones(dev);
 
 	drm_for_each_encoder(encoder, dev) {
+		validate_possible_clones(encoder);
+
 		if (encoder->funcs->late_register)
 			ret = encoder->funcs->late_register(encoder);
 		if (ret)
-- 
2.24.1

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

WARNING: multiple messages have this Message-ID (diff)
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org, Thomas Zimmermann <tzimmermann@suse.de>
Subject: [Intel-gfx] [PATCH v2 5/6] drm: Validate encoder->possible_clones
Date: Fri,  7 Feb 2020 15:59:49 +0200	[thread overview]
Message-ID: <20200207135950.6655-6-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200207135950.6655-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Many drivers are populating encoder->possible_clones wrong. Let's
persuade them to get it right by adding some loud WARNs.

We'll cross check the bits between any two encoders. So either
both encoders can clone with the other, or neither can.

We'll also complain about effectively empty possible_clones, and
possible_clones containing bits for encoders that don't exist.

TODO: Or should we just silently filter out any bits for non-existing
encoders?

v2: encoder->possible_clones now includes the encoder itelf

Cc: Thomas Zimmermann <tzimmermann@suse.de>
Cc: Daniel Vetter <daniel@ffwll.ch>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_encoder.c | 30 ++++++++++++++++++++++++++++++
 1 file changed, 30 insertions(+)

diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index f761d9306028..bc2246f27e0d 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -79,6 +79,34 @@ static void fixup_possible_clones(struct drm_device *dev)
 		encoder->possible_clones |= drm_encoder_mask(encoder);
 }
 
+static void validate_possible_clones(struct drm_encoder *encoder)
+{
+	struct drm_device *dev = encoder->dev;
+	struct drm_encoder *other;
+	u32 encoder_mask = 0;
+
+	drm_for_each_encoder(other, dev) {
+		encoder_mask |= drm_encoder_mask(other);
+
+		WARN(!(encoder->possible_clones & drm_encoder_mask(other)) !=
+		     !(other->possible_clones & drm_encoder_mask(encoder)),
+		     "possible_clones mismatch: "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x vs. "
+		     "[ENCODER:%d:%s] mask=0x%x possible_clones=0x%x\n",
+		     encoder->base.id, encoder->name,
+		     drm_encoder_mask(encoder), encoder->possible_clones,
+		     other->base.id, other->name,
+		     drm_encoder_mask(other), other->possible_clones);
+	}
+
+	WARN((encoder->possible_clones & drm_encoder_mask(encoder)) == 0 ||
+	     (encoder->possible_clones & ~encoder_mask) != 0,
+	     "Bogus possible_clones: "
+	     "[ENCODER:%d:%s] possible_clones=0x%x (full encoder mask=0x%x)\n",
+	     encoder->base.id, encoder->name,
+	     encoder->possible_clones, encoder_mask);
+}
+
 int drm_encoder_register_all(struct drm_device *dev)
 {
 	struct drm_encoder *encoder;
@@ -87,6 +115,8 @@ int drm_encoder_register_all(struct drm_device *dev)
 	fixup_possible_clones(dev);
 
 	drm_for_each_encoder(encoder, dev) {
+		validate_possible_clones(encoder);
+
 		if (encoder->funcs->late_register)
 			ret = encoder->funcs->late_register(encoder);
 		if (ret)
-- 
2.24.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-02-07 14:00 UTC|newest]

Thread overview: 44+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-02-07 13:59 [PATCH v2 0/6] drm: Try to fix encoder possible_clones/crtc Ville Syrjala
2020-02-07 13:59 ` [Intel-gfx] " Ville Syrjala
2020-02-07 13:59 ` [PATCH v2 1/6] drm: Include the encoder itself in possible_clones Ville Syrjala
2020-02-07 13:59   ` [Intel-gfx] " Ville Syrjala
2020-02-07 14:28   ` Thomas Zimmermann
2020-02-07 14:28     ` [Intel-gfx] " Thomas Zimmermann
2020-02-07 14:50     ` Ville Syrjälä
2020-02-07 14:50       ` [Intel-gfx] " Ville Syrjälä
2020-02-07 16:27       ` Daniel Vetter
2020-02-07 16:27         ` Daniel Vetter
2020-02-07 16:34         ` Ville Syrjälä
2020-02-07 16:34           ` Ville Syrjälä
2020-02-07 16:40           ` Daniel Vetter
2020-02-07 16:40             ` Daniel Vetter
2020-02-10  8:16         ` Thomas Zimmermann
2020-02-10  8:16           ` Thomas Zimmermann
2020-02-07 16:36   ` Daniel Vetter
2020-02-07 16:36     ` [Intel-gfx] " Daniel Vetter
2020-02-07 13:59 ` [PATCH v2 2/6] drm/gma500: Sanitize possible_clones Ville Syrjala
2020-02-07 13:59   ` [Intel-gfx] " Ville Syrjala
2020-02-07 16:30   ` Daniel Vetter
2020-02-07 16:30     ` [Intel-gfx] " Daniel Vetter
2020-02-07 13:59 ` [PATCH v2 3/6] drm/exynos: Use drm_encoder_mask() Ville Syrjala
2020-02-07 13:59   ` [Intel-gfx] " Ville Syrjala
2020-02-07 14:19   ` Thomas Zimmermann
2020-02-07 14:19     ` [Intel-gfx] " Thomas Zimmermann
2020-02-07 13:59 ` [PATCH v2 4/6] drm/imx: Remove the bogus possible_clones setup Ville Syrjala
2020-02-07 13:59   ` [Intel-gfx] " Ville Syrjala
2020-02-07 14:20   ` Thomas Zimmermann
2020-02-07 14:20     ` [Intel-gfx] " Thomas Zimmermann
2020-02-07 16:31     ` Daniel Vetter
2020-02-07 16:31       ` Daniel Vetter
2020-02-07 13:59 ` Ville Syrjala [this message]
2020-02-07 13:59   ` [Intel-gfx] [PATCH v2 5/6] drm: Validate encoder->possible_clones Ville Syrjala
2020-02-07 14:25   ` Thomas Zimmermann
2020-02-07 14:25     ` [Intel-gfx] " Thomas Zimmermann
2020-02-07 13:59 ` [PATCH v2 6/6] drm: Validate encoder->possible_crtcs Ville Syrjala
2020-02-07 13:59   ` [Intel-gfx] " Ville Syrjala
2020-02-07 16:39   ` Daniel Vetter
2020-02-07 16:39     ` [Intel-gfx] " Daniel Vetter
2020-02-07 16:49     ` Ville Syrjälä
2020-02-07 16:49       ` [Intel-gfx] " Ville Syrjälä
2020-02-07 17:45 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm: Try to fix encoder possible_clones/crtc (rev2) Patchwork
2020-02-10 16:36 ` [Intel-gfx] ✓ Fi.CI.IGT: " Patchwork

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=20200207135950.6655-6-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    --cc=tzimmermann@suse.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.