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
Subject: [PATCH] drm: Warn if plane/crtc/encoder/connector index exceeds our 32bit bitmasks
Date: Wed, 24 Jan 2018 20:37:52 +0200	[thread overview]
Message-ID: <20180124183752.32716-1-ville.syrjala@linux.intel.com> (raw)

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

We use 32bit bitmasks to track planes/crtcs/encoders/connectors.
Naturally we can only do that if the index of those objects stays
below 32. Issue a warning whenever we exceed that limit, hopefully
prompting someone to fix the problem.

Or should we just outright fail the object initializatio perhaps?

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_connector.c | 3 +++
 drivers/gpu/drm/drm_crtc.c      | 3 +++
 drivers/gpu/drm/drm_encoder.c   | 3 +++
 drivers/gpu/drm/drm_plane.c     | 3 +++
 4 files changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index b85a7749709d..9278a81c5d54 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -211,6 +211,9 @@ int drm_connector_init(struct drm_device *dev,
 	connector->index = ret;
 	ret = 0;
 
+	/* we have 32bit connector bitmasks */
+	WARN_ON(connector->index >= 32);
+
 	connector->connector_type = connector_type;
 	connector->connector_type_id =
 		ida_simple_get(connector_ida, 1, 0, GFP_KERNEL);
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c
index f0556e654116..e27ffa3561af 100644
--- a/drivers/gpu/drm/drm_crtc.c
+++ b/drivers/gpu/drm/drm_crtc.c
@@ -318,6 +318,9 @@ int drm_crtc_init_with_planes(struct drm_device *dev, struct drm_crtc *crtc,
 	list_add_tail(&crtc->head, &config->crtc_list);
 	crtc->index = config->num_crtc++;
 
+	/* we have 32bit crtc bitmasks */
+	WARN_ON(crtc->index >= 32);
+
 	crtc->primary = primary;
 	crtc->cursor = cursor;
 	if (primary && !primary->possible_crtcs)
diff --git a/drivers/gpu/drm/drm_encoder.c b/drivers/gpu/drm/drm_encoder.c
index 59e0ebe733f8..66d0cdd217fa 100644
--- a/drivers/gpu/drm/drm_encoder.c
+++ b/drivers/gpu/drm/drm_encoder.c
@@ -136,6 +136,9 @@ int drm_encoder_init(struct drm_device *dev,
 	list_add_tail(&encoder->head, &dev->mode_config.encoder_list);
 	encoder->index = dev->mode_config.num_encoder++;
 
+	/* we have 32bit encoder bitmasks */
+	WARN_ON(encoder->index >= 32);
+
 out_put:
 	if (ret)
 		drm_mode_object_unregister(dev, &encoder->base);
diff --git a/drivers/gpu/drm/drm_plane.c b/drivers/gpu/drm/drm_plane.c
index 2c90519576a3..0a8d807603c1 100644
--- a/drivers/gpu/drm/drm_plane.c
+++ b/drivers/gpu/drm/drm_plane.c
@@ -242,6 +242,9 @@ int drm_universal_plane_init(struct drm_device *dev, struct drm_plane *plane,
 	list_add_tail(&plane->head, &config->plane_list);
 	plane->index = config->num_total_plane++;
 
+	/* we have 32bit plane bitmasks */
+	WARN_ON(plane->index >= 32);
+
 	drm_object_attach_property(&plane->base,
 				   config->plane_type_property,
 				   plane->type);
-- 
2.13.6

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

             reply	other threads:[~2018-01-24 18:37 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-01-24 18:37 Ville Syrjala [this message]
2018-01-24 19:21 ` ✗ Fi.CI.BAT: warning for drm: Warn if plane/crtc/encoder/connector index exceeds our 32bit bitmasks Patchwork
2018-01-24 21:01 ` [PATCH] " Harry Wentland
2018-01-24 21:24   ` Ville Syrjälä
2018-01-24 21:26     ` Harry Wentland
2018-01-24 21:30     ` [Intel-gfx] " Ville Syrjälä
2018-01-24 21:47 ` [PATCH v2] " Ville Syrjala
2018-01-25  9:17   ` Maarten Lankhorst
2018-01-25 11:27     ` Ville Syrjälä
2018-01-25 13:25       ` [Intel-gfx] " Ville Syrjälä
2018-01-24 22:30 ` ✓ Fi.CI.BAT: success for drm: Warn if plane/crtc/encoder/connector index exceeds our 32bit bitmasks (rev2) Patchwork
2018-01-25  1:54 ` ✓ Fi.CI.IGT: " Patchwork
2018-01-25 13:30 ` [PATCH v3] drm: Warn if plane/crtc/encoder/connector index exceeds our 32bit bitmasks Ville Syrjala
2018-01-25 15:12   ` Harry Wentland
2018-01-29 17:21     ` Ville Syrjälä
2018-01-25 13:49 ` ✓ Fi.CI.BAT: success for drm: Warn if plane/crtc/encoder/connector index exceeds our 32bit bitmasks (rev3) Patchwork
2018-01-25 15:17 ` ✗ Fi.CI.IGT: failure " Patchwork
2018-01-29 16:45   ` Ville Syrjälä

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=20180124183752.32716-1-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.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 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.