* [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
@ 2025-07-26 0:33 Melissa Wen
2025-07-26 0:33 ` [PATCH v6 01/14] drm/amd/display: make sure drm_edid stored in aconnector doesn't leak Melissa Wen
` (14 more replies)
0 siblings, 15 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, airlied,
alexander.deucher, andrzej.hajda, christian.koenig,
harry.wentland, maarten.lankhorst, mripard, mwen, neil.armstrong,
rfoss, simona, sunpeng.li, tzimmermann
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Hi,
Siqueira and I have been working on a solution to reduce the usage of
drm_edid_raw in the AMD display driver, since the current guideline in
the DRM subsystem is to stop handling raw edid data in driver-specific
implementation and use opaque `drm_edid` object with common-code
helpers.
To keep DC as an OS-agnostic component, we create a mid layer that
isolates `drm_edid` helpers called in the DC code, while allowing other
OSes to implement their specific implementation.
This work is an extension of [1].
- Patch 1 addresses a possible leak added by previous migration to
drm_edid.
- Patch 2 allocates a temporary drm_edid from raw edid for parsing.
- Patches 3-7 use common-code, drm_edid helpers to parse edid
capabilities instead of driver-specific solutions. For this, patch 4
introduces a new helper that gets monitor name from drm_edid.
- Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
code in the DC shared code
- Patch 10 creates a mid layer to make DC embraces different ways of
handling EDID by platforms.
- Patch 11 move open-coded management of raw EDID data to the mid
layer created before.
- Patch 12 introduces a helper that compares EDIDs from two drm_edids.
- Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
free `drm_edid`.
- Patch 14 switch dc_edid to drm_edid across the driver in a way that
the DC shared code is little affected by Linux specific stuff.
[v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-mwen@igalia.com/
Changes:
- fix broken approach to get monitor name from eld (Jani)
- I introduced a new helper that gets monitor name from drm_edid
- rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
- add NULL edid checks (Jani)
- fix mishandling of product_id.manufacturer_name (Michel)
- I directly set it to manufacturer_id since sparse didn't complain.
- add Mario's r-b in the first fix patch and fix commit msg typo.
[v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-mwen@igalia.com/
Changes:
- kernel-doc and commit msg fixes (Jani)
- use drm_edid_legacy_init instead of open coded (Jani)
- place drm_edid new func into the right section (Jani)
- paramenter names fix (Jani)
- add Jani's r-b to the patch 12
- remove unnecessary include (Jani)
- call dc_edid_sink_edid_free in link_detection, instead of drm_edid_free
- rebase on top of asdn
[v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-mwen@igalia.com/
Changes:
- rebase to asdn
- some kernel-doc fixes
- move some changes to the right commit
[v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-mwen@igalia.com/
Changes:
- fix comments and commit messages (Mario)
- remove unnecessary drm_edid dup and fix mem leak (Mario)
- add Mario's rb to patches 5-7
[v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-mwen@igalia.com/
Changes:
- fix NULL pointer dereference (Alex H.) with the same approach proposed
by 7c3be3ce3dfae
---
There are three specific points where we still use drm_edid_raw() in the
driver:
1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
drm_dp_dpcd_write(), that AFAIK there is no common code solution yet;
2. open-coded connectivity log for dc link detection, that maybe can be
moved to drm (?);
3. open-coded parser that I suspect is a lot of duplicated code, but
needs careful examining.
I suggest to address those points in a next phase for regression control.
[1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-mwen@igalia.com/
Let me know yours thoughts!
Melissa
Melissa Wen (12):
drm/amd/display: make sure drm_edid stored in aconnector doesn't leak
drm/amd/display: start using drm_edid helpers to parse EDID caps
drm/amd/display: use drm_edid_product_id for parsing EDID product info
drm/edid: introduce a helper that gets monitor name from drm_edid
drm/amd/display: get panel id with drm_edid helper
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: simplify dm_helpers_parse_edid_caps signature
drm/amd/display: change DC functions to accept private types for edid
drm/edid: introduce a helper that compares edid data from two drm_edid
drm/amd/display: add drm_edid to dc_sink
drm/amd/display: move dc_sink from dc_edid to drm_edid
Rodrigo Siqueira (2):
drm/amd/display: add a mid-layer file to handle EDID in DC
drm/amd/display: create a function to fill dc_sink with edid data
.../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 +++++++-----------
.../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
.../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
.../drm/amd/display/dc/link/link_detection.c | 30 ++---
.../drm/amd/display/dc/link/link_detection.h | 9 +-
drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
drivers/gpu/drm/drm_edid.c | 54 +++++++--
include/drm/drm_edid.h | 10 +-
17 files changed, 199 insertions(+), 164 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
--
2.47.2
^ permalink raw reply [flat|nested] 25+ messages in thread
* [PATCH v6 01/14] drm/amd/display: make sure drm_edid stored in aconnector doesn't leak
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 02/14] drm/amd/display: start using drm_edid helpers to parse EDID caps Melissa Wen
` (13 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona,
mwen
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Make sure the drm_edid container stored in aconnector is freed when
destroying the aconnector.
Fixes: 48edb2a4256e ("drm/amd/display: switch amdgpu_dm_connector to use struct drm_edid")
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 ++
1 file changed, 2 insertions(+)
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 096b23ad4845..89cc5ddda982 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7308,6 +7308,8 @@ static void amdgpu_dm_connector_destroy(struct drm_connector *connector)
dc_sink_release(aconnector->dc_sink);
aconnector->dc_sink = NULL;
+ drm_edid_free(aconnector->drm_edid);
+
drm_dp_cec_unregister_connector(&aconnector->dm_dp_aux.aux);
drm_connector_unregister(connector);
drm_connector_cleanup(connector);
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 02/14] drm/amd/display: start using drm_edid helpers to parse EDID caps
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
2025-07-26 0:33 ` [PATCH v6 01/14] drm/amd/display: make sure drm_edid stored in aconnector doesn't leak Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 03/14] drm/amd/display: use drm_edid_product_id for parsing EDID product info Melissa Wen
` (12 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Groundwork that allocates a temporary drm_edid from raw edid to take
advantage of DRM common-code helpers instead of driver-specific code.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 12 +++++++++---
1 file changed, 9 insertions(+), 3 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 9e3e51a2dc49..1edab2a440e4 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
@@ -108,18 +108,21 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
struct drm_connector *connector = &aconnector->base;
struct drm_device *dev = connector->dev;
struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
+ const struct drm_edid *drm_edid;
struct cea_sad *sads;
int sad_count = -1;
int sadb_count = -1;
int i = 0;
uint8_t *sadb = NULL;
-
enum dc_edid_status result = EDID_OK;
+
if (!edid_caps || !edid)
return EDID_BAD_INPUT;
- if (!drm_edid_is_valid(edid_buf))
+ drm_edid = drm_edid_alloc(edid_buf, EDID_LENGTH * (edid_buf->extensions + 1));
+
+ if (!drm_edid_valid(drm_edid))
result = EDID_BAD_CHECKSUM;
edid_caps->manufacturer_id = (uint16_t) edid_buf->mfg_id[0] |
@@ -139,8 +142,10 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
apply_edid_quirks(dev, edid_buf, edid_caps);
sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
- if (sad_count <= 0)
+ if (sad_count <= 0) {
+ drm_edid_free(drm_edid);
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) {
@@ -166,6 +171,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
kfree(sads);
kfree(sadb);
+ drm_edid_free(drm_edid);
return result;
}
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 03/14] drm/amd/display: use drm_edid_product_id for parsing EDID product info
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
2025-07-26 0:33 ` [PATCH v6 01/14] drm/amd/display: make sure drm_edid stored in aconnector doesn't leak Melissa Wen
2025-07-26 0:33 ` [PATCH v6 02/14] drm/amd/display: start using drm_edid helpers to parse EDID caps Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 04/14] drm/edid: introduce a helper that gets monitor name from drm_edid Melissa Wen
` (11 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Use drm_edid_product_id [1] to get debug info from drm_edid instead of
directly parsing raw EDID.
[1] 3ddbd345539e ("drm/edid: add drm_edid_get_product_id()").
Signed-off-by: Melissa Wen <mwen@igalia.com>
--
v5:
- replace series url to commit hash (Mario)
---
.../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 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 1edab2a440e4..5411d6029dac 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
@@ -109,6 +109,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
struct drm_device *dev = connector->dev;
struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
const struct drm_edid *drm_edid;
+ struct drm_edid_product_id product_id;
struct cea_sad *sads;
int sad_count = -1;
int sadb_count = -1;
@@ -125,13 +126,13 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
if (!drm_edid_valid(drm_edid))
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 = 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,
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 04/14] drm/edid: introduce a helper that gets monitor name from drm_edid
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (2 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 03/14] drm/amd/display: use drm_edid_product_id for parsing EDID product info Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 05/14] drm/amd/display: get panel id with drm_edid helper Melissa Wen
` (10 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona,
andrzej.hajda, neil.armstrong, rfoss, maarten.lankhorst, mripard,
tzimmermann
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Original drm_edid_get_monitor_name encapsulates raw edid in drm_edid and
then call get_monitor_name. AMD still stores the display name for
debugging, but it is migrating to drm_edid, on the other hand,
drm_dp_mst_topology and sil-sii8620 still use the raw edid version.
Split drm_edid_get_monitor_name into two helpers, one that gets monitor
name from raw edid and another from drm_edid. It's temporary and the raw
edid version should be removed later.
v3:
- kernel-doc and commit msg mentionind raw edid stuff is deprecated (jani)
- use drm_edid_legacy_init instead of open coded (jani)
- move drm_edid new func declaration to its section (jani)
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 2 +-
drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
drivers/gpu/drm/drm_edid.c | 30 +++++++++++++------
include/drm/drm_edid.h | 8 +++--
5 files changed, 29 insertions(+), 15 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 5411d6029dac..9a22b0a057dc 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
@@ -134,7 +134,7 @@ 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,
+ drm_edid_get_monitor_name(drm_edid,
edid_caps->display_name,
AUDIO_INFO_DISPLAY_NAME_SIZE_IN_CHARS);
diff --git a/drivers/gpu/drm/bridge/sil-sii8620.c b/drivers/gpu/drm/bridge/sil-sii8620.c
index 28a2e1ee04b2..c2d60b9c28fd 100644
--- a/drivers/gpu/drm/bridge/sil-sii8620.c
+++ b/drivers/gpu/drm/bridge/sil-sii8620.c
@@ -505,7 +505,7 @@ static void sii8620_identify_sink(struct sii8620 *ctx)
else
ctx->sink_type = SINK_DVI;
- drm_edid_get_monitor_name(ctx->edid, sink_name, ARRAY_SIZE(sink_name));
+ drm_edid_raw_get_monitor_name(ctx->edid, sink_name, ARRAY_SIZE(sink_name));
dev_info(dev, "detected sink(type: %s): %s\n",
sink_str[ctx->sink_type], sink_name);
diff --git a/drivers/gpu/drm/display/drm_dp_mst_topology.c b/drivers/gpu/drm/display/drm_dp_mst_topology.c
index 3a1f1ffc7b55..b17a602516ee 100644
--- a/drivers/gpu/drm/display/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/display/drm_dp_mst_topology.c
@@ -4896,7 +4896,7 @@ static void fetch_monitor_name(struct drm_dp_mst_topology_mgr *mgr,
struct edid *mst_edid;
mst_edid = drm_dp_mst_get_edid(port->connector, mgr, port);
- drm_edid_get_monitor_name(mst_edid, name, namelen);
+ drm_edid_raw_get_monitor_name(mst_edid, name, namelen);
kfree(mst_edid);
}
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index 13bc4c290b17..d5772a3d27f1 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -5575,27 +5575,23 @@ static int get_monitor_name(const struct drm_edid *drm_edid, char name[13])
}
/**
- * drm_edid_get_monitor_name - fetch the monitor name from the edid
- * @edid: monitor EDID information
+ * drm_edid_get_monitor_name - fetch the monitor name from the drm_edid
+ * @drm_edid: EDID
* @name: pointer to a character array to hold the name of the monitor
* @bufsize: The size of the name buffer (should be at least 14 chars.)
*
*/
-void drm_edid_get_monitor_name(const struct edid *edid, char *name, int bufsize)
+void drm_edid_get_monitor_name(const struct drm_edid *drm_edid, char *name, int bufsize)
{
int name_length = 0;
if (bufsize <= 0)
return;
- if (edid) {
+ if (drm_edid->edid) {
char buf[13];
- struct drm_edid drm_edid = {
- .edid = edid,
- .size = edid_size(edid),
- };
- name_length = min(get_monitor_name(&drm_edid, buf), bufsize - 1);
+ name_length = min(get_monitor_name(drm_edid, buf), bufsize - 1);
memcpy(name, buf, name_length);
}
@@ -5603,6 +5599,22 @@ void drm_edid_get_monitor_name(const struct edid *edid, char *name, int bufsize)
}
EXPORT_SYMBOL(drm_edid_get_monitor_name);
+/**
+ * drm_edid_raw_get_monitor_name - fetch the monitor name from raw edid
+ * @edid: monitor EDID information
+ * @name: pointer to a character array to hold the name of the monitor
+ * @bufsize: The size of the name buffer (should be at least 14 chars.)
+ *
+ * This function is deprecated. Use drm_edid_get_monitor_name() instead.
+ */
+void drm_edid_raw_get_monitor_name(const struct edid *edid, char *name, int bufsize)
+{
+ struct drm_edid drm_edid;
+
+ drm_edid_get_monitor_name(drm_edid_legacy_init(&drm_edid, edid), name, bufsize);
+}
+EXPORT_SYMBOL(drm_edid_raw_get_monitor_name);
+
static void clear_eld(struct drm_connector *connector)
{
mutex_lock(&connector->eld_mutex);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index eaac5e665892..960592167486 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -441,8 +441,8 @@ int drm_add_modes_noedid(struct drm_connector *connector,
int drm_edid_header_is_valid(const void *edid);
bool drm_edid_is_valid(struct edid *edid);
-void drm_edid_get_monitor_name(const struct edid *edid, char *name,
- int buflen);
+void drm_edid_raw_get_monitor_name(const struct edid *edid, char *name,
+ int bufsize);
struct drm_display_mode *drm_mode_find_dmt(struct drm_device *dev,
int hsize, int vsize, int fresh,
bool rb);
@@ -476,5 +476,7 @@ void drm_edid_print_product_id(struct drm_printer *p,
u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid);
bool drm_edid_match(const struct drm_edid *drm_edid,
const struct drm_edid_ident *ident);
-
+void drm_edid_get_monitor_name(const struct drm_edid *drm_edid,
+ char *name,
+ int bufsize);
#endif /* __DRM_EDID_H__ */
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 05/14] drm/amd/display: get panel id with drm_edid helper
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (3 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 04/14] drm/edid: introduce a helper that gets monitor name from drm_edid Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 06/14] drm/amd/display: get SAD from drm_eld when parsing EDID caps Melissa Wen
` (9 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Instead of using driver-specific code, use DRM helpers.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 15 +++++----------
1 file changed, 5 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 9a22b0a057dc..ed2ba094d3ae 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
@@ -48,16 +48,11 @@
#include "ddc_service_types.h"
#include "clk_mgr.h"
-static u32 edid_extract_panel_id(struct edid *edid)
+static void apply_edid_quirks(struct drm_device *dev,
+ const struct drm_edid *drm_edid,
+ struct dc_edid_caps *edid_caps)
{
- return (u32)edid->mfg_id[0] << 24 |
- (u32)edid->mfg_id[1] << 16 |
- (u32)EDID_PRODUCT_ID(edid);
-}
-
-static void apply_edid_quirks(struct drm_device *dev, struct edid *edid, struct dc_edid_caps *edid_caps)
-{
- uint32_t panel_id = edid_extract_panel_id(edid);
+ uint32_t panel_id = drm_edid_get_panel_id(drm_edid);
switch (panel_id) {
/* Workaround for monitors that need a delay after detecting the link */
@@ -140,7 +135,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
edid_caps->edid_hdmi = connector->display_info.is_hdmi;
- apply_edid_quirks(dev, edid_buf, edid_caps);
+ apply_edid_quirks(dev, drm_edid, edid_caps);
sad_count = drm_edid_to_sad((struct edid *) edid->raw_edid, &sads);
if (sad_count <= 0) {
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 06/14] drm/amd/display: get SAD from drm_eld when parsing EDID caps
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (4 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 05/14] drm/amd/display: get panel id with drm_edid helper Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 07/14] drm/amd/display: get SADB " Melissa Wen
` (8 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
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.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 22 ++++++++++---------
1 file changed, 12 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 ed2ba094d3ae..2e6116a6b518 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
@@ -33,6 +33,7 @@
#include <drm/drm_probe_helper.h>
#include <drm/amdgpu_drm.h>
#include <drm/drm_edid.h>
+#include <drm/drm_eld.h>
#include <drm/drm_fixed.h>
#include "dm_services.h"
@@ -105,9 +106,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
const struct drm_edid *drm_edid;
struct drm_edid_product_id product_id;
- struct cea_sad *sads;
- int sad_count = -1;
- int sadb_count = -1;
+ int sad_count, sadb_count;
int i = 0;
uint8_t *sadb = NULL;
enum dc_edid_status result = EDID_OK;
@@ -121,6 +120,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
if (!drm_edid_valid(drm_edid))
result = EDID_BAD_CHECKSUM;
+ drm_edid_connector_update(connector, drm_edid);
drm_edid_get_product_id(drm_edid, &product_id);
edid_caps->manufacturer_id = product_id.manufacturer_name;
@@ -137,7 +137,7 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
apply_edid_quirks(dev, drm_edid, 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) {
drm_edid_free(drm_edid);
return result;
@@ -145,12 +145,15 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
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);
@@ -165,7 +168,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
else
edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
- kfree(sads);
kfree(sadb);
drm_edid_free(drm_edid);
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 07/14] drm/amd/display: get SADB from drm_eld when parsing EDID caps
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (5 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 06/14] drm/amd/display: get SAD from drm_eld when parsing EDID caps Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 08/14] drm/amd/display: simplify dm_helpers_parse_edid_caps signature Melissa Wen
` (7 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
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.
Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Melissa Wen <mwen@igalia.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 2e6116a6b518..ab8dad538308 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
@@ -106,9 +106,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(
struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
const struct drm_edid *drm_edid;
struct drm_edid_product_id product_id;
- int sad_count, sadb_count;
+ int sad_count;
int i = 0;
- uint8_t *sadb = NULL;
enum dc_edid_status result = EDID_OK;
@@ -156,19 +155,11 @@ 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);
drm_edid_free(drm_edid);
return result;
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 08/14] drm/amd/display: simplify dm_helpers_parse_edid_caps signature
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (6 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 07/14] drm/amd/display: get SADB " Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 09/14] drm/amd/display: change DC functions to accept private types for edid Melissa Wen
` (6 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Pass dc_sink to dm_helpers_parse_edid_caps(), since it already contains
edid info. It's a groundwork to get rid of raw edid stored as dc_edid.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 5 +---
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 23 ++++++++-----------
drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 ++----
.../drm/amd/display/dc/link/link_detection.c | 5 +---
4 files changed, 13 insertions(+), 27 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 89cc5ddda982..878269c2092c 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -7440,10 +7440,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);
}
}
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 ab8dad538308..d4d60d62964c 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
@@ -89,29 +89,27 @@ static void apply_edid_quirks(struct drm_device *dev,
/**
* dm_helpers_parse_edid_caps() - Parse edid caps
*
- * @link: current detected link
- * @edid: [in] pointer to edid
- * @edid_caps: [in] pointer to edid caps
+ * @link: current detected link (connector)
+ * @sink: current detected sink (display)
*
* 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_sink *sink)
{
struct amdgpu_dm_connector *aconnector = link->priv;
struct drm_connector *connector = &aconnector->base;
struct drm_device *dev = connector->dev;
- struct edid *edid_buf = edid ? (struct edid *) edid->raw_edid : NULL;
+ struct edid *edid_buf;
const struct drm_edid *drm_edid;
struct drm_edid_product_id product_id;
+ struct dc_edid_caps *edid_caps = &sink->edid_caps;
int sad_count;
int i = 0;
enum dc_edid_status result = EDID_OK;
-
- if (!edid_caps || !edid)
+ edid_buf = (struct edid *) &sink->dc_edid.raw_edid;
+ if (!edid_caps || !edid_buf)
return EDID_BAD_INPUT;
drm_edid = drm_edid_alloc(edid_buf, EDID_LENGTH * (edid_buf->extensions + 1));
@@ -1034,10 +1032,7 @@ enum dc_edid_status dm_helpers_read_local_edid(
/* 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);
+ edid_status = dm_helpers_parse_edid_caps(link, sink);
} while (edid_status == EDID_BAD_CHECKSUM && --retry > 0);
diff --git a/drivers/gpu/drm/amd/display/dc/dm_helpers.h b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
index 9d160b39e8c5..ce6a70368bd0 100644
--- a/drivers/gpu/drm/amd/display/dc/dm_helpers.h
+++ b/drivers/gpu/drm/amd/display/dc/dm_helpers.h
@@ -59,11 +59,8 @@ void dm_helpers_free_gpu_mem(
enum dc_gpu_mem_alloc_type type,
void *pvMem);
-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_sink *sink);
/*
* Update DP branch info
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 827b630daf49..a0d76d851cdd 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1421,10 +1421,7 @@ 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);
/*
* Treat device as no EDID device if EDID
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 09/14] drm/amd/display: change DC functions to accept private types for edid
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (7 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 08/14] drm/amd/display: simplify dm_helpers_parse_edid_caps signature Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 10/14] drm/amd/display: add a mid-layer file to handle EDID in DC Melissa Wen
` (5 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
There is an opaque obj in Linux/DRM to encapsulate edid data as
`drm_edid`. This obj isn't present in other platforms but we need to
pass it through DC when adding sink. To pass this data without
compromise the independence of DC code, make some DC functions accept
edid data as private options.
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c | 9 ++++-----
drivers/gpu/drm/amd/display/dc/dc.h | 9 ++++-----
drivers/gpu/drm/amd/display/dc/inc/link.h | 9 ++++-----
drivers/gpu/drm/amd/display/dc/link/link_detection.c | 4 ++--
drivers/gpu/drm/amd/display/dc/link/link_detection.h | 9 ++++-----
5 files changed, 18 insertions(+), 22 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c b/drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c
index 130455f2802a..2459d62bc586 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_link_exports.c
@@ -278,11 +278,10 @@ unsigned int dc_dp_trace_get_link_loss_count(struct dc_link *link)
return link->dc->link_srv->dp_trace_get_link_loss_count(link);
}
-struct dc_sink *dc_link_add_remote_sink(
- struct dc_link *link,
- const uint8_t *edid,
- int len,
- struct dc_sink_init_data *init_data)
+struct dc_sink *dc_link_add_remote_sink(struct dc_link *link,
+ const void *edid,
+ int len,
+ struct dc_sink_init_data *init_data)
{
return link->dc->link_srv->add_remote_sink(link, edid, len, init_data);
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 59c07756130d..233d73f9f19f 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -1943,11 +1943,10 @@ struct dc_sink_init_data;
* @len - size of the edid in byte
* @init_data -
*/
-struct dc_sink *dc_link_add_remote_sink(
- struct dc_link *dc_link,
- const uint8_t *edid,
- int len,
- struct dc_sink_init_data *init_data);
+struct dc_sink *dc_link_add_remote_sink(struct dc_link *dc_link,
+ const void *edid,
+ int len,
+ struct dc_sink_init_data *init_data);
/* Remove remote sink from a link with dc_connection_mst_branch connection type.
* @link - link the sink should be removed from
diff --git a/drivers/gpu/drm/amd/display/dc/inc/link.h b/drivers/gpu/drm/amd/display/dc/inc/link.h
index f2503402c10e..4110f11f44cc 100644
--- a/drivers/gpu/drm/amd/display/dc/inc/link.h
+++ b/drivers/gpu/drm/amd/display/dc/inc/link.h
@@ -107,11 +107,10 @@ struct link_service {
bool (*detect_link)(struct dc_link *link, enum dc_detect_reason reason);
bool (*detect_connection_type)(struct dc_link *link,
enum dc_connection_type *type);
- struct dc_sink *(*add_remote_sink)(
- struct dc_link *link,
- const uint8_t *edid,
- int len,
- struct dc_sink_init_data *init_data);
+ struct dc_sink *(*add_remote_sink)(struct dc_link *link,
+ const void *edid,
+ int len,
+ struct dc_sink_init_data *init_data);
void (*remove_remote_sink)(struct dc_link *link, struct dc_sink *sink);
bool (*get_hpd_state)(struct dc_link *link);
struct gpio *(*get_hpd_gpio)(struct dc_bios *dcb,
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 a0d76d851cdd..10670c79bf54 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1386,7 +1386,7 @@ static bool link_add_remote_sink_helper(struct dc_link *dc_link, struct dc_sink
struct dc_sink *link_add_remote_sink(
struct dc_link *link,
- const uint8_t *edid,
+ const void *edid,
int len,
struct dc_sink_init_data *init_data)
{
@@ -1413,7 +1413,7 @@ struct dc_sink *link_add_remote_sink(
if (!dc_sink)
return NULL;
- memmove(dc_sink->dc_edid.raw_edid, edid, len);
+ memmove(dc_sink->dc_edid.raw_edid, (const uint8_t *) edid, len);
dc_sink->dc_edid.length = len;
if (!link_add_remote_sink_helper(
diff --git a/drivers/gpu/drm/amd/display/dc/link/link_detection.h b/drivers/gpu/drm/amd/display/dc/link/link_detection.h
index 7da05078721e..9cd3aa36c7d8 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.h
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.h
@@ -29,11 +29,10 @@
bool link_detect(struct dc_link *link, enum dc_detect_reason reason);
bool link_detect_connection_type(struct dc_link *link,
enum dc_connection_type *type);
-struct dc_sink *link_add_remote_sink(
- struct dc_link *link,
- const uint8_t *edid,
- int len,
- struct dc_sink_init_data *init_data);
+struct dc_sink *link_add_remote_sink(struct dc_link *link,
+ const void *edid,
+ int len,
+ struct dc_sink_init_data *init_data);
void link_remove_remote_sink(struct dc_link *link, struct dc_sink *sink);
bool link_reset_cur_dp_mst_topology(struct dc_link *link);
const struct dc_link_status *link_get_status(const struct dc_link *link);
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 10/14] drm/amd/display: add a mid-layer file to handle EDID in DC
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (8 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 09/14] drm/amd/display: change DC functions to accept private types for edid Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 11/14] drm/amd/display: create a function to fill dc_sink with edid data Melissa Wen
` (4 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
From: Rodrigo Siqueira <siqueira@igalia.com>
Since DC is a shared code, this commit introduces a new file to work as
a mid-layer in DC for the edid manipulation.
Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com>
Co-developed-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 19 +++++++++++++++++++
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 11 +++++++++++
.../drm/amd/display/dc/link/link_detection.c | 17 +++--------------
4 files changed, 34 insertions(+), 14 deletions(-)
create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
index 7329b8cc2576..09cb94d8e0e4 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/Makefile
@@ -39,6 +39,7 @@ AMDGPUDM = \
amdgpu_dm_psr.o \
amdgpu_dm_replay.o \
amdgpu_dm_quirks.o \
+ dc_edid.o \
amdgpu_dm_wb.o
ifdef CONFIG_DRM_AMD_DC_FP
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
new file mode 100644
index 000000000000..3f8295a68a72
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
@@ -0,0 +1,19 @@
+// SPDX-License-Identifier: MIT
+#include "dc.h"
+#include "dc_edid.h"
+
+bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
+ struct dc_sink *current_sink)
+{
+ struct dc_edid *old_edid = &prev_sink->dc_edid;
+ struct dc_edid *new_edid = ¤t_sink->dc_edid;
+
+ if (old_edid->length != new_edid->length)
+ return false;
+
+ if (new_edid->length == 0)
+ return false;
+
+ return (memcmp(old_edid->raw_edid,
+ new_edid->raw_edid, new_edid->length) == 0);
+}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
new file mode 100644
index 000000000000..7e3b1177bc8a
--- /dev/null
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
@@ -0,0 +1,11 @@
+/* SPDX-License-Identifier: MIT */
+
+#ifndef __DC_EDID_H__
+#define __DC_EDID_H__
+
+#include "dc.h"
+
+bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
+ struct dc_sink *current_sink);
+
+#endif /* __DC_EDID_H__ */
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 10670c79bf54..1cd229b862d1 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -48,6 +48,8 @@
#include "dm_helpers.h"
#include "clk_mgr.h"
+#include "amdgpu_dm/dc_edid.h"
+
// Offset DPCD 050Eh == 0x5A
#define MST_HUB_ID_0x5A 0x5A
@@ -618,18 +620,6 @@ static bool detect_dp(struct dc_link *link,
return true;
}
-static bool is_same_edid(struct dc_edid *old_edid, struct dc_edid *new_edid)
-{
- if (old_edid->length != new_edid->length)
- return false;
-
- if (new_edid->length == 0)
- return false;
-
- return (memcmp(old_edid->raw_edid,
- new_edid->raw_edid, new_edid->length) == 0);
-}
-
static bool wait_for_entering_dp_alt_mode(struct dc_link *link)
{
@@ -1106,8 +1096,7 @@ static bool detect_link_and_local_sink(struct dc_link *link,
// Check if edid is the same
if ((prev_sink) &&
(edid_status == EDID_THE_SAME || edid_status == EDID_OK))
- same_edid = is_same_edid(&prev_sink->dc_edid,
- &sink->dc_edid);
+ same_edid = dc_edid_is_same_edid(prev_sink, sink);
if (sink->edid_caps.panel_patch.skip_scdc_overwrite)
link->ctx->dc->debug.hdmi20_disable = true;
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 11/14] drm/amd/display: create a function to fill dc_sink with edid data
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (9 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 10/14] drm/amd/display: add a mid-layer file to handle EDID in DC Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 12/14] drm/edid: introduce a helper that compares edid data from two drm_edid Melissa Wen
` (3 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
From: Rodrigo Siqueira <siqueira@igalia.com>
As part of the effort of stopping using raw edid, this commit move the
copy of the edid in DC to a dedicated function that will allow the usage
of drm_edid in the next steps.
Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com>
Co-developer-by: Melissa Wen <mwen@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 8 ++++++++
drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 2 ++
drivers/gpu/drm/amd/display/dc/link/link_detection.c | 3 +--
3 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
index 3f8295a68a72..b4ccc111fa08 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
@@ -17,3 +17,11 @@ bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
return (memcmp(old_edid->raw_edid,
new_edid->raw_edid, new_edid->length) == 0);
}
+
+void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
+ const void *edid,
+ int len)
+{
+ memmove(dc_sink->dc_edid.raw_edid, edid, len);
+ dc_sink->dc_edid.length = len;
+}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
index 7e3b1177bc8a..f42cd5bbc730 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
@@ -7,5 +7,7 @@
bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
struct dc_sink *current_sink);
+void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
+ const void *edid, int len);
#endif /* __DC_EDID_H__ */
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 1cd229b862d1..0fcdf803b7a0 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1402,8 +1402,7 @@ struct dc_sink *link_add_remote_sink(
if (!dc_sink)
return NULL;
- memmove(dc_sink->dc_edid.raw_edid, (const uint8_t *) edid, len);
- dc_sink->dc_edid.length = len;
+ dc_edid_copy_edid_to_dc(dc_sink, edid, len);
if (!link_add_remote_sink_helper(
link,
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 12/14] drm/edid: introduce a helper that compares edid data from two drm_edid
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (10 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 11/14] drm/amd/display: create a function to fill dc_sink with edid data Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-07-26 0:33 ` [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink Melissa Wen
` (2 subsequent siblings)
14 siblings, 0 replies; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, maarten.lankhorst,
mripard, tzimmermann, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, Jani Nikula,
kernel-dev
AMD driver has a function used to compare if two edid are the same; this
is useful to some of the link detection algorithms implemented by
amdgpu. Since the amdgpu function can be helpful for other drivers, this
commit abstracts the AMD function to make it available at the DRM level
by wrapping existent drm_edid_eq().
v2:
- rename drm_edid_eq to drm_edid_eq_buf (jani)
- add NULL checks (jani)
v3:
- fix kernel-doc (jani)
- fix parameter names
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
Co-developed-by: Rodrigo Siqueira <siqueira@igalia.com>
Signed-off-by: Rodrigo Siqueira <siqueira@igalia.com>
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/drm_edid.c | 24 +++++++++++++++++++++---
include/drm/drm_edid.h | 2 ++
2 files changed, 23 insertions(+), 3 deletions(-)
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index d5772a3d27f1..056e070b2f55 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -1820,8 +1820,8 @@ static bool edid_block_is_zero(const void *edid)
return mem_is_zero(edid, EDID_LENGTH);
}
-static bool drm_edid_eq(const struct drm_edid *drm_edid,
- const void *raw_edid, size_t raw_edid_size)
+static bool drm_edid_eq_buf(const struct drm_edid *drm_edid,
+ const void *raw_edid, size_t raw_edid_size)
{
bool edid1_present = drm_edid && drm_edid->edid && drm_edid->size;
bool edid2_present = raw_edid && raw_edid_size;
@@ -6915,7 +6915,7 @@ static int _drm_edid_connector_property_update(struct drm_connector *connector,
const void *old_edid = connector->edid_blob_ptr->data;
size_t old_edid_size = connector->edid_blob_ptr->length;
- if (old_edid && !drm_edid_eq(drm_edid, old_edid, old_edid_size)) {
+ if (old_edid && !drm_edid_eq_buf(drm_edid, old_edid, old_edid_size)) {
connector->epoch_counter++;
drm_dbg_kms(dev, "[CONNECTOR:%d:%s] EDID changed, epoch counter %llu\n",
connector->base.id, connector->name,
@@ -7520,3 +7520,21 @@ bool drm_edid_is_digital(const struct drm_edid *drm_edid)
drm_edid->edid->input & DRM_EDID_INPUT_DIGITAL;
}
EXPORT_SYMBOL(drm_edid_is_digital);
+
+/**
+ * drm_edid_eq - Check if EDIDs are equal
+ *
+ * @drm_edid_1: first drm_edid to compare edid
+ * @drm_edid_2: second drm_edid to compare edid
+ *
+ * Return true if EDIDs are equal.
+ */
+bool drm_edid_eq(const struct drm_edid *drm_edid_1,
+ const struct drm_edid *drm_edid_2)
+{
+ const void *edid_1 = drm_edid_1 ? drm_edid_1->edid : NULL;
+ size_t edid_1_size = drm_edid_1 ? drm_edid_1->size : 0;
+
+ return drm_edid_eq_buf(drm_edid_2, edid_1, edid_1_size);
+}
+EXPORT_SYMBOL(drm_edid_eq);
diff --git a/include/drm/drm_edid.h b/include/drm/drm_edid.h
index 960592167486..8617d2285f38 100644
--- a/include/drm/drm_edid.h
+++ b/include/drm/drm_edid.h
@@ -469,6 +469,8 @@ int drm_edid_connector_update(struct drm_connector *connector,
const struct drm_edid *edid);
int drm_edid_connector_add_modes(struct drm_connector *connector);
bool drm_edid_is_digital(const struct drm_edid *drm_edid);
+bool drm_edid_eq(const struct drm_edid *drm_edid_1,
+ const struct drm_edid *drm_edid_2);
void drm_edid_get_product_id(const struct drm_edid *drm_edid,
struct drm_edid_product_id *id);
void drm_edid_print_product_id(struct drm_printer *p,
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (11 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 12/14] drm/edid: introduce a helper that compares edid data from two drm_edid Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-08-11 21:27 ` Harry Wentland
2025-07-26 0:33 ` [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid Melissa Wen
2025-07-28 23:29 ` [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Alex Hung
14 siblings, 1 reply; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Add Linux opaque object to dc_sink for storing EDID data cross driver,
drm_edid. Also include the Linux call to free this object, the
drm_edid_free()
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 6 ++++++
drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 1 +
drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +++
drivers/gpu/drm/amd/display/dc/dc.h | 1 +
4 files changed, 11 insertions(+)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
index b4ccc111fa08..493815829aa5 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
@@ -1,6 +1,7 @@
// SPDX-License-Identifier: MIT
#include "dc.h"
#include "dc_edid.h"
+#include <drm/drm_edid.h>
bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
struct dc_sink *current_sink)
@@ -25,3 +26,8 @@ void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
memmove(dc_sink->dc_edid.raw_edid, edid, len);
dc_sink->dc_edid.length = len;
}
+
+void dc_edid_sink_edid_free(struct dc_sink *sink)
+{
+ drm_edid_free(sink->drm_edid);
+}
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
index f42cd5bbc730..2c76768be459 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
@@ -9,5 +9,6 @@ bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
struct dc_sink *current_sink);
void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
const void *edid, int len);
+void dc_edid_sink_edid_free(struct dc_sink *sink);
#endif /* __DC_EDID_H__ */
diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
index 455fa5dd1420..3774a3245506 100644
--- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
+++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
@@ -26,6 +26,7 @@
#include "dm_services.h"
#include "dm_helpers.h"
#include "core_types.h"
+#include "dc_edid.h"
/*******************************************************************************
* Private functions
@@ -65,6 +66,8 @@ void dc_sink_retain(struct dc_sink *sink)
static void dc_sink_free(struct kref *kref)
{
struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
+
+ dc_edid_sink_edid_free(sink);
kfree(sink->dc_container_id);
kfree(sink);
}
diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
index 233d73f9f19f..215d3901480a 100644
--- a/drivers/gpu/drm/amd/display/dc/dc.h
+++ b/drivers/gpu/drm/amd/display/dc/dc.h
@@ -2493,6 +2493,7 @@ struct scdc_caps {
struct dc_sink {
enum signal_type sink_signal;
struct dc_edid dc_edid; /* raw edid */
+ const struct drm_edid *drm_edid; /* Linux DRM EDID */
struct dc_edid_caps edid_caps; /* parse display caps */
struct dc_container_id *dc_container_id;
uint32_t dongle_max_pix_clk;
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (12 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink Melissa Wen
@ 2025-07-26 0:33 ` Melissa Wen
2025-08-11 21:29 ` Harry Wentland
2025-07-28 23:29 ` [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Alex Hung
14 siblings, 1 reply; 25+ messages in thread
From: Melissa Wen @ 2025-07-26 0:33 UTC (permalink / raw)
To: Mario Limonciello, Alex Hung, Rodrigo Siqueira, harry.wentland,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Reduce direct handling of edid data by resorting to drm helpers that
deal with this info inside drm_edid infrastructure.
v3:
- use dc_edid_sink_edid_free in link_detection
v5:
- no need of drm_edid duplication (Mario)
- fix mem leak on dc_sink->drm_edid
v6:
- fix NULL pointer dereference (Alex H)
Signed-off-by: Melissa Wen <mwen@igalia.com>
---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 26 ++++++---------
.../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 31 ++++++------------
.../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++++--------
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 32 +++++++++++--------
.../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 1 +
.../drm/amd/display/dc/link/link_detection.c | 3 +-
6 files changed, 48 insertions(+), 66 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 878269c2092c..1aa0ccf74580 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -68,6 +68,7 @@
#endif
#include "amdgpu_dm_psr.h"
#include "amdgpu_dm_replay.h"
+#include "dc_edid.h"
#include "ivsrcid/ivsrcid_vislands30.h"
@@ -3743,6 +3744,8 @@ void amdgpu_dm_update_connector_after_detect(
* 2. Send an event and let userspace tell us what to do
*/
if (sink) {
+ const struct drm_edid *drm_edid = sink->drm_edid;
+
/*
* TODO: check if we still need the S3 mode update workaround.
* If yes, put it here.
@@ -3754,16 +3757,15 @@ void amdgpu_dm_update_connector_after_detect(
aconnector->dc_sink = sink;
dc_sink_retain(aconnector->dc_sink);
- if (sink->dc_edid.length == 0) {
+
+ if (!drm_edid_valid(drm_edid)) {
aconnector->drm_edid = NULL;
hdmi_cec_unset_edid(aconnector);
if (aconnector->dc_link->aux_mode) {
drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
}
} else {
- const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid;
-
- aconnector->drm_edid = drm_edid_alloc(edid, sink->dc_edid.length);
+ aconnector->drm_edid = drm_edid_dup(sink->drm_edid);
drm_edid_connector_update(connector, aconnector->drm_edid);
hdmi_cec_set_edid(aconnector);
@@ -7434,12 +7436,8 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
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);
+ dc_edid_copy_edid_to_dc(dc_em_sink, drm_edid, 0);
dm_helpers_parse_edid_caps(dc_link, dc_em_sink);
}
}
@@ -7472,7 +7470,6 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
.sink_signal = SIGNAL_TYPE_VIRTUAL
};
const struct drm_edid *drm_edid;
- const struct edid *edid;
struct i2c_adapter *ddc;
if (dc_link && dc_link->aux_mode)
@@ -7492,12 +7489,9 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
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,
- (edid->extensions + 1) * EDID_LENGTH,
- &init_params);
+ aconnector->dc_em_sink = dc_link_add_remote_sink(aconnector->dc_link,
+ drm_edid, 0,
+ &init_params);
if (aconnector->base.force == DRM_FORCE_ON) {
aconnector->dc_sink = aconnector->dc_link->local_sink ?
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 d4d60d62964c..288e87f92f9e 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
@@ -48,6 +48,7 @@
#include "dm_helpers.h"
#include "ddc_service_types.h"
#include "clk_mgr.h"
+#include "dc_edid.h"
static void apply_edid_quirks(struct drm_device *dev,
const struct drm_edid *drm_edid,
@@ -100,20 +101,16 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
struct amdgpu_dm_connector *aconnector = link->priv;
struct drm_connector *connector = &aconnector->base;
struct drm_device *dev = connector->dev;
- struct edid *edid_buf;
- const struct drm_edid *drm_edid;
+ const struct drm_edid *drm_edid = sink->drm_edid;
struct drm_edid_product_id product_id;
struct dc_edid_caps *edid_caps = &sink->edid_caps;
int sad_count;
int i = 0;
enum dc_edid_status result = EDID_OK;
- edid_buf = (struct edid *) &sink->dc_edid.raw_edid;
- if (!edid_caps || !edid_buf)
+ if (!edid_caps || !drm_edid)
return EDID_BAD_INPUT;
- drm_edid = drm_edid_alloc(edid_buf, EDID_LENGTH * (edid_buf->extensions + 1));
-
if (!drm_edid_valid(drm_edid))
result = EDID_BAD_CHECKSUM;
@@ -135,10 +132,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
apply_edid_quirks(dev, drm_edid, edid_caps);
sad_count = drm_eld_sad_count(connector->eld);
- if (sad_count <= 0) {
- drm_edid_free(drm_edid);
+ 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) {
@@ -158,8 +153,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
else
edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
- drm_edid_free(drm_edid);
-
return result;
}
@@ -991,7 +984,6 @@ enum dc_edid_status dm_helpers_read_local_edid(
int retry = 3;
enum dc_edid_status edid_status;
const struct drm_edid *drm_edid;
- const struct edid *edid;
if (link->aux_mode)
ddc = &aconnector->dm_dp_aux.aux.ddc;
@@ -1002,6 +994,8 @@ enum dc_edid_status dm_helpers_read_local_edid(
* do check sum and retry to make sure read correct edid.
*/
do {
+ drm_edid_free(sink->drm_edid);
+
drm_edid = dm_helpers_read_acpi_edid(aconnector);
if (drm_edid)
drm_info(connector->dev, "Using ACPI provided EDID for %s\n", connector->name);
@@ -1021,16 +1015,7 @@ 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()
- if (!edid ||
- edid->extensions >= sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH)
- return EDID_BAD_INPUT;
-
- 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);
+ sink->drm_edid = drm_edid;
edid_status = dm_helpers_parse_edid_caps(link, sink);
@@ -1055,6 +1040,8 @@ enum dc_edid_status dm_helpers_read_local_edid(
test_response.bits.EDID_CHECKSUM_WRITE = 1;
+ // TODO: drm_edid doesn't have a helper for dp_write_dpcd yet
+ dc_edid_copy_edid_to_sink(sink);
dm_helpers_dp_write_dpcd(ctx,
link,
DP_TEST_EDID_CHECKSUM,
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 7187d5aedf0a..5ca3e668c8aa 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
@@ -359,12 +359,10 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
.link = aconnector->dc_link,
.sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST };
- dc_sink = dc_link_add_remote_sink(
- aconnector->dc_link,
- NULL,
- 0,
- &init_params);
-
+ dc_sink = dc_link_add_remote_sink(aconnector->dc_link,
+ NULL,
+ 0,
+ &init_params);
if (!dc_sink) {
DRM_ERROR("Unable to add a remote sink\n");
return 0;
@@ -397,15 +395,10 @@ 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 *)edid,
- (edid->extensions + 1) * EDID_LENGTH,
- &init_params);
+ dc_sink = dc_link_add_remote_sink(aconnector->dc_link,
+ aconnector->drm_edid, 0,
+ &init_params);
if (!dc_sink) {
DRM_ERROR("Unable to add a remote sink\n");
return 0;
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
index 493815829aa5..d89a82c349fa 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
@@ -6,25 +6,31 @@
bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
struct dc_sink *current_sink)
{
- struct dc_edid *old_edid = &prev_sink->dc_edid;
- struct dc_edid *new_edid = ¤t_sink->dc_edid;
-
- if (old_edid->length != new_edid->length)
- return false;
-
- if (new_edid->length == 0)
- return false;
-
- return (memcmp(old_edid->raw_edid,
- new_edid->raw_edid, new_edid->length) == 0);
+ return drm_edid_eq(prev_sink->drm_edid, current_sink->drm_edid);
}
void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
const void *edid,
int len)
{
- memmove(dc_sink->dc_edid.raw_edid, edid, len);
- dc_sink->dc_edid.length = len;
+ dc_sink->drm_edid = drm_edid_dup((const struct drm_edid *) edid);
+}
+
+void dc_edid_copy_edid_to_sink(struct dc_sink *sink)
+{
+ const struct edid *edid;
+
+ edid = drm_edid_raw(sink->drm_edid); // FIXME: Get rid of drm_edid_raw()
+ if (!edid ||
+ edid->extensions >= sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH) {
+ memset(sink->dc_edid.raw_edid, 0, sizeof(sink->dc_edid.raw_edid));
+ sink->dc_edid.length = 0;
+ return;
+ }
+
+ sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
+ memcpy(sink->dc_edid.raw_edid, (uint8_t *) edid,
+ sink->dc_edid.length);
}
void dc_edid_sink_edid_free(struct dc_sink *sink)
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
index 2c76768be459..a95cc6ccc743 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
@@ -9,6 +9,7 @@ bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
struct dc_sink *current_sink);
void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
const void *edid, int len);
+void dc_edid_copy_edid_to_sink(struct dc_sink *sink);
void dc_edid_sink_edid_free(struct dc_sink *sink);
#endif /* __DC_EDID_H__ */
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 0fcdf803b7a0..5df87d39903e 100644
--- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
+++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
@@ -1134,6 +1134,7 @@ static bool detect_link_and_local_sink(struct dc_link *link,
dp_trace_init(link);
/* Connectivity log: detection */
+ dc_edid_copy_edid_to_sink(sink);
for (i = 0; i < sink->dc_edid.length / DC_EDID_BLOCK_SIZE; i++) {
CONN_DATA_DETECT(link,
&sink->dc_edid.raw_edid[i * DC_EDID_BLOCK_SIZE],
@@ -1416,7 +1417,7 @@ struct dc_sink *link_add_remote_sink(
* parsing fails
*/
if (edid_status != EDID_OK && edid_status != EDID_PARTIAL_VALID) {
- dc_sink->dc_edid.length = 0;
+ dc_edid_sink_edid_free(dc_sink);
dm_error("Bad EDID, status%d!\n", edid_status);
}
--
2.47.2
^ permalink raw reply related [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
` (13 preceding siblings ...)
2025-07-26 0:33 ` [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid Melissa Wen
@ 2025-07-28 23:29 ` Alex Hung
2025-08-11 19:40 ` Melissa Wen
14 siblings, 1 reply; 25+ messages in thread
From: Alex Hung @ 2025-07-28 23:29 UTC (permalink / raw)
To: Melissa Wen, Mario Limonciello, Rodrigo Siqueira, airlied,
alexander.deucher, andrzej.hajda, christian.koenig,
harry.wentland, maarten.lankhorst, mripard, neil.armstrong, rfoss,
simona, sunpeng.li, tzimmermann
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Thanks. I will send v6 to promotion test.
On 7/25/25 18:33, Melissa Wen wrote:
> Hi,
>
> Siqueira and I have been working on a solution to reduce the usage of
> drm_edid_raw in the AMD display driver, since the current guideline in
> the DRM subsystem is to stop handling raw edid data in driver-specific
> implementation and use opaque `drm_edid` object with common-code
> helpers.
>
> To keep DC as an OS-agnostic component, we create a mid layer that
> isolates `drm_edid` helpers called in the DC code, while allowing other
> OSes to implement their specific implementation.
>
> This work is an extension of [1].
>
> - Patch 1 addresses a possible leak added by previous migration to
> drm_edid.
> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
> - Patches 3-7 use common-code, drm_edid helpers to parse edid
> capabilities instead of driver-specific solutions. For this, patch 4
> introduces a new helper that gets monitor name from drm_edid.
> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
> code in the DC shared code
> - Patch 10 creates a mid layer to make DC embraces different ways of
> handling EDID by platforms.
> - Patch 11 move open-coded management of raw EDID data to the mid
> layer created before.
> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
> free `drm_edid`.
> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
> the DC shared code is little affected by Linux specific stuff.
>
> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-mwen@igalia.com/
> Changes:
> - fix broken approach to get monitor name from eld (Jani)
> - I introduced a new helper that gets monitor name from drm_edid
> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
> - add NULL edid checks (Jani)
> - fix mishandling of product_id.manufacturer_name (Michel)
> - I directly set it to manufacturer_id since sparse didn't complain.
> - add Mario's r-b in the first fix patch and fix commit msg typo.
>
> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-mwen@igalia.com/
> Changes:
> - kernel-doc and commit msg fixes (Jani)
> - use drm_edid_legacy_init instead of open coded (Jani)
> - place drm_edid new func into the right section (Jani)
> - paramenter names fix (Jani)
> - add Jani's r-b to the patch 12
> - remove unnecessary include (Jani)
> - call dc_edid_sink_edid_free in link_detection, instead of drm_edid_free
> - rebase on top of asdn
>
> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-mwen@igalia.com/
> Changes:
> - rebase to asdn
> - some kernel-doc fixes
> - move some changes to the right commit
>
> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-mwen@igalia.com/
> Changes:
> - fix comments and commit messages (Mario)
> - remove unnecessary drm_edid dup and fix mem leak (Mario)
> - add Mario's rb to patches 5-7
>
> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-mwen@igalia.com/
> Changes:
> - fix NULL pointer dereference (Alex H.) with the same approach proposed
> by 7c3be3ce3dfae
>
> --->
> There are three specific points where we still use drm_edid_raw() in the
> driver:
> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
> drm_dp_dpcd_write(), that AFAIK there is no common code solution yet;
> 2. open-coded connectivity log for dc link detection, that maybe can be
> moved to drm (?);
> 3. open-coded parser that I suspect is a lot of duplicated code, but
> needs careful examining.
>
> I suggest to address those points in a next phase for regression control.
>
> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-mwen@igalia.com/
>
> Let me know yours thoughts!
>
> Melissa
>
> Melissa Wen (12):
> drm/amd/display: make sure drm_edid stored in aconnector doesn't leak
> drm/amd/display: start using drm_edid helpers to parse EDID caps
> drm/amd/display: use drm_edid_product_id for parsing EDID product info
> drm/edid: introduce a helper that gets monitor name from drm_edid
> drm/amd/display: get panel id with drm_edid helper
> 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: simplify dm_helpers_parse_edid_caps signature
> drm/amd/display: change DC functions to accept private types for edid
> drm/edid: introduce a helper that compares edid data from two drm_edid
> drm/amd/display: add drm_edid to dc_sink
> drm/amd/display: move dc_sink from dc_edid to drm_edid
>
> Rodrigo Siqueira (2):
> drm/amd/display: add a mid-layer file to handle EDID in DC
> drm/amd/display: create a function to fill dc_sink with edid data
>
> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 +++++++-----------
> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
> .../drm/amd/display/dc/link/link_detection.h | 9 +-
> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
> drivers/gpu/drm/drm_edid.c | 54 +++++++--
> include/drm/drm_edid.h | 10 +-
> 17 files changed, 199 insertions(+), 164 deletions(-)
> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-07-28 23:29 ` [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Alex Hung
@ 2025-08-11 19:40 ` Melissa Wen
2025-08-11 21:08 ` Alex Hung
0 siblings, 1 reply; 25+ messages in thread
From: Melissa Wen @ 2025-08-11 19:40 UTC (permalink / raw)
To: Alex Hung, Mario Limonciello, Rodrigo Siqueira, airlied,
alexander.deucher, andrzej.hajda, christian.koenig,
harry.wentland, maarten.lankhorst, mripard, neil.armstrong, rfoss,
simona, sunpeng.li, tzimmermann
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
On 28/07/2025 20:29, Alex Hung wrote:
> Thanks. I will send v6 to promotion test.
Hi Alex,
Any news about this round of tests?
BR,
Melissa
>
> On 7/25/25 18:33, Melissa Wen wrote:
>> Hi,
>>
>> Siqueira and I have been working on a solution to reduce the usage of
>> drm_edid_raw in the AMD display driver, since the current guideline in
>> the DRM subsystem is to stop handling raw edid data in driver-specific
>> implementation and use opaque `drm_edid` object with common-code
>> helpers.
>>
>> To keep DC as an OS-agnostic component, we create a mid layer that
>> isolates `drm_edid` helpers called in the DC code, while allowing other
>> OSes to implement their specific implementation.
>>
>> This work is an extension of [1].
>>
>> - Patch 1 addresses a possible leak added by previous migration to
>> drm_edid.
>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>> capabilities instead of driver-specific solutions. For this, patch 4
>> introduces a new helper that gets monitor name from drm_edid.
>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>> code in the DC shared code
>> - Patch 10 creates a mid layer to make DC embraces different ways of
>> handling EDID by platforms.
>> - Patch 11 move open-coded management of raw EDID data to the mid
>> layer created before.
>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>> free `drm_edid`.
>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>> the DC shared code is little affected by Linux specific stuff.
>>
>> [v1]
>> https://lore.kernel.org/dri-devel/20250411201333.151335-1-mwen@igalia.com/
>> Changes:
>> - fix broken approach to get monitor name from eld (Jani)
>> - I introduced a new helper that gets monitor name from drm_edid
>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>> - add NULL edid checks (Jani)
>> - fix mishandling of product_id.manufacturer_name (Michel)
>> - I directly set it to manufacturer_id since sparse didn't complain.
>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>
>> [v2]
>> https://lore.kernel.org/dri-devel/20250507001712.120215-1-mwen@igalia.com/
>> Changes:
>> - kernel-doc and commit msg fixes (Jani)
>> - use drm_edid_legacy_init instead of open coded (Jani)
>> - place drm_edid new func into the right section (Jani)
>> - paramenter names fix (Jani)
>> - add Jani's r-b to the patch 12
>> - remove unnecessary include (Jani)
>> - call dc_edid_sink_edid_free in link_detection, instead of
>> drm_edid_free
>> - rebase on top of asdn
>>
>> [v3]
>> https://lore.kernel.org/dri-devel/20250514202130.291324-1-mwen@igalia.com/
>> Changes:
>> - rebase to asdn
>> - some kernel-doc fixes
>> - move some changes to the right commit
>>
>> [v4]
>> https://lore.kernel.org/amd-gfx/20250613150015.245917-1-mwen@igalia.com/
>> Changes:
>> - fix comments and commit messages (Mario)
>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>> - add Mario's rb to patches 5-7
>>
>> [v5]
>> https://lore.kernel.org/amd-gfx/20250618152216.948406-1-mwen@igalia.com/
>> Changes:
>> - fix NULL pointer dereference (Alex H.) with the same approach proposed
>> by 7c3be3ce3dfae
>>
> > --->
>> There are three specific points where we still use drm_edid_raw() in the
>> driver:
>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>> yet;
>> 2. open-coded connectivity log for dc link detection, that maybe can be
>> moved to drm (?);
>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>> needs careful examining.
>>
>> I suggest to address those points in a next phase for regression
>> control.
>>
>> [1]
>> https://lore.kernel.org/amd-gfx/20250308142650.35920-1-mwen@igalia.com/
>>
>> Let me know yours thoughts!
>>
>> Melissa
>>
>> Melissa Wen (12):
>> drm/amd/display: make sure drm_edid stored in aconnector doesn't leak
>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>> info
>> drm/edid: introduce a helper that gets monitor name from drm_edid
>> drm/amd/display: get panel id with drm_edid helper
>> 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: simplify dm_helpers_parse_edid_caps signature
>> drm/amd/display: change DC functions to accept private types for edid
>> drm/edid: introduce a helper that compares edid data from two
>> drm_edid
>> drm/amd/display: add drm_edid to dc_sink
>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>
>> Rodrigo Siqueira (2):
>> drm/amd/display: add a mid-layer file to handle EDID in DC
>> drm/amd/display: create a function to fill dc_sink with edid data
>>
>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 +++++++-----------
>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>> include/drm/drm_edid.h | 10 +-
>> 17 files changed, 199 insertions(+), 164 deletions(-)
>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 19:40 ` Melissa Wen
@ 2025-08-11 21:08 ` Alex Hung
2025-08-11 21:09 ` Limonciello, Mario
0 siblings, 1 reply; 25+ messages in thread
From: Alex Hung @ 2025-08-11 21:08 UTC (permalink / raw)
To: Melissa Wen, Mario Limonciello, Rodrigo Siqueira, airlied,
alexander.deucher, andrzej.hajda, christian.koenig,
harry.wentland, maarten.lankhorst, mripard, neil.armstrong, rfoss,
simona, sunpeng.li, tzimmermann
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
Melissa,
The patchset passed promotion and CI.
However, since our DC code is shared with the other OS, calling drm_*
functions in DC won't work for us. For example, calling
dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
I don't have a good way to handle it. Does it make sense not to touch DC
code for now?
On 8/11/25 13:40, Melissa Wen wrote:
>
>
> On 28/07/2025 20:29, Alex Hung wrote:
>> Thanks. I will send v6 to promotion test.
> Hi Alex,
>
> Any news about this round of tests?
>
> BR,
>
> Melissa
>
>>
>> On 7/25/25 18:33, Melissa Wen wrote:
>>> Hi,
>>>
>>> Siqueira and I have been working on a solution to reduce the usage of
>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>> implementation and use opaque `drm_edid` object with common-code
>>> helpers.
>>>
>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>> OSes to implement their specific implementation.
>>>
>>> This work is an extension of [1].
>>>
>>> - Patch 1 addresses a possible leak added by previous migration to
>>> drm_edid.
>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>> capabilities instead of driver-specific solutions. For this, patch 4
>>> introduces a new helper that gets monitor name from drm_edid.
>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>> code in the DC shared code
>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>> handling EDID by platforms.
>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>> layer created before.
>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>> free `drm_edid`.
>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>> the DC shared code is little affected by Linux specific stuff.
>>>
>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>> mwen@igalia.com/
>>> Changes:
>>> - fix broken approach to get monitor name from eld (Jani)
>>> - I introduced a new helper that gets monitor name from drm_edid
>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>> - add NULL edid checks (Jani)
>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>
>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>> mwen@igalia.com/
>>> Changes:
>>> - kernel-doc and commit msg fixes (Jani)
>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>> - place drm_edid new func into the right section (Jani)
>>> - paramenter names fix (Jani)
>>> - add Jani's r-b to the patch 12
>>> - remove unnecessary include (Jani)
>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>> drm_edid_free
>>> - rebase on top of asdn
>>>
>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>> mwen@igalia.com/
>>> Changes:
>>> - rebase to asdn
>>> - some kernel-doc fixes
>>> - move some changes to the right commit
>>>
>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>> mwen@igalia.com/
>>> Changes:
>>> - fix comments and commit messages (Mario)
>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>> - add Mario's rb to patches 5-7
>>>
>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>> mwen@igalia.com/
>>> Changes:
>>> - fix NULL pointer dereference (Alex H.) with the same approach proposed
>>> by 7c3be3ce3dfae
>>>
>> > --->
>>> There are three specific points where we still use drm_edid_raw() in the
>>> driver:
>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>> yet;
>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>> moved to drm (?);
>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>> needs careful examining.
>>>
>>> I suggest to address those points in a next phase for regression
>>> control.
>>>
>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>> mwen@igalia.com/
>>>
>>> Let me know yours thoughts!
>>>
>>> Melissa
>>>
>>> Melissa Wen (12):
>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't leak
>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>> info
>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>> drm/amd/display: get panel id with drm_edid helper
>>> 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: simplify dm_helpers_parse_edid_caps signature
>>> drm/amd/display: change DC functions to accept private types for edid
>>> drm/edid: introduce a helper that compares edid data from two
>>> drm_edid
>>> drm/amd/display: add drm_edid to dc_sink
>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>
>>> Rodrigo Siqueira (2):
>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>
>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 +++++++-----------
>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>> include/drm/drm_edid.h | 10 +-
>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 21:08 ` Alex Hung
@ 2025-08-11 21:09 ` Limonciello, Mario
2025-08-11 21:26 ` Harry Wentland
0 siblings, 1 reply; 25+ messages in thread
From: Limonciello, Mario @ 2025-08-11 21:09 UTC (permalink / raw)
To: Hung, Alex, Melissa Wen, Rodrigo Siqueira, airlied@gmail.com,
Deucher, Alexander, andrzej.hajda@intel.com, Koenig, Christian,
Wentland, Harry, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, neil.armstrong@linaro.org, rfoss@kernel.org,
simona@ffwll.ch, Li, Sun peng (Leo), tzimmermann@suse.de
Cc: Michel Daenzer, Jani Nikula, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com
On 8/11/25 4:08 PM, Hung, Alex wrote:
> Melissa,
>
> The patchset passed promotion and CI.
>
> However, since our DC code is shared with the other OS, calling drm_*
> functions in DC won't work for us. For example, calling
> dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
>
> I don't have a good way to handle it. Does it make sense not to touch DC
> code for now?
What about if we have a set of compatibility macros in DC code?
Something like this:
#ifndef drm_dbg
#define drm_dbg ....
#endif
>
> On 8/11/25 13:40, Melissa Wen wrote:
>>
>>
>> On 28/07/2025 20:29, Alex Hung wrote:
>>> Thanks. I will send v6 to promotion test.
>> Hi Alex,
>>
>> Any news about this round of tests?
>>
>> BR,
>>
>> Melissa
>>
>>>
>>> On 7/25/25 18:33, Melissa Wen wrote:
>>>> Hi,
>>>>
>>>> Siqueira and I have been working on a solution to reduce the usage of
>>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>>> implementation and use opaque `drm_edid` object with common-code
>>>> helpers.
>>>>
>>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>>> OSes to implement their specific implementation.
>>>>
>>>> This work is an extension of [1].
>>>>
>>>> - Patch 1 addresses a possible leak added by previous migration to
>>>> drm_edid.
>>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>>> capabilities instead of driver-specific solutions. For this, patch 4
>>>> introduces a new helper that gets monitor name from drm_edid.
>>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>>> code in the DC shared code
>>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>>> handling EDID by platforms.
>>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>>> layer created before.
>>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>>> free `drm_edid`.
>>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>>> the DC shared code is little affected by Linux specific stuff.
>>>>
>>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>>> mwen@igalia.com/
>>>> Changes:
>>>> - fix broken approach to get monitor name from eld (Jani)
>>>> - I introduced a new helper that gets monitor name from drm_edid
>>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>>> - add NULL edid checks (Jani)
>>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>>
>>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>>> mwen@igalia.com/
>>>> Changes:
>>>> - kernel-doc and commit msg fixes (Jani)
>>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>>> - place drm_edid new func into the right section (Jani)
>>>> - paramenter names fix (Jani)
>>>> - add Jani's r-b to the patch 12
>>>> - remove unnecessary include (Jani)
>>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>>> drm_edid_free
>>>> - rebase on top of asdn
>>>>
>>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>>> mwen@igalia.com/
>>>> Changes:
>>>> - rebase to asdn
>>>> - some kernel-doc fixes
>>>> - move some changes to the right commit
>>>>
>>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>>> mwen@igalia.com/
>>>> Changes:
>>>> - fix comments and commit messages (Mario)
>>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>>> - add Mario's rb to patches 5-7
>>>>
>>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>>> mwen@igalia.com/
>>>> Changes:
>>>> - fix NULL pointer dereference (Alex H.) with the same approach
>>>> proposed
>>>> by 7c3be3ce3dfae
>>>>
>>> > --->
>>>> There are three specific points where we still use drm_edid_raw() in
>>>> the
>>>> driver:
>>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>>> yet;
>>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>>> moved to drm (?);
>>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>>> needs careful examining.
>>>>
>>>> I suggest to address those points in a next phase for regression
>>>> control.
>>>>
>>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>>> mwen@igalia.com/
>>>>
>>>> Let me know yours thoughts!
>>>>
>>>> Melissa
>>>>
>>>> Melissa Wen (12):
>>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't
>>>> leak
>>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>>> info
>>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>>> drm/amd/display: get panel id with drm_edid helper
>>>> 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: simplify dm_helpers_parse_edid_caps signature
>>>> drm/amd/display: change DC functions to accept private types for
>>>> edid
>>>> drm/edid: introduce a helper that compares edid data from two
>>>> drm_edid
>>>> drm/amd/display: add drm_edid to dc_sink
>>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>>
>>>> Rodrigo Siqueira (2):
>>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>>
>>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 ++++++
>>>> +-----------
>>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>>> include/drm/drm_edid.h | 10 +-
>>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 21:09 ` Limonciello, Mario
@ 2025-08-11 21:26 ` Harry Wentland
2025-08-11 21:47 ` Melissa Wen
2025-08-12 19:30 ` Limonciello, Mario
0 siblings, 2 replies; 25+ messages in thread
From: Harry Wentland @ 2025-08-11 21:26 UTC (permalink / raw)
To: Limonciello, Mario, Hung, Alex, Melissa Wen, Rodrigo Siqueira,
airlied@gmail.com, Deucher, Alexander, andrzej.hajda@intel.com,
Koenig, Christian, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, neil.armstrong@linaro.org, rfoss@kernel.org,
simona@ffwll.ch, Li, Sun peng (Leo), tzimmermann@suse.de
Cc: Michel Daenzer, Jani Nikula, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com
On 2025-08-11 17:09, Limonciello, Mario wrote:
> On 8/11/25 4:08 PM, Hung, Alex wrote:
>> Melissa,
>>
>> The patchset passed promotion and CI.
>>
>> However, since our DC code is shared with the other OS, calling drm_*
>> functions in DC won't work for us. For example, calling
>> dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
>>
>> I don't have a good way to handle it. Does it make sense not to touch DC
>> code for now?
>
> What about if we have a set of compatibility macros in DC code?
>
> Something like this:
>
> #ifndef drm_dbg
> #define drm_dbg ....
> #endif
DC should stay OS-agnostic. No DRM concepts in DC please.
Why the need to change dc_edid_is_same_edid?
I'll comment directly on the patch.
Harry
>>
>> On 8/11/25 13:40, Melissa Wen wrote:
>>>
>>>
>>> On 28/07/2025 20:29, Alex Hung wrote:
>>>> Thanks. I will send v6 to promotion test.
>>> Hi Alex,
>>>
>>> Any news about this round of tests?
>>>
>>> BR,
>>>
>>> Melissa
>>>
>>>>
>>>> On 7/25/25 18:33, Melissa Wen wrote:
>>>>> Hi,
>>>>>
>>>>> Siqueira and I have been working on a solution to reduce the usage of
>>>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>>>> implementation and use opaque `drm_edid` object with common-code
>>>>> helpers.
>>>>>
>>>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>>>> OSes to implement their specific implementation.
>>>>>
>>>>> This work is an extension of [1].
>>>>>
>>>>> - Patch 1 addresses a possible leak added by previous migration to
>>>>> drm_edid.
>>>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>>>> capabilities instead of driver-specific solutions. For this, patch 4
>>>>> introduces a new helper that gets monitor name from drm_edid.
>>>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>>>> code in the DC shared code
>>>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>>>> handling EDID by platforms.
>>>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>>>> layer created before.
>>>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>>>> free `drm_edid`.
>>>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>>>> the DC shared code is little affected by Linux specific stuff.
>>>>>
>>>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>>>> mwen@igalia.com/
>>>>> Changes:
>>>>> - fix broken approach to get monitor name from eld (Jani)
>>>>> - I introduced a new helper that gets monitor name from drm_edid
>>>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>>>> - add NULL edid checks (Jani)
>>>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>>>
>>>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>>>> mwen@igalia.com/
>>>>> Changes:
>>>>> - kernel-doc and commit msg fixes (Jani)
>>>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>>>> - place drm_edid new func into the right section (Jani)
>>>>> - paramenter names fix (Jani)
>>>>> - add Jani's r-b to the patch 12
>>>>> - remove unnecessary include (Jani)
>>>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>>>> drm_edid_free
>>>>> - rebase on top of asdn
>>>>>
>>>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>>>> mwen@igalia.com/
>>>>> Changes:
>>>>> - rebase to asdn
>>>>> - some kernel-doc fixes
>>>>> - move some changes to the right commit
>>>>>
>>>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>>>> mwen@igalia.com/
>>>>> Changes:
>>>>> - fix comments and commit messages (Mario)
>>>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>>>> - add Mario's rb to patches 5-7
>>>>>
>>>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>>>> mwen@igalia.com/
>>>>> Changes:
>>>>> - fix NULL pointer dereference (Alex H.) with the same approach
>>>>> proposed
>>>>> by 7c3be3ce3dfae
>>>>>
>>>>> --->
>>>>> There are three specific points where we still use drm_edid_raw() in
>>>>> the
>>>>> driver:
>>>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>>>> yet;
>>>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>>>> moved to drm (?);
>>>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>>>> needs careful examining.
>>>>>
>>>>> I suggest to address those points in a next phase for regression
>>>>> control.
>>>>>
>>>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>>>> mwen@igalia.com/
>>>>>
>>>>> Let me know yours thoughts!
>>>>>
>>>>> Melissa
>>>>>
>>>>> Melissa Wen (12):
>>>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't
>>>>> leak
>>>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>>>> info
>>>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>>>> drm/amd/display: get panel id with drm_edid helper
>>>>> 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: simplify dm_helpers_parse_edid_caps signature
>>>>> drm/amd/display: change DC functions to accept private types for
>>>>> edid
>>>>> drm/edid: introduce a helper that compares edid data from two
>>>>> drm_edid
>>>>> drm/amd/display: add drm_edid to dc_sink
>>>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>>>
>>>>> Rodrigo Siqueira (2):
>>>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>>>
>>>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 ++++++
>>>>> +-----------
>>>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>>>> include/drm/drm_edid.h | 10 +-
>>>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>>>
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink
2025-07-26 0:33 ` [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink Melissa Wen
@ 2025-08-11 21:27 ` Harry Wentland
0 siblings, 0 replies; 25+ messages in thread
From: Harry Wentland @ 2025-08-11 21:27 UTC (permalink / raw)
To: Melissa Wen, Mario Limonciello, Alex Hung, Rodrigo Siqueira,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
On 2025-07-25 20:33, Melissa Wen wrote:
> Add Linux opaque object to dc_sink for storing EDID data cross driver,
> drm_edid. Also include the Linux call to free this object, the
> drm_edid_free()
>
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> ---
> drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 6 ++++++
> drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 1 +
> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +++
> drivers/gpu/drm/amd/display/dc/dc.h | 1 +
> 4 files changed, 11 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> index b4ccc111fa08..493815829aa5 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> @@ -1,6 +1,7 @@
> // SPDX-License-Identifier: MIT
> #include "dc.h"
> #include "dc_edid.h"
> +#include <drm/drm_edid.h>
>
> bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
> struct dc_sink *current_sink)
> @@ -25,3 +26,8 @@ void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
> memmove(dc_sink->dc_edid.raw_edid, edid, len);
> dc_sink->dc_edid.length = len;
> }
> +
> +void dc_edid_sink_edid_free(struct dc_sink *sink)
> +{
> + drm_edid_free(sink->drm_edid);
> +}
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> index f42cd5bbc730..2c76768be459 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> @@ -9,5 +9,6 @@ bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
> struct dc_sink *current_sink);
> void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
> const void *edid, int len);
> +void dc_edid_sink_edid_free(struct dc_sink *sink);
>
> #endif /* __DC_EDID_H__ */
> diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> index 455fa5dd1420..3774a3245506 100644
> --- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> +++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c
> @@ -26,6 +26,7 @@
> #include "dm_services.h"
> #include "dm_helpers.h"
> #include "core_types.h"
> +#include "dc_edid.h"
>
> /*******************************************************************************
> * Private functions
> @@ -65,6 +66,8 @@ void dc_sink_retain(struct dc_sink *sink)
> static void dc_sink_free(struct kref *kref)
> {
> struct dc_sink *sink = container_of(kref, struct dc_sink, refcount);
> +
> + dc_edid_sink_edid_free(sink);
> kfree(sink->dc_container_id);
> kfree(sink);
> }
> diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h
> index 233d73f9f19f..215d3901480a 100644
> --- a/drivers/gpu/drm/amd/display/dc/dc.h
> +++ b/drivers/gpu/drm/amd/display/dc/dc.h
> @@ -2493,6 +2493,7 @@ struct scdc_caps {
> struct dc_sink {
> enum signal_type sink_signal;
> struct dc_edid dc_edid; /* raw edid */
> + const struct drm_edid *drm_edid; /* Linux DRM EDID */
DC is OS agnostic code and shouldn't deal with DRM
structs. amdgpu_dm is the one to deal with that.
Harry
> struct dc_edid_caps edid_caps; /* parse display caps */
> struct dc_container_id *dc_container_id;
> uint32_t dongle_max_pix_clk;
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid
2025-07-26 0:33 ` [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid Melissa Wen
@ 2025-08-11 21:29 ` Harry Wentland
0 siblings, 0 replies; 25+ messages in thread
From: Harry Wentland @ 2025-08-11 21:29 UTC (permalink / raw)
To: Melissa Wen, Mario Limonciello, Alex Hung, Rodrigo Siqueira,
sunpeng.li, alexander.deucher, christian.koenig, airlied, simona
Cc: Michel Daenzer, Jani Nikula, dri-devel, amd-gfx, kernel-dev
On 2025-07-25 20:33, Melissa Wen wrote:
> Reduce direct handling of edid data by resorting to drm helpers that
> deal with this info inside drm_edid infrastructure.
>
> v3:
> - use dc_edid_sink_edid_free in link_detection
>
> v5:
> - no need of drm_edid duplication (Mario)
> - fix mem leak on dc_sink->drm_edid
>
> v6:
> - fix NULL pointer dereference (Alex H)
>
> Signed-off-by: Melissa Wen <mwen@igalia.com>
> ---
> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 26 ++++++---------
> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 31 ++++++------------
> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++++--------
> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 32 +++++++++++--------
> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 1 +
> .../drm/amd/display/dc/link/link_detection.c | 3 +-
> 6 files changed, 48 insertions(+), 66 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 878269c2092c..1aa0ccf74580 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
> @@ -68,6 +68,7 @@
> #endif
> #include "amdgpu_dm_psr.h"
> #include "amdgpu_dm_replay.h"
> +#include "dc_edid.h"
>
> #include "ivsrcid/ivsrcid_vislands30.h"
>
> @@ -3743,6 +3744,8 @@ void amdgpu_dm_update_connector_after_detect(
> * 2. Send an event and let userspace tell us what to do
> */
> if (sink) {
> + const struct drm_edid *drm_edid = sink->drm_edid;
> +
> /*
> * TODO: check if we still need the S3 mode update workaround.
> * If yes, put it here.
> @@ -3754,16 +3757,15 @@ void amdgpu_dm_update_connector_after_detect(
>
> aconnector->dc_sink = sink;
> dc_sink_retain(aconnector->dc_sink);
> - if (sink->dc_edid.length == 0) {
> +
> + if (!drm_edid_valid(drm_edid)) {
> aconnector->drm_edid = NULL;
> hdmi_cec_unset_edid(aconnector);
> if (aconnector->dc_link->aux_mode) {
> drm_dp_cec_unset_edid(&aconnector->dm_dp_aux.aux);
> }
> } else {
> - const struct edid *edid = (const struct edid *)sink->dc_edid.raw_edid;
> -
> - aconnector->drm_edid = drm_edid_alloc(edid, sink->dc_edid.length);
> + aconnector->drm_edid = drm_edid_dup(sink->drm_edid);
> drm_edid_connector_update(connector, aconnector->drm_edid);
>
> hdmi_cec_set_edid(aconnector);
> @@ -7434,12 +7436,8 @@ static void amdgpu_dm_connector_funcs_force(struct drm_connector *connector)
> 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);
> + dc_edid_copy_edid_to_dc(dc_em_sink, drm_edid, 0);
> dm_helpers_parse_edid_caps(dc_link, dc_em_sink);
> }
> }
> @@ -7472,7 +7470,6 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
> .sink_signal = SIGNAL_TYPE_VIRTUAL
> };
> const struct drm_edid *drm_edid;
> - const struct edid *edid;
> struct i2c_adapter *ddc;
>
> if (dc_link && dc_link->aux_mode)
> @@ -7492,12 +7489,9 @@ static void create_eml_sink(struct amdgpu_dm_connector *aconnector)
>
> 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,
> - (edid->extensions + 1) * EDID_LENGTH,
> - &init_params);
> + aconnector->dc_em_sink = dc_link_add_remote_sink(aconnector->dc_link,
> + drm_edid, 0,
> + &init_params);
>
> if (aconnector->base.force == DRM_FORCE_ON) {
> aconnector->dc_sink = aconnector->dc_link->local_sink ?
> 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 d4d60d62964c..288e87f92f9e 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
> @@ -48,6 +48,7 @@
> #include "dm_helpers.h"
> #include "ddc_service_types.h"
> #include "clk_mgr.h"
> +#include "dc_edid.h"
>
> static void apply_edid_quirks(struct drm_device *dev,
> const struct drm_edid *drm_edid,
> @@ -100,20 +101,16 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
> struct amdgpu_dm_connector *aconnector = link->priv;
> struct drm_connector *connector = &aconnector->base;
> struct drm_device *dev = connector->dev;
> - struct edid *edid_buf;
> - const struct drm_edid *drm_edid;
> + const struct drm_edid *drm_edid = sink->drm_edid;
> struct drm_edid_product_id product_id;
> struct dc_edid_caps *edid_caps = &sink->edid_caps;
> int sad_count;
> int i = 0;
> enum dc_edid_status result = EDID_OK;
>
> - edid_buf = (struct edid *) &sink->dc_edid.raw_edid;
> - if (!edid_caps || !edid_buf)
> + if (!edid_caps || !drm_edid)
> return EDID_BAD_INPUT;
>
> - drm_edid = drm_edid_alloc(edid_buf, EDID_LENGTH * (edid_buf->extensions + 1));
> -
> if (!drm_edid_valid(drm_edid))
> result = EDID_BAD_CHECKSUM;
>
> @@ -135,10 +132,8 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
> apply_edid_quirks(dev, drm_edid, edid_caps);
>
> sad_count = drm_eld_sad_count(connector->eld);
> - if (sad_count <= 0) {
> - drm_edid_free(drm_edid);
> + 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) {
> @@ -158,8 +153,6 @@ enum dc_edid_status dm_helpers_parse_edid_caps(struct dc_link *link,
> else
> edid_caps->speaker_flags = DEFAULT_SPEAKER_LOCATION;
>
> - drm_edid_free(drm_edid);
> -
> return result;
> }
>
> @@ -991,7 +984,6 @@ enum dc_edid_status dm_helpers_read_local_edid(
> int retry = 3;
> enum dc_edid_status edid_status;
> const struct drm_edid *drm_edid;
> - const struct edid *edid;
>
> if (link->aux_mode)
> ddc = &aconnector->dm_dp_aux.aux.ddc;
> @@ -1002,6 +994,8 @@ enum dc_edid_status dm_helpers_read_local_edid(
> * do check sum and retry to make sure read correct edid.
> */
> do {
> + drm_edid_free(sink->drm_edid);
> +
> drm_edid = dm_helpers_read_acpi_edid(aconnector);
> if (drm_edid)
> drm_info(connector->dev, "Using ACPI provided EDID for %s\n", connector->name);
> @@ -1021,16 +1015,7 @@ 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()
> - if (!edid ||
> - edid->extensions >= sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH)
> - return EDID_BAD_INPUT;
> -
> - 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);
> + sink->drm_edid = drm_edid;
>
> edid_status = dm_helpers_parse_edid_caps(link, sink);
>
> @@ -1055,6 +1040,8 @@ enum dc_edid_status dm_helpers_read_local_edid(
>
> test_response.bits.EDID_CHECKSUM_WRITE = 1;
>
> + // TODO: drm_edid doesn't have a helper for dp_write_dpcd yet
> + dc_edid_copy_edid_to_sink(sink);
> dm_helpers_dp_write_dpcd(ctx,
> link,
> DP_TEST_EDID_CHECKSUM,
> 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 7187d5aedf0a..5ca3e668c8aa 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
> @@ -359,12 +359,10 @@ static int dm_dp_mst_get_modes(struct drm_connector *connector)
> .link = aconnector->dc_link,
> .sink_signal = SIGNAL_TYPE_DISPLAY_PORT_MST };
>
> - dc_sink = dc_link_add_remote_sink(
> - aconnector->dc_link,
> - NULL,
> - 0,
> - &init_params);
> -
> + dc_sink = dc_link_add_remote_sink(aconnector->dc_link,
> + NULL,
> + 0,
> + &init_params);
> if (!dc_sink) {
> DRM_ERROR("Unable to add a remote sink\n");
> return 0;
> @@ -397,15 +395,10 @@ 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 *)edid,
> - (edid->extensions + 1) * EDID_LENGTH,
> - &init_params);
>
> + dc_sink = dc_link_add_remote_sink(aconnector->dc_link,
> + aconnector->drm_edid, 0,
> + &init_params);
> if (!dc_sink) {
> DRM_ERROR("Unable to add a remote sink\n");
> return 0;
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> index 493815829aa5..d89a82c349fa 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
> @@ -6,25 +6,31 @@
> bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
> struct dc_sink *current_sink)
> {
> - struct dc_edid *old_edid = &prev_sink->dc_edid;
> - struct dc_edid *new_edid = ¤t_sink->dc_edid;
> -
> - if (old_edid->length != new_edid->length)
> - return false;
> -
> - if (new_edid->length == 0)
> - return false;
> -
> - return (memcmp(old_edid->raw_edid,
> - new_edid->raw_edid, new_edid->length) == 0);
> + return drm_edid_eq(prev_sink->drm_edid, current_sink->drm_edid);
DC is OS agnostic. There is no drm_ on other OSes.
> }
>
> void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
> const void *edid,
> int len)
> {
> - memmove(dc_sink->dc_edid.raw_edid, edid, len);
> - dc_sink->dc_edid.length = len;
> + dc_sink->drm_edid = drm_edid_dup((const struct drm_edid *) edid);
Same here.
> +}
> +
> +void dc_edid_copy_edid_to_sink(struct dc_sink *sink)
> +{
> + const struct edid *edid;
> +
> + edid = drm_edid_raw(sink->drm_edid); // FIXME: Get rid of drm_edid_raw()
And here.
Harry
> + if (!edid ||
> + edid->extensions >= sizeof(sink->dc_edid.raw_edid) / EDID_LENGTH) {
> + memset(sink->dc_edid.raw_edid, 0, sizeof(sink->dc_edid.raw_edid));
> + sink->dc_edid.length = 0;
> + return;
> + }
> +
> + sink->dc_edid.length = EDID_LENGTH * (edid->extensions + 1);
> + memcpy(sink->dc_edid.raw_edid, (uint8_t *) edid,
> + sink->dc_edid.length);
> }
>
> void dc_edid_sink_edid_free(struct dc_sink *sink)
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> index 2c76768be459..a95cc6ccc743 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
> @@ -9,6 +9,7 @@ bool dc_edid_is_same_edid(struct dc_sink *prev_sink,
> struct dc_sink *current_sink);
> void dc_edid_copy_edid_to_dc(struct dc_sink *dc_sink,
> const void *edid, int len);
> +void dc_edid_copy_edid_to_sink(struct dc_sink *sink);
> void dc_edid_sink_edid_free(struct dc_sink *sink);
>
> #endif /* __DC_EDID_H__ */
> 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 0fcdf803b7a0..5df87d39903e 100644
> --- a/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> +++ b/drivers/gpu/drm/amd/display/dc/link/link_detection.c
> @@ -1134,6 +1134,7 @@ static bool detect_link_and_local_sink(struct dc_link *link,
> dp_trace_init(link);
>
> /* Connectivity log: detection */
> + dc_edid_copy_edid_to_sink(sink);
> for (i = 0; i < sink->dc_edid.length / DC_EDID_BLOCK_SIZE; i++) {
> CONN_DATA_DETECT(link,
> &sink->dc_edid.raw_edid[i * DC_EDID_BLOCK_SIZE],
> @@ -1416,7 +1417,7 @@ struct dc_sink *link_add_remote_sink(
> * parsing fails
> */
> if (edid_status != EDID_OK && edid_status != EDID_PARTIAL_VALID) {
> - dc_sink->dc_edid.length = 0;
> + dc_edid_sink_edid_free(dc_sink);
> dm_error("Bad EDID, status%d!\n", edid_status);
> }
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 21:26 ` Harry Wentland
@ 2025-08-11 21:47 ` Melissa Wen
2025-08-12 20:39 ` Harry Wentland
2025-08-12 19:30 ` Limonciello, Mario
1 sibling, 1 reply; 25+ messages in thread
From: Melissa Wen @ 2025-08-11 21:47 UTC (permalink / raw)
To: Harry Wentland, Limonciello, Mario, Hung, Alex, Rodrigo Siqueira,
airlied@gmail.com, Deucher, Alexander, andrzej.hajda@intel.com,
Koenig, Christian, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, neil.armstrong@linaro.org, rfoss@kernel.org,
simona@ffwll.ch, Li, Sun peng (Leo), tzimmermann@suse.de
Cc: Michel Daenzer, Jani Nikula, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com
On 11/08/2025 18:26, Harry Wentland wrote:
>
> On 2025-08-11 17:09, Limonciello, Mario wrote:
>> On 8/11/25 4:08 PM, Hung, Alex wrote:
>>> Melissa,
>>>
>>> The patchset passed promotion and CI.
>>>
>>> However, since our DC code is shared with the other OS, calling drm_*
>>> functions in DC won't work for us. For example, calling
>>> dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
>>>
>>> I don't have a good way to handle it. Does it make sense not to touch DC
>>> code for now?
>> What about if we have a set of compatibility macros in DC code?
>>
>> Something like this:
>>
>> #ifndef drm_dbg
>> #define drm_dbg ....
>> #endif
> DC should stay OS-agnostic. No DRM concepts in DC please.
Yes, and that is exactly the reason for "[PATCH v6 10/14]
drm/amd/display: add a mid-layer file to handle EDID in DC"
(https://lore.kernel.org/amd-gfx/20250726003816.435227-11-mwen@igalia.com/).
DC code still handles raw EDID data and drivers handling raw EDID is
exactly what we are trying to remove from DRM. But with the current
implementation of the AMD driver, we cannot remove it without touching
DC code. The thing is, if we stop handle raw EDID in the DM layer, we
cannot pass this data to DC and vice-versa.
So the proposal with patch 10 (and follow-up patches) is creating
different dc_edid files, one for linux and another for different platforms.
>
> Why the need to change dc_edid_is_same_edid?
The linux file is done in this series by reimplementing the DC functions
that handles raw EDID, like dc_edid_is_same_edid, with drm_edid helpers.
The file for other platforms can be the original functions without these
changes.
In fact, there is a step that should be done by AMD people because we
don't handle other platforms. It should be somewhat similar to the DC
FPU isolation code.
If it's not possible for any reasons, could you share with us some
suggestions on how to address this issue?
Thanks in advance,
Melissa
>
> I'll comment directly on the patch.
>
> Harry
>
>>> On 8/11/25 13:40, Melissa Wen wrote:
>>>>
>>>> On 28/07/2025 20:29, Alex Hung wrote:
>>>>> Thanks. I will send v6 to promotion test.
>>>> Hi Alex,
>>>>
>>>> Any news about this round of tests?
>>>>
>>>> BR,
>>>>
>>>> Melissa
>>>>
>>>>> On 7/25/25 18:33, Melissa Wen wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Siqueira and I have been working on a solution to reduce the usage of
>>>>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>>>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>>>>> implementation and use opaque `drm_edid` object with common-code
>>>>>> helpers.
>>>>>>
>>>>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>>>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>>>>> OSes to implement their specific implementation.
>>>>>>
>>>>>> This work is an extension of [1].
>>>>>>
>>>>>> - Patch 1 addresses a possible leak added by previous migration to
>>>>>> drm_edid.
>>>>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>>>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>>>>> capabilities instead of driver-specific solutions. For this, patch 4
>>>>>> introduces a new helper that gets monitor name from drm_edid.
>>>>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>>>>> code in the DC shared code
>>>>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>>>>> handling EDID by platforms.
>>>>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>>>>> layer created before.
>>>>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>>>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>>>>> free `drm_edid`.
>>>>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>>>>> the DC shared code is little affected by Linux specific stuff.
>>>>>>
>>>>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix broken approach to get monitor name from eld (Jani)
>>>>>> - I introduced a new helper that gets monitor name from drm_edid
>>>>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>>>>> - add NULL edid checks (Jani)
>>>>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>>>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>>>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>>>>
>>>>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - kernel-doc and commit msg fixes (Jani)
>>>>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>>>>> - place drm_edid new func into the right section (Jani)
>>>>>> - paramenter names fix (Jani)
>>>>>> - add Jani's r-b to the patch 12
>>>>>> - remove unnecessary include (Jani)
>>>>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>>>>> drm_edid_free
>>>>>> - rebase on top of asdn
>>>>>>
>>>>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - rebase to asdn
>>>>>> - some kernel-doc fixes
>>>>>> - move some changes to the right commit
>>>>>>
>>>>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix comments and commit messages (Mario)
>>>>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>>>>> - add Mario's rb to patches 5-7
>>>>>>
>>>>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix NULL pointer dereference (Alex H.) with the same approach
>>>>>> proposed
>>>>>> by 7c3be3ce3dfae
>>>>>>
>>>>>> --->
>>>>>> There are three specific points where we still use drm_edid_raw() in
>>>>>> the
>>>>>> driver:
>>>>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>>>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>>>>> yet;
>>>>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>>>>> moved to drm (?);
>>>>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>>>>> needs careful examining.
>>>>>>
>>>>>> I suggest to address those points in a next phase for regression
>>>>>> control.
>>>>>>
>>>>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>>>>> mwen@igalia.com/
>>>>>>
>>>>>> Let me know yours thoughts!
>>>>>>
>>>>>> Melissa
>>>>>>
>>>>>> Melissa Wen (12):
>>>>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't
>>>>>> leak
>>>>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>>>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>>>>> info
>>>>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>>>>> drm/amd/display: get panel id with drm_edid helper
>>>>>> 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: simplify dm_helpers_parse_edid_caps signature
>>>>>> drm/amd/display: change DC functions to accept private types for
>>>>>> edid
>>>>>> drm/edid: introduce a helper that compares edid data from two
>>>>>> drm_edid
>>>>>> drm/amd/display: add drm_edid to dc_sink
>>>>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>>>>
>>>>>> Rodrigo Siqueira (2):
>>>>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>>>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>>>>
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>>>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 ++++++
>>>>>> +-----------
>>>>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>>>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>>>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>>>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>>>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>>>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>>>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>>>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>>>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>>>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>>>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>>>>> include/drm/drm_edid.h | 10 +-
>>>>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>>>>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 21:26 ` Harry Wentland
2025-08-11 21:47 ` Melissa Wen
@ 2025-08-12 19:30 ` Limonciello, Mario
1 sibling, 0 replies; 25+ messages in thread
From: Limonciello, Mario @ 2025-08-12 19:30 UTC (permalink / raw)
To: Wentland, Harry, Hung, Alex, Melissa Wen, Rodrigo Siqueira,
airlied@gmail.com, Deucher, Alexander, andrzej.hajda@intel.com,
Koenig, Christian, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, neil.armstrong@linaro.org, rfoss@kernel.org,
simona@ffwll.ch, Li, Sun peng (Leo), tzimmermann@suse.de
Cc: Michel Daenzer, Jani Nikula, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com
On 8/11/25 4:26 PM, Wentland, Harry wrote:
>
>
> On 2025-08-11 17:09, Limonciello, Mario wrote:
>> On 8/11/25 4:08 PM, Hung, Alex wrote:
>>> Melissa,
>>>
>>> The patchset passed promotion and CI.
>>>
>>> However, since our DC code is shared with the other OS, calling drm_*
>>> functions in DC won't work for us. For example, calling
>>> dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
>>>
>>> I don't have a good way to handle it. Does it make sense not to touch DC
>>> code for now?
>>
>> What about if we have a set of compatibility macros in DC code?
>>
>> Something like this:
>>
>> #ifndef drm_dbg
>> #define drm_dbg ....
>> #endif
>
> DC should stay OS-agnostic. No DRM concepts in DC please.
>
> Why the need to change dc_edid_is_same_edid?
>
> I'll comment directly on the patch.
>
> Harry
I hadn't dug into the patches to realize that this was more than just
debug prints. I figured for those using a macro would be fine, but more
in depth stuff totally aligned with you.
>
>>>
>>> On 8/11/25 13:40, Melissa Wen wrote:
>>>>
>>>>
>>>> On 28/07/2025 20:29, Alex Hung wrote:
>>>>> Thanks. I will send v6 to promotion test.
>>>> Hi Alex,
>>>>
>>>> Any news about this round of tests?
>>>>
>>>> BR,
>>>>
>>>> Melissa
>>>>
>>>>>
>>>>> On 7/25/25 18:33, Melissa Wen wrote:
>>>>>> Hi,
>>>>>>
>>>>>> Siqueira and I have been working on a solution to reduce the usage of
>>>>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>>>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>>>>> implementation and use opaque `drm_edid` object with common-code
>>>>>> helpers.
>>>>>>
>>>>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>>>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>>>>> OSes to implement their specific implementation.
>>>>>>
>>>>>> This work is an extension of [1].
>>>>>>
>>>>>> - Patch 1 addresses a possible leak added by previous migration to
>>>>>> drm_edid.
>>>>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>>>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>>>>> capabilities instead of driver-specific solutions. For this, patch 4
>>>>>> introduces a new helper that gets monitor name from drm_edid.
>>>>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>>>>> code in the DC shared code
>>>>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>>>>> handling EDID by platforms.
>>>>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>>>>> layer created before.
>>>>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>>>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>>>>> free `drm_edid`.
>>>>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>>>>> the DC shared code is little affected by Linux specific stuff.
>>>>>>
>>>>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix broken approach to get monitor name from eld (Jani)
>>>>>> - I introduced a new helper that gets monitor name from drm_edid
>>>>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>>>>> - add NULL edid checks (Jani)
>>>>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>>>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>>>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>>>>
>>>>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - kernel-doc and commit msg fixes (Jani)
>>>>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>>>>> - place drm_edid new func into the right section (Jani)
>>>>>> - paramenter names fix (Jani)
>>>>>> - add Jani's r-b to the patch 12
>>>>>> - remove unnecessary include (Jani)
>>>>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>>>>> drm_edid_free
>>>>>> - rebase on top of asdn
>>>>>>
>>>>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - rebase to asdn
>>>>>> - some kernel-doc fixes
>>>>>> - move some changes to the right commit
>>>>>>
>>>>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix comments and commit messages (Mario)
>>>>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>>>>> - add Mario's rb to patches 5-7
>>>>>>
>>>>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>>>>> mwen@igalia.com/
>>>>>> Changes:
>>>>>> - fix NULL pointer dereference (Alex H.) with the same approach
>>>>>> proposed
>>>>>> by 7c3be3ce3dfae
>>>>>>
>>>>>> --->
>>>>>> There are three specific points where we still use drm_edid_raw() in
>>>>>> the
>>>>>> driver:
>>>>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>>>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>>>>> yet;
>>>>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>>>>> moved to drm (?);
>>>>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>>>>> needs careful examining.
>>>>>>
>>>>>> I suggest to address those points in a next phase for regression
>>>>>> control.
>>>>>>
>>>>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>>>>> mwen@igalia.com/
>>>>>>
>>>>>> Let me know yours thoughts!
>>>>>>
>>>>>> Melissa
>>>>>>
>>>>>> Melissa Wen (12):
>>>>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't
>>>>>> leak
>>>>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>>>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>>>>> info
>>>>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>>>>> drm/amd/display: get panel id with drm_edid helper
>>>>>> 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: simplify dm_helpers_parse_edid_caps signature
>>>>>> drm/amd/display: change DC functions to accept private types for
>>>>>> edid
>>>>>> drm/edid: introduce a helper that compares edid data from two
>>>>>> drm_edid
>>>>>> drm/amd/display: add drm_edid to dc_sink
>>>>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>>>>
>>>>>> Rodrigo Siqueira (2):
>>>>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>>>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>>>>
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>>>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 ++++++
>>>>>> +-----------
>>>>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>>>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>>>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>>>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>>>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>>>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>>>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>>>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>>>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>>>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>>>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>>>>> include/drm/drm_edid.h | 10 +-
>>>>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>>>>
>>>>>
>>>>
>>>
>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
* Re: [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver
2025-08-11 21:47 ` Melissa Wen
@ 2025-08-12 20:39 ` Harry Wentland
0 siblings, 0 replies; 25+ messages in thread
From: Harry Wentland @ 2025-08-12 20:39 UTC (permalink / raw)
To: Melissa Wen, Limonciello, Mario, Hung, Alex, Rodrigo Siqueira,
airlied@gmail.com, Deucher, Alexander, andrzej.hajda@intel.com,
Koenig, Christian, maarten.lankhorst@linux.intel.com,
mripard@kernel.org, neil.armstrong@linaro.org, rfoss@kernel.org,
simona@ffwll.ch, Li, Sun peng (Leo), tzimmermann@suse.de
Cc: Michel Daenzer, Jani Nikula, dri-devel@lists.freedesktop.org,
amd-gfx@lists.freedesktop.org, kernel-dev@igalia.com
On 2025-08-11 17:47, Melissa Wen wrote:
>
>
> On 11/08/2025 18:26, Harry Wentland wrote:
>>
>> On 2025-08-11 17:09, Limonciello, Mario wrote:
>>> On 8/11/25 4:08 PM, Hung, Alex wrote:
>>>> Melissa,
>>>>
>>>> The patchset passed promotion and CI.
>>>>
>>>> However, since our DC code is shared with the other OS, calling drm_*
>>>> functions in DC won't work for us. For example, calling
>>>> dc_edid_copy_edid_to_sink from dc/link/link_detection.c in patch 14.
>>>>
>>>> I don't have a good way to handle it. Does it make sense not to touch DC
>>>> code for now?
>>> What about if we have a set of compatibility macros in DC code?
>>>
>>> Something like this:
>>>
>>> #ifndef drm_dbg
>>> #define drm_dbg ....
>>> #endif
>> DC should stay OS-agnostic. No DRM concepts in DC please.
>
> Yes, and that is exactly the reason for "[PATCH v6 10/14] drm/amd/display: add a mid-layer file to handle EDID in DC" (https://lore.kernel.org/amd-gfx/20250726003816.435227-11-mwen@igalia.com/).
>
> DC code still handles raw EDID data and drivers handling raw EDID is exactly what we are trying to remove from DRM. But with the current implementation of the AMD driver, we cannot remove it without touching DC code. The thing is, if we stop handle raw EDID in the DM layer, we cannot pass this data to DC and vice-versa.
> So the proposal with patch 10 (and follow-up patches) is creating different dc_edid files, one for linux and another for different platforms.
>>
>> Why the need to change dc_edid_is_same_edid?
>
> The linux file is done in this series by reimplementing the DC functions that handles raw EDID, like dc_edid_is_same_edid, with drm_edid helpers. The file for other platforms can be the original functions without these changes.
> In fact, there is a step that should be done by AMD people because we don't handle other platforms. It should be somewhat similar to the DC FPU isolation code.
>
> If it's not possible for any reasons, could you share with us some suggestions on how to address this issue?
>
I don't have a ton of bandwidth to get too deeply into this
but we'll have someone look at that and see how we can make
it work.
I'll be on vacation starting next Monday for two weeks but
I can have a look, if needed, some time in September.
Harry
> Thanks in advance,
>
> Melissa
>
>>
>> I'll comment directly on the patch.
>>
>> Harry
>>
>>>> On 8/11/25 13:40, Melissa Wen wrote:
>>>>>
>>>>> On 28/07/2025 20:29, Alex Hung wrote:
>>>>>> Thanks. I will send v6 to promotion test.
>>>>> Hi Alex,
>>>>>
>>>>> Any news about this round of tests?
>>>>>
>>>>> BR,
>>>>>
>>>>> Melissa
>>>>>
>>>>>> On 7/25/25 18:33, Melissa Wen wrote:
>>>>>>> Hi,
>>>>>>>
>>>>>>> Siqueira and I have been working on a solution to reduce the usage of
>>>>>>> drm_edid_raw in the AMD display driver, since the current guideline in
>>>>>>> the DRM subsystem is to stop handling raw edid data in driver-specific
>>>>>>> implementation and use opaque `drm_edid` object with common-code
>>>>>>> helpers.
>>>>>>>
>>>>>>> To keep DC as an OS-agnostic component, we create a mid layer that
>>>>>>> isolates `drm_edid` helpers called in the DC code, while allowing other
>>>>>>> OSes to implement their specific implementation.
>>>>>>>
>>>>>>> This work is an extension of [1].
>>>>>>>
>>>>>>> - Patch 1 addresses a possible leak added by previous migration to
>>>>>>> drm_edid.
>>>>>>> - Patch 2 allocates a temporary drm_edid from raw edid for parsing.
>>>>>>> - Patches 3-7 use common-code, drm_edid helpers to parse edid
>>>>>>> capabilities instead of driver-specific solutions. For this, patch 4
>>>>>>> introduces a new helper that gets monitor name from drm_edid.
>>>>>>> - Patches 8-9 are groundwork to reduce the noise of Linux/DRM specific
>>>>>>> code in the DC shared code
>>>>>>> - Patch 10 creates a mid layer to make DC embraces different ways of
>>>>>>> handling EDID by platforms.
>>>>>>> - Patch 11 move open-coded management of raw EDID data to the mid
>>>>>>> layer created before.
>>>>>>> - Patch 12 introduces a helper that compares EDIDs from two drm_edids.
>>>>>>> - Patch 13 adds drm_edid to dc_sink struct and a mid-layer helper to
>>>>>>> free `drm_edid`.
>>>>>>> - Patch 14 switch dc_edid to drm_edid across the driver in a way that
>>>>>>> the DC shared code is little affected by Linux specific stuff.
>>>>>>>
>>>>>>> [v1] https://lore.kernel.org/dri-devel/20250411201333.151335-1-
>>>>>>> mwen@igalia.com/
>>>>>>> Changes:
>>>>>>> - fix broken approach to get monitor name from eld (Jani)
>>>>>>> - I introduced a new helper that gets monitor name from drm_edid
>>>>>>> - rename drm_edid_eq to drm_edid_eq_buf and doc fixes (Jani)
>>>>>>> - add NULL edid checks (Jani)
>>>>>>> - fix mishandling of product_id.manufacturer_name (Michel)
>>>>>>> - I directly set it to manufacturer_id since sparse didn't complain.
>>>>>>> - add Mario's r-b in the first fix patch and fix commit msg typo.
>>>>>>>
>>>>>>> [v2] https://lore.kernel.org/dri-devel/20250507001712.120215-1-
>>>>>>> mwen@igalia.com/
>>>>>>> Changes:
>>>>>>> - kernel-doc and commit msg fixes (Jani)
>>>>>>> - use drm_edid_legacy_init instead of open coded (Jani)
>>>>>>> - place drm_edid new func into the right section (Jani)
>>>>>>> - paramenter names fix (Jani)
>>>>>>> - add Jani's r-b to the patch 12
>>>>>>> - remove unnecessary include (Jani)
>>>>>>> - call dc_edid_sink_edid_free in link_detection, instead of
>>>>>>> drm_edid_free
>>>>>>> - rebase on top of asdn
>>>>>>>
>>>>>>> [v3] https://lore.kernel.org/dri-devel/20250514202130.291324-1-
>>>>>>> mwen@igalia.com/
>>>>>>> Changes:
>>>>>>> - rebase to asdn
>>>>>>> - some kernel-doc fixes
>>>>>>> - move some changes to the right commit
>>>>>>>
>>>>>>> [v4] https://lore.kernel.org/amd-gfx/20250613150015.245917-1-
>>>>>>> mwen@igalia.com/
>>>>>>> Changes:
>>>>>>> - fix comments and commit messages (Mario)
>>>>>>> - remove unnecessary drm_edid dup and fix mem leak (Mario)
>>>>>>> - add Mario's rb to patches 5-7
>>>>>>>
>>>>>>> [v5] https://lore.kernel.org/amd-gfx/20250618152216.948406-1-
>>>>>>> mwen@igalia.com/
>>>>>>> Changes:
>>>>>>> - fix NULL pointer dereference (Alex H.) with the same approach
>>>>>>> proposed
>>>>>>> by 7c3be3ce3dfae
>>>>>>>
>>>>>>> --->
>>>>>>> There are three specific points where we still use drm_edid_raw() in
>>>>>>> the
>>>>>>> driver:
>>>>>>> 1. raw edid data for write EDID checksum in DP_TEST_EDID_CHECKSUM via
>>>>>>> drm_dp_dpcd_write(), that AFAIK there is no common code solution
>>>>>>> yet;
>>>>>>> 2. open-coded connectivity log for dc link detection, that maybe can be
>>>>>>> moved to drm (?);
>>>>>>> 3. open-coded parser that I suspect is a lot of duplicated code, but
>>>>>>> needs careful examining.
>>>>>>>
>>>>>>> I suggest to address those points in a next phase for regression
>>>>>>> control.
>>>>>>>
>>>>>>> [1] https://lore.kernel.org/amd-gfx/20250308142650.35920-1-
>>>>>>> mwen@igalia.com/
>>>>>>>
>>>>>>> Let me know yours thoughts!
>>>>>>>
>>>>>>> Melissa
>>>>>>>
>>>>>>> Melissa Wen (12):
>>>>>>> drm/amd/display: make sure drm_edid stored in aconnector doesn't
>>>>>>> leak
>>>>>>> drm/amd/display: start using drm_edid helpers to parse EDID caps
>>>>>>> drm/amd/display: use drm_edid_product_id for parsing EDID product
>>>>>>> info
>>>>>>> drm/edid: introduce a helper that gets monitor name from drm_edid
>>>>>>> drm/amd/display: get panel id with drm_edid helper
>>>>>>> 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: simplify dm_helpers_parse_edid_caps signature
>>>>>>> drm/amd/display: change DC functions to accept private types for
>>>>>>> edid
>>>>>>> drm/edid: introduce a helper that compares edid data from two
>>>>>>> drm_edid
>>>>>>> drm/amd/display: add drm_edid to dc_sink
>>>>>>> drm/amd/display: move dc_sink from dc_edid to drm_edid
>>>>>>>
>>>>>>> Rodrigo Siqueira (2):
>>>>>>> drm/amd/display: add a mid-layer file to handle EDID in DC
>>>>>>> drm/amd/display: create a function to fill dc_sink with edid data
>>>>>>>
>>>>>>> .../gpu/drm/amd/display/amdgpu_dm/Makefile | 1 +
>>>>>>> .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 33 +++---
>>>>>>> .../amd/display/amdgpu_dm/amdgpu_dm_helpers.c | 109 ++++++
>>>>>>> +-----------
>>>>>>> .../display/amdgpu_dm/amdgpu_dm_mst_types.c | 21 ++--
>>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.c | 39 +++++++
>>>>>>> .../gpu/drm/amd/display/amdgpu_dm/dc_edid.h | 15 +++
>>>>>>> .../drm/amd/display/dc/core/dc_link_exports.c | 9 +-
>>>>>>> drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 3 +
>>>>>>> drivers/gpu/drm/amd/display/dc/dc.h | 10 +-
>>>>>>> drivers/gpu/drm/amd/display/dc/dm_helpers.h | 7 +-
>>>>>>> drivers/gpu/drm/amd/display/dc/inc/link.h | 9 +-
>>>>>>> .../drm/amd/display/dc/link/link_detection.c | 30 ++---
>>>>>>> .../drm/amd/display/dc/link/link_detection.h | 9 +-
>>>>>>> drivers/gpu/drm/bridge/sil-sii8620.c | 2 +-
>>>>>>> drivers/gpu/drm/display/drm_dp_mst_topology.c | 2 +-
>>>>>>> drivers/gpu/drm/drm_edid.c | 54 +++++++--
>>>>>>> include/drm/drm_edid.h | 10 +-
>>>>>>> 17 files changed, 199 insertions(+), 164 deletions(-)
>>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.c
>>>>>>> create mode 100644 drivers/gpu/drm/amd/display/amdgpu_dm/dc_edid.h
>>>>>>>
>
^ permalink raw reply [flat|nested] 25+ messages in thread
end of thread, other threads:[~2025-08-12 20:39 UTC | newest]
Thread overview: 25+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-07-26 0:33 [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Melissa Wen
2025-07-26 0:33 ` [PATCH v6 01/14] drm/amd/display: make sure drm_edid stored in aconnector doesn't leak Melissa Wen
2025-07-26 0:33 ` [PATCH v6 02/14] drm/amd/display: start using drm_edid helpers to parse EDID caps Melissa Wen
2025-07-26 0:33 ` [PATCH v6 03/14] drm/amd/display: use drm_edid_product_id for parsing EDID product info Melissa Wen
2025-07-26 0:33 ` [PATCH v6 04/14] drm/edid: introduce a helper that gets monitor name from drm_edid Melissa Wen
2025-07-26 0:33 ` [PATCH v6 05/14] drm/amd/display: get panel id with drm_edid helper Melissa Wen
2025-07-26 0:33 ` [PATCH v6 06/14] drm/amd/display: get SAD from drm_eld when parsing EDID caps Melissa Wen
2025-07-26 0:33 ` [PATCH v6 07/14] drm/amd/display: get SADB " Melissa Wen
2025-07-26 0:33 ` [PATCH v6 08/14] drm/amd/display: simplify dm_helpers_parse_edid_caps signature Melissa Wen
2025-07-26 0:33 ` [PATCH v6 09/14] drm/amd/display: change DC functions to accept private types for edid Melissa Wen
2025-07-26 0:33 ` [PATCH v6 10/14] drm/amd/display: add a mid-layer file to handle EDID in DC Melissa Wen
2025-07-26 0:33 ` [PATCH v6 11/14] drm/amd/display: create a function to fill dc_sink with edid data Melissa Wen
2025-07-26 0:33 ` [PATCH v6 12/14] drm/edid: introduce a helper that compares edid data from two drm_edid Melissa Wen
2025-07-26 0:33 ` [PATCH v6 13/14] drm/amd/display: add drm_edid to dc_sink Melissa Wen
2025-08-11 21:27 ` Harry Wentland
2025-07-26 0:33 ` [PATCH v6 14/14] drm/amd/display: move dc_sink from dc_edid to drm_edid Melissa Wen
2025-08-11 21:29 ` Harry Wentland
2025-07-28 23:29 ` [PATCH v6 00/14] drm/amd/display: more drm_edid to AMD display driver Alex Hung
2025-08-11 19:40 ` Melissa Wen
2025-08-11 21:08 ` Alex Hung
2025-08-11 21:09 ` Limonciello, Mario
2025-08-11 21:26 ` Harry Wentland
2025-08-11 21:47 ` Melissa Wen
2025-08-12 20:39 ` Harry Wentland
2025-08-12 19:30 ` Limonciello, Mario
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).