Repository navigation
drm/apple: give external displays a DDC I2C adapter - #3542
Conversation
The DCP owns the DisplayPort AUX channel and the HDMI DDC lines, and the driver registered no I2C adapter for them, so ddcutil and other DDC users found no bus for an external display: no DDC/CI brightness, input or VCP control. macOS reaches the sink's DDC through the dcpav-service-epic service: one standard service command per I2C transfer, the same "xcpi" message the HDR10 metadata already uses, selector 0x0a for a write and 0x09 for a read, with chip, offset and length each in a 16-byte slot and the data after them. The firmware passes DDC/CI framing through unchanged. Register an I2C adapter for every DisplayPort and HDMI connector and pass it to drm_connector_init_with_ddc(), so DRM links it from the connector in sysfs. Each transfer goes to the pipeline driving the connector at that time, through the DCPAV instance the EDID path already admitted (and, on the 14.7 external processor, opened). The adapter takes the transfers DDC users make: a write whose first byte is the offset, a DDC/CI reply read from 0x37, and an offset write followed by a read (the EDID at 0x50). Anything else is -EOPNOTSUPP. Signed-off-by: Ryan Murray <[email protected]>
There was a problem hiding this comment.
Verdict: FINISH, then merge at c199462f
Blockers:
- Hosted CI at
c199462f(21 jobs:kunit,apple-build,host-tests,pr-text,readiness, KUnit suites) is currentlyQUEUED; wait for green CI. - Exact-head hardware rows at
c199462f: J473 (M2 mini) liveddcutil detect/getvcp/setvcp(restored) on USB-C (dcpext) and HDMI, plus K114s/J616s (-ENODEV/ regression) rows as listed in**Not yet**.
Checked:
- Audited all 9 modified/added files (
dcp-ddc.{c,h},epic/dpavserv-ddc.h,epic/dpavserv-ddc-test.c,epic/dpavservep.{c,h},apple_drv.c,connector.h,Makefile):- Lifecycle & teardown:
apple_ddc_create()only attaches toDRM_MODE_CONNECTOR_DisplayPortandDRM_MODE_CONNECTOR_HDMIA(panels/eDP getNULL).connector->dcpstarts zeroed (kzalloc_obj), so early/dev/i2c-*access before pipeline binding safely returns-ENODEV. Error unwind inapple_connector_create()andapple_probe_typec_ports()cleans upconnector->ddc, andappledrm_connector_cleanup()callsapple_ddc_destroy()(i2c_del_adapter()drains in-flight users) beforekfree(apple_connector)and before componentdcpunbind. - Transfer validation (
apple_ddc_plan()): Restricts to 1–2 messages,I2C_M_RDflag only (rejectsI2C_M_TENetc.), addresses0x37/0x50only, length bounds<= DCPAV_I2C_MAX_DATA(128 bytes), rejecting address-only probes, bare non-0x37reads, segment pointers (0x30), and cross-chip repeated starts with-EOPNOTSUPP. - Wire protocol (
dpavserv-ddc.h,dpavservep.c):dcpav_i2c_message()bounds-checkschip <= 0x7f,len <= 128, non-zero read len, and non-NULL write data;dcpav_i2c_result()validates transport, minimum reply length, echoed selector,"xcpi"magic, firmware status (-EREMOTEIO), and AFK retcode (-EIO).dcpavserv_i2c()never opens a v14.7 external DCPAV instance (-EAGAINif unopened/terminated), holdsafk_service_get()across the unlocked IPC call, and re-checks service/epoch identity underdcp->dcpavserv.lockbefore returning success. - KUnit coverage:
apple-dcpav-ddctests write/read wire layouts byte-for-byte, bounds, result error paths, and transfer planning (347/348, 1 unrelated skip).
- Lifecycle & teardown:
Evidence
Risk:one-way · every DCP DP/HDMI connector gains an I2C adapterpresent.- Minor defensive nits (non-blocking):
dcpavserv_i2c()could guardif (!dcp) return -ENODEV;beforeREAD_ONCE(dcp->crashed)in case a future caller passes apdevwith cleared drvdata.apple_ddc_plan()could guard!m->buf(and!r->bufwhennum == 2) for direct in-kernel callers passing a NULL buffer with non-zero length.
|
J473 attempt 2026-11-29 02:25 (7.3.0-aurora-pr3542 = c199462, M2MINI-DISPLAY-FULL kit): INCONCLUSIVE. DCP1's RTKit stopped answering at 1.95 s (system endpoint -110, then DPAVSERV/IBOOT/DPTX -110), apple-drm's bind failed (-19), and no connectors or adapters existed to test. The failure comes before any code in this PR runs, and the production reboot right after it also came up degraded and needed a second reboot. Rerunning on a clean boot. Our trace: traces/display/20261125-j473-dpms-relight/pr3542-c199462f-j473-a. |
ddcutil found no monitor on the new DDC adapters of the M2 Mac mini: it reads the EDID through i2c-dev's write() and read(), as two transfers, a one-byte offset write to 0x50 and then a bare read, and the adapter refused a bare read from anything but the DDC/CI address. Keep the EDID EEPROM's address counter in the adapter: a one-byte write to 0x50 only sets it, and a read from 0x50 reads there and moves it on. DDC/CI writes are still sent, and a bare read from 0x37 keeps the DDC/CI host address 0x51 as its offset. Signed-off-by: Ryan Murray <[email protected]>
|
J473 retry B at c199462 (M2MINI-ORACLE, traces/display/20261125-j473-dpms-relight/pr3542-c199462f-j473-b): both adapters register and are linked (card1-DP-2/ddc -> i2c-5 "apple-dcp DDC typec1", card1-HDMI-A-1/ddc -> i2c-3), 0 DCP crashes, but ddcutil detected no monitor. Cause: ddcutil reads the EDID with i2c-dev write()+read(), two transfers, and the adapter refused a bare read on 0x50. Fixed in a9fe2c1 (EDID address counter, KUnit updated). Rerun requested at a9fe2c1 with raw i2ctransfer probes so the errno of each step is visible. |
There was a problem hiding this comment.
Verdict: FINISH, then merge at a9fe2c14
Blockers:
- Hosted CI at
a9fe2c14(21 jobs:kunit,apple-build,host-tests,pr-text,readiness, KUnit suites) is currentlyQUEUED; wait for green CI. - Exact-head J473 (M2 mini) live
ddcutil detect/getvcp 10/setvcp 10(restored) /getvcp 60pass row ata9fe2c14(re-testing after the separatei2c-devEDID write+read fix), plus K114s/J616s rows as listed in**Not yet**.
Checked:
- Audited
a9fe2c148cacrossdrivers/gpu/drm/apple/dcp-ddc.{c,h}andepic/dpavserv-ddc-test.c:guard(mutex)(&ddc->lock)now wrapsapple_ddc_plan()andddc->edid_offsetupdates, serializing the emulated EDID EEPROM address counter cleanly.- A 1-byte write to
0x50(DDC_EDID_ADDR) setsxfer.none = true, latchesddc->edid_offset = xfer.offset, and returnsnumwithout touching DCP; a subsequent bare read on0x50reads atddc->edid_offsetand advancesddc->edid_offset = xfer.offset + xfer.len(u8wrap matching a 256-byte EEPROM). - Verified DDC/CI writes (
0x37) are never swallowed asxfer.none, bare0x37reply reads retain offset0x51, and0x30segment pointers still return-EOPNOTSUPP. - Updated
dpavddc_planKUnit suite covers all new paths (347/348, 1 unrelated skip).
Evidence
Risk:one-way · every DCP DP/HDMI connector gains an I2C adapterpresent.- Code is clean; ready to approve once queued CI and the J473 live
ddcutilre-test ata9fe2c14pass.
|
J473 (M2 mini, T8112, macOS 27.2 firmware) rows at
EvidenceLab store: |
|
Merge readiness at
Areas: Updated by pr-readiness on pushes, edits, reviews and comments, and on a schedule. Rules: merge policy · labels. |
Every transfer through /dev/i2c-N failed with -EOPNOTSUPP on the M2 Mac mini: i2c-dev marks the buffers of I2C_RDWR (and its read() and write()) DMA-safe, and the adapter refused any message flag but I2C_M_RD. The flag says nothing about the transfer, so ignore it. Log each transfer and its result at debug level, so a sink that does not answer can be told from a service that is not there. Signed-off-by: Ryan Murray <[email protected]>
|
J473 row at a9fe2c1 (traces/display/20261125-j473-dpms-relight/pr3542-a9fe2c14-j473-a): boot healthy (dual KMS OK, DPMS relight OK, 0 DCP crashes), adapters linked. Every raw |
|
J473 rerun at
EvidenceLab store: |
|
Thanks, that row did its job. Two corrections to the reading:
Boot health: 2 of 4 boots of this PR on the J473 were bad (one HDMI DCP dead at boot, one hang before rootfs). Nothing in the PR runs before userspace opens a bus: the adapters are only registered, and DRM never uses |
There was a problem hiding this comment.
Verdict: FINISH, then merge at 0aca45cc
Blockers:
- Wait for the 20 queued CI checks (
kunit,apple-build,host-tests,pr-text, 16 KUnit suites) to pass at0aca45cc. - Exact-head J473 (M2 mini) live
ddcutilhardware row (detect,getvcp 10,setvcp 10restored,getvcp 60on USB-C dcpext and HDMI) listed inNot yet.
Checked:
- Commit
0aca45cc(drivers/gpu/drm/apple/dcp-ddc.c,epic/dpavserv-ddc-test.c): 0 code blockers.- Verified
apple_ddc_plan()ignoresI2C_M_DMA_SAFEon both 1-message (m->flags & ~(I2C_M_RD | I2C_M_DMA_SAFE)) and 2-message ((r->flags & ~I2C_M_DMA_SAFE) != I2C_M_RD) transfers while still rejecting unsupported flags, addresses, and lengths. - Verified
dpavddc_planKUnit tests coverI2C_M_DMA_SAFEon both 1-message DDC/CI writes and 2-message EDID reads (347/348, 1 unrelated skip). - PR metadata (
Tested:cites0aca45cc,Risk:one-way,MERGEABLEonmain).
- Verified
Evidence
- Head:
0aca45cc(MERGEABLEonmain,+598/-5across 9 files). - Non-blocking nit: in
apple_ddc_xfer(),dev_dbg(&adapter->dev, "%d message(s) to %#x not supported\n", num, msgs[0].addr);indexesmsgs[0]whenapple_ddc_plan()rejectsnum < 1; usingnum > 0 ? msgs[0].addr : 0would keep the log path defensive ifmaster_xferis ever called withnum == 0.
|
J473 (M2 Mac mini) row at 0aca45c: PASS. 2026-11-29 05:4x, M2MINI-DISPLAY-FULL kit
Not yet: the K114s, where Linux doesn't admit the service on endpoint 0x2b yet (follow-up); the J616s with an external plugged. Our trace: traces/display/20261125-j473-dpms-relight/pr3542-0aca45cc-j473-a. |
|
J473 row at USB-C (MSI MPG 325CQRXF,
HDMI (Acer QG270 S3,
Boot health: the last three boots of this PR on the J473 were all clean. Over 5 boots, 3 were clean, 1 had the HDMI DCP dead at boot, and 1 hung before the root filesystem. EvidenceLab store: |
RyanTheTide
left a comment
There was a problem hiding this comment.
Adversarial review at 0aca45cc (from the J473 display lane; I'm not the author). Verdict: one change before merge, the rest is fine.
Change requested
- Writes to the EDID EEPROM (0x50) go through to the sink. In
apple_ddc_plan(), a one-byte write to 0x50 only sets the address counter, but a longer write to 0x50 falls into the generic write path and is sent to the monitor. No DDC user writes the EDID; it's the one transfer here that can damage hardware. Many monitors don't write-protect that EEPROM, so a strayi2cset/i2ctransfer, or a tool bug, could overwrite a monitor's EDID permanently. Please refuse writes longer than one byte to 0x50 with -EOPNOTSUPP, and add a KUnit case for it. DDC/CI (0x37) writes and EDID reads are unaffected.
Checked, no change needed
- Lifetime: the adapter is created before
drm_connector_init_with_ddc()and destroyed afterdrm_connector_cleanup().i2c_del_adapter()waits for open i2c-dev users and in-flight transfers beforekfree(), and every error path in bothapple_connector_create()andapple_probe_typec_ports()destroys it. - No adapter class is set, so the I2C core does no legacy client probing on these buses.
- Connector-type check (DP/HDMI-A) is a property of the connector, not a SoC/board gate.
dcpavserv_i2c()only uses a live service instance and drops answers from a retired one (epoch check before and after). A DPMS or relight service close gives -ENODEV, not a stale reply. On 14.7 external it never opens an instance itself.- The
I2C_M_DMA_SAFEfix covers both messages of the combined read, with KUnit cases.
Nits (optional)
adapter.timeout = 2 * HZisn't enforced by the adapter itself (the AFK call has its own timeout). Harmless, but the comment suggests otherwise.- The E-DDC segment pointer (0x30) is refused, so EDID blocks above 256 bytes can't be read over I2C. That's fine for ddcutil and DRM (DRM uses the firmware EDID); maybe say so in the header comment.
i2c_mark_adapter_suspended()around system sleep would make a kernel-side user fail cleanly during suspend. There are no kernel users today, so this is only nice to have.
Hardware
- J473 (M2 mini, macOS 27.2 firmware) at this head: stock ddcutil on the MSI over USB-C does brightness get/set/restore and reads the input source, before and after DPMS.
- On the HDMI Acer the EDID reads over DDC, but DDC/CI only gets null replies, which points at the monitor's own setting. Details: #3542 (comment)
A write of more than one byte to 0x50 went to the sink. No DDC user writes the EDID, and many monitors do not write-protect its EEPROM, so a stray i2cset or a tool bug could overwrite it for good. Take a write to 0x50 only as the one-byte address counter, refuse anything longer, and test it. Also say why the E-DDC segment pointer is refused, and that the adapter timeout is informational: the DCPAV call has its own. Signed-off-by: Ryan Murray <[email protected]>
|
Thanks for the review. At be1faea:
The J473 row at this exact head is requested from M2MINI-DISPLAY-FULL (same ddc-row.sh, plus an input-switch step). |
There was a problem hiding this comment.
Verdict: FINISH, then merge at be1faea5
Blockers:
- Queued CI checks (
21pending atbe1faea5:apple-build,host-tests,kunit, 16 KUnit suites,pr-text,readiness) must finish green. - Requested exact-head
be1faea5J473 liveddcutilrow (including input-switch step) still pending.
Checked: Delta commit be1faea519 (drivers/gpu/drm/apple/dcp-ddc.c, drivers/gpu/drm/apple/epic/dpavserv-ddc-test.c) over 0aca45cc and local KUnit results (347/348).
Evidence
- Blocker resolved (
0aca45cc -> be1faea5, 0 code blockers):apple_ddc_plan()(dcp-ddc.c:93-101) now refuses any write toDDC_EDID_ADDR(0x50) withm->len != 1(-EOPNOTSUPP) before reaching firmware, allowing only the 1-byte address-counter write while leaving0x37DDC/CI writes and EDID reads intact.dpavddc_plan()(dpavserv-ddc-test.c:138-146) covers a 3-byte write to0x50both with and withoutI2C_M_DMA_SAFE(-EOPNOTSUPP).- Comments for
adapter.timeoutand the E-DDC segment pointer (0x30) refusal are clarified cleanly.
- Verification: Local KUnit
347/348(1 unrelated skip) passes atbe1faea5; prior J4730aca45ccrow passed USB-Cddcutilgetvcp/setvcpacross DPMS off/on and HDMI EDID read over I2C.
|
J473 row at
My review point is addressed. From the J473 side this is ready for merge review. EvidenceLab store: |
There was a problem hiding this comment.
Verdict: MERGE at be1faea5 once queued CI checks pass.
Blockers: none in code or hardware verification (await queued CI checks).
Checked: Full code diff at be1faea5 (previously audited with 0 code blockers, including the EDID EEPROM 1-byte write guard at 0x50 returning -EOPNOTSUPP) plus the new exact-head J473 (M2 mini, firmware 27.2) hardware row.
Evidence
- Exact-head J473 row at
be1faea5:- Clean one-shot boot (
0failed units,0AVC denials, no DCP crash). - USB-C (
MSI MPG 325CQRXF): stockddcutilbrightness100 -> 90 -> 90 -> 100before and after a DPMS cycle; VCP0x60reads0x12,setvcp 60 0x12returns0and reads back0x12. - EDID EEPROM write guard live-verified:
i2ctransfer w3@0x50 ...returnsOperation not supported(-EOPNOTSUPP) on both buses without reaching the sink. - HDMI (
Acer QG270 S3): unchanged (EDIDreadable).
- Clean one-shot boot (
- Code audit at
be1faea5: Clean; prior EDID EEPROM write blocker is resolved. Ready to merge as soon as queued CI checks turn green.
|
code-owner ping <@422957901716652033> / @DjDeveloperr: merge train at |
|
K114s (T6050 built-in HDMI): with #3609, which admits the HDMI converter's DCPAV service on dcpext0 endpoint 0x2a, this adapter works there too. On a K114s lab one-shot with both changes, |
|
Merging under the 6-point rule at |
What
External displays on Apple DCP outputs have no DDC bus under Linux: apple-drm registers no I2C or DP-AUX adapter for them, so
ddcutilfinds nothing (no DDC/CI brightness, input switching or VCP access). The DCP owns the DP AUX channel and the HDMI DDC lines.macOS reaches the sink's DDC through the
dcpav-service-epicservice (our own macOS-guest trace on the J473,traces/display/20261129-hv-dcp/README.md, run d1). Each IOAVService ReadI2C/WriteI2C is one standard service command, the samexcpimessage the HDR10 metadata already uses. Selector 0x0a writes and 0x09 reads; chip, offset and length each sit in a 16-byte slot, then the data. The firmware passes DDC/CI framing through unchanged.This registers an I2C adapter for every DisplayPort and HDMI connector and passes it to
drm_connector_init_with_ddc(), so/sys/class/drm/cardN-*/ddclinks it. Each transfer goes to the pipeline driving the connector at that moment, through the DCPAV instance the EDID path already admitted (and, on the 14.7 external processor, opened: DDC never opens one itself). Supported transfers:Anything else returns
-EOPNOTSUPP. An unrouted connector or a DCP without the service returns-ENODEV; a sink that doesn't answer returns-EREMOTEIO(firmware status 0xe0114000).Tested
Tested: KUnit at be1faea (arm64 QEMU, 347/348, 1 unrelated skip), new suite
apple-dcpav-ddc: write/read layouts byte for byte, reply parsing (status, short or foreign replies), transfer planning (DDC/CI write and read, EDID offset+read combined or as i2c-dev write()+read(), i2c-dev DMA-safe flags, refuses writes into the EDID EEPROM; refuses segment pointer, repeated start to another chip, address-only probes, >128 bytes). J473 row PASS at 0aca45c (comment below): MSI over USB-C get/set/restore VCP 0x10 and VCP 0x60 through ddcutil, EDID over DDC on both outputs.Risk: one-way · every DCP DP/HDMI connector gains an I2C adapter; transfers only reach the firmware when a DCPAV service is live for that pipeline, otherwise they fail without touching the DCP. Panels (eDP) get none.
Not yet
-ENODEV; enabling it is a follow-up.