Skip to content

dcp on m3 devices - #608

Closed
sofus13 wants to merge 47 commits into
AsahiLinux:asahi-wipfrom
sofus13:m3-dcp
Closed

sofus13 wants to merge 47 commits into
AsahiLinux:asahi-wipfrom
sofus13:m3-dcp

Conversation

@sofus13

@sofus13 sofus13 commented Sep 9, 2026 •

Copy link
Copy Markdown

there is some overlap with #607

it will not work withouth 62bd293

It also needs m1n1 changes, for t6030 i needed:

diff --git a/src/kboot.c b/src/kboot.c
index 17c650eb..756092a2 100644
--- a/src/kboot.c
+++ b/src/kboot.c
@@ -2018,7 +2018,8 @@ static int dt_set_display(void)
             }
         }
     } else if (!fdt_node_check_compatible(dt, 0, "apple,t6020") ||
-               !fdt_node_check_compatible(dt, 0, "apple,t6021")) {
+               !fdt_node_check_compatible(dt, 0, "apple,t6021") ||
+              !fdt_node_check_compatible(dt, 0, "apple,t6030")) {
         ret = dt_carveout_reserved_regions("dcp", "disp0", disp0_piodma_alias,
                                            disp_reserved_regions_t602x,
                                            ARRAY_SIZE(disp_reserved_regions_t602x));
@@ -2040,7 +2041,8 @@ static int dt_set_display(void)
     if (!fdt_node_check_compatible(dt, 0, "apple,t8112") ||
         !fdt_node_check_compatible(dt, 0, "apple,t6020") ||
         !fdt_node_check_compatible(dt, 0, "apple,t6021") ||
-        !fdt_node_check_compatible(dt, 0, "apple,t6022"))
+        !fdt_node_check_compatible(dt, 0, "apple,t6022") ||
+        !fdt_node_check_compatible(dt, 0, "apple,t6030"))
         dt_reserve_dcpext_firmware();
 
     const display_config_t *disp_cfg = display_get_config();

Comment thread drivers/gpu/drm/apple/iomfb_v14_7.c Resolved
<0x2 0x8f348000 0x0 0x4000>, /* dummy ? */
<0x2 0x8f800000 0x0 0x800000>;
apple,bw-scratch = <&pmgr_dcp 0 5 0x988>;
apple,iomfb-surfaces = <1 1 0 1>;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Have we tested various combinations of surface? I'm hoping that we have less buggy nonsense on the M3+ DCPs.

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How can that be tested? I installed and tried kwin with KWIN_USE_OVERLAYS=1, but i think its only using two planes.

Comment thread arch/arm64/boot/dts/apple/t8122.dtsi Resolved
@sofus13 sofus13 changed the title dcp on m3 devices (internal display only) dcp on m3 devices Sep 9, 2026
@sofus13

sofus13 commented Sep 9, 2026

Copy link
Copy Markdown
Author

i added dcpext nodes for t8122 and t603[124]

Comment thread arch/arm64/boot/dts/apple/t8122.dtsi Resolved
jannau and others added 16 commits October 15, 2026 22:52
DCP supports multiple addressing and framebuffer compression formats.
While DCP does seem to support direct scanout of AGX layout images
(APPLE_GPU_TILED/APPLE_GPU_TILED_COMPRESSED), macOS is never observed
doing this. Instead, it uses a secret third layout called Apple Interchange.

Apple Interchange is a tiled and compressed framebuffer format similar
to AGX's native format, albeit with slightly different addressing.
RGB images and the chroma channels of Y'CbCr images share a tile size
of 16x16, while the luma channel of Y'CbCr formats has a tile size of
32x32.

Define enums for both addressing format and compression mode, and add
known supported modes for each.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Apple Interchange is a tiled and compressed framebuffer layout
used for sharing framebuffers between Apple hardware blocks
(AGX, AVD, DCP).

DCP can scan out framebuffers in Interchange format. Add support
for this to the Linux driver.

Co-developed-by: Oliver Bestmann <oliver.bestmann@googlemail.com>
Signed-off-by: Oliver Bestmann <oliver.bestmann@googlemail.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
On DCPs which support scanout on >2 surfaces (T8112 and later), using
Interchange on all of them will cause the coprocessor to crash. It is
unclear why this is the case.

This is never observed on macOS for two reasons:
    1. macOS never uses more than two planes at a time; and
    2. The second plane is almost always a linear framebuffer,
       except when scanning out video from AVD.

On Linux, we can avoid these crashes by simply hiding Interchange from
one of the surfaces. Since the topmost surface on these DCPs will almost
always be used only for a cursor, and since a tiny cursor framebuffer
is not bandwidth-critical, simply advertise it as linear only. This fixes
spurious crashes on T602x and T8112.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
The image tile size calculation was being done by rounding up bits
per pixel and dividing by 8. The entire size in bytes needs to be
rounded up and divided by 8.

Fixes: cb69536 ("drm: apple: Add support for Apple Interchange framebuffers")
Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Some pixel formats supported by both AVD and DCP do not have integer
bits per pixel values when using drm_format_info_bpp. Calculate the
bits per pixel "manually" instead.

Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
AVD's 10-bit semiplanar YCbCr output is in P030, P230 and P430 for
both video and full range. DCP firmware supports these, so add them
to the list of supported formats.

Signed-off-by: Sofus Forstreuter <sofus.c@icloud.com>
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
Signed-off-by: Janne Grunau <j@jannau.net>
Subdevice initialization is a low priority process and it does not make
sense to initialize multiple interface concurrently. Remove the bogus
`WQ_MEM_RECLAIM` flags.

Fixes following warning in Linux 7.2:
[    4.914732] workqueue: dchid-new is using neither WQ_PERCPU or WQ_UNBOUND. Setting WQ_PERCPU.
[    4.919378] WARNING: kernel/workqueue.c:5851

Signed-off-by: Janne Grunau <j@jannau.net>
Signed-off-by: sofus <sofus.c@icloud.com>
Signed-off-by: sofus <sofus.c@icloud.com>
Signed-off-by: sofus <sofus.c@icloud.com>
Signed-off-by: sofus <sofus.c@icloud.com>
Signed-off-by: sofus <sofus.c@icloud.com>
Signed-off-by: sofus <sofus.c@icloud.com>
@sofus13
sofus13 changed the base branch from asahi-wip-7.2 to asahi-wip October 17, 2026 07:32
@sofus13

sofus13 commented Oct 17, 2026

Copy link
Copy Markdown
Author

I rebased onto asahi-wip and added pmp power domains (not for the multi die stuff since im not sure how that should work)

@jannau
jannau force-pushed the asahi-wip branch 2 times, most recently from a7c69b6 to 902cebd Compare October 26, 2026 21:44
@jannau

jannau commented Oct 28, 2026

Copy link
Copy Markdown
Member

merged manually (mixed with changes from #607 and heavy editing by me) and pushed to asahi-wip. Tested on t8122, t6030 and t6031 (j504/j514s/j514c). Only working with m1n1 changes.

Thanks.

@jannau jannau closed this Oct 28, 2026
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 14, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 14, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 19, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 19, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
hitori-chan added a commit to hitori-chan/linux that referenced this pull request Nov 20, 2026
dwc3-apple brings the mode and the core up and down itself, per cable
(skip_core_init_mode), and takes both down in its remove before
dwc3_core_remove(). That then exited them again through the dr_mode
the glue had set for the last role: dwc3_gadget_exit() a second time
freed the gadget, its bounce buffer and its control TRBs again (an
unbind of a device-mode port oopsed), and dwc3_core_exit() a second
time powered the PHYs off again, their runtime PM counts below zero.

Record skip_core_init_mode at probe and, with it, leave the mode's
exit and dwc3_core_exit() to the glue in dwc3_core_remove().

r215, a host-mode port's unbind (ftrace): dwc3_host_exit and
dwc3_core_exit called again from dwc3_core_remove, and "phy
phy-703000000.phy.{0,1}: Runtime PM usage count underflow!" for each
port's two PHYs; a device-mode port's unbind killed its writer. This
commit (AsahiLinux#608, 2026-11-14): unbind, bind and unbind again of all three
ports, the device-mode one included: no oops, warning or underflow.

A rebound controller still gets no role until a reboot: tipd keeps the
role switch it got at its probe, which the unbind unregistered.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants