Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
138 commits
Select commit Hold shift + click to select a range
6e35fe4
drm/asahi: g17: M5: describe the M5 boards and refuse those without b…
DjDeveloperr Nov 5, 2026
5bbd3f1
drm/asahi: g17: M5: give M5 VMs sparse tiles, render pool mappings an…
DjDeveloperr Nov 5, 2026
cfb6e4a
drm/asahi: g17: M5: build the M5 firmware's InitData graph
DjDeveloperr Nov 5, 2026
3b8049b
drm/asahi: g17: M5: back M5 render and compute pools with the M5 free…
DjDeveloperr Nov 5, 2026
4a7b449
drm/asahi: g17: M5: install M5 queues and submit through the host com…
DjDeveloperr Nov 5, 2026
93a5359
drm/asahi: g17: M5: test that the M5 report mask counts tag 32 and re…
funkzy Nov 7, 2026
2715750
drm/asahi: g17: M5: accept the M5 render and compute program UAPI
DjDeveloperr Nov 5, 2026
9967d1a
selftests: asahi-m4: keep the G17 command-stream test building with t…
funkzy Nov 7, 2026
5b657e6
drm/asahi: g17: M5: submit compute on M5 queues
DjDeveloperr Nov 5, 2026
f7c7200
tools/asahi: g17-admission-order: keep checking compute admission ord…
funkzy Nov 7, 2026
a7d4bc2
tools/asahi: g17-compute-constructor: keep checking compute contexts …
funkzy Nov 7, 2026
1dc7034
drm/asahi: g17: M5: encode M5 render commands
DjDeveloperr Nov 5, 2026
acf691e
drm/asahi: g17: M5: submit renders on M5 render pairs
DjDeveloperr Nov 5, 2026
a474c98
tools/asahi: neo-auxiliary: keep testing the G17P generation under it…
funkzy Nov 7, 2026
93458ec
drm/asahi: g17: M5: Fix existing M5 Mesa losing the GPU device on sta…
funkzy Nov 6, 2026
7d90ae5
drm/asahi: g17: M5: add the opt-in M5 thermal governor
DjDeveloperr Nov 5, 2026
7b297c4
drm/asahi: g17: signal a cancelled job's fence before drm_sched frees it
DjDeveloperr Oct 25, 2026
12c28c3
drm/asahi: g17: describe the M5 Max (J716c) HW data
erikwb Oct 31, 2026
f422c1e
drm/asahi: g17: J716c: encode its own AON PTD records
erikwb Oct 31, 2026
180a63b
drm/asahi: g17: probe the M5 Max (J716c)
erikwb Oct 31, 2026
28c9c8b
drm/asahi: g17: J716c: use its 8 MiB render blocks
erikwb Oct 31, 2026
3b08a4f
drm/asahi: g17: carry the minimum parameter-buffer size in renders
erikwb Oct 31, 2026
9a0dff4
drm/asahi: g17: M5: reinstall a compute queue the firmware killed wor…
erikwb Nov 1, 2026
eb725b5
drm/asahi: g17: M5: keep the firmware's blame for a GPU MMU fault
erikwb Nov 1, 2026
274fcd3
drm/asahi: fwid: Prepare firmware identity for two-role GPU images
funkzy Nov 5, 2026
b3fadf7
drm/asahi: g17: M5: Prepare the M5 graph's board values for a third b…
funkzy Nov 5, 2026
10c4b54
drm/asahi: t6050: Support the GPU on the bare-metal M5 Ultra (J775D)
funkzy Nov 5, 2026
a21e80f
drm/asahi: t6050: Refuse unknown M5 Ultra GPU firmware before use
funkzy Nov 5, 2026
19cf3f8
rust: drm: gem: shmem: Fix memory corruption on a foreign dma-buf import
funkzy Nov 5, 2026
a6e1ec5
drm/asahi: g17: M5: Fix the M5 Ultra GPU staying at its lowest clock
funkzy Nov 5, 2026
b8b04c0
drm/asahi: g17: M5: Fix light work settling at low clocks on the M5 U…
funkzy Nov 5, 2026
4a1ead0
drm/asahi: Fix refused M5 renders after 255 reuses of a context slot
funkzy Nov 5, 2026
fa96f7b
drm/asahi: mmu: Fix Vulkan device creation failing on bare-metal M5 GPUs
funkzy Nov 5, 2026
377c7fe
drm/asahi: g17: M5: Give the M5 Ultra GPU its 3500 us idle standby delay
funkzy Nov 5, 2026
e2d691e
drm/asahi: g17: M5: Give the M5 Ultra's GPU boost its 20% idle tolerance
funkzy Nov 5, 2026
6e093f6
drm/asahi: g17: M5: Fix the Ultra power policy ignoring die 1's sensors
funkzy Nov 5, 2026
4bb467e
drm/asahi: g17: M5: Fix the Ultra firmware seeing half its cache cont…
funkzy Nov 5, 2026
a7e703b
drm/asahi: g17: Fix the M5 Ultra thermal governor never seeing a temp…
funkzy Nov 5, 2026
488684f
hwmon: macsmc: Prepare fan control for a kernel thermal policy
funkzy Nov 5, 2026
c45c685
drm/asahi: g17: Fix the M5 governor overriding fans userspace controls
funkzy Nov 5, 2026
de9b0dd
drm/asahi: g17: Fix the M5 Ultra governor spinning the fans up early
funkzy Nov 5, 2026
38c33f2
drm/asahi: g17: Fix large M5 render passes corrupting a client buffer
funkzy Nov 5, 2026
211d5b2
drm/asahi: g17: M5: Run compute and render jobs on the bare-metal M5 …
funkzy Nov 5, 2026
d490c4d
drm/asahi: g17: M5: Fix Ultra compute operand state sized for the M5 Pro
funkzy Nov 5, 2026
770a98e
drm/asahi: g17: Fix the recovery check of lockless submits on the T6041
funkzy Nov 5, 2026
806982b
drm/asahi: g17: Fix jobs succeeding on the output of a failed producer
funkzy Nov 5, 2026
47c9c7f
drm/asahi: g17: M5: Fix waited-on work running at the lowest busy clock
funkzy Nov 5, 2026
8f37bab
drm/asahi: g17: Fix false timeouts of M5 work behind its own context
funkzy Nov 5, 2026
cee81dc
drm/asahi: t6050: Prepare M5 compute queue installs for bare-metal co…
funkzy Nov 5, 2026
0dcf266
drm/asahi: g17: Fix M5 Ultra compute dispatch encoded for four clusters
funkzy Nov 5, 2026
29d3bc3
drm/asahi: g17: Fix M5 Ultra compute jobs waiting on another context
funkzy Nov 5, 2026
57999d6
drm/asahi: g17: Fix M5 Ultra compute jobs of one queue overlapping
funkzy Nov 5, 2026
c33cdc3
drm/asahi: g17: Fix M5 Ultra compute jobs carrying no per-queue count
funkzy Nov 5, 2026
c4164d5
drm/asahi: g17: Fix large M5 heaps colliding with the driver's ring a…
funkzy Nov 5, 2026
232e33d
drm/asahi: g17: Fix every compute job timing out on the M5 Ultra
funkzy Nov 5, 2026
f5d6c85
drm/asahi: g17: Fix compute scratch leaking across processes on queue…
funkzy Nov 5, 2026
a4cb2bb
drm/asahi: g17: M5: Give M5 Ultra renders the Ultra's 16 GiB render pool
funkzy Nov 5, 2026
9d950a4
drm/asahi: g17: Reduce M5 job completion latency
funkzy Nov 5, 2026
ddbab8f
drm/asahi: g17: Fix M5 Ultra faults when a tiling stage is resumed
funkzy Nov 5, 2026
e084c71
drm/asahi: g17: Leave the M5 Ultra's GPU-owned tiler state to the GPU
funkzy Nov 5, 2026
a550bbb
drm/asahi: g17: Match the M5 Ultra's tiling queue seed on rebinding
funkzy Nov 5, 2026
566e5ed
drm/asahi: g17: Fix M5 Ultra fragment kicks missing an ordering depen…
funkzy Nov 5, 2026
eebc132
drm/asahi: g17: Fix M5 renders with many attachments being refused
funkzy Nov 5, 2026
70daf04
drm/asahi: g17: Prepare M5 render encodings for per-board selection
funkzy Nov 5, 2026
bbc696d
drm/asahi: g17: Fix GPU firmware restarts during M5 Ultra renders
funkzy Nov 5, 2026
8a2dbd5
drm/asahi: g17: Fix M5 Ultra render passes flagged as recycled passes
funkzy Nov 5, 2026
c5b8f0f
drm/asahi: g17: M5: Support parameter-buffer growth on the M5 Ultra
funkzy Nov 5, 2026
247dbb6
drm/asahi: g17: M5: Fix M5 misreading firmware event 7 as a compute f…
funkzy Nov 5, 2026
90e6bb6
drm/asahi: g17: M5: Fix spurious and delayed kills of M5 contexts
funkzy Nov 5, 2026
5d5af46
drm/asahi: g17: Fix M5 renders failing after their render pool grows
funkzy Nov 5, 2026
873c60f
drm/asahi: g17: M5: Fix freeing memory the M5 GPU may still write at …
funkzy Nov 5, 2026
2be1a1c
drm/asahi: g17: M5: Fix compute queues wedging on a full work ring
funkzy Nov 5, 2026
963f968
drm/asahi: g17: M5: Fix M5 renders silently dropping their ray queries
funkzy Nov 5, 2026
5f9f6e7
drm/asahi: g17: Prevent M5 firmware crashes from InitData objects M5 …
funkzy Nov 5, 2026
4f650d1
drm/asahi: g17: M5: Fix M5 power timeouts under a longer idle delay
funkzy Nov 5, 2026
6395ed7
drm/asahi: g17: Fix GPU jobs that never retire after out-of-order sub…
funkzy Nov 5, 2026
b641cb8
drm/asahi: g17: Fix M5 submissions stalling when the shared work ring…
funkzy Nov 5, 2026
fef0bfa
drm/asahi: g17: Fix restart-cancelled M5 compute jobs reporting success
funkzy Nov 5, 2026
cb9f5f5
drm/asahi: g17: Fix M5 compute timeouts judged by an early record
funkzy Nov 5, 2026
7dfee6d
drm/asahi: g17: Fix freeing render state the M5 firmware still links
funkzy Nov 5, 2026
eee6433
drm/asahi: g17: Fix skipped or repeated GPU effort updates on M5
funkzy Nov 5, 2026
2109033
drm/asahi: g17: Fix M5 compute jobs failing with EBUSY when clients c…
funkzy Nov 5, 2026
b697b0e
tools/asahi: g17-compute-deadline: keep checking compute deadlines wi…
funkzy Nov 7, 2026
6cdf452
drm/asahi: g17: Fix out-of-memory kills when many M5 compute clients …
funkzy Nov 5, 2026
51312ca
drm/asahi: g17: Fix M5 renders refused while their context changes pair
funkzy Nov 5, 2026
e70ad14
tools/asahi: g17-owner-release-order: keep checking render release or…
funkzy Nov 7, 2026
be916a7
drm/asahi: g17: Fix M5 GPU recovery failing or completing the wrong job
funkzy Nov 5, 2026
d6e6ca6
drm/asahi: g17: Fix M5 renders retiring before their writes land
funkzy Nov 5, 2026
df70f55
drm/asahi: g17: Fix the M5 recovery log claiming listed jobs fail
funkzy Nov 5, 2026
68cc07c
drm/asahi: g17: M5: Fix slow kills of hung jobs after other clients f…
funkzy Nov 5, 2026
681e5eb
drm/asahi: g17: M5: Fix M5 GPU completions being handled at a lowered…
funkzy Nov 5, 2026
d41eec7
drm/apple: Add T6050 firmware-27 display support
DjDeveloperr Oct 26, 2026
a37178f
tools/asahi: apple-afkv2: check that only firmware 27 hands unowned b…
funkzy Nov 7, 2026
33a86df
drm/apple: log DCP CoreAnalytics events
DjDeveloperr Oct 19, 2026
d1ccd7c
drm/apple: hand the analytics payload back to the DCP unchanged
DjDeveloperr Oct 19, 2026
ee65581
iommu/apple-dart: Support T6050's boot-locked display DARTs
funkzy Nov 5, 2026
1f1c742
iommu/apple-dart: Fix the T6050 display co-processor failing buffer s…
funkzy Nov 5, 2026
5e297bf
drm/apple: dptx: Fix no DisplayPort link on T6050 with firmware 27
funkzy Nov 5, 2026
1b2230b
drm/apple: Fix garbled display output with firmware 27
funkzy Nov 5, 2026
1b60dd4
drm/apple: Fix missing EDID on T6050 external displays
funkzy Nov 5, 2026
2e0e5b9
drm/apple: Give firmware 27 analytics events firmware 26.6's answer
funkzy Nov 5, 2026
24fb184
drm/apple: Fix no display on a T6050 with more than one DCP
funkzy Nov 3, 2026
b920f1c
drm/apple: Fix one failed T6050 DCP taking down every display
funkzy Nov 5, 2026
e758282
rust: workqueue: Let drivers queue work near a CPU, for 15% faster M5…
funkzy Nov 5, 2026
e4ab75d
rust: drm: sched: Let drivers place scheduler work, for 4% faster M5 …
funkzy Nov 5, 2026
0a3018b
drm/asahi: g17: M5: Make M5 Ultra GPU jobs complete up to 20% faster …
funkzy Nov 5, 2026
911e24f
drm/asahi: g17: M5: Fix one client's binds being able to crash the GP…
funkzy Nov 5, 2026
cee8d35
drm/asahi: g17: M5: Fix hung GPU work running on with no time limit
funkzy Nov 5, 2026
5445c4a
drm/asahi: g17: Fix a process keeping access to a GPU queue after ano…
funkzy Nov 5, 2026
373775f
tools/asahi: g17-growth: keep checking compute growth with pool descr…
funkzy Nov 7, 2026
dc308b7
tools/asahi: g17-capacity-fault, g17-unpublished: keep checking capac…
funkzy Nov 7, 2026
8249dec
drm/asahi: g17: Fix a released context's QoS entry pointing at memory…
funkzy Nov 5, 2026
96007f1
drm/asahi: Fix client binds silently replacing the kernel's GPU mappings
funkzy Nov 5, 2026
9bb3a9a
drm/asahi: g17: M5: Fix compute jobs overrunning their scratch pool
funkzy Nov 5, 2026
0881957
drm/asahi: g17: M5: Fix one client exhausting system memory through G…
funkzy Nov 5, 2026
0a2f1c6
tools/asahi: g17-compute-growth-deadline: keep checking growth deadli…
funkzy Nov 7, 2026
7987ec1
drm/asahi: Fix one client taking every GPU queue from the others
funkzy Nov 5, 2026
3f20415
drm/asahi: mmu: Fix sparse tiles wasting 2 MiB of contiguous memory p…
funkzy Nov 5, 2026
243e6d4
drm/asahi: pgtable: Fix a bad firmware table pointer making the drive…
funkzy Nov 5, 2026
d71a2c2
drm/asahi: g17: M5: Fix GPU jobs being able to write the kernel's com…
funkzy Nov 5, 2026
115cd9d
drm/asahi: g17: Fix clients rewriting submitted GPU commands after th…
funkzy Nov 5, 2026
8e61690
drm/apple: Fix display firmware buffer requests reaching any mapped m…
funkzy Nov 5, 2026
3cba344
drm/asahi: g17: Fix GPU job fences being able to stall memory reclaim…
funkzy Nov 6, 2026
7aed787
tools/asahi: g17-telemetry-integration: keep checking telemetry with …
funkzy Nov 7, 2026
dea8af3
drm/asahi: g17: J716c: write the MCC mask and topology words
erikwb Nov 6, 2026
eb0b54c
drm/asahi: g17: J716c: apply its controller defaults
erikwb Nov 6, 2026
0625c9f
drm/asahi: g17: Run the M5 Max on bare metal
erikwb Nov 6, 2026
8b40458
drm/asahi: Match the T6050 GPU by its G17S compatible
erikwb Nov 6, 2026
1291e9f
drm/asahi: Fix rmmod racing a GPU probe unloading live firmware callb…
funkzy Nov 6, 2026
c504d1b
drm/apple: Fix rmmod racing a display probe unloading live DCP callbacks
funkzy Nov 6, 2026
1b5acb0
tools/asahi: apple-dcp: keep the display tests running on firmware 27…
funkzy Nov 7, 2026
5b0f106
drm/asahi: g17: Fix GPU queue creation spinning a CPU while the GPU h…
funkzy Nov 7, 2026
6b82da7
drm/asahi: g17: order an owner's overlapping renders across its own p…
funkzy Nov 7, 2026
a0fe101
drm/asahi: g17: size a render queue's credits, pool and pair limit fr…
funkzy Nov 7, 2026
9d045d3
drm/asahi: g17: restore two render pairs per queue on G17D within the…
funkzy Nov 7, 2026
b1615e3
drm/asahi: g17: take a queue's second render pair only once its first…
funkzy Nov 7, 2026
37a9e8a
drm/apple: T8142: drive the macOS 27.0 DCP firmware as firmware 27
sithglan Nov 7, 2026
42db926
arm64: dts: apple: t8142-j813: give the DCP its firmware-27 clocks
sithglan Nov 7, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 56 additions & 6 deletions Documentation/devicetree/bindings/display/apple,dcp.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ properties:
- apple,t6041-dcp
- apple,t8140-dcp
- apple,t8142-dcp
- apple,t6050-dcp
- const: apple,dcp
- items:
- enum:
Expand All @@ -34,6 +35,7 @@ properties:
- apple,t6000-dcpext
- apple,t6020-dcpext
- apple,t6041-dcpext
- apple,t6050-dcpext
- const: apple,dcpext
- items:
- const: apple,t8140-dcpext
Expand Down Expand Up @@ -85,13 +87,32 @@ properties:

clocks:
minItems: 1
maxItems: 2
maxItems: 64

clock-names:
minItems: 1
items:
- const: clock-154
- const: clock-194
maxItems: 64

apple,clock-ids:
oneOf:
- type: boolean
- $ref: /schemas/types.yaml#/definitions/uint32-array
minItems: 1
maxItems: 64
description: |
Ordered firmware provider clock identifiers. Callback clock indices
select the corresponding entry in clocks. An explicitly empty table
is allowed when the provider has no clocks.

apple,firmware-physical-regs:
$ref: /schemas/types.yaml#/definitions/uint64-array
minItems: 1
maxItems: 10
description: |
Coprocessor physical base addresses in display register-table order,
including the bandwidth scratch and optional doorbell windows.
The number of entries must match the complete register table.
Omit on identity-mapped systems; reg supplies the physical view.

memory-region:
minItems: 1
Expand Down Expand Up @@ -414,6 +435,7 @@ allOf:
enum: ['apple,t6030-dcpext', 'apple,t8132-dcpext']
required:
- compatible
then: {}
else:
properties:
mux-controls:
Expand All @@ -431,12 +453,39 @@ allOf:
then:
required:
- apple,bw-scratch
- if:
properties:
compatible:
contains:
enum: ['apple,t6050-dcp', 'apple,t6050-dcpext']
then:
required:
- apple,clock-ids
- memory-region
- memory-region-names
- apple,firmware-compat
properties:
apple,firmware-compat:
items:
- const: 27
- const: 0
- const: 0
else:
properties:
clocks:
maxItems: 2
clock-names:
items:
- const: clock-154
- const: clock-194
apple,clock-ids: false
apple,firmware-physical-regs: false
- if:
not:
properties:
compatible:
contains:
enum: ['apple,t8140-dcp', 'apple,t8140-dcpext']
enum: ['apple,t8140-dcp', 'apple,t8140-dcpext', 'apple,t6050-dcp', 'apple,t6050-dcpext']
then:
properties:
apple,power-lut-data-x: false
Expand All @@ -448,7 +497,8 @@ allOf:
properties:
compatible:
contains:
enum: ['apple,t8140-dcp', 'apple,t8140-dcpext']
enum: ['apple,t8140-dcp', 'apple,t8140-dcpext',
'apple,t6050-dcp', 'apple,t6050-dcpext']
then:
properties:
resets: false
Expand Down
7 changes: 7 additions & 0 deletions Documentation/hwmon/macsmc-hwmon.rst
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,13 @@ The driver leaves fan policy to the SMC until userspace writes a nonzero
shutdown and removal release only fans taken over by such a request; resume
does not reapply it. A new target write is required after resume.

A kernel thermal policy (the M5 GPU governor) sets the fans through
macsmc_hwmon_fans_request(), as a share of each fan's range, on every fan
whose node names its mode, target, minimum and maximum keys, with or without
apple,fan-manual-control. It uses the same manual mode, leaves fans userspace
holds alone, and its fans return to the SMC at suspend, shutdown and removal
like userspace's.

SoC die temperatures are described by the ``apple,soc-die-keys`` string list
on the hwmon device node. The driver appends these temperature channels after
the ``temperature-*`` children, in list order, with labels ``SoC die <key>``.
Expand Down
29 changes: 28 additions & 1 deletion arch/arm64/boot/dts/apple/t8142-j813-display.dtsi
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,13 @@
apple,bw-doorbell = <&pmgr_dcp 1 6>;
/* Scan out the primary plane on IOMFB surface 2. */
apple,iomfb-surfaces = <0 0 1 0>;
clocks = <&clkref>;
/*
* The macOS 27.0 DCP firmware asks for its clocks by index into
* /arm-io/disp0 clock-ids, in this order.
*/
apple,clock-ids = <585 431>;
clocks = <&dcp_fw_clk585>, <&dcp_fw_clk431>;
clock-names = "firmware-0", "firmware-1";
/* generate phandle explicitly for use in loader */
phandle = <&dcp>;
status = "disabled";
Expand All @@ -106,3 +112,24 @@
};
};
};

/ {
/*
* The 27.0 DCP firmware's clocks 585 and 431. The J813 ADT has no rate for
* these IDs (clock-frequencies has 174 entries); these are the J716c's
* 361/458 rates, which drive the panel at 2560x1600@60.
*/
dcp_fw_clk585: clock-dcp-firmware-585 {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <810000000>;
clock-output-names = "dcp_firmware_585";
};

dcp_fw_clk431: clock-dcp-firmware-431 {
compatible = "fixed-clock";
#clock-cells = <0>;
clock-frequency = <521064992>;
clock-output-names = "dcp_firmware_431";
};
};
2 changes: 2 additions & 0 deletions drivers/gpu/drm/apple/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ config DRM_APPLE
depends on APPLE_RTKIT
depends on TYPEC || !TYPEC
depends on OF_ADDRESS
# The firmware-27 remote buffer path calls into the DART driver.
depends on APPLE_DART || !APPLE_DART
select APPLE_PMP_REPORT
select OF_DYNAMIC
select DRM_CLIENT_SELECTION
Expand Down
1 change: 1 addition & 0 deletions drivers/gpu/drm/apple/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_announce_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_external_relink_test.o
appledrm-$(CONFIG_DRM_APPLE_KUNIT_TEST) += dcp_dropped_swap_test.o
appledrm-y += iomfb_v26_6.o iomfb_v26_6_link.o j613_dcp_activate.o
appledrm-y += iomfb_v27.o
appledrm-y += epic/dpavservep.o
appledrm-y += plane.o

Expand Down
82 changes: 78 additions & 4 deletions drivers/gpu/drm/apple/afk.c
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
/* Copyright 2022 Sven Peter <sven@svenpeter.dev> */

#include <linux/bitfield.h>
#include <linux/io.h>
#include <linux/iommu.h>
#include <linux/debugfs.h>
#include <linux/delay.h>
#include <linux/dma-mapping.h>
Expand All @@ -15,6 +17,8 @@
#include <linux/sizes.h>
#include <linux/unaligned.h>
#include <linux/workqueue.h>
#include <linux/ioport.h>
#include <linux/soc/apple/dart.h>
#include <linux/soc/apple/rtkit.h>

#include <kunit/visibility.h>
Expand Down Expand Up @@ -106,6 +110,7 @@ struct apple_dcp_afkep *afk_init(struct apple_dcp *dcp, u32 endpoint,

afkep->ops = ops;
afkep->dcp = dcp;
afkep->wire_v2 = dcp->fw_compat == DCP_FIRMWARE_V_27_0;
afkep->endpoint = endpoint;
afkep->wq = alloc_ordered_workqueue("apple-dcp-afkep%02x",
WQ_MEM_RECLAIM, endpoint);
Expand Down Expand Up @@ -1490,7 +1495,8 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel,
return;
}
ret = parse_epic_service_init(&ctx, &epic_name, &epic_class, &epic_unit,
ep->dcp->fw_compat == DCP_FIRMWARE_H17P);
(ep->dcp->fw_compat == DCP_FIRMWARE_H17P || ep->dcp->fw_compat == DCP_FIRMWARE_V_27_0),
ep->dcp->fw_compat == DCP_FIRMWARE_V_27_0);
if (ret == -ENOENT &&
ep->dcp->hw.iomfb_method_profile == DCP_IOMFB_METHODS_H17G) {
/*
Expand Down Expand Up @@ -1593,6 +1599,8 @@ static void afk_recv_handle_init(struct apple_dcp_afkep *ep, u32 channel,
}
if (ops->prepare)
afk_service_publish(service);
if (ops->init_props)
ops->init_props(service, epic_unit, props, props_size);
if (ops->init)
ops->init(service, epic_name, epic_class, epic_unit);
dev_info(ep->dcp->dev, "AFK[ep:%02x]: new service %s on channel %d\n",
Expand Down Expand Up @@ -1878,6 +1886,61 @@ static void afk_v2_status(struct apple_dcp_afkep *ep,
dev_warn(ep->dcp->dev, "AFKV2 error reply failed: %d\n", ret);
}

/*
* A buffer the DCP firmware names that is none of the host's pending command
* buffers. Only the firmware's own retained mappings are followed, with the
* permission they grant: a reply is written only where the firmware's leaf
* allows writes, and a DVA that Linux mapped itself, or that names Linux's RAM,
* a claimed resource or anything below DRAM (a device's registers, claimed or
* not), is refused. The copy goes through a write-combined mapping, as the
* RTKit buffers in the same firmware segments are mapped (dcp_rtk_shmem_setup()):
* the DCP is not described as DMA-coherent, so a cacheable alias could see
* stale data.
*/
static int afk_v27_access_remote(struct apple_dcp_afkep *ep, u64 dva, void *buffer,
size_t size, bool to_remote, bool copy)
{
size_t off = 0;

if (!dva || size > SZ_1M || size > U64_MAX - dva)
return -EINVAL;
while (off < size) {
phys_addr_t pa = 0;
size_t chunk = min_t(size_t, size - off,
PAGE_SIZE - ((dva + off) & ~PAGE_MASK));
int ret = apple_dart_fw_remote(ep->dcp->dev, dva + off, to_remote, &pa);
void *cpu;

if (!ret && (!dcp_fw_phys_in_dram(pa) ||
region_intersects(pa, chunk, IORESOURCE_MEM,
IORES_DESC_NONE) != REGION_DISJOINT))
ret = -EACCES;
if (ret) {
dev_err_ratelimited(ep->dcp->dev,
"AFK[ep:%02x]: refused remote buffer %#llx + %#zx (%s): %d\n",
ep->endpoint, dva, off, to_remote ? "reply" : "request", ret);
return ret;
}
if (!copy) {
off += chunk;
continue;
}
cpu = memremap(pa, chunk, MEMREMAP_WC);
if (!cpu)
return -ENOMEM;
if (to_remote) {
memcpy(cpu, buffer + off, chunk);
dma_wmb();
} else {
dma_rmb();
memcpy(buffer + off, cpu, chunk);
}
memunmap(cpu);
off += chunk;
}
return 0;
}

static int afk_v2_access_owned(struct apple_epic_service *service, u64 dva,
void *buffer, size_t size, bool to_peer, bool copy)
{
Expand Down Expand Up @@ -1921,6 +1984,9 @@ static int afk_v2_access_owned(struct apple_epic_service *service, u64 dva,
break;
}
spin_unlock_irqrestore(&service->lock, flags);
/* T6050 callbacks may refer to firmware-owned buffers in the retained DART. */
if (ret && service->ep->dcp->fw_compat == DCP_FIRMWARE_V_27_0)
ret = afk_v27_access_remote(service->ep, dva, buffer, size, to_peer, copy);
if (ret)
dev_warn_ratelimited(service->ep->dcp->dev,
"AFKV2 unowned buffer: ep=%u interface=%u size=%zu write=%u\n",
Expand Down Expand Up @@ -2139,7 +2205,8 @@ static void afk_recv_handle(struct apple_dcp_afkep *ep, u32 channel, u32 type,
hdr_len = sizeof(*ehdr) + sizeof(*c);
if (data_size < hdr_len)
goto too_small;
if (ep->dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_H17G &&
if (ep->dcp->fw_compat == DCP_FIRMWARE_H17P &&
ep->dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_H17G &&
!afk_validate_h17p_header(data, data_size)) {
dev_err(ep->dcp->dev,
"AFK[ep:%02x]: invalid compact message length\n",
Expand All @@ -2157,7 +2224,7 @@ static void afk_recv_handle(struct apple_dcp_afkep *ep, u32 channel, u32 type,
* queue channel at face value binds "system" to 0 and makes
* every later announce and report look like a duplicate.
*/
channel = le16_to_cpup((__le16 *)(data + 2));
channel = get_unaligned_le16(data + 2);

/*
* Normalise into the wide sub-header the rest of this file
Expand All @@ -2179,6 +2246,7 @@ static void afk_recv_handle(struct apple_dcp_afkep *ep, u32 channel, u32 type,
payload = data + hdr_len;
payload_size = data_size - hdr_len;


trace_afk_recv_handle(ep, channel, type, data_size, ehdr, eshdr);


Expand Down Expand Up @@ -2523,7 +2591,7 @@ static int afk_send_epic_token(struct apple_dcp_afkep *ep, u32 channel, u16 tag,
}

spin_lock_irqsave(&ep->lock, flags);
if (ep->stopping) {
if (ep->stopping || !ep->txbfr.ready) {
ret = -ESHUTDOWN;
goto out;
}
Expand All @@ -2537,6 +2605,12 @@ static int afk_send_epic_token(struct apple_dcp_afkep *ep, u32 channel, u16 tag,
dma_rmb();
rptr = le32_to_cpu(*ep->txbfr.rptr);
wptr = le32_to_cpu(*ep->txbfr.wptr);
if (rptr >= ep->txbfr.bufsz || wptr >= ep->txbfr.bufsz ||
!IS_ALIGNED(rptr, ep->txbfr.stride) ||
!IS_ALIGNED(wptr, ep->txbfr.stride)) {
ret = -EPROTO;
goto out;
}
trace_afk_send_rwptr_pre(ep, rptr, wptr);
total_epic_size = sizeof(*ehdr) +
(ep->wire_v2 ? sizeof(struct epic_sub_hdr_h17p) : sizeof(*eshdr)) +
Expand Down
3 changes: 3 additions & 0 deletions drivers/gpu/drm/apple/afk.h
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ struct apple_epic_service_ops {
const char *class, s64 unit);
void (*init)(struct apple_epic_service *service, const char *name,
const char *class, s64 unit);
/* Consumed synchronously before init publishes service readiness. */
void (*init_props)(struct apple_epic_service *service, s64 unit,
const void *props, size_t size);
int (*call)(struct apple_epic_service *service, u32 idx,
const void *data, size_t data_size, void *reply,
size_t reply_size);
Expand Down
12 changes: 9 additions & 3 deletions drivers/gpu/drm/apple/apple_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -1465,8 +1465,13 @@ static int apple_drm_init(struct device *dev)
* the boot framebuffer owns the screen; past the eviction there is no
* way back. On refusal leave the DCP running (its shutdown sequence
* can crash it and blank the panel), pin the module and keep the boot
* framebuffer.
* framebuffer. The pin is taken before the trials, while a refusal can
* still unwind; it is given back if every trial passes.
*/
if (!try_module_get(THIS_MODULE)) {
ret = -ENODEV;
goto err_unbind;
}
drm_for_each_crtc(crtc, &apple->drm) {
const char *reason = "none";

Expand All @@ -1480,9 +1485,9 @@ static int apple_drm_init(struct device *dev)
/*
* The DCPs keep running and keep their pipelines: pin the
* module and the DRM device their CRTCs and connectors live
* in, and keep them out of shutdown and sleep.
* in, and keep them out of shutdown and sleep. The module
* reference taken before the trials is kept.
*/
__module_get(THIS_MODULE);
drm_dev_get(&apple->drm);
drm_for_each_crtc(crtc, &apple->drm)
if (!t8132_ext_crtc(crtc))
Expand All @@ -1492,6 +1497,7 @@ static int apple_drm_init(struct device *dev)
t8132_ext_drm_fini(&apple->drm);
return 0;
}
module_put(THIS_MODULE);

if (retained_modeset)
drm_modeset_lock_all(&apple->drm);
Expand Down
Loading