All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-24 20:02 ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

CEA-861 says :
"d = offset for the byte following the reserved data block.
 If no data is provided in the reserved data block, then d=4.
 If no DTDs are provided, then d=0."

So let's not look for DTDs when d==0. In fact let's just make that
<4 since those values would just mean that he DTDs overlap the block
header. And let's also check that d isn't so big as to declare
the descriptors to live past the block end, although the code
does already survive that case as we'd just end up with a negative
number of descriptors and the loop would not do anything.

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 99769d6c9f84..1b6e544cf5c7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 static void
 cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
 {
-	int i, n = 0;
+	int i, n;
 	u8 d = ext[0x02];
 	u8 *det_base = ext + d;
 
+	if (d < 4 || d > 127)
+		return;
+
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
 		cb((struct detailed_timing *)(det_base + 18 * i), closure);
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-24 20:02 ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

CEA-861 says :
"d = offset for the byte following the reserved data block.
 If no data is provided in the reserved data block, then d=4.
 If no DTDs are provided, then d=0."

So let's not look for DTDs when d==0. In fact let's just make that
<4 since those values would just mean that he DTDs overlap the block
header. And let's also check that d isn't so big as to declare
the descriptors to live past the block end, although the code
does already survive that case as we'd just end up with a negative
number of descriptors and the loop would not do anything.

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 99769d6c9f84..1b6e544cf5c7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 static void
 cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
 {
-	int i, n = 0;
+	int i, n;
 	u8 d = ext[0x02];
 	u8 *det_base = ext + d;
 
+	if (d < 4 || d > 127)
+		return;
+
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
 		cb((struct detailed_timing *)(det_base + 18 * i), closure);
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

Currently we assume any 18 byte descriptor to be a display descritor
if only the tag byte matches the expected value. But for detailed
timing descriptors that same byte is just the lower 8 bits of
hblank, and as such can match any display descriptor tag. To
properly validate that the 18 byte descriptor is in fact a
display descriptor we must also examine bytes 0-2 (just byte 1
should actually suffice but the spec does say that bytes 0 and
2 must also always be zero for display descriptors so we check
those too).

Unlike Allen's original proposed patch to just fix is_rb() we
roll this out across the board to fix everything.

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 65 ++++++++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 1b6e544cf5c7..96ae1fde4ce2 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2196,6 +2196,12 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_find_dmt);
 
+static bool is_display_descriptor(const u8 d[18], u8 tag)
+{
+	return d[0] == 0x00 && d[1] == 0x00 &&
+		d[2] == 0x00 && d[3] == tag;
+}
+
 typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 
 static void
@@ -2257,9 +2263,12 @@ static void
 is_rb(struct detailed_timing *t, void *data)
 {
 	u8 *r = (u8 *)t;
-	if (r[3] == EDID_DETAIL_MONITOR_RANGE)
-		if (r[15] & 0x10)
-			*(bool *)data = true;
+
+	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
+		return;
+
+	if (r[15] & 0x10)
+		*(bool *)data = true;
 }
 
 /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
@@ -2279,7 +2288,11 @@ static void
 find_gtf2(struct detailed_timing *t, void *data)
 {
 	u8 *r = (u8 *)t;
-	if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
+
+	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
+		return;
+
+	if (r[10] == 0x02)
 		*(u8 **)data = r;
 }
 
@@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 	struct detailed_non_pixel *data = &timing->data.other_data;
 	struct detailed_data_monitor_range *range = &data->data.range;
 
-	if (data->type != EDID_DETAIL_MONITOR_RANGE)
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	closure->modes += drm_dmt_modes_for_range(closure->connector,
@@ -2897,10 +2910,11 @@ static void
 do_established_modes(struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
 
-	if (data->type == EDID_DETAIL_EST_TIMINGS)
-		closure->modes += drm_est3_modes(closure->connector, timing);
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
+		return;
+
+	closure->modes += drm_est3_modes(closure->connector, timing);
 }
 
 /**
@@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing, void *c)
 	struct detailed_non_pixel *data = &timing->data.other_data;
 	struct drm_connector *connector = closure->connector;
 	struct edid *edid = closure->edid;
+	int i;
 
-	if (data->type == EDID_DETAIL_STD_MODES) {
-		int i;
-		for (i = 0; i < 6; i++) {
-			struct std_timing *std;
-			struct drm_display_mode *newmode;
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
+		return;
 
-			std = &data->data.timings[i];
-			newmode = drm_mode_std(connector, edid, std);
-			if (newmode) {
-				drm_mode_probed_add(connector, newmode);
-				closure->modes++;
-			}
+	for (i = 0; i < 6; i++) {
+		struct std_timing *std = &data->data.timings[i];
+		struct drm_display_mode *newmode;
+
+		newmode = drm_mode_std(connector, edid, std);
+		if (newmode) {
+			drm_mode_probed_add(connector, newmode);
+			closure->modes++;
 		}
 	}
 }
@@ -3056,10 +3070,11 @@ static void
 do_cvt_mode(struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
 
-	if (data->type == EDID_DETAIL_CVT_3BYTE)
-		closure->modes += drm_cvt_modes(closure->connector, timing);
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
+		return;
+
+	closure->modes += drm_cvt_modes(closure->connector, timing);
 }
 
 static int
@@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 static void
 monitor_name(struct detailed_timing *t, void *data)
 {
-	if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
-		*(u8 **)data = t->data.other_data.data.str.str;
+	if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
+		return;
+
+	*(u8 **)data = t->data.other_data.data.str.str;
 }
 
 static int get_monitor_name(struct edid *edid, char name[13])
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

Currently we assume any 18 byte descriptor to be a display descritor
if only the tag byte matches the expected value. But for detailed
timing descriptors that same byte is just the lower 8 bits of
hblank, and as such can match any display descriptor tag. To
properly validate that the 18 byte descriptor is in fact a
display descriptor we must also examine bytes 0-2 (just byte 1
should actually suffice but the spec does say that bytes 0 and
2 must also always be zero for display descriptors so we check
those too).

Unlike Allen's original proposed patch to just fix is_rb() we
roll this out across the board to fix everything.

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 65 ++++++++++++++++++++++++--------------
 1 file changed, 41 insertions(+), 24 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 1b6e544cf5c7..96ae1fde4ce2 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2196,6 +2196,12 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
 }
 EXPORT_SYMBOL(drm_mode_find_dmt);
 
+static bool is_display_descriptor(const u8 d[18], u8 tag)
+{
+	return d[0] == 0x00 && d[1] == 0x00 &&
+		d[2] == 0x00 && d[3] == tag;
+}
+
 typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 
 static void
@@ -2257,9 +2263,12 @@ static void
 is_rb(struct detailed_timing *t, void *data)
 {
 	u8 *r = (u8 *)t;
-	if (r[3] == EDID_DETAIL_MONITOR_RANGE)
-		if (r[15] & 0x10)
-			*(bool *)data = true;
+
+	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
+		return;
+
+	if (r[15] & 0x10)
+		*(bool *)data = true;
 }
 
 /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
@@ -2279,7 +2288,11 @@ static void
 find_gtf2(struct detailed_timing *t, void *data)
 {
 	u8 *r = (u8 *)t;
-	if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
+
+	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
+		return;
+
+	if (r[10] == 0x02)
 		*(u8 **)data = r;
 }
 
@@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 	struct detailed_non_pixel *data = &timing->data.other_data;
 	struct detailed_data_monitor_range *range = &data->data.range;
 
-	if (data->type != EDID_DETAIL_MONITOR_RANGE)
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	closure->modes += drm_dmt_modes_for_range(closure->connector,
@@ -2897,10 +2910,11 @@ static void
 do_established_modes(struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
 
-	if (data->type == EDID_DETAIL_EST_TIMINGS)
-		closure->modes += drm_est3_modes(closure->connector, timing);
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
+		return;
+
+	closure->modes += drm_est3_modes(closure->connector, timing);
 }
 
 /**
@@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing, void *c)
 	struct detailed_non_pixel *data = &timing->data.other_data;
 	struct drm_connector *connector = closure->connector;
 	struct edid *edid = closure->edid;
+	int i;
 
-	if (data->type == EDID_DETAIL_STD_MODES) {
-		int i;
-		for (i = 0; i < 6; i++) {
-			struct std_timing *std;
-			struct drm_display_mode *newmode;
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
+		return;
 
-			std = &data->data.timings[i];
-			newmode = drm_mode_std(connector, edid, std);
-			if (newmode) {
-				drm_mode_probed_add(connector, newmode);
-				closure->modes++;
-			}
+	for (i = 0; i < 6; i++) {
+		struct std_timing *std = &data->data.timings[i];
+		struct drm_display_mode *newmode;
+
+		newmode = drm_mode_std(connector, edid, std);
+		if (newmode) {
+			drm_mode_probed_add(connector, newmode);
+			closure->modes++;
 		}
 	}
 }
@@ -3056,10 +3070,11 @@ static void
 do_cvt_mode(struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
 
-	if (data->type == EDID_DETAIL_CVT_3BYTE)
-		closure->modes += drm_cvt_modes(closure->connector, timing);
+	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
+		return;
+
+	closure->modes += drm_cvt_modes(closure->connector, timing);
 }
 
 static int
@@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 static void
 monitor_name(struct detailed_timing *t, void *data)
 {
-	if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
-		*(u8 **)data = t->data.other_data.data.str.str;
+	if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
+		return;
+
+	*(u8 **)data = t->data.other_data.data.str.str;
 }
 
 static int get_monitor_name(struct edid *edid, char name[13])
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

Let's introduce is_detailed_timing_descritor() as the opposite
counterpart of is_display_descriptor().

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 96ae1fde4ce2..d6bce58b27ac 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
 		d[2] == 0x00 && d[3] == tag;
 }
 
+static bool is_detailed_timing_descriptor(const u8 d[18])
+{
+	return d[0] != 0x00 || d[1] != 0x00;
+}
+
 typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 
 static void
@@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
 
-	if (timing->pixel_clock) {
-		newmode = drm_mode_detailed(closure->connector->dev,
-					    closure->edid, timing,
-					    closure->quirks);
-		if (!newmode)
-			return;
+	if (!is_detailed_timing_descriptor((const u8 *)timing))
+		return;
+
+	newmode = drm_mode_detailed(closure->connector->dev,
+				    closure->edid, timing,
+				    closure->quirks);
+	if (!newmode)
+		return;
 
-		if (closure->preferred)
-			newmode->type |= DRM_MODE_TYPE_PREFERRED;
+	if (closure->preferred)
+		newmode->type |= DRM_MODE_TYPE_PREFERRED;
 
-		/*
-		 * Detailed modes are limited to 10kHz pixel clock resolution,
-		 * so fix up anything that looks like CEA/HDMI mode, but the clock
-		 * is just slightly off.
-		 */
-		fixup_detailed_cea_mode_clock(newmode);
+	/*
+	 * Detailed modes are limited to 10kHz pixel clock resolution,
+	 * so fix up anything that looks like CEA/HDMI mode, but the clock
+	 * is just slightly off.
+	 */
+	fixup_detailed_cea_mode_clock(newmode);
 
-		drm_mode_probed_add(closure->connector, newmode);
-		closure->modes++;
-		closure->preferred = false;
-	}
+	drm_mode_probed_add(closure->connector, newmode);
+	closure->modes++;
+	closure->preferred = false;
 }
 
 /*
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: Allen Chen, intel-gfx

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

Let's introduce is_detailed_timing_descritor() as the opposite
counterpart of is_display_descriptor().

Cc: Allen Chen <allen.chen@ite.com.tw>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
 1 file changed, 24 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 96ae1fde4ce2..d6bce58b27ac 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
 		d[2] == 0x00 && d[3] == tag;
 }
 
+static bool is_detailed_timing_descriptor(const u8 d[18])
+{
+	return d[0] != 0x00 || d[1] != 0x00;
+}
+
 typedef void detailed_cb(struct detailed_timing *timing, void *closure);
 
 static void
@@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
 
-	if (timing->pixel_clock) {
-		newmode = drm_mode_detailed(closure->connector->dev,
-					    closure->edid, timing,
-					    closure->quirks);
-		if (!newmode)
-			return;
+	if (!is_detailed_timing_descriptor((const u8 *)timing))
+		return;
+
+	newmode = drm_mode_detailed(closure->connector->dev,
+				    closure->edid, timing,
+				    closure->quirks);
+	if (!newmode)
+		return;
 
-		if (closure->preferred)
-			newmode->type |= DRM_MODE_TYPE_PREFERRED;
+	if (closure->preferred)
+		newmode->type |= DRM_MODE_TYPE_PREFERRED;
 
-		/*
-		 * Detailed modes are limited to 10kHz pixel clock resolution,
-		 * so fix up anything that looks like CEA/HDMI mode, but the clock
-		 * is just slightly off.
-		 */
-		fixup_detailed_cea_mode_clock(newmode);
+	/*
+	 * Detailed modes are limited to 10kHz pixel clock resolution,
+	 * so fix up anything that looks like CEA/HDMI mode, but the clock
+	 * is just slightly off.
+	 */
+	fixup_detailed_cea_mode_clock(newmode);
 
-		drm_mode_probed_add(closure->connector, newmode);
-		closure->modes++;
-		closure->preferred = false;
-	}
+	drm_mode_probed_add(closure->connector, newmode);
+	closure->modes++;
+	closure->preferred = false;
 }
 
 /*
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 4/8] drm/i915: Clear out spurious whitespace
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

Nuke some whitespace that shouldn't be there.

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

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index d6bce58b27ac..3df5744026b0 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 	closure->modes += drm_dmt_modes_for_range(closure->connector,
 						  closure->edid,
 						  timing);
-	
+
 	if (!version_greater(closure->edid, 1, 1))
 		return; /* GTF not defined yet */
 
@@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
 
 static int
 add_cvt_modes(struct drm_connector *connector, struct edid *edid)
-{	
+{
 	struct detailed_mode_closure closure = {
 		.connector = connector,
 		.edid = edid,
@@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
 {
 	int name_length;
 	char buf[13];
-	
+
 	if (bufsize <= 0)
 		return;
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

Nuke some whitespace that shouldn't be there.

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

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index d6bce58b27ac..3df5744026b0 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 	closure->modes += drm_dmt_modes_for_range(closure->connector,
 						  closure->edid,
 						  timing);
-	
+
 	if (!version_greater(closure->edid, 1, 1))
 		return; /* GTF not defined yet */
 
@@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
 
 static int
 add_cvt_modes(struct drm_connector *connector, struct edid *edid)
-{	
+{
 	struct detailed_mode_closure closure = {
 		.connector = connector,
 		.edid = edid,
@@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
 {
 	int name_length;
 	char buf[13];
-	
+
 	if (bufsize <= 0)
 		return;
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Andres Rodriguez

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

After much head scratching I managed to convince myself that
for_each_displayid_db() has already done the bounds checks for
the DispID CEA data block. Which is why we don't need to repeat
them in cea_db_offsets(). To avoid having to go through that
pain again in the future add a comment which explains this fact.

Cc: Andres Rodriguez <andresx7@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 3df5744026b0..0369a54e3d32 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
 	 *   no non-DTD data.
 	 */
 	if (cea[0] == DATA_BLOCK_CTA) {
+		/*
+		 * for_each_displayid_db() has already verified
+		 * that these stay within expected bounds.
+		 */
 		*start = 3;
 		*end = *start + cea[2];
 	} else if (cea[0] == CEA_EXT) {
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Andres Rodriguez

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

After much head scratching I managed to convince myself that
for_each_displayid_db() has already done the bounds checks for
the DispID CEA data block. Which is why we don't need to repeat
them in cea_db_offsets(). To avoid having to go through that
pain again in the future add a comment which explains this fact.

Cc: Andres Rodriguez <andresx7@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 3df5744026b0..0369a54e3d32 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
 	 *   no non-DTD data.
 	 */
 	if (cea[0] == DATA_BLOCK_CTA) {
+		/*
+		 * for_each_displayid_db() has already verified
+		 * that these stay within expected bounds.
+		 */
 		*start = 3;
 		*end = *start + cea[2];
 	} else if (cea[0] == CEA_EXT) {
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Andres Rodriguez

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

I don't understand what the DispID CEA data block revision
means. The spec doesn't say. I guess some DispID must have
a value of >= 3 in there or else we generally wouldn't
even parse the CEA data blocks. Or does all this code
actually not do anything?

Cc: Andres Rodriguez <andresx7@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 0369a54e3d32..fd9b724067a7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)
 static int
 cea_revision(const u8 *cea)
 {
+	/*
+	 * FIXME is this correct for the DispID variant?
+	 * The DispID spec doesn't really specify whether
+	 * this is the revision of the CEA extension or
+	 * the DispID CEA data block. And the only value
+	 * given as an example is 0.
+	 */
 	return cea[1];
 }
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx, Andres Rodriguez

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

I don't understand what the DispID CEA data block revision
means. The spec doesn't say. I guess some DispID must have
a value of >= 3 in there or else we generally wouldn't
even parse the CEA data blocks. Or does all this code
actually not do anything?

Cc: Andres Rodriguez <andresx7@gmail.com>
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 0369a54e3d32..fd9b724067a7 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)
 static int
 cea_revision(const u8 *cea)
 {
+	/*
+	 * FIXME is this correct for the DispID variant?
+	 * The DispID spec doesn't really specify whether
+	 * this is the revision of the CEA extension or
+	 * the DispID CEA data block. And the only value
+	 * given as an example is 0.
+	 */
 	return cea[1];
 }
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 7/8] drm/edid: Constify lots of things
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

Let's try to make a lot more stuff const in the edid parser.

The "downside" is that we can no longer mangle the EDID in the
middle of the parsing to apply quirks (drm_mode_detailed()).
I don't really think mangling the blob itself is such a great
idea anyway so I won't miss that part. But if we do want it
back I guess we should do the mangling in one explicit place
before we otherwise parse the EDID.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_connector.c |   4 +-
 drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
 include/drm/drm_connector.h     |   4 +-
 3 files changed, 176 insertions(+), 135 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index f632ca05960e..92a5cd6ff6b1 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
  * tile group or NULL if not found.
  */
 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
-					       char topology[8])
+					       const u8 topology[8])
 {
 	struct drm_tile_group *tg;
 	int id;
@@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
  * new tile group or NULL.
  */
 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
-						  char topology[8])
+						  const u8 topology[8])
 {
 	struct drm_tile_group *tg;
 	int ret;
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index fd9b724067a7..8e76efe1654d 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -88,7 +88,7 @@
 
 struct detailed_mode_closure {
 	struct drm_connector *connector;
-	struct edid *edid;
+	const struct edid *edid;
 	bool preferred;
 	u32 quirks;
 	int modes;
@@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
 		 "Minimum number of valid EDID header bytes (0-8, default 6)");
 
 static void drm_get_displayid(struct drm_connector *connector,
-			      struct edid *edid);
-static int validate_displayid(u8 *displayid, int length, int idx);
+			      const struct edid *edid);
+static int validate_displayid(const u8 *displayid, int length, int idx);
 
 static int drm_edid_block_checksum(const u8 *raw_edid)
 {
@@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
 	return d[0] != 0x00 || d[1] != 0x00;
 }
 
-typedef void detailed_cb(struct detailed_timing *timing, void *closure);
+typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
 
 static void
-cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
+cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
 	int i, n;
 	u8 d = ext[0x02];
-	u8 *det_base = ext + d;
+	const u8 *det_base = ext + d;
 
 	if (d < 4 || d > 127)
 		return;
 
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
-		cb((struct detailed_timing *)(det_base + 18 * i), closure);
+		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
 }
 
 static void
-vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
+vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
 	unsigned int i, n = min((int)ext[0x02], 6);
-	u8 *det_base = ext + 5;
+	const u8 *det_base = ext + 5;
 
 	if (ext[0x01] != 1)
 		return; /* unknown version */
 
 	for (i = 0; i < n; i++)
-		cb((struct detailed_timing *)(det_base + 18 * i), closure);
+		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
 }
 
 static void
-drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
+drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
 {
+	const struct edid *edid = (struct edid *)raw_edid;
 	int i;
-	struct edid *edid = (struct edid *)raw_edid;
 
 	if (edid == NULL)
 		return;
@@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 		cb(&(edid->detailed_timings[i]), closure);
 
 	for (i = 1; i <= raw_edid[0x7e]; i++) {
-		u8 *ext = raw_edid + (i * EDID_LENGTH);
+		const u8 *ext = raw_edid + (i * EDID_LENGTH);
 		switch (*ext) {
 		case CEA_EXT:
 			cea_for_each_detailed_block(ext, cb, closure);
@@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 	}
 }
 
+struct bool_closure {
+	bool ret;
+};
+
 static void
-is_rb(struct detailed_timing *t, void *data)
+is_rb(const struct detailed_timing *t, void *c)
 {
-	u8 *r = (u8 *)t;
+	struct bool_closure *closure = c;
+	const u8 *r = (const u8 *)t;
 
 	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	if (r[15] & 0x10)
-		*(bool *)data = true;
+		closure->ret = true;
 }
 
 /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
 static bool
-drm_monitor_supports_rb(struct edid *edid)
+drm_monitor_supports_rb(const struct edid *edid)
 {
 	if (edid->revision >= 4) {
-		bool ret = false;
-		drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
-		return ret;
+		struct bool_closure closure = {
+			.ret = false,
+		};
+
+		drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
+
+		return closure.ret;
 	}
 
 	return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
 }
 
+struct data_closure {
+	const u8 *data;
+};
+
 static void
-find_gtf2(struct detailed_timing *t, void *data)
+do_find_gtf2(const struct detailed_timing *t, void *c)
 {
-	u8 *r = (u8 *)t;
+	struct data_closure *closure = c;
+	const u8 *r = (const u8 *)t;
 
 	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	if (r[10] == 0x02)
-		*(u8 **)data = r;
+		closure->data = r;
+}
+
+static const u8 *
+find_gtf2_descriptor(const struct edid *edid)
+{
+	struct data_closure closure = {};
+
+	drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
+
+	return closure.data;
 }
 
 /* Secondary GTF curve kicks in above some break frequency */
 static int
-drm_gtf2_hbreak(struct edid *edid)
+drm_gtf2_hbreak(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
-	return r ? (r[12] * 2) : 0;
+	const u8 *r = find_gtf2_descriptor(edid);
+
+	return r ? r[12] * 2 : 0;
 }
 
 static int
-drm_gtf2_2c(struct edid *edid)
+drm_gtf2_2c(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[13] : 0;
 }
 
 static int
-drm_gtf2_m(struct edid *edid)
+drm_gtf2_m(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
-	return r ? (r[15] << 8) + r[14] : 0;
+	const u8 *r = find_gtf2_descriptor(edid);
+
+	return r ? (r[15] << 8) | r[14] : 0;
 }
 
 static int
-drm_gtf2_k(struct edid *edid)
+drm_gtf2_k(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[16] : 0;
 }
 
 static int
-drm_gtf2_2j(struct edid *edid)
+drm_gtf2_2j(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[17] : 0;
 }
 
@@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
  * standard_timing_level - get std. timing level(CVT/GTF/DMT)
  * @edid: EDID block to scan
  */
-static int standard_timing_level(struct edid *edid)
+static int standard_timing_level(const struct edid *edid)
 {
 	if (edid->revision >= 2) {
 		if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
@@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
  * and convert them into a real mode using CVT/GTF/DMT.
  */
 static struct drm_display_mode *
-drm_mode_std(struct drm_connector *connector, struct edid *edid,
-	     struct std_timing *t)
+drm_mode_std(struct drm_connector *connector,
+	     const struct edid *edid,
+	     const struct std_timing *t)
 {
 	struct drm_device *dev = connector->dev;
 	struct drm_display_mode *m, *mode = NULL;
@@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
  */
 static void
 drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
-			    struct detailed_pixel_timing *pt)
+			    const struct detailed_pixel_timing *pt)
 {
 	int i;
 	static const struct {
@@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
  * return a new struct drm_display_mode.
  */
 static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
-						  struct edid *edid,
-						  struct detailed_timing *timing,
+						  const struct edid *edid,
+						  const struct detailed_timing *timing,
 						  u32 quirks)
 {
 	struct drm_display_mode *mode;
-	struct detailed_pixel_timing *pt = &timing->data.pixel_data;
+	const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
 	unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
 	unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
 	unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
@@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 		return NULL;
 
 	if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
-		timing->pixel_clock = cpu_to_le16(1088);
-
-	mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
+		mode->clock = 1088 * 10;
+	else
+		mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
 
 	mode->hdisplay = hactive;
 	mode->hsync_start = mode->hdisplay + hsync_offset;
@@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 	drm_mode_do_interlace_quirk(mode, pt);
 
 	if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
-		pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
+		mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
+	} else {
+		mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
+		mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
 	}
 
-	mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
-	mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
-
 set_size:
 	mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
 	mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
@@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 
 static bool
 mode_in_hsync_range(const struct drm_display_mode *mode,
-		    struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int hsync, hmin, hmax;
 
@@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
 
 static bool
 mode_in_vsync_range(const struct drm_display_mode *mode,
-		    struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int vsync, vmin, vmax;
 
@@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
 }
 
 static u32
-range_pixel_clock(struct edid *edid, u8 *t)
+range_pixel_clock(const struct edid *edid, const u8 *t)
 {
 	/* unspecified */
 	if (t[9] == 0 || t[9] == 255)
@@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
 }
 
 static bool
-mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
-	      struct detailed_timing *timing)
+mode_in_range(const struct drm_display_mode *mode,
+	      const struct edid *edid,
+	      const struct detailed_timing *timing)
 {
 	u32 max_clock;
-	u8 *t = (u8 *)timing;
+	const u8 *t = (const u8 *)timing;
 
 	if (!mode_in_hsync_range(mode, edid, t))
 		return false;
@@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
 }
 
 static int
-drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_dmt_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
 }
 
 static int
-drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_gtf_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
 }
 
 static int
-drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_cvt_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
 }
 
 static void
-do_inferred_modes(struct detailed_timing *timing, void *c)
+do_inferred_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
-	struct detailed_data_monitor_range *range = &data->data.range;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_data_monitor_range *range = &data->data.range;
 
 	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
 		return;
@@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 }
 
 static int
-add_inferred_modes(struct drm_connector *connector, struct edid *edid)
+add_inferred_modes(struct drm_connector *connector,
+		   const struct edid *edid)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
 	};
 
 	if (version_greater(edid, 1, 0))
-		drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
+		drm_for_each_detailed_block((const u8 *)edid,
+					    do_inferred_modes,
 					    &closure);
 
 	return closure.modes;
 }
 
 static int
-drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
+drm_est3_modes(struct drm_connector *connector,
+	       const struct detailed_timing *timing)
 {
 	int i, j, m, modes = 0;
 	struct drm_display_mode *mode;
-	u8 *est = ((u8 *)timing) + 6;
+	const u8 *est = ((const u8 *)timing) + 6;
 
 	for (i = 0; i < 6; i++) {
 		for (j = 7; j >= 0; j--) {
@@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
 }
 
 static void
-do_established_modes(struct detailed_timing *timing, void *c)
+do_established_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 
@@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
  * (defined above).  Tease them out and add them to the global modes list.
  */
 static int
-add_established_modes(struct drm_connector *connector, struct edid *edid)
+add_established_modes(struct drm_connector *connector,
+		      const struct edid *edid)
 {
 	struct drm_device *dev = connector->dev;
 	unsigned long est_bits = edid->established_timings.t1 |
@@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
 }
 
 static void
-do_standard_modes(struct detailed_timing *timing, void *c)
+do_standard_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
 	struct drm_connector *connector = closure->connector;
-	struct edid *edid = closure->edid;
+	const struct edid *edid = closure->edid;
 	int i;
 
 	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
 		return;
 
 	for (i = 0; i < 6; i++) {
-		struct std_timing *std = &data->data.timings[i];
+		const struct std_timing *std = &data->data.timings[i];
 		struct drm_display_mode *newmode;
 
 		newmode = drm_mode_std(connector, edid, std);
@@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
  * GTF or CVT. Grab them from @edid and add them to the list.
  */
 static int
-add_standard_modes(struct drm_connector *connector, struct edid *edid)
+add_standard_modes(struct drm_connector *connector,
+		   const struct edid *edid)
 {
 	int i, modes = 0;
 	struct detailed_mode_closure closure = {
@@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
 }
 
 static int drm_cvt_modes(struct drm_connector *connector,
-			 struct detailed_timing *timing)
+			 const struct detailed_timing *timing)
 {
 	int i, j, modes = 0;
 	struct drm_display_mode *newmode;
 	struct drm_device *dev = connector->dev;
-	struct cvt_timing *cvt;
 	const int rates[] = { 60, 85, 75, 60, 50 };
 	const u8 empty[3] = { 0, 0, 0 };
 
 	for (i = 0; i < 4; i++) {
 		int uninitialized_var(width), height;
-		cvt = &(timing->data.other_data.data.cvt[i]);
+		const struct cvt_timing *cvt =
+			&timing->data.other_data.data.cvt[i];
 
 		if (!memcmp(cvt->code, empty, 3))
 			continue;
@@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
 }
 
 static void
-do_cvt_mode(struct detailed_timing *timing, void *c)
+do_cvt_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 
@@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
 }
 
 static int
-add_cvt_modes(struct drm_connector *connector, struct edid *edid)
+add_cvt_modes(struct drm_connector *connector,
+	      const struct edid *edid)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
 static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
 
 static void
-do_detailed_mode(struct detailed_timing *timing, void *c)
+do_detailed_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
@@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
  * @quirks: quirks to apply
  */
 static int
-add_detailed_modes(struct drm_connector *connector, struct edid *edid,
-		   u32 quirks)
+add_detailed_modes(struct drm_connector *connector,
+		   struct edid *edid, u32 quirks)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
 /*
  * Search EDID for CEA extension block.
  */
-static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
+static const u8 *drm_find_edid_extension(const struct edid *edid,
+					 int ext_id)
 {
-	u8 *edid_ext = NULL;
+	const u8 *edid_ext = NULL;
 	int i;
 
 	/* No EDID or EDID extensions */
@@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
 
 	/* Find CEA extension */
 	for (i = 0; i < edid->extensions; i++) {
-		edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
+		edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
 		if (edid_ext[0] == ext_id)
 			break;
 	}
@@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
 }
 
 
-static u8 *drm_find_displayid_extension(const struct edid *edid)
+static const u8 *drm_find_displayid_extension(const struct edid *edid)
 {
 	return drm_find_edid_extension(edid, DISPLAYID_EXT);
 }
 
-static u8 *drm_find_cea_extension(const struct edid *edid)
+static const u8 *drm_find_cea_extension(const struct edid *edid)
 {
 	int ret;
 	int idx = 1;
 	int length = EDID_LENGTH;
-	struct displayid_block *block;
-	u8 *cea;
-	u8 *displayid;
+	const struct displayid_block *block;
+	const u8 *cea;
+	const u8 *displayid;
 
 	/* Look for a top level CEA extension block */
 	cea = drm_find_edid_extension(edid, CEA_EXT);
@@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 }
 
 static void
-monitor_name(struct detailed_timing *t, void *data)
+monitor_name(const struct detailed_timing *t, void *c)
 {
+	struct data_closure *closure = c;
+
 	if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
 		return;
 
-	*(u8 **)data = t->data.other_data.data.str.str;
+	closure->data = t->data.other_data.data.str.str;
 }
 
 static int get_monitor_name(struct edid *edid, char name[13])
 {
-	char *edid_name = NULL;
+	struct data_closure closure = {};
 	int mnl;
 
 	if (!edid || !name)
 		return 0;
 
-	drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
-	for (mnl = 0; edid_name && mnl < 13; mnl++) {
-		if (edid_name[mnl] == 0x0a)
+	drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
+	for (mnl = 0; closure.data && mnl < 13; mnl++) {
+		if (closure.data[mnl] == 0x0a)
 			break;
 
-		name[mnl] = edid_name[mnl];
+		name[mnl] = closure.data[mnl];
 	}
 
 	return mnl;
@@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
 static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 {
 	uint8_t *eld = connector->eld;
-	u8 *cea;
-	u8 *db;
+	const u8 *cea;
 	int total_sad_count = 0;
 	int mnl;
-	int dbl;
 
 	clear_eld(connector);
 
@@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 		}
 
 		for_each_cea_db(cea, i, start, end) {
-			db = &cea[i];
-			dbl = cea_db_payload_len(db);
+			const u8 *db = &cea[i];
+			int dbl = cea_db_payload_len(db);
 
 			switch (cea_db_tag(db)) {
 				int sad_count;
@@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 {
 	int count = 0;
 	int i, start, end, dbl;
-	u8 *cea;
+	const u8 *cea;
 
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
@@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 	}
 
 	for_each_cea_db(cea, i, start, end) {
-		u8 *db = &cea[i];
+		const u8 *db = &cea[i];
 
 		if (cea_db_tag(db) == AUDIO_BLOCK) {
 			int j;
@@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 			if (!*sads)
 				return -ENOMEM;
 			for (j = 0; j < count; j++) {
-				u8 *sad = &db[1 + j * 3];
+				const u8 *sad = &db[1 + j * 3];
 
 				(*sads)[j].format = (sad[0] & 0x78) >> 3;
 				(*sads)[j].channels = sad[0] & 0x7;
@@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
  */
 bool drm_detect_hdmi_monitor(struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i;
 	int start_offset, end_offset;
 
@@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
  */
 bool drm_detect_monitor_audio(struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i, j;
 	bool has_audio = false;
 	int start_offset, end_offset;
@@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 	return quirks;
 }
 
-static int validate_displayid(u8 *displayid, int length, int idx)
+static int validate_displayid(const u8 *displayid, int length, int idx)
 {
 	int i;
 	u8 csum = 0;
-	struct displayid_hdr *base;
+	const struct displayid_hdr *base;
 
-	base = (struct displayid_hdr *)&displayid[idx];
+	base = (const struct displayid_hdr *)&displayid[idx];
 
 	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
 		      base->rev, base->bytes, base->prod_id, base->ext_count);
@@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
 }
 
 static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
-							    struct displayid_detailed_timings_1 *timings)
+							    const struct displayid_detailed_timings_1 *timings)
 {
 	struct drm_display_mode *mode;
 	unsigned pixel_clock = (timings->pixel_clock[0] |
@@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
 	unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
 	bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
 	bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
+
 	mode = drm_mode_create(dev);
 	if (!mode)
 		return NULL;
@@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
 }
 
 static int add_displayid_detailed_1_modes(struct drm_connector *connector,
-					  struct displayid_block *block)
+					  const struct displayid_block *block)
 {
-	struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
+	const struct displayid_detailed_timing_block *det =
+		(const struct displayid_detailed_timing_block *)block;
 	int i;
 	int num_timings;
 	struct drm_display_mode *newmode;
@@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
 
 	num_timings = block->num_bytes / 20;
 	for (i = 0; i < num_timings; i++) {
-		struct displayid_detailed_timings_1 *timings = &det->timings[i];
+		const struct displayid_detailed_timings_1 *timings = &det->timings[i];
 
 		newmode = drm_mode_displayid_detailed(connector->dev, timings);
 		if (!newmode)
@@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
 }
 
 static int add_displayid_detailed_modes(struct drm_connector *connector,
-					struct edid *edid)
+					const struct edid *edid)
 {
-	u8 *displayid;
+	const u8 *displayid;
 	int ret;
 	int idx = 1;
 	int length = EDID_LENGTH;
-	struct displayid_block *block;
+	const struct displayid_block *block;
 	int num_modes = 0;
 
 	displayid = drm_find_displayid_extension(edid);
@@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
 
 static int drm_parse_tiled_block(struct drm_connector *connector,
-				 struct displayid_block *block)
+				 const struct displayid_block *block)
 {
-	struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
+	const struct displayid_tiled_block *tile =
+		(const struct displayid_tiled_block *)block;
 	u16 w, h;
 	u8 tile_v_loc, tile_h_loc;
 	u8 num_v_tile, num_h_tile;
@@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
 }
 
 static int drm_parse_display_id(struct drm_connector *connector,
-				u8 *displayid, int length,
+				const u8 *displayid, int length,
 				bool is_edid_extension)
 {
 	/* if this is an EDID extension the first byte will be 0x70 */
 	int idx = 0;
-	struct displayid_block *block;
+	const struct displayid_block *block;
 	int ret;
 
 	if (is_edid_extension)
@@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
 }
 
 static void drm_get_displayid(struct drm_connector *connector,
-			      struct edid *edid)
+			      const struct edid *edid)
 {
-	void *displayid = NULL;
+	const void *displayid;
 	int ret;
+
 	connector->has_tile = false;
+
 	displayid = drm_find_displayid_extension(edid);
 	if (!displayid) {
 		/* drop reference to any tile group we had */
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2113500b4075..c0f9ce3f4b24 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1580,9 +1580,9 @@ struct drm_tile_group {
 };
 
 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
-						  char topology[8]);
+						  const u8 topology[8]);
 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
-					       char topology[8]);
+					       const u8 topology[8]);
 void drm_mode_put_tile_group(struct drm_device *dev,
 			     struct drm_tile_group *tg);
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

Let's try to make a lot more stuff const in the edid parser.

The "downside" is that we can no longer mangle the EDID in the
middle of the parsing to apply quirks (drm_mode_detailed()).
I don't really think mangling the blob itself is such a great
idea anyway so I won't miss that part. But if we do want it
back I guess we should do the mangling in one explicit place
before we otherwise parse the EDID.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_connector.c |   4 +-
 drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
 include/drm/drm_connector.h     |   4 +-
 3 files changed, 176 insertions(+), 135 deletions(-)

diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
index f632ca05960e..92a5cd6ff6b1 100644
--- a/drivers/gpu/drm/drm_connector.c
+++ b/drivers/gpu/drm/drm_connector.c
@@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
  * tile group or NULL if not found.
  */
 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
-					       char topology[8])
+					       const u8 topology[8])
 {
 	struct drm_tile_group *tg;
 	int id;
@@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
  * new tile group or NULL.
  */
 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
-						  char topology[8])
+						  const u8 topology[8])
 {
 	struct drm_tile_group *tg;
 	int ret;
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index fd9b724067a7..8e76efe1654d 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -88,7 +88,7 @@
 
 struct detailed_mode_closure {
 	struct drm_connector *connector;
-	struct edid *edid;
+	const struct edid *edid;
 	bool preferred;
 	u32 quirks;
 	int modes;
@@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
 		 "Minimum number of valid EDID header bytes (0-8, default 6)");
 
 static void drm_get_displayid(struct drm_connector *connector,
-			      struct edid *edid);
-static int validate_displayid(u8 *displayid, int length, int idx);
+			      const struct edid *edid);
+static int validate_displayid(const u8 *displayid, int length, int idx);
 
 static int drm_edid_block_checksum(const u8 *raw_edid)
 {
@@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
 	return d[0] != 0x00 || d[1] != 0x00;
 }
 
-typedef void detailed_cb(struct detailed_timing *timing, void *closure);
+typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
 
 static void
-cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
+cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
 	int i, n;
 	u8 d = ext[0x02];
-	u8 *det_base = ext + d;
+	const u8 *det_base = ext + d;
 
 	if (d < 4 || d > 127)
 		return;
 
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
-		cb((struct detailed_timing *)(det_base + 18 * i), closure);
+		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
 }
 
 static void
-vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
+vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
 	unsigned int i, n = min((int)ext[0x02], 6);
-	u8 *det_base = ext + 5;
+	const u8 *det_base = ext + 5;
 
 	if (ext[0x01] != 1)
 		return; /* unknown version */
 
 	for (i = 0; i < n; i++)
-		cb((struct detailed_timing *)(det_base + 18 * i), closure);
+		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
 }
 
 static void
-drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
+drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
 {
+	const struct edid *edid = (struct edid *)raw_edid;
 	int i;
-	struct edid *edid = (struct edid *)raw_edid;
 
 	if (edid == NULL)
 		return;
@@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 		cb(&(edid->detailed_timings[i]), closure);
 
 	for (i = 1; i <= raw_edid[0x7e]; i++) {
-		u8 *ext = raw_edid + (i * EDID_LENGTH);
+		const u8 *ext = raw_edid + (i * EDID_LENGTH);
 		switch (*ext) {
 		case CEA_EXT:
 			cea_for_each_detailed_block(ext, cb, closure);
@@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
 	}
 }
 
+struct bool_closure {
+	bool ret;
+};
+
 static void
-is_rb(struct detailed_timing *t, void *data)
+is_rb(const struct detailed_timing *t, void *c)
 {
-	u8 *r = (u8 *)t;
+	struct bool_closure *closure = c;
+	const u8 *r = (const u8 *)t;
 
 	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	if (r[15] & 0x10)
-		*(bool *)data = true;
+		closure->ret = true;
 }
 
 /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
 static bool
-drm_monitor_supports_rb(struct edid *edid)
+drm_monitor_supports_rb(const struct edid *edid)
 {
 	if (edid->revision >= 4) {
-		bool ret = false;
-		drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
-		return ret;
+		struct bool_closure closure = {
+			.ret = false,
+		};
+
+		drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
+
+		return closure.ret;
 	}
 
 	return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
 }
 
+struct data_closure {
+	const u8 *data;
+};
+
 static void
-find_gtf2(struct detailed_timing *t, void *data)
+do_find_gtf2(const struct detailed_timing *t, void *c)
 {
-	u8 *r = (u8 *)t;
+	struct data_closure *closure = c;
+	const u8 *r = (const u8 *)t;
 
 	if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
 		return;
 
 	if (r[10] == 0x02)
-		*(u8 **)data = r;
+		closure->data = r;
+}
+
+static const u8 *
+find_gtf2_descriptor(const struct edid *edid)
+{
+	struct data_closure closure = {};
+
+	drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
+
+	return closure.data;
 }
 
 /* Secondary GTF curve kicks in above some break frequency */
 static int
-drm_gtf2_hbreak(struct edid *edid)
+drm_gtf2_hbreak(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
-	return r ? (r[12] * 2) : 0;
+	const u8 *r = find_gtf2_descriptor(edid);
+
+	return r ? r[12] * 2 : 0;
 }
 
 static int
-drm_gtf2_2c(struct edid *edid)
+drm_gtf2_2c(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[13] : 0;
 }
 
 static int
-drm_gtf2_m(struct edid *edid)
+drm_gtf2_m(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
-	return r ? (r[15] << 8) + r[14] : 0;
+	const u8 *r = find_gtf2_descriptor(edid);
+
+	return r ? (r[15] << 8) | r[14] : 0;
 }
 
 static int
-drm_gtf2_k(struct edid *edid)
+drm_gtf2_k(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[16] : 0;
 }
 
 static int
-drm_gtf2_2j(struct edid *edid)
+drm_gtf2_2j(const struct edid *edid)
 {
-	u8 *r = NULL;
-	drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
+	const u8 *r = find_gtf2_descriptor(edid);
+
 	return r ? r[17] : 0;
 }
 
@@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
  * standard_timing_level - get std. timing level(CVT/GTF/DMT)
  * @edid: EDID block to scan
  */
-static int standard_timing_level(struct edid *edid)
+static int standard_timing_level(const struct edid *edid)
 {
 	if (edid->revision >= 2) {
 		if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
@@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
  * and convert them into a real mode using CVT/GTF/DMT.
  */
 static struct drm_display_mode *
-drm_mode_std(struct drm_connector *connector, struct edid *edid,
-	     struct std_timing *t)
+drm_mode_std(struct drm_connector *connector,
+	     const struct edid *edid,
+	     const struct std_timing *t)
 {
 	struct drm_device *dev = connector->dev;
 	struct drm_display_mode *m, *mode = NULL;
@@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
  */
 static void
 drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
-			    struct detailed_pixel_timing *pt)
+			    const struct detailed_pixel_timing *pt)
 {
 	int i;
 	static const struct {
@@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
  * return a new struct drm_display_mode.
  */
 static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
-						  struct edid *edid,
-						  struct detailed_timing *timing,
+						  const struct edid *edid,
+						  const struct detailed_timing *timing,
 						  u32 quirks)
 {
 	struct drm_display_mode *mode;
-	struct detailed_pixel_timing *pt = &timing->data.pixel_data;
+	const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
 	unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
 	unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
 	unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
@@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 		return NULL;
 
 	if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
-		timing->pixel_clock = cpu_to_le16(1088);
-
-	mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
+		mode->clock = 1088 * 10;
+	else
+		mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
 
 	mode->hdisplay = hactive;
 	mode->hsync_start = mode->hdisplay + hsync_offset;
@@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 	drm_mode_do_interlace_quirk(mode, pt);
 
 	if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
-		pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
+		mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
+	} else {
+		mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
+		mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
+			DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
 	}
 
-	mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
-	mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
-		DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
-
 set_size:
 	mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
 	mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
@@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
 
 static bool
 mode_in_hsync_range(const struct drm_display_mode *mode,
-		    struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int hsync, hmin, hmax;
 
@@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
 
 static bool
 mode_in_vsync_range(const struct drm_display_mode *mode,
-		    struct edid *edid, u8 *t)
+		    const struct edid *edid, const u8 *t)
 {
 	int vsync, vmin, vmax;
 
@@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
 }
 
 static u32
-range_pixel_clock(struct edid *edid, u8 *t)
+range_pixel_clock(const struct edid *edid, const u8 *t)
 {
 	/* unspecified */
 	if (t[9] == 0 || t[9] == 255)
@@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
 }
 
 static bool
-mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
-	      struct detailed_timing *timing)
+mode_in_range(const struct drm_display_mode *mode,
+	      const struct edid *edid,
+	      const struct detailed_timing *timing)
 {
 	u32 max_clock;
-	u8 *t = (u8 *)timing;
+	const u8 *t = (const u8 *)timing;
 
 	if (!mode_in_hsync_range(mode, edid, t))
 		return false;
@@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
 }
 
 static int
-drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_dmt_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
 }
 
 static int
-drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_gtf_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
 }
 
 static int
-drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
-			struct detailed_timing *timing)
+drm_cvt_modes_for_range(struct drm_connector *connector,
+			const struct edid *edid,
+			const struct detailed_timing *timing)
 {
 	int i, modes = 0;
 	struct drm_display_mode *newmode;
@@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
 }
 
 static void
-do_inferred_modes(struct detailed_timing *timing, void *c)
+do_inferred_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
-	struct detailed_data_monitor_range *range = &data->data.range;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_data_monitor_range *range = &data->data.range;
 
 	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
 		return;
@@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
 }
 
 static int
-add_inferred_modes(struct drm_connector *connector, struct edid *edid)
+add_inferred_modes(struct drm_connector *connector,
+		   const struct edid *edid)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
 	};
 
 	if (version_greater(edid, 1, 0))
-		drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
+		drm_for_each_detailed_block((const u8 *)edid,
+					    do_inferred_modes,
 					    &closure);
 
 	return closure.modes;
 }
 
 static int
-drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
+drm_est3_modes(struct drm_connector *connector,
+	       const struct detailed_timing *timing)
 {
 	int i, j, m, modes = 0;
 	struct drm_display_mode *mode;
-	u8 *est = ((u8 *)timing) + 6;
+	const u8 *est = ((const u8 *)timing) + 6;
 
 	for (i = 0; i < 6; i++) {
 		for (j = 7; j >= 0; j--) {
@@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
 }
 
 static void
-do_established_modes(struct detailed_timing *timing, void *c)
+do_established_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 
@@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
  * (defined above).  Tease them out and add them to the global modes list.
  */
 static int
-add_established_modes(struct drm_connector *connector, struct edid *edid)
+add_established_modes(struct drm_connector *connector,
+		      const struct edid *edid)
 {
 	struct drm_device *dev = connector->dev;
 	unsigned long est_bits = edid->established_timings.t1 |
@@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
 }
 
 static void
-do_standard_modes(struct detailed_timing *timing, void *c)
+do_standard_modes(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
-	struct detailed_non_pixel *data = &timing->data.other_data;
+	const struct detailed_non_pixel *data = &timing->data.other_data;
 	struct drm_connector *connector = closure->connector;
-	struct edid *edid = closure->edid;
+	const struct edid *edid = closure->edid;
 	int i;
 
 	if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
 		return;
 
 	for (i = 0; i < 6; i++) {
-		struct std_timing *std = &data->data.timings[i];
+		const struct std_timing *std = &data->data.timings[i];
 		struct drm_display_mode *newmode;
 
 		newmode = drm_mode_std(connector, edid, std);
@@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
  * GTF or CVT. Grab them from @edid and add them to the list.
  */
 static int
-add_standard_modes(struct drm_connector *connector, struct edid *edid)
+add_standard_modes(struct drm_connector *connector,
+		   const struct edid *edid)
 {
 	int i, modes = 0;
 	struct detailed_mode_closure closure = {
@@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
 }
 
 static int drm_cvt_modes(struct drm_connector *connector,
-			 struct detailed_timing *timing)
+			 const struct detailed_timing *timing)
 {
 	int i, j, modes = 0;
 	struct drm_display_mode *newmode;
 	struct drm_device *dev = connector->dev;
-	struct cvt_timing *cvt;
 	const int rates[] = { 60, 85, 75, 60, 50 };
 	const u8 empty[3] = { 0, 0, 0 };
 
 	for (i = 0; i < 4; i++) {
 		int uninitialized_var(width), height;
-		cvt = &(timing->data.other_data.data.cvt[i]);
+		const struct cvt_timing *cvt =
+			&timing->data.other_data.data.cvt[i];
 
 		if (!memcmp(cvt->code, empty, 3))
 			continue;
@@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
 }
 
 static void
-do_cvt_mode(struct detailed_timing *timing, void *c)
+do_cvt_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 
@@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
 }
 
 static int
-add_cvt_modes(struct drm_connector *connector, struct edid *edid)
+add_cvt_modes(struct drm_connector *connector,
+	      const struct edid *edid)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
 static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
 
 static void
-do_detailed_mode(struct detailed_timing *timing, void *c)
+do_detailed_mode(const struct detailed_timing *timing, void *c)
 {
 	struct detailed_mode_closure *closure = c;
 	struct drm_display_mode *newmode;
@@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
  * @quirks: quirks to apply
  */
 static int
-add_detailed_modes(struct drm_connector *connector, struct edid *edid,
-		   u32 quirks)
+add_detailed_modes(struct drm_connector *connector,
+		   struct edid *edid, u32 quirks)
 {
 	struct detailed_mode_closure closure = {
 		.connector = connector,
@@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
 /*
  * Search EDID for CEA extension block.
  */
-static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
+static const u8 *drm_find_edid_extension(const struct edid *edid,
+					 int ext_id)
 {
-	u8 *edid_ext = NULL;
+	const u8 *edid_ext = NULL;
 	int i;
 
 	/* No EDID or EDID extensions */
@@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
 
 	/* Find CEA extension */
 	for (i = 0; i < edid->extensions; i++) {
-		edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
+		edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
 		if (edid_ext[0] == ext_id)
 			break;
 	}
@@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
 }
 
 
-static u8 *drm_find_displayid_extension(const struct edid *edid)
+static const u8 *drm_find_displayid_extension(const struct edid *edid)
 {
 	return drm_find_edid_extension(edid, DISPLAYID_EXT);
 }
 
-static u8 *drm_find_cea_extension(const struct edid *edid)
+static const u8 *drm_find_cea_extension(const struct edid *edid)
 {
 	int ret;
 	int idx = 1;
 	int length = EDID_LENGTH;
-	struct displayid_block *block;
-	u8 *cea;
-	u8 *displayid;
+	const struct displayid_block *block;
+	const u8 *cea;
+	const u8 *displayid;
 
 	/* Look for a top level CEA extension block */
 	cea = drm_find_edid_extension(edid, CEA_EXT);
@@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
 }
 
 static void
-monitor_name(struct detailed_timing *t, void *data)
+monitor_name(const struct detailed_timing *t, void *c)
 {
+	struct data_closure *closure = c;
+
 	if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
 		return;
 
-	*(u8 **)data = t->data.other_data.data.str.str;
+	closure->data = t->data.other_data.data.str.str;
 }
 
 static int get_monitor_name(struct edid *edid, char name[13])
 {
-	char *edid_name = NULL;
+	struct data_closure closure = {};
 	int mnl;
 
 	if (!edid || !name)
 		return 0;
 
-	drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
-	for (mnl = 0; edid_name && mnl < 13; mnl++) {
-		if (edid_name[mnl] == 0x0a)
+	drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
+	for (mnl = 0; closure.data && mnl < 13; mnl++) {
+		if (closure.data[mnl] == 0x0a)
 			break;
 
-		name[mnl] = edid_name[mnl];
+		name[mnl] = closure.data[mnl];
 	}
 
 	return mnl;
@@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
 static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 {
 	uint8_t *eld = connector->eld;
-	u8 *cea;
-	u8 *db;
+	const u8 *cea;
 	int total_sad_count = 0;
 	int mnl;
-	int dbl;
 
 	clear_eld(connector);
 
@@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
 		}
 
 		for_each_cea_db(cea, i, start, end) {
-			db = &cea[i];
-			dbl = cea_db_payload_len(db);
+			const u8 *db = &cea[i];
+			int dbl = cea_db_payload_len(db);
 
 			switch (cea_db_tag(db)) {
 				int sad_count;
@@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 {
 	int count = 0;
 	int i, start, end, dbl;
-	u8 *cea;
+	const u8 *cea;
 
 	cea = drm_find_cea_extension(edid);
 	if (!cea) {
@@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 	}
 
 	for_each_cea_db(cea, i, start, end) {
-		u8 *db = &cea[i];
+		const u8 *db = &cea[i];
 
 		if (cea_db_tag(db) == AUDIO_BLOCK) {
 			int j;
@@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
 			if (!*sads)
 				return -ENOMEM;
 			for (j = 0; j < count; j++) {
-				u8 *sad = &db[1 + j * 3];
+				const u8 *sad = &db[1 + j * 3];
 
 				(*sads)[j].format = (sad[0] & 0x78) >> 3;
 				(*sads)[j].channels = sad[0] & 0x7;
@@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
  */
 bool drm_detect_hdmi_monitor(struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i;
 	int start_offset, end_offset;
 
@@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
  */
 bool drm_detect_monitor_audio(struct edid *edid)
 {
-	u8 *edid_ext;
+	const u8 *edid_ext;
 	int i, j;
 	bool has_audio = false;
 	int start_offset, end_offset;
@@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 	return quirks;
 }
 
-static int validate_displayid(u8 *displayid, int length, int idx)
+static int validate_displayid(const u8 *displayid, int length, int idx)
 {
 	int i;
 	u8 csum = 0;
-	struct displayid_hdr *base;
+	const struct displayid_hdr *base;
 
-	base = (struct displayid_hdr *)&displayid[idx];
+	base = (const struct displayid_hdr *)&displayid[idx];
 
 	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
 		      base->rev, base->bytes, base->prod_id, base->ext_count);
@@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
 }
 
 static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
-							    struct displayid_detailed_timings_1 *timings)
+							    const struct displayid_detailed_timings_1 *timings)
 {
 	struct drm_display_mode *mode;
 	unsigned pixel_clock = (timings->pixel_clock[0] |
@@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
 	unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
 	bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
 	bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
+
 	mode = drm_mode_create(dev);
 	if (!mode)
 		return NULL;
@@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
 }
 
 static int add_displayid_detailed_1_modes(struct drm_connector *connector,
-					  struct displayid_block *block)
+					  const struct displayid_block *block)
 {
-	struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
+	const struct displayid_detailed_timing_block *det =
+		(const struct displayid_detailed_timing_block *)block;
 	int i;
 	int num_timings;
 	struct drm_display_mode *newmode;
@@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
 
 	num_timings = block->num_bytes / 20;
 	for (i = 0; i < num_timings; i++) {
-		struct displayid_detailed_timings_1 *timings = &det->timings[i];
+		const struct displayid_detailed_timings_1 *timings = &det->timings[i];
 
 		newmode = drm_mode_displayid_detailed(connector->dev, timings);
 		if (!newmode)
@@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
 }
 
 static int add_displayid_detailed_modes(struct drm_connector *connector,
-					struct edid *edid)
+					const struct edid *edid)
 {
-	u8 *displayid;
+	const u8 *displayid;
 	int ret;
 	int idx = 1;
 	int length = EDID_LENGTH;
-	struct displayid_block *block;
+	const struct displayid_block *block;
 	int num_modes = 0;
 
 	displayid = drm_find_displayid_extension(edid);
@@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
 EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
 
 static int drm_parse_tiled_block(struct drm_connector *connector,
-				 struct displayid_block *block)
+				 const struct displayid_block *block)
 {
-	struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
+	const struct displayid_tiled_block *tile =
+		(const struct displayid_tiled_block *)block;
 	u16 w, h;
 	u8 tile_v_loc, tile_h_loc;
 	u8 num_v_tile, num_h_tile;
@@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
 }
 
 static int drm_parse_display_id(struct drm_connector *connector,
-				u8 *displayid, int length,
+				const u8 *displayid, int length,
 				bool is_edid_extension)
 {
 	/* if this is an EDID extension the first byte will be 0x70 */
 	int idx = 0;
-	struct displayid_block *block;
+	const struct displayid_block *block;
 	int ret;
 
 	if (is_edid_extension)
@@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
 }
 
 static void drm_get_displayid(struct drm_connector *connector,
-			      struct edid *edid)
+			      const struct edid *edid)
 {
-	void *displayid = NULL;
+	const void *displayid;
 	int ret;
+
 	connector->has_tile = false;
+
 	displayid = drm_find_displayid_extension(edid);
 	if (!displayid) {
 		/* drop reference to any tile group we had */
diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
index 2113500b4075..c0f9ce3f4b24 100644
--- a/include/drm/drm_connector.h
+++ b/include/drm/drm_connector.h
@@ -1580,9 +1580,9 @@ struct drm_tile_group {
 };
 
 struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
-						  char topology[8]);
+						  const u8 topology[8]);
 struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
-					       char topology[8]);
+					       const u8 topology[8]);
 void drm_mode_put_tile_group(struct drm_device *dev,
 			     struct drm_tile_group *tg);
 
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-24 20:02   ` Ville Syrjala
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

I'm curious if there are any bogus 18 byte descriptors around.
Let's dump them out if we encounter them.

Not sure we'd actually want this, but at least I get to see
if our CI has anything that hits this :)

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

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 8e76efe1654d..4d8303e56536 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
 		d[2] == 0x00 && d[3] == tag;
 }
 
+static bool is_any_display_descriptor(const u8 d[18])
+{
+	return d[0] == 0x00 && d[1] == 0x00 &&
+		d[2] == 0x00;
+}
+
 static bool is_detailed_timing_descriptor(const u8 d[18])
 {
 	return d[0] != 0x00 || d[1] != 0x00;
@@ -2209,6 +2215,15 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
 
 typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
 
+static void do_detailed_block(const u8 d[18], detailed_cb *cb, void *closure)
+{
+	if (!is_detailed_timing_descriptor(d) &&
+	    !is_any_display_descriptor(d))
+		DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n", 18, d);
+
+	cb((const struct detailed_timing *)d, closure);
+}
+
 static void
 cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
@@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
-		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
+		do_detailed_block(det_base + 18 * i, cb, closure);
 }
 
 static void
@@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 		return; /* unknown version */
 
 	for (i = 0; i < n; i++)
-		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
+		do_detailed_block(det_base + 18 * i, cb, closure);
 }
 
 static void
@@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
 		return;
 
 	for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
-		cb(&(edid->detailed_timings[i]), closure);
+		do_detailed_block((const u8 *)&edid->detailed_timings[i],
+				  cb, closure);
 
 	for (i = 1; i <= raw_edid[0x7e]; i++) {
 		const u8 *ext = raw_edid + (i * EDID_LENGTH);
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
@ 2020-01-24 20:02   ` Ville Syrjala
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjala @ 2020-01-24 20:02 UTC (permalink / raw)
  To: dri-devel; +Cc: intel-gfx

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

I'm curious if there are any bogus 18 byte descriptors around.
Let's dump them out if we encounter them.

Not sure we'd actually want this, but at least I get to see
if our CI has anything that hits this :)

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

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 8e76efe1654d..4d8303e56536 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
 		d[2] == 0x00 && d[3] == tag;
 }
 
+static bool is_any_display_descriptor(const u8 d[18])
+{
+	return d[0] == 0x00 && d[1] == 0x00 &&
+		d[2] == 0x00;
+}
+
 static bool is_detailed_timing_descriptor(const u8 d[18])
 {
 	return d[0] != 0x00 || d[1] != 0x00;
@@ -2209,6 +2215,15 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
 
 typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
 
+static void do_detailed_block(const u8 d[18], detailed_cb *cb, void *closure)
+{
+	if (!is_detailed_timing_descriptor(d) &&
+	    !is_any_display_descriptor(d))
+		DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n", 18, d);
+
+	cb((const struct detailed_timing *)d, closure);
+}
+
 static void
 cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 {
@@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 
 	n = (127 - d) / 18;
 	for (i = 0; i < n; i++)
-		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
+		do_detailed_block(det_base + 18 * i, cb, closure);
 }
 
 static void
@@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
 		return; /* unknown version */
 
 	for (i = 0; i < n; i++)
-		cb((const struct detailed_timing *)(det_base + 18 * i), closure);
+		do_detailed_block(det_base + 18 * i, cb, closure);
 }
 
 static void
@@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
 		return;
 
 	for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
-		cb(&(edid->detailed_timings[i]), closure);
+		do_detailed_block((const u8 *)&edid->detailed_timings[i],
+				  cb, closure);
 
 	for (i = 1; i <= raw_edid[0x7e]; i++) {
 		const u8 *ext = raw_edid + (i * EDID_LENGTH);
-- 
2.24.1

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

^ permalink raw reply related	[flat|nested] 67+ messages in thread

* [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
                   ` (7 preceding siblings ...)
  (?)
@ 2020-01-24 22:53 ` Patchwork
  -1 siblings, 0 replies; 67+ messages in thread
From: Patchwork @ 2020-01-24 22:53 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
URL   : https://patchwork.freedesktop.org/series/72550/
State : warning

== Summary ==

$ dim checkpatch origin/drm-tip
3a501fdd02f1 drm/edid: Check the number of detailed timing descriptors in the CEA ext block
0e3a8bb18994 drm/edid: Don't accept any old garbage as a display descriptor
4a7295a41e0f drm/edid: Introduce is_detailed_timing_descritor()
a60ef24fcf54 drm/i915: Clear out spurious whitespace
9618198833a0 drm/edid: Document why we don't bounds check the DispID CEA block start/end
cf141fb33648 drm/edid: Add a FIXME about DispID CEA data block revision
e49f5a0e43ea drm/edid: Constify lots of things
-:757: WARNING:LONG_LINE: line over 100 characters
#757: FILE: drivers/gpu/drm/drm_edid.c:5080:
+							    const struct displayid_detailed_timings_1 *timings)

total: 0 errors, 1 warnings, 0 checks, 783 lines checked
120d72ced4d7 drm/edid: Dump bogus 18 byte descriptors

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* [Intel-gfx] ✓ Fi.CI.BAT: success for series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
                   ` (8 preceding siblings ...)
  (?)
@ 2020-01-24 23:13 ` Patchwork
  -1 siblings, 0 replies; 67+ messages in thread
From: Patchwork @ 2020-01-24 23:13 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
URL   : https://patchwork.freedesktop.org/series/72550/
State : success

== Summary ==

CI Bug Log - changes from CI_DRM_7811 -> Patchwork_16262
====================================================

Summary
-------

  **SUCCESS**

  No regressions found.

  External URL: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/index.html

Known issues
------------

  Here are the changes found in Patchwork_16262 that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_exec_suspend@basic-s0:
    - fi-cml-s:           [PASS][1] -> [FAIL][2] ([fdo#103375])
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-cml-s/igt@gem_exec_suspend@basic-s0.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-cml-s/igt@gem_exec_suspend@basic-s0.html

  * igt@i915_selftest@live_blt:
    - fi-hsw-4770r:       [PASS][3] -> [DMESG-FAIL][4] ([i915#725])
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-hsw-4770r/igt@i915_selftest@live_blt.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-hsw-4770r/igt@i915_selftest@live_blt.html

  * igt@kms_chamelium@hdmi-hpd-fast:
    - fi-icl-u2:          [PASS][5] -> [FAIL][6] ([i915#217])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-icl-u2/igt@kms_chamelium@hdmi-hpd-fast.html

  
#### Possible fixes ####

  * igt@gem_exec_parallel@fds:
    - fi-hsw-peppy:       [INCOMPLETE][7] ([i915#694]) -> [PASS][8]
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-hsw-peppy/igt@gem_exec_parallel@fds.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-hsw-peppy/igt@gem_exec_parallel@fds.html

  * igt@gem_exec_suspend@basic-s3:
    - fi-cml-s:           [INCOMPLETE][9] ([i915#283]) -> [PASS][10]
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-cml-s/igt@gem_exec_suspend@basic-s3.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-cml-s/igt@gem_exec_suspend@basic-s3.html

  * igt@i915_module_load@reload-with-fault-injection:
    - fi-cfl-8700k:       [DMESG-WARN][11] ([i915#889]) -> [PASS][12]
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-cfl-8700k/igt@i915_module_load@reload-with-fault-injection.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-cfl-8700k/igt@i915_module_load@reload-with-fault-injection.html

  * igt@i915_selftest@live_blt:
    - fi-hsw-4770:        [DMESG-FAIL][13] ([i915#725]) -> [PASS][14]
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-hsw-4770/igt@i915_selftest@live_blt.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-hsw-4770/igt@i915_selftest@live_blt.html

  * igt@i915_selftest@live_gtt:
    - fi-bdw-5557u:       [TIMEOUT][15] ([fdo#112271]) -> [PASS][16]
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-bdw-5557u/igt@i915_selftest@live_gtt.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-bdw-5557u/igt@i915_selftest@live_gtt.html

  
#### Warnings ####

  * igt@kms_chamelium@common-hpd-after-suspend:
    - fi-icl-u2:          [FAIL][17] ([i915#217]) -> [DMESG-WARN][18] ([IGT#4] / [i915#263])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/fi-icl-u2/igt@kms_chamelium@common-hpd-after-suspend.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/fi-icl-u2/igt@kms_chamelium@common-hpd-after-suspend.html

  
  [IGT#4]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/4
  [fdo#103375]: https://bugs.freedesktop.org/show_bug.cgi?id=103375
  [fdo#112271]: https://bugs.freedesktop.org/show_bug.cgi?id=112271
  [i915#217]: https://gitlab.freedesktop.org/drm/intel/issues/217
  [i915#263]: https://gitlab.freedesktop.org/drm/intel/issues/263
  [i915#283]: https://gitlab.freedesktop.org/drm/intel/issues/283
  [i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694
  [i915#725]: https://gitlab.freedesktop.org/drm/intel/issues/725
  [i915#889]: https://gitlab.freedesktop.org/drm/intel/issues/889


Participating hosts (47 -> 42)
------------------------------

  Additional (2): fi-bsw-kefka fi-skl-6600u 
  Missing    (7): fi-hsw-4200u fi-bsw-cyan fi-ilk-650 fi-ctg-p8600 fi-byt-clapper fi-bsw-nick fi-bdw-samus 


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_7811 -> Patchwork_16262

  CI-20190529: 20190529
  CI_DRM_7811: f528982f5c837f075e82ca544df010ca5183064a @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5384: fd6896567f7d612c76207970376d4f1e634ded55 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_16262: 120d72ced4d75ab3be121475f9e90d762ec99d12 @ git://anongit.freedesktop.org/gfx-ci/linux


== Linux commits ==

120d72ced4d7 drm/edid: Dump bogus 18 byte descriptors
e49f5a0e43ea drm/edid: Constify lots of things
cf141fb33648 drm/edid: Add a FIXME about DispID CEA data block revision
9618198833a0 drm/edid: Document why we don't bounds check the DispID CEA block start/end
a60ef24fcf54 drm/i915: Clear out spurious whitespace
4a7295a41e0f drm/edid: Introduce is_detailed_timing_descritor()
0e3a8bb18994 drm/edid: Don't accept any old garbage as a display descriptor
3a501fdd02f1 drm/edid: Check the number of detailed timing descriptors in the CEA ext block

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* [Intel-gfx] ✗ Fi.CI.IGT: failure for series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
                   ` (9 preceding siblings ...)
  (?)
@ 2020-01-27 13:49 ` Patchwork
  -1 siblings, 0 replies; 67+ messages in thread
From: Patchwork @ 2020-01-27 13:49 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx

== Series Details ==

Series: series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
URL   : https://patchwork.freedesktop.org/series/72550/
State : failure

== Summary ==

CI Bug Log - changes from CI_DRM_7811_full -> Patchwork_16262_full
====================================================

Summary
-------

  **FAILURE**

  Serious unknown changes coming with Patchwork_16262_full absolutely need to be
  verified manually.
  
  If you think the reported changes have nothing to do with the changes
  introduced in Patchwork_16262_full, please notify your bug team to allow them
  to document this new failure mode, which will reduce false positives in CI.

  

Possible new issues
-------------------

  Here are the unknown changes that may have been introduced in Patchwork_16262_full:

### IGT changes ###

#### Possible regressions ####

  * igt@gem_partial_pwrite_pread@reads:
    - shard-hsw:          [PASS][1] -> [FAIL][2]
   [1]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-hsw7/igt@gem_partial_pwrite_pread@reads.html
   [2]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-hsw1/igt@gem_partial_pwrite_pread@reads.html

  
Known issues
------------

  Here are the changes found in Patchwork_16262_full that come from known issues:

### IGT changes ###

#### Issues hit ####

  * igt@gem_ctx_isolation@vcs1-none:
    - shard-iclb:         [PASS][3] -> [SKIP][4] ([fdo#109276] / [fdo#112080]) +4 similar issues
   [3]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@gem_ctx_isolation@vcs1-none.html
   [4]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb6/igt@gem_ctx_isolation@vcs1-none.html

  * igt@gem_ctx_shared@exec-single-timeline-bsd:
    - shard-iclb:         [PASS][5] -> [SKIP][6] ([fdo#110841])
   [5]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb5/igt@gem_ctx_shared@exec-single-timeline-bsd.html
   [6]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@gem_ctx_shared@exec-single-timeline-bsd.html

  * igt@gem_exec_schedule@in-order-bsd:
    - shard-iclb:         [PASS][7] -> [SKIP][8] ([fdo#112146]) +3 similar issues
   [7]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb6/igt@gem_exec_schedule@in-order-bsd.html
   [8]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@gem_exec_schedule@in-order-bsd.html

  * igt@gem_exec_schedule@pi-distinct-iova-bsd:
    - shard-iclb:         [PASS][9] -> [SKIP][10] ([i915#677])
   [9]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb8/igt@gem_exec_schedule@pi-distinct-iova-bsd.html
   [10]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@gem_exec_schedule@pi-distinct-iova-bsd.html

  * igt@gem_exec_store@cachelines-vcs1:
    - shard-iclb:         [PASS][11] -> [SKIP][12] ([fdo#112080]) +7 similar issues
   [11]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@gem_exec_store@cachelines-vcs1.html
   [12]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb7/igt@gem_exec_store@cachelines-vcs1.html

  * igt@gem_wait@write-busy-vcs0:
    - shard-skl:          [PASS][13] -> [DMESG-WARN][14] ([i915#109]) +2 similar issues
   [13]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl4/igt@gem_wait@write-busy-vcs0.html
   [14]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl6/igt@gem_wait@write-busy-vcs0.html

  * igt@i915_pm_dc@dc5-dpms:
    - shard-skl:          [PASS][15] -> [INCOMPLETE][16] ([i915#198])
   [15]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl2/igt@i915_pm_dc@dc5-dpms.html
   [16]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl1/igt@i915_pm_dc@dc5-dpms.html

  * igt@i915_pm_rps@waitboost:
    - shard-iclb:         [PASS][17] -> [FAIL][18] ([i915#413])
   [17]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb7/igt@i915_pm_rps@waitboost.html
   [18]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb1/igt@i915_pm_rps@waitboost.html

  * igt@kms_flip@2x-flip-vs-absolute-wf_vblank-interruptible:
    - shard-glk:          [PASS][19] -> [FAIL][20] ([i915#34])
   [19]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-glk2/igt@kms_flip@2x-flip-vs-absolute-wf_vblank-interruptible.html
   [20]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-glk2/igt@kms_flip@2x-flip-vs-absolute-wf_vblank-interruptible.html

  * igt@kms_flip@flip-vs-expired-vblank:
    - shard-skl:          [PASS][21] -> [FAIL][22] ([i915#79])
   [21]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl9/igt@kms_flip@flip-vs-expired-vblank.html
   [22]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl2/igt@kms_flip@flip-vs-expired-vblank.html

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes:
    - shard-kbl:          [PASS][23] -> [DMESG-WARN][24] ([i915#180]) +3 similar issues
   [23]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-kbl4/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html
   [24]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-kbl4/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html

  * igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min:
    - shard-skl:          [PASS][25] -> [FAIL][26] ([fdo#108145])
   [25]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl7/igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min.html
   [26]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl3/igt@kms_plane_alpha_blend@pipe-c-constant-alpha-min.html

  * igt@kms_psr@psr2_primary_mmap_cpu:
    - shard-iclb:         [PASS][27] -> [SKIP][28] ([fdo#109441]) +3 similar issues
   [27]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@kms_psr@psr2_primary_mmap_cpu.html
   [28]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb3/igt@kms_psr@psr2_primary_mmap_cpu.html

  * igt@kms_setmode@basic:
    - shard-apl:          [PASS][29] -> [FAIL][30] ([i915#31])
   [29]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-apl3/igt@kms_setmode@basic.html
   [30]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-apl7/igt@kms_setmode@basic.html
    - shard-kbl:          [PASS][31] -> [FAIL][32] ([i915#31])
   [31]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-kbl2/igt@kms_setmode@basic.html
   [32]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-kbl6/igt@kms_setmode@basic.html

  * igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend:
    - shard-kbl:          [PASS][33] -> [INCOMPLETE][34] ([fdo#103665])
   [33]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-kbl7/igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend.html
   [34]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-kbl6/igt@kms_vblank@pipe-c-ts-continuation-dpms-suspend.html

  * igt@prime_busy@hang-bsd2:
    - shard-iclb:         [PASS][35] -> [SKIP][36] ([fdo#109276]) +15 similar issues
   [35]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@prime_busy@hang-bsd2.html
   [36]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb3/igt@prime_busy@hang-bsd2.html

  * igt@prime_mmap_coherency@ioctl-errors:
    - shard-hsw:          [PASS][37] -> [FAIL][38] ([i915#831])
   [37]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-hsw2/igt@prime_mmap_coherency@ioctl-errors.html
   [38]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-hsw7/igt@prime_mmap_coherency@ioctl-errors.html

  
#### Possible fixes ####

  * igt@gem_busy@busy-vcs1:
    - shard-iclb:         [SKIP][39] ([fdo#112080]) -> [PASS][40] +10 similar issues
   [39]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb8/igt@gem_busy@busy-vcs1.html
   [40]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@gem_busy@busy-vcs1.html

  * igt@gem_exec_async@concurrent-writes-bsd:
    - shard-iclb:         [SKIP][41] ([fdo#112146]) -> [PASS][42] +6 similar issues
   [41]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@gem_exec_async@concurrent-writes-bsd.html
   [42]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb6/igt@gem_exec_async@concurrent-writes-bsd.html

  * igt@gem_exec_schedule@pi-shared-iova-bsd:
    - shard-iclb:         [SKIP][43] ([i915#677]) -> [PASS][44]
   [43]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb2/igt@gem_exec_schedule@pi-shared-iova-bsd.html
   [44]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb6/igt@gem_exec_schedule@pi-shared-iova-bsd.html

  * igt@gem_ppgtt@flink-and-close-vma-leak:
    - shard-skl:          [FAIL][45] ([i915#644]) -> [PASS][46]
   [45]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl8/igt@gem_ppgtt@flink-and-close-vma-leak.html
   [46]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl7/igt@gem_ppgtt@flink-and-close-vma-leak.html

  * igt@i915_pm_dc@dc6-psr:
    - shard-iclb:         [FAIL][47] ([i915#454]) -> [PASS][48]
   [47]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb4/igt@i915_pm_dc@dc6-psr.html
   [48]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb1/igt@i915_pm_dc@dc6-psr.html

  * igt@kms_color@pipe-a-ctm-negative:
    - shard-skl:          [DMESG-WARN][49] ([i915#109]) -> [PASS][50] +1 similar issue
   [49]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl4/igt@kms_color@pipe-a-ctm-negative.html
   [50]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl6/igt@kms_color@pipe-a-ctm-negative.html

  * igt@kms_cursor_crc@pipe-c-cursor-suspend:
    - shard-apl:          [DMESG-WARN][51] ([i915#180]) -> [PASS][52] +2 similar issues
   [51]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-apl4/igt@kms_cursor_crc@pipe-c-cursor-suspend.html
   [52]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-apl1/igt@kms_cursor_crc@pipe-c-cursor-suspend.html

  * igt@kms_flip@flip-vs-suspend-interruptible:
    - shard-hsw:          [INCOMPLETE][53] ([i915#61]) -> [PASS][54] +1 similar issue
   [53]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-hsw7/igt@kms_flip@flip-vs-suspend-interruptible.html
   [54]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-hsw6/igt@kms_flip@flip-vs-suspend-interruptible.html

  * igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-render:
    - shard-skl:          [FAIL][55] ([i915#49]) -> [PASS][56]
   [55]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl10/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-render.html
   [56]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl2/igt@kms_frontbuffer_tracking@psr-1p-offscren-pri-shrfb-draw-render.html

  * igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes:
    - shard-skl:          [INCOMPLETE][57] ([i915#69]) -> [PASS][58]
   [57]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl8/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html
   [58]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl9/igt@kms_plane@plane-panning-bottom-right-suspend-pipe-a-planes.html

  * igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min:
    - shard-skl:          [FAIL][59] ([fdo#108145]) -> [PASS][60]
   [59]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl10/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html
   [60]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl2/igt@kms_plane_alpha_blend@pipe-a-constant-alpha-min.html

  * igt@kms_prime@basic-crc:
    - shard-skl:          [FAIL][61] ([i915#1031]) -> [PASS][62]
   [61]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-skl10/igt@kms_prime@basic-crc.html
   [62]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-skl2/igt@kms_prime@basic-crc.html

  * igt@kms_psr@no_drrs:
    - shard-iclb:         [FAIL][63] ([i915#173]) -> [PASS][64]
   [63]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb1/igt@kms_psr@no_drrs.html
   [64]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb6/igt@kms_psr@no_drrs.html

  * igt@kms_psr@psr2_cursor_mmap_cpu:
    - shard-iclb:         [SKIP][65] ([fdo#109441]) -> [PASS][66] +1 similar issue
   [65]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb8/igt@kms_psr@psr2_cursor_mmap_cpu.html
   [66]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@kms_psr@psr2_cursor_mmap_cpu.html

  * igt@prime_vgem@fence-wait-bsd2:
    - shard-iclb:         [SKIP][67] ([fdo#109276]) -> [PASS][68] +14 similar issues
   [67]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb5/igt@prime_vgem@fence-wait-bsd2.html
   [68]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb2/igt@prime_vgem@fence-wait-bsd2.html

  
#### Warnings ####

  * igt@gem_ctx_isolation@vcs1-nonpriv:
    - shard-iclb:         [FAIL][69] ([IGT#28]) -> [SKIP][70] ([fdo#109276] / [fdo#112080])
   [69]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-iclb1/igt@gem_ctx_isolation@vcs1-nonpriv.html
   [70]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-iclb6/igt@gem_ctx_isolation@vcs1-nonpriv.html

  * igt@gem_tiled_blits@normal:
    - shard-hsw:          [FAIL][71] ([i915#694]) -> [FAIL][72] ([i915#818]) +1 similar issue
   [71]: https://intel-gfx-ci.01.org/tree/drm-tip/CI_DRM_7811/shard-hsw5/igt@gem_tiled_blits@normal.html
   [72]: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/shard-hsw2/igt@gem_tiled_blits@normal.html

  
  [IGT#28]: https://gitlab.freedesktop.org/drm/igt-gpu-tools/issues/28
  [fdo#103665]: https://bugs.freedesktop.org/show_bug.cgi?id=103665
  [fdo#108145]: https://bugs.freedesktop.org/show_bug.cgi?id=108145
  [fdo#109276]: https://bugs.freedesktop.org/show_bug.cgi?id=109276
  [fdo#109441]: https://bugs.freedesktop.org/show_bug.cgi?id=109441
  [fdo#110841]: https://bugs.freedesktop.org/show_bug.cgi?id=110841
  [fdo#112080]: https://bugs.freedesktop.org/show_bug.cgi?id=112080
  [fdo#112146]: https://bugs.freedesktop.org/show_bug.cgi?id=112146
  [i915#1031]: https://gitlab.freedesktop.org/drm/intel/issues/1031
  [i915#109]: https://gitlab.freedesktop.org/drm/intel/issues/109
  [i915#173]: https://gitlab.freedesktop.org/drm/intel/issues/173
  [i915#180]: https://gitlab.freedesktop.org/drm/intel/issues/180
  [i915#198]: https://gitlab.freedesktop.org/drm/intel/issues/198
  [i915#31]: https://gitlab.freedesktop.org/drm/intel/issues/31
  [i915#34]: https://gitlab.freedesktop.org/drm/intel/issues/34
  [i915#413]: https://gitlab.freedesktop.org/drm/intel/issues/413
  [i915#454]: https://gitlab.freedesktop.org/drm/intel/issues/454
  [i915#49]: https://gitlab.freedesktop.org/drm/intel/issues/49
  [i915#61]: https://gitlab.freedesktop.org/drm/intel/issues/61
  [i915#644]: https://gitlab.freedesktop.org/drm/intel/issues/644
  [i915#677]: https://gitlab.freedesktop.org/drm/intel/issues/677
  [i915#69]: https://gitlab.freedesktop.org/drm/intel/issues/69
  [i915#694]: https://gitlab.freedesktop.org/drm/intel/issues/694
  [i915#79]: https://gitlab.freedesktop.org/drm/intel/issues/79
  [i915#818]: https://gitlab.freedesktop.org/drm/intel/issues/818
  [i915#831]: https://gitlab.freedesktop.org/drm/intel/issues/831


Participating hosts (10 -> 10)
------------------------------

  No changes in participating hosts


Build changes
-------------

  * CI: CI-20190529 -> None
  * Linux: CI_DRM_7811 -> Patchwork_16262

  CI-20190529: 20190529
  CI_DRM_7811: f528982f5c837f075e82ca544df010ca5183064a @ git://anongit.freedesktop.org/gfx-ci/linux
  IGT_5384: fd6896567f7d612c76207970376d4f1e634ded55 @ git://anongit.freedesktop.org/xorg/app/intel-gpu-tools
  Patchwork_16262: 120d72ced4d75ab3be121475f9e90d762ec99d12 @ git://anongit.freedesktop.org/gfx-ci/linux
  piglit_4509: fdc5a4ca11124ab8413c7988896eec4c97336694 @ git://anongit.freedesktop.org/piglit

== Logs ==

For more details see: https://intel-gfx-ci.01.org/tree/drm-tip/Patchwork_16262/index.html
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 4/8] drm/i915: Clear out spurious whitespace
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:28     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:28 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

Title should be s/i915/edid/ , with that fixed:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Nuke some whitespace that shouldn't be there.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index d6bce58b27ac..3df5744026b0 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>         closure->modes += drm_dmt_modes_for_range(closure->connector,
>                                                   closure->edid,
>                                                   timing);
> -
> +
>         if (!version_greater(closure->edid, 1, 1))
>                 return; /* GTF not defined yet */
>
> @@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
>
>  static int
>  add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> -{
> +{
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
>                 .edid = edid,
> @@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
>  {
>         int name_length;
>         char buf[13];
> -
> +
>         if (bufsize <= 0)
>                 return;
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
@ 2020-01-27 22:28     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:28 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

Title should be s/i915/edid/ , with that fixed:
Reviewed-by: Alex Deucher <alexander.deucher@amd.com>


On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Nuke some whitespace that shouldn't be there.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 6 +++---
>  1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index d6bce58b27ac..3df5744026b0 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>         closure->modes += drm_dmt_modes_for_range(closure->connector,
>                                                   closure->edid,
>                                                   timing);
> -
> +
>         if (!version_greater(closure->edid, 1, 1))
>                 return; /* GTF not defined yet */
>
> @@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
>
>  static int
>  add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> -{
> +{
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
>                 .edid = edid,
> @@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid *edid, char *name, int bufsize)
>  {
>         int name_length;
>         char buf[13];
> -
> +
>         if (bufsize <= 0)
>                 return;
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:30     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:30 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> After much head scratching I managed to convince myself that
> for_each_displayid_db() has already done the bounds checks for
> the DispID CEA data block. Which is why we don't need to repeat
> them in cea_db_offsets(). To avoid having to go through that
> pain again in the future add a comment which explains this fact.
>
> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 3df5744026b0..0369a54e3d32 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
>          *   no non-DTD data.
>          */
>         if (cea[0] == DATA_BLOCK_CTA) {
> +               /*
> +                * for_each_displayid_db() has already verified
> +                * that these stay within expected bounds.
> +                */

I think the preferred format is to have the start of the comment be on
the first line after the /* with that fixed:
Acked-by: Alex Deucher <alexander.deucher@amd.com>

>                 *start = 3;
>                 *end = *start + cea[2];
>         } else if (cea[0] == CEA_EXT) {
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
@ 2020-01-27 22:30     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:30 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> After much head scratching I managed to convince myself that
> for_each_displayid_db() has already done the bounds checks for
> the DispID CEA data block. Which is why we don't need to repeat
> them in cea_db_offsets(). To avoid having to go through that
> pain again in the future add a comment which explains this fact.
>
> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 4 ++++
>  1 file changed, 4 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 3df5744026b0..0369a54e3d32 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
>          *   no non-DTD data.
>          */
>         if (cea[0] == DATA_BLOCK_CTA) {
> +               /*
> +                * for_each_displayid_db() has already verified
> +                * that these stay within expected bounds.
> +                */

I think the preferred format is to have the start of the comment be on
the first line after the /* with that fixed:
Acked-by: Alex Deucher <alexander.deucher@amd.com>

>                 *start = 3;
>                 *end = *start + cea[2];
>         } else if (cea[0] == CEA_EXT) {
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:32     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:32 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> I don't understand what the DispID CEA data block revision
> means. The spec doesn't say. I guess some DispID must have
> a value of >= 3 in there or else we generally wouldn't
> even parse the CEA data blocks. Or does all this code
> actually not do anything?
>
> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 0369a54e3d32..fd9b724067a7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)
>  static int
>  cea_revision(const u8 *cea)
>  {
> +       /*
> +        * FIXME is this correct for the DispID variant?
> +        * The DispID spec doesn't really specify whether
> +        * this is the revision of the CEA extension or
> +        * the DispID CEA data block. And the only value
> +        * given as an example is 0.
> +        */

Same comment as the previous patch regarding the comment formatting.

Alex

>         return cea[1];
>  }
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
@ 2020-01-27 22:32     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:32 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> I don't understand what the DispID CEA data block revision
> means. The spec doesn't say. I guess some DispID must have
> a value of >= 3 in there or else we generally wouldn't
> even parse the CEA data blocks. Or does all this code
> actually not do anything?
>
> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 0369a54e3d32..fd9b724067a7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)
>  static int
>  cea_revision(const u8 *cea)
>  {
> +       /*
> +        * FIXME is this correct for the DispID variant?
> +        * The DispID spec doesn't really specify whether
> +        * this is the revision of the CEA extension or
> +        * the DispID CEA data block. And the only value
> +        * given as an example is 0.
> +        */

Same comment as the previous patch regarding the comment formatting.

Alex

>         return cea[1];
>  }
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:34   ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:34 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> CEA-861 says :
> "d = offset for the byte following the reserved data block.
>  If no data is provided in the reserved data block, then d=4.
>  If no DTDs are provided, then d=0."
>
> So let's not look for DTDs when d==0. In fact let's just make that
> <4 since those values would just mean that he DTDs overlap the block
> header. And let's also check that d isn't so big as to declare
> the descriptors to live past the block end, although the code
> does already survive that case as we'd just end up with a negative
> number of descriptors and the loop would not do anything.
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 99769d6c9f84..1b6e544cf5c7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>  static void
>  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
>  {
> -       int i, n = 0;
> +       int i, n;
>         u8 d = ext[0x02];
>         u8 *det_base = ext + d;
>
> +       if (d < 4 || d > 127)
> +               return;
> +
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
>                 cb((struct detailed_timing *)(det_base + 18 * i), closure);
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-27 22:34   ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:34 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> CEA-861 says :
> "d = offset for the byte following the reserved data block.
>  If no data is provided in the reserved data block, then d=4.
>  If no DTDs are provided, then d=0."
>
> So let's not look for DTDs when d==0. In fact let's just make that
> <4 since those values would just mean that he DTDs overlap the block
> header. And let's also check that d isn't so big as to declare
> the descriptors to live past the block end, although the code
> does already survive that case as we'd just end up with a negative
> number of descriptors and the loop would not do anything.
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 99769d6c9f84..1b6e544cf5c7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>  static void
>  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
>  {
> -       int i, n = 0;
> +       int i, n;
>         u8 d = ext[0x02];
>         u8 *det_base = ext + d;
>
> +       if (d < 4 || d > 127)
> +               return;
> +
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
>                 cb((struct detailed_timing *)(det_base + 18 * i), closure);
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:35     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:35 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Currently we assume any 18 byte descriptor to be a display descritor
> if only the tag byte matches the expected value. But for detailed
> timing descriptors that same byte is just the lower 8 bits of
> hblank, and as such can match any display descriptor tag. To
> properly validate that the 18 byte descriptor is in fact a
> display descriptor we must also examine bytes 0-2 (just byte 1
> should actually suffice but the spec does say that bytes 0 and
> 2 must also always be zero for display descriptors so we check
> those too).
>
> Unlike Allen's original proposed patch to just fix is_rb() we
> roll this out across the board to fix everything.
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 65 ++++++++++++++++++++++++--------------
>  1 file changed, 41 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 1b6e544cf5c7..96ae1fde4ce2 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2196,6 +2196,12 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_mode_find_dmt);
>
> +static bool is_display_descriptor(const u8 d[18], u8 tag)
> +{
> +       return d[0] == 0x00 && d[1] == 0x00 &&
> +               d[2] == 0x00 && d[3] == tag;
> +}
> +
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>
>  static void
> @@ -2257,9 +2263,12 @@ static void
>  is_rb(struct detailed_timing *t, void *data)
>  {
>         u8 *r = (u8 *)t;
> -       if (r[3] == EDID_DETAIL_MONITOR_RANGE)
> -               if (r[15] & 0x10)
> -                       *(bool *)data = true;
> +
> +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> +               return;
> +
> +       if (r[15] & 0x10)
> +               *(bool *)data = true;
>  }
>
>  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
> @@ -2279,7 +2288,11 @@ static void
>  find_gtf2(struct detailed_timing *t, void *data)
>  {
>         u8 *r = (u8 *)t;
> -       if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
> +
> +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> +               return;
> +
> +       if (r[10] == 0x02)
>                 *(u8 **)data = r;
>  }
>
> @@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>         struct detailed_non_pixel *data = &timing->data.other_data;
>         struct detailed_data_monitor_range *range = &data->data.range;
>
> -       if (data->type != EDID_DETAIL_MONITOR_RANGE)
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         closure->modes += drm_dmt_modes_for_range(closure->connector,
> @@ -2897,10 +2910,11 @@ static void
>  do_established_modes(struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
>
> -       if (data->type == EDID_DETAIL_EST_TIMINGS)
> -               closure->modes += drm_est3_modes(closure->connector, timing);
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
> +               return;
> +
> +       closure->modes += drm_est3_modes(closure->connector, timing);
>  }
>
>  /**
> @@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing, void *c)
>         struct detailed_non_pixel *data = &timing->data.other_data;
>         struct drm_connector *connector = closure->connector;
>         struct edid *edid = closure->edid;
> +       int i;
>
> -       if (data->type == EDID_DETAIL_STD_MODES) {
> -               int i;
> -               for (i = 0; i < 6; i++) {
> -                       struct std_timing *std;
> -                       struct drm_display_mode *newmode;
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> +               return;
>
> -                       std = &data->data.timings[i];
> -                       newmode = drm_mode_std(connector, edid, std);
> -                       if (newmode) {
> -                               drm_mode_probed_add(connector, newmode);
> -                               closure->modes++;
> -                       }
> +       for (i = 0; i < 6; i++) {
> +               struct std_timing *std = &data->data.timings[i];
> +               struct drm_display_mode *newmode;
> +
> +               newmode = drm_mode_std(connector, edid, std);
> +               if (newmode) {
> +                       drm_mode_probed_add(connector, newmode);
> +                       closure->modes++;
>                 }
>         }
>  }
> @@ -3056,10 +3070,11 @@ static void
>  do_cvt_mode(struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
>
> -       if (data->type == EDID_DETAIL_CVT_3BYTE)
> -               closure->modes += drm_cvt_modes(closure->connector, timing);
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
> +               return;
> +
> +       closure->modes += drm_cvt_modes(closure->connector, timing);
>  }
>
>  static int
> @@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
>  static void
>  monitor_name(struct detailed_timing *t, void *data)
>  {
> -       if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
> -               *(u8 **)data = t->data.other_data.data.str.str;
> +       if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> +               return;
> +
> +       *(u8 **)data = t->data.other_data.data.str.str;
>  }
>
>  static int get_monitor_name(struct edid *edid, char name[13])
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
@ 2020-01-27 22:35     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:35 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Currently we assume any 18 byte descriptor to be a display descritor
> if only the tag byte matches the expected value. But for detailed
> timing descriptors that same byte is just the lower 8 bits of
> hblank, and as such can match any display descriptor tag. To
> properly validate that the 18 byte descriptor is in fact a
> display descriptor we must also examine bytes 0-2 (just byte 1
> should actually suffice but the spec does say that bytes 0 and
> 2 must also always be zero for display descriptors so we check
> those too).
>
> Unlike Allen's original proposed patch to just fix is_rb() we
> roll this out across the board to fix everything.
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 65 ++++++++++++++++++++++++--------------
>  1 file changed, 41 insertions(+), 24 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 1b6e544cf5c7..96ae1fde4ce2 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2196,6 +2196,12 @@ struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
>  }
>  EXPORT_SYMBOL(drm_mode_find_dmt);
>
> +static bool is_display_descriptor(const u8 d[18], u8 tag)
> +{
> +       return d[0] == 0x00 && d[1] == 0x00 &&
> +               d[2] == 0x00 && d[3] == tag;
> +}
> +
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>
>  static void
> @@ -2257,9 +2263,12 @@ static void
>  is_rb(struct detailed_timing *t, void *data)
>  {
>         u8 *r = (u8 *)t;
> -       if (r[3] == EDID_DETAIL_MONITOR_RANGE)
> -               if (r[15] & 0x10)
> -                       *(bool *)data = true;
> +
> +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> +               return;
> +
> +       if (r[15] & 0x10)
> +               *(bool *)data = true;
>  }
>
>  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
> @@ -2279,7 +2288,11 @@ static void
>  find_gtf2(struct detailed_timing *t, void *data)
>  {
>         u8 *r = (u8 *)t;
> -       if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
> +
> +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> +               return;
> +
> +       if (r[10] == 0x02)
>                 *(u8 **)data = r;
>  }
>
> @@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>         struct detailed_non_pixel *data = &timing->data.other_data;
>         struct detailed_data_monitor_range *range = &data->data.range;
>
> -       if (data->type != EDID_DETAIL_MONITOR_RANGE)
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         closure->modes += drm_dmt_modes_for_range(closure->connector,
> @@ -2897,10 +2910,11 @@ static void
>  do_established_modes(struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
>
> -       if (data->type == EDID_DETAIL_EST_TIMINGS)
> -               closure->modes += drm_est3_modes(closure->connector, timing);
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
> +               return;
> +
> +       closure->modes += drm_est3_modes(closure->connector, timing);
>  }
>
>  /**
> @@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing, void *c)
>         struct detailed_non_pixel *data = &timing->data.other_data;
>         struct drm_connector *connector = closure->connector;
>         struct edid *edid = closure->edid;
> +       int i;
>
> -       if (data->type == EDID_DETAIL_STD_MODES) {
> -               int i;
> -               for (i = 0; i < 6; i++) {
> -                       struct std_timing *std;
> -                       struct drm_display_mode *newmode;
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> +               return;
>
> -                       std = &data->data.timings[i];
> -                       newmode = drm_mode_std(connector, edid, std);
> -                       if (newmode) {
> -                               drm_mode_probed_add(connector, newmode);
> -                               closure->modes++;
> -                       }
> +       for (i = 0; i < 6; i++) {
> +               struct std_timing *std = &data->data.timings[i];
> +               struct drm_display_mode *newmode;
> +
> +               newmode = drm_mode_std(connector, edid, std);
> +               if (newmode) {
> +                       drm_mode_probed_add(connector, newmode);
> +                       closure->modes++;
>                 }
>         }
>  }
> @@ -3056,10 +3070,11 @@ static void
>  do_cvt_mode(struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
>
> -       if (data->type == EDID_DETAIL_CVT_3BYTE)
> -               closure->modes += drm_cvt_modes(closure->connector, timing);
> +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
> +               return;
> +
> +       closure->modes += drm_cvt_modes(closure->connector, timing);
>  }
>
>  static int
> @@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
>  static void
>  monitor_name(struct detailed_timing *t, void *data)
>  {
> -       if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
> -               *(u8 **)data = t->data.other_data.data.str.str;
> +       if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> +               return;
> +
> +       *(u8 **)data = t->data.other_data.data.str.str;
>  }
>
>  static int get_monitor_name(struct edid *edid, char name[13])
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:36     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:36 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Let's introduce is_detailed_timing_descritor() as the opposite
> counterpart of is_display_descriptor().
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 96ae1fde4ce2..d6bce58b27ac 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
>                 d[2] == 0x00 && d[3] == tag;
>  }
>
> +static bool is_detailed_timing_descriptor(const u8 d[18])
> +{
> +       return d[0] != 0x00 || d[1] != 0x00;
> +}
> +
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>
>  static void
> @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>         struct detailed_mode_closure *closure = c;
>         struct drm_display_mode *newmode;
>
> -       if (timing->pixel_clock) {
> -               newmode = drm_mode_detailed(closure->connector->dev,
> -                                           closure->edid, timing,
> -                                           closure->quirks);
> -               if (!newmode)
> -                       return;
> +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> +               return;
> +
> +       newmode = drm_mode_detailed(closure->connector->dev,
> +                                   closure->edid, timing,
> +                                   closure->quirks);
> +       if (!newmode)
> +               return;
>
> -               if (closure->preferred)
> -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> +       if (closure->preferred)
> +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
>
> -               /*
> -                * Detailed modes are limited to 10kHz pixel clock resolution,
> -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> -                * is just slightly off.
> -                */
> -               fixup_detailed_cea_mode_clock(newmode);
> +       /*
> +        * Detailed modes are limited to 10kHz pixel clock resolution,
> +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> +        * is just slightly off.
> +        */
> +       fixup_detailed_cea_mode_clock(newmode);
>
> -               drm_mode_probed_add(closure->connector, newmode);
> -               closure->modes++;
> -               closure->preferred = false;
> -       }
> +       drm_mode_probed_add(closure->connector, newmode);
> +       closure->modes++;
> +       closure->preferred = false;
>  }
>
>  /*
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
@ 2020-01-27 22:36     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:36 UTC (permalink / raw)
  To: Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Let's introduce is_detailed_timing_descritor() as the opposite
> counterpart of is_display_descriptor().
>
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 42 ++++++++++++++++++++++----------------
>  1 file changed, 24 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 96ae1fde4ce2..d6bce58b27ac 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
>                 d[2] == 0x00 && d[3] == tag;
>  }
>
> +static bool is_detailed_timing_descriptor(const u8 d[18])
> +{
> +       return d[0] != 0x00 || d[1] != 0x00;
> +}
> +
>  typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>
>  static void
> @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>         struct detailed_mode_closure *closure = c;
>         struct drm_display_mode *newmode;
>
> -       if (timing->pixel_clock) {
> -               newmode = drm_mode_detailed(closure->connector->dev,
> -                                           closure->edid, timing,
> -                                           closure->quirks);
> -               if (!newmode)
> -                       return;
> +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> +               return;
> +
> +       newmode = drm_mode_detailed(closure->connector->dev,
> +                                   closure->edid, timing,
> +                                   closure->quirks);
> +       if (!newmode)
> +               return;
>
> -               if (closure->preferred)
> -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> +       if (closure->preferred)
> +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
>
> -               /*
> -                * Detailed modes are limited to 10kHz pixel clock resolution,
> -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> -                * is just slightly off.
> -                */
> -               fixup_detailed_cea_mode_clock(newmode);
> +       /*
> +        * Detailed modes are limited to 10kHz pixel clock resolution,
> +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> +        * is just slightly off.
> +        */
> +       fixup_detailed_cea_mode_clock(newmode);
>
> -               drm_mode_probed_add(closure->connector, newmode);
> -               closure->modes++;
> -               closure->preferred = false;
> -       }
> +       drm_mode_probed_add(closure->connector, newmode);
> +       closure->modes++;
> +       closure->preferred = false;
>  }
>
>  /*
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 7/8] drm/edid: Constify lots of things
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:38     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:38 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Let's try to make a lot more stuff const in the edid parser.
>
> The "downside" is that we can no longer mangle the EDID in the
> middle of the parsing to apply quirks (drm_mode_detailed()).
> I don't really think mangling the blob itself is such a great
> idea anyway so I won't miss that part. But if we do want it
> back I guess we should do the mangling in one explicit place
> before we otherwise parse the EDID.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I generally agree, but are there any userspace expectations that they
will be getting a corrected EDID in some cases?

Alex

> ---
>  drivers/gpu/drm/drm_connector.c |   4 +-
>  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
>  include/drm/drm_connector.h     |   4 +-
>  3 files changed, 176 insertions(+), 135 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index f632ca05960e..92a5cd6ff6b1 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
>   * tile group or NULL if not found.
>   */
>  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> -                                              char topology[8])
> +                                              const u8 topology[8])
>  {
>         struct drm_tile_group *tg;
>         int id;
> @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
>   * new tile group or NULL.
>   */
>  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> -                                                 char topology[8])
> +                                                 const u8 topology[8])
>  {
>         struct drm_tile_group *tg;
>         int ret;
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index fd9b724067a7..8e76efe1654d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -88,7 +88,7 @@
>
>  struct detailed_mode_closure {
>         struct drm_connector *connector;
> -       struct edid *edid;
> +       const struct edid *edid;
>         bool preferred;
>         u32 quirks;
>         int modes;
> @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
>                  "Minimum number of valid EDID header bytes (0-8, default 6)");
>
>  static void drm_get_displayid(struct drm_connector *connector,
> -                             struct edid *edid);
> -static int validate_displayid(u8 *displayid, int length, int idx);
> +                             const struct edid *edid);
> +static int validate_displayid(const u8 *displayid, int length, int idx);
>
>  static int drm_edid_block_checksum(const u8 *raw_edid)
>  {
> @@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
>         return d[0] != 0x00 || d[1] != 0x00;
>  }
>
> -typedef void detailed_cb(struct detailed_timing *timing, void *closure);
> +typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
>
>  static void
> -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>         int i, n;
>         u8 d = ext[0x02];
> -       u8 *det_base = ext + d;
> +       const u8 *det_base = ext + d;
>
>         if (d < 4 || d > 127)
>                 return;
>
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
> -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>
>  static void
> -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>         unsigned int i, n = min((int)ext[0x02], 6);
> -       u8 *det_base = ext + 5;
> +       const u8 *det_base = ext + 5;
>
>         if (ext[0x01] != 1)
>                 return; /* unknown version */
>
>         for (i = 0; i < n; i++)
> -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>
>  static void
> -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
>  {
> +       const struct edid *edid = (struct edid *)raw_edid;
>         int i;
> -       struct edid *edid = (struct edid *)raw_edid;
>
>         if (edid == NULL)
>                 return;
> @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
>                 cb(&(edid->detailed_timings[i]), closure);
>
>         for (i = 1; i <= raw_edid[0x7e]; i++) {
> -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
>                 switch (*ext) {
>                 case CEA_EXT:
>                         cea_for_each_detailed_block(ext, cb, closure);
> @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
>         }
>  }
>
> +struct bool_closure {
> +       bool ret;
> +};
> +
>  static void
> -is_rb(struct detailed_timing *t, void *data)
> +is_rb(const struct detailed_timing *t, void *c)
>  {
> -       u8 *r = (u8 *)t;
> +       struct bool_closure *closure = c;
> +       const u8 *r = (const u8 *)t;
>
>         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         if (r[15] & 0x10)
> -               *(bool *)data = true;
> +               closure->ret = true;
>  }
>
>  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
>  static bool
> -drm_monitor_supports_rb(struct edid *edid)
> +drm_monitor_supports_rb(const struct edid *edid)
>  {
>         if (edid->revision >= 4) {
> -               bool ret = false;
> -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> -               return ret;
> +               struct bool_closure closure = {
> +                       .ret = false,
> +               };
> +
> +               drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
> +
> +               return closure.ret;
>         }
>
>         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
>  }
>
> +struct data_closure {
> +       const u8 *data;
> +};
> +
>  static void
> -find_gtf2(struct detailed_timing *t, void *data)
> +do_find_gtf2(const struct detailed_timing *t, void *c)
>  {
> -       u8 *r = (u8 *)t;
> +       struct data_closure *closure = c;
> +       const u8 *r = (const u8 *)t;
>
>         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         if (r[10] == 0x02)
> -               *(u8 **)data = r;
> +               closure->data = r;
> +}
> +
> +static const u8 *
> +find_gtf2_descriptor(const struct edid *edid)
> +{
> +       struct data_closure closure = {};
> +
> +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
> +
> +       return closure.data;
>  }
>
>  /* Secondary GTF curve kicks in above some break frequency */
>  static int
> -drm_gtf2_hbreak(struct edid *edid)
> +drm_gtf2_hbreak(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> -       return r ? (r[12] * 2) : 0;
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
> +       return r ? r[12] * 2 : 0;
>  }
>
>  static int
> -drm_gtf2_2c(struct edid *edid)
> +drm_gtf2_2c(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[13] : 0;
>  }
>
>  static int
> -drm_gtf2_m(struct edid *edid)
> +drm_gtf2_m(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> -       return r ? (r[15] << 8) + r[14] : 0;
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
> +       return r ? (r[15] << 8) | r[14] : 0;
>  }
>
>  static int
> -drm_gtf2_k(struct edid *edid)
> +drm_gtf2_k(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[16] : 0;
>  }
>
>  static int
> -drm_gtf2_2j(struct edid *edid)
> +drm_gtf2_2j(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[17] : 0;
>  }
>
> @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
>   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
>   * @edid: EDID block to scan
>   */
> -static int standard_timing_level(struct edid *edid)
> +static int standard_timing_level(const struct edid *edid)
>  {
>         if (edid->revision >= 2) {
>                 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
> @@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
>   * and convert them into a real mode using CVT/GTF/DMT.
>   */
>  static struct drm_display_mode *
> -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> -            struct std_timing *t)
> +drm_mode_std(struct drm_connector *connector,
> +            const struct edid *edid,
> +            const struct std_timing *t)
>  {
>         struct drm_device *dev = connector->dev;
>         struct drm_display_mode *m, *mode = NULL;
> @@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
>   */
>  static void
>  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> -                           struct detailed_pixel_timing *pt)
> +                           const struct detailed_pixel_timing *pt)
>  {
>         int i;
>         static const struct {
> @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
>   * return a new struct drm_display_mode.
>   */
>  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> -                                                 struct edid *edid,
> -                                                 struct detailed_timing *timing,
> +                                                 const struct edid *edid,
> +                                                 const struct detailed_timing *timing,
>                                                   u32 quirks)
>  {
>         struct drm_display_mode *mode;
> -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> +       const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
>         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
>         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
>         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
> @@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>                 return NULL;
>
>         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> -               timing->pixel_clock = cpu_to_le16(1088);
> -
> -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> +               mode->clock = 1088 * 10;
> +       else
> +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
>
>         mode->hdisplay = hactive;
>         mode->hsync_start = mode->hdisplay + hsync_offset;
> @@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>         drm_mode_do_interlace_quirk(mode, pt);
>
>         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
> +               mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
> +       } else {
> +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
>         }
>
> -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> -
>  set_size:
>         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
>         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
> @@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>
>  static bool
>  mode_in_hsync_range(const struct drm_display_mode *mode,
> -                   struct edid *edid, u8 *t)
> +                   const struct edid *edid, const u8 *t)
>  {
>         int hsync, hmin, hmax;
>
> @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
>
>  static bool
>  mode_in_vsync_range(const struct drm_display_mode *mode,
> -                   struct edid *edid, u8 *t)
> +                   const struct edid *edid, const u8 *t)
>  {
>         int vsync, vmin, vmax;
>
> @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
>  }
>
>  static u32
> -range_pixel_clock(struct edid *edid, u8 *t)
> +range_pixel_clock(const struct edid *edid, const u8 *t)
>  {
>         /* unspecified */
>         if (t[9] == 0 || t[9] == 255)
> @@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
>  }
>
>  static bool
> -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> -             struct detailed_timing *timing)
> +mode_in_range(const struct drm_display_mode *mode,
> +             const struct edid *edid,
> +             const struct detailed_timing *timing)
>  {
>         u32 max_clock;
> -       u8 *t = (u8 *)timing;
> +       const u8 *t = (const u8 *)timing;
>
>         if (!mode_in_hsync_range(mode, edid, t))
>                 return false;
> @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
>  }
>
>  static int
> -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_dmt_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
>  }
>
>  static int
> -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_gtf_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
>  }
>
>  static int
> -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_cvt_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
>  }
>
>  static void
> -do_inferred_modes(struct detailed_timing *timing, void *c)
> +do_inferred_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
> -       struct detailed_data_monitor_range *range = &data->data.range;
> +       const struct detailed_non_pixel *data = &timing->data.other_data;
> +       const struct detailed_data_monitor_range *range = &data->data.range;
>
>         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
>                 return;
> @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>  }
>
>  static int
> -add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> +add_inferred_modes(struct drm_connector *connector,
> +                  const struct edid *edid)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
>         };
>
>         if (version_greater(edid, 1, 0))
> -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> +               drm_for_each_detailed_block((const u8 *)edid,
> +                                           do_inferred_modes,
>                                             &closure);
>
>         return closure.modes;
>  }
>
>  static int
> -drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> +drm_est3_modes(struct drm_connector *connector,
> +              const struct detailed_timing *timing)
>  {
>         int i, j, m, modes = 0;
>         struct drm_display_mode *mode;
> -       u8 *est = ((u8 *)timing) + 6;
> +       const u8 *est = ((const u8 *)timing) + 6;
>
>         for (i = 0; i < 6; i++) {
>                 for (j = 7; j >= 0; j--) {
> @@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
>  }
>
>  static void
> -do_established_modes(struct detailed_timing *timing, void *c)
> +do_established_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>
> @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
>   * (defined above).  Tease them out and add them to the global modes list.
>   */
>  static int
> -add_established_modes(struct drm_connector *connector, struct edid *edid)
> +add_established_modes(struct drm_connector *connector,
> +                     const struct edid *edid)
>  {
>         struct drm_device *dev = connector->dev;
>         unsigned long est_bits = edid->established_timings.t1 |
> @@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
>  }
>
>  static void
> -do_standard_modes(struct detailed_timing *timing, void *c)
> +do_standard_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
> +       const struct detailed_non_pixel *data = &timing->data.other_data;
>         struct drm_connector *connector = closure->connector;
> -       struct edid *edid = closure->edid;
> +       const struct edid *edid = closure->edid;
>         int i;
>
>         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
>                 return;
>
>         for (i = 0; i < 6; i++) {
> -               struct std_timing *std = &data->data.timings[i];
> +               const struct std_timing *std = &data->data.timings[i];
>                 struct drm_display_mode *newmode;
>
>                 newmode = drm_mode_std(connector, edid, std);
> @@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
>   * GTF or CVT. Grab them from @edid and add them to the list.
>   */
>  static int
> -add_standard_modes(struct drm_connector *connector, struct edid *edid)
> +add_standard_modes(struct drm_connector *connector,
> +                  const struct edid *edid)
>  {
>         int i, modes = 0;
>         struct detailed_mode_closure closure = {
> @@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
>  }
>
>  static int drm_cvt_modes(struct drm_connector *connector,
> -                        struct detailed_timing *timing)
> +                        const struct detailed_timing *timing)
>  {
>         int i, j, modes = 0;
>         struct drm_display_mode *newmode;
>         struct drm_device *dev = connector->dev;
> -       struct cvt_timing *cvt;
>         const int rates[] = { 60, 85, 75, 60, 50 };
>         const u8 empty[3] = { 0, 0, 0 };
>
>         for (i = 0; i < 4; i++) {
>                 int uninitialized_var(width), height;
> -               cvt = &(timing->data.other_data.data.cvt[i]);
> +               const struct cvt_timing *cvt =
> +                       &timing->data.other_data.data.cvt[i];
>
>                 if (!memcmp(cvt->code, empty, 3))
>                         continue;
> @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
>  }
>
>  static void
> -do_cvt_mode(struct detailed_timing *timing, void *c)
> +do_cvt_mode(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>
> @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
>  }
>
>  static int
> -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> +add_cvt_modes(struct drm_connector *connector,
> +             const struct edid *edid)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
>  static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
>
>  static void
> -do_detailed_mode(struct detailed_timing *timing, void *c)
> +do_detailed_mode(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>         struct drm_display_mode *newmode;
> @@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>   * @quirks: quirks to apply
>   */
>  static int
> -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> -                  u32 quirks)
> +add_detailed_modes(struct drm_connector *connector,
> +                  struct edid *edid, u32 quirks)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
>  /*
>   * Search EDID for CEA extension block.
>   */
> -static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> +static const u8 *drm_find_edid_extension(const struct edid *edid,
> +                                        int ext_id)
>  {
> -       u8 *edid_ext = NULL;
> +       const u8 *edid_ext = NULL;
>         int i;
>
>         /* No EDID or EDID extensions */
> @@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
>
>         /* Find CEA extension */
>         for (i = 0; i < edid->extensions; i++) {
> -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
>                 if (edid_ext[0] == ext_id)
>                         break;
>         }
> @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
>  }
>
>
> -static u8 *drm_find_displayid_extension(const struct edid *edid)
> +static const u8 *drm_find_displayid_extension(const struct edid *edid)
>  {
>         return drm_find_edid_extension(edid, DISPLAYID_EXT);
>  }
>
> -static u8 *drm_find_cea_extension(const struct edid *edid)
> +static const u8 *drm_find_cea_extension(const struct edid *edid)
>  {
>         int ret;
>         int idx = 1;
>         int length = EDID_LENGTH;
> -       struct displayid_block *block;
> -       u8 *cea;
> -       u8 *displayid;
> +       const struct displayid_block *block;
> +       const u8 *cea;
> +       const u8 *displayid;
>
>         /* Look for a top level CEA extension block */
>         cea = drm_find_edid_extension(edid, CEA_EXT);
> @@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
>  }
>
>  static void
> -monitor_name(struct detailed_timing *t, void *data)
> +monitor_name(const struct detailed_timing *t, void *c)
>  {
> +       struct data_closure *closure = c;
> +
>         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
>                 return;
>
> -       *(u8 **)data = t->data.other_data.data.str.str;
> +       closure->data = t->data.other_data.data.str.str;
>  }
>
>  static int get_monitor_name(struct edid *edid, char name[13])
>  {
> -       char *edid_name = NULL;
> +       struct data_closure closure = {};
>         int mnl;
>
>         if (!edid || !name)
>                 return 0;
>
> -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> -               if (edid_name[mnl] == 0x0a)
> +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> +               if (closure.data[mnl] == 0x0a)
>                         break;
>
> -               name[mnl] = edid_name[mnl];
> +               name[mnl] = closure.data[mnl];
>         }
>
>         return mnl;
> @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
>  static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
>  {
>         uint8_t *eld = connector->eld;
> -       u8 *cea;
> -       u8 *db;
> +       const u8 *cea;
>         int total_sad_count = 0;
>         int mnl;
> -       int dbl;
>
>         clear_eld(connector);
>
> @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
>                 }
>
>                 for_each_cea_db(cea, i, start, end) {
> -                       db = &cea[i];
> -                       dbl = cea_db_payload_len(db);
> +                       const u8 *db = &cea[i];
> +                       int dbl = cea_db_payload_len(db);
>
>                         switch (cea_db_tag(db)) {
>                                 int sad_count;
> @@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>  {
>         int count = 0;
>         int i, start, end, dbl;
> -       u8 *cea;
> +       const u8 *cea;
>
>         cea = drm_find_cea_extension(edid);
>         if (!cea) {
> @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>         }
>
>         for_each_cea_db(cea, i, start, end) {
> -               u8 *db = &cea[i];
> +               const u8 *db = &cea[i];
>
>                 if (cea_db_tag(db) == AUDIO_BLOCK) {
>                         int j;
> @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>                         if (!*sads)
>                                 return -ENOMEM;
>                         for (j = 0; j < count; j++) {
> -                               u8 *sad = &db[1 + j * 3];
> +                               const u8 *sad = &db[1 + j * 3];
>
>                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
>                                 (*sads)[j].channels = sad[0] & 0x7;
> @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
>   */
>  bool drm_detect_hdmi_monitor(struct edid *edid)
>  {
> -       u8 *edid_ext;
> +       const u8 *edid_ext;
>         int i;
>         int start_offset, end_offset;
>
> @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
>   */
>  bool drm_detect_monitor_audio(struct edid *edid)
>  {
> -       u8 *edid_ext;
> +       const u8 *edid_ext;
>         int i, j;
>         bool has_audio = false;
>         int start_offset, end_offset;
> @@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
>         return quirks;
>  }
>
> -static int validate_displayid(u8 *displayid, int length, int idx)
> +static int validate_displayid(const u8 *displayid, int length, int idx)
>  {
>         int i;
>         u8 csum = 0;
> -       struct displayid_hdr *base;
> +       const struct displayid_hdr *base;
>
> -       base = (struct displayid_hdr *)&displayid[idx];
> +       base = (const struct displayid_hdr *)&displayid[idx];
>
>         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
>                       base->rev, base->bytes, base->prod_id, base->ext_count);
> @@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
>  }
>
>  static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
> -                                                           struct displayid_detailed_timings_1 *timings)
> +                                                           const struct displayid_detailed_timings_1 *timings)
>  {
>         struct drm_display_mode *mode;
>         unsigned pixel_clock = (timings->pixel_clock[0] |
> @@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
>         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
>         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
>         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> +
>         mode = drm_mode_create(dev);
>         if (!mode)
>                 return NULL;
> @@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
>  }
>
>  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> -                                         struct displayid_block *block)
> +                                         const struct displayid_block *block)
>  {
> -       struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
> +       const struct displayid_detailed_timing_block *det =
> +               (const struct displayid_detailed_timing_block *)block;
>         int i;
>         int num_timings;
>         struct drm_display_mode *newmode;
> @@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
>
>         num_timings = block->num_bytes / 20;
>         for (i = 0; i < num_timings; i++) {
> -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> +               const struct displayid_detailed_timings_1 *timings = &det->timings[i];
>
>                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
>                 if (!newmode)
> @@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
>  }
>
>  static int add_displayid_detailed_modes(struct drm_connector *connector,
> -                                       struct edid *edid)
> +                                       const struct edid *edid)
>  {
> -       u8 *displayid;
> +       const u8 *displayid;
>         int ret;
>         int idx = 1;
>         int length = EDID_LENGTH;
> -       struct displayid_block *block;
> +       const struct displayid_block *block;
>         int num_modes = 0;
>
>         displayid = drm_find_displayid_extension(edid);
> @@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>  EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
>
>  static int drm_parse_tiled_block(struct drm_connector *connector,
> -                                struct displayid_block *block)
> +                                const struct displayid_block *block)
>  {
> -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> +       const struct displayid_tiled_block *tile =
> +               (const struct displayid_tiled_block *)block;
>         u16 w, h;
>         u8 tile_v_loc, tile_h_loc;
>         u8 num_v_tile, num_h_tile;
> @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
>  }
>
>  static int drm_parse_display_id(struct drm_connector *connector,
> -                               u8 *displayid, int length,
> +                               const u8 *displayid, int length,
>                                 bool is_edid_extension)
>  {
>         /* if this is an EDID extension the first byte will be 0x70 */
>         int idx = 0;
> -       struct displayid_block *block;
> +       const struct displayid_block *block;
>         int ret;
>
>         if (is_edid_extension)
> @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
>  }
>
>  static void drm_get_displayid(struct drm_connector *connector,
> -                             struct edid *edid)
> +                             const struct edid *edid)
>  {
> -       void *displayid = NULL;
> +       const void *displayid;
>         int ret;
> +
>         connector->has_tile = false;
> +
>         displayid = drm_find_displayid_extension(edid);
>         if (!displayid) {
>                 /* drop reference to any tile group we had */
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 2113500b4075..c0f9ce3f4b24 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1580,9 +1580,9 @@ struct drm_tile_group {
>  };
>
>  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> -                                                 char topology[8]);
> +                                                 const u8 topology[8]);
>  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> -                                              char topology[8]);
> +                                              const u8 topology[8]);
>  void drm_mode_put_tile_group(struct drm_device *dev,
>                              struct drm_tile_group *tg);
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
@ 2020-01-27 22:38     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:38 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> Let's try to make a lot more stuff const in the edid parser.
>
> The "downside" is that we can no longer mangle the EDID in the
> middle of the parsing to apply quirks (drm_mode_detailed()).
> I don't really think mangling the blob itself is such a great
> idea anyway so I won't miss that part. But if we do want it
> back I guess we should do the mangling in one explicit place
> before we otherwise parse the EDID.
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

I generally agree, but are there any userspace expectations that they
will be getting a corrected EDID in some cases?

Alex

> ---
>  drivers/gpu/drm/drm_connector.c |   4 +-
>  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
>  include/drm/drm_connector.h     |   4 +-
>  3 files changed, 176 insertions(+), 135 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> index f632ca05960e..92a5cd6ff6b1 100644
> --- a/drivers/gpu/drm/drm_connector.c
> +++ b/drivers/gpu/drm/drm_connector.c
> @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
>   * tile group or NULL if not found.
>   */
>  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> -                                              char topology[8])
> +                                              const u8 topology[8])
>  {
>         struct drm_tile_group *tg;
>         int id;
> @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
>   * new tile group or NULL.
>   */
>  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> -                                                 char topology[8])
> +                                                 const u8 topology[8])
>  {
>         struct drm_tile_group *tg;
>         int ret;
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index fd9b724067a7..8e76efe1654d 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -88,7 +88,7 @@
>
>  struct detailed_mode_closure {
>         struct drm_connector *connector;
> -       struct edid *edid;
> +       const struct edid *edid;
>         bool preferred;
>         u32 quirks;
>         int modes;
> @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
>                  "Minimum number of valid EDID header bytes (0-8, default 6)");
>
>  static void drm_get_displayid(struct drm_connector *connector,
> -                             struct edid *edid);
> -static int validate_displayid(u8 *displayid, int length, int idx);
> +                             const struct edid *edid);
> +static int validate_displayid(const u8 *displayid, int length, int idx);
>
>  static int drm_edid_block_checksum(const u8 *raw_edid)
>  {
> @@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
>         return d[0] != 0x00 || d[1] != 0x00;
>  }
>
> -typedef void detailed_cb(struct detailed_timing *timing, void *closure);
> +typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
>
>  static void
> -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>         int i, n;
>         u8 d = ext[0x02];
> -       u8 *det_base = ext + d;
> +       const u8 *det_base = ext + d;
>
>         if (d < 4 || d > 127)
>                 return;
>
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
> -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>
>  static void
> -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
>         unsigned int i, n = min((int)ext[0x02], 6);
> -       u8 *det_base = ext + 5;
> +       const u8 *det_base = ext + 5;
>
>         if (ext[0x01] != 1)
>                 return; /* unknown version */
>
>         for (i = 0; i < n; i++)
> -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
>  }
>
>  static void
> -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
>  {
> +       const struct edid *edid = (struct edid *)raw_edid;
>         int i;
> -       struct edid *edid = (struct edid *)raw_edid;
>
>         if (edid == NULL)
>                 return;
> @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
>                 cb(&(edid->detailed_timings[i]), closure);
>
>         for (i = 1; i <= raw_edid[0x7e]; i++) {
> -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
>                 switch (*ext) {
>                 case CEA_EXT:
>                         cea_for_each_detailed_block(ext, cb, closure);
> @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
>         }
>  }
>
> +struct bool_closure {
> +       bool ret;
> +};
> +
>  static void
> -is_rb(struct detailed_timing *t, void *data)
> +is_rb(const struct detailed_timing *t, void *c)
>  {
> -       u8 *r = (u8 *)t;
> +       struct bool_closure *closure = c;
> +       const u8 *r = (const u8 *)t;
>
>         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         if (r[15] & 0x10)
> -               *(bool *)data = true;
> +               closure->ret = true;
>  }
>
>  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
>  static bool
> -drm_monitor_supports_rb(struct edid *edid)
> +drm_monitor_supports_rb(const struct edid *edid)
>  {
>         if (edid->revision >= 4) {
> -               bool ret = false;
> -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> -               return ret;
> +               struct bool_closure closure = {
> +                       .ret = false,
> +               };
> +
> +               drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
> +
> +               return closure.ret;
>         }
>
>         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
>  }
>
> +struct data_closure {
> +       const u8 *data;
> +};
> +
>  static void
> -find_gtf2(struct detailed_timing *t, void *data)
> +do_find_gtf2(const struct detailed_timing *t, void *c)
>  {
> -       u8 *r = (u8 *)t;
> +       struct data_closure *closure = c;
> +       const u8 *r = (const u8 *)t;
>
>         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
>                 return;
>
>         if (r[10] == 0x02)
> -               *(u8 **)data = r;
> +               closure->data = r;
> +}
> +
> +static const u8 *
> +find_gtf2_descriptor(const struct edid *edid)
> +{
> +       struct data_closure closure = {};
> +
> +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
> +
> +       return closure.data;
>  }
>
>  /* Secondary GTF curve kicks in above some break frequency */
>  static int
> -drm_gtf2_hbreak(struct edid *edid)
> +drm_gtf2_hbreak(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> -       return r ? (r[12] * 2) : 0;
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
> +       return r ? r[12] * 2 : 0;
>  }
>
>  static int
> -drm_gtf2_2c(struct edid *edid)
> +drm_gtf2_2c(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[13] : 0;
>  }
>
>  static int
> -drm_gtf2_m(struct edid *edid)
> +drm_gtf2_m(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> -       return r ? (r[15] << 8) + r[14] : 0;
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
> +       return r ? (r[15] << 8) | r[14] : 0;
>  }
>
>  static int
> -drm_gtf2_k(struct edid *edid)
> +drm_gtf2_k(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[16] : 0;
>  }
>
>  static int
> -drm_gtf2_2j(struct edid *edid)
> +drm_gtf2_2j(const struct edid *edid)
>  {
> -       u8 *r = NULL;
> -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> +       const u8 *r = find_gtf2_descriptor(edid);
> +
>         return r ? r[17] : 0;
>  }
>
> @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
>   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
>   * @edid: EDID block to scan
>   */
> -static int standard_timing_level(struct edid *edid)
> +static int standard_timing_level(const struct edid *edid)
>  {
>         if (edid->revision >= 2) {
>                 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
> @@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
>   * and convert them into a real mode using CVT/GTF/DMT.
>   */
>  static struct drm_display_mode *
> -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> -            struct std_timing *t)
> +drm_mode_std(struct drm_connector *connector,
> +            const struct edid *edid,
> +            const struct std_timing *t)
>  {
>         struct drm_device *dev = connector->dev;
>         struct drm_display_mode *m, *mode = NULL;
> @@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
>   */
>  static void
>  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> -                           struct detailed_pixel_timing *pt)
> +                           const struct detailed_pixel_timing *pt)
>  {
>         int i;
>         static const struct {
> @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
>   * return a new struct drm_display_mode.
>   */
>  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> -                                                 struct edid *edid,
> -                                                 struct detailed_timing *timing,
> +                                                 const struct edid *edid,
> +                                                 const struct detailed_timing *timing,
>                                                   u32 quirks)
>  {
>         struct drm_display_mode *mode;
> -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> +       const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
>         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
>         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
>         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
> @@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>                 return NULL;
>
>         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> -               timing->pixel_clock = cpu_to_le16(1088);
> -
> -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> +               mode->clock = 1088 * 10;
> +       else
> +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
>
>         mode->hdisplay = hactive;
>         mode->hsync_start = mode->hdisplay + hsync_offset;
> @@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>         drm_mode_do_interlace_quirk(mode, pt);
>
>         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
> +               mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
> +       } else {
> +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
>         }
>
> -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> -
>  set_size:
>         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
>         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
> @@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
>
>  static bool
>  mode_in_hsync_range(const struct drm_display_mode *mode,
> -                   struct edid *edid, u8 *t)
> +                   const struct edid *edid, const u8 *t)
>  {
>         int hsync, hmin, hmax;
>
> @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
>
>  static bool
>  mode_in_vsync_range(const struct drm_display_mode *mode,
> -                   struct edid *edid, u8 *t)
> +                   const struct edid *edid, const u8 *t)
>  {
>         int vsync, vmin, vmax;
>
> @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
>  }
>
>  static u32
> -range_pixel_clock(struct edid *edid, u8 *t)
> +range_pixel_clock(const struct edid *edid, const u8 *t)
>  {
>         /* unspecified */
>         if (t[9] == 0 || t[9] == 255)
> @@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
>  }
>
>  static bool
> -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> -             struct detailed_timing *timing)
> +mode_in_range(const struct drm_display_mode *mode,
> +             const struct edid *edid,
> +             const struct detailed_timing *timing)
>  {
>         u32 max_clock;
> -       u8 *t = (u8 *)timing;
> +       const u8 *t = (const u8 *)timing;
>
>         if (!mode_in_hsync_range(mode, edid, t))
>                 return false;
> @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
>  }
>
>  static int
> -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_dmt_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
>  }
>
>  static int
> -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_gtf_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
>  }
>
>  static int
> -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> -                       struct detailed_timing *timing)
> +drm_cvt_modes_for_range(struct drm_connector *connector,
> +                       const struct edid *edid,
> +                       const struct detailed_timing *timing)
>  {
>         int i, modes = 0;
>         struct drm_display_mode *newmode;
> @@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
>  }
>
>  static void
> -do_inferred_modes(struct detailed_timing *timing, void *c)
> +do_inferred_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
> -       struct detailed_data_monitor_range *range = &data->data.range;
> +       const struct detailed_non_pixel *data = &timing->data.other_data;
> +       const struct detailed_data_monitor_range *range = &data->data.range;
>
>         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
>                 return;
> @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
>  }
>
>  static int
> -add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> +add_inferred_modes(struct drm_connector *connector,
> +                  const struct edid *edid)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
>         };
>
>         if (version_greater(edid, 1, 0))
> -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> +               drm_for_each_detailed_block((const u8 *)edid,
> +                                           do_inferred_modes,
>                                             &closure);
>
>         return closure.modes;
>  }
>
>  static int
> -drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> +drm_est3_modes(struct drm_connector *connector,
> +              const struct detailed_timing *timing)
>  {
>         int i, j, m, modes = 0;
>         struct drm_display_mode *mode;
> -       u8 *est = ((u8 *)timing) + 6;
> +       const u8 *est = ((const u8 *)timing) + 6;
>
>         for (i = 0; i < 6; i++) {
>                 for (j = 7; j >= 0; j--) {
> @@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
>  }
>
>  static void
> -do_established_modes(struct detailed_timing *timing, void *c)
> +do_established_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>
> @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
>   * (defined above).  Tease them out and add them to the global modes list.
>   */
>  static int
> -add_established_modes(struct drm_connector *connector, struct edid *edid)
> +add_established_modes(struct drm_connector *connector,
> +                     const struct edid *edid)
>  {
>         struct drm_device *dev = connector->dev;
>         unsigned long est_bits = edid->established_timings.t1 |
> @@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
>  }
>
>  static void
> -do_standard_modes(struct detailed_timing *timing, void *c)
> +do_standard_modes(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
> -       struct detailed_non_pixel *data = &timing->data.other_data;
> +       const struct detailed_non_pixel *data = &timing->data.other_data;
>         struct drm_connector *connector = closure->connector;
> -       struct edid *edid = closure->edid;
> +       const struct edid *edid = closure->edid;
>         int i;
>
>         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
>                 return;
>
>         for (i = 0; i < 6; i++) {
> -               struct std_timing *std = &data->data.timings[i];
> +               const struct std_timing *std = &data->data.timings[i];
>                 struct drm_display_mode *newmode;
>
>                 newmode = drm_mode_std(connector, edid, std);
> @@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
>   * GTF or CVT. Grab them from @edid and add them to the list.
>   */
>  static int
> -add_standard_modes(struct drm_connector *connector, struct edid *edid)
> +add_standard_modes(struct drm_connector *connector,
> +                  const struct edid *edid)
>  {
>         int i, modes = 0;
>         struct detailed_mode_closure closure = {
> @@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
>  }
>
>  static int drm_cvt_modes(struct drm_connector *connector,
> -                        struct detailed_timing *timing)
> +                        const struct detailed_timing *timing)
>  {
>         int i, j, modes = 0;
>         struct drm_display_mode *newmode;
>         struct drm_device *dev = connector->dev;
> -       struct cvt_timing *cvt;
>         const int rates[] = { 60, 85, 75, 60, 50 };
>         const u8 empty[3] = { 0, 0, 0 };
>
>         for (i = 0; i < 4; i++) {
>                 int uninitialized_var(width), height;
> -               cvt = &(timing->data.other_data.data.cvt[i]);
> +               const struct cvt_timing *cvt =
> +                       &timing->data.other_data.data.cvt[i];
>
>                 if (!memcmp(cvt->code, empty, 3))
>                         continue;
> @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
>  }
>
>  static void
> -do_cvt_mode(struct detailed_timing *timing, void *c)
> +do_cvt_mode(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>
> @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
>  }
>
>  static int
> -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> +add_cvt_modes(struct drm_connector *connector,
> +             const struct edid *edid)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
>  static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
>
>  static void
> -do_detailed_mode(struct detailed_timing *timing, void *c)
> +do_detailed_mode(const struct detailed_timing *timing, void *c)
>  {
>         struct detailed_mode_closure *closure = c;
>         struct drm_display_mode *newmode;
> @@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
>   * @quirks: quirks to apply
>   */
>  static int
> -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> -                  u32 quirks)
> +add_detailed_modes(struct drm_connector *connector,
> +                  struct edid *edid, u32 quirks)
>  {
>         struct detailed_mode_closure closure = {
>                 .connector = connector,
> @@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
>  /*
>   * Search EDID for CEA extension block.
>   */
> -static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> +static const u8 *drm_find_edid_extension(const struct edid *edid,
> +                                        int ext_id)
>  {
> -       u8 *edid_ext = NULL;
> +       const u8 *edid_ext = NULL;
>         int i;
>
>         /* No EDID or EDID extensions */
> @@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
>
>         /* Find CEA extension */
>         for (i = 0; i < edid->extensions; i++) {
> -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
>                 if (edid_ext[0] == ext_id)
>                         break;
>         }
> @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
>  }
>
>
> -static u8 *drm_find_displayid_extension(const struct edid *edid)
> +static const u8 *drm_find_displayid_extension(const struct edid *edid)
>  {
>         return drm_find_edid_extension(edid, DISPLAYID_EXT);
>  }
>
> -static u8 *drm_find_cea_extension(const struct edid *edid)
> +static const u8 *drm_find_cea_extension(const struct edid *edid)
>  {
>         int ret;
>         int idx = 1;
>         int length = EDID_LENGTH;
> -       struct displayid_block *block;
> -       u8 *cea;
> -       u8 *displayid;
> +       const struct displayid_block *block;
> +       const u8 *cea;
> +       const u8 *displayid;
>
>         /* Look for a top level CEA extension block */
>         cea = drm_find_edid_extension(edid, CEA_EXT);
> @@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
>  }
>
>  static void
> -monitor_name(struct detailed_timing *t, void *data)
> +monitor_name(const struct detailed_timing *t, void *c)
>  {
> +       struct data_closure *closure = c;
> +
>         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
>                 return;
>
> -       *(u8 **)data = t->data.other_data.data.str.str;
> +       closure->data = t->data.other_data.data.str.str;
>  }
>
>  static int get_monitor_name(struct edid *edid, char name[13])
>  {
> -       char *edid_name = NULL;
> +       struct data_closure closure = {};
>         int mnl;
>
>         if (!edid || !name)
>                 return 0;
>
> -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> -               if (edid_name[mnl] == 0x0a)
> +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> +               if (closure.data[mnl] == 0x0a)
>                         break;
>
> -               name[mnl] = edid_name[mnl];
> +               name[mnl] = closure.data[mnl];
>         }
>
>         return mnl;
> @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
>  static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
>  {
>         uint8_t *eld = connector->eld;
> -       u8 *cea;
> -       u8 *db;
> +       const u8 *cea;
>         int total_sad_count = 0;
>         int mnl;
> -       int dbl;
>
>         clear_eld(connector);
>
> @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
>                 }
>
>                 for_each_cea_db(cea, i, start, end) {
> -                       db = &cea[i];
> -                       dbl = cea_db_payload_len(db);
> +                       const u8 *db = &cea[i];
> +                       int dbl = cea_db_payload_len(db);
>
>                         switch (cea_db_tag(db)) {
>                                 int sad_count;
> @@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>  {
>         int count = 0;
>         int i, start, end, dbl;
> -       u8 *cea;
> +       const u8 *cea;
>
>         cea = drm_find_cea_extension(edid);
>         if (!cea) {
> @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>         }
>
>         for_each_cea_db(cea, i, start, end) {
> -               u8 *db = &cea[i];
> +               const u8 *db = &cea[i];
>
>                 if (cea_db_tag(db) == AUDIO_BLOCK) {
>                         int j;
> @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
>                         if (!*sads)
>                                 return -ENOMEM;
>                         for (j = 0; j < count; j++) {
> -                               u8 *sad = &db[1 + j * 3];
> +                               const u8 *sad = &db[1 + j * 3];
>
>                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
>                                 (*sads)[j].channels = sad[0] & 0x7;
> @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
>   */
>  bool drm_detect_hdmi_monitor(struct edid *edid)
>  {
> -       u8 *edid_ext;
> +       const u8 *edid_ext;
>         int i;
>         int start_offset, end_offset;
>
> @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
>   */
>  bool drm_detect_monitor_audio(struct edid *edid)
>  {
> -       u8 *edid_ext;
> +       const u8 *edid_ext;
>         int i, j;
>         bool has_audio = false;
>         int start_offset, end_offset;
> @@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
>         return quirks;
>  }
>
> -static int validate_displayid(u8 *displayid, int length, int idx)
> +static int validate_displayid(const u8 *displayid, int length, int idx)
>  {
>         int i;
>         u8 csum = 0;
> -       struct displayid_hdr *base;
> +       const struct displayid_hdr *base;
>
> -       base = (struct displayid_hdr *)&displayid[idx];
> +       base = (const struct displayid_hdr *)&displayid[idx];
>
>         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
>                       base->rev, base->bytes, base->prod_id, base->ext_count);
> @@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
>  }
>
>  static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
> -                                                           struct displayid_detailed_timings_1 *timings)
> +                                                           const struct displayid_detailed_timings_1 *timings)
>  {
>         struct drm_display_mode *mode;
>         unsigned pixel_clock = (timings->pixel_clock[0] |
> @@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
>         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
>         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
>         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> +
>         mode = drm_mode_create(dev);
>         if (!mode)
>                 return NULL;
> @@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
>  }
>
>  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> -                                         struct displayid_block *block)
> +                                         const struct displayid_block *block)
>  {
> -       struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
> +       const struct displayid_detailed_timing_block *det =
> +               (const struct displayid_detailed_timing_block *)block;
>         int i;
>         int num_timings;
>         struct drm_display_mode *newmode;
> @@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
>
>         num_timings = block->num_bytes / 20;
>         for (i = 0; i < num_timings; i++) {
> -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> +               const struct displayid_detailed_timings_1 *timings = &det->timings[i];
>
>                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
>                 if (!newmode)
> @@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
>  }
>
>  static int add_displayid_detailed_modes(struct drm_connector *connector,
> -                                       struct edid *edid)
> +                                       const struct edid *edid)
>  {
> -       u8 *displayid;
> +       const u8 *displayid;
>         int ret;
>         int idx = 1;
>         int length = EDID_LENGTH;
> -       struct displayid_block *block;
> +       const struct displayid_block *block;
>         int num_modes = 0;
>
>         displayid = drm_find_displayid_extension(edid);
> @@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
>  EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
>
>  static int drm_parse_tiled_block(struct drm_connector *connector,
> -                                struct displayid_block *block)
> +                                const struct displayid_block *block)
>  {
> -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> +       const struct displayid_tiled_block *tile =
> +               (const struct displayid_tiled_block *)block;
>         u16 w, h;
>         u8 tile_v_loc, tile_h_loc;
>         u8 num_v_tile, num_h_tile;
> @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
>  }
>
>  static int drm_parse_display_id(struct drm_connector *connector,
> -                               u8 *displayid, int length,
> +                               const u8 *displayid, int length,
>                                 bool is_edid_extension)
>  {
>         /* if this is an EDID extension the first byte will be 0x70 */
>         int idx = 0;
> -       struct displayid_block *block;
> +       const struct displayid_block *block;
>         int ret;
>
>         if (is_edid_extension)
> @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
>  }
>
>  static void drm_get_displayid(struct drm_connector *connector,
> -                             struct edid *edid)
> +                             const struct edid *edid)
>  {
> -       void *displayid = NULL;
> +       const void *displayid;
>         int ret;
> +
>         connector->has_tile = false;
> +
>         displayid = drm_find_displayid_extension(edid);
>         if (!displayid) {
>                 /* drop reference to any tile group we had */
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 2113500b4075..c0f9ce3f4b24 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1580,9 +1580,9 @@ struct drm_tile_group {
>  };
>
>  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> -                                                 char topology[8]);
> +                                                 const u8 topology[8]);
>  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> -                                              char topology[8]);
> +                                              const u8 topology[8]);
>  void drm_mode_put_tile_group(struct drm_device *dev,
>                              struct drm_tile_group *tg);
>
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-01-27 22:38     ` Alex Deucher
  -1 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:38 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> I'm curious if there are any bogus 18 byte descriptors around.
> Let's dump them out if we encounter them.
>
> Not sure we'd actually want this, but at least I get to see
> if our CI has anything that hits this :)
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 8e76efe1654d..4d8303e56536 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
>                 d[2] == 0x00 && d[3] == tag;
>  }
>
> +static bool is_any_display_descriptor(const u8 d[18])
> +{
> +       return d[0] == 0x00 && d[1] == 0x00 &&
> +               d[2] == 0x00;
> +}
> +
>  static bool is_detailed_timing_descriptor(const u8 d[18])
>  {
>         return d[0] != 0x00 || d[1] != 0x00;
> @@ -2209,6 +2215,15 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
>
>  typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
>
> +static void do_detailed_block(const u8 d[18], detailed_cb *cb, void *closure)
> +{
> +       if (!is_detailed_timing_descriptor(d) &&
> +           !is_any_display_descriptor(d))
> +               DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n", 18, d);
> +
> +       cb((const struct detailed_timing *)d, closure);
> +}
> +
>  static void
>  cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
> @@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
> -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> +               do_detailed_block(det_base + 18 * i, cb, closure);
>  }
>
>  static void
> @@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>                 return; /* unknown version */
>
>         for (i = 0; i < n; i++)
> -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> +               do_detailed_block(det_base + 18 * i, cb, closure);
>  }
>
>  static void
> @@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
>                 return;
>
>         for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
> -               cb(&(edid->detailed_timings[i]), closure);
> +               do_detailed_block((const u8 *)&edid->detailed_timings[i],
> +                                 cb, closure);
>
>         for (i = 1; i <= raw_edid[0x7e]; i++) {
>                 const u8 *ext = raw_edid + (i * EDID_LENGTH);
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
@ 2020-01-27 22:38     ` Alex Deucher
  0 siblings, 0 replies; 67+ messages in thread
From: Alex Deucher @ 2020-01-27 22:38 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Intel Graphics Development, Maling list - DRI developers

On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
<ville.syrjala@linux.intel.com> wrote:
>
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
>
> I'm curious if there are any bogus 18 byte descriptors around.
> Let's dump them out if we encounter them.
>
> Not sure we'd actually want this, but at least I get to see
> if our CI has anything that hits this :)
>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/drm_edid.c | 22 +++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 8e76efe1654d..4d8303e56536 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8 tag)
>                 d[2] == 0x00 && d[3] == tag;
>  }
>
> +static bool is_any_display_descriptor(const u8 d[18])
> +{
> +       return d[0] == 0x00 && d[1] == 0x00 &&
> +               d[2] == 0x00;
> +}
> +
>  static bool is_detailed_timing_descriptor(const u8 d[18])
>  {
>         return d[0] != 0x00 || d[1] != 0x00;
> @@ -2209,6 +2215,15 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
>
>  typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
>
> +static void do_detailed_block(const u8 d[18], detailed_cb *cb, void *closure)
> +{
> +       if (!is_detailed_timing_descriptor(d) &&
> +           !is_any_display_descriptor(d))
> +               DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n", 18, d);
> +
> +       cb((const struct detailed_timing *)d, closure);
> +}
> +
>  static void
>  cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>  {
> @@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>
>         n = (127 - d) / 18;
>         for (i = 0; i < n; i++)
> -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> +               do_detailed_block(det_base + 18 * i, cb, closure);
>  }
>
>  static void
> @@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
>                 return; /* unknown version */
>
>         for (i = 0; i < n; i++)
> -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> +               do_detailed_block(det_base + 18 * i, cb, closure);
>  }
>
>  static void
> @@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
>                 return;
>
>         for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
> -               cb(&(edid->detailed_timings[i]), closure);
> +               do_detailed_block((const u8 *)&edid->detailed_timings[i],
> +                                 cb, closure);
>
>         for (i = 1; i <= raw_edid[0x7e]; i++) {
>                 const u8 *ext = raw_edid + (i * EDID_LENGTH);
> --
> 2.24.1
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
  2020-01-27 22:30     ` [Intel-gfx] " Alex Deucher
@ 2020-01-28 11:44       ` Ville Syrjälä
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 11:44 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Mon, Jan 27, 2020 at 05:30:42PM -0500, Alex Deucher wrote:
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > After much head scratching I managed to convince myself that
> > for_each_displayid_db() has already done the bounds checks for
> > the DispID CEA data block. Which is why we don't need to repeat
> > them in cea_db_offsets(). To avoid having to go through that
> > pain again in the future add a comment which explains this fact.
> >
> > Cc: Andres Rodriguez <andresx7@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 3df5744026b0..0369a54e3d32 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
> >          *   no non-DTD data.
> >          */
> >         if (cea[0] == DATA_BLOCK_CTA) {
> > +               /*
> > +                * for_each_displayid_db() has already verified
> > +                * that these stay within expected bounds.
> > +                */
> 
> I think the preferred format is to have the start of the comment be on
> the first line after the /* with that fixed:

Nope.

> Acked-by: Alex Deucher <alexander.deucher@amd.com>
> 
> >                 *start = 3;
> >                 *end = *start + cea[2];
> >         } else if (cea[0] == CEA_EXT) {
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
@ 2020-01-28 11:44       ` Ville Syrjälä
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 11:44 UTC (permalink / raw)
  To: Alex Deucher
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers

On Mon, Jan 27, 2020 at 05:30:42PM -0500, Alex Deucher wrote:
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > After much head scratching I managed to convince myself that
> > for_each_displayid_db() has already done the bounds checks for
> > the DispID CEA data block. Which is why we don't need to repeat
> > them in cea_db_offsets(). To avoid having to go through that
> > pain again in the future add a comment which explains this fact.
> >
> > Cc: Andres Rodriguez <andresx7@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 4 ++++
> >  1 file changed, 4 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 3df5744026b0..0369a54e3d32 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
> >          *   no non-DTD data.
> >          */
> >         if (cea[0] == DATA_BLOCK_CTA) {
> > +               /*
> > +                * for_each_displayid_db() has already verified
> > +                * that these stay within expected bounds.
> > +                */
> 
> I think the preferred format is to have the start of the comment be on
> the first line after the /* with that fixed:

Nope.

> Acked-by: Alex Deucher <alexander.deucher@amd.com>
> 
> >                 *start = 3;
> >                 *end = *start + cea[2];
> >         } else if (cea[0] == CEA_EXT) {
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 7/8] drm/edid: Constify lots of things
  2020-01-27 22:38     ` [Intel-gfx] " Alex Deucher
@ 2020-01-28 11:49       ` Ville Syrjälä
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 11:49 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Intel Graphics Development, Maling list - DRI developers

On Mon, Jan 27, 2020 at 05:38:15PM -0500, Alex Deucher wrote:
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Let's try to make a lot more stuff const in the edid parser.
> >
> > The "downside" is that we can no longer mangle the EDID in the
> > middle of the parsing to apply quirks (drm_mode_detailed()).
> > I don't really think mangling the blob itself is such a great
> > idea anyway so I won't miss that part. But if we do want it
> > back I guess we should do the mangling in one explicit place
> > before we otherwise parse the EDID.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I generally agree, but are there any userspace expectations that they
> will be getting a corrected EDID in some cases?

Not sure. I think the the only thing we're fixing up is some DTDs so
at least there's a better way for userspace to get the fixed
information (getconnector ioctl). I guess Xorg is still parsing the
EDID though, but it should have more or less the same quirks in its
parser.

> 
> Alex
> 
> > ---
> >  drivers/gpu/drm/drm_connector.c |   4 +-
> >  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
> >  include/drm/drm_connector.h     |   4 +-
> >  3 files changed, 176 insertions(+), 135 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index f632ca05960e..92a5cd6ff6b1 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
> >   * tile group or NULL if not found.
> >   */
> >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > -                                              char topology[8])
> > +                                              const u8 topology[8])
> >  {
> >         struct drm_tile_group *tg;
> >         int id;
> > @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
> >   * new tile group or NULL.
> >   */
> >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > -                                                 char topology[8])
> > +                                                 const u8 topology[8])
> >  {
> >         struct drm_tile_group *tg;
> >         int ret;
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index fd9b724067a7..8e76efe1654d 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -88,7 +88,7 @@
> >
> >  struct detailed_mode_closure {
> >         struct drm_connector *connector;
> > -       struct edid *edid;
> > +       const struct edid *edid;
> >         bool preferred;
> >         u32 quirks;
> >         int modes;
> > @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
> >                  "Minimum number of valid EDID header bytes (0-8, default 6)");
> >
> >  static void drm_get_displayid(struct drm_connector *connector,
> > -                             struct edid *edid);
> > -static int validate_displayid(u8 *displayid, int length, int idx);
> > +                             const struct edid *edid);
> > +static int validate_displayid(const u8 *displayid, int length, int idx);
> >
> >  static int drm_edid_block_checksum(const u8 *raw_edid)
> >  {
> > @@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
> >         return d[0] != 0x00 || d[1] != 0x00;
> >  }
> >
> > -typedef void detailed_cb(struct detailed_timing *timing, void *closure);
> > +typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
> >
> >  static void
> > -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
> >  {
> >         int i, n;
> >         u8 d = ext[0x02];
> > -       u8 *det_base = ext + d;
> > +       const u8 *det_base = ext + d;
> >
> >         if (d < 4 || d > 127)
> >                 return;
> >
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> >  }
> >
> >  static void
> > -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
> >  {
> >         unsigned int i, n = min((int)ext[0x02], 6);
> > -       u8 *det_base = ext + 5;
> > +       const u8 *det_base = ext + 5;
> >
> >         if (ext[0x01] != 1)
> >                 return; /* unknown version */
> >
> >         for (i = 0; i < n; i++)
> > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> >  }
> >
> >  static void
> > -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> > +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
> >  {
> > +       const struct edid *edid = (struct edid *)raw_edid;
> >         int i;
> > -       struct edid *edid = (struct edid *)raw_edid;
> >
> >         if (edid == NULL)
> >                 return;
> > @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> >                 cb(&(edid->detailed_timings[i]), closure);
> >
> >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> > -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> > +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
> >                 switch (*ext) {
> >                 case CEA_EXT:
> >                         cea_for_each_detailed_block(ext, cb, closure);
> > @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> >         }
> >  }
> >
> > +struct bool_closure {
> > +       bool ret;
> > +};
> > +
> >  static void
> > -is_rb(struct detailed_timing *t, void *data)
> > +is_rb(const struct detailed_timing *t, void *c)
> >  {
> > -       u8 *r = (u8 *)t;
> > +       struct bool_closure *closure = c;
> > +       const u8 *r = (const u8 *)t;
> >
> >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         if (r[15] & 0x10)
> > -               *(bool *)data = true;
> > +               closure->ret = true;
> >  }
> >
> >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
> >  static bool
> > -drm_monitor_supports_rb(struct edid *edid)
> > +drm_monitor_supports_rb(const struct edid *edid)
> >  {
> >         if (edid->revision >= 4) {
> > -               bool ret = false;
> > -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> > -               return ret;
> > +               struct bool_closure closure = {
> > +                       .ret = false,
> > +               };
> > +
> > +               drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
> > +
> > +               return closure.ret;
> >         }
> >
> >         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
> >  }
> >
> > +struct data_closure {
> > +       const u8 *data;
> > +};
> > +
> >  static void
> > -find_gtf2(struct detailed_timing *t, void *data)
> > +do_find_gtf2(const struct detailed_timing *t, void *c)
> >  {
> > -       u8 *r = (u8 *)t;
> > +       struct data_closure *closure = c;
> > +       const u8 *r = (const u8 *)t;
> >
> >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         if (r[10] == 0x02)
> > -               *(u8 **)data = r;
> > +               closure->data = r;
> > +}
> > +
> > +static const u8 *
> > +find_gtf2_descriptor(const struct edid *edid)
> > +{
> > +       struct data_closure closure = {};
> > +
> > +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
> > +
> > +       return closure.data;
> >  }
> >
> >  /* Secondary GTF curve kicks in above some break frequency */
> >  static int
> > -drm_gtf2_hbreak(struct edid *edid)
> > +drm_gtf2_hbreak(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > -       return r ? (r[12] * 2) : 0;
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> > +       return r ? r[12] * 2 : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_2c(struct edid *edid)
> > +drm_gtf2_2c(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[13] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_m(struct edid *edid)
> > +drm_gtf2_m(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > -       return r ? (r[15] << 8) + r[14] : 0;
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> > +       return r ? (r[15] << 8) | r[14] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_k(struct edid *edid)
> > +drm_gtf2_k(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[16] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_2j(struct edid *edid)
> > +drm_gtf2_2j(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[17] : 0;
> >  }
> >
> > @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
> >   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
> >   * @edid: EDID block to scan
> >   */
> > -static int standard_timing_level(struct edid *edid)
> > +static int standard_timing_level(const struct edid *edid)
> >  {
> >         if (edid->revision >= 2) {
> >                 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
> > @@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
> >   * and convert them into a real mode using CVT/GTF/DMT.
> >   */
> >  static struct drm_display_mode *
> > -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > -            struct std_timing *t)
> > +drm_mode_std(struct drm_connector *connector,
> > +            const struct edid *edid,
> > +            const struct std_timing *t)
> >  {
> >         struct drm_device *dev = connector->dev;
> >         struct drm_display_mode *m, *mode = NULL;
> > @@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
> >   */
> >  static void
> >  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> > -                           struct detailed_pixel_timing *pt)
> > +                           const struct detailed_pixel_timing *pt)
> >  {
> >         int i;
> >         static const struct {
> > @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> >   * return a new struct drm_display_mode.
> >   */
> >  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> > -                                                 struct edid *edid,
> > -                                                 struct detailed_timing *timing,
> > +                                                 const struct edid *edid,
> > +                                                 const struct detailed_timing *timing,
> >                                                   u32 quirks)
> >  {
> >         struct drm_display_mode *mode;
> > -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> > +       const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> >         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
> >         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
> >         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
> > @@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >                 return NULL;
> >
> >         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> > -               timing->pixel_clock = cpu_to_le16(1088);
> > -
> > -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > +               mode->clock = 1088 * 10;
> > +       else
> > +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> >
> >         mode->hdisplay = hactive;
> >         mode->hsync_start = mode->hdisplay + hsync_offset;
> > @@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >         drm_mode_do_interlace_quirk(mode, pt);
> >
> >         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> > -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
> > +               mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
> > +       } else {
> > +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> >         }
> >
> > -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > -
> >  set_size:
> >         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
> >         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
> > @@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >
> >  static bool
> >  mode_in_hsync_range(const struct drm_display_mode *mode,
> > -                   struct edid *edid, u8 *t)
> > +                   const struct edid *edid, const u8 *t)
> >  {
> >         int hsync, hmin, hmax;
> >
> > @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
> >
> >  static bool
> >  mode_in_vsync_range(const struct drm_display_mode *mode,
> > -                   struct edid *edid, u8 *t)
> > +                   const struct edid *edid, const u8 *t)
> >  {
> >         int vsync, vmin, vmax;
> >
> > @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
> >  }
> >
> >  static u32
> > -range_pixel_clock(struct edid *edid, u8 *t)
> > +range_pixel_clock(const struct edid *edid, const u8 *t)
> >  {
> >         /* unspecified */
> >         if (t[9] == 0 || t[9] == 255)
> > @@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
> >  }
> >
> >  static bool
> > -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> > -             struct detailed_timing *timing)
> > +mode_in_range(const struct drm_display_mode *mode,
> > +             const struct edid *edid,
> > +             const struct detailed_timing *timing)
> >  {
> >         u32 max_clock;
> > -       u8 *t = (u8 *)timing;
> > +       const u8 *t = (const u8 *)timing;
> >
> >         if (!mode_in_hsync_range(mode, edid, t))
> >                 return false;
> > @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
> >  }
> >
> >  static int
> > -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_dmt_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
> >  }
> >
> >  static int
> > -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_gtf_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> >  }
> >
> >  static int
> > -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_cvt_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> >  }
> >
> >  static void
> > -do_inferred_modes(struct detailed_timing *timing, void *c)
> > +do_inferred_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > -       struct detailed_data_monitor_range *range = &data->data.range;
> > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> > +       const struct detailed_data_monitor_range *range = &data->data.range;
> >
> >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> > @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
> >  }
> >
> >  static int
> > -add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> > +add_inferred_modes(struct drm_connector *connector,
> > +                  const struct edid *edid)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> >         };
> >
> >         if (version_greater(edid, 1, 0))
> > -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> > +               drm_for_each_detailed_block((const u8 *)edid,
> > +                                           do_inferred_modes,
> >                                             &closure);
> >
> >         return closure.modes;
> >  }
> >
> >  static int
> > -drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> > +drm_est3_modes(struct drm_connector *connector,
> > +              const struct detailed_timing *timing)
> >  {
> >         int i, j, m, modes = 0;
> >         struct drm_display_mode *mode;
> > -       u8 *est = ((u8 *)timing) + 6;
> > +       const u8 *est = ((const u8 *)timing) + 6;
> >
> >         for (i = 0; i < 6; i++) {
> >                 for (j = 7; j >= 0; j--) {
> > @@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> >  }
> >
> >  static void
> > -do_established_modes(struct detailed_timing *timing, void *c)
> > +do_established_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >
> > @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
> >   * (defined above).  Tease them out and add them to the global modes list.
> >   */
> >  static int
> > -add_established_modes(struct drm_connector *connector, struct edid *edid)
> > +add_established_modes(struct drm_connector *connector,
> > +                     const struct edid *edid)
> >  {
> >         struct drm_device *dev = connector->dev;
> >         unsigned long est_bits = edid->established_timings.t1 |
> > @@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
> >  }
> >
> >  static void
> > -do_standard_modes(struct detailed_timing *timing, void *c)
> > +do_standard_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct drm_connector *connector = closure->connector;
> > -       struct edid *edid = closure->edid;
> > +       const struct edid *edid = closure->edid;
> >         int i;
> >
> >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> >                 return;
> >
> >         for (i = 0; i < 6; i++) {
> > -               struct std_timing *std = &data->data.timings[i];
> > +               const struct std_timing *std = &data->data.timings[i];
> >                 struct drm_display_mode *newmode;
> >
> >                 newmode = drm_mode_std(connector, edid, std);
> > @@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
> >   * GTF or CVT. Grab them from @edid and add them to the list.
> >   */
> >  static int
> > -add_standard_modes(struct drm_connector *connector, struct edid *edid)
> > +add_standard_modes(struct drm_connector *connector,
> > +                  const struct edid *edid)
> >  {
> >         int i, modes = 0;
> >         struct detailed_mode_closure closure = {
> > @@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
> >  }
> >
> >  static int drm_cvt_modes(struct drm_connector *connector,
> > -                        struct detailed_timing *timing)
> > +                        const struct detailed_timing *timing)
> >  {
> >         int i, j, modes = 0;
> >         struct drm_display_mode *newmode;
> >         struct drm_device *dev = connector->dev;
> > -       struct cvt_timing *cvt;
> >         const int rates[] = { 60, 85, 75, 60, 50 };
> >         const u8 empty[3] = { 0, 0, 0 };
> >
> >         for (i = 0; i < 4; i++) {
> >                 int uninitialized_var(width), height;
> > -               cvt = &(timing->data.other_data.data.cvt[i]);
> > +               const struct cvt_timing *cvt =
> > +                       &timing->data.other_data.data.cvt[i];
> >
> >                 if (!memcmp(cvt->code, empty, 3))
> >                         continue;
> > @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
> >  }
> >
> >  static void
> > -do_cvt_mode(struct detailed_timing *timing, void *c)
> > +do_cvt_mode(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >
> > @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
> >  }
> >
> >  static int
> > -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > +add_cvt_modes(struct drm_connector *connector,
> > +             const struct edid *edid)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> >  static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
> >
> >  static void
> > -do_detailed_mode(struct detailed_timing *timing, void *c)
> > +do_detailed_mode(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >         struct drm_display_mode *newmode;
> > @@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
> >   * @quirks: quirks to apply
> >   */
> >  static int
> > -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> > -                  u32 quirks)
> > +add_detailed_modes(struct drm_connector *connector,
> > +                  struct edid *edid, u32 quirks)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> >  /*
> >   * Search EDID for CEA extension block.
> >   */
> > -static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> > +static const u8 *drm_find_edid_extension(const struct edid *edid,
> > +                                        int ext_id)
> >  {
> > -       u8 *edid_ext = NULL;
> > +       const u8 *edid_ext = NULL;
> >         int i;
> >
> >         /* No EDID or EDID extensions */
> > @@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> >
> >         /* Find CEA extension */
> >         for (i = 0; i < edid->extensions; i++) {
> > -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> > +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
> >                 if (edid_ext[0] == ext_id)
> >                         break;
> >         }
> > @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> >  }
> >
> >
> > -static u8 *drm_find_displayid_extension(const struct edid *edid)
> > +static const u8 *drm_find_displayid_extension(const struct edid *edid)
> >  {
> >         return drm_find_edid_extension(edid, DISPLAYID_EXT);
> >  }
> >
> > -static u8 *drm_find_cea_extension(const struct edid *edid)
> > +static const u8 *drm_find_cea_extension(const struct edid *edid)
> >  {
> >         int ret;
> >         int idx = 1;
> >         int length = EDID_LENGTH;
> > -       struct displayid_block *block;
> > -       u8 *cea;
> > -       u8 *displayid;
> > +       const struct displayid_block *block;
> > +       const u8 *cea;
> > +       const u8 *displayid;
> >
> >         /* Look for a top level CEA extension block */
> >         cea = drm_find_edid_extension(edid, CEA_EXT);
> > @@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
> >  }
> >
> >  static void
> > -monitor_name(struct detailed_timing *t, void *data)
> > +monitor_name(const struct detailed_timing *t, void *c)
> >  {
> > +       struct data_closure *closure = c;
> > +
> >         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> >                 return;
> >
> > -       *(u8 **)data = t->data.other_data.data.str.str;
> > +       closure->data = t->data.other_data.data.str.str;
> >  }
> >
> >  static int get_monitor_name(struct edid *edid, char name[13])
> >  {
> > -       char *edid_name = NULL;
> > +       struct data_closure closure = {};
> >         int mnl;
> >
> >         if (!edid || !name)
> >                 return 0;
> >
> > -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> > -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> > -               if (edid_name[mnl] == 0x0a)
> > +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> > +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> > +               if (closure.data[mnl] == 0x0a)
> >                         break;
> >
> > -               name[mnl] = edid_name[mnl];
> > +               name[mnl] = closure.data[mnl];
> >         }
> >
> >         return mnl;
> > @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
> >  static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> >  {
> >         uint8_t *eld = connector->eld;
> > -       u8 *cea;
> > -       u8 *db;
> > +       const u8 *cea;
> >         int total_sad_count = 0;
> >         int mnl;
> > -       int dbl;
> >
> >         clear_eld(connector);
> >
> > @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> >                 }
> >
> >                 for_each_cea_db(cea, i, start, end) {
> > -                       db = &cea[i];
> > -                       dbl = cea_db_payload_len(db);
> > +                       const u8 *db = &cea[i];
> > +                       int dbl = cea_db_payload_len(db);
> >
> >                         switch (cea_db_tag(db)) {
> >                                 int sad_count;
> > @@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >  {
> >         int count = 0;
> >         int i, start, end, dbl;
> > -       u8 *cea;
> > +       const u8 *cea;
> >
> >         cea = drm_find_cea_extension(edid);
> >         if (!cea) {
> > @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >         }
> >
> >         for_each_cea_db(cea, i, start, end) {
> > -               u8 *db = &cea[i];
> > +               const u8 *db = &cea[i];
> >
> >                 if (cea_db_tag(db) == AUDIO_BLOCK) {
> >                         int j;
> > @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >                         if (!*sads)
> >                                 return -ENOMEM;
> >                         for (j = 0; j < count; j++) {
> > -                               u8 *sad = &db[1 + j * 3];
> > +                               const u8 *sad = &db[1 + j * 3];
> >
> >                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
> >                                 (*sads)[j].channels = sad[0] & 0x7;
> > @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
> >   */
> >  bool drm_detect_hdmi_monitor(struct edid *edid)
> >  {
> > -       u8 *edid_ext;
> > +       const u8 *edid_ext;
> >         int i;
> >         int start_offset, end_offset;
> >
> > @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
> >   */
> >  bool drm_detect_monitor_audio(struct edid *edid)
> >  {
> > -       u8 *edid_ext;
> > +       const u8 *edid_ext;
> >         int i, j;
> >         bool has_audio = false;
> >         int start_offset, end_offset;
> > @@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
> >         return quirks;
> >  }
> >
> > -static int validate_displayid(u8 *displayid, int length, int idx)
> > +static int validate_displayid(const u8 *displayid, int length, int idx)
> >  {
> >         int i;
> >         u8 csum = 0;
> > -       struct displayid_hdr *base;
> > +       const struct displayid_hdr *base;
> >
> > -       base = (struct displayid_hdr *)&displayid[idx];
> > +       base = (const struct displayid_hdr *)&displayid[idx];
> >
> >         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> >                       base->rev, base->bytes, base->prod_id, base->ext_count);
> > @@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
> >  }
> >
> >  static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
> > -                                                           struct displayid_detailed_timings_1 *timings)
> > +                                                           const struct displayid_detailed_timings_1 *timings)
> >  {
> >         struct drm_display_mode *mode;
> >         unsigned pixel_clock = (timings->pixel_clock[0] |
> > @@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
> >         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
> >         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
> >         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> > +
> >         mode = drm_mode_create(dev);
> >         if (!mode)
> >                 return NULL;
> > @@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
> >  }
> >
> >  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> > -                                         struct displayid_block *block)
> > +                                         const struct displayid_block *block)
> >  {
> > -       struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
> > +       const struct displayid_detailed_timing_block *det =
> > +               (const struct displayid_detailed_timing_block *)block;
> >         int i;
> >         int num_timings;
> >         struct drm_display_mode *newmode;
> > @@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> >
> >         num_timings = block->num_bytes / 20;
> >         for (i = 0; i < num_timings; i++) {
> > -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> > +               const struct displayid_detailed_timings_1 *timings = &det->timings[i];
> >
> >                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
> >                 if (!newmode)
> > @@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> >  }
> >
> >  static int add_displayid_detailed_modes(struct drm_connector *connector,
> > -                                       struct edid *edid)
> > +                                       const struct edid *edid)
> >  {
> > -       u8 *displayid;
> > +       const u8 *displayid;
> >         int ret;
> >         int idx = 1;
> >         int length = EDID_LENGTH;
> > -       struct displayid_block *block;
> > +       const struct displayid_block *block;
> >         int num_modes = 0;
> >
> >         displayid = drm_find_displayid_extension(edid);
> > @@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >  EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
> >
> >  static int drm_parse_tiled_block(struct drm_connector *connector,
> > -                                struct displayid_block *block)
> > +                                const struct displayid_block *block)
> >  {
> > -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> > +       const struct displayid_tiled_block *tile =
> > +               (const struct displayid_tiled_block *)block;
> >         u16 w, h;
> >         u8 tile_v_loc, tile_h_loc;
> >         u8 num_v_tile, num_h_tile;
> > @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
> >  }
> >
> >  static int drm_parse_display_id(struct drm_connector *connector,
> > -                               u8 *displayid, int length,
> > +                               const u8 *displayid, int length,
> >                                 bool is_edid_extension)
> >  {
> >         /* if this is an EDID extension the first byte will be 0x70 */
> >         int idx = 0;
> > -       struct displayid_block *block;
> > +       const struct displayid_block *block;
> >         int ret;
> >
> >         if (is_edid_extension)
> > @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
> >  }
> >
> >  static void drm_get_displayid(struct drm_connector *connector,
> > -                             struct edid *edid)
> > +                             const struct edid *edid)
> >  {
> > -       void *displayid = NULL;
> > +       const void *displayid;
> >         int ret;
> > +
> >         connector->has_tile = false;
> > +
> >         displayid = drm_find_displayid_extension(edid);
> >         if (!displayid) {
> >                 /* drop reference to any tile group we had */
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 2113500b4075..c0f9ce3f4b24 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -1580,9 +1580,9 @@ struct drm_tile_group {
> >  };
> >
> >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > -                                                 char topology[8]);
> > +                                                 const u8 topology[8]);
> >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > -                                              char topology[8]);
> > +                                              const u8 topology[8]);
> >  void drm_mode_put_tile_group(struct drm_device *dev,
> >                              struct drm_tile_group *tg);
> >
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
@ 2020-01-28 11:49       ` Ville Syrjälä
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 11:49 UTC (permalink / raw)
  To: Alex Deucher; +Cc: Intel Graphics Development, Maling list - DRI developers

On Mon, Jan 27, 2020 at 05:38:15PM -0500, Alex Deucher wrote:
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Let's try to make a lot more stuff const in the edid parser.
> >
> > The "downside" is that we can no longer mangle the EDID in the
> > middle of the parsing to apply quirks (drm_mode_detailed()).
> > I don't really think mangling the blob itself is such a great
> > idea anyway so I won't miss that part. But if we do want it
> > back I guess we should do the mangling in one explicit place
> > before we otherwise parse the EDID.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I generally agree, but are there any userspace expectations that they
> will be getting a corrected EDID in some cases?

Not sure. I think the the only thing we're fixing up is some DTDs so
at least there's a better way for userspace to get the fixed
information (getconnector ioctl). I guess Xorg is still parsing the
EDID though, but it should have more or less the same quirks in its
parser.

> 
> Alex
> 
> > ---
> >  drivers/gpu/drm/drm_connector.c |   4 +-
> >  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
> >  include/drm/drm_connector.h     |   4 +-
> >  3 files changed, 176 insertions(+), 135 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c
> > index f632ca05960e..92a5cd6ff6b1 100644
> > --- a/drivers/gpu/drm/drm_connector.c
> > +++ b/drivers/gpu/drm/drm_connector.c
> > @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
> >   * tile group or NULL if not found.
> >   */
> >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > -                                              char topology[8])
> > +                                              const u8 topology[8])
> >  {
> >         struct drm_tile_group *tg;
> >         int id;
> > @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
> >   * new tile group or NULL.
> >   */
> >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > -                                                 char topology[8])
> > +                                                 const u8 topology[8])
> >  {
> >         struct drm_tile_group *tg;
> >         int ret;
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index fd9b724067a7..8e76efe1654d 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -88,7 +88,7 @@
> >
> >  struct detailed_mode_closure {
> >         struct drm_connector *connector;
> > -       struct edid *edid;
> > +       const struct edid *edid;
> >         bool preferred;
> >         u32 quirks;
> >         int modes;
> > @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
> >                  "Minimum number of valid EDID header bytes (0-8, default 6)");
> >
> >  static void drm_get_displayid(struct drm_connector *connector,
> > -                             struct edid *edid);
> > -static int validate_displayid(u8 *displayid, int length, int idx);
> > +                             const struct edid *edid);
> > +static int validate_displayid(const u8 *displayid, int length, int idx);
> >
> >  static int drm_edid_block_checksum(const u8 *raw_edid)
> >  {
> > @@ -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
> >         return d[0] != 0x00 || d[1] != 0x00;
> >  }
> >
> > -typedef void detailed_cb(struct detailed_timing *timing, void *closure);
> > +typedef void detailed_cb(const struct detailed_timing *timing, void *closure);
> >
> >  static void
> > -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
> >  {
> >         int i, n;
> >         u8 d = ext[0x02];
> > -       u8 *det_base = ext + d;
> > +       const u8 *det_base = ext + d;
> >
> >         if (d < 4 || d > 127)
> >                 return;
> >
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> >  }
> >
> >  static void
> > -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void *closure)
> >  {
> >         unsigned int i, n = min((int)ext[0x02], 6);
> > -       u8 *det_base = ext + 5;
> > +       const u8 *det_base = ext + 5;
> >
> >         if (ext[0x01] != 1)
> >                 return; /* unknown version */
> >
> >         for (i = 0; i < n; i++)
> > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > +               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> >  }
> >
> >  static void
> > -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> > +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb, void *closure)
> >  {
> > +       const struct edid *edid = (struct edid *)raw_edid;
> >         int i;
> > -       struct edid *edid = (struct edid *)raw_edid;
> >
> >         if (edid == NULL)
> >                 return;
> > @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> >                 cb(&(edid->detailed_timings[i]), closure);
> >
> >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> > -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> > +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
> >                 switch (*ext) {
> >                 case CEA_EXT:
> >                         cea_for_each_detailed_block(ext, cb, closure);
> > @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void *closure)
> >         }
> >  }
> >
> > +struct bool_closure {
> > +       bool ret;
> > +};
> > +
> >  static void
> > -is_rb(struct detailed_timing *t, void *data)
> > +is_rb(const struct detailed_timing *t, void *c)
> >  {
> > -       u8 *r = (u8 *)t;
> > +       struct bool_closure *closure = c;
> > +       const u8 *r = (const u8 *)t;
> >
> >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         if (r[15] & 0x10)
> > -               *(bool *)data = true;
> > +               closure->ret = true;
> >  }
> >
> >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly. */
> >  static bool
> > -drm_monitor_supports_rb(struct edid *edid)
> > +drm_monitor_supports_rb(const struct edid *edid)
> >  {
> >         if (edid->revision >= 4) {
> > -               bool ret = false;
> > -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> > -               return ret;
> > +               struct bool_closure closure = {
> > +                       .ret = false,
> > +               };
> > +
> > +               drm_for_each_detailed_block((u8 *)edid, is_rb, &closure);
> > +
> > +               return closure.ret;
> >         }
> >
> >         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);
> >  }
> >
> > +struct data_closure {
> > +       const u8 *data;
> > +};
> > +
> >  static void
> > -find_gtf2(struct detailed_timing *t, void *data)
> > +do_find_gtf2(const struct detailed_timing *t, void *c)
> >  {
> > -       u8 *r = (u8 *)t;
> > +       struct data_closure *closure = c;
> > +       const u8 *r = (const u8 *)t;
> >
> >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         if (r[10] == 0x02)
> > -               *(u8 **)data = r;
> > +               closure->data = r;
> > +}
> > +
> > +static const u8 *
> > +find_gtf2_descriptor(const struct edid *edid)
> > +{
> > +       struct data_closure closure = {};
> > +
> > +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2, &closure);
> > +
> > +       return closure.data;
> >  }
> >
> >  /* Secondary GTF curve kicks in above some break frequency */
> >  static int
> > -drm_gtf2_hbreak(struct edid *edid)
> > +drm_gtf2_hbreak(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > -       return r ? (r[12] * 2) : 0;
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> > +       return r ? r[12] * 2 : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_2c(struct edid *edid)
> > +drm_gtf2_2c(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[13] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_m(struct edid *edid)
> > +drm_gtf2_m(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > -       return r ? (r[15] << 8) + r[14] : 0;
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> > +       return r ? (r[15] << 8) | r[14] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_k(struct edid *edid)
> > +drm_gtf2_k(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[16] : 0;
> >  }
> >
> >  static int
> > -drm_gtf2_2j(struct edid *edid)
> > +drm_gtf2_2j(const struct edid *edid)
> >  {
> > -       u8 *r = NULL;
> > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > +       const u8 *r = find_gtf2_descriptor(edid);
> > +
> >         return r ? r[17] : 0;
> >  }
> >
> > @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
> >   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
> >   * @edid: EDID block to scan
> >   */
> > -static int standard_timing_level(struct edid *edid)
> > +static int standard_timing_level(const struct edid *edid)
> >  {
> >         if (edid->revision >= 2) {
> >                 if (edid->revision >= 4 && (edid->features & DRM_EDID_FEATURE_DEFAULT_GTF))
> > @@ -2381,8 +2405,9 @@ bad_std_timing(u8 a, u8 b)
> >   * and convert them into a real mode using CVT/GTF/DMT.
> >   */
> >  static struct drm_display_mode *
> > -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > -            struct std_timing *t)
> > +drm_mode_std(struct drm_connector *connector,
> > +            const struct edid *edid,
> > +            const struct std_timing *t)
> >  {
> >         struct drm_device *dev = connector->dev;
> >         struct drm_display_mode *m, *mode = NULL;
> > @@ -2500,7 +2525,7 @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
> >   */
> >  static void
> >  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> > -                           struct detailed_pixel_timing *pt)
> > +                           const struct detailed_pixel_timing *pt)
> >  {
> >         int i;
> >         static const struct {
> > @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> >   * return a new struct drm_display_mode.
> >   */
> >  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> > -                                                 struct edid *edid,
> > -                                                 struct detailed_timing *timing,
> > +                                                 const struct edid *edid,
> > +                                                 const struct detailed_timing *timing,
> >                                                   u32 quirks)
> >  {
> >         struct drm_display_mode *mode;
> > -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> > +       const struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> >         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
> >         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
> >         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 | pt->hblank_lo;
> > @@ -2590,9 +2615,9 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >                 return NULL;
> >
> >         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> > -               timing->pixel_clock = cpu_to_le16(1088);
> > -
> > -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > +               mode->clock = 1088 * 10;
> > +       else
> > +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> >
> >         mode->hdisplay = hactive;
> >         mode->hsync_start = mode->hdisplay + hsync_offset;
> > @@ -2613,14 +2638,14 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >         drm_mode_do_interlace_quirk(mode, pt);
> >
> >         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> > -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE | DRM_EDID_PT_VSYNC_POSITIVE;
> > +               mode->flags |= DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC;
> > +       } else {
> > +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> >         }
> >
> > -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > -
> >  set_size:
> >         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0) << 4;
> >         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi & 0xf) << 8;
> > @@ -2644,7 +2669,7 @@ static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> >
> >  static bool
> >  mode_in_hsync_range(const struct drm_display_mode *mode,
> > -                   struct edid *edid, u8 *t)
> > +                   const struct edid *edid, const u8 *t)
> >  {
> >         int hsync, hmin, hmax;
> >
> > @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct drm_display_mode *mode,
> >
> >  static bool
> >  mode_in_vsync_range(const struct drm_display_mode *mode,
> > -                   struct edid *edid, u8 *t)
> > +                   const struct edid *edid, const u8 *t)
> >  {
> >         int vsync, vmin, vmax;
> >
> > @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct drm_display_mode *mode,
> >  }
> >
> >  static u32
> > -range_pixel_clock(struct edid *edid, u8 *t)
> > +range_pixel_clock(const struct edid *edid, const u8 *t)
> >  {
> >         /* unspecified */
> >         if (t[9] == 0 || t[9] == 255)
> > @@ -2692,11 +2717,12 @@ range_pixel_clock(struct edid *edid, u8 *t)
> >  }
> >
> >  static bool
> > -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> > -             struct detailed_timing *timing)
> > +mode_in_range(const struct drm_display_mode *mode,
> > +             const struct edid *edid,
> > +             const struct detailed_timing *timing)
> >  {
> >         u32 max_clock;
> > -       u8 *t = (u8 *)timing;
> > +       const u8 *t = (const u8 *)timing;
> >
> >         if (!mode_in_hsync_range(mode, edid, t))
> >                 return false;
> > @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct drm_connector *connector,
> >  }
> >
> >  static int
> > -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_dmt_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2773,8 +2800,9 @@ void drm_mode_fixup_1366x768(struct drm_display_mode *mode)
> >  }
> >
> >  static int
> > -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_gtf_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2801,8 +2829,9 @@ drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> >  }
> >
> >  static int
> > -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > -                       struct detailed_timing *timing)
> > +drm_cvt_modes_for_range(struct drm_connector *connector,
> > +                       const struct edid *edid,
> > +                       const struct detailed_timing *timing)
> >  {
> >         int i, modes = 0;
> >         struct drm_display_mode *newmode;
> > @@ -2830,11 +2859,11 @@ drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> >  }
> >
> >  static void
> > -do_inferred_modes(struct detailed_timing *timing, void *c)
> > +do_inferred_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > -       struct detailed_data_monitor_range *range = &data->data.range;
> > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> > +       const struct detailed_data_monitor_range *range = &data->data.range;
> >
> >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> > @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing *timing, void *c)
> >  }
> >
> >  static int
> > -add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> > +add_inferred_modes(struct drm_connector *connector,
> > +                  const struct edid *edid)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -2876,18 +2906,20 @@ add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> >         };
> >
> >         if (version_greater(edid, 1, 0))
> > -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> > +               drm_for_each_detailed_block((const u8 *)edid,
> > +                                           do_inferred_modes,
> >                                             &closure);
> >
> >         return closure.modes;
> >  }
> >
> >  static int
> > -drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> > +drm_est3_modes(struct drm_connector *connector,
> > +              const struct detailed_timing *timing)
> >  {
> >         int i, j, m, modes = 0;
> >         struct drm_display_mode *mode;
> > -       u8 *est = ((u8 *)timing) + 6;
> > +       const u8 *est = ((const u8 *)timing) + 6;
> >
> >         for (i = 0; i < 6; i++) {
> >                 for (j = 7; j >= 0; j--) {
> > @@ -2912,7 +2944,7 @@ drm_est3_modes(struct drm_connector *connector, struct detailed_timing *timing)
> >  }
> >
> >  static void
> > -do_established_modes(struct detailed_timing *timing, void *c)
> > +do_established_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >
> > @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing, void *c)
> >   * (defined above).  Tease them out and add them to the global modes list.
> >   */
> >  static int
> > -add_established_modes(struct drm_connector *connector, struct edid *edid)
> > +add_established_modes(struct drm_connector *connector,
> > +                     const struct edid *edid)
> >  {
> >         struct drm_device *dev = connector->dev;
> >         unsigned long est_bits = edid->established_timings.t1 |
> > @@ -2962,19 +2995,19 @@ add_established_modes(struct drm_connector *connector, struct edid *edid)
> >  }
> >
> >  static void
> > -do_standard_modes(struct detailed_timing *timing, void *c)
> > +do_standard_modes(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct drm_connector *connector = closure->connector;
> > -       struct edid *edid = closure->edid;
> > +       const struct edid *edid = closure->edid;
> >         int i;
> >
> >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> >                 return;
> >
> >         for (i = 0; i < 6; i++) {
> > -               struct std_timing *std = &data->data.timings[i];
> > +               const struct std_timing *std = &data->data.timings[i];
> >                 struct drm_display_mode *newmode;
> >
> >                 newmode = drm_mode_std(connector, edid, std);
> > @@ -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void *c)
> >   * GTF or CVT. Grab them from @edid and add them to the list.
> >   */
> >  static int
> > -add_standard_modes(struct drm_connector *connector, struct edid *edid)
> > +add_standard_modes(struct drm_connector *connector,
> > +                  const struct edid *edid)
> >  {
> >         int i, modes = 0;
> >         struct detailed_mode_closure closure = {
> > @@ -3023,18 +3057,18 @@ add_standard_modes(struct drm_connector *connector, struct edid *edid)
> >  }
> >
> >  static int drm_cvt_modes(struct drm_connector *connector,
> > -                        struct detailed_timing *timing)
> > +                        const struct detailed_timing *timing)
> >  {
> >         int i, j, modes = 0;
> >         struct drm_display_mode *newmode;
> >         struct drm_device *dev = connector->dev;
> > -       struct cvt_timing *cvt;
> >         const int rates[] = { 60, 85, 75, 60, 50 };
> >         const u8 empty[3] = { 0, 0, 0 };
> >
> >         for (i = 0; i < 4; i++) {
> >                 int uninitialized_var(width), height;
> > -               cvt = &(timing->data.other_data.data.cvt[i]);
> > +               const struct cvt_timing *cvt =
> > +                       &timing->data.other_data.data.cvt[i];
> >
> >                 if (!memcmp(cvt->code, empty, 3))
> >                         continue;
> > @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector *connector,
> >  }
> >
> >  static void
> > -do_cvt_mode(struct detailed_timing *timing, void *c)
> > +do_cvt_mode(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >
> > @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing, void *c)
> >  }
> >
> >  static int
> > -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > +add_cvt_modes(struct drm_connector *connector,
> > +             const struct edid *edid)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -3101,7 +3136,7 @@ add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> >  static void fixup_detailed_cea_mode_clock(struct drm_display_mode *mode);
> >
> >  static void
> > -do_detailed_mode(struct detailed_timing *timing, void *c)
> > +do_detailed_mode(const struct detailed_timing *timing, void *c)
> >  {
> >         struct detailed_mode_closure *closure = c;
> >         struct drm_display_mode *newmode;
> > @@ -3137,8 +3172,8 @@ do_detailed_mode(struct detailed_timing *timing, void *c)
> >   * @quirks: quirks to apply
> >   */
> >  static int
> > -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> > -                  u32 quirks)
> > +add_detailed_modes(struct drm_connector *connector,
> > +                  struct edid *edid, u32 quirks)
> >  {
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> > @@ -3173,9 +3208,10 @@ add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> >  /*
> >   * Search EDID for CEA extension block.
> >   */
> > -static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> > +static const u8 *drm_find_edid_extension(const struct edid *edid,
> > +                                        int ext_id)
> >  {
> > -       u8 *edid_ext = NULL;
> > +       const u8 *edid_ext = NULL;
> >         int i;
> >
> >         /* No EDID or EDID extensions */
> > @@ -3184,7 +3220,7 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> >
> >         /* Find CEA extension */
> >         for (i = 0; i < edid->extensions; i++) {
> > -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> > +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
> >                 if (edid_ext[0] == ext_id)
> >                         break;
> >         }
> > @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const struct edid *edid, int ext_id)
> >  }
> >
> >
> > -static u8 *drm_find_displayid_extension(const struct edid *edid)
> > +static const u8 *drm_find_displayid_extension(const struct edid *edid)
> >  {
> >         return drm_find_edid_extension(edid, DISPLAYID_EXT);
> >  }
> >
> > -static u8 *drm_find_cea_extension(const struct edid *edid)
> > +static const u8 *drm_find_cea_extension(const struct edid *edid)
> >  {
> >         int ret;
> >         int idx = 1;
> >         int length = EDID_LENGTH;
> > -       struct displayid_block *block;
> > -       u8 *cea;
> > -       u8 *displayid;
> > +       const struct displayid_block *block;
> > +       const u8 *cea;
> > +       const u8 *displayid;
> >
> >         /* Look for a top level CEA extension block */
> >         cea = drm_find_edid_extension(edid, CEA_EXT);
> > @@ -4315,28 +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector *connector, const u8 *db)
> >  }
> >
> >  static void
> > -monitor_name(struct detailed_timing *t, void *data)
> > +monitor_name(const struct detailed_timing *t, void *c)
> >  {
> > +       struct data_closure *closure = c;
> > +
> >         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> >                 return;
> >
> > -       *(u8 **)data = t->data.other_data.data.str.str;
> > +       closure->data = t->data.other_data.data.str.str;
> >  }
> >
> >  static int get_monitor_name(struct edid *edid, char name[13])
> >  {
> > -       char *edid_name = NULL;
> > +       struct data_closure closure = {};
> >         int mnl;
> >
> >         if (!edid || !name)
> >                 return 0;
> >
> > -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> > -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> > -               if (edid_name[mnl] == 0x0a)
> > +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> > +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> > +               if (closure.data[mnl] == 0x0a)
> >                         break;
> >
> > -               name[mnl] = edid_name[mnl];
> > +               name[mnl] = closure.data[mnl];
> >         }
> >
> >         return mnl;
> > @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector *connector)
> >  static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> >  {
> >         uint8_t *eld = connector->eld;
> > -       u8 *cea;
> > -       u8 *db;
> > +       const u8 *cea;
> >         int total_sad_count = 0;
> >         int mnl;
> > -       int dbl;
> >
> >         clear_eld(connector);
> >
> > @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector *connector, struct edid *edid)
> >                 }
> >
> >                 for_each_cea_db(cea, i, start, end) {
> > -                       db = &cea[i];
> > -                       dbl = cea_db_payload_len(db);
> > +                       const u8 *db = &cea[i];
> > +                       int dbl = cea_db_payload_len(db);
> >
> >                         switch (cea_db_tag(db)) {
> >                                 int sad_count;
> > @@ -4484,7 +4520,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >  {
> >         int count = 0;
> >         int i, start, end, dbl;
> > -       u8 *cea;
> > +       const u8 *cea;
> >
> >         cea = drm_find_cea_extension(edid);
> >         if (!cea) {
> > @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >         }
> >
> >         for_each_cea_db(cea, i, start, end) {
> > -               u8 *db = &cea[i];
> > +               const u8 *db = &cea[i];
> >
> >                 if (cea_db_tag(db) == AUDIO_BLOCK) {
> >                         int j;
> > @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)
> >                         if (!*sads)
> >                                 return -ENOMEM;
> >                         for (j = 0; j < count; j++) {
> > -                               u8 *sad = &db[1 + j * 3];
> > +                               const u8 *sad = &db[1 + j * 3];
> >
> >                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
> >                                 (*sads)[j].channels = sad[0] & 0x7;
> > @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
> >   */
> >  bool drm_detect_hdmi_monitor(struct edid *edid)
> >  {
> > -       u8 *edid_ext;
> > +       const u8 *edid_ext;
> >         int i;
> >         int start_offset, end_offset;
> >
> > @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
> >   */
> >  bool drm_detect_monitor_audio(struct edid *edid)
> >  {
> > -       u8 *edid_ext;
> > +       const u8 *edid_ext;
> >         int i, j;
> >         bool has_audio = false;
> >         int start_offset, end_offset;
> > @@ -5017,13 +5053,13 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
> >         return quirks;
> >  }
> >
> > -static int validate_displayid(u8 *displayid, int length, int idx)
> > +static int validate_displayid(const u8 *displayid, int length, int idx)
> >  {
> >         int i;
> >         u8 csum = 0;
> > -       struct displayid_hdr *base;
> > +       const struct displayid_hdr *base;
> >
> > -       base = (struct displayid_hdr *)&displayid[idx];
> > +       base = (const struct displayid_hdr *)&displayid[idx];
> >
> >         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> >                       base->rev, base->bytes, base->prod_id, base->ext_count);
> > @@ -5041,7 +5077,7 @@ static int validate_displayid(u8 *displayid, int length, int idx)
> >  }
> >
> >  static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *dev,
> > -                                                           struct displayid_detailed_timings_1 *timings)
> > +                                                           const struct displayid_detailed_timings_1 *timings)
> >  {
> >         struct drm_display_mode *mode;
> >         unsigned pixel_clock = (timings->pixel_clock[0] |
> > @@ -5057,6 +5093,7 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
> >         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
> >         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
> >         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> > +
> >         mode = drm_mode_create(dev);
> >         if (!mode)
> >                 return NULL;
> > @@ -5086,9 +5123,10 @@ static struct drm_display_mode *drm_mode_displayid_detailed(struct drm_device *d
> >  }
> >
> >  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> > -                                         struct displayid_block *block)
> > +                                         const struct displayid_block *block)
> >  {
> > -       struct displayid_detailed_timing_block *det = (struct displayid_detailed_timing_block *)block;
> > +       const struct displayid_detailed_timing_block *det =
> > +               (const struct displayid_detailed_timing_block *)block;
> >         int i;
> >         int num_timings;
> >         struct drm_display_mode *newmode;
> > @@ -5099,7 +5137,7 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> >
> >         num_timings = block->num_bytes / 20;
> >         for (i = 0; i < num_timings; i++) {
> > -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> > +               const struct displayid_detailed_timings_1 *timings = &det->timings[i];
> >
> >                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
> >                 if (!newmode)
> > @@ -5112,13 +5150,13 @@ static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> >  }
> >
> >  static int add_displayid_detailed_modes(struct drm_connector *connector,
> > -                                       struct edid *edid)
> > +                                       const struct edid *edid)
> >  {
> > -       u8 *displayid;
> > +       const u8 *displayid;
> >         int ret;
> >         int idx = 1;
> >         int length = EDID_LENGTH;
> > -       struct displayid_block *block;
> > +       const struct displayid_block *block;
> >         int num_modes = 0;
> >
> >         displayid = drm_find_displayid_extension(edid);
> > @@ -5720,9 +5758,10 @@ drm_hdmi_vendor_infoframe_from_display_mode(struct hdmi_vendor_infoframe *frame,
> >  EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
> >
> >  static int drm_parse_tiled_block(struct drm_connector *connector,
> > -                                struct displayid_block *block)
> > +                                const struct displayid_block *block)
> >  {
> > -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> > +       const struct displayid_tiled_block *tile =
> > +               (const struct displayid_tiled_block *)block;
> >         u16 w, h;
> >         u8 tile_v_loc, tile_h_loc;
> >         u8 num_v_tile, num_h_tile;
> > @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct drm_connector *connector,
> >  }
> >
> >  static int drm_parse_display_id(struct drm_connector *connector,
> > -                               u8 *displayid, int length,
> > +                               const u8 *displayid, int length,
> >                                 bool is_edid_extension)
> >  {
> >         /* if this is an EDID extension the first byte will be 0x70 */
> >         int idx = 0;
> > -       struct displayid_block *block;
> > +       const struct displayid_block *block;
> >         int ret;
> >
> >         if (is_edid_extension)
> > @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct drm_connector *connector,
> >  }
> >
> >  static void drm_get_displayid(struct drm_connector *connector,
> > -                             struct edid *edid)
> > +                             const struct edid *edid)
> >  {
> > -       void *displayid = NULL;
> > +       const void *displayid;
> >         int ret;
> > +
> >         connector->has_tile = false;
> > +
> >         displayid = drm_find_displayid_extension(edid);
> >         if (!displayid) {
> >                 /* drop reference to any tile group we had */
> > diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > index 2113500b4075..c0f9ce3f4b24 100644
> > --- a/include/drm/drm_connector.h
> > +++ b/include/drm/drm_connector.h
> > @@ -1580,9 +1580,9 @@ struct drm_tile_group {
> >  };
> >
> >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > -                                                 char topology[8]);
> > +                                                 const u8 topology[8]);
> >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > -                                              char topology[8]);
> > +                                              const u8 topology[8]);
> >  void drm_mode_put_tile_group(struct drm_device *dev,
> >                              struct drm_tile_group *tg);
> >
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
@ 2020-01-28 15:17   ` Daniel Vetter
  -1 siblings, 0 replies; 67+ messages in thread
From: Daniel Vetter @ 2020-01-28 15:17 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Allen Chen, intel-gfx, dri-devel

On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> CEA-861 says :
> "d = offset for the byte following the reserved data block.
>  If no data is provided in the reserved data block, then d=4.
>  If no DTDs are provided, then d=0."
> 
> So let's not look for DTDs when d==0. In fact let's just make that
> <4 since those values would just mean that he DTDs overlap the block
> header. And let's also check that d isn't so big as to declare
> the descriptors to live past the block end, although the code
> does already survive that case as we'd just end up with a negative
> number of descriptors and the loop would not do anything.
> 
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Hm I think edid parsing is like the perfect use-case for some in-kernel
unit tests ... In case anyone feels motivated?
-Daniel

> ---
>  drivers/gpu/drm/drm_edid.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 99769d6c9f84..1b6e544cf5c7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>  static void
>  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
>  {
> -	int i, n = 0;
> +	int i, n;
>  	u8 d = ext[0x02];
>  	u8 *det_base = ext + d;
>  
> +	if (d < 4 || d > 127)
> +		return;
> +
>  	n = (127 - d) / 18;
>  	for (i = 0; i < n; i++)
>  		cb((struct detailed_timing *)(det_base + 18 * i), closure);
> -- 
> 2.24.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-28 15:17   ` Daniel Vetter
  0 siblings, 0 replies; 67+ messages in thread
From: Daniel Vetter @ 2020-01-28 15:17 UTC (permalink / raw)
  To: Ville Syrjala; +Cc: Allen Chen, intel-gfx, dri-devel

On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> CEA-861 says :
> "d = offset for the byte following the reserved data block.
>  If no data is provided in the reserved data block, then d=4.
>  If no DTDs are provided, then d=0."
> 
> So let's not look for DTDs when d==0. In fact let's just make that
> <4 since those values would just mean that he DTDs overlap the block
> header. And let's also check that d isn't so big as to declare
> the descriptors to live past the block end, although the code
> does already survive that case as we'd just end up with a negative
> number of descriptors and the loop would not do anything.
> 
> Cc: Allen Chen <allen.chen@ite.com.tw>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>

Hm I think edid parsing is like the perfect use-case for some in-kernel
unit tests ... In case anyone feels motivated?
-Daniel

> ---
>  drivers/gpu/drm/drm_edid.c | 5 ++++-
>  1 file changed, 4 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 99769d6c9f84..1b6e544cf5c7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct detailed_timing *timing, void *closure);
>  static void
>  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
>  {
> -	int i, n = 0;
> +	int i, n;
>  	u8 d = ext[0x02];
>  	u8 *det_base = ext + d;
>  
> +	if (d < 4 || d > 127)
> +		return;
> +
>  	n = (127 - d) / 18;
>  	for (i = 0; i < n; i++)
>  		cb((struct detailed_timing *)(det_base + 18 * i), closure);
> -- 
> 2.24.1
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-28 15:17   ` [Intel-gfx] " Daniel Vetter
@ 2020-01-28 16:15     ` Ville Syrjälä
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 16:15 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > CEA-861 says :
> > "d = offset for the byte following the reserved data block.
> >  If no data is provided in the reserved data block, then d=4.
> >  If no DTDs are provided, then d=0."
> > 
> > So let's not look for DTDs when d==0. In fact let's just make that
> > <4 since those values would just mean that he DTDs overlap the block
> > header. And let's also check that d isn't so big as to declare
> > the descriptors to live past the block end, although the code
> > does already survive that case as we'd just end up with a negative
> > number of descriptors and the loop would not do anything.
> > 
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Hm I think edid parsing is like the perfect use-case for some in-kernel
> unit tests ... In case anyone feels motivated?

Another idea I've been putting off is simply shoving the parser into
userspace. Kinda looks like with fork_usermode_blob() we could embed
the executable into the kernel/module and thus avoid the problem of
actually shipping the binary somehow.

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-28 16:15     ` Ville Syrjälä
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 16:15 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > CEA-861 says :
> > "d = offset for the byte following the reserved data block.
> >  If no data is provided in the reserved data block, then d=4.
> >  If no DTDs are provided, then d=0."
> > 
> > So let's not look for DTDs when d==0. In fact let's just make that
> > <4 since those values would just mean that he DTDs overlap the block
> > header. And let's also check that d isn't so big as to declare
> > the descriptors to live past the block end, although the code
> > does already survive that case as we'd just end up with a negative
> > number of descriptors and the loop would not do anything.
> > 
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Hm I think edid parsing is like the perfect use-case for some in-kernel
> unit tests ... In case anyone feels motivated?

Another idea I've been putting off is simply shoving the parser into
userspace. Kinda looks like with fork_usermode_blob() we could embed
the executable into the kernel/module and thus avoid the problem of
actually shipping the binary somehow.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-28 16:15     ` [Intel-gfx] " Ville Syrjälä
@ 2020-01-28 16:18       ` Daniel Vetter
  -1 siblings, 0 replies; 67+ messages in thread
From: Daniel Vetter @ 2020-01-28 16:18 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 5:15 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> > On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > CEA-861 says :
> > > "d = offset for the byte following the reserved data block.
> > >  If no data is provided in the reserved data block, then d=4.
> > >  If no DTDs are provided, then d=0."
> > >
> > > So let's not look for DTDs when d==0. In fact let's just make that
> > > <4 since those values would just mean that he DTDs overlap the block
> > > header. And let's also check that d isn't so big as to declare
> > > the descriptors to live past the block end, although the code
> > > does already survive that case as we'd just end up with a negative
> > > number of descriptors and the loop would not do anything.
> > >
> > > Cc: Allen Chen <allen.chen@ite.com.tw>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Hm I think edid parsing is like the perfect use-case for some in-kernel
> > unit tests ... In case anyone feels motivated?
>
> Another idea I've been putting off is simply shoving the parser into
> userspace. Kinda looks like with fork_usermode_blob() we could embed
> the executable into the kernel/module and thus avoid the problem of
> actually shipping the binary somehow.

"How to run unit tests without losing hair" is essentially what kunit
tries to solve. I think we should cut over to that (it's merged now,
should be good enough for at least the edid parser, mocking stuff
isn't there there), and then make sure CI runs that stuff for us. Then
we could convert over at least the unit test like selftests eventually
too.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-28 16:18       ` Daniel Vetter
  0 siblings, 0 replies; 67+ messages in thread
From: Daniel Vetter @ 2020-01-28 16:18 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 5:15 PM Ville Syrjälä
<ville.syrjala@linux.intel.com> wrote:
>
> On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> > On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > CEA-861 says :
> > > "d = offset for the byte following the reserved data block.
> > >  If no data is provided in the reserved data block, then d=4.
> > >  If no DTDs are provided, then d=0."
> > >
> > > So let's not look for DTDs when d==0. In fact let's just make that
> > > <4 since those values would just mean that he DTDs overlap the block
> > > header. And let's also check that d isn't so big as to declare
> > > the descriptors to live past the block end, although the code
> > > does already survive that case as we'd just end up with a negative
> > > number of descriptors and the loop would not do anything.
> > >
> > > Cc: Allen Chen <allen.chen@ite.com.tw>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Hm I think edid parsing is like the perfect use-case for some in-kernel
> > unit tests ... In case anyone feels motivated?
>
> Another idea I've been putting off is simply shoving the parser into
> userspace. Kinda looks like with fork_usermode_blob() we could embed
> the executable into the kernel/module and thus avoid the problem of
> actually shipping the binary somehow.

"How to run unit tests without losing hair" is essentially what kunit
tries to solve. I think we should cut over to that (it's merged now,
should be good enough for at least the edid parser, mocking stuff
isn't there there), and then make sure CI runs that stuff for us. Then
we could convert over at least the unit test like selftests eventually
too.
-Daniel
-- 
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-28 16:18       ` [Intel-gfx] " Daniel Vetter
@ 2020-01-28 16:28         ` Ville Syrjälä
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 16:28 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 05:18:34PM +0100, Daniel Vetter wrote:
> On Tue, Jan 28, 2020 at 5:15 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> > > On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > >
> > > > CEA-861 says :
> > > > "d = offset for the byte following the reserved data block.
> > > >  If no data is provided in the reserved data block, then d=4.
> > > >  If no DTDs are provided, then d=0."
> > > >
> > > > So let's not look for DTDs when d==0. In fact let's just make that
> > > > <4 since those values would just mean that he DTDs overlap the block
> > > > header. And let's also check that d isn't so big as to declare
> > > > the descriptors to live past the block end, although the code
> > > > does already survive that case as we'd just end up with a negative
> > > > number of descriptors and the loop would not do anything.
> > > >
> > > > Cc: Allen Chen <allen.chen@ite.com.tw>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Hm I think edid parsing is like the perfect use-case for some in-kernel
> > > unit tests ... In case anyone feels motivated?
> >
> > Another idea I've been putting off is simply shoving the parser into
> > userspace. Kinda looks like with fork_usermode_blob() we could embed
> > the executable into the kernel/module and thus avoid the problem of
> > actually shipping the binary somehow.
> 
> "How to run unit tests without losing hair" is essentially what kunit
> tries to solve. I think we should cut over to that (it's merged now,
> should be good enough for at least the edid parser, mocking stuff
> isn't there there), and then make sure CI runs that stuff for us. Then
> we could convert over at least the unit test like selftests eventually
> too.

I meant run it in userspace *always*, not just for testing.

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-01-28 16:28         ` Ville Syrjälä
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-01-28 16:28 UTC (permalink / raw)
  To: Daniel Vetter; +Cc: Allen Chen, intel-gfx, dri-devel

On Tue, Jan 28, 2020 at 05:18:34PM +0100, Daniel Vetter wrote:
> On Tue, Jan 28, 2020 at 5:15 PM Ville Syrjälä
> <ville.syrjala@linux.intel.com> wrote:
> >
> > On Tue, Jan 28, 2020 at 04:17:58PM +0100, Daniel Vetter wrote:
> > > On Fri, Jan 24, 2020 at 10:02:24PM +0200, Ville Syrjala wrote:
> > > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > >
> > > > CEA-861 says :
> > > > "d = offset for the byte following the reserved data block.
> > > >  If no data is provided in the reserved data block, then d=4.
> > > >  If no DTDs are provided, then d=0."
> > > >
> > > > So let's not look for DTDs when d==0. In fact let's just make that
> > > > <4 since those values would just mean that he DTDs overlap the block
> > > > header. And let's also check that d isn't so big as to declare
> > > > the descriptors to live past the block end, although the code
> > > > does already survive that case as we'd just end up with a negative
> > > > number of descriptors and the loop would not do anything.
> > > >
> > > > Cc: Allen Chen <allen.chen@ite.com.tw>
> > > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Hm I think edid parsing is like the perfect use-case for some in-kernel
> > > unit tests ... In case anyone feels motivated?
> >
> > Another idea I've been putting off is simply shoving the parser into
> > userspace. Kinda looks like with fork_usermode_blob() we could embed
> > the executable into the kernel/module and thus avoid the problem of
> > actually shipping the binary somehow.
> 
> "How to run unit tests without losing hair" is essentially what kunit
> tries to solve. I think we should cut over to that (it's merged now,
> should be good enough for at least the edid parser, mocking stuff
> isn't there there), and then make sure CI runs that stuff for us. Then
> we could convert over at least the unit test like selftests eventually
> too.

I meant run it in userspace *always*, not just for testing.

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
  2020-01-27 22:34   ` [Intel-gfx] " Alex Deucher
@ 2020-02-03 19:15     ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:15 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:04 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors
> in the CEA ext block
> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > CEA-861 says :
> > "d = offset for the byte following the reserved data block.
> >  If no data is provided in the reserved data block, then d=4.
> >  If no DTDs are provided, then d=0."
> >
> > So let's not look for DTDs when d==0. In fact let's just make that
> > <4 since those values would just mean that he DTDs overlap the block
> > header. And let's also check that d isn't so big as to declare the
> > descriptors to live past the block end, although the code does already
> > survive that case as we'd just end up with a negative number of
> > descriptors and the loop would not do anything.
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good to me as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 99769d6c9f84..1b6e544cf5c7 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct
> > detailed_timing *timing, void *closure);  static void
> >  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > {
> > -       int i, n = 0;
> > +       int i, n;
> >         u8 d = ext[0x02];
> >         u8 *det_base = ext + d;
> >
> > +       if (d < 4 || d > 127)
> > +               return;
> > +
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> >                 cb((struct detailed_timing *)(det_base + 18 * i),
> > closure);
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block
@ 2020-02-03 19:15     ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:15 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:04 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors
> in the CEA ext block
> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > CEA-861 says :
> > "d = offset for the byte following the reserved data block.
> >  If no data is provided in the reserved data block, then d=4.
> >  If no DTDs are provided, then d=0."
> >
> > So let's not look for DTDs when d==0. In fact let's just make that
> > <4 since those values would just mean that he DTDs overlap the block
> > header. And let's also check that d isn't so big as to declare the
> > descriptors to live past the block end, although the code does already
> > survive that case as we'd just end up with a negative number of
> > descriptors and the loop would not do anything.
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good to me as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 5 ++++-
> >  1 file changed, 4 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 99769d6c9f84..1b6e544cf5c7 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2201,10 +2201,13 @@ typedef void detailed_cb(struct
> > detailed_timing *timing, void *closure);  static void
> >  cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void *closure)
> > {
> > -       int i, n = 0;
> > +       int i, n;
> >         u8 d = ext[0x02];
> >         u8 *det_base = ext + d;
> >
> > +       if (d < 4 || d > 127)
> > +               return;
> > +
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> >                 cb((struct detailed_timing *)(det_base + 18 * i),
> > closure);
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
  2020-01-27 22:35     ` [Intel-gfx] " Alex Deucher
@ 2020-02-03 19:44       ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:44 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:06 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a
> display descriptor
> 
> On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Currently we assume any 18 byte descriptor to be a display descritor
> > if only the tag byte matches the expected value. But for detailed
> > timing descriptors that same byte is just the lower 8 bits of hblank,
> > and as such can match any display descriptor tag. To properly validate
> > that the 18 byte descriptor is in fact a display descriptor we must
> > also examine bytes 0-2 (just byte 1 should actually suffice but the
> > spec does say that bytes 0 and
> > 2 must also always be zero for display descriptors so we check those
> > too).
> >
> > Unlike Allen's original proposed patch to just fix is_rb() we roll
> > this out across the board to fix everything.
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks Good to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 65
> > ++++++++++++++++++++++++--------------
> >  1 file changed, 41 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 1b6e544cf5c7..96ae1fde4ce2 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2196,6 +2196,12 @@ struct drm_display_mode
> > *drm_mode_find_dmt(struct drm_device *dev,  }
> > EXPORT_SYMBOL(drm_mode_find_dmt);
> >
> > +static bool is_display_descriptor(const u8 d[18], u8 tag) {
> > +       return d[0] == 0x00 && d[1] == 0x00 &&
> > +               d[2] == 0x00 && d[3] == tag; }
> > +
> >  typedef void detailed_cb(struct detailed_timing *timing, void
> > *closure);
> >
> >  static void
> > @@ -2257,9 +2263,12 @@ static void
> >  is_rb(struct detailed_timing *t, void *data)  {
> >         u8 *r = (u8 *)t;
> > -       if (r[3] == EDID_DETAIL_MONITOR_RANGE)
> > -               if (r[15] & 0x10)
> > -                       *(bool *)data = true;
> > +
> > +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > +               return;
> > +
> > +       if (r[15] & 0x10)
> > +               *(bool *)data = true;
> >  }
> >
> >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly.
> > */ @@ -2279,7 +2288,11 @@ static void  find_gtf2(struct
> > detailed_timing *t, void *data)  {
> >         u8 *r = (u8 *)t;
> > -       if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
> > +
> > +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > +               return;
> > +
> > +       if (r[10] == 0x02)
> >                 *(u8 **)data = r;
> >  }
> >
> > @@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void
> *c)
> >         struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct detailed_data_monitor_range *range = &data->data.range;
> >
> > -       if (data->type != EDID_DETAIL_MONITOR_RANGE)
> > +       if (!is_display_descriptor((const u8 *)timing,
> > + EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         closure->modes += drm_dmt_modes_for_range(closure->connector,
> > @@ -2897,10 +2910,11 @@ static void
> >  do_established_modes(struct detailed_timing *timing, void *c)  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> >
> > -       if (data->type == EDID_DETAIL_EST_TIMINGS)
> > -               closure->modes += drm_est3_modes(closure->connector, timing);
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
> > +               return;
> > +
> > +       closure->modes += drm_est3_modes(closure->connector, timing);
> >  }
> >
> >  /**
> > @@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing,
> void *c)
> >         struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct drm_connector *connector = closure->connector;
> >         struct edid *edid = closure->edid;
> > +       int i;
> >
> > -       if (data->type == EDID_DETAIL_STD_MODES) {
> > -               int i;
> > -               for (i = 0; i < 6; i++) {
> > -                       struct std_timing *std;
> > -                       struct drm_display_mode *newmode;
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> > +               return;
> >
> > -                       std = &data->data.timings[i];
> > -                       newmode = drm_mode_std(connector, edid, std);
> > -                       if (newmode) {
> > -                               drm_mode_probed_add(connector, newmode);
> > -                               closure->modes++;
> > -                       }
> > +       for (i = 0; i < 6; i++) {
> > +               struct std_timing *std = &data->data.timings[i];
> > +               struct drm_display_mode *newmode;
> > +
> > +               newmode = drm_mode_std(connector, edid, std);
> > +               if (newmode) {
> > +                       drm_mode_probed_add(connector, newmode);
> > +                       closure->modes++;
> >                 }
> >         }
> >  }
> > @@ -3056,10 +3070,11 @@ static void
> >  do_cvt_mode(struct detailed_timing *timing, void *c)  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> >
> > -       if (data->type == EDID_DETAIL_CVT_3BYTE)
> > -               closure->modes += drm_cvt_modes(closure->connector, timing);
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
> > +               return;
> > +
> > +       closure->modes += drm_cvt_modes(closure->connector, timing);
> >  }
> >
> >  static int
> > @@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector
> > *connector, const u8 *db)  static void  monitor_name(struct
> > detailed_timing *t, void *data)  {
> > -       if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
> > -               *(u8 **)data = t->data.other_data.data.str.str;
> > +       if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> > +               return;
> > +
> > +       *(u8 **)data = t->data.other_data.data.str.str;
> >  }
> >
> >  static int get_monitor_name(struct edid *edid, char name[13])
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor
@ 2020-02-03 19:44       ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:44 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:06 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 2/8] drm/edid: Don't accept any old garbage as a
> display descriptor
> 
> On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Currently we assume any 18 byte descriptor to be a display descritor
> > if only the tag byte matches the expected value. But for detailed
> > timing descriptors that same byte is just the lower 8 bits of hblank,
> > and as such can match any display descriptor tag. To properly validate
> > that the 18 byte descriptor is in fact a display descriptor we must
> > also examine bytes 0-2 (just byte 1 should actually suffice but the
> > spec does say that bytes 0 and
> > 2 must also always be zero for display descriptors so we check those
> > too).
> >
> > Unlike Allen's original proposed patch to just fix is_rb() we roll
> > this out across the board to fix everything.
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks Good to me.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 65
> > ++++++++++++++++++++++++--------------
> >  1 file changed, 41 insertions(+), 24 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 1b6e544cf5c7..96ae1fde4ce2 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2196,6 +2196,12 @@ struct drm_display_mode
> > *drm_mode_find_dmt(struct drm_device *dev,  }
> > EXPORT_SYMBOL(drm_mode_find_dmt);
> >
> > +static bool is_display_descriptor(const u8 d[18], u8 tag) {
> > +       return d[0] == 0x00 && d[1] == 0x00 &&
> > +               d[2] == 0x00 && d[3] == tag; }
> > +
> >  typedef void detailed_cb(struct detailed_timing *timing, void
> > *closure);
> >
> >  static void
> > @@ -2257,9 +2263,12 @@ static void
> >  is_rb(struct detailed_timing *t, void *data)  {
> >         u8 *r = (u8 *)t;
> > -       if (r[3] == EDID_DETAIL_MONITOR_RANGE)
> > -               if (r[15] & 0x10)
> > -                       *(bool *)data = true;
> > +
> > +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > +               return;
> > +
> > +       if (r[15] & 0x10)
> > +               *(bool *)data = true;
> >  }
> >
> >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess, badly.
> > */ @@ -2279,7 +2288,11 @@ static void  find_gtf2(struct
> > detailed_timing *t, void *data)  {
> >         u8 *r = (u8 *)t;
> > -       if (r[3] == EDID_DETAIL_MONITOR_RANGE && r[10] == 0x02)
> > +
> > +       if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > +               return;
> > +
> > +       if (r[10] == 0x02)
> >                 *(u8 **)data = r;
> >  }
> >
> > @@ -2818,7 +2831,7 @@ do_inferred_modes(struct detailed_timing *timing, void
> *c)
> >         struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct detailed_data_monitor_range *range = &data->data.range;
> >
> > -       if (data->type != EDID_DETAIL_MONITOR_RANGE)
> > +       if (!is_display_descriptor((const u8 *)timing,
> > + EDID_DETAIL_MONITOR_RANGE))
> >                 return;
> >
> >         closure->modes += drm_dmt_modes_for_range(closure->connector,
> > @@ -2897,10 +2910,11 @@ static void
> >  do_established_modes(struct detailed_timing *timing, void *c)  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> >
> > -       if (data->type == EDID_DETAIL_EST_TIMINGS)
> > -               closure->modes += drm_est3_modes(closure->connector, timing);
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_EST_TIMINGS))
> > +               return;
> > +
> > +       closure->modes += drm_est3_modes(closure->connector, timing);
> >  }
> >
> >  /**
> > @@ -2949,19 +2963,19 @@ do_standard_modes(struct detailed_timing *timing,
> void *c)
> >         struct detailed_non_pixel *data = &timing->data.other_data;
> >         struct drm_connector *connector = closure->connector;
> >         struct edid *edid = closure->edid;
> > +       int i;
> >
> > -       if (data->type == EDID_DETAIL_STD_MODES) {
> > -               int i;
> > -               for (i = 0; i < 6; i++) {
> > -                       struct std_timing *std;
> > -                       struct drm_display_mode *newmode;
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> > +               return;
> >
> > -                       std = &data->data.timings[i];
> > -                       newmode = drm_mode_std(connector, edid, std);
> > -                       if (newmode) {
> > -                               drm_mode_probed_add(connector, newmode);
> > -                               closure->modes++;
> > -                       }
> > +       for (i = 0; i < 6; i++) {
> > +               struct std_timing *std = &data->data.timings[i];
> > +               struct drm_display_mode *newmode;
> > +
> > +               newmode = drm_mode_std(connector, edid, std);
> > +               if (newmode) {
> > +                       drm_mode_probed_add(connector, newmode);
> > +                       closure->modes++;
> >                 }
> >         }
> >  }
> > @@ -3056,10 +3070,11 @@ static void
> >  do_cvt_mode(struct detailed_timing *timing, void *c)  {
> >         struct detailed_mode_closure *closure = c;
> > -       struct detailed_non_pixel *data = &timing->data.other_data;
> >
> > -       if (data->type == EDID_DETAIL_CVT_3BYTE)
> > -               closure->modes += drm_cvt_modes(closure->connector, timing);
> > +       if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_CVT_3BYTE))
> > +               return;
> > +
> > +       closure->modes += drm_cvt_modes(closure->connector, timing);
> >  }
> >
> >  static int
> > @@ -4285,8 +4300,10 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector
> > *connector, const u8 *db)  static void  monitor_name(struct
> > detailed_timing *t, void *data)  {
> > -       if (t->data.other_data.type == EDID_DETAIL_MONITOR_NAME)
> > -               *(u8 **)data = t->data.other_data.data.str.str;
> > +       if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> > +               return;
> > +
> > +       *(u8 **)data = t->data.other_data.data.str.str;
> >  }
> >
> >  static int get_monitor_name(struct edid *edid, char name[13])
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
  2020-01-27 22:36     ` [Intel-gfx] " Alex Deucher
@ 2020-02-03 19:49       ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:49 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:06 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce
> is_detailed_timing_descritor()
> 
> On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Let's introduce is_detailed_timing_descritor() as the opposite
> > counterpart of is_display_descriptor().
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 42
> > ++++++++++++++++++++++----------------
> >  1 file changed, 24 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 96ae1fde4ce2..d6bce58b27ac 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8
> tag)
> >                 d[2] == 0x00 && d[3] == tag;  }
> >
> > +static bool is_detailed_timing_descriptor(const u8 d[18]) {
> > +       return d[0] != 0x00 || d[1] != 0x00; }
> > +
> >  typedef void detailed_cb(struct detailed_timing *timing, void
> > *closure);
> >
> >  static void
> > @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing,
> void *c)
> >         struct detailed_mode_closure *closure = c;
> >         struct drm_display_mode *newmode;
> >
> > -       if (timing->pixel_clock) {
> > -               newmode = drm_mode_detailed(closure->connector->dev,
> > -                                           closure->edid, timing,
> > -                                           closure->quirks);
> > -               if (!newmode)
> > -                       return;
> > +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> > +               return;
> > +
> > +       newmode = drm_mode_detailed(closure->connector->dev,
> > +                                   closure->edid, timing,
> > +                                   closure->quirks);
> > +       if (!newmode)
> > +               return;
> >
> > -               if (closure->preferred)
> > -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> > +       if (closure->preferred)
> > +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
> >
> > -               /*
> > -                * Detailed modes are limited to 10kHz pixel clock resolution,
> > -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> > -                * is just slightly off.
> > -                */
> > -               fixup_detailed_cea_mode_clock(newmode);
> > +       /*
> > +        * Detailed modes are limited to 10kHz pixel clock resolution,
> > +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> > +        * is just slightly off.
> > +        */
> > +       fixup_detailed_cea_mode_clock(newmode);
> >
> > -               drm_mode_probed_add(closure->connector, newmode);
> > -               closure->modes++;
> > -               closure->preferred = false;
> > -       }
> > +       drm_mode_probed_add(closure->connector, newmode);
> > +       closure->modes++;
> > +       closure->preferred = false;
> >  }
> >
> >  /*
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor()
@ 2020-02-03 19:49       ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:49 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Allen Chen, Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:06 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Allen Chen <allen.chen@ite.com.tw>; Intel Graphics Development <intel-
> gfx@lists.freedesktop.org>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 3/8] drm/edid: Introduce
> is_detailed_timing_descritor()
> 
> On Fri, Jan 24, 2020 at 3:02 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Let's introduce is_detailed_timing_descritor() as the opposite
> > counterpart of is_display_descriptor().
> >
> > Cc: Allen Chen <allen.chen@ite.com.tw>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 42
> > ++++++++++++++++++++++----------------
> >  1 file changed, 24 insertions(+), 18 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 96ae1fde4ce2..d6bce58b27ac 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2202,6 +2202,11 @@ static bool is_display_descriptor(const u8 d[18], u8
> tag)
> >                 d[2] == 0x00 && d[3] == tag;  }
> >
> > +static bool is_detailed_timing_descriptor(const u8 d[18]) {
> > +       return d[0] != 0x00 || d[1] != 0x00; }
> > +
> >  typedef void detailed_cb(struct detailed_timing *timing, void
> > *closure);
> >
> >  static void
> > @@ -3101,27 +3106,28 @@ do_detailed_mode(struct detailed_timing *timing,
> void *c)
> >         struct detailed_mode_closure *closure = c;
> >         struct drm_display_mode *newmode;
> >
> > -       if (timing->pixel_clock) {
> > -               newmode = drm_mode_detailed(closure->connector->dev,
> > -                                           closure->edid, timing,
> > -                                           closure->quirks);
> > -               if (!newmode)
> > -                       return;
> > +       if (!is_detailed_timing_descriptor((const u8 *)timing))
> > +               return;
> > +
> > +       newmode = drm_mode_detailed(closure->connector->dev,
> > +                                   closure->edid, timing,
> > +                                   closure->quirks);
> > +       if (!newmode)
> > +               return;
> >
> > -               if (closure->preferred)
> > -                       newmode->type |= DRM_MODE_TYPE_PREFERRED;
> > +       if (closure->preferred)
> > +               newmode->type |= DRM_MODE_TYPE_PREFERRED;
> >
> > -               /*
> > -                * Detailed modes are limited to 10kHz pixel clock resolution,
> > -                * so fix up anything that looks like CEA/HDMI mode, but the clock
> > -                * is just slightly off.
> > -                */
> > -               fixup_detailed_cea_mode_clock(newmode);
> > +       /*
> > +        * Detailed modes are limited to 10kHz pixel clock resolution,
> > +        * so fix up anything that looks like CEA/HDMI mode, but the clock
> > +        * is just slightly off.
> > +        */
> > +       fixup_detailed_cea_mode_clock(newmode);
> >
> > -               drm_mode_probed_add(closure->connector, newmode);
> > -               closure->modes++;
> > -               closure->preferred = false;
> > -       }
> > +       drm_mode_probed_add(closure->connector, newmode);
> > +       closure->modes++;
> > +       closure->preferred = false;
> >  }
> >
> >  /*
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
  2020-01-27 22:28     ` [Intel-gfx] " Alex Deucher
@ 2020-02-03 19:51       ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:51 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 3:58 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
> 
> Title should be s/i915/edid/ , with that fixed:
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Yeah with the title fixed, this is
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Nuke some whitespace that shouldn't be there.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index d6bce58b27ac..3df5744026b0 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void
> *c)
> >         closure->modes += drm_dmt_modes_for_range(closure->connector,
> >                                                   closure->edid,
> >                                                   timing);
> > -
> > +
> >         if (!version_greater(closure->edid, 1, 1))
> >                 return; /* GTF not defined yet */
> >
> > @@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void
> > *c)
> >
> >  static int
> >  add_cvt_modes(struct drm_connector *connector, struct edid *edid) -{
> > +{
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> >                 .edid = edid,
> > @@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid
> > *edid, char *name, int bufsize)  {
> >         int name_length;
> >         char buf[13];
> > -
> > +
> >         if (bufsize <= 0)
> >                 return;
> >
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
@ 2020-02-03 19:51       ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:51 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 3:58 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 4/8] drm/i915: Clear out spurious whitespace
> 
> Title should be s/i915/edid/ , with that fixed:
> Reviewed-by: Alex Deucher <alexander.deucher@amd.com>

Yeah with the title fixed, this is
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > Nuke some whitespace that shouldn't be there.
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 6 +++---
> >  1 file changed, 3 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index d6bce58b27ac..3df5744026b0 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2842,7 +2842,7 @@ do_inferred_modes(struct detailed_timing *timing, void
> *c)
> >         closure->modes += drm_dmt_modes_for_range(closure->connector,
> >                                                   closure->edid,
> >                                                   timing);
> > -
> > +
> >         if (!version_greater(closure->edid, 1, 1))
> >                 return; /* GTF not defined yet */
> >
> > @@ -3084,7 +3084,7 @@ do_cvt_mode(struct detailed_timing *timing, void
> > *c)
> >
> >  static int
> >  add_cvt_modes(struct drm_connector *connector, struct edid *edid) -{
> > +{
> >         struct detailed_mode_closure closure = {
> >                 .connector = connector,
> >                 .edid = edid,
> > @@ -4342,7 +4342,7 @@ void drm_edid_get_monitor_name(struct edid
> > *edid, char *name, int bufsize)  {
> >         int name_length;
> >         char buf[13];
> > -
> > +
> >         if (bufsize <= 0)
> >                 return;
> >
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
  2020-01-28 11:44       ` [Intel-gfx] " Ville Syrjälä
@ 2020-02-03 19:58         ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:58 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers



> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjälä
> Sent: Tuesday, January 28, 2020 5:14 PM
> To: Alex Deucher <alexdeucher@gmail.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Andres Rodriguez
> <andresx7@gmail.com>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [PATCH 5/8] drm/edid: Document why we don't bounds check the
> DispID CEA block start/end
> 
> On Mon, Jan 27, 2020 at 05:30:42PM -0500, Alex Deucher wrote:
> > On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> > <ville.syrjala@linux.intel.com> wrote:
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > After much head scratching I managed to convince myself that
> > > for_each_displayid_db() has already done the bounds checks for the
> > > DispID CEA data block. Which is why we don't need to repeat them in
> > > cea_db_offsets(). To avoid having to go through that pain again in
> > > the future add a comment which explains this fact.
> > >
> > > Cc: Andres Rodriguez <andresx7@gmail.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_edid.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index 3df5744026b0..0369a54e3d32 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
> > >          *   no non-DTD data.
> > >          */
> > >         if (cea[0] == DATA_BLOCK_CTA) {
> > > +               /*
> > > +                * for_each_displayid_db() has already verified
> > > +                * that these stay within expected bounds.
> > > +                */
> >
> > I think the preferred format is to have the start of the comment be on
> > the first line after the /* with that fixed:
> 
> Nope.

Yes the style is correct here, comment is apt as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > Acked-by: Alex Deucher <alexander.deucher@amd.com>
> >
> > >                 *start = 3;
> > >                 *end = *start + cea[2];
> > >         } else if (cea[0] == CEA_EXT) {
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> --
> Ville Syrjälä
> Intel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end
@ 2020-02-03 19:58         ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 19:58 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Intel Graphics Development, Andres Rodriguez,
	Maling list - DRI developers



> -----Original Message-----
> From: dri-devel <dri-devel-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjälä
> Sent: Tuesday, January 28, 2020 5:14 PM
> To: Alex Deucher <alexdeucher@gmail.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Andres Rodriguez
> <andresx7@gmail.com>; Maling list - DRI developers <dri-
> devel@lists.freedesktop.org>
> Subject: Re: [PATCH 5/8] drm/edid: Document why we don't bounds check the
> DispID CEA block start/end
> 
> On Mon, Jan 27, 2020 at 05:30:42PM -0500, Alex Deucher wrote:
> > On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> > <ville.syrjala@linux.intel.com> wrote:
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > After much head scratching I managed to convince myself that
> > > for_each_displayid_db() has already done the bounds checks for the
> > > DispID CEA data block. Which is why we don't need to repeat them in
> > > cea_db_offsets(). To avoid having to go through that pain again in
> > > the future add a comment which explains this fact.
> > >
> > > Cc: Andres Rodriguez <andresx7@gmail.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_edid.c | 4 ++++
> > >  1 file changed, 4 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index 3df5744026b0..0369a54e3d32 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -4001,6 +4001,10 @@ cea_db_offsets(const u8 *cea, int *start, int *end)
> > >          *   no non-DTD data.
> > >          */
> > >         if (cea[0] == DATA_BLOCK_CTA) {
> > > +               /*
> > > +                * for_each_displayid_db() has already verified
> > > +                * that these stay within expected bounds.
> > > +                */
> >
> > I think the preferred format is to have the start of the comment be on
> > the first line after the /* with that fixed:
> 
> Nope.

Yes the style is correct here, comment is apt as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > Acked-by: Alex Deucher <alexander.deucher@amd.com>
> >
> > >                 *start = 3;
> > >                 *end = *start + cea[2];
> > >         } else if (cea[0] == CEA_EXT) {
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> --
> Ville Syrjälä
> Intel
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
  2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
@ 2020-02-03 20:15     ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:15 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Andres Rodriguez



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjala
> Sent: Saturday, January 25, 2020 1:32 AM
> To: dri-devel@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez <andresx7@gmail.com>
> Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block
> revision
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I don't understand what the DispID CEA data block revision means. The spec doesn't
> say. I guess some DispID must have a value of >= 3 in there or else we generally
> wouldn't even parse the CEA data blocks. Or does all this code actually not do
> anything?

This signifies the CTA extension revision (byte 1 of the block). As per the spec, seems like
Version 1 is legacy and 2 is deprecated. So version >=3 is checked here.
Refer section 7.3 of CTA-861-G

> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
> 0369a54e3d32..fd9b724067a7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int  cea_revision(const
> u8 *cea)  {
> +	/*
> +	 * FIXME is this correct for the DispID variant?
> +	 * The DispID spec doesn't really specify whether
> +	 * this is the revision of the CEA extension or
> +	 * the DispID CEA data block. And the only value
> +	 * given as an example is 0.
> +	 */
>  	return cea[1];
>  }
> 
> --
> 2.24.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
@ 2020-02-03 20:15     ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:15 UTC (permalink / raw)
  To: Ville Syrjala, dri-devel; +Cc: intel-gfx, Andres Rodriguez



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjala
> Sent: Saturday, January 25, 2020 1:32 AM
> To: dri-devel@lists.freedesktop.org
> Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez <andresx7@gmail.com>
> Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block
> revision
> 
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> I don't understand what the DispID CEA data block revision means. The spec doesn't
> say. I guess some DispID must have a value of >= 3 in there or else we generally
> wouldn't even parse the CEA data blocks. Or does all this code actually not do
> anything?

This signifies the CTA extension revision (byte 1 of the block). As per the spec, seems like
Version 1 is legacy and 2 is deprecated. So version >=3 is checked here.
Refer section 7.3 of CTA-861-G

> Cc: Andres Rodriguez <andresx7@gmail.com>
> Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> ---
>  drivers/gpu/drm/drm_edid.c | 7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
> 0369a54e3d32..fd9b724067a7 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int  cea_revision(const
> u8 *cea)  {
> +	/*
> +	 * FIXME is this correct for the DispID variant?
> +	 * The DispID spec doesn't really specify whether
> +	 * this is the revision of the CEA extension or
> +	 * the DispID CEA data block. And the only value
> +	 * given as an example is 0.
> +	 */
>  	return cea[1];
>  }
> 
> --
> 2.24.1
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
  2020-01-28 11:49       ` [Intel-gfx] " Ville Syrjälä
@ 2020-02-03 20:34         ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:34 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjälä
> Sent: Tuesday, January 28, 2020 5:19 PM
> To: Alex Deucher <alexdeucher@gmail.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
> 
> On Mon, Jan 27, 2020 at 05:38:15PM -0500, Alex Deucher wrote:
> > On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> > <ville.syrjala@linux.intel.com> wrote:
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Let's try to make a lot more stuff const in the edid parser.
> > >
> > > The "downside" is that we can no longer mangle the EDID in the
> > > middle of the parsing to apply quirks (drm_mode_detailed()).
> > > I don't really think mangling the blob itself is such a great idea
> > > anyway so I won't miss that part. But if we do want it back I guess
> > > we should do the mangling in one explicit place before we otherwise
> > > parse the EDID.
> > >
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I generally agree, but are there any userspace expectations that they
> > will be getting a corrected EDID in some cases?
> 
> Not sure. I think the the only thing we're fixing up is some DTDs so at least there's a
> better way for userspace to get the fixed information (getconnector ioctl). I guess
> Xorg is still parsing the EDID though, but it should have more or less the same quirks
> in its parser.

Theoretically, there may be a possibility of userspace getting out of sync in case EDID exposed
to user is different to the quirked version getting used in kernel. I feel what you said in commit
message looks good, where we can do the quirks at one place and share the same to userspace.
Later just use that to proceed with parsing with constantifed edid in kernel.

Regards,
Uma Shankar

> >
> > Alex
> >
> > > ---
> > >  drivers/gpu/drm/drm_connector.c |   4 +-
> > >  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
> > >  include/drm/drm_connector.h     |   4 +-
> > >  3 files changed, 176 insertions(+), 135 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_connector.c
> > > b/drivers/gpu/drm/drm_connector.c index f632ca05960e..92a5cd6ff6b1
> > > 100644
> > > --- a/drivers/gpu/drm/drm_connector.c
> > > +++ b/drivers/gpu/drm/drm_connector.c
> > > @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
> > >   * tile group or NULL if not found.
> > >   */
> > >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > > -                                              char topology[8])
> > > +                                              const u8 topology[8])
> > >  {
> > >         struct drm_tile_group *tg;
> > >         int id;
> > > @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
> > >   * new tile group or NULL.
> > >   */
> > >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > > -                                                 char topology[8])
> > > +                                                 const u8
> > > + topology[8])
> > >  {
> > >         struct drm_tile_group *tg;
> > >         int ret;
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index fd9b724067a7..8e76efe1654d 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -88,7 +88,7 @@
> > >
> > >  struct detailed_mode_closure {
> > >         struct drm_connector *connector;
> > > -       struct edid *edid;
> > > +       const struct edid *edid;
> > >         bool preferred;
> > >         u32 quirks;
> > >         int modes;
> > > @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
> > >                  "Minimum number of valid EDID header bytes (0-8,
> > > default 6)");
> > >
> > >  static void drm_get_displayid(struct drm_connector *connector,
> > > -                             struct edid *edid);
> > > -static int validate_displayid(u8 *displayid, int length, int idx);
> > > +                             const struct edid *edid); static int
> > > +validate_displayid(const u8 *displayid, int length, int idx);
> > >
> > >  static int drm_edid_block_checksum(const u8 *raw_edid)  { @@
> > > -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
> > >         return d[0] != 0x00 || d[1] != 0x00;  }
> > >
> > > -typedef void detailed_cb(struct detailed_timing *timing, void
> > > *closure);
> > > +typedef void detailed_cb(const struct detailed_timing *timing, void
> > > +*closure);
> > >
> > >  static void
> > > -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void
> > > *closure)
> > > +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > > +*closure)
> > >  {
> > >         int i, n;
> > >         u8 d = ext[0x02];
> > > -       u8 *det_base = ext + d;
> > > +       const u8 *det_base = ext + d;
> > >
> > >         if (d < 4 || d > 127)
> > >                 return;
> > >
> > >         n = (127 - d) / 18;
> > >         for (i = 0; i < n; i++)
> > > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > > +               cb((const struct detailed_timing *)(det_base + 18 *
> > > + i), closure);
> > >  }
> > >
> > >  static void
> > > -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void
> > > *closure)
> > > +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > > +*closure)
> > >  {
> > >         unsigned int i, n = min((int)ext[0x02], 6);
> > > -       u8 *det_base = ext + 5;
> > > +       const u8 *det_base = ext + 5;
> > >
> > >         if (ext[0x01] != 1)
> > >                 return; /* unknown version */
> > >
> > >         for (i = 0; i < n; i++)
> > > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > > +               cb((const struct detailed_timing *)(det_base + 18 *
> > > + i), closure);
> > >  }
> > >
> > >  static void
> > > -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void
> > > *closure)
> > > +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb,
> > > +void *closure)
> > >  {
> > > +       const struct edid *edid = (struct edid *)raw_edid;
> > >         int i;
> > > -       struct edid *edid = (struct edid *)raw_edid;
> > >
> > >         if (edid == NULL)
> > >                 return;
> > > @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid,
> detailed_cb *cb, void *closure)
> > >                 cb(&(edid->detailed_timings[i]), closure);
> > >
> > >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> > > -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> > > +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
> > >                 switch (*ext) {
> > >                 case CEA_EXT:
> > >                         cea_for_each_detailed_block(ext, cb,
> > > closure); @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8
> *raw_edid, detailed_cb *cb, void *closure)
> > >         }
> > >  }
> > >
> > > +struct bool_closure {
> > > +       bool ret;
> > > +};
> > > +
> > >  static void
> > > -is_rb(struct detailed_timing *t, void *data)
> > > +is_rb(const struct detailed_timing *t, void *c)
> > >  {
> > > -       u8 *r = (u8 *)t;
> > > +       struct bool_closure *closure = c;
> > > +       const u8 *r = (const u8 *)t;
> > >
> > >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > >
> > >         if (r[15] & 0x10)
> > > -               *(bool *)data = true;
> > > +               closure->ret = true;
> > >  }
> > >
> > >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess,
> > > badly. */  static bool -drm_monitor_supports_rb(struct edid *edid)
> > > +drm_monitor_supports_rb(const struct edid *edid)
> > >  {
> > >         if (edid->revision >= 4) {
> > > -               bool ret = false;
> > > -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> > > -               return ret;
> > > +               struct bool_closure closure = {
> > > +                       .ret = false,
> > > +               };
> > > +
> > > +               drm_for_each_detailed_block((u8 *)edid, is_rb,
> > > + &closure);
> > > +
> > > +               return closure.ret;
> > >         }
> > >
> > >         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);  }
> > >
> > > +struct data_closure {
> > > +       const u8 *data;
> > > +};
> > > +
> > >  static void
> > > -find_gtf2(struct detailed_timing *t, void *data)
> > > +do_find_gtf2(const struct detailed_timing *t, void *c)
> > >  {
> > > -       u8 *r = (u8 *)t;
> > > +       struct data_closure *closure = c;
> > > +       const u8 *r = (const u8 *)t;
> > >
> > >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > >
> > >         if (r[10] == 0x02)
> > > -               *(u8 **)data = r;
> > > +               closure->data = r;
> > > +}
> > > +
> > > +static const u8 *
> > > +find_gtf2_descriptor(const struct edid *edid) {
> > > +       struct data_closure closure = {};
> > > +
> > > +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2,
> > > + &closure);
> > > +
> > > +       return closure.data;
> > >  }
> > >
> > >  /* Secondary GTF curve kicks in above some break frequency */
> > > static int -drm_gtf2_hbreak(struct edid *edid)
> > > +drm_gtf2_hbreak(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > -       return r ? (r[12] * 2) : 0;
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > > +       return r ? r[12] * 2 : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_2c(struct edid *edid)
> > > +drm_gtf2_2c(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[13] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_m(struct edid *edid)
> > > +drm_gtf2_m(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > -       return r ? (r[15] << 8) + r[14] : 0;
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > > +       return r ? (r[15] << 8) | r[14] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_k(struct edid *edid)
> > > +drm_gtf2_k(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[16] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_2j(struct edid *edid)
> > > +drm_gtf2_2j(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[17] : 0;
> > >  }
> > >
> > > @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
> > >   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
> > >   * @edid: EDID block to scan
> > >   */
> > > -static int standard_timing_level(struct edid *edid)
> > > +static int standard_timing_level(const struct edid *edid)
> > >  {
> > >         if (edid->revision >= 2) {
> > >                 if (edid->revision >= 4 && (edid->features &
> > > DRM_EDID_FEATURE_DEFAULT_GTF)) @@ -2381,8 +2405,9 @@
> bad_std_timing(u8 a, u8 b)
> > >   * and convert them into a real mode using CVT/GTF/DMT.
> > >   */
> > >  static struct drm_display_mode *
> > > -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > > -            struct std_timing *t)
> > > +drm_mode_std(struct drm_connector *connector,
> > > +            const struct edid *edid,
> > > +            const struct std_timing *t)
> > >  {
> > >         struct drm_device *dev = connector->dev;
> > >         struct drm_display_mode *m, *mode = NULL; @@ -2500,7 +2525,7
> > > @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > >   */
> > >  static void
> > >  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> > > -                           struct detailed_pixel_timing *pt)
> > > +                           const struct detailed_pixel_timing *pt)
> > >  {
> > >         int i;
> > >         static const struct {
> > > @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct
> drm_display_mode *mode,
> > >   * return a new struct drm_display_mode.
> > >   */
> > >  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> > > -                                                 struct edid *edid,
> > > -                                                 struct detailed_timing *timing,
> > > +                                                 const struct edid *edid,
> > > +                                                 const struct
> > > + detailed_timing *timing,
> > >                                                   u32 quirks)  {
> > >         struct drm_display_mode *mode;
> > > -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> > > +       const struct detailed_pixel_timing *pt =
> > > + &timing->data.pixel_data;
> > >         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
> > >         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
> > >         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 |
> > > pt->hblank_lo; @@ -2590,9 +2615,9 @@ static struct drm_display_mode
> *drm_mode_detailed(struct drm_device *dev,
> > >                 return NULL;
> > >
> > >         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> > > -               timing->pixel_clock = cpu_to_le16(1088);
> > > -
> > > -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > > +               mode->clock = 1088 * 10;
> > > +       else
> > > +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > >
> > >         mode->hdisplay = hactive;
> > >         mode->hsync_start = mode->hdisplay + hsync_offset; @@
> > > -2613,14 +2638,14 @@ static struct drm_display_mode
> *drm_mode_detailed(struct drm_device *dev,
> > >         drm_mode_do_interlace_quirk(mode, pt);
> > >
> > >         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> > > -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE |
> DRM_EDID_PT_VSYNC_POSITIVE;
> > > +               mode->flags |= DRM_MODE_FLAG_PHSYNC |
> DRM_MODE_FLAG_NVSYNC;
> > > +       } else {
> > > +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > > +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > > +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > > +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > >         }
> > >
> > > -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > > -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > > -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > > -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > > -
> > >  set_size:
> > >         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0)
> << 4;
> > >         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi
> > > & 0xf) << 8; @@ -2644,7 +2669,7 @@ static struct drm_display_mode
> > > *drm_mode_detailed(struct drm_device *dev,
> > >
> > >  static bool
> > >  mode_in_hsync_range(const struct drm_display_mode *mode,
> > > -                   struct edid *edid, u8 *t)
> > > +                   const struct edid *edid, const u8 *t)
> > >  {
> > >         int hsync, hmin, hmax;
> > >
> > > @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct
> > > drm_display_mode *mode,
> > >
> > >  static bool
> > >  mode_in_vsync_range(const struct drm_display_mode *mode,
> > > -                   struct edid *edid, u8 *t)
> > > +                   const struct edid *edid, const u8 *t)
> > >  {
> > >         int vsync, vmin, vmax;
> > >
> > > @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct
> > > drm_display_mode *mode,  }
> > >
> > >  static u32
> > > -range_pixel_clock(struct edid *edid, u8 *t)
> > > +range_pixel_clock(const struct edid *edid, const u8 *t)
> > >  {
> > >         /* unspecified */
> > >         if (t[9] == 0 || t[9] == 255) @@ -2692,11 +2717,12 @@
> > > range_pixel_clock(struct edid *edid, u8 *t)  }
> > >
> > >  static bool
> > > -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> > > -             struct detailed_timing *timing)
> > > +mode_in_range(const struct drm_display_mode *mode,
> > > +             const struct edid *edid,
> > > +             const struct detailed_timing *timing)
> > >  {
> > >         u32 max_clock;
> > > -       u8 *t = (u8 *)timing;
> > > +       const u8 *t = (const u8 *)timing;
> > >
> > >         if (!mode_in_hsync_range(mode, edid, t))
> > >                 return false;
> > > @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct
> > > drm_connector *connector,  }
> > >
> > >  static int
> > > -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid
> *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_dmt_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2773,8 +2800,9 @@ void
> > > drm_mode_fixup_1366x768(struct drm_display_mode *mode)  }
> > >
> > >  static int
> > > -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_gtf_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2801,8 +2829,9 @@
> > > drm_gtf_modes_for_range(struct drm_connector *connector, struct edid
> > > *edid,  }
> > >
> > >  static int
> > > -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_cvt_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2830,11 +2859,11 @@
> > > drm_cvt_modes_for_range(struct drm_connector *connector, struct edid
> > > *edid,  }
> > >
> > >  static void
> > > -do_inferred_modes(struct detailed_timing *timing, void *c)
> > > +do_inferred_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > > -       struct detailed_data_monitor_range *range = &data->data.range;
> > > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> > > +       const struct detailed_data_monitor_range *range =
> > > + &data->data.range;
> > >
> > >         if (!is_display_descriptor((const u8 *)timing,
> EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > > @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing
> > > *timing, void *c)  }
> > >
> > >  static int
> > > -add_inferred_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_inferred_modes(struct drm_connector *connector,
> > > +                  const struct edid *edid)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -2876,18 +2906,20 @@
> > > add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> > >         };
> > >
> > >         if (version_greater(edid, 1, 0))
> > > -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> > > +               drm_for_each_detailed_block((const u8 *)edid,
> > > +                                           do_inferred_modes,
> > >                                             &closure);
> > >
> > >         return closure.modes;
> > >  }
> > >
> > >  static int
> > > -drm_est3_modes(struct drm_connector *connector, struct
> > > detailed_timing *timing)
> > > +drm_est3_modes(struct drm_connector *connector,
> > > +              const struct detailed_timing *timing)
> > >  {
> > >         int i, j, m, modes = 0;
> > >         struct drm_display_mode *mode;
> > > -       u8 *est = ((u8 *)timing) + 6;
> > > +       const u8 *est = ((const u8 *)timing) + 6;
> > >
> > >         for (i = 0; i < 6; i++) {
> > >                 for (j = 7; j >= 0; j--) { @@ -2912,7 +2944,7 @@
> > > drm_est3_modes(struct drm_connector *connector, struct
> > > detailed_timing *timing)  }
> > >
> > >  static void
> > > -do_established_modes(struct detailed_timing *timing, void *c)
> > > +do_established_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >
> > > @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing,
> void *c)
> > >   * (defined above).  Tease them out and add them to the global modes list.
> > >   */
> > >  static int
> > > -add_established_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_established_modes(struct drm_connector *connector,
> > > +                     const struct edid *edid)
> > >  {
> > >         struct drm_device *dev = connector->dev;
> > >         unsigned long est_bits = edid->established_timings.t1 | @@
> > > -2962,19 +2995,19 @@ add_established_modes(struct drm_connector
> > > *connector, struct edid *edid)  }
> > >
> > >  static void
> > > -do_standard_modes(struct detailed_timing *timing, void *c)
> > > +do_standard_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > > +       const struct detailed_non_pixel *data =
> > > + &timing->data.other_data;
> > >         struct drm_connector *connector = closure->connector;
> > > -       struct edid *edid = closure->edid;
> > > +       const struct edid *edid = closure->edid;
> > >         int i;
> > >
> > >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> > >                 return;
> > >
> > >         for (i = 0; i < 6; i++) {
> > > -               struct std_timing *std = &data->data.timings[i];
> > > +               const struct std_timing *std =
> > > + &data->data.timings[i];
> > >                 struct drm_display_mode *newmode;
> > >
> > >                 newmode = drm_mode_std(connector, edid, std); @@
> > > -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void
> *c)
> > >   * GTF or CVT. Grab them from @edid and add them to the list.
> > >   */
> > >  static int
> > > -add_standard_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_standard_modes(struct drm_connector *connector,
> > > +                  const struct edid *edid)
> > >  {
> > >         int i, modes = 0;
> > >         struct detailed_mode_closure closure = { @@ -3023,18
> > > +3057,18 @@ add_standard_modes(struct drm_connector *connector,
> > > struct edid *edid)  }
> > >
> > >  static int drm_cvt_modes(struct drm_connector *connector,
> > > -                        struct detailed_timing *timing)
> > > +                        const struct detailed_timing *timing)
> > >  {
> > >         int i, j, modes = 0;
> > >         struct drm_display_mode *newmode;
> > >         struct drm_device *dev = connector->dev;
> > > -       struct cvt_timing *cvt;
> > >         const int rates[] = { 60, 85, 75, 60, 50 };
> > >         const u8 empty[3] = { 0, 0, 0 };
> > >
> > >         for (i = 0; i < 4; i++) {
> > >                 int uninitialized_var(width), height;
> > > -               cvt = &(timing->data.other_data.data.cvt[i]);
> > > +               const struct cvt_timing *cvt =
> > > +                       &timing->data.other_data.data.cvt[i];
> > >
> > >                 if (!memcmp(cvt->code, empty, 3))
> > >                         continue;
> > > @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector
> > > *connector,  }
> > >
> > >  static void
> > > -do_cvt_mode(struct detailed_timing *timing, void *c)
> > > +do_cvt_mode(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >
> > > @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing,
> > > void *c)  }
> > >
> > >  static int
> > > -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > > +add_cvt_modes(struct drm_connector *connector,
> > > +             const struct edid *edid)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -3101,7 +3136,7 @@
> > > add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > > static void fixup_detailed_cea_mode_clock(struct drm_display_mode
> > > *mode);
> > >
> > >  static void
> > > -do_detailed_mode(struct detailed_timing *timing, void *c)
> > > +do_detailed_mode(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >         struct drm_display_mode *newmode; @@ -3137,8 +3172,8 @@
> > > do_detailed_mode(struct detailed_timing *timing, void *c)
> > >   * @quirks: quirks to apply
> > >   */
> > >  static int
> > > -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> > > -                  u32 quirks)
> > > +add_detailed_modes(struct drm_connector *connector,
> > > +                  struct edid *edid, u32 quirks)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -3173,9 +3208,10 @@
> > > add_detailed_modes(struct drm_connector *connector, struct edid
> > > *edid,
> > >  /*
> > >   * Search EDID for CEA extension block.
> > >   */
> > > -static u8 *drm_find_edid_extension(const struct edid *edid, int
> > > ext_id)
> > > +static const u8 *drm_find_edid_extension(const struct edid *edid,
> > > +                                        int ext_id)
> > >  {
> > > -       u8 *edid_ext = NULL;
> > > +       const u8 *edid_ext = NULL;
> > >         int i;
> > >
> > >         /* No EDID or EDID extensions */ @@ -3184,7 +3220,7 @@
> > > static u8 *drm_find_edid_extension(const struct edid *edid, int
> > > ext_id)
> > >
> > >         /* Find CEA extension */
> > >         for (i = 0; i < edid->extensions; i++) {
> > > -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> > > +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
> > >                 if (edid_ext[0] == ext_id)
> > >                         break;
> > >         }
> > > @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const
> > > struct edid *edid, int ext_id)  }
> > >
> > >
> > > -static u8 *drm_find_displayid_extension(const struct edid *edid)
> > > +static const u8 *drm_find_displayid_extension(const struct edid
> > > +*edid)
> > >  {
> > >         return drm_find_edid_extension(edid, DISPLAYID_EXT);  }
> > >
> > > -static u8 *drm_find_cea_extension(const struct edid *edid)
> > > +static const u8 *drm_find_cea_extension(const struct edid *edid)
> > >  {
> > >         int ret;
> > >         int idx = 1;
> > >         int length = EDID_LENGTH;
> > > -       struct displayid_block *block;
> > > -       u8 *cea;
> > > -       u8 *displayid;
> > > +       const struct displayid_block *block;
> > > +       const u8 *cea;
> > > +       const u8 *displayid;
> > >
> > >         /* Look for a top level CEA extension block */
> > >         cea = drm_find_edid_extension(edid, CEA_EXT); @@ -4315,28
> > > +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector
> > > *connector, const u8 *db)  }
> > >
> > >  static void
> > > -monitor_name(struct detailed_timing *t, void *data)
> > > +monitor_name(const struct detailed_timing *t, void *c)
> > >  {
> > > +       struct data_closure *closure = c;
> > > +
> > >         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> > >                 return;
> > >
> > > -       *(u8 **)data = t->data.other_data.data.str.str;
> > > +       closure->data = t->data.other_data.data.str.str;
> > >  }
> > >
> > >  static int get_monitor_name(struct edid *edid, char name[13])  {
> > > -       char *edid_name = NULL;
> > > +       struct data_closure closure = {};
> > >         int mnl;
> > >
> > >         if (!edid || !name)
> > >                 return 0;
> > >
> > > -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> > > -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> > > -               if (edid_name[mnl] == 0x0a)
> > > +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> > > +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> > > +               if (closure.data[mnl] == 0x0a)
> > >                         break;
> > >
> > > -               name[mnl] = edid_name[mnl];
> > > +               name[mnl] = closure.data[mnl];
> > >         }
> > >
> > >         return mnl;
> > > @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector
> > > *connector)  static void drm_edid_to_eld(struct drm_connector
> > > *connector, struct edid *edid)  {
> > >         uint8_t *eld = connector->eld;
> > > -       u8 *cea;
> > > -       u8 *db;
> > > +       const u8 *cea;
> > >         int total_sad_count = 0;
> > >         int mnl;
> > > -       int dbl;
> > >
> > >         clear_eld(connector);
> > >
> > > @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector
> *connector, struct edid *edid)
> > >                 }
> > >
> > >                 for_each_cea_db(cea, i, start, end) {
> > > -                       db = &cea[i];
> > > -                       dbl = cea_db_payload_len(db);
> > > +                       const u8 *db = &cea[i];
> > > +                       int dbl = cea_db_payload_len(db);
> > >
> > >                         switch (cea_db_tag(db)) {
> > >                                 int sad_count; @@ -4484,7 +4520,7 @@
> > > int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)  {
> > >         int count = 0;
> > >         int i, start, end, dbl;
> > > -       u8 *cea;
> > > +       const u8 *cea;
> > >
> > >         cea = drm_find_cea_extension(edid);
> > >         if (!cea) {
> > > @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad
> **sads)
> > >         }
> > >
> > >         for_each_cea_db(cea, i, start, end) {
> > > -               u8 *db = &cea[i];
> > > +               const u8 *db = &cea[i];
> > >
> > >                 if (cea_db_tag(db) == AUDIO_BLOCK) {
> > >                         int j;
> > > @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad
> **sads)
> > >                         if (!*sads)
> > >                                 return -ENOMEM;
> > >                         for (j = 0; j < count; j++) {
> > > -                               u8 *sad = &db[1 + j * 3];
> > > +                               const u8 *sad = &db[1 + j * 3];
> > >
> > >                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
> > >                                 (*sads)[j].channels = sad[0] & 0x7;
> > > @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
> > >   */
> > >  bool drm_detect_hdmi_monitor(struct edid *edid)  {
> > > -       u8 *edid_ext;
> > > +       const u8 *edid_ext;
> > >         int i;
> > >         int start_offset, end_offset;
> > >
> > > @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
> > >   */
> > >  bool drm_detect_monitor_audio(struct edid *edid)  {
> > > -       u8 *edid_ext;
> > > +       const u8 *edid_ext;
> > >         int i, j;
> > >         bool has_audio = false;
> > >         int start_offset, end_offset; @@ -5017,13 +5053,13 @@ u32
> > > drm_add_display_info(struct drm_connector *connector, const struct edid *edi
> > >         return quirks;
> > >  }
> > >
> > > -static int validate_displayid(u8 *displayid, int length, int idx)
> > > +static int validate_displayid(const u8 *displayid, int length, int
> > > +idx)
> > >  {
> > >         int i;
> > >         u8 csum = 0;
> > > -       struct displayid_hdr *base;
> > > +       const struct displayid_hdr *base;
> > >
> > > -       base = (struct displayid_hdr *)&displayid[idx];
> > > +       base = (const struct displayid_hdr *)&displayid[idx];
> > >
> > >         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> > >                       base->rev, base->bytes, base->prod_id,
> > > base->ext_count); @@ -5041,7 +5077,7 @@ static int
> > > validate_displayid(u8 *displayid, int length, int idx)  }
> > >
> > >  static struct drm_display_mode *drm_mode_displayid_detailed(struct
> drm_device *dev,
> > > -                                                           struct displayid_detailed_timings_1 *timings)
> > > +                                                           const
> > > + struct displayid_detailed_timings_1 *timings)
> > >  {
> > >         struct drm_display_mode *mode;
> > >         unsigned pixel_clock = (timings->pixel_clock[0] | @@ -5057,6
> > > +5093,7 @@ static struct drm_display_mode
> *drm_mode_displayid_detailed(struct drm_device *d
> > >         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
> > >         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
> > >         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> > > +
> > >         mode = drm_mode_create(dev);
> > >         if (!mode)
> > >                 return NULL;
> > > @@ -5086,9 +5123,10 @@ static struct drm_display_mode
> > > *drm_mode_displayid_detailed(struct drm_device *d  }
> > >
> > >  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> > > -                                         struct displayid_block *block)
> > > +                                         const struct
> > > + displayid_block *block)
> > >  {
> > > -       struct displayid_detailed_timing_block *det = (struct
> displayid_detailed_timing_block *)block;
> > > +       const struct displayid_detailed_timing_block *det =
> > > +               (const struct displayid_detailed_timing_block
> > > + *)block;
> > >         int i;
> > >         int num_timings;
> > >         struct drm_display_mode *newmode; @@ -5099,7 +5137,7 @@
> > > static int add_displayid_detailed_1_modes(struct drm_connector
> > > *connector,
> > >
> > >         num_timings = block->num_bytes / 20;
> > >         for (i = 0; i < num_timings; i++) {
> > > -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> > > +               const struct displayid_detailed_timings_1 *timings =
> > > + &det->timings[i];
> > >
> > >                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
> > >                 if (!newmode)
> > > @@ -5112,13 +5150,13 @@ static int
> > > add_displayid_detailed_1_modes(struct drm_connector *connector,  }
> > >
> > >  static int add_displayid_detailed_modes(struct drm_connector *connector,
> > > -                                       struct edid *edid)
> > > +                                       const struct edid *edid)
> > >  {
> > > -       u8 *displayid;
> > > +       const u8 *displayid;
> > >         int ret;
> > >         int idx = 1;
> > >         int length = EDID_LENGTH;
> > > -       struct displayid_block *block;
> > > +       const struct displayid_block *block;
> > >         int num_modes = 0;
> > >
> > >         displayid = drm_find_displayid_extension(edid);
> > > @@ -5720,9 +5758,10 @@
> > > drm_hdmi_vendor_infoframe_from_display_mode(struct
> > > hdmi_vendor_infoframe *frame,
> > > EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
> > >
> > >  static int drm_parse_tiled_block(struct drm_connector *connector,
> > > -                                struct displayid_block *block)
> > > +                                const struct displayid_block
> > > + *block)
> > >  {
> > > -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> > > +       const struct displayid_tiled_block *tile =
> > > +               (const struct displayid_tiled_block *)block;
> > >         u16 w, h;
> > >         u8 tile_v_loc, tile_h_loc;
> > >         u8 num_v_tile, num_h_tile;
> > > @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct
> > > drm_connector *connector,  }
> > >
> > >  static int drm_parse_display_id(struct drm_connector *connector,
> > > -                               u8 *displayid, int length,
> > > +                               const u8 *displayid, int length,
> > >                                 bool is_edid_extension)  {
> > >         /* if this is an EDID extension the first byte will be 0x70 */
> > >         int idx = 0;
> > > -       struct displayid_block *block;
> > > +       const struct displayid_block *block;
> > >         int ret;
> > >
> > >         if (is_edid_extension)
> > > @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct
> > > drm_connector *connector,  }
> > >
> > >  static void drm_get_displayid(struct drm_connector *connector,
> > > -                             struct edid *edid)
> > > +                             const struct edid *edid)
> > >  {
> > > -       void *displayid = NULL;
> > > +       const void *displayid;
> > >         int ret;
> > > +
> > >         connector->has_tile = false;
> > > +
> > >         displayid = drm_find_displayid_extension(edid);
> > >         if (!displayid) {
> > >                 /* drop reference to any tile group we had */ diff
> > > --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > > index 2113500b4075..c0f9ce3f4b24 100644
> > > --- a/include/drm/drm_connector.h
> > > +++ b/include/drm/drm_connector.h
> > > @@ -1580,9 +1580,9 @@ struct drm_tile_group {  };
> > >
> > >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > > -                                                 char topology[8]);
> > > +                                                 const u8
> > > + topology[8]);
> > >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > > -                                              char topology[8]);
> > > +                                              const u8
> > > + topology[8]);
> > >  void drm_mode_put_tile_group(struct drm_device *dev,
> > >                              struct drm_tile_group *tg);
> > >
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> --
> Ville Syrjälä
> Intel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
@ 2020-02-03 20:34         ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:34 UTC (permalink / raw)
  To: Ville Syrjälä, Alex Deucher
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjälä
> Sent: Tuesday, January 28, 2020 5:19 PM
> To: Alex Deucher <alexdeucher@gmail.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 7/8] drm/edid: Constify lots of things
> 
> On Mon, Jan 27, 2020 at 05:38:15PM -0500, Alex Deucher wrote:
> > On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala
> > <ville.syrjala@linux.intel.com> wrote:
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > Let's try to make a lot more stuff const in the edid parser.
> > >
> > > The "downside" is that we can no longer mangle the EDID in the
> > > middle of the parsing to apply quirks (drm_mode_detailed()).
> > > I don't really think mangling the blob itself is such a great idea
> > > anyway so I won't miss that part. But if we do want it back I guess
> > > we should do the mangling in one explicit place before we otherwise
> > > parse the EDID.
> > >
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I generally agree, but are there any userspace expectations that they
> > will be getting a corrected EDID in some cases?
> 
> Not sure. I think the the only thing we're fixing up is some DTDs so at least there's a
> better way for userspace to get the fixed information (getconnector ioctl). I guess
> Xorg is still parsing the EDID though, but it should have more or less the same quirks
> in its parser.

Theoretically, there may be a possibility of userspace getting out of sync in case EDID exposed
to user is different to the quirked version getting used in kernel. I feel what you said in commit
message looks good, where we can do the quirks at one place and share the same to userspace.
Later just use that to proceed with parsing with constantifed edid in kernel.

Regards,
Uma Shankar

> >
> > Alex
> >
> > > ---
> > >  drivers/gpu/drm/drm_connector.c |   4 +-
> > >  drivers/gpu/drm/drm_edid.c      | 303 ++++++++++++++++++--------------
> > >  include/drm/drm_connector.h     |   4 +-
> > >  3 files changed, 176 insertions(+), 135 deletions(-)
> > >
> > > diff --git a/drivers/gpu/drm/drm_connector.c
> > > b/drivers/gpu/drm/drm_connector.c index f632ca05960e..92a5cd6ff6b1
> > > 100644
> > > --- a/drivers/gpu/drm/drm_connector.c
> > > +++ b/drivers/gpu/drm/drm_connector.c
> > > @@ -2377,7 +2377,7 @@ EXPORT_SYMBOL(drm_mode_put_tile_group);
> > >   * tile group or NULL if not found.
> > >   */
> > >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > > -                                              char topology[8])
> > > +                                              const u8 topology[8])
> > >  {
> > >         struct drm_tile_group *tg;
> > >         int id;
> > > @@ -2407,7 +2407,7 @@ EXPORT_SYMBOL(drm_mode_get_tile_group);
> > >   * new tile group or NULL.
> > >   */
> > >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > > -                                                 char topology[8])
> > > +                                                 const u8
> > > + topology[8])
> > >  {
> > >         struct drm_tile_group *tg;
> > >         int ret;
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index fd9b724067a7..8e76efe1654d 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -88,7 +88,7 @@
> > >
> > >  struct detailed_mode_closure {
> > >         struct drm_connector *connector;
> > > -       struct edid *edid;
> > > +       const struct edid *edid;
> > >         bool preferred;
> > >         u32 quirks;
> > >         int modes;
> > > @@ -1584,8 +1584,8 @@ MODULE_PARM_DESC(edid_fixup,
> > >                  "Minimum number of valid EDID header bytes (0-8,
> > > default 6)");
> > >
> > >  static void drm_get_displayid(struct drm_connector *connector,
> > > -                             struct edid *edid);
> > > -static int validate_displayid(u8 *displayid, int length, int idx);
> > > +                             const struct edid *edid); static int
> > > +validate_displayid(const u8 *displayid, int length, int idx);
> > >
> > >  static int drm_edid_block_checksum(const u8 *raw_edid)  { @@
> > > -2207,41 +2207,41 @@ static bool is_detailed_timing_descriptor(const u8 d[18])
> > >         return d[0] != 0x00 || d[1] != 0x00;  }
> > >
> > > -typedef void detailed_cb(struct detailed_timing *timing, void
> > > *closure);
> > > +typedef void detailed_cb(const struct detailed_timing *timing, void
> > > +*closure);
> > >
> > >  static void
> > > -cea_for_each_detailed_block(u8 *ext, detailed_cb *cb, void
> > > *closure)
> > > +cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > > +*closure)
> > >  {
> > >         int i, n;
> > >         u8 d = ext[0x02];
> > > -       u8 *det_base = ext + d;
> > > +       const u8 *det_base = ext + d;
> > >
> > >         if (d < 4 || d > 127)
> > >                 return;
> > >
> > >         n = (127 - d) / 18;
> > >         for (i = 0; i < n; i++)
> > > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > > +               cb((const struct detailed_timing *)(det_base + 18 *
> > > + i), closure);
> > >  }
> > >
> > >  static void
> > > -vtb_for_each_detailed_block(u8 *ext, detailed_cb *cb, void
> > > *closure)
> > > +vtb_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > > +*closure)
> > >  {
> > >         unsigned int i, n = min((int)ext[0x02], 6);
> > > -       u8 *det_base = ext + 5;
> > > +       const u8 *det_base = ext + 5;
> > >
> > >         if (ext[0x01] != 1)
> > >                 return; /* unknown version */
> > >
> > >         for (i = 0; i < n; i++)
> > > -               cb((struct detailed_timing *)(det_base + 18 * i), closure);
> > > +               cb((const struct detailed_timing *)(det_base + 18 *
> > > + i), closure);
> > >  }
> > >
> > >  static void
> > > -drm_for_each_detailed_block(u8 *raw_edid, detailed_cb *cb, void
> > > *closure)
> > > +drm_for_each_detailed_block(const u8 *raw_edid, detailed_cb *cb,
> > > +void *closure)
> > >  {
> > > +       const struct edid *edid = (struct edid *)raw_edid;
> > >         int i;
> > > -       struct edid *edid = (struct edid *)raw_edid;
> > >
> > >         if (edid == NULL)
> > >                 return;
> > > @@ -2250,7 +2250,7 @@ drm_for_each_detailed_block(u8 *raw_edid,
> detailed_cb *cb, void *closure)
> > >                 cb(&(edid->detailed_timings[i]), closure);
> > >
> > >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> > > -               u8 *ext = raw_edid + (i * EDID_LENGTH);
> > > +               const u8 *ext = raw_edid + (i * EDID_LENGTH);
> > >                 switch (*ext) {
> > >                 case CEA_EXT:
> > >                         cea_for_each_detailed_block(ext, cb,
> > > closure); @@ -2264,81 +2264,105 @@ drm_for_each_detailed_block(u8
> *raw_edid, detailed_cb *cb, void *closure)
> > >         }
> > >  }
> > >
> > > +struct bool_closure {
> > > +       bool ret;
> > > +};
> > > +
> > >  static void
> > > -is_rb(struct detailed_timing *t, void *data)
> > > +is_rb(const struct detailed_timing *t, void *c)
> > >  {
> > > -       u8 *r = (u8 *)t;
> > > +       struct bool_closure *closure = c;
> > > +       const u8 *r = (const u8 *)t;
> > >
> > >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > >
> > >         if (r[15] & 0x10)
> > > -               *(bool *)data = true;
> > > +               closure->ret = true;
> > >  }
> > >
> > >  /* EDID 1.4 defines this explicitly.  For EDID 1.3, we guess,
> > > badly. */  static bool -drm_monitor_supports_rb(struct edid *edid)
> > > +drm_monitor_supports_rb(const struct edid *edid)
> > >  {
> > >         if (edid->revision >= 4) {
> > > -               bool ret = false;
> > > -               drm_for_each_detailed_block((u8 *)edid, is_rb, &ret);
> > > -               return ret;
> > > +               struct bool_closure closure = {
> > > +                       .ret = false,
> > > +               };
> > > +
> > > +               drm_for_each_detailed_block((u8 *)edid, is_rb,
> > > + &closure);
> > > +
> > > +               return closure.ret;
> > >         }
> > >
> > >         return ((edid->input & DRM_EDID_INPUT_DIGITAL) != 0);  }
> > >
> > > +struct data_closure {
> > > +       const u8 *data;
> > > +};
> > > +
> > >  static void
> > > -find_gtf2(struct detailed_timing *t, void *data)
> > > +do_find_gtf2(const struct detailed_timing *t, void *c)
> > >  {
> > > -       u8 *r = (u8 *)t;
> > > +       struct data_closure *closure = c;
> > > +       const u8 *r = (const u8 *)t;
> > >
> > >         if (!is_display_descriptor(r, EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > >
> > >         if (r[10] == 0x02)
> > > -               *(u8 **)data = r;
> > > +               closure->data = r;
> > > +}
> > > +
> > > +static const u8 *
> > > +find_gtf2_descriptor(const struct edid *edid) {
> > > +       struct data_closure closure = {};
> > > +
> > > +       drm_for_each_detailed_block((u8 *)edid, do_find_gtf2,
> > > + &closure);
> > > +
> > > +       return closure.data;
> > >  }
> > >
> > >  /* Secondary GTF curve kicks in above some break frequency */
> > > static int -drm_gtf2_hbreak(struct edid *edid)
> > > +drm_gtf2_hbreak(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > -       return r ? (r[12] * 2) : 0;
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > > +       return r ? r[12] * 2 : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_2c(struct edid *edid)
> > > +drm_gtf2_2c(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[13] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_m(struct edid *edid)
> > > +drm_gtf2_m(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > -       return r ? (r[15] << 8) + r[14] : 0;
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > > +       return r ? (r[15] << 8) | r[14] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_k(struct edid *edid)
> > > +drm_gtf2_k(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[16] : 0;
> > >  }
> > >
> > >  static int
> > > -drm_gtf2_2j(struct edid *edid)
> > > +drm_gtf2_2j(const struct edid *edid)
> > >  {
> > > -       u8 *r = NULL;
> > > -       drm_for_each_detailed_block((u8 *)edid, find_gtf2, &r);
> > > +       const u8 *r = find_gtf2_descriptor(edid);
> > > +
> > >         return r ? r[17] : 0;
> > >  }
> > >
> > > @@ -2346,7 +2370,7 @@ drm_gtf2_2j(struct edid *edid)
> > >   * standard_timing_level - get std. timing level(CVT/GTF/DMT)
> > >   * @edid: EDID block to scan
> > >   */
> > > -static int standard_timing_level(struct edid *edid)
> > > +static int standard_timing_level(const struct edid *edid)
> > >  {
> > >         if (edid->revision >= 2) {
> > >                 if (edid->revision >= 4 && (edid->features &
> > > DRM_EDID_FEATURE_DEFAULT_GTF)) @@ -2381,8 +2405,9 @@
> bad_std_timing(u8 a, u8 b)
> > >   * and convert them into a real mode using CVT/GTF/DMT.
> > >   */
> > >  static struct drm_display_mode *
> > > -drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > > -            struct std_timing *t)
> > > +drm_mode_std(struct drm_connector *connector,
> > > +            const struct edid *edid,
> > > +            const struct std_timing *t)
> > >  {
> > >         struct drm_device *dev = connector->dev;
> > >         struct drm_display_mode *m, *mode = NULL; @@ -2500,7 +2525,7
> > > @@ drm_mode_std(struct drm_connector *connector, struct edid *edid,
> > >   */
> > >  static void
> > >  drm_mode_do_interlace_quirk(struct drm_display_mode *mode,
> > > -                           struct detailed_pixel_timing *pt)
> > > +                           const struct detailed_pixel_timing *pt)
> > >  {
> > >         int i;
> > >         static const struct {
> > > @@ -2543,12 +2568,12 @@ drm_mode_do_interlace_quirk(struct
> drm_display_mode *mode,
> > >   * return a new struct drm_display_mode.
> > >   */
> > >  static struct drm_display_mode *drm_mode_detailed(struct drm_device *dev,
> > > -                                                 struct edid *edid,
> > > -                                                 struct detailed_timing *timing,
> > > +                                                 const struct edid *edid,
> > > +                                                 const struct
> > > + detailed_timing *timing,
> > >                                                   u32 quirks)  {
> > >         struct drm_display_mode *mode;
> > > -       struct detailed_pixel_timing *pt = &timing->data.pixel_data;
> > > +       const struct detailed_pixel_timing *pt =
> > > + &timing->data.pixel_data;
> > >         unsigned hactive = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
> > >         unsigned vactive = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
> > >         unsigned hblank = (pt->hactive_hblank_hi & 0xf) << 8 |
> > > pt->hblank_lo; @@ -2590,9 +2615,9 @@ static struct drm_display_mode
> *drm_mode_detailed(struct drm_device *dev,
> > >                 return NULL;
> > >
> > >         if (quirks & EDID_QUIRK_135_CLOCK_TOO_HIGH)
> > > -               timing->pixel_clock = cpu_to_le16(1088);
> > > -
> > > -       mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > > +               mode->clock = 1088 * 10;
> > > +       else
> > > +               mode->clock = le16_to_cpu(timing->pixel_clock) * 10;
> > >
> > >         mode->hdisplay = hactive;
> > >         mode->hsync_start = mode->hdisplay + hsync_offset; @@
> > > -2613,14 +2638,14 @@ static struct drm_display_mode
> *drm_mode_detailed(struct drm_device *dev,
> > >         drm_mode_do_interlace_quirk(mode, pt);
> > >
> > >         if (quirks & EDID_QUIRK_DETAILED_SYNC_PP) {
> > > -               pt->misc |= DRM_EDID_PT_HSYNC_POSITIVE |
> DRM_EDID_PT_VSYNC_POSITIVE;
> > > +               mode->flags |= DRM_MODE_FLAG_PHSYNC |
> DRM_MODE_FLAG_NVSYNC;
> > > +       } else {
> > > +               mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > > +                       DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > > +               mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > > +                       DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > >         }
> > >
> > > -       mode->flags |= (pt->misc & DRM_EDID_PT_HSYNC_POSITIVE) ?
> > > -               DRM_MODE_FLAG_PHSYNC : DRM_MODE_FLAG_NHSYNC;
> > > -       mode->flags |= (pt->misc & DRM_EDID_PT_VSYNC_POSITIVE) ?
> > > -               DRM_MODE_FLAG_PVSYNC : DRM_MODE_FLAG_NVSYNC;
> > > -
> > >  set_size:
> > >         mode->width_mm = pt->width_mm_lo | (pt->width_height_mm_hi & 0xf0)
> << 4;
> > >         mode->height_mm = pt->height_mm_lo | (pt->width_height_mm_hi
> > > & 0xf) << 8; @@ -2644,7 +2669,7 @@ static struct drm_display_mode
> > > *drm_mode_detailed(struct drm_device *dev,
> > >
> > >  static bool
> > >  mode_in_hsync_range(const struct drm_display_mode *mode,
> > > -                   struct edid *edid, u8 *t)
> > > +                   const struct edid *edid, const u8 *t)
> > >  {
> > >         int hsync, hmin, hmax;
> > >
> > > @@ -2661,7 +2686,7 @@ mode_in_hsync_range(const struct
> > > drm_display_mode *mode,
> > >
> > >  static bool
> > >  mode_in_vsync_range(const struct drm_display_mode *mode,
> > > -                   struct edid *edid, u8 *t)
> > > +                   const struct edid *edid, const u8 *t)
> > >  {
> > >         int vsync, vmin, vmax;
> > >
> > > @@ -2677,7 +2702,7 @@ mode_in_vsync_range(const struct
> > > drm_display_mode *mode,  }
> > >
> > >  static u32
> > > -range_pixel_clock(struct edid *edid, u8 *t)
> > > +range_pixel_clock(const struct edid *edid, const u8 *t)
> > >  {
> > >         /* unspecified */
> > >         if (t[9] == 0 || t[9] == 255) @@ -2692,11 +2717,12 @@
> > > range_pixel_clock(struct edid *edid, u8 *t)  }
> > >
> > >  static bool
> > > -mode_in_range(const struct drm_display_mode *mode, struct edid *edid,
> > > -             struct detailed_timing *timing)
> > > +mode_in_range(const struct drm_display_mode *mode,
> > > +             const struct edid *edid,
> > > +             const struct detailed_timing *timing)
> > >  {
> > >         u32 max_clock;
> > > -       u8 *t = (u8 *)timing;
> > > +       const u8 *t = (const u8 *)timing;
> > >
> > >         if (!mode_in_hsync_range(mode, edid, t))
> > >                 return false;
> > > @@ -2738,8 +2764,9 @@ static bool valid_inferred_mode(const struct
> > > drm_connector *connector,  }
> > >
> > >  static int
> > > -drm_dmt_modes_for_range(struct drm_connector *connector, struct edid
> *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_dmt_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2773,8 +2800,9 @@ void
> > > drm_mode_fixup_1366x768(struct drm_display_mode *mode)  }
> > >
> > >  static int
> > > -drm_gtf_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_gtf_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2801,8 +2829,9 @@
> > > drm_gtf_modes_for_range(struct drm_connector *connector, struct edid
> > > *edid,  }
> > >
> > >  static int
> > > -drm_cvt_modes_for_range(struct drm_connector *connector, struct edid *edid,
> > > -                       struct detailed_timing *timing)
> > > +drm_cvt_modes_for_range(struct drm_connector *connector,
> > > +                       const struct edid *edid,
> > > +                       const struct detailed_timing *timing)
> > >  {
> > >         int i, modes = 0;
> > >         struct drm_display_mode *newmode; @@ -2830,11 +2859,11 @@
> > > drm_cvt_modes_for_range(struct drm_connector *connector, struct edid
> > > *edid,  }
> > >
> > >  static void
> > > -do_inferred_modes(struct detailed_timing *timing, void *c)
> > > +do_inferred_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > > -       struct detailed_data_monitor_range *range = &data->data.range;
> > > +       const struct detailed_non_pixel *data = &timing->data.other_data;
> > > +       const struct detailed_data_monitor_range *range =
> > > + &data->data.range;
> > >
> > >         if (!is_display_descriptor((const u8 *)timing,
> EDID_DETAIL_MONITOR_RANGE))
> > >                 return;
> > > @@ -2868,7 +2897,8 @@ do_inferred_modes(struct detailed_timing
> > > *timing, void *c)  }
> > >
> > >  static int
> > > -add_inferred_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_inferred_modes(struct drm_connector *connector,
> > > +                  const struct edid *edid)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -2876,18 +2906,20 @@
> > > add_inferred_modes(struct drm_connector *connector, struct edid *edid)
> > >         };
> > >
> > >         if (version_greater(edid, 1, 0))
> > > -               drm_for_each_detailed_block((u8 *)edid, do_inferred_modes,
> > > +               drm_for_each_detailed_block((const u8 *)edid,
> > > +                                           do_inferred_modes,
> > >                                             &closure);
> > >
> > >         return closure.modes;
> > >  }
> > >
> > >  static int
> > > -drm_est3_modes(struct drm_connector *connector, struct
> > > detailed_timing *timing)
> > > +drm_est3_modes(struct drm_connector *connector,
> > > +              const struct detailed_timing *timing)
> > >  {
> > >         int i, j, m, modes = 0;
> > >         struct drm_display_mode *mode;
> > > -       u8 *est = ((u8 *)timing) + 6;
> > > +       const u8 *est = ((const u8 *)timing) + 6;
> > >
> > >         for (i = 0; i < 6; i++) {
> > >                 for (j = 7; j >= 0; j--) { @@ -2912,7 +2944,7 @@
> > > drm_est3_modes(struct drm_connector *connector, struct
> > > detailed_timing *timing)  }
> > >
> > >  static void
> > > -do_established_modes(struct detailed_timing *timing, void *c)
> > > +do_established_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >
> > > @@ -2931,7 +2963,8 @@ do_established_modes(struct detailed_timing *timing,
> void *c)
> > >   * (defined above).  Tease them out and add them to the global modes list.
> > >   */
> > >  static int
> > > -add_established_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_established_modes(struct drm_connector *connector,
> > > +                     const struct edid *edid)
> > >  {
> > >         struct drm_device *dev = connector->dev;
> > >         unsigned long est_bits = edid->established_timings.t1 | @@
> > > -2962,19 +2995,19 @@ add_established_modes(struct drm_connector
> > > *connector, struct edid *edid)  }
> > >
> > >  static void
> > > -do_standard_modes(struct detailed_timing *timing, void *c)
> > > +do_standard_modes(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > > -       struct detailed_non_pixel *data = &timing->data.other_data;
> > > +       const struct detailed_non_pixel *data =
> > > + &timing->data.other_data;
> > >         struct drm_connector *connector = closure->connector;
> > > -       struct edid *edid = closure->edid;
> > > +       const struct edid *edid = closure->edid;
> > >         int i;
> > >
> > >         if (!is_display_descriptor((const u8 *)timing, EDID_DETAIL_STD_MODES))
> > >                 return;
> > >
> > >         for (i = 0; i < 6; i++) {
> > > -               struct std_timing *std = &data->data.timings[i];
> > > +               const struct std_timing *std =
> > > + &data->data.timings[i];
> > >                 struct drm_display_mode *newmode;
> > >
> > >                 newmode = drm_mode_std(connector, edid, std); @@
> > > -2994,7 +3027,8 @@ do_standard_modes(struct detailed_timing *timing, void
> *c)
> > >   * GTF or CVT. Grab them from @edid and add them to the list.
> > >   */
> > >  static int
> > > -add_standard_modes(struct drm_connector *connector, struct edid
> > > *edid)
> > > +add_standard_modes(struct drm_connector *connector,
> > > +                  const struct edid *edid)
> > >  {
> > >         int i, modes = 0;
> > >         struct detailed_mode_closure closure = { @@ -3023,18
> > > +3057,18 @@ add_standard_modes(struct drm_connector *connector,
> > > struct edid *edid)  }
> > >
> > >  static int drm_cvt_modes(struct drm_connector *connector,
> > > -                        struct detailed_timing *timing)
> > > +                        const struct detailed_timing *timing)
> > >  {
> > >         int i, j, modes = 0;
> > >         struct drm_display_mode *newmode;
> > >         struct drm_device *dev = connector->dev;
> > > -       struct cvt_timing *cvt;
> > >         const int rates[] = { 60, 85, 75, 60, 50 };
> > >         const u8 empty[3] = { 0, 0, 0 };
> > >
> > >         for (i = 0; i < 4; i++) {
> > >                 int uninitialized_var(width), height;
> > > -               cvt = &(timing->data.other_data.data.cvt[i]);
> > > +               const struct cvt_timing *cvt =
> > > +                       &timing->data.other_data.data.cvt[i];
> > >
> > >                 if (!memcmp(cvt->code, empty, 3))
> > >                         continue;
> > > @@ -3072,7 +3106,7 @@ static int drm_cvt_modes(struct drm_connector
> > > *connector,  }
> > >
> > >  static void
> > > -do_cvt_mode(struct detailed_timing *timing, void *c)
> > > +do_cvt_mode(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >
> > > @@ -3083,7 +3117,8 @@ do_cvt_mode(struct detailed_timing *timing,
> > > void *c)  }
> > >
> > >  static int
> > > -add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > > +add_cvt_modes(struct drm_connector *connector,
> > > +             const struct edid *edid)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -3101,7 +3136,7 @@
> > > add_cvt_modes(struct drm_connector *connector, struct edid *edid)
> > > static void fixup_detailed_cea_mode_clock(struct drm_display_mode
> > > *mode);
> > >
> > >  static void
> > > -do_detailed_mode(struct detailed_timing *timing, void *c)
> > > +do_detailed_mode(const struct detailed_timing *timing, void *c)
> > >  {
> > >         struct detailed_mode_closure *closure = c;
> > >         struct drm_display_mode *newmode; @@ -3137,8 +3172,8 @@
> > > do_detailed_mode(struct detailed_timing *timing, void *c)
> > >   * @quirks: quirks to apply
> > >   */
> > >  static int
> > > -add_detailed_modes(struct drm_connector *connector, struct edid *edid,
> > > -                  u32 quirks)
> > > +add_detailed_modes(struct drm_connector *connector,
> > > +                  struct edid *edid, u32 quirks)
> > >  {
> > >         struct detailed_mode_closure closure = {
> > >                 .connector = connector, @@ -3173,9 +3208,10 @@
> > > add_detailed_modes(struct drm_connector *connector, struct edid
> > > *edid,
> > >  /*
> > >   * Search EDID for CEA extension block.
> > >   */
> > > -static u8 *drm_find_edid_extension(const struct edid *edid, int
> > > ext_id)
> > > +static const u8 *drm_find_edid_extension(const struct edid *edid,
> > > +                                        int ext_id)
> > >  {
> > > -       u8 *edid_ext = NULL;
> > > +       const u8 *edid_ext = NULL;
> > >         int i;
> > >
> > >         /* No EDID or EDID extensions */ @@ -3184,7 +3220,7 @@
> > > static u8 *drm_find_edid_extension(const struct edid *edid, int
> > > ext_id)
> > >
> > >         /* Find CEA extension */
> > >         for (i = 0; i < edid->extensions; i++) {
> > > -               edid_ext = (u8 *)edid + EDID_LENGTH * (i + 1);
> > > +               edid_ext = (const u8 *)edid + EDID_LENGTH * (i + 1);
> > >                 if (edid_ext[0] == ext_id)
> > >                         break;
> > >         }
> > > @@ -3196,19 +3232,19 @@ static u8 *drm_find_edid_extension(const
> > > struct edid *edid, int ext_id)  }
> > >
> > >
> > > -static u8 *drm_find_displayid_extension(const struct edid *edid)
> > > +static const u8 *drm_find_displayid_extension(const struct edid
> > > +*edid)
> > >  {
> > >         return drm_find_edid_extension(edid, DISPLAYID_EXT);  }
> > >
> > > -static u8 *drm_find_cea_extension(const struct edid *edid)
> > > +static const u8 *drm_find_cea_extension(const struct edid *edid)
> > >  {
> > >         int ret;
> > >         int idx = 1;
> > >         int length = EDID_LENGTH;
> > > -       struct displayid_block *block;
> > > -       u8 *cea;
> > > -       u8 *displayid;
> > > +       const struct displayid_block *block;
> > > +       const u8 *cea;
> > > +       const u8 *displayid;
> > >
> > >         /* Look for a top level CEA extension block */
> > >         cea = drm_find_edid_extension(edid, CEA_EXT); @@ -4315,28
> > > +4351,30 @@ drm_parse_hdmi_vsdb_audio(struct drm_connector
> > > *connector, const u8 *db)  }
> > >
> > >  static void
> > > -monitor_name(struct detailed_timing *t, void *data)
> > > +monitor_name(const struct detailed_timing *t, void *c)
> > >  {
> > > +       struct data_closure *closure = c;
> > > +
> > >         if (!is_display_descriptor((const u8 *)t, EDID_DETAIL_MONITOR_NAME))
> > >                 return;
> > >
> > > -       *(u8 **)data = t->data.other_data.data.str.str;
> > > +       closure->data = t->data.other_data.data.str.str;
> > >  }
> > >
> > >  static int get_monitor_name(struct edid *edid, char name[13])  {
> > > -       char *edid_name = NULL;
> > > +       struct data_closure closure = {};
> > >         int mnl;
> > >
> > >         if (!edid || !name)
> > >                 return 0;
> > >
> > > -       drm_for_each_detailed_block((u8 *)edid, monitor_name, &edid_name);
> > > -       for (mnl = 0; edid_name && mnl < 13; mnl++) {
> > > -               if (edid_name[mnl] == 0x0a)
> > > +       drm_for_each_detailed_block((const u8 *)edid, monitor_name, &closure);
> > > +       for (mnl = 0; closure.data && mnl < 13; mnl++) {
> > > +               if (closure.data[mnl] == 0x0a)
> > >                         break;
> > >
> > > -               name[mnl] = edid_name[mnl];
> > > +               name[mnl] = closure.data[mnl];
> > >         }
> > >
> > >         return mnl;
> > > @@ -4386,11 +4424,9 @@ static void clear_eld(struct drm_connector
> > > *connector)  static void drm_edid_to_eld(struct drm_connector
> > > *connector, struct edid *edid)  {
> > >         uint8_t *eld = connector->eld;
> > > -       u8 *cea;
> > > -       u8 *db;
> > > +       const u8 *cea;
> > >         int total_sad_count = 0;
> > >         int mnl;
> > > -       int dbl;
> > >
> > >         clear_eld(connector);
> > >
> > > @@ -4425,8 +4461,8 @@ static void drm_edid_to_eld(struct drm_connector
> *connector, struct edid *edid)
> > >                 }
> > >
> > >                 for_each_cea_db(cea, i, start, end) {
> > > -                       db = &cea[i];
> > > -                       dbl = cea_db_payload_len(db);
> > > +                       const u8 *db = &cea[i];
> > > +                       int dbl = cea_db_payload_len(db);
> > >
> > >                         switch (cea_db_tag(db)) {
> > >                                 int sad_count; @@ -4484,7 +4520,7 @@
> > > int drm_edid_to_sad(struct edid *edid, struct cea_sad **sads)  {
> > >         int count = 0;
> > >         int i, start, end, dbl;
> > > -       u8 *cea;
> > > +       const u8 *cea;
> > >
> > >         cea = drm_find_cea_extension(edid);
> > >         if (!cea) {
> > > @@ -4503,7 +4539,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad
> **sads)
> > >         }
> > >
> > >         for_each_cea_db(cea, i, start, end) {
> > > -               u8 *db = &cea[i];
> > > +               const u8 *db = &cea[i];
> > >
> > >                 if (cea_db_tag(db) == AUDIO_BLOCK) {
> > >                         int j;
> > > @@ -4514,7 +4550,7 @@ int drm_edid_to_sad(struct edid *edid, struct cea_sad
> **sads)
> > >                         if (!*sads)
> > >                                 return -ENOMEM;
> > >                         for (j = 0; j < count; j++) {
> > > -                               u8 *sad = &db[1 + j * 3];
> > > +                               const u8 *sad = &db[1 + j * 3];
> > >
> > >                                 (*sads)[j].format = (sad[0] & 0x78) >> 3;
> > >                                 (*sads)[j].channels = sad[0] & 0x7;
> > > @@ -4635,7 +4671,7 @@ EXPORT_SYMBOL(drm_av_sync_delay);
> > >   */
> > >  bool drm_detect_hdmi_monitor(struct edid *edid)  {
> > > -       u8 *edid_ext;
> > > +       const u8 *edid_ext;
> > >         int i;
> > >         int start_offset, end_offset;
> > >
> > > @@ -4673,7 +4709,7 @@ EXPORT_SYMBOL(drm_detect_hdmi_monitor);
> > >   */
> > >  bool drm_detect_monitor_audio(struct edid *edid)  {
> > > -       u8 *edid_ext;
> > > +       const u8 *edid_ext;
> > >         int i, j;
> > >         bool has_audio = false;
> > >         int start_offset, end_offset; @@ -5017,13 +5053,13 @@ u32
> > > drm_add_display_info(struct drm_connector *connector, const struct edid *edi
> > >         return quirks;
> > >  }
> > >
> > > -static int validate_displayid(u8 *displayid, int length, int idx)
> > > +static int validate_displayid(const u8 *displayid, int length, int
> > > +idx)
> > >  {
> > >         int i;
> > >         u8 csum = 0;
> > > -       struct displayid_hdr *base;
> > > +       const struct displayid_hdr *base;
> > >
> > > -       base = (struct displayid_hdr *)&displayid[idx];
> > > +       base = (const struct displayid_hdr *)&displayid[idx];
> > >
> > >         DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> > >                       base->rev, base->bytes, base->prod_id,
> > > base->ext_count); @@ -5041,7 +5077,7 @@ static int
> > > validate_displayid(u8 *displayid, int length, int idx)  }
> > >
> > >  static struct drm_display_mode *drm_mode_displayid_detailed(struct
> drm_device *dev,
> > > -                                                           struct displayid_detailed_timings_1 *timings)
> > > +                                                           const
> > > + struct displayid_detailed_timings_1 *timings)
> > >  {
> > >         struct drm_display_mode *mode;
> > >         unsigned pixel_clock = (timings->pixel_clock[0] | @@ -5057,6
> > > +5093,7 @@ static struct drm_display_mode
> *drm_mode_displayid_detailed(struct drm_device *d
> > >         unsigned vsync_width = (timings->vsw[0] | timings->vsw[1] << 8) + 1;
> > >         bool hsync_positive = (timings->hsync[1] >> 7) & 0x1;
> > >         bool vsync_positive = (timings->vsync[1] >> 7) & 0x1;
> > > +
> > >         mode = drm_mode_create(dev);
> > >         if (!mode)
> > >                 return NULL;
> > > @@ -5086,9 +5123,10 @@ static struct drm_display_mode
> > > *drm_mode_displayid_detailed(struct drm_device *d  }
> > >
> > >  static int add_displayid_detailed_1_modes(struct drm_connector *connector,
> > > -                                         struct displayid_block *block)
> > > +                                         const struct
> > > + displayid_block *block)
> > >  {
> > > -       struct displayid_detailed_timing_block *det = (struct
> displayid_detailed_timing_block *)block;
> > > +       const struct displayid_detailed_timing_block *det =
> > > +               (const struct displayid_detailed_timing_block
> > > + *)block;
> > >         int i;
> > >         int num_timings;
> > >         struct drm_display_mode *newmode; @@ -5099,7 +5137,7 @@
> > > static int add_displayid_detailed_1_modes(struct drm_connector
> > > *connector,
> > >
> > >         num_timings = block->num_bytes / 20;
> > >         for (i = 0; i < num_timings; i++) {
> > > -               struct displayid_detailed_timings_1 *timings = &det->timings[i];
> > > +               const struct displayid_detailed_timings_1 *timings =
> > > + &det->timings[i];
> > >
> > >                 newmode = drm_mode_displayid_detailed(connector->dev, timings);
> > >                 if (!newmode)
> > > @@ -5112,13 +5150,13 @@ static int
> > > add_displayid_detailed_1_modes(struct drm_connector *connector,  }
> > >
> > >  static int add_displayid_detailed_modes(struct drm_connector *connector,
> > > -                                       struct edid *edid)
> > > +                                       const struct edid *edid)
> > >  {
> > > -       u8 *displayid;
> > > +       const u8 *displayid;
> > >         int ret;
> > >         int idx = 1;
> > >         int length = EDID_LENGTH;
> > > -       struct displayid_block *block;
> > > +       const struct displayid_block *block;
> > >         int num_modes = 0;
> > >
> > >         displayid = drm_find_displayid_extension(edid);
> > > @@ -5720,9 +5758,10 @@
> > > drm_hdmi_vendor_infoframe_from_display_mode(struct
> > > hdmi_vendor_infoframe *frame,
> > > EXPORT_SYMBOL(drm_hdmi_vendor_infoframe_from_display_mode);
> > >
> > >  static int drm_parse_tiled_block(struct drm_connector *connector,
> > > -                                struct displayid_block *block)
> > > +                                const struct displayid_block
> > > + *block)
> > >  {
> > > -       struct displayid_tiled_block *tile = (struct displayid_tiled_block *)block;
> > > +       const struct displayid_tiled_block *tile =
> > > +               (const struct displayid_tiled_block *)block;
> > >         u16 w, h;
> > >         u8 tile_v_loc, tile_h_loc;
> > >         u8 num_v_tile, num_h_tile;
> > > @@ -5774,12 +5813,12 @@ static int drm_parse_tiled_block(struct
> > > drm_connector *connector,  }
> > >
> > >  static int drm_parse_display_id(struct drm_connector *connector,
> > > -                               u8 *displayid, int length,
> > > +                               const u8 *displayid, int length,
> > >                                 bool is_edid_extension)  {
> > >         /* if this is an EDID extension the first byte will be 0x70 */
> > >         int idx = 0;
> > > -       struct displayid_block *block;
> > > +       const struct displayid_block *block;
> > >         int ret;
> > >
> > >         if (is_edid_extension)
> > > @@ -5815,11 +5854,13 @@ static int drm_parse_display_id(struct
> > > drm_connector *connector,  }
> > >
> > >  static void drm_get_displayid(struct drm_connector *connector,
> > > -                             struct edid *edid)
> > > +                             const struct edid *edid)
> > >  {
> > > -       void *displayid = NULL;
> > > +       const void *displayid;
> > >         int ret;
> > > +
> > >         connector->has_tile = false;
> > > +
> > >         displayid = drm_find_displayid_extension(edid);
> > >         if (!displayid) {
> > >                 /* drop reference to any tile group we had */ diff
> > > --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> > > index 2113500b4075..c0f9ce3f4b24 100644
> > > --- a/include/drm/drm_connector.h
> > > +++ b/include/drm/drm_connector.h
> > > @@ -1580,9 +1580,9 @@ struct drm_tile_group {  };
> > >
> > >  struct drm_tile_group *drm_mode_create_tile_group(struct drm_device *dev,
> > > -                                                 char topology[8]);
> > > +                                                 const u8
> > > + topology[8]);
> > >  struct drm_tile_group *drm_mode_get_tile_group(struct drm_device *dev,
> > > -                                              char topology[8]);
> > > +                                              const u8
> > > + topology[8]);
> > >  void drm_mode_put_tile_group(struct drm_device *dev,
> > >                              struct drm_tile_group *tg);
> > >
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > dri-devel mailing list
> > > dri-devel@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> 
> --
> Ville Syrjälä
> Intel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
  2020-01-27 22:38     ` [Intel-gfx] " Alex Deucher
@ 2020-02-03 20:38       ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:38 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:09 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I'm curious if there are any bogus 18 byte descriptors around.
> > Let's dump them out if we encounter them.
> >
> > Not sure we'd actually want this, but at least I get to see if our CI
> > has anything that hits this :)
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good to me as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 22 +++++++++++++++++++---
> >  1 file changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 8e76efe1654d..4d8303e56536 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8
> tag)
> >                 d[2] == 0x00 && d[3] == tag;  }
> >
> > +static bool is_any_display_descriptor(const u8 d[18]) {
> > +       return d[0] == 0x00 && d[1] == 0x00 &&
> > +               d[2] == 0x00;
> > +}
> > +
> >  static bool is_detailed_timing_descriptor(const u8 d[18])  {
> >         return d[0] != 0x00 || d[1] != 0x00; @@ -2209,6 +2215,15 @@
> > static bool is_detailed_timing_descriptor(const u8 d[18])
> >
> >  typedef void detailed_cb(const struct detailed_timing *timing, void
> > *closure);
> >
> > +static void do_detailed_block(const u8 d[18], detailed_cb *cb, void
> > +*closure) {
> > +       if (!is_detailed_timing_descriptor(d) &&
> > +           !is_any_display_descriptor(d))
> > +               DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n",
> > +18, d);
> > +
> > +       cb((const struct detailed_timing *)d, closure); }
> > +
> >  static void
> >  cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > *closure)  { @@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const
> > u8 *ext, detailed_cb *cb, void *closure)
> >
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> > -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> > +               do_detailed_block(det_base + 18 * i, cb, closure);
> >  }
> >
> >  static void
> > @@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb
> *cb, void *closure)
> >                 return; /* unknown version */
> >
> >         for (i = 0; i < n; i++)
> > -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> > +               do_detailed_block(det_base + 18 * i, cb, closure);
> >  }
> >
> >  static void
> > @@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid,
> detailed_cb *cb, void *closure)
> >                 return;
> >
> >         for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
> > -               cb(&(edid->detailed_timings[i]), closure);
> > +               do_detailed_block((const u8 *)&edid->detailed_timings[i],
> > +                                 cb, closure);
> >
> >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> >                 const u8 *ext = raw_edid + (i * EDID_LENGTH);
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
@ 2020-02-03 20:38       ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-03 20:38 UTC (permalink / raw)
  To: Alex Deucher, Ville Syrjala
  Cc: Intel Graphics Development, Maling list - DRI developers



> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Alex
> Deucher
> Sent: Tuesday, January 28, 2020 4:09 AM
> To: Ville Syrjala <ville.syrjala@linux.intel.com>
> Cc: Intel Graphics Development <intel-gfx@lists.freedesktop.org>; Maling list - DRI
> developers <dri-devel@lists.freedesktop.org>
> Subject: Re: [Intel-gfx] [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors
> 
> On Fri, Jan 24, 2020 at 3:03 PM Ville Syrjala <ville.syrjala@linux.intel.com> wrote:
> >
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> >
> > I'm curious if there are any bogus 18 byte descriptors around.
> > Let's dump them out if we encounter them.
> >
> > Not sure we'd actually want this, but at least I get to see if our CI
> > has anything that hits this :)
> >
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> 
> Acked-by: Alex Deucher <alexander.deucher@amd.com>

Looks good to me as well.
Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> > ---
> >  drivers/gpu/drm/drm_edid.c | 22 +++++++++++++++++++---
> >  1 file changed, 19 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > index 8e76efe1654d..4d8303e56536 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -2202,6 +2202,12 @@ static bool is_display_descriptor(const u8 d[18], u8
> tag)
> >                 d[2] == 0x00 && d[3] == tag;  }
> >
> > +static bool is_any_display_descriptor(const u8 d[18]) {
> > +       return d[0] == 0x00 && d[1] == 0x00 &&
> > +               d[2] == 0x00;
> > +}
> > +
> >  static bool is_detailed_timing_descriptor(const u8 d[18])  {
> >         return d[0] != 0x00 || d[1] != 0x00; @@ -2209,6 +2215,15 @@
> > static bool is_detailed_timing_descriptor(const u8 d[18])
> >
> >  typedef void detailed_cb(const struct detailed_timing *timing, void
> > *closure);
> >
> > +static void do_detailed_block(const u8 d[18], detailed_cb *cb, void
> > +*closure) {
> > +       if (!is_detailed_timing_descriptor(d) &&
> > +           !is_any_display_descriptor(d))
> > +               DRM_WARN("Unrecognized 18 byte descriptor: %*ph\n",
> > +18, d);
> > +
> > +       cb((const struct detailed_timing *)d, closure); }
> > +
> >  static void
> >  cea_for_each_detailed_block(const u8 *ext, detailed_cb *cb, void
> > *closure)  { @@ -2221,7 +2236,7 @@ cea_for_each_detailed_block(const
> > u8 *ext, detailed_cb *cb, void *closure)
> >
> >         n = (127 - d) / 18;
> >         for (i = 0; i < n; i++)
> > -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> > +               do_detailed_block(det_base + 18 * i, cb, closure);
> >  }
> >
> >  static void
> > @@ -2234,7 +2249,7 @@ vtb_for_each_detailed_block(const u8 *ext, detailed_cb
> *cb, void *closure)
> >                 return; /* unknown version */
> >
> >         for (i = 0; i < n; i++)
> > -               cb((const struct detailed_timing *)(det_base + 18 * i), closure);
> > +               do_detailed_block(det_base + 18 * i, cb, closure);
> >  }
> >
> >  static void
> > @@ -2247,7 +2262,8 @@ drm_for_each_detailed_block(const u8 *raw_edid,
> detailed_cb *cb, void *closure)
> >                 return;
> >
> >         for (i = 0; i < EDID_DETAILED_TIMINGS; i++)
> > -               cb(&(edid->detailed_timings[i]), closure);
> > +               do_detailed_block((const u8 *)&edid->detailed_timings[i],
> > +                                 cb, closure);
> >
> >         for (i = 1; i <= raw_edid[0x7e]; i++) {
> >                 const u8 *ext = raw_edid + (i * EDID_LENGTH);
> > --
> > 2.24.1
> >
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
  2020-02-03 20:15     ` Shankar, Uma
@ 2020-02-04 13:32       ` Ville Syrjälä
  -1 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-02-04 13:32 UTC (permalink / raw)
  To: Shankar, Uma; +Cc: intel-gfx, Andres Rodriguez, dri-devel

On Mon, Feb 03, 2020 at 08:15:51PM +0000, Shankar, Uma wrote:
> 
> 
> > -----Original Message-----
> > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjala
> > Sent: Saturday, January 25, 2020 1:32 AM
> > To: dri-devel@lists.freedesktop.org
> > Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez <andresx7@gmail.com>
> > Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block
> > revision
> > 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > I don't understand what the DispID CEA data block revision means. The spec doesn't
> > say. I guess some DispID must have a value of >= 3 in there or else we generally
> > wouldn't even parse the CEA data blocks. Or does all this code actually not do
> > anything?
> 
> This signifies the CTA extension revision (byte 1 of the block). As per the spec, seems like
> Version 1 is legacy and 2 is deprecated. So version >=3 is checked here.
> Refer section 7.3 of CTA-861-G

The confusion is about the revision field in the DispID CTA
block, not in the CTA extension block.

> 
> > Cc: Andres Rodriguez <andresx7@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
> > 0369a54e3d32..fd9b724067a7 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int  cea_revision(const
> > u8 *cea)  {
> > +	/*
> > +	 * FIXME is this correct for the DispID variant?
> > +	 * The DispID spec doesn't really specify whether
> > +	 * this is the revision of the CEA extension or
> > +	 * the DispID CEA data block. And the only value
> > +	 * given as an example is 0.
> > +	 */
> >  	return cea[1];
> >  }
> > 
> > --
> > 2.24.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

-- 
Ville Syrjälä
Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
@ 2020-02-04 13:32       ` Ville Syrjälä
  0 siblings, 0 replies; 67+ messages in thread
From: Ville Syrjälä @ 2020-02-04 13:32 UTC (permalink / raw)
  To: Shankar, Uma; +Cc: intel-gfx, Andres Rodriguez, dri-devel

On Mon, Feb 03, 2020 at 08:15:51PM +0000, Shankar, Uma wrote:
> 
> 
> > -----Original Message-----
> > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville Syrjala
> > Sent: Saturday, January 25, 2020 1:32 AM
> > To: dri-devel@lists.freedesktop.org
> > Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez <andresx7@gmail.com>
> > Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block
> > revision
> > 
> > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > 
> > I don't understand what the DispID CEA data block revision means. The spec doesn't
> > say. I guess some DispID must have a value of >= 3 in there or else we generally
> > wouldn't even parse the CEA data blocks. Or does all this code actually not do
> > anything?
> 
> This signifies the CTA extension revision (byte 1 of the block). As per the spec, seems like
> Version 1 is legacy and 2 is deprecated. So version >=3 is checked here.
> Refer section 7.3 of CTA-861-G

The confusion is about the revision field in the DispID CTA
block, not in the CTA extension block.

> 
> > Cc: Andres Rodriguez <andresx7@gmail.com>
> > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > ---
> >  drivers/gpu/drm/drm_edid.c | 7 +++++++
> >  1 file changed, 7 insertions(+)
> > 
> > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index
> > 0369a54e3d32..fd9b724067a7 100644
> > --- a/drivers/gpu/drm/drm_edid.c
> > +++ b/drivers/gpu/drm/drm_edid.c
> > @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int  cea_revision(const
> > u8 *cea)  {
> > +	/*
> > +	 * FIXME is this correct for the DispID variant?
> > +	 * The DispID spec doesn't really specify whether
> > +	 * this is the revision of the CEA extension or
> > +	 * the DispID CEA data block. And the only value
> > +	 * given as an example is 0.
> > +	 */
> >  	return cea[1];
> >  }
> > 
> > --
> > 2.24.1
> > 
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx

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

^ permalink raw reply	[flat|nested] 67+ messages in thread

* RE: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
  2020-02-04 13:32       ` Ville Syrjälä
@ 2020-02-04 14:57         ` Shankar, Uma
  -1 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-04 14:57 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Andres Rodriguez, dri-devel



> -----Original Message-----
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Sent: Tuesday, February 4, 2020 7:02 PM
> To: Shankar, Uma <uma.shankar@intel.com>
> Cc: dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; Andres
> Rodriguez <andresx7@gmail.com>
> Subject: Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data
> block revision
> 
> On Mon, Feb 03, 2020 at 08:15:51PM +0000, Shankar, Uma wrote:
> >
> >
> > > -----Original Message-----
> > > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf
> > > Of Ville Syrjala
> > > Sent: Saturday, January 25, 2020 1:32 AM
> > > To: dri-devel@lists.freedesktop.org
> > > Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez
> > > <andresx7@gmail.com>
> > > Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID
> > > CEA data block revision
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > I don't understand what the DispID CEA data block revision means.
> > > The spec doesn't say. I guess some DispID must have a value of >= 3
> > > in there or else we generally wouldn't even parse the CEA data
> > > blocks. Or does all this code actually not do anything?
> >
> > This signifies the CTA extension revision (byte 1 of the block). As
> > per the spec, seems like Version 1 is legacy and 2 is deprecated. So version >=3 is
> checked here.
> > Refer section 7.3 of CTA-861-G
> 
> The confusion is about the revision field in the DispID CTA block, not in the CTA
> extension block.

Oh ok, got the ambiguity here. Not sure if we actually get >3 here as value for the block revision,
totally unclear from spec, default being 0. Good to have this comment till we get some clarity on
its significance. Thanks for the clarification.

Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> >
> > > Cc: Andres Rodriguez <andresx7@gmail.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_edid.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index
> > > 0369a54e3d32..fd9b724067a7 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int
> > > cea_revision(const
> > > u8 *cea)  {
> > > +	/*
> > > +	 * FIXME is this correct for the DispID variant?
> > > +	 * The DispID spec doesn't really specify whether
> > > +	 * this is the revision of the CEA extension or
> > > +	 * the DispID CEA data block. And the only value
> > > +	 * given as an example is 0.
> > > +	 */
> > >  	return cea[1];
> > >  }
> > >
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> --
> Ville Syrjälä
> Intel
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

^ permalink raw reply	[flat|nested] 67+ messages in thread

* Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision
@ 2020-02-04 14:57         ` Shankar, Uma
  0 siblings, 0 replies; 67+ messages in thread
From: Shankar, Uma @ 2020-02-04 14:57 UTC (permalink / raw)
  To: Ville Syrjälä; +Cc: intel-gfx, Andres Rodriguez, dri-devel



> -----Original Message-----
> From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> Sent: Tuesday, February 4, 2020 7:02 PM
> To: Shankar, Uma <uma.shankar@intel.com>
> Cc: dri-devel@lists.freedesktop.org; intel-gfx@lists.freedesktop.org; Andres
> Rodriguez <andresx7@gmail.com>
> Subject: Re: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data
> block revision
> 
> On Mon, Feb 03, 2020 at 08:15:51PM +0000, Shankar, Uma wrote:
> >
> >
> > > -----Original Message-----
> > > From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf
> > > Of Ville Syrjala
> > > Sent: Saturday, January 25, 2020 1:32 AM
> > > To: dri-devel@lists.freedesktop.org
> > > Cc: intel-gfx@lists.freedesktop.org; Andres Rodriguez
> > > <andresx7@gmail.com>
> > > Subject: [Intel-gfx] [PATCH 6/8] drm/edid: Add a FIXME about DispID
> > > CEA data block revision
> > >
> > > From: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > >
> > > I don't understand what the DispID CEA data block revision means.
> > > The spec doesn't say. I guess some DispID must have a value of >= 3
> > > in there or else we generally wouldn't even parse the CEA data
> > > blocks. Or does all this code actually not do anything?
> >
> > This signifies the CTA extension revision (byte 1 of the block). As
> > per the spec, seems like Version 1 is legacy and 2 is deprecated. So version >=3 is
> checked here.
> > Refer section 7.3 of CTA-861-G
> 
> The confusion is about the revision field in the DispID CTA block, not in the CTA
> extension block.

Oh ok, got the ambiguity here. Not sure if we actually get >3 here as value for the block revision,
totally unclear from spec, default being 0. Good to have this comment till we get some clarity on
its significance. Thanks for the clarification.

Reviewed-by: Uma Shankar <uma.shankar@intel.com>

> >
> > > Cc: Andres Rodriguez <andresx7@gmail.com>
> > > Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
> > > ---
> > >  drivers/gpu/drm/drm_edid.c | 7 +++++++
> > >  1 file changed, 7 insertions(+)
> > >
> > > diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> > > index
> > > 0369a54e3d32..fd9b724067a7 100644
> > > --- a/drivers/gpu/drm/drm_edid.c
> > > +++ b/drivers/gpu/drm/drm_edid.c
> > > @@ -3977,6 +3977,13 @@ cea_db_tag(const u8 *db)  static int
> > > cea_revision(const
> > > u8 *cea)  {
> > > +	/*
> > > +	 * FIXME is this correct for the DispID variant?
> > > +	 * The DispID spec doesn't really specify whether
> > > +	 * this is the revision of the CEA extension or
> > > +	 * the DispID CEA data block. And the only value
> > > +	 * given as an example is 0.
> > > +	 */
> > >  	return cea[1];
> > >  }
> > >
> > > --
> > > 2.24.1
> > >
> > > _______________________________________________
> > > Intel-gfx mailing list
> > > Intel-gfx@lists.freedesktop.org
> > > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> --
> Ville Syrjälä
> Intel
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

^ permalink raw reply	[flat|nested] 67+ messages in thread

end of thread, other threads:[~2020-02-04 14:57 UTC | newest]

Thread overview: 67+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-24 20:02 [PATCH 1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block Ville Syrjala
2020-01-24 20:02 ` [Intel-gfx] " Ville Syrjala
2020-01-24 20:02 ` [PATCH 2/8] drm/edid: Don't accept any old garbage as a display descriptor Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:35   ` Alex Deucher
2020-01-27 22:35     ` [Intel-gfx] " Alex Deucher
2020-02-03 19:44     ` Shankar, Uma
2020-02-03 19:44       ` Shankar, Uma
2020-01-24 20:02 ` [PATCH 3/8] drm/edid: Introduce is_detailed_timing_descritor() Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:36   ` Alex Deucher
2020-01-27 22:36     ` [Intel-gfx] " Alex Deucher
2020-02-03 19:49     ` Shankar, Uma
2020-02-03 19:49       ` Shankar, Uma
2020-01-24 20:02 ` [PATCH 4/8] drm/i915: Clear out spurious whitespace Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:28   ` Alex Deucher
2020-01-27 22:28     ` [Intel-gfx] " Alex Deucher
2020-02-03 19:51     ` Shankar, Uma
2020-02-03 19:51       ` Shankar, Uma
2020-01-24 20:02 ` [PATCH 5/8] drm/edid: Document why we don't bounds check the DispID CEA block start/end Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:30   ` Alex Deucher
2020-01-27 22:30     ` [Intel-gfx] " Alex Deucher
2020-01-28 11:44     ` Ville Syrjälä
2020-01-28 11:44       ` [Intel-gfx] " Ville Syrjälä
2020-02-03 19:58       ` Shankar, Uma
2020-02-03 19:58         ` [Intel-gfx] " Shankar, Uma
2020-01-24 20:02 ` [PATCH 6/8] drm/edid: Add a FIXME about DispID CEA data block revision Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:32   ` Alex Deucher
2020-01-27 22:32     ` [Intel-gfx] " Alex Deucher
2020-02-03 20:15   ` Shankar, Uma
2020-02-03 20:15     ` Shankar, Uma
2020-02-04 13:32     ` Ville Syrjälä
2020-02-04 13:32       ` Ville Syrjälä
2020-02-04 14:57       ` Shankar, Uma
2020-02-04 14:57         ` Shankar, Uma
2020-01-24 20:02 ` [PATCH 7/8] drm/edid: Constify lots of things Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:38   ` Alex Deucher
2020-01-27 22:38     ` [Intel-gfx] " Alex Deucher
2020-01-28 11:49     ` Ville Syrjälä
2020-01-28 11:49       ` [Intel-gfx] " Ville Syrjälä
2020-02-03 20:34       ` Shankar, Uma
2020-02-03 20:34         ` Shankar, Uma
2020-01-24 20:02 ` [PATCH 8/8] drm/edid: Dump bogus 18 byte descriptors Ville Syrjala
2020-01-24 20:02   ` [Intel-gfx] " Ville Syrjala
2020-01-27 22:38   ` Alex Deucher
2020-01-27 22:38     ` [Intel-gfx] " Alex Deucher
2020-02-03 20:38     ` Shankar, Uma
2020-02-03 20:38       ` Shankar, Uma
2020-01-24 22:53 ` [Intel-gfx] ✗ Fi.CI.CHECKPATCH: warning for series starting with [1/8] drm/edid: Check the number of detailed timing descriptors in the CEA ext block Patchwork
2020-01-24 23:13 ` [Intel-gfx] ✓ Fi.CI.BAT: success " Patchwork
2020-01-27 13:49 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork
2020-01-27 22:34 ` [PATCH 1/8] " Alex Deucher
2020-01-27 22:34   ` [Intel-gfx] " Alex Deucher
2020-02-03 19:15   ` Shankar, Uma
2020-02-03 19:15     ` [Intel-gfx] " Shankar, Uma
2020-01-28 15:17 ` Daniel Vetter
2020-01-28 15:17   ` [Intel-gfx] " Daniel Vetter
2020-01-28 16:15   ` Ville Syrjälä
2020-01-28 16:15     ` [Intel-gfx] " Ville Syrjälä
2020-01-28 16:18     ` Daniel Vetter
2020-01-28 16:18       ` [Intel-gfx] " Daniel Vetter
2020-01-28 16:28       ` Ville Syrjälä
2020-01-28 16:28         ` [Intel-gfx] " Ville Syrjälä

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.