From 5f1cb748e89d04cc1233b4e62fbb05fb3e20bf8c Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 01/15] dt-bindings: iommu: apple,dart: document apple,t8152-disp-isoc-dart Document the apple,t8152-disp-isoc-dart compatible for T8152 display isochronous DARTs, which handle display ADMAC audio DMA on SID 30. Signed-off-by: Thomas Glanzmann --- Documentation/devicetree/bindings/iommu/apple,dart.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/iommu/apple,dart.yaml b/Documentation/devicetree/bindings/iommu/apple,dart.yaml index 252c44db78c4d..87f6fa28f5376 100644 --- a/Documentation/devicetree/bindings/iommu/apple,dart.yaml +++ b/Documentation/devicetree/bindings/iommu/apple,dart.yaml @@ -36,6 +36,7 @@ properties: - apple,t8152-acio-dart - apple,t8152-pciec-dart - apple,t8152-avd-dart + - apple,t8152-disp-isoc-dart - items: - const: apple,t8140-ane-dart - const: apple,t8140-dart @@ -389,6 +390,7 @@ allOf: - apple,t8152-acio-dart - apple,t8152-pciec-dart - apple,t8152-avd-dart + - apple,t8152-disp-isoc-dart then: description: The T8152 Gen3 DARTs in front of the display coprocessors and their From c36486896994c620fdd8e7f67042f0eaec0b2c89 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 02/15] iommu/dart: support cold T8152 display isochronous DARTs Add support for apple,t8152-disp-isoc-dart as a cold Gen3 DART covering stream ID 30 (the display ADMAC audio stream) with optional tunables. Signed-off-by: Thomas Glanzmann --- drivers/iommu/apple-dart.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 268159d63bad2..241e5b7f4947f 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -2373,6 +2373,9 @@ static void apple_dart_apply_own_tunables(struct apple_dart *dart) { size_t i; + if (!dart->tunables) + return; + for (i = 0; i < dart->tunables->sz; ++i) { u32 offset = dart->tunables->values[i].offset; u32 old_value, value; @@ -5976,6 +5979,7 @@ static int apple_dart_probe(struct platform_device *pdev) "usb4-pcie-tunnel-"); bool j713_display, j713_dcpext, j713_dispext, j713_radio, t8132_dcp = false; bool cold_avd = of_device_is_compatible(dev->of_node, "apple,t8152-avd-dart"); + bool cold_isoc = of_device_is_compatible(dev->of_node, "apple,t8152-disp-isoc-dart"); /* * The M4 internal display DARTs are live: DCP firmware (SID23) @@ -6094,6 +6098,10 @@ static int apple_dart_probe(struct platform_device *pdev) dart->cold_gen3 = true; dart->cold_gen3_sids = 0x7; } + if (cold_isoc) { + dart->cold_gen3 = true; + dart->cold_gen3_sids = BIT(30); + } if (of_device_is_compatible(dev->of_node, "apple,t8152-acio-dart")) { dart->cold_gen3 = true; dart->cold_gen3_sids = 0x0fff0fff; @@ -6546,9 +6554,12 @@ static int apple_dart_probe(struct platform_device *pdev) goto err_clk_disable; } if (dart->cold_gen3 && - (dart->locked || dart->version != 0x300 || !dart->tunables || + (dart->locked || dart->version != 0x300 || + (!cold_isoc && !dart->tunables) || (dart->cold_gen3_pcie ? (!tunneled || !dev->pm_domain) : cold_avd ? (dart->num_streams != 16 || !dev->pm_domain) : + cold_isoc ? (dart->num_streams < 31 || dart->num_streams > 32 || + !dev->pm_domain) : dart->num_streams != 32) || (apple_dart_readl(dart, dart->hw->enable_streams) & dart->cold_gen3_sids))) { ret = -EINVAL; @@ -8038,6 +8049,7 @@ static const struct dev_pm_ops apple_dart_pm_ops = { static const struct of_device_id apple_dart_of_match[] = { { .compatible = "apple,t8152-dart-gen3", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8152-avd-dart", .data = &apple_dart_hw_gen3 }, + { .compatible = "apple,t8152-disp-isoc-dart", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8152-acio-dart", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8152-pciec-dart", .data = &apple_dart_hw_gen3 }, { .compatible = "apple,t8103-dart", .data = &apple_dart_hw_t8103 }, From 254e66e97248aa7e598e8edeff68f877ae25a0bc Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 03/15] dt-bindings: dma: apple,admac: document T8152 display ADMAC Document apple,t8152-display-admac and apple,t8152-admac-control for the T8152 display audio DMA controllers and their CED/SSW control blocks. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/dma/apple,admac-control.yaml | 4 +++- .../devicetree/bindings/dma/apple,admac.yaml | 12 ++++++++---- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Documentation/devicetree/bindings/dma/apple,admac-control.yaml b/Documentation/devicetree/bindings/dma/apple,admac-control.yaml index 1d6542014d0cc..46190e1e245a0 100644 --- a/Documentation/devicetree/bindings/dma/apple,admac-control.yaml +++ b/Documentation/devicetree/bindings/dma/apple,admac-control.yaml @@ -17,7 +17,9 @@ description: | properties: compatible: items: - - const: apple,t6050-admac-control + - enum: + - apple,t6050-admac-control + - apple,t8152-admac-control - const: apple,admac-control reg: diff --git a/Documentation/devicetree/bindings/dma/apple,admac.yaml b/Documentation/devicetree/bindings/dma/apple,admac.yaml index e472332dc97e7..1d6a5c4487e71 100644 --- a/Documentation/devicetree/bindings/dma/apple,admac.yaml +++ b/Documentation/devicetree/bindings/dma/apple,admac.yaml @@ -24,7 +24,9 @@ allOf: properties: compatible: contains: - const: apple,t6050-display-admac + enum: + - apple,t6050-display-admac + - apple,t8152-display-admac then: properties: apple,admac-control: false @@ -58,9 +60,11 @@ properties: - const: apple,t6050-admac - const: apple,t8140-admac - description: - A T6050 display engine's own ADMAC (ADT "self-actuated"), which - feeds the engine's DisplayPort audio. - const: apple,t6050-display-admac + A display engine's own ADMAC (ADT "self-actuated"), which + feeds the engine's DisplayPort/HDMI audio. + enum: + - apple,t6050-display-admac + - apple,t8152-display-admac reg: maxItems: 1 From 2950694f30bb66ba592cb8a8827fbeb5fc659ec0 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 04/15] dmaengine: apple-admac: add T8152 display ADMAC support Add the apple,t8152-display-admac match entry using T8152's 0x40000 channel layout with the display ADMAC profile. Signed-off-by: Thomas Glanzmann --- drivers/dma/apple-admac.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c index a42ba9559db11..077def59c81f1 100644 --- a/drivers/dma/apple-admac.c +++ b/drivers/dma/apple-admac.c @@ -1832,7 +1832,14 @@ static const struct admac_hw admac_t8152_hw = { .t8152_layout = true, }; +/* The T8152 display ADMACs: T8152's 0x40000 channel layout with the display profile */ +static const struct admac_hw admac_t8152_display_hw = { + .t8152_layout = true, + .display = true, +}; + static const struct of_device_id admac_of_match[] = { + { .compatible = "apple,t8152-display-admac", .data = &admac_t8152_display_hw }, { .compatible = "apple,t6050-display-admac", .data = &admac_t6050_display_hw }, { .compatible = "apple,t8152-admac", .data = &admac_t8152_hw }, { .compatible = "apple,t8140-admac", .data = &admac_t8140_hw }, From 20a11de52cb3781d3274551515782548d191fc69 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 05/15] dt-bindings: sound: apple,t6030-dpaudio: add apple,t8152-dpaudio Add the apple,t8152-dpaudio compatible to the Apple DisplayPort audio controller binding. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/sound/apple,t6030-dpaudio.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Documentation/devicetree/bindings/sound/apple,t6030-dpaudio.yaml b/Documentation/devicetree/bindings/sound/apple,t6030-dpaudio.yaml index 8fe63cf0a3b56..39ed06365b125 100644 --- a/Documentation/devicetree/bindings/sound/apple,t6030-dpaudio.yaml +++ b/Documentation/devicetree/bindings/sound/apple,t6030-dpaudio.yaml @@ -28,6 +28,7 @@ select: - apple,t6041-dpaudio - apple,t6050-dpaudio - apple,t8140-dpaudio + - apple,t8152-dpaudio required: - compatible @@ -39,6 +40,7 @@ properties: - apple,t6041-dpaudio - apple,t6050-dpaudio - apple,t8140-dpaudio + - apple,t8152-dpaudio - const: apple,dpaudio dmas: From 12f9421106b1be10b05d14691f5b9b89bac4485e Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 06/15] dt-bindings: display: apple,t8152-dcp-iboot: allow audio ports Allow an optional ports/port@0 audio graph endpoint on T8152 iBoot DCP nodes so display audio controllers can link to their owning DCP. Signed-off-by: Thomas Glanzmann --- .../devicetree/bindings/display/apple,t8152-dcp-iboot.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml index b25cd3a74cfa0..e67895d83fd20 100644 --- a/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml +++ b/Documentation/devicetree/bindings/display/apple,t8152-dcp-iboot.yaml @@ -216,6 +216,13 @@ properties: ranges: true + ports: + $ref: /schemas/graph.yaml#/properties/ports + properties: + port@0: + $ref: /schemas/graph.yaml#/properties/port + description: Connection to the DisplayPort/HDMI audio interface. + patternProperties: "^usb-c@[0-9a-f]+$": type: object From d5974460bda269e718d81ef9b1ddf4c9b5cc02c9 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 07/15] drm/apple: t8152: fix Firmware 27 GetDriveSettings and retrain after EDID On T8152 Firmware 27, DPTX_APCALL_GET_DRIVE_SETTINGS places the lane count at offset +0 and the IOReturn status at offset +16 (swapped relative to SET), with lane entries starting at +32. Fix the reply marshalling and buffer-size check accordingly. Additionally, when atc_read_edid() borrows the crossbar for AUX0 on an active link, mark the port as needing a retrain and return KIO_RETURN_NOT_READY from GetDriveSettings until the firmware retrains and issues a fresh SET_DRIVE_SETTINGS (or deactivates the port). Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/t8152_atc.c | 8 ++++++- drivers/gpu/drm/apple/t8152_display.h | 2 ++ drivers/gpu/drm/apple/t8152_dptx.c | 33 +++++++++++++++++++-------- 3 files changed, 33 insertions(+), 10 deletions(-) diff --git a/drivers/gpu/drm/apple/t8152_atc.c b/drivers/gpu/drm/apple/t8152_atc.c index 4c2a5cd9ba1ba..33445c7fde0cf 100644 --- a/drivers/gpu/drm/apple/t8152_atc.c +++ b/drivers/gpu/drm/apple/t8152_atc.c @@ -635,8 +635,14 @@ static int atc_read_edid(struct t8152_display *disp, u8 *buf, size_t size) if (!ret) ret = t8152_aux_read_edid(disp, atc->aux, buf, size); atc_route_stop(disp, atc); - if (was_started) + if (was_started) { atc_route_start(disp, atc); + /* + * Switching the crossbar to AUX0 interrupted the live main + * link: ask the firmware to retrain it on the next link check. + */ + WRITE_ONCE(disp->port[0].needs_retrain, true); + } out: mutex_unlock(&atc_aux_lock); return ret; diff --git a/drivers/gpu/drm/apple/t8152_display.h b/drivers/gpu/drm/apple/t8152_display.h index 3cdf58c863422..a59e92e45b9a2 100644 --- a/drivers/gpu/drm/apple/t8152_display.h +++ b/drivers/gpu/drm/apple/t8152_display.h @@ -66,6 +66,8 @@ struct t8152_port { /* the drive settings the firmware set last, for GET_DRIVE_SETTINGS */ struct t8152_drive_settings drive[4]; u32 drive_count; + /* crossbar was borrowed (e.g. for EDID) after link training; force retrain */ + bool needs_retrain; }; /* An AP DisplayPort AUX controller, and its output select */ diff --git a/drivers/gpu/drm/apple/t8152_dptx.c b/drivers/gpu/drm/apple/t8152_dptx.c index 84523670c43ab..35c1273628e29 100644 --- a/drivers/gpu/drm/apple/t8152_dptx.c +++ b/drivers/gpu/drm/apple/t8152_dptx.c @@ -78,6 +78,7 @@ static u32 dptx_apcall(struct t8152_display *disp, struct t8152_port *port, if (phy->deactivate(disp)) return KIO_RETURN_ERROR; port->link_rate = 0; + WRITE_ONCE(port->needs_retrain, false); return 0; case DPTX_APCALL_WILL_CHANGE_LINKG_CONFIG: case DPTX_APCALL_DID_CHANGE_LINK_CONFIG: @@ -142,22 +143,34 @@ static u32 dptx_apcall(struct t8152_display *disp, struct t8152_port *port, return KIO_RETURN_ERROR; memcpy(port->drive, settings, arg * sizeof(settings[0])); port->drive_count = arg; + WRITE_ONCE(port->needs_retrain, false); return 0; } - case DPTX_APCALL_GET_DRIVE_SETTINGS: + case DPTX_APCALL_GET_DRIVE_SETTINGS: { + u32 count; + /* - * The firmware reads back what it set during link training; an - * unsupported reply here was followed by a firmware crash. - * Same layout as SET: count at 16, settings from 32. + * Firmware 27 GetDriveSettings carries the lane count at +0 and + * the IOReturn status at +16 (swapped relative to SET), with + * the lane entries from +32. */ if (group != 1) return KIO_RETURN_UNSUPPORTED; - if (reply_size < 32 + port->drive_count * sizeof(port->drive[0])) + if (data_size < 32 || reply_size < 32) return KIO_RETURN_BAD_ARG; - put_unaligned_le32(port->drive_count, reply + 16); + if (READ_ONCE(port->needs_retrain)) { + put_unaligned_le32(0, reply); + return KIO_RETURN_NOT_READY; + } + count = get_unaligned_le32(data); + if (count > 4 || reply_size < 32 + count * sizeof(port->drive[0])) + return KIO_RETURN_BAD_ARG; + memset(reply + 32, 0, reply_size - 32); + put_unaligned_le32(count, reply); memcpy(reply + 32, port->drive, - port->drive_count * sizeof(port->drive[0])); + min(count, port->drive_count) * sizeof(port->drive[0])); return 0; + } case DPTX_APCALL_SET_DOWN_SPREAD: if (data_size < 17) return KIO_RETURN_BAD_ARG; @@ -206,12 +219,14 @@ static int t8152_dptx_call(struct apple_epic_service *service, u16 group, struct apple_dcp *dcp = service->ep->dcp; struct dptx_port *dptx = service->cookie; struct t8152_display *disp = READ_ONCE(dcp->t8152); + bool status_at_16 = group == 1 && + command == DPTX_APCALL_GET_DRIVE_SETTINGS; u32 status; dev_dbg(dcp->dev, "DPTX: port %d group %u command %u size %zu\n", dptx ? (int)dptx->unit : -1, group, command, size); /* The firmware sizes the reply; it has to hold the status word. */ - if (room < sizeof(__le32)) { + if (room < (status_at_16 ? 20 : sizeof(__le32))) { dev_warn_ratelimited(dcp->dev, "DPTX: group %u command %u reply of %zu bytes has no room for its status\n", group, command, room); @@ -226,7 +241,7 @@ static int t8152_dptx_call(struct apple_epic_service *service, u16 group, if (status) dev_dbg(dcp->dev, "DPTX: group %u command %u -> %#x\n", group, command, status); - put_unaligned_le32(status, reply); + put_unaligned_le32(status, reply + (status_at_16 ? 16 : 0)); return 0; } From 476e9d6d44224d72c9a881ddfd546ac805942464 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 08/15] drm/apple: enable DisplayPort/HDMI audio on T8152 iBoot DCPs Wire up the AV EPIC endpoint and audio server ops for DCP_FIRMWARE_IBOOT so T8152 iBoot DCP instances expose DisplayPort and HDMI audio through the existing dcp-dp-audio ASoC driver. - Bring up avep_init() and av_iboot_ops for DCP_FIRMWARE_IBOOT. - Check the Firmware 27 IOReturn status at reply + 48 in dcp_audiosrv_link(). - Support standalone dcp-dp-audio probing/binding via av_audiosrv_ready(), av_attach_audio_dev(), and av_detach_audio_dev() when the audio controller is described as a separate device tree node linked through the OF graph. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 61 ++++++++++- drivers/gpu/drm/apple/av.c | 161 ++++++++++++++++++++++++++-- drivers/gpu/drm/apple/av.h | 11 ++ drivers/gpu/drm/apple/iboot_drm.c | 15 ++- drivers/gpu/drm/apple/iomfb_iboot.c | 9 ++ 5 files changed, 242 insertions(+), 15 deletions(-) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index d2333b9340b32..0eae3b207ce50 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -149,6 +149,8 @@ struct dcp_audio { #endif /* Runtime PM was enabled at bind, see dcpaud_hold_link_locked() */ bool rpm_enabled; + /* Bound directly without a display-subsystem component master (T8152 iBoot) */ + bool standalone; }; /* Native external audio service (DRM_APPLE_DCP_T6030_AUDIO only). */ @@ -2026,7 +2028,7 @@ void dcpaud_disconnect(struct platform_device *pdev) #endif } -static int dcpaud_comp_bind(struct device *dev, struct device *main, void *data) +static int dcpaud_bind(struct device *dev) { struct dcp_audio *dcpaud = dev_get_drvdata(dev); struct device_node *endpoint, *dcp_node = NULL; @@ -2118,8 +2120,12 @@ static int dcpaud_comp_bind(struct device *dev, struct device *main, void *data) return 0; } -static void dcpaud_comp_unbind(struct device *dev, struct device *main, - void *data) +static int dcpaud_comp_bind(struct device *dev, struct device *main, void *data) +{ + return dcpaud_bind(dev); +} + +static void dcpaud_unbind(struct device *dev) { struct dcp_audio *dcpaud = dev_get_drvdata(dev); @@ -2165,6 +2171,12 @@ static void dcpaud_comp_unbind(struct device *dev, struct device *main, device_link_del(dcpaud->dma_link); } +static void dcpaud_comp_unbind(struct device *dev, struct device *main, + void *data) +{ + dcpaud_unbind(dev); +} + static const struct component_ops dcpaud_comp_ops = { .bind = dcpaud_comp_bind, .unbind = dcpaud_comp_unbind, @@ -2177,6 +2189,7 @@ static void dcpaud_free_elements(void *elements) static int dcpaud_probe(struct platform_device *pdev) { + struct device_node *endpoint, *dcp_node = NULL; struct dcp_audio *dcpaud; int ret; @@ -2209,16 +2222,58 @@ static int dcpaud_probe(struct platform_device *pdev) INIT_DELAYED_WORK(&dcpaud->void_work, dcpaud_void_work); platform_set_drvdata(pdev, dcpaud); + endpoint = of_graph_get_endpoint_by_regs(pdev->dev.of_node, 0, 0); + if (endpoint) { + dcp_node = of_graph_get_remote_port_parent(endpoint); + of_node_put(endpoint); + } + if (dcp_node && of_device_is_compatible(dcp_node, "apple,t8152-dcp-iboot")) { + struct platform_device *dcp_pdev = of_find_device_by_node(dcp_node); + + of_node_put(dcp_node); + if (!dcp_pdev) + return -EPROBE_DEFER; + if (!av_audiosrv_ready(&dcp_pdev->dev)) { + put_device(&dcp_pdev->dev); + return -EPROBE_DEFER; + } + dcpaud->standalone = true; + ret = dcpaud_bind(&pdev->dev); + if (!ret) + av_attach_audio_dev(&dcp_pdev->dev, pdev); + put_device(&dcp_pdev->dev); + return ret; + } + of_node_put(dcp_node); + return component_add(&pdev->dev, &dcpaud_comp_ops); } static void dcpaud_remove(struct platform_device *pdev) { + struct dcp_audio *dcpaud = platform_get_drvdata(pdev); + + if (dcpaud->standalone) { + if (dcpaud->dcp_dev) + av_detach_audio_dev(dcpaud->dcp_dev, pdev); + dcpaud_unbind(&pdev->dev); + dcpaud->standalone = false; + return; + } component_del(&pdev->dev, &dcpaud_comp_ops); } static void dcpaud_shutdown(struct platform_device *pdev) { + struct dcp_audio *dcpaud = platform_get_drvdata(pdev); + + if (dcpaud->standalone) { + if (dcpaud->dcp_dev) + av_detach_audio_dev(dcpaud->dcp_dev, pdev); + dcpaud_unbind(&pdev->dev); + dcpaud->standalone = false; + return; + } component_del(&pdev->dev, &dcpaud_comp_ops); } diff --git a/drivers/gpu/drm/apple/av.c b/drivers/gpu/drm/apple/av.c index 3496f5ccdfb50..7b14e7d4f8e30 100644 --- a/drivers/gpu/drm/apple/av.c +++ b/drivers/gpu/drm/apple/av.c @@ -22,6 +22,7 @@ #include "cec.h" #include "dcp.h" #include "dcp-internal.h" +#include "iomfb_iboot.h" struct dcp_av_audio_cmds { /* commands in group 0*/ @@ -333,9 +334,16 @@ static bool av_desktop_audio_role(struct apple_dcp *dcp) dcp_is_v27_external(dcp); } +static bool dcp_is_iboot_audio(const struct apple_dcp *dcp) +{ + return dcp && dcp->fw_compat == DCP_FIRMWARE_IBOOT; +} + bool dcp_audiosrv_link_by_format(struct device *dev) { - return dcp_is_v27_external(dev_get_drvdata(dev)); + struct apple_dcp *dcp = dev_get_drvdata(dev); + + return dcp_is_v27_external(dcp) || dcp_is_iboot_audio(dcp); } /* Native audio links are selected from the firmware role, before service start. */ @@ -343,7 +351,8 @@ bool dcp_audiosrv_native_link(struct device *dev) { struct apple_dcp *dcp = dev_get_drvdata(dev); - return dcp_is_v14_7_external(dcp) || av_desktop_audio_role(dcp); + return dcp_is_v14_7_external(dcp) || av_desktop_audio_role(dcp) || + dcp_is_iboot_audio(dcp); } /* The 14.7 external role's audio service calls; KUnit stubs them. */ @@ -617,7 +626,7 @@ int dcp_audiosrv_link(struct device *dev, enum dcp_audio_link op, return 0; static_assert(sizeof(*cookie) == DCP_SOUND_COOKIE_SIZE_V14_7); static_assert(sizeof(struct dcp_audio_link_format) <= sizeof(*cookie)); - by_format = dcp_is_v27_external(dcp); + by_format = dcp_is_v27_external(dcp) || dcp_is_iboot_audio(dcp); if (!by_format) memcpy(body, cookie, sizeof(*cookie)); else if (op != DCP_AUDIO_LINK_QUERY) @@ -636,18 +645,34 @@ int dcp_audiosrv_link(struct device *dev, enum dcp_audio_link op, /* A link ends on the instance it was prepared on; one gone took it along. */ if (op != DCP_AUDIO_LINK_PREPARE && asrv->link_gen != asrv->open_gen) return -ENODEV; + memset(reply, 0, sizeof(reply)); ret = av_audiosrv_call(asrv->open_srv, command, body, sizeof(body), 0, reply, sizeof(reply)); if (ret) return ret; - status = get_unaligned_le32(by_format ? reply : reply + 48); if (op == DCP_AUDIO_LINK_QUERY) { + status = get_unaligned_le32(by_format ? reply : reply + 48); dev_dbg(dev, "audiosrv: link state %#x\n", status); return 0; } - if (by_format ? status != 1 : status) { - dev_err(dev, "audiosrv: link method %u answered %#x\n", command, status); - return -EIO; + /* + * iBoot firmware echoes the 48-byte format header at +0 and + * returns the IOReturn status at +48. + */ + if (dcp_is_iboot_audio(dcp)) { + status = get_unaligned_le32(reply + 48); + if (status) { + dev_err(dev, "audiosrv: link method %u answered %#x\n", + command, status); + return -EIO; + } + } else { + status = get_unaligned_le32(by_format ? reply : reply + 48); + if (by_format ? status != 1 : status) { + dev_err(dev, "audiosrv: link method %u answered %#x\n", + command, status); + return -EIO; + } } if (op == DCP_AUDIO_LINK_PREPARE) { if (!av_audiosrv_open_published(asrv)) @@ -845,6 +870,17 @@ int dcp_audio_sink_eld(struct device *dev, u8 *eld, size_t size) dcp = dev_get_drvdata(dev); if (!dcp) return -ENODEV; +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8152) + if (dcp->fw_compat == DCP_FIRMWARE_IBOOT) { + struct dcp_iboot *ib = READ_ONCE(dcp->iboot); + + if (!ib) + return -ENODEV; + guard(mutex)(&ib->connector.eld_mutex); + memcpy(eld, ib->connector.eld, min(size, sizeof(ib->connector.eld))); + return 0; + } +#endif connector = READ_ONCE(dcp->connector); if (!connector) return -ENODEV; @@ -932,7 +968,8 @@ static void av_video_init(struct apple_epic_service *service, const char *name, struct audiosrv_data *asrv = service->ep->dcp->audiosrv; struct apple_epic_service *old; - if (!asrv || !dcp_is_v27_external(service->ep->dcp)) + if (!asrv || (!dcp_is_v27_external(service->ep->dcp) && + !dcp_is_iboot_audio(service->ep->dcp))) return; service = afk_service_get(service); if (!service) @@ -1103,6 +1140,58 @@ static const struct apple_epic_service_ops avep_ops[] = { {} }; +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) +enum av_iboot_service_kind { + AV_IBOOT_NONE = 0, + AV_IBOOT_AUDIO = 1, + AV_IBOOT_VIDEO = 2, +}; + +static void av_iboot_init(struct apple_epic_service *service, const char *name, + const char *class, s64 unit) +{ + if (name && strstr(name, "dcpav-audio-interface")) { + service->cookie = (void *)AV_IBOOT_AUDIO; + av_audiosrv_init(service, name, class, unit); + } else if (name && strstr(name, "dcpav-video-interface")) { + struct dcp_iboot *ib = READ_ONCE(service->ep->dcp->iboot); + + service->cookie = (void *)AV_IBOOT_VIDEO; + av_video_init(service, name, class, unit); + if (ib) + dcp_iboot_av_started(ib); + } else { + service->cookie = (void *)AV_IBOOT_NONE; + } +} + +static int av_iboot_report(struct apple_epic_service *service, u32 idx, + const void *data, size_t data_size) +{ + if (service->cookie == (void *)AV_IBOOT_AUDIO) + return av_audiosrv_report(service, idx, data, data_size); + return 0; +} + +static void av_iboot_teardown(struct apple_epic_service *service) +{ + if (service->cookie == (void *)AV_IBOOT_AUDIO) + av_audiosrv_teardown(service); + else if (service->cookie == (void *)AV_IBOOT_VIDEO) + av_video_teardown(service); + else + afk_service_disable(service); +} + +static const struct apple_epic_service_ops av_iboot_ops = { + .name = "dcpav-iboot", + .reusable = true, + .init = av_iboot_init, + .report = av_iboot_report, + .teardown = av_iboot_teardown, +}; +#endif + void av_audio_sink_changed(struct apple_dcp *dcp) { struct audiosrv_data *asrv = dcp->audiosrv; @@ -1164,7 +1253,7 @@ void av_service_connect(struct apple_dcp *dcp) if (dcp_audiosrv_native_link(dcp->dev)) { if (dcp_is_v14_7_external(dcp) && !iomfb_v14_7_external_powered(dcp)) goto out; - if (dcp_is_v27_external(dcp)) { + if (dcp_is_v27_external(dcp) || dcp_is_iboot_audio(dcp)) { u64 gen; scoped_guard(rwsem_read, &asrv->srv_rwsem) @@ -1521,6 +1610,42 @@ void av_audiosrv_reports_restart(struct apple_dcp *dcp) up_write(&asrv->srv_rwsem); } +bool av_audiosrv_ready(struct device *dcp_dev) +{ + struct apple_dcp *dcp = dcp_dev ? dev_get_drvdata(dcp_dev) : NULL; + + return dcp && READ_ONCE(dcp->audiosrv); +} + +void av_attach_audio_dev(struct device *dcp_dev, struct platform_device *audio_pdev) +{ + struct apple_dcp *dcp = dcp_dev ? dev_get_drvdata(dcp_dev) : NULL; + struct audiosrv_data *asrv = dcp ? READ_ONCE(dcp->audiosrv) : NULL; + bool plugged; + + if (!asrv) + return; + scoped_guard(mutex, &asrv->plug_lock) { + asrv->audio_dev = audio_pdev; + plugged = asrv->plugged; + } + if (plugged) + av_service_connect(dcp); +} + +void av_detach_audio_dev(struct device *dcp_dev, struct platform_device *audio_pdev) +{ + struct apple_dcp *dcp = dcp_dev ? dev_get_drvdata(dcp_dev) : NULL; + struct audiosrv_data *asrv = dcp ? READ_ONCE(dcp->audiosrv) : NULL; + + if (!asrv) + return; + scoped_guard(mutex, &asrv->plug_lock) { + if (asrv->audio_dev == audio_pdev) + asrv->audio_dev = NULL; + } +} + int avep_init(struct apple_dcp *dcp) { struct audiosrv_data *audiosrv_data; @@ -1587,6 +1712,12 @@ int avep_init(struct apple_dcp *dcp) case DCP_FIRMWARE_V_27_0: audiosrv_data->cmds = dcp_av_audio_cmds_v27; break; +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) + case DCP_FIRMWARE_IBOOT: + audiosrv_data->cmds = dcp_av_audio_cmds_v27; + ops = NULL; + break; +#endif default: #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) /* @@ -1622,7 +1753,12 @@ int avep_init(struct apple_dcp *dcp) dev_info(dev, "No DP/HDMI audio device not ready\n"); return av_audiosrv_register_cleanup(dcp, audiosrv_data, NULL); } - dcp->audiosrv->audio_dev = audio_pdev; + /* + * iBoot DCPs have no component master, so the audio platform device + * attaches once its own probe finishes (av_attach_audio_dev()). + */ + if (dcp->fw_compat != DCP_FIRMWARE_IBOOT) + dcp->audiosrv->audio_dev = audio_pdev; device_link_add(&audio_pdev->dev, dev, DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME); @@ -1642,6 +1778,10 @@ int avep_init(struct apple_dcp *dcp) av_audiosrv_cleanup(&audiosrv_data->cleanup); return ret; } +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) + if (dcp->fw_compat == DCP_FIRMWARE_IBOOT) + dcp->avep->unmatched_ops = &av_iboot_ops; +#endif /* Newer than afk_release_context, so owner work drains before RX dies. */ ret = av_audiosrv_register_cleanup(dcp, audiosrv_data, dcp->avep); if (ret) @@ -1650,6 +1790,7 @@ int avep_init(struct apple_dcp *dcp) /* afk_start waits for RX: publish the desktop route before starting. */ if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP) WRITE_ONCE(dcp->desktop->graph[av_endpoint - 0x20], dcp->avep); + WRITE_ONCE(dcp->avep, dcp->avep); ret = afk_start(dcp->avep); if (ret) av_audiosrv_cleanup(&audiosrv_data->cleanup); diff --git a/drivers/gpu/drm/apple/av.h b/drivers/gpu/drm/apple/av.h index c41a853a57382..fbfb1243cc27e 100644 --- a/drivers/gpu/drm/apple/av.h +++ b/drivers/gpu/drm/apple/av.h @@ -3,6 +3,9 @@ #include "parser.h" +struct device; +struct platform_device; + //int avep_audiosrv_startlink(struct apple_dcp *dcp, struct dcp_sound_cookie *cookie); //int avep_audiosrv_stoplink(struct apple_dcp *dcp); @@ -18,6 +21,9 @@ void av_audio_sink_changed(struct apple_dcp *dcp); void av_audiosrv_quiesce(struct apple_dcp *dcp); /* Pair of av_audiosrv_quiesce after a later successful bind. */ void av_audiosrv_reports_restart(struct apple_dcp *dcp); +bool av_audiosrv_ready(struct device *dcp_dev); +void av_attach_audio_dev(struct device *dcp_dev, struct platform_device *audio_pdev); +void av_detach_audio_dev(struct device *dcp_dev, struct platform_device *audio_pdev); #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) /* Before the display's mode is set, see dcpaud_before_modeset(). */ void av_audio_before_modeset(struct apple_dcp *dcp); @@ -30,6 +36,11 @@ static inline void av_service_disconnect(struct apple_dcp *dcp) { } static inline void av_audio_sink_changed(struct apple_dcp *dcp) { } static inline void av_audiosrv_quiesce(struct apple_dcp *dcp) { } static inline void av_audiosrv_reports_restart(struct apple_dcp *dcp) { } +static inline bool av_audiosrv_ready(struct device *dcp_dev) { return false; } +static inline void av_attach_audio_dev(struct device *dcp_dev, + struct platform_device *audio_pdev) { } +static inline void av_detach_audio_dev(struct device *dcp_dev, + struct platform_device *audio_pdev) { } static inline void av_audio_before_modeset(struct apple_dcp *dcp) { } #endif diff --git a/drivers/gpu/drm/apple/iboot_drm.c b/drivers/gpu/drm/apple/iboot_drm.c index fbe43688c52e4..071f6f3041b20 100644 --- a/drivers/gpu/drm/apple/iboot_drm.c +++ b/drivers/gpu/drm/apple/iboot_drm.c @@ -38,6 +38,7 @@ #include #include +#include "av.h" #include "dcp-internal.h" #include "ibootep.h" #include "iomfb_iboot.h" @@ -262,6 +263,7 @@ static int iboot_connector_get_modes(struct drm_connector *connector) int count = 0; drm_edid_connector_update(connector, ib->edid); + av_audio_sink_changed(ib->dcp); if (ib->edid) return iboot_edid_get_modes(connector); @@ -460,6 +462,8 @@ iboot_connector_detect(struct drm_connector *connector, bool force) connector_status_disconnected; out: mutex_unlock(&ib->lock); + if (status == connector_status_disconnected) + av_service_disconnect(dcp); return status; } @@ -827,6 +831,7 @@ static void iboot_crtc_atomic_enable(struct drm_crtc *crtc, struct apple_dcp *dcp = ib->dcp; const struct iboot_timing_mode *t; const struct iboot_color_mode *c; + bool connect_audio = false; int ret; mutex_lock(&ib->lock); @@ -857,8 +862,10 @@ static void iboot_crtc_atomic_enable(struct drm_crtc *crtc, } ib->powered = true; } - if (ib->mode_set && !memcmp(t, &ib->cur_mode, sizeof(*t))) + if (ib->mode_set && !memcmp(t, &ib->cur_mode, sizeof(*t))) { + connect_audio = true; goto out; + } dev_info(dcp->dev, "modeset %ux%u@%d\n", le32_to_cpu(t->width), le32_to_cpu(t->height), iboot_refresh(t)); /* @@ -878,9 +885,12 @@ static void iboot_crtc_atomic_enable(struct drm_crtc *crtc, c = iboot_find_color(ib); if (!t || !c) goto out; - iboot_set_mode_locked(ib, t, c); + if (!iboot_set_mode_locked(ib, t, c)) + connect_audio = true; out: mutex_unlock(&ib->lock); + if (connect_audio) + av_service_connect(dcp); drm_crtc_vblank_on(crtc); } @@ -922,6 +932,7 @@ static void iboot_crtc_atomic_disable(struct drm_crtc *crtc, ib->mode_set = false; } mutex_unlock(&ib->lock); + av_service_disconnect(ib->dcp); drm_dev_exit(idx); } diff --git a/drivers/gpu/drm/apple/iomfb_iboot.c b/drivers/gpu/drm/apple/iomfb_iboot.c index d949ad9d769e8..bf246e7dc7b61 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.c +++ b/drivers/gpu/drm/apple/iomfb_iboot.c @@ -35,6 +35,7 @@ #include #include "afk.h" +#include "av.h" #include "dcp.h" #include "dcp-internal.h" #include "ibootep.h" @@ -74,6 +75,9 @@ static void dcp_iboot_rtk_recv(void *cookie, u8 endpoint, u64 message) case DPTX_ENDPOINT: ep = READ_ONCE(dcp->dptxep); break; + case AV_ENDPOINT: + ep = READ_ONCE(dcp->avep); + break; } if (IS_ERR_OR_NULL(ep)) { dev_dbg(dcp->dev, "message %#llx for idle endpoint %#x\n", @@ -610,6 +614,8 @@ static void dcp_iboot_detach(struct dcp_iboot *ib) WRITE_ONCE(dcp->quiescing, true); cancel_delayed_work_sync(&ib->av_work); dcp_iboot_kms_stop(ib); + av_audiosrv_quiesce(dcp); + afk_quiesce(dcp->avep); afk_quiesce(dcp->ibootep); afk_quiesce(dcp->dptx_controller_ep); afk_quiesce(dcp->dptxep); @@ -710,6 +716,9 @@ static int dcp_iboot_start(struct dcp_iboot *ib) ret = dcp_iboot_kms_init(ib); if (ret) return ret; + ret = avep_init(dcp); + if (ret) + dev_warn(dev, "DP/HDMI audio init failed: %d\n", ret); if (sink) { ret = dcp_iboot_set_boot_mode(ib); if (ret) From 65f2b05a38f523c291dac2bcc4b08ef1cf05e6a9 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 09:56:41 +0100 Subject: [PATCH 09/15] arm64: dts: apple: t8152-j873: enable DisplayPort and HDMI audio Switch the T8152 display isochronous DARTs to apple,t8152-disp-isoc-dart with their TLBI register windows, and add t8152-j873-dpaudio.dtsi (and include it from t8152-j873g.dts) enabling the display ADMACs, ADMAC control blocks, PMGR power states, isochronous DARTs, and DisplayPort audio controllers for disp0, dispext0, and dispext1. Signed-off-by: Thomas Glanzmann --- .../boot/dts/apple/t8152-j873-dpaudio.dtsi | 235 ++++++++++++++++++ arch/arm64/boot/dts/apple/t8152-j873g.dts | 1 + .../boot/dts/apple/t8152-peripherals.dtsi | 18 +- 3 files changed, 248 insertions(+), 6 deletions(-) create mode 100644 arch/arm64/boot/dts/apple/t8152-j873-dpaudio.dtsi diff --git a/arch/arm64/boot/dts/apple/t8152-j873-dpaudio.dtsi b/arch/arm64/boot/dts/apple/t8152-j873-dpaudio.dtsi new file mode 100644 index 0000000000000..ea103a7bb2e95 --- /dev/null +++ b/arch/arm64/boot/dts/apple/t8152-j873-dpaudio.dtsi @@ -0,0 +1,235 @@ +// SPDX-License-Identifier: GPL-2.0-only +/* + * J873g DisplayPort/HDMI audio: each display engine's dp-audio takes its + * samples from that engine's own self-actuated display ADMAC + * (admac-disp0 / admac-dispext0 / admac-dispext1, behind its unlocked + * Gen3 isochronous DART on SID 30, 1 TiB / 64 GiB DMA window), gated by + * its DISP*_ADMA power domain. + */ + +/ { + aliases { + admac-disp0-control = &admac_disp0_ced_ssw; + admac-dispext0-control = &admac_dispext0_ced_ssw; + admac-dispext1-control = &admac_dispext1_ced_ssw; + }; + + dpaudio0: audio-controller-0 { + compatible = "apple,t8152-dpaudio", "apple,dpaudio"; + dmas = <&admac_disp0 0>; + dma-names = "tx"; + power-domains = <&ps_disp_adma>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dpaudio0_dcp: endpoint { + remote-endpoint = <&dcp_iboot_audio>; + }; + }; + }; + }; + + dpaudio1: audio-controller-1 { + compatible = "apple,t8152-dpaudio", "apple,dpaudio"; + dmas = <&admac_dispext0 0>; + dma-names = "tx"; + power-domains = <&ps_dispext0_adma>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dpaudio1_dcpext0: endpoint { + remote-endpoint = <&dcpext_iboot_audio>; + }; + }; + }; + }; + + dpaudio2: audio-controller-2 { + compatible = "apple,t8152-dpaudio", "apple,dpaudio"; + dmas = <&admac_dispext1 0>; + dma-names = "tx"; + power-domains = <&ps_dispext1_adma>; + status = "okay"; + + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dpaudio2_dcpext1: endpoint { + remote-endpoint = <&dcpext1_iboot_audio>; + }; + }; + }; + }; +}; + +&pmgr { + ps_dispext1_adma: power-controller@a40 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0xa40 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "dispext1_adma"; + }; + + ps_dispext0_adma: power-controller@da0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0xda0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "dispext0_adma"; + }; + + ps_disp_adma: power-controller@141c0 { + compatible = "apple,t8152-pmgr-pwrstate", + "apple,t8103-pmgr-pwrstate"; + reg = <0x141c0 4>; + #power-domain-cells = <0>; + #reset-cells = <0>; + label = "disp_adma"; + }; +}; + +&disp0_isoc_dart { + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + power-domains = <&ps_disp_adma>; + status = "okay"; +}; + +&dispext0_isoc_dart { + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + power-domains = <&ps_dispext0_adma>; + status = "okay"; +}; + +&dispext1_isoc_dart { + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + power-domains = <&ps_dispext1_adma>; + status = "okay"; +}; + +/ { + soc { + admac_disp0: dma-controller@286140000 { + compatible = "apple,t8152-display-admac"; + reg = <0x2 0x86140000 0x0 0x44000>; + dma-channels = <1>; + interrupts-extended = <&aic AIC_IRQ 906 IRQ_TYPE_LEVEL_HIGH>, + <0>, <0>, <0>; + iommus = <&disp0_isoc_dart 30>; + #dma-cells = <1>; + power-domains = <&ps_disp_adma>; + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + apple,admac-control = <&admac_disp0_ced_ssw>; + status = "okay"; + }; + + admac_disp0_ced_ssw: dma-control@2862ec000 { + compatible = "apple,t8152-admac-control", "apple,admac-control"; + reg = <0x2 0x862ec000 0x0 0x4000>, + <0x2 0x861e0000 0x0 0x4000>; + interrupts = ; + status = "disabled"; + }; + + admac_dispext0: dma-controller@32a140000 { + compatible = "apple,t8152-display-admac"; + reg = <0x3 0x2a140000 0x0 0x44000>; + dma-channels = <1>; + interrupts-extended = <&aic AIC_IRQ 1044 IRQ_TYPE_LEVEL_HIGH>, + <0>, <0>, <0>; + iommus = <&dispext0_isoc_dart 30>; + #dma-cells = <1>; + power-domains = <&ps_dispext0_adma>; + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + apple,admac-control = <&admac_dispext0_ced_ssw>; + status = "okay"; + }; + + admac_dispext0_ced_ssw: dma-control@32a2ec000 { + compatible = "apple,t8152-admac-control", "apple,admac-control"; + reg = <0x3 0x2a2ec000 0x0 0x4000>, + <0x3 0x2a1e0000 0x0 0x4000>; + interrupts = ; + status = "disabled"; + }; + + admac_dispext1: dma-controller@502140000 { + compatible = "apple,t8152-display-admac"; + reg = <0x5 0x02140000 0x0 0x44000>; + dma-channels = <1>; + interrupts-extended = <&aic AIC_IRQ 1120 IRQ_TYPE_LEVEL_HIGH>, + <0>, <0>, <0>; + iommus = <&dispext1_isoc_dart 30>; + #dma-cells = <1>; + power-domains = <&ps_dispext1_adma>; + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; + apple,admac-control = <&admac_dispext1_ced_ssw>; + status = "okay"; + }; + + admac_dispext1_ced_ssw: dma-control@5022ec000 { + compatible = "apple,t8152-admac-control", "apple,admac-control"; + reg = <0x5 0x022ec000 0x0 0x4000>, + <0x5 0x021e0000 0x0 0x4000>; + interrupts = ; + status = "disabled"; + }; + }; +}; + +&dcp_iboot { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dcp_iboot_audio: endpoint { + remote-endpoint = <&dpaudio0_dcp>; + }; + }; + }; +}; + +&dcpext_iboot { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dcpext_iboot_audio: endpoint { + remote-endpoint = <&dpaudio1_dcpext0>; + }; + }; + }; +}; + +&dcpext1_iboot { + ports { + #address-cells = <1>; + #size-cells = <0>; + + port@0 { + reg = <0>; + dcpext1_iboot_audio: endpoint { + remote-endpoint = <&dpaudio2_dcpext1>; + }; + }; + }; +}; diff --git a/arch/arm64/boot/dts/apple/t8152-j873g.dts b/arch/arm64/boot/dts/apple/t8152-j873g.dts index b6743791d76ac..a47a77cb62914 100644 --- a/arch/arm64/boot/dts/apple/t8152-j873g.dts +++ b/arch/arm64/boot/dts/apple/t8152-j873g.dts @@ -672,6 +672,7 @@ #include "t8152-j873-ethernet.dtsi" #include "t8152-j873-audio.dtsi" #include "t8152-j873-dcp.dtsi" +#include "t8152-j873-dpaudio.dtsi" #include "t8152-j873-avd.dtsi" #include "t8152-j873-thermal.dtsi" #include "t8152-j873-usb4.dtsi" diff --git a/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi b/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi index d1dcb53240fc1..884d1b7e26200 100644 --- a/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi +++ b/arch/arm64/boot/dts/apple/t8152-peripherals.dtsi @@ -143,8 +143,10 @@ }; disp0_isoc_dart: iommu@2861c0000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x2 0x861c0000 0x0 0x20000>; + compatible = "apple,t8152-disp-isoc-dart"; + reg = <0x2 0x861c0000 0x0 0x20000>, + <0x2 0x00000400 0x0 0x10>; + reg-names = "dart", "tlbi"; interrupts = ; #iommu-cells = <1>; status = "disabled"; @@ -171,8 +173,10 @@ }; dispext0_isoc_dart: iommu@32a1c0000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x3 0x2a1c0000 0x0 0x20000>; + compatible = "apple,t8152-disp-isoc-dart"; + reg = <0x3 0x2a1c0000 0x0 0x20000>, + <0x2 0x00000480 0x0 0x10>; + reg-names = "dart", "tlbi"; interrupts = ; #iommu-cells = <1>; status = "disabled"; @@ -196,8 +200,10 @@ }; dispext1_isoc_dart: iommu@5021c0000 { - compatible = "apple,t8152-dart", "apple,t8110-dart"; - reg = <0x5 0x21c0000 0x0 0x20000>; + compatible = "apple,t8152-disp-isoc-dart"; + reg = <0x5 0x21c0000 0x0 0x20000>, + <0x2 0x00000500 0x0 0x10>; + reg-names = "dart", "tlbi"; interrupts = ; #iommu-cells = <1>; status = "disabled"; From 4b986e3c20f3a56fedc6b13799237b1482c8e78f Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 12:16:06 +0100 Subject: [PATCH 10/15] drm/apple: fix T8152 audio build guards and standalone probe/unbind races Address review blockers on the T8152 iBoot DP/HDMI audio path: - Add a static inline dcp_iboot_av_started() stub in iomfb_iboot.h and guard av_iboot_ops / DCP_FIRMWARE_IBOOT in av.c on both CONFIG_DRM_APPLE_DCP_T6030_AUDIO and CONFIG_DRM_APPLE_DCP_T8152 so non-T8152 builds compile cleanly. - In standalone dcpaud_probe(), add a managed consumer link (DL_FLAG_AUTOREMOVE_CONSUMER | DL_FLAG_PM_RUNTIME) to dcp_pdev and skip the stateless link in avep_init() for DCP_FIRMWARE_IBOOT so dpaudio always unbinds before dcp_iboot. - Keep avep local in avep_init() until unmatched_ops, debugfs_entry, and cleanup registration complete, publish dcp->avep with release semantics before afk_start(), and expose av_audiosrv_ready() only after afk_start() succeeds. - Propagate bind/deferral errors (e.g. -EPROBE_DEFER when admac_disp* has not probed yet) from dcpaud_bind() in standalone mode and release dma_link on failure instead of attaching a cardless audio device. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 37 +++++++++++++--- drivers/gpu/drm/apple/av.c | 67 ++++++++++++++++++----------- drivers/gpu/drm/apple/iomfb_iboot.c | 3 +- drivers/gpu/drm/apple/iomfb_iboot.h | 1 + 4 files changed, 78 insertions(+), 30 deletions(-) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index 0eae3b207ce50..9c5f93ed5bae2 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -2054,6 +2054,7 @@ static int dcpaud_bind(struct device *dev) if (!dcp_node || !of_device_is_available(dcp_node)) { of_node_put(dcp_node); dev_info(dev, "No audio support\n"); + ret = -ENODEV; goto rpm_put; } dcpaud_port_names(dcpaud, dcp_node); @@ -2061,19 +2062,25 @@ static int dcpaud_bind(struct device *dev) index = of_property_match_string(dev->of_node, "dma-names", "tx"); if (index < 0) { dev_err(dev, "No dma-names property\n"); + of_node_put(dcp_node); + ret = index; goto rpm_put; } if (of_parse_phandle_with_args(dev->of_node, "dmas", "#dma-cells", index, &dma_spec) || !dma_spec.np) { dev_err(dev, "Failed to parse dmas property\n"); + of_node_put(dcp_node); + ret = -ENODEV; goto rpm_put; } dcp_pdev = of_find_device_by_node(dcp_node); of_node_put(dcp_node); if (!dcp_pdev) { + of_node_put(dma_spec.np); dev_info(dev, "No DP/HDMI audio device, dcp not ready\n"); + ret = -EPROBE_DEFER; goto rpm_put; } dcpaud->dcp_dev = &dcp_pdev->dev; @@ -2088,6 +2095,7 @@ static int dcpaud_bind(struct device *dev) of_node_put(dma_spec.np); if (!dma_pdev) { dev_info(dev, "No DMA device\n"); + ret = -EPROBE_DEFER; goto rpm_put; } dcpaud->dma_dev = &dma_pdev->dev; @@ -2097,7 +2105,11 @@ static int dcpaud_bind(struct device *dev) DL_FLAG_RPM_ACTIVE | DL_FLAG_STATELESS); - /* ignore errors to prevent audio issues affecting the display side */ + /* + * Component-bound audio ignores errors so audio issues do not fail + * display bring-up; standalone audio propagates them (including + * -EPROBE_DEFER when the display ADMAC has not probed yet). + */ ret = dcpaud_init_snd_card(dcpaud); if (!ret) { @@ -2112,12 +2124,15 @@ static int dcpaud_bind(struct device *dev) DCPAUD_ELEMENTS_MAXSIZE); dcpaud_expose_debugfs_blob(dcpaud, "product_attrs", dcpaud->productattrs, DCPAUD_PRODUCTATTRS_MAXSIZE); + } else if (dcpaud->standalone && dcpaud->dma_link) { + device_link_del(dcpaud->dma_link); + dcpaud->dma_link = NULL; } rpm_put: pm_runtime_put(dev); - return 0; + return dcpaud->standalone ? ret : 0; } static int dcpaud_comp_bind(struct device *dev, struct device *main, void *data) @@ -2229,20 +2244,32 @@ static int dcpaud_probe(struct platform_device *pdev) } if (dcp_node && of_device_is_compatible(dcp_node, "apple,t8152-dcp-iboot")) { struct platform_device *dcp_pdev = of_find_device_by_node(dcp_node); + struct device_link *link; of_node_put(dcp_node); if (!dcp_pdev) return -EPROBE_DEFER; + link = device_link_add(&pdev->dev, &dcp_pdev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER | + DL_FLAG_PM_RUNTIME); + if (!link) { + put_device(&dcp_pdev->dev); + return -EPROBE_DEFER; + } if (!av_audiosrv_ready(&dcp_pdev->dev)) { put_device(&dcp_pdev->dev); return -EPROBE_DEFER; } dcpaud->standalone = true; ret = dcpaud_bind(&pdev->dev); - if (!ret) - av_attach_audio_dev(&dcp_pdev->dev, pdev); + if (ret) { + dcpaud->standalone = false; + put_device(&dcp_pdev->dev); + return ret; + } + av_attach_audio_dev(&dcp_pdev->dev, pdev); put_device(&dcp_pdev->dev); - return ret; + return 0; } of_node_put(dcp_node); diff --git a/drivers/gpu/drm/apple/av.c b/drivers/gpu/drm/apple/av.c index 7b14e7d4f8e30..1219fc9b590da 100644 --- a/drivers/gpu/drm/apple/av.c +++ b/drivers/gpu/drm/apple/av.c @@ -137,6 +137,7 @@ struct audiosrv_data { bool warned_get_elements; bool warned_get_product_attrs; bool is_open; + bool ready; /* * A classic Open the firmware refused (-EINVAL), judged once the * instance has had time to be replaced (av_work_open_check()). @@ -1140,7 +1141,7 @@ static const struct apple_epic_service_ops avep_ops[] = { {} }; -#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) && IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8152) enum av_iboot_service_kind { AV_IBOOT_NONE = 0, AV_IBOOT_AUDIO = 1, @@ -1549,6 +1550,8 @@ static void av_audiosrv_cleanup(void *data) struct apple_dcp *dcp = cleanup->dcp; /* Keep RX alive until any owner work that may make an RPC has left. */ + if (asrv) + WRITE_ONCE(asrv->ready, false); if (asrv && asrv->works_live) { av_audiosrv_block_owner_restart(asrv); av_audiosrv_drain_owner(asrv); @@ -1613,8 +1616,13 @@ void av_audiosrv_reports_restart(struct apple_dcp *dcp) bool av_audiosrv_ready(struct device *dcp_dev) { struct apple_dcp *dcp = dcp_dev ? dev_get_drvdata(dcp_dev) : NULL; + struct audiosrv_data *asrv; - return dcp && READ_ONCE(dcp->audiosrv); + /* Pairs with smp_store_release() in avep_init() after afk_start(). */ + asrv = dcp ? smp_load_acquire(&dcp->audiosrv) : NULL; + + /* Pairs with smp_store_release() in avep_init() once started. */ + return asrv && smp_load_acquire(&asrv->ready); } void av_attach_audio_dev(struct device *dcp_dev, struct platform_device *audio_pdev) @@ -1649,6 +1657,7 @@ void av_detach_audio_dev(struct device *dcp_dev, struct platform_device *audio_p int avep_init(struct apple_dcp *dcp) { struct audiosrv_data *audiosrv_data; + struct apple_dcp_afkep *avep; struct platform_device *audio_pdev; struct device *dev = dcp->dev; struct device_node *endpoint, *audio_node = NULL; @@ -1712,7 +1721,7 @@ int avep_init(struct apple_dcp *dcp) case DCP_FIRMWARE_V_27_0: audiosrv_data->cmds = dcp_av_audio_cmds_v27; break; -#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) && IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8152) case DCP_FIRMWARE_IBOOT: audiosrv_data->cmds = dcp_av_audio_cmds_v27; ops = NULL; @@ -1745,56 +1754,66 @@ int avep_init(struct apple_dcp *dcp) init_waitqueue_head(&audiosrv_data->gen_wq); #endif audiosrv_data->works_live = true; - dcp->audiosrv = audiosrv_data; audio_pdev = of_find_device_by_node(audio_node); of_node_put(audio_node); if (!audio_pdev) { dev_info(dev, "No DP/HDMI audio device not ready\n"); + dcp->audiosrv = audiosrv_data; return av_audiosrv_register_cleanup(dcp, audiosrv_data, NULL); } /* * iBoot DCPs have no component master, so the audio platform device - * attaches once its own probe finishes (av_attach_audio_dev()). + * creates its own managed consumer link and attaches once its own + * probe finishes (av_attach_audio_dev()). */ - if (dcp->fw_compat != DCP_FIRMWARE_IBOOT) - dcp->audiosrv->audio_dev = audio_pdev; - - device_link_add(&audio_pdev->dev, dev, - DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME); + if (dcp->fw_compat != DCP_FIRMWARE_IBOOT) { + audiosrv_data->audio_dev = audio_pdev; + device_link_add(&audio_pdev->dev, dev, + DL_FLAG_STATELESS | DL_FLAG_PM_RUNTIME); + } else { + put_device(&audio_pdev->dev); + } /* The J700 and T6050 DCPEXTs: start the audio endpoint only if the firmware has it. */ if ((dcp->hw.iomfb_method_profile == DCP_IOMFB_METHODS_H17P_EXTERNAL || dcp_is_v27_external(dcp)) && !apple_rtkit_has_endpoint(dcp->rtk, av_endpoint)) { dev_info(dev, "no DP/HDMI audio endpoint\n"); + dcp->audiosrv = audiosrv_data; return av_audiosrv_register_cleanup(dcp, audiosrv_data, NULL); } - dcp->avep = afk_init(dcp, av_endpoint, ops); - if (IS_ERR(dcp->avep)) { - ret = PTR_ERR(dcp->avep); - if (!av_audiosrv_register_cleanup(dcp, audiosrv_data, dcp->avep)) + avep = afk_init(dcp, av_endpoint, ops); + if (IS_ERR(avep)) { + ret = PTR_ERR(avep); + if (!av_audiosrv_register_cleanup(dcp, audiosrv_data, avep)) av_audiosrv_cleanup(&audiosrv_data->cleanup); return ret; } -#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) && IS_ENABLED(CONFIG_DRM_APPLE_DCP_T8152) if (dcp->fw_compat == DCP_FIRMWARE_IBOOT) - dcp->avep->unmatched_ops = &av_iboot_ops; + avep->unmatched_ops = &av_iboot_ops; #endif + avep->debugfs_entry = dcp->ep_debugfs[av_endpoint - 0x20]; /* Newer than afk_release_context, so owner work drains before RX dies. */ - ret = av_audiosrv_register_cleanup(dcp, audiosrv_data, dcp->avep); + ret = av_audiosrv_register_cleanup(dcp, audiosrv_data, avep); if (ret) return ret; - dcp->avep->debugfs_entry = dcp->ep_debugfs[av_endpoint - 0x20]; - /* afk_start waits for RX: publish the desktop route before starting. */ + /* afk_start waits for RX: publish audiosrv and avep once fully initialized. */ + smp_store_release(&dcp->audiosrv, audiosrv_data); if (dcp->fw_compat == DCP_FIRMWARE_V_26_6_DESKTOP) - WRITE_ONCE(dcp->desktop->graph[av_endpoint - 0x20], dcp->avep); - WRITE_ONCE(dcp->avep, dcp->avep); - ret = afk_start(dcp->avep); - if (ret) + WRITE_ONCE(dcp->desktop->graph[av_endpoint - 0x20], avep); + /* Pairs with smp_load_acquire() in dcp_iboot_rtk_recv(). */ + smp_store_release(&dcp->avep, avep); + ret = afk_start(avep); + if (ret) { av_audiosrv_cleanup(&audiosrv_data->cleanup); - return ret; + return ret; + } + /* Pairs with smp_load_acquire() in av_audiosrv_ready(). */ + smp_store_release(&audiosrv_data->ready, true); + return 0; } #if IS_ENABLED(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) && IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) diff --git a/drivers/gpu/drm/apple/iomfb_iboot.c b/drivers/gpu/drm/apple/iomfb_iboot.c index bf246e7dc7b61..d4a63eb6466ea 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.c +++ b/drivers/gpu/drm/apple/iomfb_iboot.c @@ -76,7 +76,8 @@ static void dcp_iboot_rtk_recv(void *cookie, u8 endpoint, u64 message) ep = READ_ONCE(dcp->dptxep); break; case AV_ENDPOINT: - ep = READ_ONCE(dcp->avep); + /* Pairs with smp_store_release() in avep_init(). */ + ep = smp_load_acquire(&dcp->avep); break; } if (IS_ERR_OR_NULL(ep)) { diff --git a/drivers/gpu/drm/apple/iomfb_iboot.h b/drivers/gpu/drm/apple/iomfb_iboot.h index bddeeedc198d5..bdfdb46b4fd8c 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.h +++ b/drivers/gpu/drm/apple/iomfb_iboot.h @@ -141,6 +141,7 @@ static inline void t8152_typec_register(struct device *dev) { } static inline void t8152_typec_unregister(void) { } static inline int dcp_iboot_probe(struct apple_dcp *dcp) { return -ENODEV; } static inline void dcp_iboot_remove(struct apple_dcp *dcp) { } +static inline void dcp_iboot_av_started(struct dcp_iboot *ib) { } #endif #endif From ed0fdb178ef52cdb88f5a31c7c2a9901201e6e26 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 14:48:42 +0100 Subject: [PATCH 11/15] drm/apple: gate iBoot avep_init on audio/hdmi_audio, fix ref leak, update selftest Address follow-up review and host-tests blockers on T8152 DP/HDMI audio: - Guard avep_init() in dcp_iboot_probe() on IS_ENABLED(CONFIG_DRM_APPLE_AUDIO) and hdmi_audio so audio-disabled T8152 builds link cleanly and appledrm.hdmi_audio=0 suppresses AV endpoint startup as on other DCPs. - Put the dcp_pdev (and dma_pdev) device references acquired by of_find_device_by_node() on deferred DMA lookup, standalone bind failure, and standalone unbind in audio.c. - Add the dcp_is_iboot_audio() stub in apple-dcp's cec-only-av-endpoint host selftest (tools/testing/selftests/drivers/gpu/apple-dcp/audio.py). Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 28 ++++++++++++++++--- drivers/gpu/drm/apple/iomfb_iboot.c | 10 +++++-- .../selftests/drivers/gpu/apple-dcp/audio.py | 1 + 3 files changed, 32 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index 9c5f93ed5bae2..367b0449a659f 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -2094,6 +2094,8 @@ static int dcpaud_bind(struct device *dev) dma_pdev = of_find_device_by_node(dma_spec.np); of_node_put(dma_spec.np); if (!dma_pdev) { + put_device(&dcp_pdev->dev); + dcpaud->dcp_dev = NULL; dev_info(dev, "No DMA device\n"); ret = -EPROBE_DEFER; goto rpm_put; @@ -2124,9 +2126,15 @@ static int dcpaud_bind(struct device *dev) DCPAUD_ELEMENTS_MAXSIZE); dcpaud_expose_debugfs_blob(dcpaud, "product_attrs", dcpaud->productattrs, DCPAUD_PRODUCTATTRS_MAXSIZE); - } else if (dcpaud->standalone && dcpaud->dma_link) { - device_link_del(dcpaud->dma_link); - dcpaud->dma_link = NULL; + } else if (dcpaud->standalone) { + if (dcpaud->dma_link) { + device_link_del(dcpaud->dma_link); + dcpaud->dma_link = NULL; + } + put_device(&dma_pdev->dev); + dcpaud->dma_dev = NULL; + put_device(&dcp_pdev->dev); + dcpaud->dcp_dev = NULL; } rpm_put: @@ -2182,8 +2190,20 @@ static void dcpaud_unbind(struct device *dev) } #endif - if (dcpaud->dma_link) + if (dcpaud->dma_link) { device_link_del(dcpaud->dma_link); + dcpaud->dma_link = NULL; + } + if (dcpaud->standalone) { + if (dcpaud->dma_dev) { + put_device(dcpaud->dma_dev); + dcpaud->dma_dev = NULL; + } + if (dcpaud->dcp_dev) { + put_device(dcpaud->dcp_dev); + dcpaud->dcp_dev = NULL; + } + } } static void dcpaud_comp_unbind(struct device *dev, struct device *main, diff --git a/drivers/gpu/drm/apple/iomfb_iboot.c b/drivers/gpu/drm/apple/iomfb_iboot.c index d4a63eb6466ea..7d1309b0ce866 100644 --- a/drivers/gpu/drm/apple/iomfb_iboot.c +++ b/drivers/gpu/drm/apple/iomfb_iboot.c @@ -717,9 +717,13 @@ static int dcp_iboot_start(struct dcp_iboot *ib) ret = dcp_iboot_kms_init(ib); if (ret) return ret; - ret = avep_init(dcp); - if (ret) - dev_warn(dev, "DP/HDMI audio init failed: %d\n", ret); +#if IS_ENABLED(CONFIG_DRM_APPLE_AUDIO) + if (hdmi_audio) { + ret = avep_init(dcp); + if (ret) + dev_warn(dev, "DP/HDMI audio init failed: %d\n", ret); + } +#endif if (sink) { ret = dcp_iboot_set_boot_mode(ib); if (ret) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py b/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py index d1d6e9f57c3e6..5cd6b5f6ada33 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py @@ -173,6 +173,7 @@ def cec_only_endpoint(root): static bool dcp_is_v14_7_external(const struct apple_dcp *dcp) {(void)dcp; return false;} static bool iomfb_v14_7_external_powered(struct apple_dcp *dcp) {(void)dcp; return true;} static bool dcp_is_v27_external(const struct apple_dcp *dcp) {(void)dcp; return v27;} +static bool dcp_is_iboot_audio(const struct apple_dcp *dcp) {(void)dcp; return false;} static void av_v27_start(struct apple_dcp *dcp, struct apple_epic_service *srv) {(void)dcp; assert(srv->pins); v27_starts++;} static void dcpaud_connect(struct platform_device *pdev, bool plugged) {(void)pdev; (void)plugged; connects++;} static void dcpaud_disconnect(struct platform_device *pdev) {(void)pdev; disconnects++;} From e4f3bebf77350af66fa92e5a9a5a99702172c67d Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 15:07:39 +0100 Subject: [PATCH 12/15] drm/apple: defer standalone dpaudio device_link_add until iBoot DCP binds On T8152/J873g, of_fwnode_add_links() creates a pair of SYNC_STATE_ONLY cycle links between each apple,dpaudio node and its apple,t8152-dcp-iboot peer over the OF graph endpoints. Because dcp_audio_register() runs before dcp_register() (and unused main DCP nodes stay unbound), calling device_link_add() in dcpaud_probe() while the DCP device is still unbound clears DL_FLAG_SYNC_STATE_ONLY on the persistent fw_devlink without turning it into an autoremove link. When dcpaud_probe() then defers on !av_audiosrv_ready(), __device_links_no_driver() triggers a WARN_ON for each dpaudio instance. Check device_is_bound() and av_audiosrv_ready() before adding the managed device link, and re-check av_audiosrv_ready() after adding it. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index 367b0449a659f..f7b5febc60f62 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -2269,14 +2269,22 @@ static int dcpaud_probe(struct platform_device *pdev) of_node_put(dcp_node); if (!dcp_pdev) return -EPROBE_DEFER; - link = device_link_add(&pdev->dev, &dcp_pdev->dev, - DL_FLAG_AUTOREMOVE_CONSUMER | - DL_FLAG_PM_RUNTIME); - if (!link) { + /* + * Wait until the iBoot DCP is bound and its AV audio service + * is live before upgrading the OF-graph fw_devlink cycle link; + * calling device_link_add() while the supplier is unbound + * clears DL_FLAG_SYNC_STATE_ONLY and triggers a WARN_ON in + * __device_links_no_driver() when probe defers. + */ + if (!device_is_bound(&dcp_pdev->dev) || + !av_audiosrv_ready(&dcp_pdev->dev)) { put_device(&dcp_pdev->dev); return -EPROBE_DEFER; } - if (!av_audiosrv_ready(&dcp_pdev->dev)) { + link = device_link_add(&pdev->dev, &dcp_pdev->dev, + DL_FLAG_AUTOREMOVE_CONSUMER | + DL_FLAG_PM_RUNTIME); + if (!link || !av_audiosrv_ready(&dcp_pdev->dev)) { put_device(&dcp_pdev->dev); return -EPROBE_DEFER; } From d3b3ade5d6ec2b9569e6802eecbe487629fcfa7b Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 16:49:34 +0100 Subject: [PATCH 13/15] drm/apple: quiesce standalone dpaudio teardown and exit on disabled audio Address follow-up review findings on standalone T8152 DP/HDMI audio: - Serialize outside-plug_lock AV audio callbacks (av_audio_before_modeset() and __av_service_disconnect()'s dcpaud_release_link()) with an rwsem in audiosrv_data so av_detach_audio_dev() drains both plug_lock and outside-plug_lock callbacks before standalone audio teardown proceeds. - Quiesce standalone dpaudio before dropping dma_link and supplier device references: dcpaud_remove() disconnects and waits for open PCM users via snd_card_free() and cancels void_work before releasing dma_link/dma_dev/ dcp_dev; dcpaud_shutdown() quiesces AV callbacks, disconnects the card, and stops void/native-link work without blocking on frozen userspace. - Exit dcpaud_probe() with -ENODEV instead of deferring indefinitely when appledrm.hdmi_audio=0 or when the bound iBoot DCP has no live AV audio service. Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 101 +++++++++++++++++------ drivers/gpu/drm/apple/av-lifetime-test.c | 3 + drivers/gpu/drm/apple/av-v14-test.c | 1 + drivers/gpu/drm/apple/av.c | 47 +++++++---- 4 files changed, 111 insertions(+), 41 deletions(-) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index f7b5febc60f62..e46ad064e5555 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -2194,16 +2194,51 @@ static void dcpaud_unbind(struct device *dev) device_link_del(dcpaud->dma_link); dcpaud->dma_link = NULL; } - if (dcpaud->standalone) { - if (dcpaud->dma_dev) { - put_device(dcpaud->dma_dev); - dcpaud->dma_dev = NULL; +} + +static void dcpaud_quiesce_standalone(struct dcp_audio *dcpaud, + struct platform_device *pdev, + bool wait_close) +{ + if (dcpaud->dcp_dev) + av_detach_audio_dev(dcpaud->dcp_dev, pdev); +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) + if (dcpaud->replaced_enabled) { + disable_work_sync(&dcpaud->replaced_work); + dcpaud->replaced_enabled = false; + } +#endif + if (dcpaud->card) { + if (wait_close) { + snd_card_free(dcpaud->card); + dcpaud->card = NULL; + } else { + snd_card_disconnect(dcpaud->card); } - if (dcpaud->dcp_dev) { - put_device(dcpaud->dcp_dev); - dcpaud->dcp_dev = NULL; + } + cancel_delayed_work_sync(&dcpaud->void_work); +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) + if (dcpaud->native_link) { + bool held; + + cancel_work_sync(&dcpaud->stale_work); + scoped_guard(mutex, &dcpaud->link_lock) { + held = dcpaud->silence_running; + if (held) + dcpaud_link_teardown(dcpaud); + else if (dcpaud->idle_set) + dcpaud_idle(dcpaud, false); + if (dcpaud->silence && dcpaud->idle_set) + dev_err(dcpaud->dev, "silence kept: its DMA channel did not stop\n"); + else if (dcpaud->silence) + dma_free_coherent(dcpaud->chan->device->dev, DCPAUD_SILENCE_BYTES, + dcpaud->silence, dcpaud->silence_addr); + dcpaud->silence = NULL; } + if (held && dcpaud->dcp_dev) + dcp_audiosrv_close(dcpaud->dcp_dev); } +#endif } static void dcpaud_comp_unbind(struct device *dev, struct device *main, @@ -2263,31 +2298,44 @@ static int dcpaud_probe(struct platform_device *pdev) of_node_put(endpoint); } if (dcp_node && of_device_is_compatible(dcp_node, "apple,t8152-dcp-iboot")) { - struct platform_device *dcp_pdev = of_find_device_by_node(dcp_node); + struct platform_device *dcp_pdev; struct device_link *link; + if (!hdmi_audio) { + of_node_put(dcp_node); + return -ENODEV; + } + dcp_pdev = of_find_device_by_node(dcp_node); of_node_put(dcp_node); if (!dcp_pdev) return -EPROBE_DEFER; /* - * Wait until the iBoot DCP is bound and its AV audio service - * is live before upgrading the OF-graph fw_devlink cycle link; - * calling device_link_add() while the supplier is unbound - * clears DL_FLAG_SYNC_STATE_ONLY and triggers a WARN_ON in - * __device_links_no_driver() when probe defers. + * Wait until the iBoot DCP is bound before upgrading the + * OF-graph fw_devlink cycle link; calling device_link_add() + * while the supplier is unbound clears DL_FLAG_SYNC_STATE_ONLY + * and triggers a WARN_ON in __device_links_no_driver() when + * probe defers. Once bound, an iBoot DCP without a live AV + * audio service will not gain one later, so exit cleanly. */ - if (!device_is_bound(&dcp_pdev->dev) || - !av_audiosrv_ready(&dcp_pdev->dev)) { + if (!device_is_bound(&dcp_pdev->dev)) { put_device(&dcp_pdev->dev); return -EPROBE_DEFER; } + if (!av_audiosrv_ready(&dcp_pdev->dev)) { + put_device(&dcp_pdev->dev); + return -ENODEV; + } link = device_link_add(&pdev->dev, &dcp_pdev->dev, DL_FLAG_AUTOREMOVE_CONSUMER | DL_FLAG_PM_RUNTIME); - if (!link || !av_audiosrv_ready(&dcp_pdev->dev)) { + if (!link) { put_device(&dcp_pdev->dev); return -EPROBE_DEFER; } + if (!av_audiosrv_ready(&dcp_pdev->dev)) { + put_device(&dcp_pdev->dev); + return -ENODEV; + } dcpaud->standalone = true; ret = dcpaud_bind(&pdev->dev); if (ret) { @@ -2309,9 +2357,19 @@ static void dcpaud_remove(struct platform_device *pdev) struct dcp_audio *dcpaud = platform_get_drvdata(pdev); if (dcpaud->standalone) { - if (dcpaud->dcp_dev) - av_detach_audio_dev(dcpaud->dcp_dev, pdev); - dcpaud_unbind(&pdev->dev); + dcpaud_quiesce_standalone(dcpaud, pdev, true); + if (dcpaud->dma_link) { + device_link_del(dcpaud->dma_link); + dcpaud->dma_link = NULL; + } + if (dcpaud->dma_dev) { + put_device(dcpaud->dma_dev); + dcpaud->dma_dev = NULL; + } + if (dcpaud->dcp_dev) { + put_device(dcpaud->dcp_dev); + dcpaud->dcp_dev = NULL; + } dcpaud->standalone = false; return; } @@ -2323,10 +2381,7 @@ static void dcpaud_shutdown(struct platform_device *pdev) struct dcp_audio *dcpaud = platform_get_drvdata(pdev); if (dcpaud->standalone) { - if (dcpaud->dcp_dev) - av_detach_audio_dev(dcpaud->dcp_dev, pdev); - dcpaud_unbind(&pdev->dev); - dcpaud->standalone = false; + dcpaud_quiesce_standalone(dcpaud, pdev, false); return; } component_del(&pdev->dev, &dcpaud_comp_ops); diff --git a/drivers/gpu/drm/apple/av-lifetime-test.c b/drivers/gpu/drm/apple/av-lifetime-test.c index 54b8ed919fb2a..5a1a46448c717 100644 --- a/drivers/gpu/drm/apple/av-lifetime-test.c +++ b/drivers/gpu/drm/apple/av-lifetime-test.c @@ -156,6 +156,7 @@ static struct av_life_test *av_life_setup(struct kunit *test, work_func_t owner_ dev_set_drvdata(t->dev, t->dcp); afk_ep_init_state(t->ep); init_rwsem(&t->asrv->srv_rwsem); + init_rwsem(&t->asrv->audio_cb_rwsem); #if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) init_waitqueue_head(&t->asrv->gen_wq); #endif @@ -483,6 +484,7 @@ static struct av_life_test *av_life_group_setup(struct kunit *test, t->asrv = devm_kzalloc(t->dev, sizeof(*t->asrv), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, t->asrv); init_rwsem(&t->asrv->srv_rwsem); + init_rwsem(&t->asrv->audio_cb_rwsem); INIT_WORK(&t->asrv->start_av_service_wq, fn); INIT_WORK(&t->asrv->terminate_wq, fn); t->asrv->works_live = true; @@ -629,6 +631,7 @@ static void av_lifetime_devres_fresh_rebind(struct kunit *test) t->asrv = devm_kzalloc(t->dev, sizeof(*t->asrv), GFP_KERNEL); KUNIT_ASSERT_NOT_NULL(test, t->asrv); init_rwsem(&t->asrv->srv_rwsem); + init_rwsem(&t->asrv->audio_cb_rwsem); INIT_WORK(&t->asrv->start_av_service_wq, av_life_owner_fn); INIT_WORK(&t->asrv->terminate_wq, av_life_owner_fn); t->asrv->works_live = true; diff --git a/drivers/gpu/drm/apple/av-v14-test.c b/drivers/gpu/drm/apple/av-v14-test.c index 8c1156ad6f927..6874af15559f6 100644 --- a/drivers/gpu/drm/apple/av-v14-test.c +++ b/drivers/gpu/drm/apple/av-v14-test.c @@ -140,6 +140,7 @@ static struct av_v14_test *av_v14_setup(struct kunit *test) t->dcp->desktop_external = true; init_rwsem(&asrv->srv_rwsem); + init_rwsem(&asrv->audio_cb_rwsem); mutex_init(&asrv->plug_lock); mutex_init(&asrv->open_lock); init_waitqueue_head(&asrv->gen_wq); diff --git a/drivers/gpu/drm/apple/av.c b/drivers/gpu/drm/apple/av.c index 1219fc9b590da..b5234c3a298b3 100644 --- a/drivers/gpu/drm/apple/av.c +++ b/drivers/gpu/drm/apple/av.c @@ -100,6 +100,8 @@ struct audiosrv_data { struct platform_device *audio_dev; bool plugged; struct mutex plug_lock; + /* Serializes callbacks made outside plug_lock against av_detach_audio_dev(). */ + struct rw_semaphore audio_cb_rwsem; struct apple_epic_service *srv; struct rw_semaphore srv_rwsem; @@ -1318,6 +1320,7 @@ void av_audio_before_modeset(struct apple_dcp *dcp) if (!asrv || !dcp_audiosrv_native_link(dcp->dev)) return; + guard(rwsem_read)(&asrv->audio_cb_rwsem); scoped_guard(mutex, &asrv->plug_lock) { if (asrv->plugged) audio_dev = asrv->audio_dev; @@ -1358,29 +1361,33 @@ static void __av_service_disconnect(struct apple_dcp *dcp, const u64 *gen) struct platform_device *audio_dev = NULL; bool published = true; - /* - * Each step acts on instance @gen only, checked as it is taken: - * a successor may be published and opened in between. - */ - scoped_guard(mutex, &asrv->plug_lock) { - if (gen) { - scoped_guard(rwsem_read, &asrv->srv_rwsem) - published = asrv->gen == *gen; + scoped_guard(rwsem_read, &asrv->audio_cb_rwsem) { + /* + * Each step acts on instance @gen only, checked as it is taken: + * a successor may be published and opened in between. + */ + scoped_guard(mutex, &asrv->plug_lock) { + if (gen) { + scoped_guard(rwsem_read, &asrv->srv_rwsem) + published = asrv->gen == *gen; + } + if (published) { + audio_dev = asrv->audio_dev; + if (audio_dev) + dcpaud_disconnect(audio_dev); + } } - if (published) { - audio_dev = asrv->audio_dev; - if (audio_dev) - dcpaud_disconnect(audio_dev); + if (published && audio_dev) { + /* + * The open PCM's link ends on the service, before its + * Close; outside plug_lock, which the endpoint's + * receive path takes. + */ + dcpaud_release_link(audio_dev, gen); } } if (!published) goto out; - /* - * The open PCM's link ends on the service, before its Close; - * outside plug_lock, which the endpoint's receive path takes. - */ - if (audio_dev) - dcpaud_release_link(audio_dev, gen); av_audiosrv_close(dcp, asrv, gen); goto out; } @@ -1652,6 +1659,9 @@ void av_detach_audio_dev(struct device *dcp_dev, struct platform_device *audio_p if (asrv->audio_dev == audio_pdev) asrv->audio_dev = NULL; } + /* Wait for any in-flight callback that snapshotted audio_dev before detach. */ + scoped_guard(rwsem_write, &asrv->audio_cb_rwsem) { + } } int avep_init(struct apple_dcp *dcp) @@ -1701,6 +1711,7 @@ int avep_init(struct apple_dcp *dcp) return -ENOMEM; } init_rwsem(&audiosrv_data->srv_rwsem); + init_rwsem(&audiosrv_data->audio_cb_rwsem); mutex_init(&audiosrv_data->plug_lock); switch (dcp->fw_compat) { From 3ff2527c14fab161da81272fab8edb7946fbc8e3 Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 16:57:28 +0100 Subject: [PATCH 14/15] drm/apple: release standalone dpaudio TX DMA channel on remove When standalone T8152 dpaudio unbinds, dcpaud_remove() quiesced the sound card and dropped dma_link/dma_dev without calling dma_release_channel() on dcpaud->chan. Rebinding dcp-dp-audio then failed with -ENODEV (-19) when of_dma_request_slave_channel() tried to claim the already-held ADMAC TX channel. Release dcpaud->chan in dcpaud_remove() after quiescing the card and silence link (unless idle_set remained stuck on a non-stopped channel). Signed-off-by: Thomas Glanzmann --- drivers/gpu/drm/apple/audio.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/drivers/gpu/drm/apple/audio.c b/drivers/gpu/drm/apple/audio.c index e46ad064e5555..7f7863f3fffaa 100644 --- a/drivers/gpu/drm/apple/audio.c +++ b/drivers/gpu/drm/apple/audio.c @@ -2358,6 +2358,15 @@ static void dcpaud_remove(struct platform_device *pdev) if (dcpaud->standalone) { dcpaud_quiesce_standalone(dcpaud, pdev, true); + if (dcpaud->chan) { +#if IS_ENABLED(CONFIG_DRM_APPLE_DCP_T6030_AUDIO) + if (!dcpaud->idle_set) + dma_release_channel(dcpaud->chan); +#else + dma_release_channel(dcpaud->chan); +#endif + dcpaud->chan = NULL; + } if (dcpaud->dma_link) { device_link_del(dcpaud->dma_link); dcpaud->dma_link = NULL; From 0773d03b9b5d0803f5d730a8dc1c2cc0abb0854b Mon Sep 17 00:00:00 2001 From: Thomas Glanzmann Date: Sun, 29 Nov 2026 20:27:50 +0100 Subject: [PATCH 15/15] selftests: apple-dcp: add audio_cb_rwsem to cec-only-av-endpoint stub Commit d3b3ade5d6ec ("drm/apple: quiesce standalone dpaudio teardown and exit on disabled audio") added audio_cb_rwsem to struct audiosrv_data in drivers/gpu/drm/apple/av.c. Add the matching struct lock field to the host-test stub in tools/testing/selftests/drivers/gpu/apple-dcp/audio.py so cec-only-av-endpoint builds and passes again. Signed-off-by: Thomas Glanzmann --- tools/testing/selftests/drivers/gpu/apple-dcp/audio.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py b/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py index 5cd6b5f6ada33..23ecbcd7157b8 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/audio.py @@ -154,7 +154,7 @@ def cec_only_endpoint(root): struct apple_epic_service {bool torndown; unsigned pins;}; struct apple_dcp_afkep {int endpoint;}; struct audiosrv_data { - struct lock srv_rwsem, plug_lock; + struct lock srv_rwsem, plug_lock, audio_cb_rwsem; struct apple_epic_service *srv; bool plugged, is_open; u64 gen, v27_boot_gen;