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 06/12] drm/client: Constify modes
Date: Thu,  4 Apr 2024 23:33:30 +0300	[thread overview]
Message-ID: <20240404203336.10454-7-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20240404203336.10454-1-ville.syrjala@linux.intel.com>

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

The modes used by the client code live on the connectors' mode
lists, which are not owned by the client code, and thus it has
no business modifying the modes. Mark the modes const to make
that fact abundantly clear.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_client_modeset.c | 36 +++++++++++++++-------------
 1 file changed, 19 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/drm_client_modeset.c b/drivers/gpu/drm/drm_client_modeset.c
index cf1de06f99aa..384a9f8227a0 100644
--- a/drivers/gpu/drm/drm_client_modeset.c
+++ b/drivers/gpu/drm/drm_client_modeset.c
@@ -117,10 +117,10 @@ drm_client_find_modeset(struct drm_client_dev *client, struct drm_crtc *crtc)
 	return NULL;
 }
 
-static struct drm_display_mode *
+static const struct drm_display_mode *
 drm_connector_get_tiled_mode(struct drm_connector *connector)
 {
-	struct drm_display_mode *mode;
+	const struct drm_display_mode *mode;
 
 	list_for_each_entry(mode, &connector->modes, head) {
 		if (mode->hdisplay == connector->tile_h_size &&
@@ -130,10 +130,10 @@ drm_connector_get_tiled_mode(struct drm_connector *connector)
 	return NULL;
 }
 
-static struct drm_display_mode *
+static const struct drm_display_mode *
 drm_connector_fallback_non_tiled_mode(struct drm_connector *connector)
 {
-	struct drm_display_mode *mode;
+	const struct drm_display_mode *mode;
 
 	list_for_each_entry(mode, &connector->modes, head) {
 		if (mode->hdisplay == connector->tile_h_size &&
@@ -144,10 +144,10 @@ drm_connector_fallback_non_tiled_mode(struct drm_connector *connector)
 	return NULL;
 }
 
-static struct drm_display_mode *
+static const struct drm_display_mode *
 drm_connector_preferred_mode(struct drm_connector *connector, int width, int height)
 {
-	struct drm_display_mode *mode;
+	const struct drm_display_mode *mode;
 
 	list_for_each_entry(mode, &connector->modes, head) {
 		if (mode->hdisplay > width ||
@@ -159,10 +159,11 @@ drm_connector_preferred_mode(struct drm_connector *connector, int width, int hei
 	return NULL;
 }
 
-static struct drm_display_mode *drm_connector_pick_cmdline_mode(struct drm_connector *connector)
+static const struct drm_display_mode *
+drm_connector_pick_cmdline_mode(struct drm_connector *connector)
 {
-	struct drm_cmdline_mode *cmdline_mode;
-	struct drm_display_mode *mode;
+	const struct drm_cmdline_mode *cmdline_mode;
+	const struct drm_display_mode *mode;
 	bool prefer_non_interlace;
 
 	/*
@@ -258,13 +259,14 @@ static void drm_client_connectors_enabled(struct drm_connector **connectors,
 static bool drm_client_target_cloned(struct drm_device *dev,
 				     struct drm_connector **connectors,
 				     unsigned int connector_count,
-				     struct drm_display_mode **modes,
+				     const struct drm_display_mode **modes,
 				     struct drm_client_offset *offsets,
 				     bool *enabled, int width, int height)
 {
 	int count, i, j;
 	bool can_clone = false;
-	struct drm_display_mode *dmt_mode, *mode;
+	const struct drm_display_mode *mode;
+	struct drm_display_mode *dmt_mode;
 
 	/* only contemplate cloning in the single crtc case */
 	if (dev->mode_config.num_crtc > 1)
@@ -342,7 +344,7 @@ static bool drm_client_target_cloned(struct drm_device *dev,
 
 static int drm_client_get_tile_offsets(struct drm_connector **connectors,
 				       unsigned int connector_count,
-				       struct drm_display_mode **modes,
+				       const struct drm_display_mode **modes,
 				       struct drm_client_offset *offsets,
 				       int idx,
 				       int h_idx, int v_idx)
@@ -375,7 +377,7 @@ static int drm_client_get_tile_offsets(struct drm_connector **connectors,
 
 static bool drm_client_target_preferred(struct drm_connector **connectors,
 					unsigned int connector_count,
-					struct drm_display_mode **modes,
+					const struct drm_display_mode **modes,
 					struct drm_client_offset *offsets,
 					bool *enabled, int width, int height)
 {
@@ -492,7 +494,7 @@ static int drm_client_pick_crtcs(struct drm_client_dev *client,
 				 struct drm_connector **connectors,
 				 unsigned int connector_count,
 				 struct drm_crtc **best_crtcs,
-				 struct drm_display_mode **modes,
+				 const struct drm_display_mode **modes,
 				 int n, int width, int height)
 {
 	struct drm_device *dev = client->dev;
@@ -567,7 +569,7 @@ static bool drm_client_firmware_config(struct drm_client_dev *client,
 				       struct drm_connector **connectors,
 				       unsigned int connector_count,
 				       struct drm_crtc **crtcs,
-				       struct drm_display_mode **modes,
+				       const struct drm_display_mode **modes,
 				       struct drm_client_offset *offsets,
 				       bool *enabled, int width, int height)
 {
@@ -772,7 +774,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 	struct drm_client_offset *offsets;
 	unsigned int connector_count = 0;
 	/* points to modes protected by mode_config.mutex */
-	struct drm_display_mode **modes;
+	const struct drm_display_mode **modes;
 	struct drm_crtc **crtcs;
 	int i, ret = 0;
 	bool *enabled;
@@ -844,7 +846,7 @@ int drm_client_modeset_probe(struct drm_client_dev *client, unsigned int width,
 	drm_client_modeset_release(client);
 
 	for (i = 0; i < connector_count; i++) {
-		struct drm_display_mode *mode = modes[i];
+		const struct drm_display_mode *mode = modes[i];
 		struct drm_crtc *crtc = crtcs[i];
 		struct drm_client_offset *offset = &offsets[i];
 
-- 
2.43.2


  parent reply	other threads:[~2024-04-04 20:34 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-04 20:33 [PATCH 00/12] drm/client: Use after free and debug improvements Ville Syrjala
2024-04-04 20:33 ` [PATCH 01/12] drm/client: Fully protect modes[] with dev->mode_config.mutex Ville Syrjala
2024-04-05  3:24   ` Dmitry Baryshkov
2024-04-05 19:17     ` Ville Syrjälä
2024-04-05 20:39       ` Dmitry Baryshkov
2024-04-05 20:57         ` Ville Syrjälä
2024-04-04 20:33 ` [PATCH 02/12] drm/client: s/drm_connector_has_preferred_mode/drm_connector_preferred_mode/ Ville Syrjala
2024-04-05  3:27   ` Dmitry Baryshkov
2024-04-04 20:33 ` [PATCH 03/12] drm/client: Use drm_mode_destroy() Ville Syrjala
2024-04-05  3:28   ` Dmitry Baryshkov
2024-04-04 20:33 ` [PATCH 04/12] drm/client: Add a FIXME around crtc->mode usage Ville Syrjala
2024-04-05  3:32   ` Dmitry Baryshkov
2024-04-05 19:40     ` Ville Syrjälä
2024-04-04 20:33 ` [PATCH 05/12] drm/client: Nuke outdated fastboot comment Ville Syrjala
2024-04-05  3:33   ` Dmitry Baryshkov
2024-04-04 20:33 ` Ville Syrjala [this message]
2024-04-05  7:01   ` [PATCH 06/12] drm/client: Constify modes kernel test robot
2024-04-06 21:59   ` kernel test robot
2024-04-04 20:33 ` [PATCH 07/12] drm/client: Use array notation for function arguments Ville Syrjala
2024-04-05  8:02   ` Thomas Zimmermann
2024-04-04 20:33 ` [PATCH 08/12] drm/client: Extract drm_connector_first_mode() Ville Syrjala
2024-04-05  8:26   ` Jani Nikula
2024-04-04 20:33 ` [PATCH 09/12] drm/client: Switch to per-device debugs Ville Syrjala
2024-04-04 20:33 ` [PATCH 10/12] drm/client: Use [CONNECTOR:%d:%s] formatting Ville Syrjala
2024-04-05  8:23   ` Jani Nikula
2024-04-05 20:12     ` Ville Syrjälä
2024-04-04 20:33 ` [PATCH 11/12] drm/client: Streamline mode selection debugs Ville Syrjala
2024-04-05  7:49   ` Thomas Zimmermann
2024-04-05  7:57   ` Thomas Zimmermann
2024-04-05 19:58     ` Ville Syrjälä
2024-04-08  7:46       ` Thomas Zimmermann
2024-04-08 17:26         ` Ville Syrjälä
2024-04-09  8:01           ` Thomas Zimmermann
2024-04-04 20:33 ` [PATCH 12/12] drm/probe-helper: Switch to per-device debugs Ville Syrjala
2024-04-05  8:25   ` Jani Nikula
2024-04-05  8:30     ` Thomas Zimmermann
2024-04-04 21:10 ` ✗ Fi.CI.CHECKPATCH: warning for drm/client: Use after free and debug improvements Patchwork
2024-04-04 21:10 ` ✗ Fi.CI.SPARSE: " Patchwork
2024-04-04 21:22 ` ✓ Fi.CI.BAT: success " Patchwork
2024-04-05  8:04 ` [PATCH 00/12] " Thomas Zimmermann
2024-04-05 14:02 ` ✗ Fi.CI.IGT: failure for " 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=20240404203336.10454-7-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.