diff --git a/Documentation/devicetree/bindings/display/apple,dcp.yaml b/Documentation/devicetree/bindings/display/apple,dcp.yaml index 9437c59a76d3a..e43066be6aa33 100644 --- a/Documentation/devicetree/bindings/display/apple,dcp.yaml +++ b/Documentation/devicetree/bindings/display/apple,dcp.yaml @@ -92,6 +92,21 @@ properties: - const: mbox - const: secure + apple,secure-mbox: + $ref: /schemas/types.yaml#/definitions/phandle + description: + The coprocessor's secure RTBuddy port, on a machine whose boot loader + hands the display over only to a node with a single mailbox in mboxes. + The driver takes it as the "secure" mailbox. Elsewhere the port is the + second entry of mboxes. + + apple,merged-mode-limit: + type: boolean + description: + The platform's limit on merged modes applies to this external display + coprocessor. A display takes a second coprocessor as its pair only + while one is left for every external display that is present. + iommus: maxItems: 1 diff --git a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml index 8afd38261fe30..71c6458c15310 100644 --- a/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml +++ b/Documentation/devicetree/bindings/mailbox/apple,mailbox.yaml @@ -81,6 +81,7 @@ properties: iop,secure-rtbuddy-proxy. It is polled, with no interrupts described. items: - enum: + - apple,t6050-secure-rtbuddy-proxy - apple,t8140-secure-rtbuddy-proxy - const: apple,secure-rtbuddy-proxy diff --git a/Documentation/devicetree/bindings/mfd/apple,smc.yaml b/Documentation/devicetree/bindings/mfd/apple,smc.yaml index c35e7d0e10faa..34416179acfa0 100644 --- a/Documentation/devicetree/bindings/mfd/apple,smc.yaml +++ b/Documentation/devicetree/bindings/mfd/apple,smc.yaml @@ -68,6 +68,22 @@ properties: hwmon: $ref: /schemas/hwmon/apple,smc-hwmon.yaml + apple,wake-reasons: + $ref: /schemas/types.yaml#/definitions/uint32-array + minItems: 1 + maxItems: 64 + items: + maximum: 63 + description: | + The bits of the SMC's wake record that have a name on this board, as the + ADT's smc-pmu node numbers them (event_name-bitN). + + apple,wake-reason-names: + $ref: /schemas/types.yaml#/definitions/string-array + minItems: 1 + maxItems: 64 + description: The names of the bits in apple,wake-reasons, in the same order. + additionalProperties: false required: diff --git a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml index c32148802bd18..a8908c524d1ae 100644 --- a/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml +++ b/Documentation/devicetree/bindings/soc/apple/apple,t6050-sleep.yaml @@ -117,10 +117,12 @@ properties: description: The AP pin controller, whose pins a deep sleep resets. apple,pinctrl-skip-pins: - $ref: /schemas/types.yaml#/definitions/uint32-array + oneOf: + - $ref: /schemas/types.yaml#/definitions/uint32-array + - type: boolean description: | Pins neither saved nor restored. From the ADT, set by the bootloader; - without it no pin is saved. + without it no pin is saved. Empty where every pin is saved. apple,sleep-low-pins: $ref: /schemas/types.yaml#/definitions/uint32-array @@ -144,6 +146,14 @@ properties: The GFX die's wake sources left enabled for a sleep. From the ADT, set by the bootloader. + apple,display-method-sleep: + type: boolean + description: | + The display coprocessors take the sleep through their firmware 27 method + table: its sleep call and its swap, the panel's AV and DP services and the + external processors' handling around a sleep. Without it they keep the + method table they had and take the sleep's endpoint transport alone. + apple,clk-gating-boot: $ref: /schemas/types.yaml#/definitions/uint32-matrix items: diff --git a/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi b/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi index 9b0f2f0c3376e..5ef086dee5765 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi +++ b/arch/arm64/boot/dts/apple/t6050-j714s-sleep-soc.dtsi @@ -4576,7 +4576,11 @@ * taking that DART down and back to the live value before using it again. The router's host * also needs the port's PHY, which it stops after the router and starts before it. The left * port's router was never up in a trace: it has none of this and is powered off for a sleep. + * + * A board that includes these SoC values without that router (no acio2) defines + * T6050_SLEEP_SOC_NO_CIO first. */ +#ifndef T6050_SLEEP_SOC_NO_CIO &die0 { ps_prot: syscon@2803f0000 { compatible = "apple,t6050-ps-prot", "syscon"; @@ -4595,3 +4599,4 @@ &apciec2_dart { apple,clock-protection = <&ps_prot 31>; }; +#endif /* T6050_SLEEP_SOC_NO_CIO */ diff --git a/arch/arm64/boot/dts/apple/t6050-j714s.dts b/arch/arm64/boot/dts/apple/t6050-j714s.dts index 18b7c700c8469..0b83928178a4b 100644 --- a/arch/arm64/boot/dts/apple/t6050-j714s.dts +++ b/arch/arm64/boot/dts/apple/t6050-j714s.dts @@ -792,6 +792,36 @@ #include "t6050-j714s-sleep-soc.dtsi" #include "t6050-j714s-sleep-adt.dtsi" +/* A merged mode's pair is given only while every external display has an engine */ +&dcpext0 { + apple,merged-mode-limit; +}; + +&dcpext1 { + apple,merged-mode-limit; +}; + +&dcpext2 { + apple,merged-mode-limit; +}; + +&dcpext3 { + apple,merged-mode-limit; +}; + +/* The display coprocessors take the sleep through their firmware 27 method table */ +&sleep { + apple,display-method-sleep; +}; + +/* The SMC's wake reasons (ADT smc-pmu, event_name-bitN) */ +&smc { + apple,wake-reasons = <0 8 9 11 13 35 40 41 42 43 44 45 48>; + apple,wake-reason-names = "pwrbtn", "lid", "sdconn", "charger", "wifibt", + "trackpadkeyboard", "acattach", "acdetach", "USB-C_plug", + "USB2_plug", "USB2_wake", "aupo", "rtc"; +}; + /* * Sound through the AOP, as on J813: its audio service runs the serializers, the * CS42L84 headphone jack on admac-base-ns TX2/RX2 and the six SN012776 speaker amps diff --git a/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi b/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi new file mode 100644 index 0000000000000..040cee8bae63b --- /dev/null +++ b/arch/arm64/boot/dts/apple/t6050-k116s-sleep.dtsi @@ -0,0 +1,285 @@ +// SPDX-License-Identifier: GPL-2.0+ OR MIT +/* + * Deep sleep (suspend to RAM) on the K116s: the J714s description with this board's differences + * (the pins, the display coprocessor's secure mailbox, dcpext0). The sleep controller and what + * it needs from the rest of the tree. + */ + +/ { + aliases { + /* The boot loader finds the SIO by this alias */ + sio = &sio; + }; + + sleep: sleep-controller@280600000 { + compatible = "apple,t6050-sleep"; + reg = <0x2 0x80600000 0x0 0x4000>, + <0x2 0x80900000 0x0 0x4000>, + <0x2 0x88300000 0x0 0xc000>, + <0x23 0x00e80000 0x0 0x4000>, + <0x23 0x80600000 0x0 0xc000>, + <0x23 0x88300000 0x0 0x4000>, + <0x2 0x80760000 0x0 0x10000>, + <0x2 0x807d4000 0x0 0x4000>, + <0x2 0x80930000 0x0 0x4000>, + <0x23 0x00e90000 0x0 0x4000>, + <0x23 0x80760000 0x0 0x10000>, + <0x2 0x80700000 0x0 0x20000>, + <0x23 0x80700000 0x0 0x14000>, + <0x2 0x807ec000 0x0 0x4000>, + <0x2 0x80950000 0x0 0x4000>, + <0x23 0x807dc000 0x0 0x4000>, + <0x2 0x80620000 0x0 0x4000>, + <0x2 0x8062c000 0x0 0x4000>, + <0x2 0x80688000 0x0 0x4000>, + <0x2 0x88f04000 0x0 0x4000>, + <0x2 0x8836c000 0x0 0x4000>, + <0x2 0x88330000 0x0 0x4000>, + <0x2 0x80920000 0x0 0x4000>, + <0x2 0x8a014000 0x0 0x4000>, + <0x2 0x86700000 0x0 0x14000>, + <0x2 0x86806000 0x0 0x3000>, + <0x2 0x84240000 0x0 0x20000>, + <0x2 0x803f0000 0x0 0x4000>, + <0x2 0x88370000 0x0 0x4000>, + <0x23 0x88370000 0x0 0x4000>, + <0x2 0x10e40000 0x0 0x10000>, + <0x2 0x11e40000 0x0 0x10000>, + <0x2 0x12e40000 0x0 0x10000>, + <0x4 0x17020000 0x0 0x4000>, + <0x4 0x17980000 0x0 0x4000>, + <0x2 0x80000000 0x0 0x4000>, + <0x2 0x80078000 0x0 0x4000>, + <0x23 0x80078000 0x0 0x4000>, + <0x22 0x20200000 0x0 0x8000>, + <0x22 0x20400000 0x0 0x8000>, + <0x22 0x20600000 0x0 0x8000>, + <0x22 0x20800000 0x0 0x8000>, + <0x22 0x22200000 0x0 0x8000>, + <0x2 0x88004000 0x0 0x4000>, + <0x23 0x88004000 0x0 0x4000>, + <0x23 0x80400000 0x0 0x4000>; + reg-names = "ps0", "ps1", "ps-aon", "ps-gpx", "ps-media", "ps-gfx-aon", + "clk", "clk-soc", "clk1", "afr-clk", "media-clk", + "perf", "media-perf", "table0", "table1", "media-table", + "cluster", "pwrgate", "cpu-start", "commit", "wdt", "wdt-aux", + "disp-gate", "spmi", "pmc-voters", "pmc-rails", "ptd", "gapf", + "aon-clk", "media-aon-clk", "cpm0", "cpm1", "cpm2", + "storage-phy", "storage-phy-ip", + "clkgen", "clkgen-78", "media-clkgen-78", + "mcc22", "mcc23", "mcc24", "mcc25", "mcc26", + "wake", "wake-gfx", "aic-gfx"; + apple,display-coprocessors = <&dcp>, <&dcpext0>, <&dcpext1>, <&dcpext2>, <&dcpext3>; + apple,spmi-buses = <&nub_spmi_a0>, <&nub_spmi2>, <&nub_spmi_a1>, <&nub_spmi3>, + <&aop_spmi0>; + /* SEP's, PMP0's, SIO's and the DCP's DART, stopped in the sleep's last steps */ + apple,sleep-darts = <&sep_dart>, <&pmp0_dart>, <&sio_dart>, <&dcp_dart>; + /* The N1's host: its link is shut down for the sleep and brought back after it */ + apple,radio-pcie = <&pcie0>; + apple,pinctrl = <&pinctrl_ap>; + /* The display coprocessors take the sleep through their firmware 27 method table */ + apple,display-method-sleep; + }; +}; + +/* The SMC's wake reasons (ADT smc-pmu, event_name-bitN) */ +&smc { + apple,wake-reasons = <0 8 9 11 13 35 40 41 42 43 44 45 48>; + apple,wake-reason-names = "pwrbtn", "lid", "sdconn", "charger", "wifibt", + "trackpadkeyboard", "acattach", "acdetach", "USB-C_plug", + "USB2_plug", "USB2_wake", "aupo", "rtc"; +}; + +/* + * The N1's warm reset (ADT pci-bridge0 function-warm_reset: the SMC, key 'bpli'). The N1's + * firmware does not survive a sleep; the host resets the N1 after the wake, before its link + * trains. The writes that give the reset are the boot loader's to add (see the binding). + */ +&port00 { + apple,function-warm-reset = <&smc 0x62706c69 0x1000000>; +}; + +/* On through the commit: the sleep stops their users in its last steps. */ +&ps_pmp { + apple,always-on; +}; + +&ps_pms_sram { + apple,always-on; +}; + +&ps_gfx { + apple,always-on; +}; + +&ps_spi_p { + apple,always-on; +}; + +&ps_atc3_usb_aon { + apple,always-on; +}; + +&ps_sio { + apple,always-on; + status = "okay"; +}; + +&ps_sio_cpu { + apple,always-on; + status = "okay"; +}; + +/* The port controllers put in system power state S3 before the commit, then SLEEP */ +&hpm1 { + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; +}; + +&hpm2 { + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; +}; + +/* + * The MagSafe port's PD controller (ADT hpm5, nub-spmi-a0 0x08), described as + * on the J714s so that the sleep puts it in S3 with the others. + */ +&nub_spmi_a0 { + hpm5: usb-pd@8 { + compatible = "apple,sn201202x"; + reg = <0x8 SPMI_USID>; + apple,no-liquid-detection; + apple,sleep-ssps; + apple,sleep-ssps-rules; + apple,reset-on-failed-probe; + }; +}; + +&{/soc@200000000} { + /* + * The cores' power-gate enables, /arm-io/pmgr reg[0] + 0x2c000, one word per core: the + * boot loader leaves core 0's (the boot core's) and core 12's clear. Without them the + * boot cluster never powers down, and the sleep never gets past its first sequence. + */ + cluster_pwrgate: power-gate@28062c000 { + compatible = "apple,t6050-cluster-pwrgate", "apple,cluster-pwrgate"; + reg = <0x2 0x8062c000 0x0 0x4>, + <0x2 0x8062c0c0 0x0 0x4>; + }; +}; + +/* AOP2, running until the commit: its ASC mailbox at the AOP2 ASC + 0x8000 */ +&{/soc@200000000} { + aop2_mbox: mailbox@291608000 { + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x2 0x91608000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + #mbox-cells = <0>; + }; +}; + +&aop2 { + reg = <0x2 0x91600000 0x0 0x4000>; + reg-names = "asc"; + /delete-property/ interrupts; + mboxes = <&aop2_mbox>; + mbox-names = "mbox"; + apple,dma-range = <0x110 0x0 0x10 0x0>; + status = "okay"; +}; + +/* + * The SIO, running until the sleep's own stop: its ASC bank split around its mailbox. The boot + * loader enables it with its firmware and tables. + */ +/delete-node/ &sio; + +&{/soc@200000000} { + sio_mbox: mailbox@505e08000 { + compatible = "apple,t6050-asc-mailbox", "apple,asc-mailbox-v4"; + reg = <0x5 0x5e08000 0x0 0x4000>; + interrupts = , + , + , + ; + interrupt-names = "send-empty", "send-not-empty", + "recv-empty", "recv-not-empty"; + power-domains = <&ps_sio_cpu>; + #mbox-cells = <0>; + }; + + sio: dma-controller@505e00000 { + compatible = "apple,t6050-sio", "apple,sio"; + reg = <0x5 0x5e00000 0x0 0x8000>, + <0x5 0x5850000 0x0 0x4000>, + <0x5 0x5e0c000 0x0 0x7c000>; + reg-names = "asc", "auxiliary", "asc-tail"; + #dma-cells = <1>; + dma-channels = <128>; + mboxes = <&sio_mbox>; + iommus = <&sio_dart 0>; + power-domains = <&ps_sio_cpu>; + clocks = <&peripheral_clocks 359>, <&peripheral_clocks 358>; + status = "disabled"; + }; +}; + +&sio_dart { + power-domains = <&ps_sio_cpu>; + status = "okay"; +}; + +/* + * The AP pins a deep sleep neither saves nor restores: none. The K116s ADT's gpio0 has no + * no-restore-gpio-pins (the J714s's has 5 6 7 112 141), and with those skipped the panel stayed + * dark after a deep sleep. Without the property no pin is saved at all. + */ +&sleep { + apple,pinctrl-skip-pins = <>; +}; + +/* + * The display coprocessor's secure mailbox (ADT /arm-io/dcp-exclave-mailbox, + * iop,secure-rtbuddy-proxy, reg 0x4cae7c000). Firmware 27.2 acknowledges no IOP power state + * while nothing answers it, as on T8140. + */ +&{/soc@200000000} { + dcp_secure_mbox: mailbox@4cae7c000 { + compatible = "apple,t6050-secure-rtbuddy-proxy", "apple,secure-rtbuddy-proxy"; + reg = <0x4 0xcae7c000 0x0 0x4000>; + #mbox-cells = <0>; + }; +}; + +/* + * Not in mboxes: the boot loader hands the display over only to a node whose mboxes is the one + * ASC mailbox. The driver adds it to the live tree at probe. + */ +&dcp { + apple,secure-mbox = <&dcp_secure_mbox>; +}; + +/* + * dcpext0 without its Type-C route, as dcpext1 to 3 are here. Its PHY's DP side + * is not described on this board, and the engine's probe waits for it and gives the engine + * up; a deep sleep needs the engine bound, to stop its firmware. + */ +&dcpext0 { + /delete-property/ apple,connector-type; + /delete-property/ apple,dptx-die; + /delete-property/ apple,typec-dptx-phys; + /delete-property/ apple,typec-mux-indices; + /delete-property/ phys; + /delete-property/ phy-names; + /delete-property/ mux-controls; + /delete-property/ mux-control-names; + /delete-node/ typec-routes; +}; diff --git a/arch/arm64/boot/dts/apple/t6050-k116s.dts b/arch/arm64/boot/dts/apple/t6050-k116s.dts index fe6468edc72c1..f049736e9489f 100644 --- a/arch/arm64/boot/dts/apple/t6050-k116s.dts +++ b/arch/arm64/boot/dts/apple/t6050-k116s.dts @@ -913,3 +913,107 @@ &avd { status = "okay"; }; + +/* + * The PMU's RTC and its alarm. ADT: the PMU's info-rtc (0x2002), + * info-rtc_alarm_offset (0x2008), info-rtc_irq_mask_offset (0x200e), + * info-rtc_alarm_ctrl (0x2000) and info-rtc_scrpad (0x2100), the registers of + * the T6041 PMU. It raises no interrupt on this SoC: an armed alarm can only + * wake the machine from a firmware sleep, not from s2idle. + */ +&pmu { + pmu_rtc: rtc { + compatible = "apple,t6050-pmu-rtc", "apple,t6041-pmu-rtc"; + nvmem-cells = <&rtc_offset>; + nvmem-cell-names = "rtc_offset"; + wakeup-source; + }; +}; + +/* + * The video encoder's power states, as on the J714s. iBoot leaves VENC0_SYS on, and the SoC does + * not enter the firmware-driven sleep with it on. Enabled and unused, genpd turns it off at + * boot. No encoder is described yet. + */ +&ps_fab1_piogw { + apple,firmware-owned; + status = "okay"; +}; + +&ps_fab0_soc { + apple,always-on; + status = "okay"; +}; + +&ps_venc0_sys { + status = "okay"; +}; + +&ps_venc0_dma { + status = "okay"; +}; + +&ps_venc0_pipe4 { + status = "okay"; +}; + +&ps_venc0_pipe5 { + status = "okay"; +}; + +&ps_venc0_me0 { + status = "okay"; +}; + +&ps_venc0_me1 { + status = "okay"; +}; + +/* + * Deep sleep: the sleep controller's description and the J714s's SoC values, then what differs + * on this board (firmware 27.2). + */ +#include "t6050-k116s-sleep.dtsi" +/* No USB4 router is described on this board: without the J714s's CIO sleep part. */ +#define T6050_SLEEP_SOC_NO_CIO +#include "t6050-j714s-sleep-soc.dtsi" + +/* + * macOS on this board parks the four clock words with 0x80100000 in the last 0.5 ms before its + * commit (traced as an aura guest); the J714s's values have bit 10 set. + */ +&sleep { + apple,seq-commit-sio = + <0x0 17 0x290 0x400024f>, + <0x0 17 0x2a0 0x400024f>, + <0x1 51 0xa0 0x0>, + <0x0 51 0xa0 0x80100000>, + <0x1 51 0xa0 0x0>, + <0x1 51 0xa4 0x0>, + <0x0 51 0xa4 0x80100000>, + <0x1 51 0xa4 0x0>, + <0x1 51 0x94 0x0>, + <0x0 51 0x94 0x80100000>, + <0x1 51 0x94 0x0>, + <0x1 51 0x90 0x0>, + <0x0 51 0x90 0x80100000>, + <0x1 51 0x90 0x0>; +}; + +/* + * The PMP firmware's __DATA starts at 0x56000 on 27.2 (ADT pmp0 segment-ranges: __TEXT 0x56000 + * bytes, __DATA 0x9b000 bytes), not at the J714s's 0x58000. With the wrong range kept over the + * sleep the PMP does not come back (endpoint discovery -62). + */ +&pmp0 { + apple,sram-keep = <0x56000 0x9b000>; +}; + +/* + * The panel's plug takes about 2.9 ms here from the video interface's announcement to the + * firmware's "ioav i/f is now closed", and the next round of reports follows about 33 ms later. + * With the J714s's 2500 us the open landed 25 us before the close. + */ +&dcp { + apple,panel-video-open-delay-us = <10000>; +}; diff --git a/drivers/dma/apple-sio.c b/drivers/dma/apple-sio.c index cb75beb54ae99..4c5b0b1627b5e 100644 --- a/drivers/dma/apple-sio.c +++ b/drivers/dma/apple-sio.c @@ -697,12 +697,13 @@ static const struct sio_hw_data sio_hw_t6050 = { }; /* - * The T6050 description is in force on the board it has run on. On another T6050 board the - * node is taken as before: by its generic compatible. + * The T6050 description, with its stop at the sleep's commit, is in force on the boards + * that describe the sleep. On another T6050 board the node is taken as before: by its + * generic compatible. */ static bool sio_t6050_board(void) { - return of_machine_is_compatible("apple,j714s"); + return apple_t6050_sleep_described(); } static const struct of_device_id sio_of_match[] = { diff --git a/drivers/gpu/drm/apple/dcp-internal.h b/drivers/gpu/drm/apple/dcp-internal.h index 515e6bf065f09..a4b9c10ead2a5 100644 --- a/drivers/gpu/drm/apple/dcp-internal.h +++ b/drivers/gpu/drm/apple/dcp-internal.h @@ -972,6 +972,10 @@ struct apple_dcp { /* V27 sleep: the panel's next mode set is the mode it already has */ bool v27_keep_mode; + /* Since the V27 wake: the panel's video interface opened, firmware reported the panel */ + struct completion v27_wake_video, v27_wake_hotplug; +#define V27_WAKE_VIDEO_MS 1500 +#define V27_WAKE_HOTPLUG_MS 250 /* V27 sleep: the output area of the call being pushed holds this (an in/out word) */ const void *push_out_prefill; diff --git a/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc index a5aa449b446dd..0ac6d6c344761 100644 --- a/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-modeset-probe-v27.inc @@ -7,11 +7,16 @@ static int dcp_peer_probe_power(struct apple_dcp *dcp, struct apple_dcp *peer, bool on) { struct dcp_peer_video_wait *wait; - struct dcp_method_entry method = { .name = "peer_power_test", - .tag = {'A', '4', '8', '4'} }; + struct dcp_method_entry method = { .name = "peer_power_test" }; u8 power[16] = {}, response[8]; + char peer_tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A484", method.tag) ?: + iomfb_v27_tag(peer->v27_methods, "A484", peer_tag); + if (ret) + return ret; + wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return -ENOMEM; @@ -134,13 +139,18 @@ static int dcp_peer_probe_modeset(struct apple_dcp *dcp, struct apple_dcp *peer, bool firmware_requires_merge) { struct dcp_peer_video_wait *wait; - struct dcp_method_entry method = { .name = "peer_modeset_test", - .tag = {'A', '4', '1', '3'} }; + struct dcp_method_entry method = { .name = "peer_modeset_test" }; __le32 mode[2] = {video->color_id, video->timing_id}; u32 primary_id, peer_id, phase, status; unsigned long deadline; + char peer_tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A413", method.tag) ?: + iomfb_v27_tag(peer->v27_methods, "A413", peer_tag); + if (ret) + return ret; + { guard(mutex)(&dcp_peer_lock); if (dcp->peer_reserved != peer || peer->peer_owner != dcp || diff --git a/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc index 33def11c752ea..a1c017c98e085 100644 --- a/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-probe-v27.inc @@ -24,9 +24,7 @@ static ssize_t peer_setup_test_store(struct device *dev, struct device_attribute *attr, const char *buf, size_t count) { - static const struct dcp_method_entry method = { - .name = "setup_peer_dcp", .tag = {'A', '3', '6', '6'}, - }; + struct dcp_method_entry method = { .name = "setup_peer_dcp" }; struct apple_dcp *dcp = dev_get_drvdata(dev); struct dcp_peer_probe_wait *wait; __le32 enabled = cpu_to_le32(1); @@ -55,6 +53,11 @@ static ssize_t peer_setup_test_store(struct device *dev, kref_put(&wait->refs, dcp_peer_probe_free); return -EBUSY; } + ret = iomfb_v27_tag(dcp->v27_methods, "A366", method.tag); + if (ret) { + kref_put(&wait->refs, dcp_peer_probe_free); + return ret; + } kref_get(&wait->refs); /* Peer-DCP setup (one bool argument): four input * bytes (boolean followed by zero padding), no output. diff --git a/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc index ed73f355eda7e..343fa1872bada 100644 --- a/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-swap-probe-v27.inc @@ -6,6 +6,7 @@ struct dcp_peer_background { struct iomfb_transaction transaction; struct dcp_peer_video_wait *wait; struct dcp_swap_submit_req_v27 wire; + char tag[4]; bool sent; }; @@ -26,10 +27,11 @@ static void dcp_peer_background_start(struct apple_dcp *dcp, { struct dcp_peer_background *background = container_of(transaction, struct dcp_peer_background, transaction); - struct dcp_method_entry method = { .name = "peer_background_test", - .tag = {'A', '4', '0', '8'} }; + struct dcp_method_entry method = { .name = "peer_background_test" }; struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U }; + memcpy(method.tag, background->tag, sizeof(method.tag)); + background->sent = true; if (!dcp_present_begin_h17p(&dcp->present_state_h17p, background->wire.swap.swap_id)) { @@ -55,13 +57,18 @@ static int dcp_peer_queue_background(struct apple_dcp *dcp, struct dcp_peer_video_wait *wait) { struct dcp_peer_background *background; + char tag[4]; int ret; + ret = iomfb_v27_tag(dcp->v27_methods, "A408", tag); + if (ret) + return ret; background = kzalloc_obj(*background); if (!background) return -ENOMEM; background->wire = *wire; background->wait = wait; + memcpy(background->tag, tag, sizeof(background->tag)); kref_get(&wait->refs); background->transaction.start = dcp_peer_background_start; background->transaction.release = dcp_peer_background_release; @@ -185,6 +192,7 @@ static void dcp_peer_a407_background_start(struct apple_dcp *dcp, { struct dcp_peer_a407_background *background = container_of(transaction, struct dcp_peer_a407_background, transaction); + /* The J714s's 27.0 swap form, whose table names A407 (iomfb_v27_methods_j714s()). */ struct dcp_method_entry method = { .name = "peer_background_test", .tag = {'A', '4', '0', '7'} }; struct dcp_swap_submit_resp_v27 failed = { .ret = ~0U }; @@ -345,6 +353,8 @@ static ssize_t peer_swap_test_store(struct device *dev, dcp->crtc->base.state->active || peer->crtc->base.state->active || dcp->fw_compat != DCP_FIRMWARE_V_27_0 || peer->fw_compat != DCP_FIRMWARE_V_27_0 || + /* Both engines must take the swap form the owner sends. */ + dcp->v27_a407 != peer->v27_a407 || !device_trylock(peer->dev)) { ret = -EBUSY; goto out; diff --git a/drivers/gpu/drm/apple/dcp-peer-v27.inc b/drivers/gpu/drm/apple/dcp-peer-v27.inc index a824ab7e99265..34ee3e472d3ef 100644 --- a/drivers/gpu/drm/apple/dcp-peer-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-v27.inc @@ -8,12 +8,14 @@ module_param(peer_allocation_probe, bool, 0444); MODULE_PARM_DESC(peer_allocation_probe, "Firmware27 logical peer allocation for merged modes (default: on)"); /* - * The platform limit on merged modes (dcp_fabric_merged_fits()) holds on the - * board it has run on, for the J714s's T6050 external display processors. + * The platform limit on merged modes (dcp_fabric_merged_fits()) holds for the + * external display processors whose node says so (apple,merged-mode-limit). */ static bool dcp_peer_limit_applies(struct apple_dcp *dcp) { - return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && dcp_j714s_ext(dcp->dev); + return dcp->fw_compat == DCP_FIRMWARE_V_27_0 && + of_device_is_compatible(dcp->dev->of_node, "apple,t6050-dcpext") && + of_property_read_bool(dcp->dev->of_node, "apple,merged-mode-limit"); } /* @@ -68,8 +70,7 @@ void dcp_peer_limit_update_v27(struct drm_device *drm) unsigned int n = 0, i; struct drm_crtc *crtc; - /* Neither a board without the limit nor a device without CRTCs. */ - if (!of_machine_is_compatible("apple,j714s") || !drm->mode_config.num_crtc) + if (!drm->mode_config.num_crtc) return; scoped_guard(mutex, &dcp_peer_lock) { drm_for_each_crtc(crtc, drm) { diff --git a/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc b/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc index 3560cfc447a99..86b0f20b5823d 100644 --- a/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc +++ b/drivers/gpu/drm/apple/dcp-peer-video-probe-v27.inc @@ -37,6 +37,10 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent, if (out_size > sizeof(wait->reply)) return -EINVAL; + /* The calls name 27.0 IDs: this engine's build may number them differently. */ + ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag); + if (ret) + return ret; /* An unrelated AP thread gets its own firmware stream. A369/A367/etc. * must not be mistaken for nested callbacks of the pending A413. * Stream1 (the driver's OOB context) is independent of stream0. @@ -46,7 +50,6 @@ static int dcp_peer_video_call_stream(struct apple_dcp *dcp, bool independent, wait = kzalloc(sizeof(*wait), GFP_KERNEL); if (!wait) return -ENOMEM; - memcpy(method.tag, tag, sizeof(method.tag)); wait->size = out_size; init_completion(&wait->done); kref_init(&wait->refs); diff --git a/drivers/gpu/drm/apple/dcp-v27-sleep.inc b/drivers/gpu/drm/apple/dcp-v27-sleep.inc index 027927a4ec055..756ce9467ae68 100644 --- a/drivers/gpu/drm/apple/dcp-v27-sleep.inc +++ b/drivers/gpu/drm/apple/dcp-v27-sleep.inc @@ -250,6 +250,41 @@ static int dcp_v27_ext_cycle_ready(struct apple_dcp *dcp) return dcp->s2r_dcp_dart ? 0 : -ENODEV; } +/* + * A restart with the secure port (firmware 27.2), as dcp_s2r_warm_restart() does it: the + * port restarted before RUN, mapped between the main mailbox's IOP report and its AP on, then on. + */ +static int dcp_v27_warm_restart(struct apple_dcp *dcp, bool strict) +{ + int ret; + + if (dcp->secure_rtk && dcp->secure_answered) { + dcp_secure_poll_stop(dcp); + ret = apple_rtkit_port_restart(dcp->secure_rtk); + if (ret) + dev_warn(dcp->dev, "V27 wake: secure port restart: %d\n", ret); + } + return strict ? apple_rtkit_warm_restart_strict(dcp->rtk) : + apple_rtkit_warm_restart_stopped(dcp->rtk); +} + +static int dcp_v27_boot(struct apple_dcp *dcp) +{ + bool secure = dcp->secure_rtk && dcp->secure_answered; + int ret; + + ret = apple_rtkit_boot_with(dcp->rtk, secure ? dcp_secure_port_map : NULL, dcp); + if (ret || !secure) + return ret; + ret = dcp->secure_map_ret ?: apple_rtkit_port_on(dcp->secure_rtk, DCP_SECURE_TIMEOUT_MS); + if (ret) + dev_warn(dcp->dev, "V27 wake: secure port map %d (%lld us), on %d\n", + dcp->secure_map_ret, dcp->secure_map_us, ret); + else + dcp_secure_poll_start(dcp); + return 0; +} + /* * macOS's DCP stop/restart between its wake steps: sessions closed, AP and IOP * idle, IDLE_DONE, receive off, CPU_CONTROL RUN off; dart-dcp stopped, the display's domain off and, @@ -273,7 +308,11 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) if (s && s->cycle_failed) return -ECANCELED; dcp_v27_sessions(dcp, false); - ret = apple_rtkit_idle_strict(dcp->rtk); + /* With a secure port: the IOP idle is taken only after the port's AP idle */ + if (dcp->secure_rtk && dcp->secure_answered) + ret = apple_rtkit_idle_strict_with(dcp->rtk, dcp_secure_port_idle, dcp); + else + ret = apple_rtkit_idle_strict(dcp->rtk); if (ret) { dev_warn(dcp->dev, "V27 wake: RTKit cycle: idle %d\n", ret); dcp_v27_sessions(dcp, true); @@ -349,12 +388,12 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) dev_warn(dcp->dev, "V27 wake: RTKit cycle: display DART rewrite %d\n", ret); } } - ret = apple_rtkit_warm_restart_strict(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, true); if (!ret) { writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); run_status = readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_STATUS); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); } /* * An external processor that did not start is not left down: its DART, power words and @@ -373,13 +412,13 @@ static int dcp_v27_rtkit_cycle(struct apple_dcp *dcp, unsigned int pause_ms) ret = apple_dart_m5_display_cycle(dcp->s2r_dcp_dart, true); } if (!ret) - ret = apple_rtkit_warm_restart_stopped(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, false); if (!ret) { writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); run_status = readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_STATUS); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); } } if (ret) { @@ -1213,6 +1252,8 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) return ret; s->soft_off = false; } + reinit_completion(&dcp->v27_wake_video); + reinit_completion(&dcp->v27_wake_hotplug); WRITE_ONCE(dcp->v27_keep_mode, true); } else if (s->ext_wake) { ret = dcp_v27_ext_wake_calls(s); @@ -1258,6 +1299,8 @@ static int dcp_v27_reopen_live(struct apple_dcp *dcp) return 0; } +static int dcp_v27_secure_idle_atomic(void *data); + static int dcp_v27_late_arm(void *data) { struct dcp_v27_sleep *s = data; @@ -1287,6 +1330,8 @@ static int dcp_v27_late_arm(void *data) ret = apple_rtkit_v27_arm(dcp->rtk, &s->rx); if (ret) dev_info(dcp->dev, "V27 arm: RTKit %d\n", ret); + else + apple_rtkit_v27_set_after_ap(s->rx, dcp_v27_secure_idle_atomic, dcp); } if (ret) { if (s->display && !s->display_early) { @@ -1305,6 +1350,20 @@ static int dcp_v27_late_arm(void *data) return 0; } +/* + * With a secure port (firmware 27.2): its AP idle between the main mailbox's AP idle and + * its IOP idle, polled, as this runs with interrupts off. Not acknowledged, it fails the stop: + * the firmware would not take the IOP idle. + */ +static int dcp_v27_secure_idle_atomic(void *data) +{ + struct apple_dcp *dcp = data; + + if (!dcp->secure_rtk || !dcp->secure_answered) + return 0; + return apple_rtkit_v27_port_ap_idle_atomic(dcp->secure_rtk, 5000); +} + static int dcp_v27_late_check(void *data) { struct dcp_v27_sleep *s = data; @@ -1439,9 +1498,11 @@ static int dcp_v27_sleep_prepare(struct apple_dcp *dcp) dev_warn(dcp->dev, "V27 sleep: no sleep RPC arguments in the DT\n"); return -EOPNOTSUPP; } - if (!dcp->retain_dma || IS_ERR_OR_NULL(dcp->rtk) || !dcp->active || dcp->crashed || dcp->quiescing || - dcp->secure_rtk) - return dcp_v27_refuse(dcp, "coprocessor not live (dma, rtkit, active, crashed, quiescing, secure)"); + if (!dcp->retain_dma || IS_ERR_OR_NULL(dcp->rtk) || !dcp->active || dcp->crashed || dcp->quiescing) + return dcp_v27_refuse(dcp, "coprocessor not live (dma, rtkit, active, crashed, quiescing)"); + /* The secure port is idled from the late stop, with nothing else reading it. */ + if (dcp->secure_rtk && dcp->secure_answered) + dcp_secure_poll_stop(dcp); /* Mode-config suspend is the actual DRM scanout-owner boundary. No HPD * shortcut: external firmware still executes A484/A500/AFK and late IDLE. */ @@ -1606,7 +1667,18 @@ static int dcp_v27_sleep_prepare(struct apple_dcp *dcp) if (ret) goto uncertain; for (i = ARRAY_SIZE(v27_sleep_endpoints); i-- > 0;) { - ret = afk_v27_sleep_control(dcp->sleep_v27_ep[v27_sleep_endpoints[i] - 0x20], false); + struct apple_dcp_afkep *ep = dcp->sleep_v27_ep[v27_sleep_endpoints[i] - 0x20]; + int check; + + /* + * An endpoint still taking a message (a service announced late, seen on 0x31 of + * a K116s DCPEXT) answers -EBUSY for a moment: wait it out as the other steps do, + * rather than refuse the sleep. + */ + if (ep) + read_poll_timeout(afk_v27_sleep_check, check, check != -EBUSY, 1000, + 300 * USEC_PER_MSEC, false, ep); + ret = afk_v27_sleep_control(ep, false); if (ret) { char name[12]; @@ -1694,7 +1766,7 @@ static int dcp_v27_sleep_restart(struct apple_dcp *dcp) if (s->phase == V27_STOPPED) { ret = apple_sleep_display_v27_power_ready(dcp->dev); if (!ret) - ret = apple_rtkit_warm_restart_strict(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, true); /* * The final step stopped this CPU and it is still stopped: the firmware boots * from its reset vector next, so the state tracked before the stop does not @@ -1703,12 +1775,12 @@ static int dcp_v27_sleep_restart(struct apple_dcp *dcp) if (ret == -EUCLEAN && READ_ONCE(dcp->s2r_fw_down) && !(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) & APPLE_DCP_COPROC_CPU_CONTROL_RUN)) - ret = apple_rtkit_warm_restart_stopped(dcp->rtk); + ret = dcp_v27_warm_restart(dcp, false); if (ret) return dcp_v27_fail(s, ret); writel(readl(dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL) | APPLE_DCP_COPROC_CPU_CONTROL_RUN, dcp->coproc_reg + APPLE_DCP_COPROC_CPU_CONTROL); - ret = apple_rtkit_boot(dcp->rtk); + ret = dcp_v27_boot(dcp); if (ret) return dcp_v27_fail(s, ret); } diff --git a/drivers/gpu/drm/apple/dcp.c b/drivers/gpu/drm/apple/dcp.c index b16995083020d..f2fdb18090a19 100644 --- a/drivers/gpu/drm/apple/dcp.c +++ b/drivers/gpu/drm/apple/dcp.c @@ -272,6 +272,36 @@ static int dcp_secure_port_init(struct apple_dcp *dcp) { struct device *dev = dcp->dev; + /* + * The secure mailbox named outside mboxes, which the boot loader wants to be the one ASC + * mailbox (it refuses the display handoff otherwise). Added to the live node here. + */ + if (of_property_match_string(dev->of_node, "mbox-names", "secure") < 0 && + of_property_present(dev->of_node, "apple,secure-mbox")) { + static const char names[] = "mbox\0secure"; + struct property *boxes, *nm; + const __be32 *main_box, *sec; + __be32 *v; + int len; + + main_box = of_get_property(dev->of_node, "mboxes", &len); + sec = of_get_property(dev->of_node, "apple,secure-mbox", NULL); + boxes = devm_kzalloc(dev, sizeof(*boxes), GFP_KERNEL); + nm = devm_kzalloc(dev, sizeof(*nm), GFP_KERNEL); + v = devm_kcalloc(dev, 2, sizeof(*v), GFP_KERNEL); + if (main_box && len == 4 && sec && boxes && nm && v) { + v[0] = main_box[0]; + v[1] = sec[0]; + boxes->name = "mboxes"; + boxes->value = v; + boxes->length = 8; + nm->name = "mbox-names"; + nm->value = (void *)names; + nm->length = sizeof(names); + if (!of_update_property(dev->of_node, boxes)) + of_update_property(dev->of_node, nm); + } + } if (of_property_match_string(dev->of_node, "mbox-names", "secure") < 0) return 0; @@ -467,12 +497,13 @@ MODULE_PARM_DESC(t6050_ext_sleep, /* * What a T6050 external display processor gained outside the firmware 27 sleep itself (the * Type-C reconnect skipped for a crashed one, a crashed one refusing a deep sleep before - * anything is stopped, the link line) is in force on the board it has run on, the J714s. - * Elsewhere, other boards with the same SoC included, these are as before. + * anything is stopped, the link line) is in force where the sleep's description has the + * display coprocessors sleep by their method table (apple,display-method-sleep). Elsewhere, + * other boards with the same SoC included, these are as before. */ static bool dcp_j714s_ext(struct device *dev) { - return of_machine_is_compatible("apple,j714s") && + return apple_t6050_sleep_property("apple,display-method-sleep") && of_device_is_compatible(dev->of_node, "apple,t6050-dcpext"); } @@ -5914,31 +5945,25 @@ static bool dcp_ext26_admitted(struct device_node *np) } /* - * J716c shares the 27.0 endpoint-control wire format, not the J714s normal - * IOMFB method or panel profile. Establish this before RTKit can receive any - * application traffic, including traffic that invalidates a later inventory. + * Firmware 27 (T6050) sleep endpoint-control transport. Establish this before + * RTKit can receive any application traffic, including traffic that invalidates + * a later inventory. Admitted for a T6050 DCP/DCPEXT whose firmware 27 method + * table has an ID for every call the sleep sends. */ static bool dcp_v27_sleep_transport_supported(struct apple_dcp *dcp) { struct device *dev = dcp->dev; - char compat[DCP_FW_VERSION_STR_LEN]; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP)) return false; - if (dcp->v27_j714s) - return true; - if (!of_machine_is_compatible("apple,j716c") || - !of_machine_is_compatible("apple,t6050") || - !(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") || + if (!(of_device_is_compatible(dev->of_node, "apple,t6050-dcp") || of_device_is_compatible(dev->of_node, "apple,t6050-dcpext")) || !dcp->hw.adopt_live_session || dcp->hw.iomfb_method_profile != DCP_IOMFB_METHODS_DEFAULT || dcp->fw_compat != DCP_FIRMWARE_V_27_0) return false; - /* The enum also covers later 27.x method tables. */ - return dcp_read_fw_version(dev, "apple,firmware-compat", compat) >= 0 && - !strcmp(compat, "27.0.0"); + return iomfb_v27_sleep_methods_complete(dcp->v27_methods); } /* @@ -7214,6 +7239,8 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) INIT_LIST_HEAD(&dcp->swapped_out_fbs); mutex_init(&dcp->swapped_out_fbs_lock); + init_completion(&dcp->v27_wake_video); + init_completion(&dcp->v27_wake_hotplug); ret = dcp_backlight_init(dcp, dev); if (ret) return ret; @@ -7221,7 +7248,7 @@ static int dcp_platform_probe_pipe(struct platform_device *pdev) dcp->fw_compat = fw_compat; dcp->v27_j714s = fw_compat == DCP_FIRMWARE_V_27_0 && - of_machine_is_compatible("apple,j714s"); + apple_t6050_sleep_property("apple,display-method-sleep"); /* * Probe-lifetime like the desktop state: component bind opens a devres * group on this device and releases it on failure or unbind. diff --git a/drivers/gpu/drm/apple/epic/panelavep.c b/drivers/gpu/drm/apple/epic/panelavep.c index cd4507b2bf78f..6e7a0cb682bcf 100644 --- a/drivers/gpu/drm/apple/epic/panelavep.c +++ b/drivers/gpu/drm/apple/epic/panelavep.c @@ -131,9 +131,11 @@ static void panelav_open_worker(struct work_struct *work) if (ret) dev_warn(service->ep->dcp->dev, "panel AV: video interface %u OPEN failed: %d\n", service->channel, ret); - else + else { + complete(&service->ep->dcp->v27_wake_video); dev_info(service->ep->dcp->dev, "panel AV: video interface %u opened\n", service->channel); + } afk_service_put(service); kfree(w); } diff --git a/drivers/gpu/drm/apple/iomfb.c b/drivers/gpu/drm/apple/iomfb.c index 38282c45ba88f..1f3304d9c02d7 100644 --- a/drivers/gpu/drm/apple/iomfb.c +++ b/drivers/gpu/drm/apple/iomfb.c @@ -893,11 +893,12 @@ static void iomfb_v27_sleep_start(struct apple_dcp *dcp, rpc->data, iomfb_v27_sleep_done, rpc); dcp->push_out_prefill = NULL; if ((rpc->a442 || rpc->a442_key) && !rpc->oob) { - static const struct dcp_method_entry a442 = { - .name = "v27_a442", .tag = { 'A', '4', '4', '2' }, - }; + struct dcp_method_entry a442 = { .name = "v27_a442" }; u8 in[92]; + if (iomfb_v27_tag(dcp->v27_methods, "A442", a442.tag)) + return; + memset(in, 0xaa, sizeof(in)); memset(in, 0, 16); in[8] = rpc->a442_key ?: 0x41; @@ -905,6 +906,9 @@ static void iomfb_v27_sleep_start(struct apple_dcp *dcp, if (rpc->a442_key) { memset(in + 80, 0, 12); in[84] = 0x20; + } else if (iomfb_v27_methods_renumbered(dcp->v27_methods)) { + /* 27.2 reads the filler as an index count and a block size. */ + memset(in + 16, 0, sizeof(in) - 16); } dcp_push(dcp, true, &a442, sizeof(in), 4100, in, iomfb_v27_a442_done, NULL); } @@ -982,6 +986,9 @@ int iomfb_v27_sleep_plain(struct apple_dcp *dcp, bool on) static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) { + struct dcp_method_entry method = { + .name = a500 ? "v27_sleep_500" : "v27_sleep_power", + }; struct iomfb_v27_sleep_rpc *rpc; u8 args[IOMFB_V27_SLEEP_ARGS]; int ret; @@ -992,6 +999,9 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) (a500 || flags ? iomfb_v27_sleep_args(dcp, a500, args) : iomfb_v27_display_args(dcp, false, args))) return -EOPNOTSUPP; + ret = iomfb_v27_tag(dcp->v27_methods, a500 ? "A500" : "A484", method.tag); + if (ret) + return ret; rpc = kzalloc_obj(*rpc); if (!rpc) return -ENOMEM; @@ -1000,10 +1010,7 @@ static int iomfb_v27_rpc(struct apple_dcp *dcp, bool a500, bool on, bool flags) rpc->status = ~0U; rpc->transaction.start = iomfb_v27_sleep_start; rpc->transaction.release = iomfb_v27_sleep_release; - rpc->method = (struct dcp_method_entry) { - .name = a500 ? "v27_sleep_500" : "v27_sleep_power", - }; - memcpy(rpc->method.tag, a500 ? "A500" : "A484", 4); + rpc->method = method; /* * Off, before each DCP's and DCPEXT's sleep idle: A484 with the sleep's flags, then * A500's sleep form. On, after the wake: A500's wake form, then A484 with the flags. @@ -1075,6 +1082,7 @@ int iomfb_v27_sleep_a115(struct apple_dcp *dcp, bool awake) static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in, u32 in_len, u32 out_len, bool inout, u8 a442_key) { + struct dcp_method_entry method = { .name = "v27_display_stage" }; struct iomfb_v27_sleep_rpc *rpc; int ret; @@ -1082,6 +1090,9 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in dcp->fw_compat != DCP_FIRMWARE_V_27_0 || in_len > sizeof(rpc->data) || (inout && out_len > sizeof(rpc->data))) return -EOPNOTSUPP; + ret = iomfb_v27_tag(dcp->v27_methods, tag, method.tag); + if (ret) + return ret; rpc = kzalloc_obj(*rpc); if (!rpc) return -ENOMEM; @@ -1091,8 +1102,7 @@ static int iomfb_v27_call(struct apple_dcp *dcp, const char *tag, const void *in rpc->any_reply = true; rpc->transaction.start = iomfb_v27_sleep_start; rpc->transaction.release = iomfb_v27_sleep_release; - rpc->method = (struct dcp_method_entry) { .name = "v27_display_stage" }; - memcpy(rpc->method.tag, tag, 4); + rpc->method = method; rpc->input = in_len; rpc->output = out_len; rpc->inout = inout; diff --git a/drivers/gpu/drm/apple/iomfb.h b/drivers/gpu/drm/apple/iomfb.h index e230a9eac9c5c..0b2c04b7c6123 100644 --- a/drivers/gpu/drm/apple/iomfb.h +++ b/drivers/gpu/drm/apple/iomfb.h @@ -198,6 +198,28 @@ enum dcpep_method { dcpep_pipe_set_476, dcpep_unnamed_500, iomfbep_set_brightness_correction, + /* + * Firmware 27.x sleep and paired-mode calls named by their 27.0 ID. + * Optional for single-engine boot (iomfb_v27_missing_method() skips + * them); iomfb_v27_tag() refuses any call missing from a renumbered + * table. + */ + dcpep_v27_sleep_a115, + dcpep_v27_wake_a442, + dcpep_v27_peer_a360, + dcpep_v27_peer_a361, + dcpep_v27_peer_a362, + dcpep_v27_peer_a364, + dcpep_v27_peer_a365, + dcpep_v27_peer_a366, + dcpep_v27_peer_a367, + dcpep_v27_peer_a368, + dcpep_v27_peer_a369, + dcpep_v27_peer_a370, + dcpep_v27_peer_a371, + dcpep_v27_peer_a372, + dcpep_v27_peer_a373, + dcpep_v27_peer_a449, dcpep_num_methods }; @@ -220,6 +242,9 @@ struct dcp_method_entry { /* The IOMFB method table of a firmware 27.x build, by its compat string; NULL if unknown. */ const struct dcp_method_entry *iomfb_v27_methods(const char *compat); +bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods); +int iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out); +bool iomfb_v27_sleep_methods_complete(const struct dcp_method_entry *methods); const struct dcp_method_entry *iomfb_v27_methods_j714s(struct device *dev, const struct dcp_method_entry *methods); /* The first method of a firmware 27.x table that has no ID, NULL if none. */ diff --git a/drivers/gpu/drm/apple/iomfb_template.c b/drivers/gpu/drm/apple/iomfb_template.c index 0e9064dcb289b..01c7b942709b7 100644 --- a/drivers/gpu/drm/apple/iomfb_template.c +++ b/drivers/gpu/drm/apple/iomfb_template.c @@ -4264,6 +4264,21 @@ int DCP_FW_NAME(iomfb_modeset)(struct apple_dcp *dcp, keep_mode = dcp->v27_j714s && xchg(&dcp->v27_keep_mode, false) && dcp->mode.color_mode_id == mode->color_mode_id && dcp->mode.timing_mode_id == mode->timing_mode_id; + /* + * Firmware 27.2: sent once the panel's video interface is open again and the firmware + * has reported the panel, which it does after the open. + */ + if (keep_mode && iomfb_v27_methods_renumbered(dcp->v27_methods)) { + if (!wait_for_completion_timeout(&dcp->v27_wake_video, + msecs_to_jiffies(V27_WAKE_VIDEO_MS))) + dev_warn(dcp->dev, "V27 wake: panel video interface not open after %u ms\n", + V27_WAKE_VIDEO_MS); + else if (!wait_for_completion_timeout(&dcp->v27_wake_hotplug, + msecs_to_jiffies(V27_WAKE_HOTPLUG_MS))) + dev_warn(dcp->dev, "V27 wake: no hotplug report %u ms after the panel's open\n", + V27_WAKE_HOTPLUG_MS); + keep_mode = false; + } #endif dcp->mode = (struct dcp_set_digital_out_mode_req){ .color_mode_id = mode->color_mode_id, diff --git a/drivers/gpu/drm/apple/iomfb_v27.c b/drivers/gpu/drm/apple/iomfb_v27.c index a7d7d6b93f341..460d93a167034 100644 --- a/drivers/gpu/drm/apple/iomfb_v27.c +++ b/drivers/gpu/drm/apple/iomfb_v27.c @@ -164,6 +164,22 @@ static const struct dcp_method_entry dcp_methods_27_0[dcpep_num_methods] = { * the IOMFB calls around it; 27.2 moved both to A550/A551. */ IOMFB_METHOD("A500", dcpep_unnamed_500), + IOMFB_METHOD("A115", dcpep_v27_sleep_a115), + IOMFB_METHOD("A442", dcpep_v27_wake_a442), + IOMFB_METHOD("A360", dcpep_v27_peer_a360), + IOMFB_METHOD("A361", dcpep_v27_peer_a361), + IOMFB_METHOD("A362", dcpep_v27_peer_a362), + IOMFB_METHOD("A364", dcpep_v27_peer_a364), + IOMFB_METHOD("A365", dcpep_v27_peer_a365), + IOMFB_METHOD("A366", dcpep_v27_peer_a366), + IOMFB_METHOD("A367", dcpep_v27_peer_a367), + IOMFB_METHOD("A368", dcpep_v27_peer_a368), + IOMFB_METHOD("A369", dcpep_v27_peer_a369), + IOMFB_METHOD("A370", dcpep_v27_peer_a370), + IOMFB_METHOD("A371", dcpep_v27_peer_a371), + IOMFB_METHOD("A372", dcpep_v27_peer_a372), + IOMFB_METHOD("A373", dcpep_v27_peer_a373), + IOMFB_METHOD("A449", dcpep_v27_peer_a449), }; /* @@ -222,6 +238,22 @@ static const struct dcp_method_entry dcp_methods_27_2[dcpep_num_methods] = { * dispatch where 26A428's compares 'A500' (0x1df68c vs 0x1de0dc, same code). */ IOMFB_METHOD("A550", dcpep_unnamed_500), + IOMFB_METHOD("A115", dcpep_v27_sleep_a115), + IOMFB_METHOD("A492", dcpep_v27_wake_a442), + IOMFB_METHOD("A360", dcpep_v27_peer_a360), + IOMFB_METHOD("A361", dcpep_v27_peer_a361), + IOMFB_METHOD("A362", dcpep_v27_peer_a362), + IOMFB_METHOD("A364", dcpep_v27_peer_a364), + IOMFB_METHOD("A365", dcpep_v27_peer_a365), + IOMFB_METHOD("A366", dcpep_v27_peer_a366), + IOMFB_METHOD("A367", dcpep_v27_peer_a367), + IOMFB_METHOD("A368", dcpep_v27_peer_a368), + IOMFB_METHOD("A369", dcpep_v27_peer_a369), + IOMFB_METHOD("A370", dcpep_v27_peer_a370), + IOMFB_METHOD("A371", dcpep_v27_peer_a371), + IOMFB_METHOD("A372", dcpep_v27_peer_a372), + IOMFB_METHOD("A373", dcpep_v27_peer_a373), + IOMFB_METHOD("A499", dcpep_v27_peer_a449), }; /* @@ -269,6 +301,67 @@ const struct dcp_method_entry *iomfb_v27_methods(const char *compat) return NULL; } +/* + * Translate @tag, a 27.0 ID named directly by sleep or paired-mode callers, + * into the build of @methods (4 bytes in @out). On 27.0 (including the J714s + * copy) the tag is sent unchanged. On a renumbered build every ID must come + * from @methods; a missing entry returns -EOPNOTSUPP instead of sending an + * unknown tag that would panic the firmware. + */ +int iomfb_v27_tag(const struct dcp_method_entry *methods, const char *tag, char *out) +{ + unsigned int i; + char in[4]; + + if (!methods) + return -EOPNOTSUPP; + memcpy(in, tag, 4); + if (!iomfb_v27_methods_renumbered(methods)) { + memcpy(out, in, 4); + return 0; + } + for (i = 0; i < dcpep_num_methods; i++) { + if (dcp_methods_27_0[i].tag[0] && !memcmp(dcp_methods_27_0[i].tag, in, 4)) { + if (!methods[i].tag[0]) + return -EOPNOTSUPP; + memcpy(out, methods[i].tag, 4); + return 0; + } + } + return -EOPNOTSUPP; +} + +/* Whether @methods is a build's table whose AP method IDs differ from 27.0's. */ +bool iomfb_v27_methods_renumbered(const struct dcp_method_entry *methods) +{ + return methods && (methods == dcp_methods_27_2 || methods == dcp_methods_27_3); +} + +static const enum dcpep_method iomfb_v27_sleep_methods[] = { + dcpep_is_main_display, + dcpep_pipe_cfg_414, + dcpep_set_power_state, + dcpep_pipe_set_476, + dcpep_pipe_query_478, + dcpep_unnamed_500, + dcpep_v27_sleep_a115, + dcpep_v27_wake_a442, +}; + +/* Whether @methods names an ID for every call the firmware 27 display sleep sends. */ +bool iomfb_v27_sleep_methods_complete(const struct dcp_method_entry *methods) +{ + unsigned int i; + + if (!methods) + return false; + for (i = 0; i < ARRAY_SIZE(iomfb_v27_sleep_methods); i++) { + if (!methods[iomfb_v27_sleep_methods[i]].tag[0]) + return false; + } + return true; +} + /* * The 27.0 table for the J714s, the board the firmware 27 sleep has run on (dcp->v27_j714s): a * copy with the sleep's A500 added. The shared table keeps the methods it had, so every other @@ -309,9 +402,14 @@ const char *iomfb_v27_missing_method(const struct dcp_method_entry *methods, *count = 0; for (i = 0; i < dcpep_num_methods; i++) { - /* Only a firmware sleep sends unnamed_500, and it checks the build's table. */ + /* + * Only sleep and paired-mode paths send unnamed_500 and the + * v27-optional entries; each checks the build's table before + * sending. + */ if (!dcp_methods_27_0[i].tag[0] || methods[i].tag[0] || - i == dcpep_dfb_ready_query || i == dcpep_unnamed_500) + i == dcpep_dfb_ready_query || i == dcpep_unnamed_500 || + i >= dcpep_v27_sleep_a115) continue; if (!first) first = dcp_methods_27_0[i].name; @@ -406,6 +504,9 @@ static bool trampoline_hotplug_h17p(struct apple_dcp *dcp, int tag, if (!(request->tiled_display_null & 1)) memcpy(out, request->tiled_display, sizeof(request->tiled_display)); + /* The V27 wake's mode set waits for the firmware's report of the panel */ + if (request->connected && dcp->v27_j714s) + complete(&dcp->v27_wake_hotplug); return trampoline_hotplug(dcp, tag, out, in); } diff --git a/drivers/gpu/drm/asahi/g17/sleep.c b/drivers/gpu/drm/asahi/g17/sleep.c index 380e6662f1419..0131ace971222 100644 --- a/drivers/gpu/drm/asahi/g17/sleep.c +++ b/drivers/gpu/drm/asahi/g17/sleep.c @@ -46,14 +46,13 @@ #define ASC_CPU_CONTROL 0x44 #define ASC_CPU_CONTROL_RUN BIT(4) -/* Only the M5 boards with a deep sleep need a wrapped provider translation here: the J714s - * and the J716c. Other G17 clients retain their established direct-domain methods below. +/* Only the M5 boards with a deep sleep need a wrapped provider translation here: those whose + * device tree describes it. Other G17 clients retain their established direct-domain methods + * below. */ static bool asahi_g17_m5_provider(struct device *dev) { - return (of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c")) && - of_machine_is_compatible("apple,t6050") && + return apple_t6050_sleep_described() && of_device_is_compatible(dev->of_node, "apple,agx-g17s"); } diff --git a/drivers/iommu/apple-dart-v27-admission.inc b/drivers/iommu/apple-dart-v27-admission.inc index 906be5ef222ef..7b6c2be51b903 100644 --- a/drivers/iommu/apple-dart-v27-admission.inc +++ b/drivers/iommu/apple-dart-v27-admission.inc @@ -10,9 +10,7 @@ static bool apple_dart_v27_provider(struct device *dev, resource_size_t base) unsigned int i; if (!IS_ENABLED(CONFIG_APPLE_SOC_SLEEP) || - !(of_machine_is_compatible("apple,j714s") || - (of_machine_is_compatible("apple,j716c") && - of_machine_is_compatible("apple,t6050"))) || + !apple_t6050_sleep_described() || !of_device_is_compatible(dev->of_node, "apple,t6050-dart")) return false; for (i = 0; i < ARRAY_SIZE(ids); i++) diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index 33a29ce9beb04..cf960d718638d 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -5471,7 +5471,7 @@ static int apple_dart_probe(struct platform_device *pdev) if (dart->cold_ane && !IS_BUILTIN(CONFIG_APPLE_DART)) return -EOPNOTSUPP; dart->isp_host = of_device_is_compatible(dev->of_node, "apple,t6050-isp-dart"); - dart->isp_sleep = dart->isp_host && of_machine_is_compatible("apple,j714s"); + dart->isp_sleep = dart->isp_host && apple_t6050_sleep_described(); dart->power_retained = dart->isp_host; dart->per_stream = dart->isp_host || of_device_is_compatible(dev->of_node, "apple,t8140-dart") || diff --git a/drivers/irqchip/irq-apple-aic.c b/drivers/irqchip/irq-apple-aic.c index 52a892164c3a4..769e4105d9ac3 100644 --- a/drivers/irqchip/irq-apple-aic.c +++ b/drivers/irqchip/irq-apple-aic.c @@ -56,6 +56,7 @@ #include #include #include +#include #include #include #include @@ -278,8 +279,8 @@ struct aic_info { bool vm_timer_fiq_readonly; /* A firmware-driven suspend powers the controller down: aic_syscore_ops keep it. */ bool fw_suspend; - /* If set, fw_suspend holds on these boards only */ - const char *const *fw_suspend_boards; + /* If set, fw_suspend holds only where this says the sleep is described */ + bool (*fw_suspend_described)(void); }; static const struct aic_info aic1_info __initconst = { @@ -328,12 +329,9 @@ static const struct aic_info aic3_info __initconst = { /* * The M5 Pro's sleep: the last steps mask every interrupt and acknowledge events by hand. The - * save and restore are set up on the boards with a T6050 sleep, the J714s and the J716c; + * save and restore are set up on the boards whose device tree describes a T6050 sleep; * another T6050 board is as one without them. */ -static const char *const aic3_t6050_sleep_boards[] __initconst = { - "apple,j714s", "apple,j716c", NULL -}; static const struct aic_info aic3_t6050_info __initconst = { .version = 3, @@ -341,7 +339,7 @@ static const struct aic_info aic3_t6050_info __initconst = { .fast_ipi = true, .local_fast_ipi = true, .fw_suspend = true, - .fw_suspend_boards = aic3_t6050_sleep_boards, + .fw_suspend_described = apple_t6050_sleep_described, }; static const struct aic_info aic3_t8140_info __initconst = { @@ -1298,8 +1296,7 @@ static struct syscore aic_syscore = { static void __init aic_sleep_init(struct aic_irq_chip *irqc) { if (!irqc->info.fw_suspend || - (irqc->info.fw_suspend_boards && - !of_machine_compatible_match(irqc->info.fw_suspend_boards))) + (irqc->info.fw_suspend_described && !irqc->info.fw_suspend_described())) return; aic_sleep.irq_cfg = kcalloc(irqc->nr_die * irqc->nr_irq, sizeof(u32), GFP_KERNEL); diff --git a/drivers/mfd/macsmc-test.c b/drivers/mfd/macsmc-test.c index 2dec0920f982d..fc07a3eb61719 100644 --- a/drivers/mfd/macsmc-test.c +++ b/drivers/mfd/macsmc-test.c @@ -352,6 +352,9 @@ static void macsmc_lid_wake_test(struct kunit *test) static void macsmc_wake_reason_test(struct kunit *test) { + static const struct apple_smc_wake_reason j714s[] = { + { 8, "lid" }, { 9, "sdconn" }, { 13, "wifibt" }, { } + }; struct macsmc_test_context *ctx = test->priv; char names[128]; @@ -371,8 +374,8 @@ static void macsmc_wake_reason_test(struct kunit *test) KUNIT_EXPECT_EQ(test, apple_smc_wake_reason_bit(&ctx->smc, "lid"), 8); KUNIT_EXPECT_EQ(test, apple_smc_wake_reason_bit(&ctx->smc, "ipd_touch"), -1); - /* The J714s's: T8132's lid and radio bits, its SD reader at bit 9. */ - ctx->smc.wake_reasons = apple_smc_j714s_wake_reasons; + /* A device tree's own, here the J714s's: its SD reader at bit 9. */ + ctx->smc.wake_reasons = j714s; apple_smc_wake_reason_names(&ctx->smc, BIT_ULL(8) | BIT_ULL(9) | BIT_ULL(10) | BIT_ULL(13), names, sizeof(names)); KUNIT_EXPECT_STREQ(test, names, "lid sdconn wifibt"); diff --git a/drivers/mfd/macsmc.c b/drivers/mfd/macsmc.c index ad4d84f9c3dd2..0cf23c46a16ac 100644 --- a/drivers/mfd/macsmc.c +++ b/drivers/mfd/macsmc.c @@ -629,6 +629,30 @@ static const struct apple_smc_wake_reason apple_smc_j714s_wake_reasons[] = { { 43, "USB2_plug" }, { 44, "USB2_wake" }, { 45, "aupo" }, { 48, "rtc" }, { } }; +/* A board's own numbering, from its device tree (apple,wake-reasons and their names) */ +static const struct apple_smc_wake_reason *apple_smc_dt_wake_reasons(struct device *dev) +{ + struct device_node *np = dev->of_node; + struct apple_smc_wake_reason *r; + int i, n; + + n = of_property_count_u32_elems(np, "apple,wake-reasons"); + if (n <= 0 || n != of_property_count_strings(np, "apple,wake-reason-names")) + return NULL; + r = devm_kcalloc(dev, n + 1, sizeof(*r), GFP_KERNEL); + if (!r) + return NULL; + for (i = 0; i < n; i++) { + u32 bit; + + if (of_property_read_u32_index(np, "apple,wake-reasons", i, &bit) || bit > 63 || + of_property_read_string_index(np, "apple,wake-reason-names", i, &r[i].name)) + return NULL; + r[i].bit = bit; + } + return r; +} + static int apple_smc_probe(struct platform_device *pdev) { struct device *dev = &pdev->dev; @@ -640,15 +664,15 @@ static int apple_smc_probe(struct platform_device *pdev) smc = devm_kzalloc(dev, sizeof(*smc), GFP_KERNEL); if (!smc) return -ENOMEM; - smc->wake_reasons = of_device_is_compatible(dev->of_node, "apple,t8132-smc") ? - apple_smc_t8132_wake_reasons : apple_smc_t8140_wake_reasons; + smc->wake_reasons = apple_smc_dt_wake_reasons(dev); + if (!smc->wake_reasons) + smc->wake_reasons = of_device_is_compatible(dev->of_node, "apple,t8132-smc") ? + apple_smc_t8132_wake_reasons : apple_smc_t8140_wake_reasons; mutex_init(&smc->mutex); spin_lock_init(&smc->lock); smc->dev = &pdev->dev; - smc->saved_enabled = of_machine_is_compatible("apple,t6050") && - (of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c")) && + smc->saved_enabled = apple_t6050_sleep_described() && of_device_is_compatible(dev->of_node, "apple,t6050-smc"); if (smc->saved_enabled && of_machine_is_compatible("apple,j714s")) smc->wake_reasons = apple_smc_j714s_wake_reasons; diff --git a/drivers/nvme/host/apple-m5-sleep.h b/drivers/nvme/host/apple-m5-sleep.h index f22d6902bf256..50bcaeabde604 100644 --- a/drivers/nvme/host/apple-m5-sleep.h +++ b/drivers/nvme/host/apple-m5-sleep.h @@ -167,10 +167,8 @@ static int apple_nvme_m5_attach(struct apple_nvme *anv) { int ret; - /* Both boards use T6050 ANS2's split NVMe/NVMMU layout and retained SART. */ - if (!of_machine_is_compatible("apple,t6050") || - (!of_machine_is_compatible("apple,j714s") && - !of_machine_is_compatible("apple,j716c"))) + /* T6050 ANS2's split NVMe/NVMMU layout and retained SART, where the sleep is described. */ + if (!apple_t6050_sleep_described()) return -EOPNOTSUPP; /* The wait before the restart after a sleep comes from the DT; without it, no sleep. */ if (of_property_read_u32(anv->dev->of_node, "apple,sleep-wake-delay-ms", diff --git a/drivers/of/base.c b/drivers/of/base.c index f63a9486b1305..1e7b2e90f2f9a 100644 --- a/drivers/of/base.c +++ b/drivers/of/base.c @@ -1916,6 +1916,7 @@ int of_update_property(struct device_node *np, struct property *newprop) return rc; } +EXPORT_SYMBOL_GPL(of_update_property); static void of_alias_add(struct alias_prop *ap, struct device_node *np, int id, const char *stem, int stem_len) diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index 66b1cbe936637..e4973e5705ba3 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -5465,8 +5465,7 @@ static void apple_pcie_t6050_sleep_probe(struct platform_device *pdev, struct ap { struct apple_pcie_port *port; - if (pcie->managed_sids || !(of_machine_is_compatible("apple,j714s") || - of_machine_is_compatible("apple,j716c"))) + if (pcie->managed_sids || !apple_t6050_sleep_described()) return; /* The one port a boot loader trained; an endpoint Linux powers is parked instead. */ list_for_each_entry(port, &pcie->ports, entry) diff --git a/drivers/phy/apple/atc-t6050-combo.h b/drivers/phy/apple/atc-t6050-combo.h index 584680e398ed8..ff44fc4086652 100644 --- a/drivers/phy/apple/atc-t6050-combo.h +++ b/drivers/phy/apple/atc-t6050-combo.h @@ -122,13 +122,13 @@ static void combo_pipe_fault(struct t6050_dp *dp, const char *what, int ret) /* * What the combo PHY gained for a deep sleep outside its sleep callbacks (a wrapper domain * still held at a stop is released, a safe state with a domain still held is stopped again, - * the always-on domain's hold over the sleep) is in force on the boards with a T6050 sleep, - * the J714s and the J716c. On another T6050 board the stop, the safe state and the probe are + * the always-on domain's hold over the sleep) is in force on the boards whose device tree + * describes a T6050 sleep. On another T6050 board the stop, the safe state and the probe are * as before. */ static bool combo_sleep_board(void) { - return of_machine_is_compatible("apple,j714s") || of_machine_is_compatible("apple,j716c"); + return apple_t6050_sleep_described(); } static bool combo_domains_held(struct t6050_dp *dp) diff --git a/drivers/soc/apple/rtkit-v27-late.inc b/drivers/soc/apple/rtkit-v27-late.inc index 6f3bfd84ab0a5..44d3b92cb27b8 100644 --- a/drivers/soc/apple/rtkit-v27-late.inc +++ b/drivers/soc/apple/rtkit-v27-late.inc @@ -7,8 +7,23 @@ struct apple_rtkit_v27_scope { DECLARE_KFIFO(deferred, struct apple_mbox_msg, 64); bool held, stopped, failed; int error; + /* + * Run once between the AP state's acknowledgment and the IOP request, interrupts off. + * An error fails the idle. + */ + int (*after_ap)(void *data); + void *after_ap_data; }; +void apple_rtkit_v27_set_after_ap(struct apple_rtkit_v27_scope *s, int (*fn)(void *), void *data) +{ + if (s) { + s->after_ap = fn; + s->after_ap_data = data; + } +} +EXPORT_SYMBOL_GPL(apple_rtkit_v27_set_after_ap); + bool apple_rtkit_v27_live(struct apple_rtkit *rtk) { return !rtk->crashed && !rtk->shutting_down && @@ -118,6 +133,43 @@ int apple_rtkit_v27_check(struct apple_rtkit_v27_scope *s) } EXPORT_SYMBOL_GPL(apple_rtkit_v27_check); +/* + * A second port's AP idle with interrupts off: sent, and its acknowledgment awaited by polling + * the port's mailbox, for at most @us. The port's tracked state is not updated. + */ +int apple_rtkit_v27_port_ap_idle_atomic(struct apple_rtkit *rtk, unsigned int us) +{ + struct apple_mbox_msg msg = { + .msg0 = FIELD_PREP(APPLE_RTKIT_MGMT_TYPE, APPLE_RTKIT_MGMT_SET_AP_PWR_STATE) | + FIELD_PREP(APPLE_RTKIT_MGMT_PWR_STATE, APPLE_RTKIT_PWR_STATE_IDLE), + .msg1 = APPLE_RTKIT_EP_MGMT, + }; + unsigned int i, n = us / 10; + int ret = -ETIMEDOUT; + + for (i = 0; i < n; i++) { + ret = apple_mbox_send_nowait(rtk->mbox, msg); + if (ret != -EAGAIN && ret != -EBUSY) + break; + udelay(10); + } + if (ret) + return ret; + for (; i < n; i++) { + struct apple_mbox_msg in; + + ret = apple_mbox_recv_nowait(rtk->mbox, &in); + if (ret < 0 && ret != -EBUSY) + return ret; + if (ret > 0 && in.msg1 == APPLE_RTKIT_EP_MGMT && + FIELD_GET(APPLE_RTKIT_MGMT_TYPE, in.msg0) == APPLE_RTKIT_MGMT_SET_AP_PWR_STATE_ACK) + return 0; + udelay(10); + } + return -ETIMEDOUT; +} +EXPORT_SYMBOL_GPL(apple_rtkit_v27_port_ap_idle_atomic); + int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *s) { struct apple_rtkit *rtk; @@ -180,6 +232,11 @@ int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *s) type == APPLE_RTKIT_MGMT_SET_AP_PWR_STATE_ACK && arg == APPLE_RTKIT_PWR_STATE_IDLE) { ap_ack = true; + if (s->after_ap) { + ret = s->after_ap(s->after_ap_data); + if (ret) + goto poison; + } } else if (msg.msg1 == APPLE_RTKIT_EP_MGMT && iop_sent && !iop_ack && type == APPLE_RTKIT_MGMT_SET_IOP_PWR_STATE_ACK && arg == APPLE_RTKIT_PWR_STATE_IDLE) { diff --git a/drivers/soc/apple/rtkit.c b/drivers/soc/apple/rtkit.c index e529b4d4dd4c6..836531aec7f2c 100644 --- a/drivers/soc/apple/rtkit.c +++ b/drivers/soc/apple/rtkit.c @@ -558,11 +558,9 @@ static void apple_rtkit_management_rx(struct apple_rtkit *rtk, u64 msg) } } -static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, - struct apple_rtkit_shmem *buffer) +static int apple_rtkit_alloc_first_shmem(struct apple_rtkit *rtk, u8 ep, + struct apple_rtkit_shmem *buffer) { - if (READ_ONCE(rtk->ans_hold)) - return apple_rtkit_ans_fail(rtk, -EBUSY); /* The crash log's buffer is asked for only at a crash: serve it after a strict restart too. */ if (READ_ONCE(rtk->strict_retained_buffers) && ep != APPLE_RTKIT_EP_CRASHLOG) return -EPROTO; @@ -577,6 +575,14 @@ static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, return buffer->buffer ? 0 : -ENOMEM; } +static int apple_rtkit_alloc_shmem(struct apple_rtkit *rtk, u8 ep, + struct apple_rtkit_shmem *buffer) +{ + if (READ_ONCE(rtk->ans_hold)) + return apple_rtkit_ans_fail(rtk, -EBUSY); + return apple_rtkit_alloc_first_shmem(rtk, ep, buffer); +} + static int apple_rtkit_common_rx_get_buffer(struct apple_rtkit *rtk, struct apple_rtkit_shmem *buffer, u8 ep, u64 msg) @@ -650,7 +656,8 @@ static int apple_rtkit_common_rx_get_buffer(struct apple_rtkit *rtk, goto error; } - err = apple_rtkit_alloc_shmem(rtk, ep, &request); + /* The endpoint has no buffer yet: a first one replaces nothing the ANS hold protects */ + err = apple_rtkit_alloc_first_shmem(rtk, ep, &request); if (err) goto error; *buffer = request; @@ -2340,8 +2347,7 @@ static struct apple_rtkit *__apple_rtkit_init(struct device *dev, void *cookie, goto free_rtk; rtk->pmp_registry_v2 = of_device_is_compatible(dev->of_node, "apple,t6050-pmp-v2"); - rtk->pmp_ca_event_ack = rtk->pmp_registry_v2 && - of_machine_is_compatible("apple,j714s"); + rtk->pmp_ca_event_ack = rtk->pmp_registry_v2; init_completion(&rtk->epmap_completion); init_completion(&rtk->coreanalytics_completion); @@ -2843,6 +2849,13 @@ static int apple_rtkit_strict_idle_state(struct apple_rtkit *rtk, bool ap) } int apple_rtkit_idle_strict(struct apple_rtkit *rtk) +{ + return apple_rtkit_idle_strict_with(rtk, NULL, NULL); +} +EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict); + +/* As apple_rtkit_idle_strict(), with a step between the AP state's and the IOP state's. */ +int apple_rtkit_idle_strict_with(struct apple_rtkit *rtk, void (*after_ap)(void *data), void *data) { int ret; @@ -2853,6 +2866,8 @@ int apple_rtkit_idle_strict(struct apple_rtkit *rtk) reinit_completion(&rtk->strict_idle_done); WRITE_ONCE(rtk->strict_idle_waiting, true); ret = apple_rtkit_strict_idle_state(rtk, true); + if (!ret && after_ap) + after_ap(data); if (!ret) ret = apple_rtkit_strict_idle_state(rtk, false); if (!ret && !wait_for_completion_timeout(&rtk->strict_idle_done, @@ -2865,7 +2880,7 @@ int apple_rtkit_idle_strict(struct apple_rtkit *rtk) rtk->strict_idle_poisoned = true; return ret; } -EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict); +EXPORT_SYMBOL_GPL(apple_rtkit_idle_strict_with); int apple_rtkit_warm_restart_strict(struct apple_rtkit *rtk) { diff --git a/drivers/soc/apple/sleep.c b/drivers/soc/apple/sleep.c index 9cee856626f91..4a71b157fcc30 100644 --- a/drivers/soc/apple/sleep.c +++ b/drivers/soc/apple/sleep.c @@ -1916,10 +1916,10 @@ static int apple_sleep_validate_cpu_topology(struct apple_sleep *s) soc->cpu_cores_per_cluster > 32) return dev_err_probe(s->dev, -EINVAL, "invalid CPU-start geometry\n"); - if (soc->machine && (!of_machine_is_compatible(soc->machine) || - cpu_logical_map(0) != soc->boot_mpidr || - num_possible_cpus() != soc->cpu_count)) - return dev_err_probe(s->dev, -EINVAL, "unsupported board/CPU inventory\n"); + /* The node's compatible chose the profile: its machine is where it was measured */ + if (soc->machine && (cpu_logical_map(0) != soc->boot_mpidr || + num_possible_cpus() != soc->cpu_count)) + return dev_err_probe(s->dev, -EINVAL, "unsupported CPU inventory\n"); index = of_property_match_string(np, "reg-names", "cpu-start"); if (index < 0) diff --git a/drivers/usb/dwc3/dwc3-apple.c b/drivers/usb/dwc3/dwc3-apple.c index c5740ee25d532..5757cf33832da 100644 --- a/drivers/usb/dwc3/dwc3-apple.c +++ b/drivers/usb/dwc3/dwc3-apple.c @@ -1109,12 +1109,12 @@ static void dwc3_apple_check_hub_later(struct dwc3_apple *appledwc) /* * Waiting for a Type-C PHY that is not started after sleep is specific to the T6050 boards - * whose port controllers take the sleep's power states (J714s, J716c). The notifier work - * and its admission rules apply to every board. + * whose port controllers take the sleep's power states: those whose device tree describes + * the sleep. The notifier work and its admission rules apply to every board. */ static bool dwc3_apple_sleep_board(void) { - return of_machine_is_compatible("apple,j714s") || of_machine_is_compatible("apple,j716c"); + return apple_t6050_sleep_described(); } /* diff --git a/include/linux/soc/apple/dcp-v27-sleep.h b/include/linux/soc/apple/dcp-v27-sleep.h index 5e56c40141903..3484c04a98c2c 100644 --- a/include/linux/soc/apple/dcp-v27-sleep.h +++ b/include/linux/soc/apple/dcp-v27-sleep.h @@ -39,6 +39,8 @@ int apple_rtkit_v27_arm(struct apple_rtkit *, struct apple_rtkit_v27_scope **); bool apple_rtkit_v27_live(struct apple_rtkit *); int apple_rtkit_v27_check(struct apple_rtkit_v27_scope *); int apple_rtkit_v27_idle_atomic(struct apple_rtkit_v27_scope *); +int apple_rtkit_v27_port_ap_idle_atomic(struct apple_rtkit *rtk, unsigned int us); +void apple_rtkit_v27_set_after_ap(struct apple_rtkit_v27_scope *s, int (*fn)(void *), void *data); int apple_rtkit_v27_disarm(struct apple_rtkit_v27_scope *, bool stopped); int apple_dart_v27_claim(struct device *provider, struct device *firmware, diff --git a/include/linux/soc/apple/rtkit.h b/include/linux/soc/apple/rtkit.h index 4db916bb89f09..01b6f604148de 100644 --- a/include/linux/soc/apple/rtkit.h +++ b/include/linux/soc/apple/rtkit.h @@ -285,6 +285,7 @@ int apple_rtkit_idle(struct apple_rtkit *rtk); /* The mailbox's receive-enable bit (I2A_CONTROL bit 0): off once a slept firmware has answered its idle. */ void apple_rtkit_set_recv_enabled(struct apple_rtkit *rtk, bool enabled); int apple_rtkit_idle_strict(struct apple_rtkit *rtk); +int apple_rtkit_idle_strict_with(struct apple_rtkit *rtk, void (*after_ap)(void *data), void *data); int apple_rtkit_warm_restart_strict(struct apple_rtkit *rtk); int apple_rtkit_warm_restart_stopped(struct apple_rtkit *rtk); diff --git a/include/linux/soc/apple/sleep.h b/include/linux/soc/apple/sleep.h index db4337d663b81..09ec51cbf8050 100644 --- a/include/linux/soc/apple/sleep.h +++ b/include/linux/soc/apple/sleep.h @@ -9,10 +9,33 @@ #include #include #include +#include #include struct device; -struct device_node; + +/* + * A T6050 machine whose device tree describes the firmware-driven sleep. What a + * driver does for that sleep follows the description, not a list of boards. + * With @prop: the description also has that property. + */ +static inline bool apple_t6050_sleep_property(const char *prop) +{ + struct device_node *np; + bool ret; + + if (!of_machine_is_compatible("apple,t6050")) + return false; + np = of_find_compatible_node(NULL, NULL, "apple,t6050-sleep"); + ret = np && of_device_is_available(np) && (!prop || of_property_read_bool(np, prop)); + of_node_put(np); + return ret; +} + +static inline bool apple_t6050_sleep_described(void) +{ + return apple_t6050_sleep_property(NULL); +} /* The SMC's sleep messages: the pmVC value and the spacings between them, used as floors */ struct apple_sleep_smc_policy { diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py index b7ebb2fc9fc5f..14c5c73ee3d07 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/boot.py @@ -219,10 +219,12 @@ def t6041_v27_admission(root): selector = selector_full[:selector_full.index(cutoff)] + '\n\t(void)v14_board;\n\treturn DCP_FIRMWARE_UNKNOWN;\n}\n' return r''' #include +#include #include #include #include #include +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) typedef uint32_t u32; enum dcp_firmware_version { DCP_FIRMWARE_UNKNOWN, @@ -428,3 +430,184 @@ def t6041_v27_admission(root): return 0; } ''' + + +def v27_tag_translation(root): + iomfb_h = (root / 'drivers/gpu/drm/apple/iomfb.h').read_text() + methods_decl = iomfb_h[iomfb_h.index('enum dcpep_method {'): + iomfb_h.index('#define IOMFB_MAX_CB')] + v27_c = (root / 'drivers/gpu/drm/apple/iomfb_v27.c').read_text() + v27_tables = v27_c[v27_c.index('static const struct dcp_method_entry dcp_methods_27_0'): + v27_c.index('/* The template\'s calls resolve through')] + dcp_c = (root / 'drivers/gpu/drm/apple/dcp.c').read_text() + transport = block(dcp_c, 'static bool dcp_v27_sleep_transport_supported(') + return r''' +#include +#include +#include +#include +#include +#include +#include +#define ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0])) +#define CONFIG_APPLE_SOC_SLEEP 1 +#define IS_ENABLED(option) (option) +#define GFP_KERNEL 0 +enum dcp_firmware_version { + DCP_FIRMWARE_UNKNOWN, + DCP_FIRMWARE_V_27_0, +}; +enum dcp_iomfb_method_profile { + DCP_IOMFB_METHODS_DEFAULT, + DCP_IOMFB_METHODS_H17G, +}; +struct device_node { const char *compatible; }; +struct device { struct device_node *of_node; }; +struct apple_dcp_hw_data { + bool adopt_live_session; + enum dcp_iomfb_method_profile iomfb_method_profile; +}; +struct apple_dcp { + struct device *dev; + struct apple_dcp_hw_data hw; + enum dcp_firmware_version fw_compat; + const struct dcp_method_entry *v27_methods; +}; +static int of_device_is_compatible(const struct device_node *np, const char *s) +{ + return np && np->compatible && !strcmp(np->compatible, s); +} +static void *devm_kmemdup(struct device *dev, const void *src, size_t len, unsigned int gfp) +{ + void *copy = malloc(len); + (void)dev; (void)gfp; + if (copy) + memcpy(copy, src, len); + return copy; +} +''' + methods_decl + '\n' + v27_tables + '\n' + transport + r''' +static void expect_tag(const struct dcp_method_entry *methods, const char *in, const char *want) +{ + char out[4] = { 'X', 'X', 'X', 'X' }; + assert(iomfb_v27_tag(methods, in, out) == 0); + assert(memcmp(out, want, 4) == 0); +} + +static void expect_tag_fail(const struct dcp_method_entry *methods, const char *in) +{ + char out[4] = { 'X', 'X', 'X', 'X' }; + assert(iomfb_v27_tag(methods, in, out) == -EOPNOTSUPP); + assert(memcmp(out, "XXXX", 4) == 0); +} + +int main(void) +{ + struct device_node node = { .compatible = "apple,t6050-dcp" }; + struct device dev = { .of_node = &node }; + const struct dcp_method_entry *m27_0 = iomfb_v27_methods("27.0.0"); + const struct dcp_method_entry *m27_2 = iomfb_v27_methods("27.2.0"); + const struct dcp_method_entry *m27_3 = iomfb_v27_methods("27.3.0"); + const struct dcp_method_entry *j714s = iomfb_v27_methods_j714s(&dev, m27_0); + struct dcp_method_entry partial_27_2[dcpep_num_methods]; + unsigned int missing_count; + + assert(m27_0 && m27_2 && m27_3 && j714s); + assert(!iomfb_v27_methods_renumbered(NULL)); + assert(!iomfb_v27_methods_renumbered(m27_0)); + assert(!iomfb_v27_methods_renumbered(j714s)); + assert(iomfb_v27_methods_renumbered(m27_2)); + assert(iomfb_v27_methods_renumbered(m27_3)); + + /* NULL table fails closed. */ + expect_tag_fail(NULL, "A411"); + assert(!iomfb_v27_sleep_methods_complete(NULL)); + + /* 27.0 and J714s copy keep 27.0 IDs unchanged. */ + expect_tag(m27_0, "A411", "A411"); + expect_tag(m27_0, "A484", "A484"); + expect_tag(m27_0, "A500", "A500"); + expect_tag(m27_0, "A442", "A442"); + expect_tag(m27_0, "A449", "A449"); + expect_tag(m27_0, "A115", "A115"); + expect_tag(m27_0, "A364", "A364"); + expect_tag(j714s, "A411", "A411"); + expect_tag(j714s, "A408", "A408"); + expect_tag(j714s, "A500", "A500"); + assert(iomfb_v27_sleep_methods_complete(m27_0)); + assert(iomfb_v27_sleep_methods_complete(j714s)); + assert(!iomfb_v27_missing_method(m27_0, &missing_count) && missing_count == 0); + + /* 27.2 translates every recorded shifted and unchanged paired/sleep tag. */ + const struct { const char *in, *out; } map_27_2[] = { + { "A406", "A456" }, { "A408", "A458" }, { "A411", "A461" }, { "A412", "A462" }, + { "A413", "A463" }, { "A414", "A464" }, { "A423", "A473" }, { "A428", "A478" }, + { "A442", "A492" }, { "A449", "A499" }, { "A450", "A500" }, { "A453", "A503" }, + { "A484", "A534" }, { "A487", "A537" }, { "A489", "A539" }, { "A500", "A550" }, + { "A115", "A115" }, + { "A360", "A360" }, { "A361", "A361" }, { "A362", "A362" }, { "A364", "A364" }, + { "A365", "A365" }, { "A366", "A366" }, { "A367", "A367" }, { "A368", "A368" }, + { "A369", "A369" }, { "A370", "A370" }, { "A371", "A371" }, { "A372", "A372" }, + { "A373", "A373" }, + }; + for (unsigned int i = 0; i < ARRAY_SIZE(map_27_2); i++) + expect_tag(m27_2, map_27_2[i].in, map_27_2[i].out); + assert(iomfb_v27_sleep_methods_complete(m27_2)); + assert(!iomfb_v27_missing_method(m27_2, &missing_count) && missing_count == 0); + + /* Unrecorded tags on 27.2 fail closed (no +50 arithmetic, no 27.0 fallback). */ + expect_tag_fail(m27_2, "A495"); + expect_tag_fail(m27_2, "A499"); + expect_tag_fail(m27_2, "A375"); + expect_tag_fail(m27_2, "A999"); + + /* Incomplete renumbered table (27.3) translates recorded entries and fails closed on missing ones. */ + expect_tag(m27_3, "A453", "A503"); + const char *missing_27_3[] = { + "A411", "A413", "A484", "A500", "A442", "A449", "A115", "A364", "A367", + }; + for (unsigned int i = 0; i < ARRAY_SIZE(missing_27_3); i++) + expect_tag_fail(m27_3, missing_27_3[i]); + assert(!iomfb_v27_sleep_methods_complete(m27_3)); + assert(iomfb_v27_missing_method(m27_3, &missing_count) && missing_count > 0); + + /* Dropping an optional sleep/paired entry does not block basic boot admission, + * but does mark sleep incomplete when a sleep entry is missing. */ + memcpy(partial_27_2, m27_2, sizeof(partial_27_2)); + partial_27_2[dcpep_v27_wake_a442].tag[0] = '\0'; + assert(!iomfb_v27_missing_method(partial_27_2, &missing_count) && missing_count == 0); + assert(!iomfb_v27_sleep_methods_complete(partial_27_2)); + + /* + * Sleep transport admission keys on T6050 DCP/DCPEXT and table completeness. + * No of_machine_is_compatible() stub exists in this translation unit, enforcing + * at compile time that admission does not gate on a board model. + */ + struct apple_dcp dcp = { + .dev = &dev, + .hw = { .adopt_live_session = true, .iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT }, + .fw_compat = DCP_FIRMWARE_V_27_0, + }; + const char *t6050_compats[] = { "apple,t6050-dcp", "apple,t6050-dcpext" }; + for (unsigned int i = 0; i < ARRAY_SIZE(t6050_compats); i++) { + node.compatible = t6050_compats[i]; + dcp.v27_methods = m27_0; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = j714s; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = m27_2; assert(dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = m27_3; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = partial_27_2; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.v27_methods = NULL; assert(!dcp_v27_sleep_transport_supported(&dcp)); + } + dcp.v27_methods = m27_2; + node.compatible = "apple,t6041-dcp"; assert(!dcp_v27_sleep_transport_supported(&dcp)); + node.compatible = "apple,t6050-dcp"; + dcp.hw.adopt_live_session = false; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.hw.adopt_live_session = true; + dcp.hw.iomfb_method_profile = DCP_IOMFB_METHODS_H17G; assert(!dcp_v27_sleep_transport_supported(&dcp)); + dcp.hw.iomfb_method_profile = DCP_IOMFB_METHODS_DEFAULT; + dcp.fw_compat = DCP_FIRMWARE_UNKNOWN; assert(!dcp_v27_sleep_transport_supported(&dcp)); + + free((void *)j714s); + puts("PASS v27 tag translation fail-closed and table-driven sleep transport admission"); + return 0; +} +''' diff --git a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py index e97977c2e7860..49088b9977cf4 100644 --- a/tools/testing/selftests/drivers/gpu/apple-dcp/run.py +++ b/tools/testing/selftests/drivers/gpu/apple-dcp/run.py @@ -92,6 +92,7 @@ def main(): ('boot', 'oslog-events', boot.oslog, ((),), ()), ('boot', 'syslog-policy', boot.syslog, ((),), ()), ('boot', 't6041-v27-admission', boot.t6041_v27_admission, ((),), ()), + ('boot', 'v27-tag-translation', boot.v27_tag_translation, ((),), ()), ('edid', 'dpavserv-start', edid.startup, ((),), ()), ('edid', 'service-rebind', edid.rebind, ((),), ()), ('edid', 'provider-admission', edid.admission, ((),), ()),