All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code
@ 2024-09-18 21:38 Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Mario Limonciello
                   ` (10 more replies)
  0 siblings, 11 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

This is the successor of Melissa's v5 series that was posted [1] as well
as my series that was posted [2].

Melissa's patches are mostly unmodified from v5, but the series has been
rebase on the new 6.10 based amd-staging-drm-next.

As were both touching similar code for fetching the EDID, I've merged the
pertinent parts of my series into this one in allowing the connector to
fetch the EDID from _DDC if available for eDP as well.

There are still some remaining uses of drm_edid_raw() but they touch pure
DC code, so a wrapper or macro will probably be needed to convert them.
This can be for follow ups later on.

Link: https://lore.kernel.org/amd-gfx/20240807203207.2830-1-mwen@igalia.com/ [1]
Link: https://lore.kernel.org/dri-devel/20240214215756.6530-1-mario.limonciello@amd.com/ [2]

v7:
 * Rebase on amd-staging-drm-next which is now 6.10 based
 * Fix the two LKP robot reported issues

Mario Limonciello (1):
  drm/amd/display: Fetch the EDID from _DDC if available for eDP

Melissa Wen (9):
  drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid
  drm/amd/display: switch to setting physical address directly
  drm/amd/display: always call connector_update when parsing
    freesync_caps
  drm/amd/display: remove redundant freesync parser for DP
  drm/amd/display: use drm_edid_product_id for parsing EDID product info
  drm/amd/display: parse display name from drm_eld
  drm/amd/display: get SAD from drm_eld when parsing EDID caps
  drm/amd/display: get SADB from drm_eld when parsing EDID caps
  drm/amd/display: remove dc_edid handler from
    dm_helpers_parse_edid_caps

 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 200 ++++++------------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 172 +++++++++------
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  34 +--
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   1 -
 .../drm/amd/display/dc/link/link_detection.c  |   6 +-
 drivers/gpu/drm/amd/include/amd_shared.h      |   5 +
 7 files changed, 200 insertions(+), 222 deletions(-)


base-commit: 0569603f945225067d963c8ba4fda31d967ab584
-- 
2.34.1


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

* [PATCH v7 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 02/10] drm/amd/display: switch to setting physical address directly Mario Limonciello
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

Replace raw edid handling (struct edid) with the opaque EDID type
(struct drm_edid) on amdgpu_dm_connector for consistency. It may also
prevent mismatch of approaches in different parts of the driver code.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v7: fix LKP robot issue
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 123 ++++++++----------
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +-
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c |  13 +-
 .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  34 ++---
 4 files changed, 84 insertions(+), 90 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 6f4b753f5f51..b7d93787667c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3487,7 +3487,7 @@ void amdgpu_dm_update_connector_after_detect(
 			aconnector->dc_sink = sink;
 			dc_sink_retain(aconnector->dc_sink);
 			amdgpu_dm_update_freesync_caps(connector,
-					aconnector->edid);
+					aconnector->drm_edid);
 		} else {
 			amdgpu_dm_update_freesync_caps(connector, NULL);
 			if (!aconnector->dc_sink) {
@@ -3546,18 +3546,19 @@ void amdgpu_dm_update_connector_after_detect(
 		aconnector->dc_sink = sink;
 		dc_sink_retain(aconnector->dc_sink);
 		if (sink->dc_edid.length == 0) {
-			aconnector->edid = NULL;
+			aconnector->drm_edid = NULL;
 			if (aconnector->dc_link->aux_mode) {
 				drm_dp_cec_unset_edid(
 					&aconnector->dm_dp_aux.aux);
 			}
 		} else {
-			aconnector->edid =
-				(struct edid *)sink->dc_edid.raw_edid;
+			const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid;
+
+			aconnector->drm_edid = drm_edid_alloc(edid, sink->dc_edid.length);
+			drm_edid_connector_update(connector, aconnector->drm_edid);
 
 			if (aconnector->dc_link->aux_mode)
-				drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux,
-						    aconnector->edid);
+				drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux, edid);
 		}
 
 		if (!aconnector->timing_requested) {
@@ -3568,17 +3569,18 @@ void amdgpu_dm_update_connector_after_detect(
 					"failed to create aconnector->requested_timing\n");
 		}
 
-		drm_connector_update_edid_property(connector, aconnector->edid);
-		amdgpu_dm_update_freesync_caps(connector, aconnector->edid);
+		drm_edid_connector_update(connector, aconnector->drm_edid);
+		amdgpu_dm_update_freesync_caps(connector, aconnector->drm_edid);
 		update_connector_ext_caps(aconnector);
 	} else {
 		drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
 		amdgpu_dm_update_freesync_caps(connector, NULL);
-		drm_connector_update_edid_property(connector, NULL);
+		drm_edid_connector_update(connector, NULL);
 		aconnector->num_modes = 0;
 		dc_sink_release(aconnector->dc_sink);
 		aconnector->dc_sink = NULL;
-		aconnector->edid = NULL;
+		drm_edid_free(aconnector->drm_edid);
+		aconnector->drm_edid = NULL;
 		kfree(aconnector->timing_requested);
 		aconnector->timing_requested = NULL;
 		/* Set CP to DESIRED if it was ENABLED, so we can re-enable it again on hotplug */
@@ -7105,32 +7107,24 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
 	struct amdgpu_dm_connector *aconnector = to_amdgpu_dm_connector(connector);
 	struct dc_link *dc_link = aconnector->dc_link;
 	struct dc_sink *dc_em_sink = aconnector->dc_em_sink;
-	struct edid *edid;
-	struct i2c_adapter *ddc;
-
-	if (dc_link && dc_link->aux_mode)
-		ddc = &aconnector->dm_dp_aux.aux.ddc;
-	else
-		ddc = &aconnector->i2c->base;
+	const struct drm_edid *drm_edid;
 
-	/*
-	 * Note: drm_get_edid gets edid in the following order:
-	 * 1) override EDID if set via edid_override debugfs,
-	 * 2) firmware EDID if set via edid_firmware module parameter
-	 * 3) regular DDC read.
-	 */
-	edid = drm_get_edid(connector, ddc);
-	if (!edid) {
+	drm_edid = drm_edid_read(connector);
+	drm_edid_connector_update(connector, drm_edid);
+	if (!drm_edid) {
 		DRM_ERROR("No EDID found on connector: %s.\n", connector->name);
 		return;
 	}
 
-	aconnector->edid = edid;
-
+	aconnector->drm_edid = drm_edid;
 	/* Update emulated (virtual) sink's EDID */
 	if (dc_em_sink && dc_link) {
+		// FIXME: Get rid of drm_edid_raw()
+		const struct edid *edid = drm_edid_raw(drm_edid);
+
 		memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
-		memmove(dc_em_sink->dc_edid.raw_edid, edid, (edid->extensions + 1) * EDID_LENGTH);
+		memmove(dc_em_sink->dc_edid.raw_edid, edid,
+			(edid->extensions + 1) * EDID_LENGTH);
 		dm_helpers_parse_edid_caps(
 			dc_link,
 			&dc_em_sink->dc_edid,
@@ -7160,36 +7154,26 @@ static int get_modes(struct drm_connector *connector)
 static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
 {
 	struct drm_connector *connector = &aconnector->base;
-	struct dc_link *dc_link = aconnector->dc_link;
 	struct dc_sink_init_data init_params = {
 			.link = aconnector->dc_link,
 			.sink_signal = SIGNAL_TYPE_VIRTUAL
 	};
-	struct edid *edid;
-	struct i2c_adapter *ddc;
-
-	if (dc_link->aux_mode)
-		ddc = &aconnector->dm_dp_aux.aux.ddc;
-	else
-		ddc = &aconnector->i2c->base;
+	const struct drm_edid *drm_edid;
+	const struct edid *edid;
 
-	/*
-	 * Note: drm_get_edid gets edid in the following order:
-	 * 1) override EDID if set via edid_override debugfs,
-	 * 2) firmware EDID if set via edid_firmware module parameter
-	 * 3) regular DDC read.
-	 */
-	edid = drm_get_edid(connector, ddc);
-	if (!edid) {
+	drm_edid = drm_edid_read(connector);
+	drm_edid_connector_update(connector, drm_edid);
+	if (!drm_edid) {
 		DRM_ERROR("No EDID found on connector: %s.\n", connector->name);
 		return;
 	}
 
-	if (drm_detect_hdmi_monitor(edid))
+	if (connector->display_info.is_hdmi)
 		init_params.sink_signal = SIGNAL_TYPE_HDMI_TYPE_A;
 
-	aconnector->edid = edid;
+	aconnector->drm_edid = drm_edid;
 
+	edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
 	aconnector->dc_em_sink = dc_link_add_remote_sink(
 		aconnector->dc_link,
 		(uint8_t *)edid,
@@ -7876,16 +7860,16 @@ static void amdgpu_set_panel_orientation(struct drm_connector *connector)
 }
 
 static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
-					      struct edid *edid)
+					      const struct drm_edid *drm_edid)
 {
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 			to_amdgpu_dm_connector(connector);
 
-	if (edid) {
+	if (drm_edid) {
 		/* empty probed_modes */
 		INIT_LIST_HEAD(&connector->probed_modes);
 		amdgpu_dm_connector->num_modes =
-				drm_add_edid_modes(connector, edid);
+				drm_edid_connector_add_modes(connector);
 
 		/* sorting the probed modes before calling function
 		 * amdgpu_dm_get_native_mode() since EDID can have
@@ -7899,10 +7883,10 @@ static void amdgpu_dm_connector_ddc_get_modes(struct drm_connector *connector,
 		amdgpu_dm_get_native_mode(connector);
 
 		/* Freesync capabilities are reset by calling
-		 * drm_add_edid_modes() and need to be
+		 * drm_edid_connector_add_modes() and need to be
 		 * restored here.
 		 */
-		amdgpu_dm_update_freesync_caps(connector, edid);
+		amdgpu_dm_update_freesync_caps(connector, drm_edid);
 	} else {
 		amdgpu_dm_connector->num_modes = 0;
 	}
@@ -7998,12 +7982,12 @@ static uint add_fs_modes(struct amdgpu_dm_connector *aconnector)
 }
 
 static void amdgpu_dm_connector_add_freesync_modes(struct drm_connector *connector,
-						   struct edid *edid)
+						   const struct drm_edid *drm_edid)
 {
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 		to_amdgpu_dm_connector(connector);
 
-	if (!(amdgpu_freesync_vid_mode && edid))
+	if (!(amdgpu_freesync_vid_mode && drm_edid))
 		return;
 
 	if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10)
@@ -8016,24 +8000,24 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 			to_amdgpu_dm_connector(connector);
 	struct drm_encoder *encoder;
-	struct edid *edid = amdgpu_dm_connector->edid;
+	const struct drm_edid *drm_edid = amdgpu_dm_connector->drm_edid;
 	struct dc_link_settings *verified_link_cap =
 			&amdgpu_dm_connector->dc_link->verified_link_cap;
 	const struct dc *dc = amdgpu_dm_connector->dc_link->dc;
 
 	encoder = amdgpu_dm_connector_to_encoder(connector);
 
-	if (!drm_edid_is_valid(edid)) {
+	if (!drm_edid) {
 		amdgpu_dm_connector->num_modes =
 				drm_add_modes_noedid(connector, 640, 480);
 		if (dc->link_srv->dp_get_encoding_format(verified_link_cap) == DP_128b_132b_ENCODING)
 			amdgpu_dm_connector->num_modes +=
 				drm_add_modes_noedid(connector, 1920, 1080);
 	} else {
-		amdgpu_dm_connector_ddc_get_modes(connector, edid);
+		amdgpu_dm_connector_ddc_get_modes(connector, drm_edid);
 		if (encoder)
 			amdgpu_dm_connector_add_common_modes(encoder, connector);
-		amdgpu_dm_connector_add_freesync_modes(connector, edid);
+		amdgpu_dm_connector_add_freesync_modes(connector, drm_edid);
 	}
 	amdgpu_dm_fbc_init(connector);
 
@@ -11958,7 +11942,7 @@ static bool parse_edid_cea(struct amdgpu_dm_connector *aconnector,
 }
 
 static void parse_edid_displayid_vrr(struct drm_connector *connector,
-		struct edid *edid)
+				     const struct edid *edid)
 {
 	u8 *edid_ext = NULL;
 	int i;
@@ -12001,7 +11985,7 @@ static void parse_edid_displayid_vrr(struct drm_connector *connector,
 }
 
 static int parse_amd_vsdb(struct amdgpu_dm_connector *aconnector,
-			  struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info)
+			  const struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info)
 {
 	u8 *edid_ext = NULL;
 	int i;
@@ -12036,7 +12020,8 @@ static int parse_amd_vsdb(struct amdgpu_dm_connector *aconnector,
 }
 
 static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
-		struct edid *edid, struct amdgpu_hdmi_vsdb_info *vsdb_info)
+			       const struct edid *edid,
+			       struct amdgpu_hdmi_vsdb_info *vsdb_info)
 {
 	u8 *edid_ext = NULL;
 	int i;
@@ -12070,7 +12055,7 @@ static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
  * amdgpu_dm_update_freesync_caps - Update Freesync capabilities
  *
  * @connector: Connector to query.
- * @edid: EDID from monitor
+ * @drm_edid: DRM EDID from monitor
  *
  * Amdgpu supports Freesync in DP and HDMI displays, and it is required to keep
  * track of some of the display information in the internal data struct used by
@@ -12078,19 +12063,19 @@ static int parse_hdmi_amd_vsdb(struct amdgpu_dm_connector *aconnector,
  * FreeSync parameters.
  */
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
-				    struct edid *edid)
+				    const struct drm_edid *drm_edid)
 {
 	int i = 0;
-	struct detailed_timing *timing;
-	struct detailed_non_pixel *data;
-	struct detailed_data_monitor_range *range;
+	const struct detailed_timing *timing;
+	const struct detailed_non_pixel *data;
+	const struct detailed_data_monitor_range *range;
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 			to_amdgpu_dm_connector(connector);
 	struct dm_connector_state *dm_con_state = NULL;
 	struct dc_sink *sink;
-
 	struct amdgpu_device *adev = drm_to_adev(connector->dev);
 	struct amdgpu_hdmi_vsdb_info vsdb_info = {0};
+	const struct edid *edid;
 	bool freesync_capable = false;
 	enum adaptive_sync_type as_type = ADAPTIVE_SYNC_TYPE_NONE;
 
@@ -12103,7 +12088,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 		amdgpu_dm_connector->dc_sink :
 		amdgpu_dm_connector->dc_em_sink;
 
-	if (!edid || !sink) {
+	if (!drm_edid || !sink) {
 		dm_con_state = to_dm_connector_state(connector->state);
 
 		amdgpu_dm_connector->min_vfreq = 0;
@@ -12120,6 +12105,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 	if (!adev->dm.freesync_module)
 		goto update;
 
+	edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
+
 	/* Some eDP panels only have the refresh rate range info in DisplayID */
 	if ((connector->display_info.monitor_range.min_vfreq == 0 ||
 	     connector->display_info.monitor_range.max_vfreq == 0))
@@ -12196,7 +12183,7 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 			amdgpu_dm_connector->as_type = ADAPTIVE_SYNC_TYPE_EDP;
 		}
 
-	} else if (edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {
+	} else if (drm_edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {
 		i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info);
 		if (i >= 0 && vsdb_info.freesync_supported) {
 			timing  = &edid->detailed_timings[i];
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
index 15d4690c74d6..5e49b97b3d46 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h
@@ -673,7 +673,7 @@ struct amdgpu_dm_connector {
 
 	/* we need to mind the EDID between detect
 	   and get modes due to analog/digital/tvencoder */
-	struct edid *edid;
+	const struct drm_edid *drm_edid;
 
 	/* shared with amdgpu */
 	struct amdgpu_hpd hpd;
@@ -951,7 +951,7 @@ void dm_restore_drm_connector_state(struct drm_device *dev,
 				    struct drm_connector *connector);
 
 void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
-					struct edid *edid);
+				    const struct drm_edid *drm_edid);
 
 void amdgpu_dm_trigger_timing_sync(struct drm_device *dev);
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 50109d13d967..b8004ccdcc33 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -897,7 +897,8 @@ enum dc_edid_status dm_helpers_read_local_edid(
 	struct i2c_adapter *ddc;
 	int retry = 3;
 	enum dc_edid_status edid_status;
-	struct edid *edid;
+	const struct drm_edid *drm_edid;
+	const struct edid *edid;
 
 	if (link->aux_mode)
 		ddc = &aconnector->dm_dp_aux.aux.ddc;
@@ -909,25 +910,27 @@ enum dc_edid_status dm_helpers_read_local_edid(
 	 */
 	do {
 
-		edid = drm_get_edid(&aconnector->base, ddc);
+		drm_edid = drm_edid_read_ddc(connector, ddc);
+		drm_edid_connector_update(connector, drm_edid);
 
 		/* DP Compliance Test 4.2.2.6 */
 		if (link->aux_mode && connector->edid_corrupt)
 			drm_dp_send_real_edid_checksum(&aconnector->dm_dp_aux.aux, connector->real_edid_checksum);
 
-		if (!edid && connector->edid_corrupt) {
+		if (!drm_edid && connector->edid_corrupt) {
 			connector->edid_corrupt = false;
 			return EDID_BAD_CHECKSUM;
 		}
 
-		if (!edid)
+		if (!drm_edid)
 			return EDID_NO_RESPONSE;
 
+		edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
 		sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
 		memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
 
 		/* We don't need the original edid anymore */
-		kfree(edid);
+		drm_edid_free(drm_edid);
 
 		edid_status = dm_helpers_parse_edid_caps(
 						link,
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
index 83a31b97e96b..5e3d3eda3c9f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_mst_types.c
@@ -129,7 +129,7 @@ dm_dp_mst_connector_destroy(struct drm_connector *connector)
 		dc_sink_release(aconnector->dc_sink);
 	}
 
-	kfree(aconnector->edid);
+	drm_edid_free(aconnector->drm_edid);
 
 	drm_connector_cleanup(connector);
 	drm_dp_mst_put_port_malloc(aconnector->mst_output_port);
@@ -182,7 +182,7 @@ amdgpu_dm_mst_connector_early_unregister(struct drm_connector *connector)
 
 		dc_sink_release(dc_sink);
 		aconnector->dc_sink = NULL;
-		aconnector->edid = NULL;
+		aconnector->drm_edid = NULL;
 		aconnector->dsc_aux = NULL;
 		port->passthrough_aux = NULL;
 	}
@@ -302,16 +302,18 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 	if (!aconnector)
 		return drm_add_edid_modes(connector, NULL);
 
-	if (!aconnector->edid) {
-		struct edid *edid;
+	if (!aconnector->drm_edid) {
+		const struct drm_edid *drm_edid;
 
-		edid = drm_dp_mst_get_edid(connector, &aconnector->mst_root->mst_mgr, aconnector->mst_output_port);
+		drm_edid = drm_dp_mst_edid_read(connector,
+						&aconnector->mst_root->mst_mgr,
+						aconnector->mst_output_port);
 
-		if (!edid) {
+		if (!drm_edid) {
 			amdgpu_dm_set_mst_status(&aconnector->mst_status,
 			MST_REMOTE_EDID, false);
 
-			drm_connector_update_edid_property(
+			drm_edid_connector_update(
 				&aconnector->base,
 				NULL);
 
@@ -345,7 +347,7 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 			return ret;
 		}
 
-		aconnector->edid = edid;
+		aconnector->drm_edid = drm_edid;
 		amdgpu_dm_set_mst_status(&aconnector->mst_status,
 			MST_REMOTE_EDID, true);
 	}
@@ -360,10 +362,13 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 		struct dc_sink_init_data init_params = {
 				.link = aconnector->dc_link,
 				.sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST };
+		const struct edid *edid;
+
+		edid = drm_edid_raw(aconnector->drm_edid); // FIXME: Get rid of drm_edid_raw()
 		dc_sink = dc_link_add_remote_sink(
 			aconnector->dc_link,
-			(uint8_t *)aconnector->edid,
-			(aconnector->edid->extensions + 1) * EDID_LENGTH,
+			(uint8_t *)edid,
+			(edid->extensions + 1) * EDID_LENGTH,
 			&init_params);
 
 		if (!dc_sink) {
@@ -405,7 +410,7 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 
 		if (aconnector->dc_sink) {
 			amdgpu_dm_update_freesync_caps(
-					connector, aconnector->edid);
+					connector, aconnector->drm_edid);
 
 #if defined(CONFIG_DRM_AMD_DC_FP)
 			if (!validate_dsc_caps_on_connector(aconnector))
@@ -419,10 +424,9 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
 		}
 	}
 
-	drm_connector_update_edid_property(
-					&aconnector->base, aconnector->edid);
+	drm_edid_connector_update(&aconnector->base, aconnector->drm_edid);
 
-	ret = drm_add_edid_modes(connector, aconnector->edid);
+	ret = drm_edid_connector_add_modes(connector);
 
 	return ret;
 }
@@ -500,7 +504,7 @@ dm_dp_mst_detect(struct drm_connector *connector,
 
 		dc_sink_release(aconnector->dc_sink);
 		aconnector->dc_sink = NULL;
-		aconnector->edid = NULL;
+		aconnector->drm_edid = NULL;
 		aconnector->dsc_aux = NULL;
 		port->passthrough_aux = NULL;
 
-- 
2.34.1


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

* [PATCH v7 02/10] drm/amd/display: switch to setting physical address directly
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 03/10] drm/amd/display: always call connector_update when parsing freesync_caps Mario Limonciello
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

Connectors have source physical address available in display
info. Use drm_dp_cec_attach() to use it instead of parsing the EDID
again.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index b7d93787667c..0b6c936be7a6 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3548,8 +3548,7 @@ void amdgpu_dm_update_connector_after_detect(
 		if (sink->dc_edid.length == 0) {
 			aconnector->drm_edid = NULL;
 			if (aconnector->dc_link->aux_mode) {
-				drm_dp_cec_unset_edid(
-					&aconnector->dm_dp_aux.aux);
+				drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
 			}
 		} else {
 			const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid;
@@ -3558,7 +3557,8 @@ void amdgpu_dm_update_connector_after_detect(
 			drm_edid_connector_update(connector, aconnector->drm_edid);
 
 			if (aconnector->dc_link->aux_mode)
-				drm_dp_cec_set_edid(&aconnector->dm_dp_aux.aux, edid);
+				drm_dp_cec_attach(&aconnector->dm_dp_aux.aux,
+						  connector->display_info.source_physical_address);
 		}
 
 		if (!aconnector->timing_requested) {
-- 
2.34.1


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

* [PATCH v7 03/10] drm/amd/display: always call connector_update when parsing freesync_caps
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 02/10] drm/amd/display: switch to setting physical address directly Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 04/10] drm/amd/display: remove redundant freesync parser for DP Mario Limonciello
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

Update connector caps with drm_edid data before parsing info for
freesync.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 0b6c936be7a6..efc1609ff26f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -3569,13 +3569,11 @@ void amdgpu_dm_update_connector_after_detect(
 					"failed to create aconnector->requested_timing\n");
 		}
 
-		drm_edid_connector_update(connector, aconnector->drm_edid);
 		amdgpu_dm_update_freesync_caps(connector, aconnector->drm_edid);
 		update_connector_ext_caps(aconnector);
 	} else {
 		drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
 		amdgpu_dm_update_freesync_caps(connector, NULL);
-		drm_edid_connector_update(connector, NULL);
 		aconnector->num_modes = 0;
 		dc_sink_release(aconnector->dc_sink);
 		aconnector->dc_sink = NULL;
@@ -12088,6 +12086,8 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 		amdgpu_dm_connector->dc_sink :
 		amdgpu_dm_connector->dc_em_sink;
 
+	drm_edid_connector_update(connector, drm_edid);
+
 	if (!drm_edid || !sink) {
 		dm_con_state = to_dm_connector_state(connector->state);
 
-- 
2.34.1


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

* [PATCH v7 04/10] drm/amd/display: remove redundant freesync parser for DP
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (2 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 03/10] drm/amd/display: always call connector_update when parsing freesync_caps Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 05/10] drm/amd/display: use drm_edid_product_id for parsing EDID product info Mario Limonciello
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

When updating connector under drm_edid infrastructure, many calculations
and validations are already done and become redundant inside AMD driver.
Remove those driver-specific code in favor of the DRM common code.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 74 +------------------
 1 file changed, 4 insertions(+), 70 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index efc1609ff26f..bd8fb9968c7c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -12064,9 +12064,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 				    const struct drm_edid *drm_edid)
 {
 	int i = 0;
-	const struct detailed_timing *timing;
-	const struct detailed_non_pixel *data;
-	const struct detailed_data_monitor_range *range;
 	struct amdgpu_dm_connector *amdgpu_dm_connector =
 			to_amdgpu_dm_connector(connector);
 	struct dm_connector_state *dm_con_state = NULL;
@@ -12093,8 +12090,6 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 
 		amdgpu_dm_connector->min_vfreq = 0;
 		amdgpu_dm_connector->max_vfreq = 0;
-		connector->display_info.monitor_range.min_vfreq = 0;
-		connector->display_info.monitor_range.max_vfreq = 0;
 		freesync_capable = false;
 
 		goto update;
@@ -12114,67 +12109,10 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 
 	if (edid && (sink->sink_signal == SIGNAL_TYPE_DISPLAY_PORT ||
 		     sink->sink_signal == SIGNAL_TYPE_EDP)) {
-		bool edid_check_required = false;
-
-		if (amdgpu_dm_connector->dc_link &&
-		    amdgpu_dm_connector->dc_link->dpcd_caps.allow_invalid_MSA_timing_param) {
-			if (edid->features & DRM_EDID_FEATURE_CONTINUOUS_FREQ) {
-				amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq;
-				amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq;
-				if (amdgpu_dm_connector->max_vfreq -
-				    amdgpu_dm_connector->min_vfreq > 10)
-					freesync_capable = true;
-			} else {
-				edid_check_required = edid->version > 1 ||
-						      (edid->version == 1 &&
-						       edid->revision > 1);
-			}
-		}
-
-		if (edid_check_required) {
-			for (i = 0; i < 4; i++) {
-
-				timing	= &edid->detailed_timings[i];
-				data	= &timing->data.other_data;
-				range	= &data->data.range;
-				/*
-				 * Check if monitor has continuous frequency mode
-				 */
-				if (data->type != EDID_DETAIL_MONITOR_RANGE)
-					continue;
-				/*
-				 * Check for flag range limits only. If flag == 1 then
-				 * no additional timing information provided.
-				 * Default GTF, GTF Secondary curve and CVT are not
-				 * supported
-				 */
-				if (range->flags != 1)
-					continue;
-
-				connector->display_info.monitor_range.min_vfreq = range->min_vfreq;
-				connector->display_info.monitor_range.max_vfreq = range->max_vfreq;
-
-				if (edid->revision >= 4) {
-					if (data->pad2 & DRM_EDID_RANGE_OFFSET_MIN_VFREQ)
-						connector->display_info.monitor_range.min_vfreq += 255;
-					if (data->pad2 & DRM_EDID_RANGE_OFFSET_MAX_VFREQ)
-						connector->display_info.monitor_range.max_vfreq += 255;
-				}
-
-				amdgpu_dm_connector->min_vfreq =
-					connector->display_info.monitor_range.min_vfreq;
-				amdgpu_dm_connector->max_vfreq =
-					connector->display_info.monitor_range.max_vfreq;
-
-				break;
-			}
-
-			if (amdgpu_dm_connector->max_vfreq -
-			    amdgpu_dm_connector->min_vfreq > 10) {
-
-				freesync_capable = true;
-			}
-		}
+		amdgpu_dm_connector->min_vfreq = connector->display_info.monitor_range.min_vfreq;
+		amdgpu_dm_connector->max_vfreq = connector->display_info.monitor_range.max_vfreq;
+		if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10)
+			freesync_capable = true;
 		parse_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info);
 
 		if (vsdb_info.replay_mode) {
@@ -12182,13 +12120,9 @@ void amdgpu_dm_update_freesync_caps(struct drm_connector *connector,
 			amdgpu_dm_connector->vsdb_info.amd_vsdb_version = vsdb_info.amd_vsdb_version;
 			amdgpu_dm_connector->as_type = ADAPTIVE_SYNC_TYPE_EDP;
 		}
-
 	} else if (drm_edid && sink->sink_signal == SIGNAL_TYPE_HDMI_TYPE_A) {
 		i = parse_hdmi_amd_vsdb(amdgpu_dm_connector, edid, &vsdb_info);
 		if (i >= 0 && vsdb_info.freesync_supported) {
-			timing  = &edid->detailed_timings[i];
-			data    = &timing->data.other_data;
-
 			amdgpu_dm_connector->min_vfreq = vsdb_info.min_refresh_rate_hz;
 			amdgpu_dm_connector->max_vfreq = vsdb_info.max_refresh_rate_hz;
 			if (amdgpu_dm_connector->max_vfreq - amdgpu_dm_connector->min_vfreq > 10)
-- 
2.34.1


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

* [PATCH v7 05/10] drm/amd/display: use drm_edid_product_id for parsing EDID product info
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (3 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 04/10] drm/amd/display: remove redundant freesync parser for DP Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 06/10] drm/amd/display: parse display name from drm_eld Mario Limonciello
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

Since [1], we can use drm_edid_product_id to get debug info from
drm_edid instead of directly parsing EDID.

Link: https://lore.kernel.org/dri-devel/cover.1712655867.git.jani.nikula@intel.com/ [1]
Signed-off-by: Melissa Wen <mwen@igalia.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 38 ++++++++++---------
 1 file changed, 20 insertions(+), 18 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index b8004ccdcc33..cf11ac4c1672 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -45,16 +45,16 @@
 #include "dm_helpers.h"
 #include "ddc_service_types.h"
 
-static u32 edid_extract_panel_id(struct edid *edid)
+static u32 edid_extract_panel_id(struct drm_edid_product_id *product_id)
 {
-	return (u32)edid->mfg_id[0] << 24   |
-	       (u32)edid->mfg_id[1] << 16   |
-	       (u32)EDID_PRODUCT_ID(edid);
+	return (u32)be16_to_cpu(product_id->manufacturer_name) << 16 |
+	       (u32)le16_to_cpu(product_id->product_code);
 }
 
-static void apply_edid_quirks(struct edid *edid, struct dc_edid_caps *edid_caps)
+static void apply_edid_quirks(struct drm_edid_product_id *product_id,
+			      struct dc_edid_caps *edid_caps)
 {
-	uint32_t panel_id = edid_extract_panel_id(edid);
+	uint32_t panel_id = edid_extract_panel_id(product_id);
 
 	switch (panel_id) {
 	/* Workaround for some monitors which does not work well with FAMS */
@@ -94,6 +94,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 {
 	struct amdgpu_dm_connector *aconnector = link->priv;
 	struct drm_connector *connector = &aconnector->base;
+	const struct drm_edid *drm_edid = aconnector->drm_edid;
+	struct drm_edid_product_id product_id;
 	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
 	struct cea_sad *sads;
 	int sad_count = -1;
@@ -109,13 +111,13 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	if (!drm_edid_is_valid(edid_buf))
 		result = EDID_BAD_CHECKSUM;
 
-	edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] |
-					((uint16_t) edid_buf->mfg_id[1])<<8;
-	edid_caps->product_id = (uint16_t) edid_buf->prod_code[0] |
-					((uint16_t) edid_buf->prod_code[1])<<8;
-	edid_caps->serial_number = edid_buf->serial;
-	edid_caps->manufacture_week = edid_buf->mfg_week;
-	edid_caps->manufacture_year = edid_buf->mfg_year;
+	drm_edid_get_product_id(drm_edid, &product_id);
+
+	edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
+	edid_caps->product_id = le16_to_cpu(product_id.product_code);
+	edid_caps->serial_number = le32_to_cpu(product_id.serial_number);
+	edid_caps->manufacture_week = product_id.week_of_manufacture;
+	edid_caps->manufacture_year = product_id.year_of_manufacture;
 
 	drm_edid_get_monitor_name(edid_buf,
 				  edid_caps->display_name,
@@ -123,7 +125,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 
 	edid_caps->edid_hdmi = connector->display_info.is_hdmi;
 
-	apply_edid_quirks(edid_buf, edid_caps);
+	apply_edid_quirks(&product_id, edid_caps);
 
 	sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
 	if (sad_count <= 0)
@@ -909,9 +911,9 @@ enum dc_edid_status dm_helpers_read_local_edid(
 	 * do check sum and retry to make sure read correct edid.
 	 */
 	do {
-
 		drm_edid = drm_edid_read_ddc(connector, ddc);
 		drm_edid_connector_update(connector, drm_edid);
+		aconnector->drm_edid = drm_edid;
 
 		/* DP Compliance Test 4.2.2.6 */
 		if (link->aux_mode && connector->edid_corrupt)
@@ -929,14 +931,14 @@ enum dc_edid_status dm_helpers_read_local_edid(
 		sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
 		memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
 
-		/* We don't need the original edid anymore */
-		drm_edid_free(drm_edid);
-
 		edid_status = dm_helpers_parse_edid_caps(
 						link,
 						&sink->dc_edid,
 						&sink->edid_caps);
 
+		/* We don't need the original edid anymore */
+		drm_edid_free(drm_edid);
+
 	} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
 
 	if (edid_status != EDID_OK)
-- 
2.34.1


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

* [PATCH v7 06/10] drm/amd/display: parse display name from drm_eld
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (4 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 05/10] drm/amd/display: use drm_edid_product_id for parsing EDID product info Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps Mario Limonciello
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

We don't need to parse dc_edid to get the display name since it's
already set in drm_eld which in turn had it values updated when updating
connector with the opaque drm_edid.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c  | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index cf11ac4c1672..854e51c0b3fb 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -32,7 +32,7 @@
 #include <drm/amdgpu_drm.h>
 #include <drm/drm_edid.h>
 #include <drm/drm_fixed.h>
-
+#include <drm/drm_eld.h>
 #include "dm_services.h"
 #include "amdgpu.h"
 #include "dc.h"
@@ -78,6 +78,7 @@ static void apply_edid_quirks(struct drm_edid_product_id *product_id,
 	}
 }
 
+#define AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS 13
 /**
  * dm_helpers_parse_edid_caps() - Parse edid caps
  *
@@ -119,9 +120,10 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	edid_caps->manufacture_week = product_id.week_of_manufacture;
 	edid_caps->manufacture_year = product_id.year_of_manufacture;
 
-	drm_edid_get_monitor_name(edid_buf,
-				  edid_caps->display_name,
-				  AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
+	memset(edid_caps->display_name, 0, AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
+	memcpy(edid_caps->display_name,
+	       &connector->eld[DRM_ELD_MONITOR_NAME_STRING],
+	       AMDGPU_ELD_DISPLAY_NAME_SIZE_IN_CHARS);
 
 	edid_caps->edid_hdmi = connector->display_info.is_hdmi;
 
-- 
2.34.1


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

* [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (5 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 06/10] drm/amd/display: parse display name from drm_eld Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-26 19:21   ` Alex Hung
  2024-09-18 21:38 ` [PATCH v7 08/10] drm/amd/display: get SADB " Mario Limonciello
                   ` (3 subsequent siblings)
  10 siblings, 1 reply; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

drm_edid_connector_update() updates display info, filling ELD with audio
info from Short-Audio Descriptors in the last step of
update_dislay_info(). Our goal is stopping using raw edid, so we can
extract SAD from drm_eld instead of access raw edid to get audio caps.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 20 +++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 854e51c0b3fb..e0326127fd9a 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -98,9 +98,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	const struct drm_edid *drm_edid = aconnector->drm_edid;
 	struct drm_edid_product_id product_id;
 	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
-	struct cea_sad *sads;
-	int sad_count = -1;
-	int sadb_count = -1;
+	int sad_count, sadb_count;
 	int i = 0;
 	uint8_t *sadb = NULL;
 
@@ -129,18 +127,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 
 	apply_edid_quirks(&product_id, edid_caps);
 
-	sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
+	sad_count = drm_eld_sad_count(connector->eld);
 	if (sad_count <= 0)
 		return result;
 
 	edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT);
 	for (i = 0; i < edid_caps->audio_mode_count; ++i) {
-		struct cea_sad *sad = &sads[i];
+		struct cea_sad sad;
 
-		edid_caps->audio_modes[i].format_code = sad->format;
-		edid_caps->audio_modes[i].channel_count = sad->channels + 1;
-		edid_caps->audio_modes[i].sample_rate = sad->freq;
-		edid_caps->audio_modes[i].sample_size = sad->byte2;
+		if (drm_eld_sad_get(connector->eld, i, &sad) < 0)
+			continue;
+
+		edid_caps->audio_modes[i].format_code = sad.format;
+		edid_caps->audio_modes[i].channel_count = sad.channels + 1;
+		edid_caps->audio_modes[i].sample_rate = sad.freq;
+		edid_caps->audio_modes[i].sample_size = sad.byte2;
 	}
 
 	sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb);
@@ -155,7 +156,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	else
 		edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
 
-	kfree(sads);
 	kfree(sadb);
 
 	return result;
-- 
2.34.1


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

* [PATCH v7 08/10] drm/amd/display: get SADB from drm_eld when parsing EDID caps
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (6 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-18 21:38 ` [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Mario Limonciello
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

drm_edid_connector_update() updates display info, filling ELD with
speaker allocation data in the last step of update_dislay_info(). Our
goal is stopping using raw edid, so we can extract SADB from drm_eld
instead of access raw edid to get audio caps.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 15 +++------------
 1 file changed, 3 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index e0326127fd9a..d43ed3ea000b 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -98,9 +98,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 	const struct drm_edid *drm_edid = aconnector->drm_edid;
 	struct drm_edid_product_id product_id;
 	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
-	int sad_count, sadb_count;
+	int sad_count;
 	int i = 0;
-	uint8_t *sadb = NULL;
 
 	enum dc_edid_status result = EDID_OK;
 
@@ -144,20 +143,12 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
 		edid_caps->audio_modes[i].sample_size = sad.byte2;
 	}
 
-	sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb);
 
-	if (sadb_count < 0) {
-		DRM_ERROR("Couldn't read Speaker Allocation Data Block: %d\n", sadb_count);
-		sadb_count = 0;
-	}
-
-	if (sadb_count)
-		edid_caps->speaker_flags = sadb[0];
+	if (connector->eld[DRM_ELD_SPEAKER])
+		edid_caps->speaker_flags = connector->eld[DRM_ELD_SPEAKER];
 	else
 		edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
 
-	kfree(sadb);
-
 	return result;
 }
 
-- 
2.34.1


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

* [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (7 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 08/10] drm/amd/display: get SADB " Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-25 17:06   ` Alex Hung
  2024-09-18 21:38 ` [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP Mario Limonciello
  2024-09-27 18:48 ` [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Alex Hung
  10 siblings, 1 reply; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

From: Melissa Wen <mwen@igalia.com>

We can parse edid caps from drm_edid and drm_eld and any calls of
dm_helpers_parse_edid_caps is made in a state that we have drm_edid set
to amdgpu connector.

Signed-off-by: Melissa Wen <mwen@igalia.com>
Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 +---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 ++++++++-----------
 drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  1 -
 .../drm/amd/display/dc/link/link_detection.c  |  6 ++--
 4 files changed, 16 insertions(+), 26 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bd8fb9968c7c..bf847ac55475 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7123,10 +7123,7 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
 		memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
 		memmove(dc_em_sink->dc_edid.raw_edid, edid,
 			(edid->extensions + 1) * EDID_LENGTH);
-		dm_helpers_parse_edid_caps(
-			dc_link,
-			&dc_em_sink->dc_edid,
-			&dc_em_sink->edid_caps);
+		dm_helpers_parse_edid_caps(dc_link, &dc_em_sink->edid_caps);
 	}
 }
 
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index d43ed3ea000b..8f4be7a1ec45 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -83,32 +83,24 @@ static void apply_edid_quirks(struct drm_edid_product_id *product_id,
  * dm_helpers_parse_edid_caps() - Parse edid caps
  *
  * @link: current detected link
- * @edid:	[in] pointer to edid
  * @edid_caps:	[in] pointer to edid caps
  *
  * Return: void
  */
-enum dc_edid_status dm_helpers_parse_edid_caps(
-		struct dc_link *link,
-		const struct dc_edid *edid,
-		struct dc_edid_caps *edid_caps)
+enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
+					       struct dc_edid_caps *edid_caps)
 {
 	struct amdgpu_dm_connector *aconnector = link->priv;
 	struct drm_connector *connector = &aconnector->base;
 	const struct drm_edid *drm_edid = aconnector->drm_edid;
 	struct drm_edid_product_id product_id;
-	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
 	int sad_count;
 	int i = 0;
-
 	enum dc_edid_status result = EDID_OK;
 
-	if (!edid_caps || !edid)
+	if (!edid_caps || !drm_edid)
 		return EDID_BAD_INPUT;
 
-	if (!drm_edid_is_valid(edid_buf))
-		result = EDID_BAD_CHECKSUM;
-
 	drm_edid_get_product_id(drm_edid, &product_id);
 
 	edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
@@ -920,19 +912,23 @@ enum dc_edid_status dm_helpers_read_local_edid(
 		if (!drm_edid)
 			return EDID_NO_RESPONSE;
 
-		edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
+		/* FIXME: Get rid of drm_edid_raw()
+		 * Raw edid is still needed for dm_helpers_dp_write_dpcd()
+		 */
+		edid = drm_edid_raw(drm_edid);
 		sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
 		memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
 
 		edid_status = dm_helpers_parse_edid_caps(
 						link,
-						&sink->dc_edid,
 						&sink->edid_caps);
 
-		/* We don't need the original edid anymore */
-		drm_edid_free(drm_edid);
-
-	} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
+		if (edid_status != EDID_OK) {
+			/* We can discard the drm_edid and retry */
+			drm_edid_free(drm_edid);
+			drm_edid_connector_update(connector, drm_edid);
+		}
+	} while (edid_status != EDID_OK && --retry > 0);
 
 	if (edid_status != EDID_OK)
 		DRM_ERROR("EDID err: %d, on connector: %s",
diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
index 2e4a46f1b499..4e1776b5f0d4 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
@@ -61,7 +61,6 @@ void dm_helpers_free_gpu_mem(
 
 enum dc_edid_status dm_helpers_parse_edid_caps(
 	struct dc_link *link,
-	const struct dc_edid *edid,
 	struct dc_edid_caps *edid_caps);
 
 
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
index d21ee9d12d26..94c911742dd3 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1413,10 +1413,8 @@ struct dc_sink *link_add_remote_sink(
 			dc_sink))
 		goto fail_add_sink;
 
-	edid_status = dm_helpers_parse_edid_caps(
-			link,
-			&dc_sink->dc_edid,
-			&dc_sink->edid_caps);
+	edid_status = dm_helpers_parse_edid_caps(link,
+						 &dc_sink->edid_caps);
 
 	/*
 	 * Treat device as no EDID device if EDID
-- 
2.34.1


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

* [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (8 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Mario Limonciello
@ 2024-09-18 21:38 ` Mario Limonciello
  2024-09-19 16:03   ` Alex Hung
  2024-09-27 18:48 ` [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Alex Hung
  10 siblings, 1 reply; 23+ messages in thread
From: Mario Limonciello @ 2024-09-18 21:38 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Mario Limonciello

Some manufacturers have intentionally put an EDID that differs from
the EDID on the internal panel on laptops.

Attempt to fetch this EDID if it exists and prefer it over the EDID
that is provided by the panel. If a user prefers to use the EDID from
the panel, offer a DC debugging parameter that would disable this.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 ++++++++++++++++++-
 drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
 2 files changed, 66 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
index 8f4be7a1ec45..05d3e00ecce0 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
@@ -23,6 +23,8 @@
  *
  */
 
+#include <acpi/video.h>
+
 #include <linux/string.h>
 #include <linux/acpi.h>
 #include <linux/i2c.h>
@@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link *link)
 	return dp_sink_present;
 }
 
+static int
+dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len)
+{
+	struct drm_connector *connector = data;
+	struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
+	unsigned char start = block * EDID_LENGTH;
+	void *edid;
+	int r;
+
+	if (!acpidev)
+		return -ENODEV;
+
+	/* fetch the entire edid from BIOS */
+	r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
+	if (r < 0) {
+		DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
+		return r;
+	}
+	if (len > r || start > r || start + len > r) {
+		r = -EINVAL;
+		goto cleanup;
+	}
+
+	memcpy(buf, edid + start, len);
+	r = 0;
+
+cleanup:
+	kfree(edid);
+
+	return r;
+}
+
+static const struct drm_edid *
+dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
+{
+	struct drm_connector *connector = &aconnector->base;
+
+	if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
+		return NULL;
+
+	switch (connector->connector_type) {
+	case DRM_MODE_CONNECTOR_LVDS:
+	case DRM_MODE_CONNECTOR_eDP:
+		break;
+	default:
+		return NULL;
+	}
+
+	if (connector->force == DRM_FORCE_OFF)
+		return NULL;
+
+	return drm_edid_read_custom(connector, dm_helpers_probe_acpi_edid, connector);
+}
+
 enum dc_edid_status dm_helpers_read_local_edid(
 		struct dc_context *ctx,
 		struct dc_link *link,
@@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
 	 * do check sum and retry to make sure read correct edid.
 	 */
 	do {
-		drm_edid = drm_edid_read_ddc(connector, ddc);
+		drm_edid = dm_helpers_read_acpi_edid(aconnector);
+		if (drm_edid)
+			DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n", connector->name);
+		else
+			drm_edid = drm_edid_read_ddc(connector, ddc);
 		drm_edid_connector_update(connector, drm_edid);
 		aconnector->drm_edid = drm_edid;
 
diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
index 3f91926a50e9..1ec7c5e5249e 100644
--- a/drivers/gpu/drm/amd/include/amd_shared.h
+++ b/drivers/gpu/drm/amd/include/amd_shared.h
@@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
 	 * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the time.
 	 */
 	DC_FORCE_IPS_ENABLE = 0x4000,
+	/**
+	 * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
+	 * eDP display from ACPI _DDC method.
+	 */
+	DC_DISABLE_ACPI_EDID = 0x8000,
 };
 
 enum amd_dpm_forced_level;
-- 
2.34.1


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

* Re: [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-18 21:38 ` [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP Mario Limonciello
@ 2024-09-19 16:03   ` Alex Hung
  2024-09-19 16:05     ` Mario Limonciello
  0 siblings, 1 reply; 23+ messages in thread
From: Alex Hung @ 2024-09-19 16:03 UTC (permalink / raw)
  To: Mario Limonciello, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson

A minor comment (see inline below).

Otherwise

Reviewed-by: Alex Hung <alex.hung@amd.com>

On 2024-09-18 15:38, Mario Limonciello wrote:
> Some manufacturers have intentionally put an EDID that differs from
> the EDID on the internal panel on laptops.
> 
> Attempt to fetch this EDID if it exists and prefer it over the EDID
> that is provided by the panel. If a user prefers to use the EDID from
> the panel, offer a DC debugging parameter that would disable this.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 ++++++++++++++++++-
>   drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
>   2 files changed, 66 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index 8f4be7a1ec45..05d3e00ecce0 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -23,6 +23,8 @@
>    *
>    */
>   
> +#include <acpi/video.h>
> +
>   #include <linux/string.h>
>   #include <linux/acpi.h>
>   #include <linux/i2c.h>
> @@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link *link)
>   	return dp_sink_present;
>   }
>   
> +static int
> +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, size_t len)
> +{
> +	struct drm_connector *connector = data;
> +	struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
> +	unsigned char start = block * EDID_LENGTH;
> +	void *edid;
> +	int r;
> +
> +	if (!acpidev)
> +		return -ENODEV;
> +
> +	/* fetch the entire edid from BIOS */
> +	r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
> +	if (r < 0) {
> +		DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
> +		return r;
> +	}
> +	if (len > r || start > r || start + len > r) {
> +		r = -EINVAL;
> +		goto cleanup;
> +	}
> +
> +	memcpy(buf, edid + start, len);
> +	r = 0;
> +
> +cleanup:
> +	kfree(edid);
> +
> +	return r;
> +}
> +
> +static const struct drm_edid *
> +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
> +{
> +	struct drm_connector *connector = &aconnector->base;
> +
> +	if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
> +		return NULL;
> +
> +	switch (connector->connector_type) {
> +	case DRM_MODE_CONNECTOR_LVDS:
> +	case DRM_MODE_CONNECTOR_eDP:
> +		break;
> +	default:
> +		return NULL;
> +	}
> +
> +	if (connector->force == DRM_FORCE_OFF)
> +		return NULL;
> +
> +	return drm_edid_read_custom(connector, dm_helpers_probe_acpi_edid, connector);
> +}
> +
>   enum dc_edid_status dm_helpers_read_local_edid(
>   		struct dc_context *ctx,
>   		struct dc_link *link,
> @@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
>   	 * do check sum and retry to make sure read correct edid.
>   	 */
>   	do {
> -		drm_edid = drm_edid_read_ddc(connector, ddc);
> +		drm_edid = dm_helpers_read_acpi_edid(aconnector);
> +		if (drm_edid)
> +			DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n", connector->name);

It is better to always output a message when ACPI's EDID is used without 
enabling any debug options. How about DRM_INFO?

> +		else
> +			drm_edid = drm_edid_read_ddc(connector, ddc);
>   		drm_edid_connector_update(connector, drm_edid);
>   		aconnector->drm_edid = drm_edid;
>   
> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h b/drivers/gpu/drm/amd/include/amd_shared.h
> index 3f91926a50e9..1ec7c5e5249e 100644
> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> @@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
>   	 * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the time.
>   	 */
>   	DC_FORCE_IPS_ENABLE = 0x4000,
> +	/**
> +	 * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
> +	 * eDP display from ACPI _DDC method.
> +	 */
> +	DC_DISABLE_ACPI_EDID = 0x8000,
>   };
>   
>   enum amd_dpm_forced_level;

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

* Re: [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-19 16:03   ` Alex Hung
@ 2024-09-19 16:05     ` Mario Limonciello
  2024-09-19 17:29       ` Alex Deucher
  0 siblings, 1 reply; 23+ messages in thread
From: Mario Limonciello @ 2024-09-19 16:05 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson

On 9/19/2024 11:03, Alex Hung wrote:
> A minor comment (see inline below).
> 
> Otherwise
> 
> Reviewed-by: Alex Hung <alex.hung@amd.com>
> 
> On 2024-09-18 15:38, Mario Limonciello wrote:
>> Some manufacturers have intentionally put an EDID that differs from
>> the EDID on the internal panel on laptops.
>>
>> Attempt to fetch this EDID if it exists and prefer it over the EDID
>> that is provided by the panel. If a user prefers to use the EDID from
>> the panel, offer a DC debugging parameter that would disable this.
>>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 ++++++++++++++++++-
>>   drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
>>   2 files changed, 66 insertions(+), 1 deletion(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> index 8f4be7a1ec45..05d3e00ecce0 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> @@ -23,6 +23,8 @@
>>    *
>>    */
>> +#include <acpi/video.h>
>> +
>>   #include <linux/string.h>
>>   #include <linux/acpi.h>
>>   #include <linux/i2c.h>
>> @@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link 
>> *link)
>>       return dp_sink_present;
>>   }
>> +static int
>> +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block, 
>> size_t len)
>> +{
>> +    struct drm_connector *connector = data;
>> +    struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
>> +    unsigned char start = block * EDID_LENGTH;
>> +    void *edid;
>> +    int r;
>> +
>> +    if (!acpidev)
>> +        return -ENODEV;
>> +
>> +    /* fetch the entire edid from BIOS */
>> +    r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
>> +    if (r < 0) {
>> +        DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
>> +        return r;
>> +    }
>> +    if (len > r || start > r || start + len > r) {
>> +        r = -EINVAL;
>> +        goto cleanup;
>> +    }
>> +
>> +    memcpy(buf, edid + start, len);
>> +    r = 0;
>> +
>> +cleanup:
>> +    kfree(edid);
>> +
>> +    return r;
>> +}
>> +
>> +static const struct drm_edid *
>> +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
>> +{
>> +    struct drm_connector *connector = &aconnector->base;
>> +
>> +    if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
>> +        return NULL;
>> +
>> +    switch (connector->connector_type) {
>> +    case DRM_MODE_CONNECTOR_LVDS:
>> +    case DRM_MODE_CONNECTOR_eDP:
>> +        break;
>> +    default:
>> +        return NULL;
>> +    }
>> +
>> +    if (connector->force == DRM_FORCE_OFF)
>> +        return NULL;
>> +
>> +    return drm_edid_read_custom(connector, 
>> dm_helpers_probe_acpi_edid, connector);
>> +}
>> +
>>   enum dc_edid_status dm_helpers_read_local_edid(
>>           struct dc_context *ctx,
>>           struct dc_link *link,
>> @@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
>>        * do check sum and retry to make sure read correct edid.
>>        */
>>       do {
>> -        drm_edid = drm_edid_read_ddc(connector, ddc);
>> +        drm_edid = dm_helpers_read_acpi_edid(aconnector);
>> +        if (drm_edid)
>> +            DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n", 
>> connector->name);
> 
> It is better to always output a message when ACPI's EDID is used without 
> enabling any debug options. How about DRM_INFO?

Thanks, DRM_INFO makes sense for discoverability and will adjust it.

> 
>> +        else
>> +            drm_edid = drm_edid_read_ddc(connector, ddc);
>>           drm_edid_connector_update(connector, drm_edid);
>>           aconnector->drm_edid = drm_edid;
>> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h 
>> b/drivers/gpu/drm/amd/include/amd_shared.h
>> index 3f91926a50e9..1ec7c5e5249e 100644
>> --- a/drivers/gpu/drm/amd/include/amd_shared.h
>> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
>> @@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
>>        * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the 
>> time.
>>        */
>>       DC_FORCE_IPS_ENABLE = 0x4000,
>> +    /**
>> +     * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
>> +     * eDP display from ACPI _DDC method.
>> +     */
>> +    DC_DISABLE_ACPI_EDID = 0x8000,
>>   };
>>   enum amd_dpm_forced_level;


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

* Re: [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-19 16:05     ` Mario Limonciello
@ 2024-09-19 17:29       ` Alex Deucher
  2024-09-19 17:36         ` Hamza Mahfooz
  0 siblings, 1 reply; 23+ messages in thread
From: Alex Deucher @ 2024-09-19 17:29 UTC (permalink / raw)
  To: Mario Limonciello
  Cc: Alex Hung, Alexander Deucher, Melissa Wen, kernel-dev, amd-gfx,
	dri-devel, harry.wentland, sunpeng.li, Mark Pearson

On Thu, Sep 19, 2024 at 12:06 PM Mario Limonciello
<mario.limonciello@amd.com> wrote:
>
> On 9/19/2024 11:03, Alex Hung wrote:
> > A minor comment (see inline below).
> >
> > Otherwise
> >
> > Reviewed-by: Alex Hung <alex.hung@amd.com>
> >
> > On 2024-09-18 15:38, Mario Limonciello wrote:
> >> Some manufacturers have intentionally put an EDID that differs from
> >> the EDID on the internal panel on laptops.
> >>
> >> Attempt to fetch this EDID if it exists and prefer it over the EDID
> >> that is provided by the panel. If a user prefers to use the EDID from
> >> the panel, offer a DC debugging parameter that would disable this.
> >>
> >> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> >> ---
> >>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 ++++++++++++++++++-
> >>   drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
> >>   2 files changed, 66 insertions(+), 1 deletion(-)
> >>
> >> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> >> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> >> index 8f4be7a1ec45..05d3e00ecce0 100644
> >> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> >> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> >> @@ -23,6 +23,8 @@
> >>    *
> >>    */
> >> +#include <acpi/video.h>
> >> +
> >>   #include <linux/string.h>
> >>   #include <linux/acpi.h>
> >>   #include <linux/i2c.h>
> >> @@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link
> >> *link)
> >>       return dp_sink_present;
> >>   }
> >> +static int
> >> +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block,
> >> size_t len)
> >> +{
> >> +    struct drm_connector *connector = data;
> >> +    struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
> >> +    unsigned char start = block * EDID_LENGTH;
> >> +    void *edid;
> >> +    int r;
> >> +
> >> +    if (!acpidev)
> >> +        return -ENODEV;
> >> +
> >> +    /* fetch the entire edid from BIOS */
> >> +    r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
> >> +    if (r < 0) {
> >> +        DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
> >> +        return r;
> >> +    }
> >> +    if (len > r || start > r || start + len > r) {
> >> +        r = -EINVAL;
> >> +        goto cleanup;
> >> +    }
> >> +
> >> +    memcpy(buf, edid + start, len);
> >> +    r = 0;
> >> +
> >> +cleanup:
> >> +    kfree(edid);
> >> +
> >> +    return r;
> >> +}
> >> +
> >> +static const struct drm_edid *
> >> +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
> >> +{
> >> +    struct drm_connector *connector = &aconnector->base;
> >> +
> >> +    if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
> >> +        return NULL;
> >> +
> >> +    switch (connector->connector_type) {
> >> +    case DRM_MODE_CONNECTOR_LVDS:
> >> +    case DRM_MODE_CONNECTOR_eDP:
> >> +        break;
> >> +    default:
> >> +        return NULL;
> >> +    }
> >> +
> >> +    if (connector->force == DRM_FORCE_OFF)
> >> +        return NULL;
> >> +
> >> +    return drm_edid_read_custom(connector,
> >> dm_helpers_probe_acpi_edid, connector);
> >> +}
> >> +
> >>   enum dc_edid_status dm_helpers_read_local_edid(
> >>           struct dc_context *ctx,
> >>           struct dc_link *link,
> >> @@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
> >>        * do check sum and retry to make sure read correct edid.
> >>        */
> >>       do {
> >> -        drm_edid = drm_edid_read_ddc(connector, ddc);
> >> +        drm_edid = dm_helpers_read_acpi_edid(aconnector);
> >> +        if (drm_edid)
> >> +            DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n",
> >> connector->name);
> >
> > It is better to always output a message when ACPI's EDID is used without
> > enabling any debug options. How about DRM_INFO?
>
> Thanks, DRM_INFO makes sense for discoverability and will adjust it.

I'd suggest using dev_info() or one of the newer DRM macros so we know
which device we are talking about if there are multiple GPUs in the
system.

Alex

>
> >
> >> +        else
> >> +            drm_edid = drm_edid_read_ddc(connector, ddc);
> >>           drm_edid_connector_update(connector, drm_edid);
> >>           aconnector->drm_edid = drm_edid;
> >> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h
> >> b/drivers/gpu/drm/amd/include/amd_shared.h
> >> index 3f91926a50e9..1ec7c5e5249e 100644
> >> --- a/drivers/gpu/drm/amd/include/amd_shared.h
> >> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
> >> @@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
> >>        * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the
> >> time.
> >>        */
> >>       DC_FORCE_IPS_ENABLE = 0x4000,
> >> +    /**
> >> +     * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
> >> +     * eDP display from ACPI _DDC method.
> >> +     */
> >> +    DC_DISABLE_ACPI_EDID = 0x8000,
> >>   };
> >>   enum amd_dpm_forced_level;
>

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

* Re: [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-19 17:29       ` Alex Deucher
@ 2024-09-19 17:36         ` Hamza Mahfooz
  2024-09-19 18:14           ` Mario Limonciello
  0 siblings, 1 reply; 23+ messages in thread
From: Hamza Mahfooz @ 2024-09-19 17:36 UTC (permalink / raw)
  To: Alex Deucher, Mario Limonciello
  Cc: Alex Hung, Alexander Deucher, Melissa Wen, kernel-dev, amd-gfx,
	dri-devel, harry.wentland, sunpeng.li, Mark Pearson

On 9/19/24 13:29, Alex Deucher wrote:
> On Thu, Sep 19, 2024 at 12:06 PM Mario Limonciello
> <mario.limonciello@amd.com> wrote:
>>
>> On 9/19/2024 11:03, Alex Hung wrote:
>>> A minor comment (see inline below).
>>>
>>> Otherwise
>>>
>>> Reviewed-by: Alex Hung <alex.hung@amd.com>
>>>
>>> On 2024-09-18 15:38, Mario Limonciello wrote:
>>>> Some manufacturers have intentionally put an EDID that differs from
>>>> the EDID on the internal panel on laptops.
>>>>
>>>> Attempt to fetch this EDID if it exists and prefer it over the EDID
>>>> that is provided by the panel. If a user prefers to use the EDID from
>>>> the panel, offer a DC debugging parameter that would disable this.
>>>>
>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>> ---
>>>>    .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 ++++++++++++++++++-
>>>>    drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
>>>>    2 files changed, 66 insertions(+), 1 deletion(-)
>>>>
>>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>> index 8f4be7a1ec45..05d3e00ecce0 100644
>>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>> @@ -23,6 +23,8 @@
>>>>     *
>>>>     */
>>>> +#include <acpi/video.h>
>>>> +
>>>>    #include <linux/string.h>
>>>>    #include <linux/acpi.h>
>>>>    #include <linux/i2c.h>
>>>> @@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link
>>>> *link)
>>>>        return dp_sink_present;
>>>>    }
>>>> +static int
>>>> +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block,
>>>> size_t len)
>>>> +{
>>>> +    struct drm_connector *connector = data;
>>>> +    struct acpi_device *acpidev = ACPI_COMPANION(connector->dev->dev);
>>>> +    unsigned char start = block * EDID_LENGTH;
>>>> +    void *edid;
>>>> +    int r;
>>>> +
>>>> +    if (!acpidev)
>>>> +        return -ENODEV;
>>>> +
>>>> +    /* fetch the entire edid from BIOS */
>>>> +    r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, &edid);
>>>> +    if (r < 0) {
>>>> +        DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
>>>> +        return r;
>>>> +    }
>>>> +    if (len > r || start > r || start + len > r) {
>>>> +        r = -EINVAL;
>>>> +        goto cleanup;
>>>> +    }
>>>> +
>>>> +    memcpy(buf, edid + start, len);
>>>> +    r = 0;
>>>> +
>>>> +cleanup:
>>>> +    kfree(edid);
>>>> +
>>>> +    return r;
>>>> +}
>>>> +
>>>> +static const struct drm_edid *
>>>> +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
>>>> +{
>>>> +    struct drm_connector *connector = &aconnector->base;
>>>> +
>>>> +    if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
>>>> +        return NULL;
>>>> +
>>>> +    switch (connector->connector_type) {
>>>> +    case DRM_MODE_CONNECTOR_LVDS:
>>>> +    case DRM_MODE_CONNECTOR_eDP:
>>>> +        break;
>>>> +    default:
>>>> +        return NULL;
>>>> +    }
>>>> +
>>>> +    if (connector->force == DRM_FORCE_OFF)
>>>> +        return NULL;
>>>> +
>>>> +    return drm_edid_read_custom(connector,
>>>> dm_helpers_probe_acpi_edid, connector);
>>>> +}
>>>> +
>>>>    enum dc_edid_status dm_helpers_read_local_edid(
>>>>            struct dc_context *ctx,
>>>>            struct dc_link *link,
>>>> @@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
>>>>         * do check sum and retry to make sure read correct edid.
>>>>         */
>>>>        do {
>>>> -        drm_edid = drm_edid_read_ddc(connector, ddc);
>>>> +        drm_edid = dm_helpers_read_acpi_edid(aconnector);
>>>> +        if (drm_edid)
>>>> +            DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n",
>>>> connector->name);
>>>
>>> It is better to always output a message when ACPI's EDID is used without
>>> enabling any debug options. How about DRM_INFO?
>>
>> Thanks, DRM_INFO makes sense for discoverability and will adjust it.
> 
> I'd suggest using dev_info() or one of the newer DRM macros so we know
> which device we are talking about if there are multiple GPUs in the
> system.

Ya, I'd personally prefer moving amdgpu_dm over to the new(er) drm_.*
family of logging macros.

> 
> Alex
> 
>>
>>>
>>>> +        else
>>>> +            drm_edid = drm_edid_read_ddc(connector, ddc);
>>>>            drm_edid_connector_update(connector, drm_edid);
>>>>            aconnector->drm_edid = drm_edid;
>>>> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h
>>>> b/drivers/gpu/drm/amd/include/amd_shared.h
>>>> index 3f91926a50e9..1ec7c5e5249e 100644
>>>> --- a/drivers/gpu/drm/amd/include/amd_shared.h
>>>> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
>>>> @@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
>>>>         * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the
>>>> time.
>>>>         */
>>>>        DC_FORCE_IPS_ENABLE = 0x4000,
>>>> +    /**
>>>> +     * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
>>>> +     * eDP display from ACPI _DDC method.
>>>> +     */
>>>> +    DC_DISABLE_ACPI_EDID = 0x8000,
>>>>    };
>>>>    enum amd_dpm_forced_level;
>>
-- 
Hamza


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

* Re: [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP
  2024-09-19 17:36         ` Hamza Mahfooz
@ 2024-09-19 18:14           ` Mario Limonciello
  0 siblings, 0 replies; 23+ messages in thread
From: Mario Limonciello @ 2024-09-19 18:14 UTC (permalink / raw)
  To: Hamza Mahfooz, Alex Deucher
  Cc: Alex Hung, Alexander Deucher, Melissa Wen, kernel-dev, amd-gfx,
	dri-devel, harry.wentland, sunpeng.li, Mark Pearson

On 9/19/2024 12:36, Hamza Mahfooz wrote:
> On 9/19/24 13:29, Alex Deucher wrote:
>> On Thu, Sep 19, 2024 at 12:06 PM Mario Limonciello
>> <mario.limonciello@amd.com> wrote:
>>>
>>> On 9/19/2024 11:03, Alex Hung wrote:
>>>> A minor comment (see inline below).
>>>>
>>>> Otherwise
>>>>
>>>> Reviewed-by: Alex Hung <alex.hung@amd.com>
>>>>
>>>> On 2024-09-18 15:38, Mario Limonciello wrote:
>>>>> Some manufacturers have intentionally put an EDID that differs from
>>>>> the EDID on the internal panel on laptops.
>>>>>
>>>>> Attempt to fetch this EDID if it exists and prefer it over the EDID
>>>>> that is provided by the panel. If a user prefers to use the EDID from
>>>>> the panel, offer a DC debugging parameter that would disable this.
>>>>>
>>>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>>>> ---
>>>>>    .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 62 
>>>>> ++++++++++++++++++-
>>>>>    drivers/gpu/drm/amd/include/amd_shared.h      |  5 ++
>>>>>    2 files changed, 66 insertions(+), 1 deletion(-)
>>>>>
>>>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>>> index 8f4be7a1ec45..05d3e00ecce0 100644
>>>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>>>> @@ -23,6 +23,8 @@
>>>>>     *
>>>>>     */
>>>>> +#include <acpi/video.h>
>>>>> +
>>>>>    #include <linux/string.h>
>>>>>    #include <linux/acpi.h>
>>>>>    #include <linux/i2c.h>
>>>>> @@ -874,6 +876,60 @@ bool dm_helpers_is_dp_sink_present(struct dc_link
>>>>> *link)
>>>>>        return dp_sink_present;
>>>>>    }
>>>>> +static int
>>>>> +dm_helpers_probe_acpi_edid(void *data, u8 *buf, unsigned int block,
>>>>> size_t len)
>>>>> +{
>>>>> +    struct drm_connector *connector = data;
>>>>> +    struct acpi_device *acpidev = 
>>>>> ACPI_COMPANION(connector->dev->dev);
>>>>> +    unsigned char start = block * EDID_LENGTH;
>>>>> +    void *edid;
>>>>> +    int r;
>>>>> +
>>>>> +    if (!acpidev)
>>>>> +        return -ENODEV;
>>>>> +
>>>>> +    /* fetch the entire edid from BIOS */
>>>>> +    r = acpi_video_get_edid(acpidev, ACPI_VIDEO_DISPLAY_LCD, -1, 
>>>>> &edid);
>>>>> +    if (r < 0) {
>>>>> +        DRM_DEBUG_KMS("Failed to get EDID from ACPI: %d\n", r);
>>>>> +        return r;
>>>>> +    }
>>>>> +    if (len > r || start > r || start + len > r) {
>>>>> +        r = -EINVAL;
>>>>> +        goto cleanup;
>>>>> +    }
>>>>> +
>>>>> +    memcpy(buf, edid + start, len);
>>>>> +    r = 0;
>>>>> +
>>>>> +cleanup:
>>>>> +    kfree(edid);
>>>>> +
>>>>> +    return r;
>>>>> +}
>>>>> +
>>>>> +static const struct drm_edid *
>>>>> +dm_helpers_read_acpi_edid(struct amdgpu_dm_connector *aconnector)
>>>>> +{
>>>>> +    struct drm_connector *connector = &aconnector->base;
>>>>> +
>>>>> +    if (amdgpu_dc_debug_mask & DC_DISABLE_ACPI_EDID)
>>>>> +        return NULL;
>>>>> +
>>>>> +    switch (connector->connector_type) {
>>>>> +    case DRM_MODE_CONNECTOR_LVDS:
>>>>> +    case DRM_MODE_CONNECTOR_eDP:
>>>>> +        break;
>>>>> +    default:
>>>>> +        return NULL;
>>>>> +    }
>>>>> +
>>>>> +    if (connector->force == DRM_FORCE_OFF)
>>>>> +        return NULL;
>>>>> +
>>>>> +    return drm_edid_read_custom(connector,
>>>>> dm_helpers_probe_acpi_edid, connector);
>>>>> +}
>>>>> +
>>>>>    enum dc_edid_status dm_helpers_read_local_edid(
>>>>>            struct dc_context *ctx,
>>>>>            struct dc_link *link,
>>>>> @@ -896,7 +952,11 @@ enum dc_edid_status dm_helpers_read_local_edid(
>>>>>         * do check sum and retry to make sure read correct edid.
>>>>>         */
>>>>>        do {
>>>>> -        drm_edid = drm_edid_read_ddc(connector, ddc);
>>>>> +        drm_edid = dm_helpers_read_acpi_edid(aconnector);
>>>>> +        if (drm_edid)
>>>>> +            DRM_DEBUG_KMS("Using ACPI provided EDID for %s\n",
>>>>> connector->name);
>>>>
>>>> It is better to always output a message when ACPI's EDID is used 
>>>> without
>>>> enabling any debug options. How about DRM_INFO?
>>>
>>> Thanks, DRM_INFO makes sense for discoverability and will adjust it.
>>
>> I'd suggest using dev_info() or one of the newer DRM macros so we know
>> which device we are talking about if there are multiple GPUs in the
>> system.
> 
> Ya, I'd personally prefer moving amdgpu_dm over to the new(er) drm_.*
> family of logging macros.

Thanks.  I've adjusted it to:

drm_info(connector->dev, "Using ACPI provided EDID for %s\n", 
connector->name);

Also there is a debug one used above that I adjusted to:

drm_dbg(connector->dev, "Failed to get EDID from ACPI: %d\n", r);

> 
>>
>> Alex
>>
>>>
>>>>
>>>>> +        else
>>>>> +            drm_edid = drm_edid_read_ddc(connector, ddc);
>>>>>            drm_edid_connector_update(connector, drm_edid);
>>>>>            aconnector->drm_edid = drm_edid;
>>>>> diff --git a/drivers/gpu/drm/amd/include/amd_shared.h
>>>>> b/drivers/gpu/drm/amd/include/amd_shared.h
>>>>> index 3f91926a50e9..1ec7c5e5249e 100644
>>>>> --- a/drivers/gpu/drm/amd/include/amd_shared.h
>>>>> +++ b/drivers/gpu/drm/amd/include/amd_shared.h
>>>>> @@ -337,6 +337,11 @@ enum DC_DEBUG_MASK {
>>>>>         * @DC_FORCE_IPS_ENABLE: If set, force enable all IPS, all the
>>>>> time.
>>>>>         */
>>>>>        DC_FORCE_IPS_ENABLE = 0x4000,
>>>>> +    /**
>>>>> +     * @DC_DISABLE_ACPI_EDID: If set, don't attempt to fetch EDID for
>>>>> +     * eDP display from ACPI _DDC method.
>>>>> +     */
>>>>> +    DC_DISABLE_ACPI_EDID = 0x8000,
>>>>>    };
>>>>>    enum amd_dpm_forced_level;
>>>


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

* Re: [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps
  2024-09-18 21:38 ` [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Mario Limonciello
@ 2024-09-25 17:06   ` Alex Hung
  2024-09-25 17:55     ` Mario Limonciello
  0 siblings, 1 reply; 23+ messages in thread
From: Alex Hung @ 2024-09-25 17:06 UTC (permalink / raw)
  To: Mario Limonciello, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Wheeler, Daniel

Mario and Melissa,

This patch causes a regrerssion on 7900 XTX in an IGT test: 
amd_mem_leak's connector-suspend-resume.

Is this patch necessary on this series or is it independent from other 
patches, i.e. can it be dropped from this series until fixed??

Cheers,
Alex Hung

On 9/18/24 15:38, Mario Limonciello wrote:
> From: Melissa Wen <mwen@igalia.com>
> 
> We can parse edid caps from drm_edid and drm_eld and any calls of
> dm_helpers_parse_edid_caps is made in a state that we have drm_edid set
> to amdgpu connector.
> 
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 +---
>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 ++++++++-----------
>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  1 -
>   .../drm/amd/display/dc/link/link_detection.c  |  6 ++--
>   4 files changed, 16 insertions(+), 26 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index bd8fb9968c7c..bf847ac55475 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -7123,10 +7123,7 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
>   		memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
>   		memmove(dc_em_sink->dc_edid.raw_edid, edid,
>   			(edid->extensions + 1) * EDID_LENGTH);
> -		dm_helpers_parse_edid_caps(
> -			dc_link,
> -			&dc_em_sink->dc_edid,
> -			&dc_em_sink->edid_caps);
> +		dm_helpers_parse_edid_caps(dc_link, &dc_em_sink->edid_caps);
>   	}
>   }
>   
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index d43ed3ea000b..8f4be7a1ec45 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -83,32 +83,24 @@ static void apply_edid_quirks(struct drm_edid_product_id *product_id,
>    * dm_helpers_parse_edid_caps() - Parse edid caps
>    *
>    * @link: current detected link
> - * @edid:	[in] pointer to edid
>    * @edid_caps:	[in] pointer to edid caps
>    *
>    * Return: void
>    */
> -enum dc_edid_status dm_helpers_parse_edid_caps(
> -		struct dc_link *link,
> -		const struct dc_edid *edid,
> -		struct dc_edid_caps *edid_caps)
> +enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
> +					       struct dc_edid_caps *edid_caps)
>   {
>   	struct amdgpu_dm_connector *aconnector = link->priv;
>   	struct drm_connector *connector = &aconnector->base;
>   	const struct drm_edid *drm_edid = aconnector->drm_edid;
>   	struct drm_edid_product_id product_id;
> -	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
>   	int sad_count;
>   	int i = 0;
> -
>   	enum dc_edid_status result = EDID_OK;
>   
> -	if (!edid_caps || !edid)
> +	if (!edid_caps || !drm_edid)
>   		return EDID_BAD_INPUT;
>   
> -	if (!drm_edid_is_valid(edid_buf))
> -		result = EDID_BAD_CHECKSUM;
> -
>   	drm_edid_get_product_id(drm_edid, &product_id);
>   
>   	edid_caps->manufacturer_id = le16_to_cpu(product_id.manufacturer_name);
> @@ -920,19 +912,23 @@ enum dc_edid_status dm_helpers_read_local_edid(
>   		if (!drm_edid)
>   			return EDID_NO_RESPONSE;
>   
> -		edid = drm_edid_raw(drm_edid); // FIXME: Get rid of drm_edid_raw()
> +		/* FIXME: Get rid of drm_edid_raw()
> +		 * Raw edid is still needed for dm_helpers_dp_write_dpcd()
> +		 */
> +		edid = drm_edid_raw(drm_edid);
>   		sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
>   		memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink->dc_edid.length);
>   
>   		edid_status = dm_helpers_parse_edid_caps(
>   						link,
> -						&sink->dc_edid,
>   						&sink->edid_caps);
>   
> -		/* We don't need the original edid anymore */
> -		drm_edid_free(drm_edid);
> -
> -	} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
> +		if (edid_status != EDID_OK) {
> +			/* We can discard the drm_edid and retry */
> +			drm_edid_free(drm_edid);
> +			drm_edid_connector_update(connector, drm_edid);
> +		}
> +	} while (edid_status != EDID_OK && --retry > 0);
>   
>   	if (edid_status != EDID_OK)
>   		DRM_ERROR("EDID err: %d, on connector: %s",
> diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
> index 2e4a46f1b499..4e1776b5f0d4 100644
> --- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
> +++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
> @@ -61,7 +61,6 @@ void dm_helpers_free_gpu_mem(
>   
>   enum dc_edid_status dm_helpers_parse_edid_caps(
>   	struct dc_link *link,
> -	const struct dc_edid *edid,
>   	struct dc_edid_caps *edid_caps);
>   
>   
> diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> index d21ee9d12d26..94c911742dd3 100644
> --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> @@ -1413,10 +1413,8 @@ struct dc_sink *link_add_remote_sink(
>   			dc_sink))
>   		goto fail_add_sink;
>   
> -	edid_status = dm_helpers_parse_edid_caps(
> -			link,
> -			&dc_sink->dc_edid,
> -			&dc_sink->edid_caps);
> +	edid_status = dm_helpers_parse_edid_caps(link,
> +						 &dc_sink->edid_caps);
>   
>   	/*
>   	 * Treat device as no EDID device if EDID


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

* Re: [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps
  2024-09-25 17:06   ` Alex Hung
@ 2024-09-25 17:55     ` Mario Limonciello
  2024-09-26 10:48       ` Melissa Wen
  0 siblings, 1 reply; 23+ messages in thread
From: Mario Limonciello @ 2024-09-25 17:55 UTC (permalink / raw)
  To: Alex Hung, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Wheeler, Daniel

Alex,

Unfortunately I can't reproduce the regression on the APU I tried. 
However I do have a suspicion on a fix.

Can you see if this helps?  If it does, we can squash it in.

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index bf847ac55475..e75cd527d753 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7008,6 +7008,7 @@ static void amdgpu_dm_connector_destroy(struct 
drm_connector *connector)
                 kfree(aconnector->i2c);
         }
         kfree(aconnector->dm_dp_aux.aux.name);
+       drm_edid_free(aconnector->drm_edid);

         kfree(connector);
  }

If that doesn't help, I did test dropping this patch and it doesn't 
affect the last patch in the series, that one still works so I'm fine 
with dropping it and we can follow up later.

On 9/25/2024 12:06, Alex Hung wrote:
> Mario and Melissa,
> 
> This patch causes a regrerssion on 7900 XTX in an IGT test: 
> amd_mem_leak's connector-suspend-resume.
> 
> Is this patch necessary on this series or is it independent from other 
> patches, i.e. can it be dropped from this series until fixed??
> 
> Cheers,
> Alex Hung
> 
> On 9/18/24 15:38, Mario Limonciello wrote:
>> From: Melissa Wen <mwen@igalia.com>
>>
>> We can parse edid caps from drm_edid and drm_eld and any calls of
>> dm_helpers_parse_edid_caps is made in a state that we have drm_edid set
>> to amdgpu connector.
>>
>> Signed-off-by: Melissa Wen <mwen@igalia.com>
>> Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>> ---
>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 +---
>>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 ++++++++-----------
>>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  1 -
>>   .../drm/amd/display/dc/link/link_detection.c  |  6 ++--
>>   4 files changed, 16 insertions(+), 26 deletions(-)
>>
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/ 
>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> index bd8fb9968c7c..bf847ac55475 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>> @@ -7123,10 +7123,7 @@ static void 
>> amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
>>           memset(&dc_em_sink->edid_caps, 0, sizeof(struct dc_edid_caps));
>>           memmove(dc_em_sink->dc_edid.raw_edid, edid,
>>               (edid->extensions + 1) * EDID_LENGTH);
>> -        dm_helpers_parse_edid_caps(
>> -            dc_link,
>> -            &dc_em_sink->dc_edid,
>> -            &dc_em_sink->edid_caps);
>> +        dm_helpers_parse_edid_caps(dc_link, &dc_em_sink->edid_caps);
>>       }
>>   }
>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> index d43ed3ea000b..8f4be7a1ec45 100644
>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>> @@ -83,32 +83,24 @@ static void apply_edid_quirks(struct 
>> drm_edid_product_id *product_id,
>>    * dm_helpers_parse_edid_caps() - Parse edid caps
>>    *
>>    * @link: current detected link
>> - * @edid:    [in] pointer to edid
>>    * @edid_caps:    [in] pointer to edid caps
>>    *
>>    * Return: void
>>    */
>> -enum dc_edid_status dm_helpers_parse_edid_caps(
>> -        struct dc_link *link,
>> -        const struct dc_edid *edid,
>> -        struct dc_edid_caps *edid_caps)
>> +enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
>> +                           struct dc_edid_caps *edid_caps)
>>   {
>>       struct amdgpu_dm_connector *aconnector = link->priv;
>>       struct drm_connector *connector = &aconnector->base;
>>       const struct drm_edid *drm_edid = aconnector->drm_edid;
>>       struct drm_edid_product_id product_id;
>> -    struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : 
>> NULL;
>>       int sad_count;
>>       int i = 0;
>> -
>>       enum dc_edid_status result = EDID_OK;
>> -    if (!edid_caps || !edid)
>> +    if (!edid_caps || !drm_edid)
>>           return EDID_BAD_INPUT;
>> -    if (!drm_edid_is_valid(edid_buf))
>> -        result = EDID_BAD_CHECKSUM;
>> -
>>       drm_edid_get_product_id(drm_edid, &product_id);
>>       edid_caps->manufacturer_id = 
>> le16_to_cpu(product_id.manufacturer_name);
>> @@ -920,19 +912,23 @@ enum dc_edid_status dm_helpers_read_local_edid(
>>           if (!drm_edid)
>>               return EDID_NO_RESPONSE;
>> -        edid = drm_edid_raw(drm_edid); // FIXME: Get rid of 
>> drm_edid_raw()
>> +        /* FIXME: Get rid of drm_edid_raw()
>> +         * Raw edid is still needed for dm_helpers_dp_write_dpcd()
>> +         */
>> +        edid = drm_edid_raw(drm_edid);
>>           sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
>>           memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink- 
>> >dc_edid.length);
>>           edid_status = dm_helpers_parse_edid_caps(
>>                           link,
>> -                        &sink->dc_edid,
>>                           &sink->edid_caps);
>> -        /* We don't need the original edid anymore */
>> -        drm_edid_free(drm_edid);
>> -
>> -    } while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
>> +        if (edid_status != EDID_OK) {
>> +            /* We can discard the drm_edid and retry */
>> +            drm_edid_free(drm_edid);
>> +            drm_edid_connector_update(connector, drm_edid);
>> +        }
>> +    } while (edid_status != EDID_OK && --retry > 0);
>>       if (edid_status != EDID_OK)
>>           DRM_ERROR("EDID err: %d, on connector: %s",
>> diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/ 
>> gpu/drm/amd/display/dc/dm_helpers.h
>> index 2e4a46f1b499..4e1776b5f0d4 100644
>> --- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
>> +++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
>> @@ -61,7 +61,6 @@ void dm_helpers_free_gpu_mem(
>>   enum dc_edid_status dm_helpers_parse_edid_caps(
>>       struct dc_link *link,
>> -    const struct dc_edid *edid,
>>       struct dc_edid_caps *edid_caps);
>> diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/ 
>> drivers/gpu/drm/amd/display/dc/link/link_detection.c
>> index d21ee9d12d26..94c911742dd3 100644
>> --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
>> +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
>> @@ -1413,10 +1413,8 @@ struct dc_sink *link_add_remote_sink(
>>               dc_sink))
>>           goto fail_add_sink;
>> -    edid_status = dm_helpers_parse_edid_caps(
>> -            link,
>> -            &dc_sink->dc_edid,
>> -            &dc_sink->edid_caps);
>> +    edid_status = dm_helpers_parse_edid_caps(link,
>> +                         &dc_sink->edid_caps);
>>       /*
>>        * Treat device as no EDID device if EDID
> 


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

* Re: [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps
  2024-09-25 17:55     ` Mario Limonciello
@ 2024-09-26 10:48       ` Melissa Wen
  0 siblings, 0 replies; 23+ messages in thread
From: Melissa Wen @ 2024-09-26 10:48 UTC (permalink / raw)
  To: Mario Limonciello, Alex Hung, Alexander Deucher
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Wheeler, Daniel




On 25/09/2024 14:55, Mario Limonciello wrote:
> Alex,
>
> Unfortunately I can't reproduce the regression on the APU I tried. 
> However I do have a suspicion on a fix.
>
> Can you see if this helps?  If it does, we can squash it in.
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> index bf847ac55475..e75cd527d753 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -7008,6 +7008,7 @@ static void amdgpu_dm_connector_destroy(struct 
> drm_connector *connector)
>                 kfree(aconnector->i2c);
>         }
>         kfree(aconnector->dm_dp_aux.aux.name);
> +       drm_edid_free(aconnector->drm_edid);
>
>         kfree(connector);
>  }
>
> If that doesn't help, I did test dropping this patch and it doesn't 
> affect the last patch in the series, that one still works so I'm fine 
> with dropping it and we can follow up later.
yes, I agree with Mario's proposal.
>
> On 9/25/2024 12:06, Alex Hung wrote:
>> Mario and Melissa,
>>
>> This patch causes a regrerssion on 7900 XTX in an IGT test: 
>> amd_mem_leak's connector-suspend-resume.
>>
>> Is this patch necessary on this series or is it independent from 
>> other patches, i.e. can it be dropped from this series until fixed??
>>
>> Cheers,
>> Alex Hung
>>
>> On 9/18/24 15:38, Mario Limonciello wrote:
>>> From: Melissa Wen <mwen@igalia.com>
>>>
>>> We can parse edid caps from drm_edid and drm_eld and any calls of
>>> dm_helpers_parse_edid_caps is made in a state that we have drm_edid set
>>> to amdgpu connector.
>>>
>>> Signed-off-by: Melissa Wen <mwen@igalia.com>
>>> Co-developed-by: Mario Limonciello <mario.limonciello@amd.com>
>>> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
>>> ---
>>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c |  5 +---
>>>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 30 
>>> ++++++++-----------
>>>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |  1 -
>>>   .../drm/amd/display/dc/link/link_detection.c  |  6 ++--
>>>   4 files changed, 16 insertions(+), 26 deletions(-)
>>>
>>> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c b/ 
>>> drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> index bd8fb9968c7c..bf847ac55475 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
>>> @@ -7123,10 +7123,7 @@ static void 
>>> amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
>>>           memset(&dc_em_sink->edid_caps, 0, sizeof(struct 
>>> dc_edid_caps));
>>>           memmove(dc_em_sink->dc_edid.raw_edid, edid,
>>>               (edid->extensions + 1) * EDID_LENGTH);
>>> -        dm_helpers_parse_edid_caps(
>>> -            dc_link,
>>> -            &dc_em_sink->dc_edid,
>>> -            &dc_em_sink->edid_caps);
>>> +        dm_helpers_parse_edid_caps(dc_link, &dc_em_sink->edid_caps);
>>>       }
>>>   }
>>> diff --git 
>>> a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c 
>>> b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> index d43ed3ea000b..8f4be7a1ec45 100644
>>> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
>>> @@ -83,32 +83,24 @@ static void apply_edid_quirks(struct 
>>> drm_edid_product_id *product_id,
>>>    * dm_helpers_parse_edid_caps() - Parse edid caps
>>>    *
>>>    * @link: current detected link
>>> - * @edid:    [in] pointer to edid
>>>    * @edid_caps:    [in] pointer to edid caps
>>>    *
>>>    * Return: void
>>>    */
>>> -enum dc_edid_status dm_helpers_parse_edid_caps(
>>> -        struct dc_link *link,
>>> -        const struct dc_edid *edid,
>>> -        struct dc_edid_caps *edid_caps)
>>> +enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
>>> +                           struct dc_edid_caps *edid_caps)
>>>   {
>>>       struct amdgpu_dm_connector *aconnector = link->priv;
>>>       struct drm_connector *connector = &aconnector->base;
>>>       const struct drm_edid *drm_edid = aconnector->drm_edid;
>>>       struct drm_edid_product_id product_id;
>>> -    struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : 
>>> NULL;
>>>       int sad_count;
>>>       int i = 0;
>>> -
>>>       enum dc_edid_status result = EDID_OK;
>>> -    if (!edid_caps || !edid)
>>> +    if (!edid_caps || !drm_edid)
>>>           return EDID_BAD_INPUT;
>>> -    if (!drm_edid_is_valid(edid_buf))
>>> -        result = EDID_BAD_CHECKSUM;
>>> -
>>>       drm_edid_get_product_id(drm_edid, &product_id);
>>>       edid_caps->manufacturer_id = 
>>> le16_to_cpu(product_id.manufacturer_name);
>>> @@ -920,19 +912,23 @@ enum dc_edid_status dm_helpers_read_local_edid(
>>>           if (!drm_edid)
>>>               return EDID_NO_RESPONSE;
>>> -        edid = drm_edid_raw(drm_edid); // FIXME: Get rid of 
>>> drm_edid_raw()
>>> +        /* FIXME: Get rid of drm_edid_raw()
>>> +         * Raw edid is still needed for dm_helpers_dp_write_dpcd()
>>> +         */
>>> +        edid = drm_edid_raw(drm_edid);
>>>           sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
>>>           memmove(sink->dc_edid.raw_edid, (uint8_t *)edid, sink- 
>>> >dc_edid.length);
>>>           edid_status = dm_helpers_parse_edid_caps(
>>>                           link,
>>> -                        &sink->dc_edid,
>>>                           &sink->edid_caps);
>>> -        /* We don't need the original edid anymore */
>>> -        drm_edid_free(drm_edid);
>>> -
>>> -    } while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
>>> +        if (edid_status != EDID_OK) {
>>> +            /* We can discard the drm_edid and retry */
>>> +            drm_edid_free(drm_edid);
>>> +            drm_edid_connector_update(connector, drm_edid);
>>> +        }
>>> +    } while (edid_status != EDID_OK && --retry > 0);
>>>       if (edid_status != EDID_OK)
>>>           DRM_ERROR("EDID err: %d, on connector: %s",
>>> diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/ 
>>> gpu/drm/amd/display/dc/dm_helpers.h
>>> index 2e4a46f1b499..4e1776b5f0d4 100644
>>> --- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
>>> +++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
>>> @@ -61,7 +61,6 @@ void dm_helpers_free_gpu_mem(
>>>   enum dc_edid_status dm_helpers_parse_edid_caps(
>>>       struct dc_link *link,
>>> -    const struct dc_edid *edid,
>>>       struct dc_edid_caps *edid_caps);
>>> diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.c b/ 
>>> drivers/gpu/drm/amd/display/dc/link/link_detection.c
>>> index d21ee9d12d26..94c911742dd3 100644
>>> --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
>>> +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
>>> @@ -1413,10 +1413,8 @@ struct dc_sink *link_add_remote_sink(
>>>               dc_sink))
>>>           goto fail_add_sink;
>>> -    edid_status = dm_helpers_parse_edid_caps(
>>> -            link,
>>> -            &dc_sink->dc_edid,
>>> -            &dc_sink->edid_caps);
>>> +    edid_status = dm_helpers_parse_edid_caps(link,
>>> +                         &dc_sink->edid_caps);
>>>       /*
>>>        * Treat device as no EDID device if EDID
>>
>


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

* Re: [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps
  2024-09-18 21:38 ` [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps Mario Limonciello
@ 2024-09-26 19:21   ` Alex Hung
  0 siblings, 0 replies; 23+ messages in thread
From: Alex Hung @ 2024-09-26 19:21 UTC (permalink / raw)
  To: Mario Limonciello, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Broadworth, Mark, Wheeler, Daniel

Mario and Melissa,

Another regression identified on this patch - DP Display is not listed 
as an audio device after this patch is applied.

Cheers,
Alex Hung


On 9/18/24 15:38, Mario Limonciello wrote:
> From: Melissa Wen <mwen@igalia.com>
> 
> drm_edid_connector_update() updates display info, filling ELD with audio
> info from Short-Audio Descriptors in the last step of
> update_dislay_info(). Our goal is stopping using raw edid, so we can
> extract SAD from drm_eld instead of access raw edid to get audio caps.
> 
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 20 +++++++++----------
>   1 file changed, 10 insertions(+), 10 deletions(-)
> 
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> index 854e51c0b3fb..e0326127fd9a 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
> @@ -98,9 +98,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>   	const struct drm_edid *drm_edid = aconnector->drm_edid;
>   	struct drm_edid_product_id product_id;
>   	struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
> -	struct cea_sad *sads;
> -	int sad_count = -1;
> -	int sadb_count = -1;
> +	int sad_count, sadb_count;
>   	int i = 0;
>   	uint8_t *sadb = NULL;
>   
> @@ -129,18 +127,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>   
>   	apply_edid_quirks(&product_id, edid_caps);
>   
> -	sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
> +	sad_count = drm_eld_sad_count(connector->eld);
>   	if (sad_count <= 0)
>   		return result;
>   
>   	edid_caps->audio_mode_count = min(sad_count, DC_MAX_AUDIO_DESC_COUNT);
>   	for (i = 0; i < edid_caps->audio_mode_count; ++i) {
> -		struct cea_sad *sad = &sads[i];
> +		struct cea_sad sad;
>   
> -		edid_caps->audio_modes[i].format_code = sad->format;
> -		edid_caps->audio_modes[i].channel_count = sad->channels + 1;
> -		edid_caps->audio_modes[i].sample_rate = sad->freq;
> -		edid_caps->audio_modes[i].sample_size = sad->byte2;
> +		if (drm_eld_sad_get(connector->eld, i, &sad) < 0)
> +			continue;
> +
> +		edid_caps->audio_modes[i].format_code = sad.format;
> +		edid_caps->audio_modes[i].channel_count = sad.channels + 1;
> +		edid_caps->audio_modes[i].sample_rate = sad.freq;
> +		edid_caps->audio_modes[i].sample_size = sad.byte2;
>   	}
>   
>   	sadb_count = drm_edid_to_speaker_allocation((struct edid *) edid->raw_edid, &sadb);
> @@ -155,7 +156,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
>   	else
>   		edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
>   
> -	kfree(sads);
>   	kfree(sadb);
>   
>   	return result;


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

* Re: [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code
  2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
                   ` (9 preceding siblings ...)
  2024-09-18 21:38 ` [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP Mario Limonciello
@ 2024-09-27 18:48 ` Alex Hung
  2024-09-27 20:45   ` Melissa Wen
  10 siblings, 1 reply; 23+ messages in thread
From: Alex Hung @ 2024-09-27 18:48 UTC (permalink / raw)
  To: Mario Limonciello, Alexander Deucher, Melissa Wen
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Broadworth, Mark, Wheeler, Daniel

Hi Mario and Melissa,

There are three regressions identified during the test, and improvement 
is required before the patches can be merged. Please see details below.

1. null pointer when hot-plugging a dsc hub (+ three 4k60 monitors).

This may point to "drm/amd/display: use drm_edid_product_id for parsing 
EDID product info" since that's the only patch calling 
drm_edid_get_product_id.


[  227.797361] RIP: 0010:drm_edid_get_product_id+0x1d/0x50 [drm]
[  227.797388] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 00 
00 55 48 89 e5 48 85 ff 74 24 48 8b 47 08 48 85 c0 74 1b 48 83 3f 7f 76 
15 <48> 8b 50 08 5d 48 89 16 0f b7 40 10 66 89 46 08 e9 a9 47 ee ce 31
[  227.797391] RSP: 0018:ffffac58126f7930 EFLAGS: 00010216
[  227.797394] RAX: 000000000000372d RBX: ffff8eaeaf8ac808 RCX: 
ffff8eaeaf8ac107
[  227.797396] RDX: 0000000000000002 RSI: ffffac58126f7944 RDI: 
ffff8eaeeeaf9f80
[  227.797398] RBP: ffffac58126f7930 R08: ffff8eae8e500d00 R09: 
0000000000000001
[  227.797400] R10: ffffac58126f7978 R11: 000000000017f81b R12: 
ffff8eae84cb0000
[  227.797402] R13: ffff8eaeeeaf9f80 R14: 0000000000000000 R15: 
0000000000000100
[  227.797405] FS:  00007f031a616ac0(0000) GS:ffff8eb57cd80000(0000) 
knlGS:0000000000000000
[  227.797407] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[  227.797409] CR2: 0000000000003735 CR3: 000000014decc000 CR4: 
0000000000750ef0
[  227.797411] PKRU: 55555554
[  227.797413] Call Trace:
[  227.797415]  <TASK>
[  227.797417]  ? show_regs+0x64/0x70
[  227.797423]  ? __die+0x24/0x70
[  227.797427]  ? page_fault_oops+0x160/0x520
[  227.797435]  ? do_user_addr_fault+0x2e9/0x6a0
[  227.797438]  ? dc_link_add_remote_sink+0x20/0x30 [amdgpu]
[  227.797654]  ? dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
[  227.797882]  ? drm_helper_probe_single_connector_modes+0x1b5/0x670 
[drm_kms_helper]
[  227.797894]  ? exc_page_fault+0x7f/0x190
[  227.797899]  ? asm_exc_page_fault+0x27/0x30
[  227.797906]  ? drm_edid_get_product_id+0x1d/0x50 [drm]
[  227.797932]  dm_helpers_parse_edid_caps+0x69/0x260 [amdgpu]
[  227.798139] amdgpu 0000:0b:00.0: [drm:drm_dp_dpcd_write 
[drm_display_helper]] AMDGPU DM aux hw bus 2: 0x02003 AUX <- (ret=  1) 10
[  227.798158]  link_add_remote_sink+0xa8/0x1a0 [amdgpu]
[  227.798402]  dc_link_add_remote_sink+0x20/0x30 [amdgpu]
[  227.798615]  dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
[  227.798843]  ? srso_alias_return_thunk+0x5/0xfbef5
[  227.798848]  drm_helper_probe_single_connector_modes+0x1b5/0x670 
[drm_kms_helper]


2. DP2 Display is not listed as an audio device

Steps to reproduce:
- Attach display to system.
- Boot to Desktop (Wayland)
- Attempt to select display as an audio device.

This points to patch "drm/amd/display: get SAD from drm_eld when parsing 
EDID caps"


3. IGT amd_mem_leak'sconnector-suspend-resume fails on Navi 31.

This points to the patch "drm/amd/display: remove dc_edid handler from 
dm_helpers_parse_edid_caps".


Using IGT_SRANDOM=1727192429 for randomisation
Opened device: /dev/dri/card0
Starting subtest: connector-suspend-resume
[cmd] rtcwake: assuming RTC uses UTC ...
rtcwake: wakeup from "mem" using /dev/rtc0 at Tue Sep 24 15:40:50 2024
unreferenced object 0xffff95c683517b00 (size 256):
   comm "kworker/u64:30", pid 3636, jiffies 4295452761
   hex dump (first 32 bytes):
     00 ff ff ff ff ff ff 00 22 0e c2 36 00 00 00 00  ........"..6....
     33 1d 01 04 b5 3c 22 78 3b 28 91 a7 55 4e a3 26  3....<"x;(..UN.&
   backtrace (crc 5800a91d):
     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
     [<ffffffffbabbde07>] kmalloc_node_track_caller_noprof+0x337/0x410
     [<ffffffffbab631f8>] krealloc_noprof+0x58/0xb0
     [<ffffffffc04e8e38>] _drm_do_get_edid+0x138/0x410 [drm]
     [<ffffffffc04e9155>] drm_edid_read_custom+0x35/0xd0 [drm]
     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 [amdgpu]
     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
unreferenced object 0xffff95c6c58dd0c0 (size 16):
   comm "kworker/u64:30", pid 3636, jiffies 4295452764
   hex dump (first 16 bytes):
     00 01 00 00 00 00 00 00 00 7b 51 83 c6 95 ff ff  .........{Q.....
   backtrace (crc 70d89717):
     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
     [<ffffffffbabbbf3e>] kmalloc_trace_noprof+0x28e/0x300
     [<ffffffffc04e6845>] _drm_edid_alloc+0x35/0x60 [drm]
     [<ffffffffc04e9175>] drm_edid_read_custom+0x55/0xd0 [drm]
     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 [amdgpu]
     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
     [<ffffffffbb22ca76>] device_resume+0xb6/0x2c0
Stack trace:
   #0 ../lib/igt_core.c:2051 __igt_fail_assert()
   #1 ../tests/amdgpu/amd_mem_leak.c:202 __igt_unique____real_main208()
   #2 ../tests/amdgpu/amd_mem_leak.c:208 main()
   #3 ../sysdeps/nptl/libc_start_call_main.h:74 __libc_start_call_main()
   #4 ../csu/libc-start.c:128 __libc_start_main@@GLIBC_2.34()
   #5 [_start+0x25]
Subtest connector-suspend-resume: FAIL (9.535s)

On 9/18/24 15:38, Mario Limonciello wrote:
> This is the successor of Melissa's v5 series that was posted [1] as well
> as my series that was posted [2].
> 
> Melissa's patches are mostly unmodified from v5, but the series has been
> rebase on the new 6.10 based amd-staging-drm-next.
> 
> As were both touching similar code for fetching the EDID, I've merged the
> pertinent parts of my series into this one in allowing the connector to
> fetch the EDID from _DDC if available for eDP as well.
> 
> There are still some remaining uses of drm_edid_raw() but they touch pure
> DC code, so a wrapper or macro will probably be needed to convert them.
> This can be for follow ups later on.
> 
> Link: https://lore.kernel.org/amd-gfx/20240807203207.2830-1-mwen@igalia.com/ [1]
> Link: https://lore.kernel.org/dri-devel/20240214215756.6530-1-mario.limonciello@amd.com/ [2]
> 
> v7:
>   * Rebase on amd-staging-drm-next which is now 6.10 based
>   * Fix the two LKP robot reported issues
> 
> Mario Limonciello (1):
>    drm/amd/display: Fetch the EDID from _DDC if available for eDP
> 
> Melissa Wen (9):
>    drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid
>    drm/amd/display: switch to setting physical address directly
>    drm/amd/display: always call connector_update when parsing
>      freesync_caps
>    drm/amd/display: remove redundant freesync parser for DP
>    drm/amd/display: use drm_edid_product_id for parsing EDID product info
>    drm/amd/display: parse display name from drm_eld
>    drm/amd/display: get SAD from drm_eld when parsing EDID caps
>    drm/amd/display: get SADB from drm_eld when parsing EDID caps
>    drm/amd/display: remove dc_edid handler from
>      dm_helpers_parse_edid_caps
> 
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 200 ++++++------------
>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +-
>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 172 +++++++++------
>   .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  34 +--
>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   1 -
>   .../drm/amd/display/dc/link/link_detection.c  |   6 +-
>   drivers/gpu/drm/amd/include/amd_shared.h      |   5 +
>   7 files changed, 200 insertions(+), 222 deletions(-)
> 
> 
> base-commit: 0569603f945225067d963c8ba4fda31d967ab584


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

* Re: [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code
  2024-09-27 18:48 ` [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Alex Hung
@ 2024-09-27 20:45   ` Melissa Wen
  2024-09-27 21:34     ` Alex Hung
  0 siblings, 1 reply; 23+ messages in thread
From: Melissa Wen @ 2024-09-27 20:45 UTC (permalink / raw)
  To: Alex Hung, Mario Limonciello, Alexander Deucher
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Broadworth, Mark, Wheeler, Daniel

Hi Alex,

Thanks for the intensive testing.

I'll need some time to reproduce and debug these regressions.

So, we can divide this series into four steps:
1-2 are the basis for drm_edid migration
3-4 are code cleanups
5-9 are drm_edid_product_id migration
10 is for ACPI EDID feature.

Bearing this and the reported regressions around the product_id part in 
mind, I wonder if we can start by applying the drm_edid migration and 
the ACPI EDID feature, which means applying patches 1-4 and 10. And then 
let the second part of product_id migration for the next iteration.
IMHO it seems a smoother transition.

WDYT?

Melissa


On 27/09/2024 15:48, Alex Hung wrote:
> Hi Mario and Melissa,
>
> There are three regressions identified during the test, and 
> improvement is required before the patches can be merged. Please see 
> details below.
>
> 1. null pointer when hot-plugging a dsc hub (+ three 4k60 monitors).
>
> This may point to "drm/amd/display: use drm_edid_product_id for 
> parsing EDID product info" since that's the only patch calling 
> drm_edid_get_product_id.
>
>
> [  227.797361] RIP: 0010:drm_edid_get_product_id+0x1d/0x50 [drm]
> [  227.797388] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 
> 00 00 55 48 89 e5 48 85 ff 74 24 48 8b 47 08 48 85 c0 74 1b 48 83 3f 
> 7f 76 15 <48> 8b 50 08 5d 48 89 16 0f b7 40 10 66 89 46 08 e9 a9 47 ee 
> ce 31
> [  227.797391] RSP: 0018:ffffac58126f7930 EFLAGS: 00010216
> [  227.797394] RAX: 000000000000372d RBX: ffff8eaeaf8ac808 RCX: 
> ffff8eaeaf8ac107
> [  227.797396] RDX: 0000000000000002 RSI: ffffac58126f7944 RDI: 
> ffff8eaeeeaf9f80
> [  227.797398] RBP: ffffac58126f7930 R08: ffff8eae8e500d00 R09: 
> 0000000000000001
> [  227.797400] R10: ffffac58126f7978 R11: 000000000017f81b R12: 
> ffff8eae84cb0000
> [  227.797402] R13: ffff8eaeeeaf9f80 R14: 0000000000000000 R15: 
> 0000000000000100
> [  227.797405] FS:  00007f031a616ac0(0000) GS:ffff8eb57cd80000(0000) 
> knlGS:0000000000000000
> [  227.797407] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
> [  227.797409] CR2: 0000000000003735 CR3: 000000014decc000 CR4: 
> 0000000000750ef0
> [  227.797411] PKRU: 55555554
> [  227.797413] Call Trace:
> [  227.797415]  <TASK>
> [  227.797417]  ? show_regs+0x64/0x70
> [  227.797423]  ? __die+0x24/0x70
> [  227.797427]  ? page_fault_oops+0x160/0x520
> [  227.797435]  ? do_user_addr_fault+0x2e9/0x6a0
> [  227.797438]  ? dc_link_add_remote_sink+0x20/0x30 [amdgpu]
> [  227.797654]  ? dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
> [  227.797882]  ? drm_helper_probe_single_connector_modes+0x1b5/0x670 
> [drm_kms_helper]
> [  227.797894]  ? exc_page_fault+0x7f/0x190
> [  227.797899]  ? asm_exc_page_fault+0x27/0x30
> [  227.797906]  ? drm_edid_get_product_id+0x1d/0x50 [drm]
> [  227.797932]  dm_helpers_parse_edid_caps+0x69/0x260 [amdgpu]
> [  227.798139] amdgpu 0000:0b:00.0: [drm:drm_dp_dpcd_write 
> [drm_display_helper]] AMDGPU DM aux hw bus 2: 0x02003 AUX <- (ret=  1) 10
> [  227.798158]  link_add_remote_sink+0xa8/0x1a0 [amdgpu]
> [  227.798402]  dc_link_add_remote_sink+0x20/0x30 [amdgpu]
> [  227.798615]  dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
> [  227.798843]  ? srso_alias_return_thunk+0x5/0xfbef5
> [  227.798848] drm_helper_probe_single_connector_modes+0x1b5/0x670 
> [drm_kms_helper]
>
>
> 2. DP2 Display is not listed as an audio device
>
> Steps to reproduce:
> - Attach display to system.
> - Boot to Desktop (Wayland)
> - Attempt to select display as an audio device.
>
> This points to patch "drm/amd/display: get SAD from drm_eld when 
> parsing EDID caps"
>
>
> 3. IGT amd_mem_leak'sconnector-suspend-resume fails on Navi 31.
>
> This points to the patch "drm/amd/display: remove dc_edid handler from 
> dm_helpers_parse_edid_caps".
>
>
> Using IGT_SRANDOM=1727192429 for randomisation
> Opened device: /dev/dri/card0
> Starting subtest: connector-suspend-resume
> [cmd] rtcwake: assuming RTC uses UTC ...
> rtcwake: wakeup from "mem" using /dev/rtc0 at Tue Sep 24 15:40:50 2024
> unreferenced object 0xffff95c683517b00 (size 256):
>   comm "kworker/u64:30", pid 3636, jiffies 4295452761
>   hex dump (first 32 bytes):
>     00 ff ff ff ff ff ff 00 22 0e c2 36 00 00 00 00 ........"..6....
>     33 1d 01 04 b5 3c 22 78 3b 28 91 a7 55 4e a3 26 3....<"x;(..UN.&
>   backtrace (crc 5800a91d):
>     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
>     [<ffffffffbabbde07>] kmalloc_node_track_caller_noprof+0x337/0x410
>     [<ffffffffbab631f8>] krealloc_noprof+0x58/0xb0
>     [<ffffffffc04e8e38>] _drm_do_get_edid+0x138/0x410 [drm]
>     [<ffffffffc04e9155>] drm_edid_read_custom+0x35/0xd0 [drm]
>     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
>     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
>     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
>     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
>     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
>     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
>     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 
> [amdgpu]
>     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
>     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
>     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
>     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
> unreferenced object 0xffff95c6c58dd0c0 (size 16):
>   comm "kworker/u64:30", pid 3636, jiffies 4295452764
>   hex dump (first 16 bytes):
>     00 01 00 00 00 00 00 00 00 7b 51 83 c6 95 ff ff .........{Q.....
>   backtrace (crc 70d89717):
>     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
>     [<ffffffffbabbbf3e>] kmalloc_trace_noprof+0x28e/0x300
>     [<ffffffffc04e6845>] _drm_edid_alloc+0x35/0x60 [drm]
>     [<ffffffffc04e9175>] drm_edid_read_custom+0x55/0xd0 [drm]
>     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
>     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
>     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
>     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
>     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
>     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
>     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 
> [amdgpu]
>     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
>     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
>     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
>     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
>     [<ffffffffbb22ca76>] device_resume+0xb6/0x2c0
> Stack trace:
>   #0 ../lib/igt_core.c:2051 __igt_fail_assert()
>   #1 ../tests/amdgpu/amd_mem_leak.c:202 __igt_unique____real_main208()
>   #2 ../tests/amdgpu/amd_mem_leak.c:208 main()
>   #3 ../sysdeps/nptl/libc_start_call_main.h:74 __libc_start_call_main()
>   #4 ../csu/libc-start.c:128 __libc_start_main@@GLIBC_2.34()
>   #5 [_start+0x25]
> Subtest connector-suspend-resume: FAIL (9.535s)
>
> On 9/18/24 15:38, Mario Limonciello wrote:
>> This is the successor of Melissa's v5 series that was posted [1] as well
>> as my series that was posted [2].
>>
>> Melissa's patches are mostly unmodified from v5, but the series has been
>> rebase on the new 6.10 based amd-staging-drm-next.
>>
>> As were both touching similar code for fetching the EDID, I've merged 
>> the
>> pertinent parts of my series into this one in allowing the connector to
>> fetch the EDID from _DDC if available for eDP as well.
>>
>> There are still some remaining uses of drm_edid_raw() but they touch 
>> pure
>> DC code, so a wrapper or macro will probably be needed to convert them.
>> This can be for follow ups later on.
>>
>> Link: 
>> https://lore.kernel.org/amd-gfx/20240807203207.2830-1-mwen@igalia.com/ 
>> [1]
>> Link: 
>> https://lore.kernel.org/dri-devel/20240214215756.6530-1-mario.limonciello@amd.com/ 
>> [2]
>>
>> v7:
>>   * Rebase on amd-staging-drm-next which is now 6.10 based
>>   * Fix the two LKP robot reported issues
>>
>> Mario Limonciello (1):
>>    drm/amd/display: Fetch the EDID from _DDC if available for eDP
>>
>> Melissa Wen (9):
>>    drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid
>>    drm/amd/display: switch to setting physical address directly
>>    drm/amd/display: always call connector_update when parsing
>>      freesync_caps
>>    drm/amd/display: remove redundant freesync parser for DP
>>    drm/amd/display: use drm_edid_product_id for parsing EDID product 
>> info
>>    drm/amd/display: parse display name from drm_eld
>>    drm/amd/display: get SAD from drm_eld when parsing EDID caps
>>    drm/amd/display: get SADB from drm_eld when parsing EDID caps
>>    drm/amd/display: remove dc_edid handler from
>>      dm_helpers_parse_edid_caps
>>
>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 200 ++++++------------
>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +-
>>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 172 +++++++++------
>>   .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  34 +--
>>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   1 -
>>   .../drm/amd/display/dc/link/link_detection.c  |   6 +-
>>   drivers/gpu/drm/amd/include/amd_shared.h      |   5 +
>>   7 files changed, 200 insertions(+), 222 deletions(-)
>>
>>
>> base-commit: 0569603f945225067d963c8ba4fda31d967ab584
>


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

* Re: [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code
  2024-09-27 20:45   ` Melissa Wen
@ 2024-09-27 21:34     ` Alex Hung
  0 siblings, 0 replies; 23+ messages in thread
From: Alex Hung @ 2024-09-27 21:34 UTC (permalink / raw)
  To: Melissa Wen, Mario Limonciello, Alexander Deucher,
	Siqueira, Rodrigo
  Cc: kernel-dev, amd-gfx, dri-devel, harry.wentland, sunpeng.li,
	Mark Pearson, Broadworth, Mark, Wheeler, Daniel



On 9/27/24 14:45, Melissa Wen wrote:
> Hi Alex,
> 
> Thanks for the intensive testing.
> 
> I'll need some time to reproduce and debug these regressions.
> 
> So, we can divide this series into four steps:
> 1-2 are the basis for drm_edid migration
> 3-4 are code cleanups
> 5-9 are drm_edid_product_id migration
> 10 is for ACPI EDID feature.
> 
> Bearing this and the reported regressions around the product_id part in 
> mind, I wonder if we can start by applying the drm_edid migration and 
> the ACPI EDID feature, which means applying patches 1-4 and 10. And then 
> let the second part of product_id migration for the next iteration.
> IMHO it seems a smoother transition.
> 
> WDYT?

This sounds like a good plan.

Not all tests were completed on 1-4 + 10 as the series were dropped due 
to the regressions. I can send the 5 patches for tests next week again; 
however, 10 cannot be applied cleanly on top of 1-4, and help from Mario 
to rebase is probably needed.

As for the rest, let me know if you cannot reproduce these issues since 
you may or may not have the same hardware configs.

> 
> Melissa
> 
> 
> On 27/09/2024 15:48, Alex Hung wrote:
>> Hi Mario and Melissa,
>>
>> There are three regressions identified during the test, and 
>> improvement is required before the patches can be merged. Please see 
>> details below.
>>
>> 1. null pointer when hot-plugging a dsc hub (+ three 4k60 monitors).
>>
>> This may point to "drm/amd/display: use drm_edid_product_id for 
>> parsing EDID product info" since that's the only patch calling 
>> drm_edid_get_product_id.
>>
>>
>> [  227.797361] RIP: 0010:drm_edid_get_product_id+0x1d/0x50 [drm]
>> [  227.797388] Code: 90 90 90 90 90 90 90 90 90 90 90 90 90 0f 1f 44 
>> 00 00 55 48 89 e5 48 85 ff 74 24 48 8b 47 08 48 85 c0 74 1b 48 83 3f 
>> 7f 76 15 <48> 8b 50 08 5d 48 89 16 0f b7 40 10 66 89 46 08 e9 a9 47 ee 
>> ce 31
>> [  227.797391] RSP: 0018:ffffac58126f7930 EFLAGS: 00010216
>> [  227.797394] RAX: 000000000000372d RBX: ffff8eaeaf8ac808 RCX: 
>> ffff8eaeaf8ac107
>> [  227.797396] RDX: 0000000000000002 RSI: ffffac58126f7944 RDI: 
>> ffff8eaeeeaf9f80
>> [  227.797398] RBP: ffffac58126f7930 R08: ffff8eae8e500d00 R09: 
>> 0000000000000001
>> [  227.797400] R10: ffffac58126f7978 R11: 000000000017f81b R12: 
>> ffff8eae84cb0000
>> [  227.797402] R13: ffff8eaeeeaf9f80 R14: 0000000000000000 R15: 
>> 0000000000000100
>> [  227.797405] FS:  00007f031a616ac0(0000) GS:ffff8eb57cd80000(0000) 
>> knlGS:0000000000000000
>> [  227.797407] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
>> [  227.797409] CR2: 0000000000003735 CR3: 000000014decc000 CR4: 
>> 0000000000750ef0
>> [  227.797411] PKRU: 55555554
>> [  227.797413] Call Trace:
>> [  227.797415]  <TASK>
>> [  227.797417]  ? show_regs+0x64/0x70
>> [  227.797423]  ? __die+0x24/0x70
>> [  227.797427]  ? page_fault_oops+0x160/0x520
>> [  227.797435]  ? do_user_addr_fault+0x2e9/0x6a0
>> [  227.797438]  ? dc_link_add_remote_sink+0x20/0x30 [amdgpu]
>> [  227.797654]  ? dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
>> [  227.797882]  ? drm_helper_probe_single_connector_modes+0x1b5/0x670 
>> [drm_kms_helper]
>> [  227.797894]  ? exc_page_fault+0x7f/0x190
>> [  227.797899]  ? asm_exc_page_fault+0x27/0x30
>> [  227.797906]  ? drm_edid_get_product_id+0x1d/0x50 [drm]
>> [  227.797932]  dm_helpers_parse_edid_caps+0x69/0x260 [amdgpu]
>> [  227.798139] amdgpu 0000:0b:00.0: [drm:drm_dp_dpcd_write 
>> [drm_display_helper]] AMDGPU DM aux hw bus 2: 0x02003 AUX <- (ret=  1) 10
>> [  227.798158]  link_add_remote_sink+0xa8/0x1a0 [amdgpu]
>> [  227.798402]  dc_link_add_remote_sink+0x20/0x30 [amdgpu]
>> [  227.798615]  dm_dp_mst_get_modes+0xee/0x520 [amdgpu]
>> [  227.798843]  ? srso_alias_return_thunk+0x5/0xfbef5
>> [  227.798848] drm_helper_probe_single_connector_modes+0x1b5/0x670 
>> [drm_kms_helper]
>>
>>
>> 2. DP2 Display is not listed as an audio device
>>
>> Steps to reproduce:
>> - Attach display to system.
>> - Boot to Desktop (Wayland)
>> - Attempt to select display as an audio device.
>>
>> This points to patch "drm/amd/display: get SAD from drm_eld when 
>> parsing EDID caps"
>>
>>
>> 3. IGT amd_mem_leak'sconnector-suspend-resume fails on Navi 31.
>>
>> This points to the patch "drm/amd/display: remove dc_edid handler from 
>> dm_helpers_parse_edid_caps".
>>
>>
>> Using IGT_SRANDOM=1727192429 for randomisation
>> Opened device: /dev/dri/card0
>> Starting subtest: connector-suspend-resume
>> [cmd] rtcwake: assuming RTC uses UTC ...
>> rtcwake: wakeup from "mem" using /dev/rtc0 at Tue Sep 24 15:40:50 2024
>> unreferenced object 0xffff95c683517b00 (size 256):
>>   comm "kworker/u64:30", pid 3636, jiffies 4295452761
>>   hex dump (first 32 bytes):
>>     00 ff ff ff ff ff ff 00 22 0e c2 36 00 00 00 00 ........"..6....
>>     33 1d 01 04 b5 3c 22 78 3b 28 91 a7 55 4e a3 26 3....<"x;(..UN.&
>>   backtrace (crc 5800a91d):
>>     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
>>     [<ffffffffbabbde07>] kmalloc_node_track_caller_noprof+0x337/0x410
>>     [<ffffffffbab631f8>] krealloc_noprof+0x58/0xb0
>>     [<ffffffffc04e8e38>] _drm_do_get_edid+0x138/0x410 [drm]
>>     [<ffffffffc04e9155>] drm_edid_read_custom+0x35/0xd0 [drm]
>>     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
>>     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
>>     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
>>     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
>>     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
>>     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
>>     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 
>> [amdgpu]
>>     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
>>     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
>>     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
>>     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
>> unreferenced object 0xffff95c6c58dd0c0 (size 16):
>>   comm "kworker/u64:30", pid 3636, jiffies 4295452764
>>   hex dump (first 16 bytes):
>>     00 01 00 00 00 00 00 00 00 7b 51 83 c6 95 ff ff .........{Q.....
>>   backtrace (crc 70d89717):
>>     [<ffffffffbb73502a>] kmemleak_alloc+0x4a/0x80
>>     [<ffffffffbabbbf3e>] kmalloc_trace_noprof+0x28e/0x300
>>     [<ffffffffc04e6845>] _drm_edid_alloc+0x35/0x60 [drm]
>>     [<ffffffffc04e9175>] drm_edid_read_custom+0x55/0xd0 [drm]
>>     [<ffffffffc04e9244>] drm_edid_read_ddc+0x44/0x80 [drm]
>>     [<ffffffffc1061808>] dm_helpers_read_local_edid+0x1d8/0x340 [amdgpu]
>>     [<ffffffffc11b7446>] detect_link_and_local_sink+0x356/0x1230 [amdgpu]
>>     [<ffffffffc11b8366>] link_detect+0x36/0x4f0 [amdgpu]
>>     [<ffffffffc13667a0>] dc_link_detect+0x20/0x30 [amdgpu]
>>     [<ffffffffc10536f0>] dm_resume+0x1e0/0x7d0 [amdgpu]
>>     [<ffffffffc0d25908>] amdgpu_device_ip_resume_phase2+0x58/0xd0 
>> [amdgpu]
>>     [<ffffffffc0d29cb7>] amdgpu_device_resume+0xa7/0x2e0 [amdgpu]
>>     [<ffffffffc0d2467c>] amdgpu_pmops_resume+0x4c/0x90 [amdgpu]
>>     [<ffffffffbb02e121>] pci_pm_resume+0x71/0x100
>>     [<ffffffffbb22c551>] dpm_run_callback+0x91/0x1e0
>>     [<ffffffffbb22ca76>] device_resume+0xb6/0x2c0
>> Stack trace:
>>   #0 ../lib/igt_core.c:2051 __igt_fail_assert()
>>   #1 ../tests/amdgpu/amd_mem_leak.c:202 __igt_unique____real_main208()
>>   #2 ../tests/amdgpu/amd_mem_leak.c:208 main()
>>   #3 ../sysdeps/nptl/libc_start_call_main.h:74 __libc_start_call_main()
>>   #4 ../csu/libc-start.c:128 __libc_start_main@@GLIBC_2.34()
>>   #5 [_start+0x25]
>> Subtest connector-suspend-resume: FAIL (9.535s)
>>
>> On 9/18/24 15:38, Mario Limonciello wrote:
>>> This is the successor of Melissa's v5 series that was posted [1] as well
>>> as my series that was posted [2].
>>>
>>> Melissa's patches are mostly unmodified from v5, but the series has been
>>> rebase on the new 6.10 based amd-staging-drm-next.
>>>
>>> As were both touching similar code for fetching the EDID, I've merged 
>>> the
>>> pertinent parts of my series into this one in allowing the connector to
>>> fetch the EDID from _DDC if available for eDP as well.
>>>
>>> There are still some remaining uses of drm_edid_raw() but they touch 
>>> pure
>>> DC code, so a wrapper or macro will probably be needed to convert them.
>>> This can be for follow ups later on.
>>>
>>> Link: https://lore.kernel.org/amd-gfx/20240807203207.2830-1- 
>>> mwen@igalia.com/ [1]
>>> Link: https://lore.kernel.org/dri-devel/20240214215756.6530-1- 
>>> mario.limonciello@amd.com/ [2]
>>>
>>> v7:
>>>   * Rebase on amd-staging-drm-next which is now 6.10 based
>>>   * Fix the two LKP robot reported issues
>>>
>>> Mario Limonciello (1):
>>>    drm/amd/display: Fetch the EDID from _DDC if available for eDP
>>>
>>> Melissa Wen (9):
>>>    drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid
>>>    drm/amd/display: switch to setting physical address directly
>>>    drm/amd/display: always call connector_update when parsing
>>>      freesync_caps
>>>    drm/amd/display: remove redundant freesync parser for DP
>>>    drm/amd/display: use drm_edid_product_id for parsing EDID product 
>>> info
>>>    drm/amd/display: parse display name from drm_eld
>>>    drm/amd/display: get SAD from drm_eld when parsing EDID caps
>>>    drm/amd/display: get SADB from drm_eld when parsing EDID caps
>>>    drm/amd/display: remove dc_edid handler from
>>>      dm_helpers_parse_edid_caps
>>>
>>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 200 ++++++------------
>>>   .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h |   4 +-
>>>   .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 172 +++++++++------
>>>   .../display/amdgpu_dm/amdgpu_dm_mst_types.c   |  34 +--
>>>   drivers/gpu/drm/amd/display/dc/dm_helpers.h   |   1 -
>>>   .../drm/amd/display/dc/link/link_detection.c  |   6 +-
>>>   drivers/gpu/drm/amd/include/amd_shared.h      |   5 +
>>>   7 files changed, 200 insertions(+), 222 deletions(-)
>>>
>>>
>>> base-commit: 0569603f945225067d963c8ba4fda31d967ab584
>>
> 


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

end of thread, other threads:[~2024-09-27 21:34 UTC | newest]

Thread overview: 23+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-09-18 21:38 [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 01/10] drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 02/10] drm/amd/display: switch to setting physical address directly Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 03/10] drm/amd/display: always call connector_update when parsing freesync_caps Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 04/10] drm/amd/display: remove redundant freesync parser for DP Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 05/10] drm/amd/display: use drm_edid_product_id for parsing EDID product info Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 06/10] drm/amd/display: parse display name from drm_eld Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 07/10] drm/amd/display: get SAD from drm_eld when parsing EDID caps Mario Limonciello
2024-09-26 19:21   ` Alex Hung
2024-09-18 21:38 ` [PATCH v7 08/10] drm/amd/display: get SADB " Mario Limonciello
2024-09-18 21:38 ` [PATCH v7 09/10] drm/amd/display: remove dc_edid handler from dm_helpers_parse_edid_caps Mario Limonciello
2024-09-25 17:06   ` Alex Hung
2024-09-25 17:55     ` Mario Limonciello
2024-09-26 10:48       ` Melissa Wen
2024-09-18 21:38 ` [PATCH v7 10/10] drm/amd/display: Fetch the EDID from _DDC if available for eDP Mario Limonciello
2024-09-19 16:03   ` Alex Hung
2024-09-19 16:05     ` Mario Limonciello
2024-09-19 17:29       ` Alex Deucher
2024-09-19 17:36         ` Hamza Mahfooz
2024-09-19 18:14           ` Mario Limonciello
2024-09-27 18:48 ` [PATCH v7 00/10] drm/amd/display: Use drm_edid for more code Alex Hung
2024-09-27 20:45   ` Melissa Wen
2024-09-27 21:34     ` Alex Hung

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.