drm/amd/display: Route connector DDC over AUX for native DP sinks
Subsystems (3)
PATCH v4 1/1 drm/amd/display: Route connector DDC over AUX for native DP sinks
On DisplayPort and eDP connectors DDC is tunneled over the AUX channel, but the connector's "ddc" adapter ("AMDGPU DM i2c hw bus N") always drives the physical i2c pins, which don't reach a native DP sink. The AUX backed adapter ("AMDGPU DM aux hw bus N") does, so userspace such as fwupd, which uses the "ddc" sysfs link for DDC/CI, has to work around this.
Keep a single i2c bus per connector and pick the transport per transfer based on the link's transaction mode (link->aux_mode), as the EDID read helpers already do: for native DP/eDP/MST sinks forward the transfer to the AUX adapter, otherwise (DVI/HDMI, including DP++ with a passive adapter) use the hw i2c engine as before.
---
Changes in v4:
- Add Wayne's tag
- Fold in Eren's fix for kunit tests
- Link to v3: https://patch.msgid.link/[email protected]
Changes in v3:
- Select the transport with link->aux_mode instead of link->local_sink->sink_signal, matching the EDID read helpers in amdgpu_dm_helpers.c. This drops the unlocked local_sink dereference
that could race with link detection/hotplug (use-after-free), and it
also covers MST links (local_sink is NULL there) and links with force_to_use_aux set.
- Check ddc_service->link for NULL before dereferencing it, so amdgpu_dm_i2c_xfer() still returns -EIO when there is no ddc_pin
(fixes dm_test_i2c_xfer_no_ddc_pin()).
- Reword the commit message to describe the aux_mode selection.
- Link to v2: https://patch.msgid.link/[email protected]
Changes in v2:
- Check which i2c bus to use on the fly instead of changing static symlink to avoid regressing passive adapters.
- Link to v1: https://patch.msgid.link/[email protected]
--- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c | 16 ++++++++++++++++ .../display/amdgpu_dm/tests/amdgpu_dm_connector_test.c | 6 +++++- 2 files changed, 21 insertions(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +16 -0
@@ -3373,6 +3373,22 @@ STATIC_IFN_KUNIT int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,int i;int result = -EIO ; +if (!i2c->oem && ddc_service->link) { +struct dc_link *link = ddc_service->link; +struct amdgpu_dm_connector *aconnector = link->priv; + +/* +* DDC to a native DisplayPort sink (SST, MST or eDP) is +* tunneled over the AUX channel; the physical i2c pins only +* reach DVI/HDMI sinks (e.g. DP++ with a passive adapter). +* Use the same aux_mode selection as the EDID read helpers so +* the connector's single "ddc" bus works for either sink. +*/ +if (aconnector && link->aux_mode && + aconnector->dm_dp_aux.aux.ddc.algo) +return i2c_transfer (&aconnector->dm_dp_aux.aux.ddc, msgs, num); + } +if (!ddc_service->ddc_pin)return result;
drivers/gpu/drm/amd/display/amdgpu_dm/tests/amdgpu_dm_connector_test.c +5 -1
@@ -6140,7 +6140,9 @@ static void dm_test_i2c_func_returns_flags(struct kunit *test)* @test: The KUnit test context * * When the backing ddc_service has no ddc_pin the transfer bails out early -* with -EIO before touching the message buffers or the dc handle. +* with -EIO before touching the message buffers or the dc handle. Non-OEM +* adapters always have a link, so the test gives the ddc_service a zeroed +* one. */ static void dm_test_i2c_xfer_no_ddc_pin (struct kunit *test) {
@@ -6151,6 +6153,8 @@ static void dm_test_i2c_xfer_no_ddc_pin(struct kunit *test)KUNIT_ASSERT_NOT_NULL (test, i2c); ddc =kunit_kzalloc (test,sizeof (*ddc),GFP_KERNEL );KUNIT_ASSERT_NOT_NULL (test, ddc); + ddc->link =kunit_kzalloc (test,sizeof (*ddc->link),GFP_KERNEL ); +KUNIT_ASSERT_NOT_NULL (test, ddc->link); i2c->ddc_service = ddc;i2c_set_adapdata (&i2c->base, i2c);
---
base-commit: 7475ea8b58616b33c04afb976cf0fbaad9dd63fb
change-id: 20261102-superm1-amdgpu-ddc-63f0eb10c022
Best regards,
Signature · 1 line
Mario Limonciello <[email protected]>
[email protected]
AI reviewThank you for your contribution! Sashiko AI review found 1 potential issue to consider: - [High] drm/amd/display: stale link->aux_mode in amdgpu_dm_i2c_xfer() breaks DP++ --
Thank you for your contribution! Sashiko AI review found 1 potential issue to consider:
- [High] drm/amd/display: stale link->aux_mode in amdgpu_dm_i2c_xfer() breaks DP++
--
commit bd7217b6334d8e26e4a44e7561c8afe2462a790d
Author: Mario Limonciello <[email protected]>
drm/amd/display: Route connector DDC over AUX for native DP sinks
This commit routes transfers on a connector's DDC i2c adapter through the AUX DDC adapter when link->aux_mode is set so that native DisplayPort, eDP, and MST sinks can be reached via the connector's ddc bus.
Quoted 13 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +5
-0@@ -3373,6 +3373,22 @@ STATIC_IFN_KUNIT int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap,int i;int result = -EIO ; +if (!i2c->oem && ddc_service->link) { +struct dc_link *link = ddc_service->link; +struct amdgpu_dm_connector *aconnector = link->priv; + +/*
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c STATIC_IFN_KUNIT int amdgpu_dm_i2c_xfer(struct i2c_adapter *i2c_adap, · line 3390
Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_connector.c +10
-0+* DDC to a native DisplayPort sink (SST, MST or eDP) is +* tunneled over the AUX channel; the physical i2c pins only +* reach DVI/HDMI sinks (e.g. DP++ with a passive adapter). +* Use the same aux_mode selection as the EDID read helpers so +* the connector's single "ddc" bus works for either sink. +*/ +if (aconnector && link->aux_mode && + aconnector->dm_dp_aux.aux.ddc.algo) +return i2c_transfer (&aconnector->dm_dp_aux.aux.ddc, msgs, num); + }
[Severity: High]
As reported by Eren Özen on v2 [1], can a stale link->aux_mode misroute the passive DP++ dongle identification read over AUX when a native DisplayPort sink is unplugged and replaced with a passive DP-to-HDMI adapter on the same port?
link->aux_mode is not cleared on disconnect, and detect_link_and_local_sink() only updates it after detect_dp() returns:
drivers/gpu/drm/amd/display/dc/link/link_detection.c:detect_link_and_local_sink() {
...
if (!detect_dp(link, &sink_caps, reason)) {
...
set_ddc_transaction_type(link->ddc,
sink_caps.transaction_type);
link->aux_mode =
link_is_in_aux_transaction_mode(link->ddc);
...
}During detect_dp(), dp_passive_dongle_detection() -> query_dp_dual_mode_adaptor() reads DP_HDMI_DONGLE_ADDRESS (0x40) via i2c_read() -> dm_helpers_submit_i2c() -> i2c_transfer(&aconnector->i2c->base) -> amdgpu_dm_i2c_xfer() while link->aux_mode is still true from the previous native DP sink. Forwarding that read to I2C-over-AUX fails on a passive DP++ adapter, causing query_dp_dual_mode_adaptor() to fall back to DISPLAY_DONGLE_DP_DVI_DONGLE (SIGNAL_TYPE_DVI_SINGLE_LINK), which caps the pixel clock to 165 MHz and disables HDMI audio and infoframes.
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Hi Mario,
Thanks for folding it in and for the credit. My part was written with help from an AI assistant, so per Documentation/process/coding-assistants.rst as far as I understand, the commit should also carry:
Could you add it when this gets applied?
Thanks,
Eren
Quoted 6 lines · Eren Özen
Hi Mario,
Thanks for folding it in and for the credit. My part was written with help from an AI assistant, so per
Documentation/process/coding-assistants.rstas far as I understand, the commit should also carry:
Quoted 6 lines
Assisted-by Claude:claude-opus-5-5Could you add it when this gets applied?
Thanks,
Eren
Actually the kernel dropped the policy for documenting this requirement.
So no need to add it.
I still do have feedback from Sashiko about the swapping to a passive DP++ dongle. But I'd like to know from Simon if this even conceptually works.
So Simon please test this patch against the original issue.
If you need some help building the kernel, I suggest working with an LLM on your specific distro, they're pretty good at helping with this kind of thing.