diff --git a/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml b/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml index ac106575a9672..d2f0438188560 100644 --- a/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml +++ b/Documentation/devicetree/bindings/display/apple,display-subsystem.yaml @@ -19,6 +19,7 @@ properties: - enum: - apple,display-subsystem - apple,t6031-display-subsystem + - apple,t8122-display-subsystem - apple,t8132-display-subsystem - const: apple,t8132-display-diagnostics deprecated: true @@ -50,6 +51,15 @@ properties: type: boolean description: The loader validated the inherited J713 SID0 scanout mapping. + apple,dma-range: + $ref: /schemas/types.yaml#/definitions/uint64-array + minItems: 2 + maxItems: 2 + description: + Common scanout DMA aperture, encoded as a base and nonzero size. This + overrides the default aperture of each referenced DART stream. Other + consumers of the same DART retain their own apertures. + required: - compatible - iommus diff --git a/Documentation/networking/device_drivers/wifi/mt7932-neo.rst b/Documentation/networking/device_drivers/wifi/mt7932-neo.rst index 3fd4a1c81853e..187bbf70aa081 100644 --- a/Documentation/networking/device_drivers/wifi/mt7932-neo.rst +++ b/Documentation/networking/device_drivers/wifi/mt7932-neo.rst @@ -112,8 +112,9 @@ fallback reason and the result of each lookup. Station security ---------------- -The driver advertises PSK, PSK-SHA256, SAE and OWE with CCMP, plus -BIP-CMAC-128 for management protection. Firmware performs SAE +The driver advertises PSK, PSK-SHA256, SAE and OWE with CCMP as the pairwise +cipher, plus BIP-CMAC-128 for management protection. PSK also accepts a TKIP +group key, described below. Firmware performs SAE authentication and the four-way handshake and owns PTK, GTK and IGTK; there is no host key-install interface or external-auth exchange. @@ -151,9 +152,21 @@ follows the AP's RSN capabilities; it is not a firmware readback. Selectors The standard SAE PWE settings (unspecified, hunting-and-pecking, hash-to-element and both) are accepted; firmware chooses the exchange without a host PWE field. Exact PWE policy behavior on 2.4 and 5 GHz still needs -qualification. SAE-PK, SAE-EXT-KEY and additional ciphers are not advertised. OWE and +qualification. SAE-PK and SAE-EXT-KEY are not advertised. OWE and 6 GHz support are described below. +TKIP is registered so that WPA2-PSK can join a WPA/WPA2 mixed-mode access point, +which pairs a CCMP unicast key with a TKIP group key. Pairwise TKIP, WPA1, and a +TKIP group key with SAE or OWE are refused. Firmware owns the TKIP group key like +any other. MIC failure reporting and TKIP countermeasures are left to firmware and +have not been verified: firmware runs the four-way handshake, so the host has no +KCK and calling ``cfg80211_michael_mic_failure()`` would do nothing. + +J700 hardware testing joined one mixed-mode router on 2.4 and 5 GHz, and stayed +connected to a hostapd access point through 14 group rekeys at 60 second intervals +with ARP and mDNS still received. DHCP renewal, IPv6 router advertisements and a +commercial access point's own rekey still need qualification. + J700 hardware testing with NetworkManager and wpa_supplicant on a PSK+SAE transition network has confirmed, on 2.4 GHz channel 6 and 5 GHz channel 149: diff --git a/arch/arm64/boot/dts/apple/t8122-dcp.dtsi b/arch/arm64/boot/dts/apple/t8122-dcp.dtsi index 8d812eae377e8..cf3686c8255eb 100644 --- a/arch/arm64/boot/dts/apple/t8122-dcp.dtsi +++ b/arch/arm64/boot/dts/apple/t8122-dcp.dtsi @@ -33,6 +33,8 @@ display: display-subsystem { compatible = "apple,t8122-display-subsystem"; iommus = <&disp0_dart 0>; + /* Keep the inherited scanout alias when adding external streams. */ + apple,dma-range = /bits/ 64 <0x10000000000 0x1000000000>; status = "disabled"; }; }; @@ -112,6 +114,9 @@ /* * External display processor: the boot loader only reserves its * firmware, the driver starts it. DMA windows as on T8112. + * The display subsystem's stream 0 on dispext0_dart uses the display + * subsystem's own high scanout aperture; its PIODMA stream keeps the + * low window below. */ dispext0_dart: iommu@319304000 { compatible = "apple,t8122-dart", "apple,t8110-dart"; diff --git a/drivers/gpu/drm/apple/Makefile b/drivers/gpu/drm/apple/Makefile index f91642a35a9c4..24473e1497582 100644 --- a/drivers/gpu/drm/apple/Makefile +++ b/drivers/gpu/drm/apple/Makefile @@ -49,4 +49,5 @@ obj-$(CONFIG_DRM_APPLE_PARSER_KUNIT_TEST) += afkv2-test.o appledrm-$(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) += parser-test.o appledrm-$(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) += hotplug-test.o appledrm-$(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) += v14-board-test.o +appledrm-$(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) += v14-plane-test.o appledrm-$(CONFIG_DRM_APPLE_DISPLAY_KUNIT_TEST) += audio-no-sio-test.dtbo.o diff --git a/drivers/gpu/drm/apple/iomfb_v14_7.c b/drivers/gpu/drm/apple/iomfb_v14_7.c index a99bfed67183f..4e753210d957f 100644 --- a/drivers/gpu/drm/apple/iomfb_v14_7.c +++ b/drivers/gpu/drm/apple/iomfb_v14_7.c @@ -42,6 +42,7 @@ #include "iomfb_v14_7.h" #include "iomfb_v14_7_backlight.h" #include "iomfb_v14_7_board.h" +#include "iomfb_v14_7_plane.h" #include "iomfb_v14_7_link.h" #include "iomfb_v14_7_swap.h" #include "av.h" @@ -3085,12 +3086,7 @@ int iomfb_v14_7_atomic_check(struct apple_dcp *dcp, struct drm_crtc *crtc, if (fb->modifier != DRM_FORMAT_MOD_LINEAR || fb->offsets[0] || fb->pitches[0] < width * 4 || (fb->pitches[0] & 63)) return -EINVAL; - /* An external pipe may show the top-left of a larger framebuffer. */ - if (p->src_x || p->src_y || p->crtc_x || p->crtc_y || - p->src_w != width << 16 || p->src_h != height << 16 || - p->crtc_w != width || p->crtc_h != height || - (dcp->external ? fb->width < width || fb->height < height : - fb->width != width || fb->height != height)) + if (!dcp_v14_plane_fits_mode(p, width, height, dcp->external)) return -EINVAL; obj = drm_fb_dma_get_gem_obj(fb, 0); if (!obj || !obj->dma_addr || (u64)fb->pitches[0] * height > obj->base.size) @@ -3344,12 +3340,15 @@ void iomfb_v14_7_flush(struct apple_dcp *dcp, struct drm_crtc *crtc, struct drm_plane_state *p = drm_atomic_get_new_plane_state(state, crtc->primary); struct drm_crtc_state *cs = drm_atomic_get_new_crtc_state(state, crtc); struct drm_framebuffer *fb; + u32 width = 0, height = 0; if (!p) p = crtc->primary->state; if (!cs) cs = crtc->state; fb = p && p->visible ? p->fb : NULL; + if (fb) + dcp_v14_plane_scanout_size(p, dcp->external, &width, &height); /* * No swaps while an external display is off, unset, unplugged, or * being described again. @@ -3364,10 +3363,7 @@ void iomfb_v14_7_flush(struct apple_dcp *dcp, struct drm_crtc *crtc, if (!dcp->external) dcp_v14_configure_backlight(dcp); dcp->swap_start = ktime_get(); - if (dcp->v14 && dcp_v14_present(dcp->v14, fb, - fb ? (dcp->external ? p->src_w >> 16 : fb->width) : 0, - fb ? (dcp->external ? p->src_h >> 16 : fb->height) : 0, - dcp->notch_height, cs)) { + if (dcp->v14 && dcp_v14_present(dcp->v14, fb, width, height, dcp->notch_height, cs)) { dcp_drm_crtc_page_flip(dcp, ktime_get()); /* * The swap completed: the framebuffers this commit and earlier diff --git a/drivers/gpu/drm/apple/iomfb_v14_7_plane.h b/drivers/gpu/drm/apple/iomfb_v14_7_plane.h new file mode 100644 index 0000000000000..d330d38ca6d01 --- /dev/null +++ b/drivers/gpu/drm/apple/iomfb_v14_7_plane.h @@ -0,0 +1,65 @@ +/* SPDX-License-Identifier: GPL-2.0-only OR MIT */ + +#ifndef __APPLE_IOMFB_V14_7_PLANE_H__ +#define __APPLE_IOMFB_V14_7_PLANE_H__ + +#include + +#include +#include +#include + +/* + * The 14.7 presenter scans out one unscaled image of the mode's size from + * the top-left corner of the framebuffer. Judge a plane by its clipped + * rectangles, which drm_atomic_helper_check_plane_state() has set by the + * time the CRTC is checked: a plane that reaches past the right or bottom + * edge of the mode is clipped there, and what remains is exactly what the + * presenter scans out. Compositors put up such planes, for example when they + * centre a mirrored output and round its borders up on both sides. + * + * A plane that starts left of or above the mode, or that is scaled, starts + * its clipped source inside the framebuffer or differs in size from the + * mode, which the presenter cannot show. Clipping rounds the source toward + * 1:1, so a plane that reaches past the edge with a source less than a pixel + * off unscaled may clip to exactly the mode's size; it is then taken and + * shown unscaled. + * + * An external pipe may show the top-left of a larger framebuffer; the panel + * takes only a framebuffer of its mode's size. + */ +static inline bool dcp_v14_plane_fits_mode(const struct drm_plane_state *p, + u32 width, u32 height, bool external) +{ + const struct drm_framebuffer *fb = p->fb; + + if (p->src.x1 || p->src.y1 || p->dst.x1 || p->dst.y1) + return false; + if (drm_rect_width(&p->src) != (int)(width << 16) || + drm_rect_height(&p->src) != (int)(height << 16) || + drm_rect_width(&p->dst) != (int)width || + drm_rect_height(&p->dst) != (int)height) + return false; + if (external) + return fb->width >= width && fb->height >= height; + return fb->width == width && fb->height == height; +} + +/* + * The size of the image the presenter scans out for a visible plane that + * dcp_v14_plane_fits_mode() took: its clipped source on an external pipe, + * where the framebuffer may be larger, and the framebuffer on the panel. + */ +static inline void dcp_v14_plane_scanout_size(const struct drm_plane_state *p, + bool external, u32 *width, u32 *height) +{ + if (external) { + *width = drm_rect_width(&p->src) >> 16; + *height = drm_rect_height(&p->src) >> 16; + } else { + *width = p->fb->width; + *height = p->fb->height; + } +} + +#endif /* __APPLE_IOMFB_V14_7_PLANE_H__ */ diff --git a/drivers/gpu/drm/apple/v14-plane-test.c b/drivers/gpu/drm/apple/v14-plane-test.c new file mode 100644 index 0000000000000..2527b6726c759 --- /dev/null +++ b/drivers/gpu/drm/apple/v14-plane-test.c @@ -0,0 +1,146 @@ +// SPDX-License-Identifier: GPL-2.0-only OR MIT +/* + * Which primary planes the 14.7 presenter takes: one unscaled image of the + * mode's size from the top-left of the framebuffer, judged on the rectangles + * drm_atomic_helper_check_plane_state() clips to the mode, with the scaling + * limits apple_plane_atomic_check() passes it. A plane that reaches past the + * right or bottom edge of the mode is clipped there and taken; one that is + * offset into the mode, starts left of or above it, or is scaled is not. For + * a plane it takes, check the size iomfb_v14_7_flush() hands the presenter. + */ +#include + +#include +#include +#include +#include +#include +#include +#include + +#include "iomfb_v14_7_plane.h" + +struct v14_plane_case { + const char *name; + u16 hdisplay, vdisplay; /* the mode */ + u32 fb_w, fb_h; + int crtc_x, crtc_y; + u32 crtc_w, crtc_h; + u32 src_x, src_y, src_w, src_h; /* whole pixels */ + bool external; + bool fits; + u32 shown_w, shown_h; /* clipped source, when it fits */ + u32 src_w_frac; /* 16.16 fraction added to src_w */ +}; + +static const struct v14_plane_case v14_plane_cases[] = { + { "external, exact", 1920, 1080, 1920, 1080, 0, 0, 1920, 1080, + 0, 0, 1920, 1080, true, true, 1920, 1080 }, + /* + * KWin mirroring a 3024x1964 panel at scale 1.7 onto a 1920x1080 + * display: 1663 columns of picture and 129 of border on each side. + */ + { "external, one column past the right edge", 1920, 1080, 1921, 1080, + 0, 0, 1921, 1080, 0, 0, 1921, 1080, true, true, 1920, 1080 }, + { "external, one row past the bottom edge", 1920, 1080, 1920, 1081, + 0, 0, 1920, 1081, 0, 0, 1920, 1081, true, true, 1920, 1080 }, + { "external, past the right and bottom edges", 1920, 1080, 1921, 1081, + 0, 0, 1921, 1081, 0, 0, 1921, 1081, true, true, 1920, 1080 }, + /* + * Clipping rounds the source toward 1:1: 1921 + 1/65536 columns on + * 1921 clip to exactly 1920 << 16, while 1921.5 on 1921 clip to + * (1920 << 16) + 32750, which is scaled. + */ + { "external, past the edge, source a 65536th over 1:1", 1920, 1080, + 1922, 1080, 0, 0, 1921, 1080, 0, 0, 1921, 1080, true, true, + 1920, 1080, .src_w_frac = 1 }, + { "external, past the edge, source half a pixel over 1:1", 1920, 1080, + 1922, 1080, 0, 0, 1921, 1080, 0, 0, 1921, 1080, true, false, + .src_w_frac = 0x8000 }, + { "external, top-left of a larger framebuffer", 1920, 1080, 2560, 1440, + 0, 0, 1920, 1080, 0, 0, 1920, 1080, true, true, 1920, 1080 }, + { "external, starts left of the mode", 1920, 1080, 1921, 1080, + -1, 0, 1921, 1080, 0, 0, 1921, 1080, true, false }, + { "external, starts above the mode", 1920, 1080, 1920, 1081, + 0, -1, 1920, 1081, 0, 0, 1920, 1081, true, false }, + { "external, offset into the framebuffer", 1920, 1080, 1921, 1080, + 0, 0, 1920, 1080, 1, 0, 1920, 1080, true, false }, + { "external, scaled to the mode", 1920, 1080, 1921, 1080, + 0, 0, 1920, 1080, 0, 0, 1921, 1080, true, false }, + { "external, narrower than the mode", 1920, 1080, 1919, 1080, + 0, 0, 1919, 1080, 0, 0, 1919, 1080, true, false }, + { "external, positioned inside the mode", 1920, 1080, 1920, 1080, + 1, 0, 1919, 1080, 0, 0, 1919, 1080, true, false }, + { "panel, exact", 3024, 1964, 3024, 1964, 0, 0, 3024, 1964, + 0, 0, 3024, 1964, false, true, 3024, 1964 }, + { "panel, larger framebuffer", 3024, 1964, 3025, 1964, 0, 0, 3025, 1964, + 0, 0, 3025, 1964, false, false }, +}; + +static void v14_plane_case_desc(const struct v14_plane_case *c, char *desc) +{ + strscpy(desc, c->name, KUNIT_PARAM_DESC_SIZE); +} + +KUNIT_ARRAY_PARAM(v14_plane, v14_plane_cases, v14_plane_case_desc); + +static void v14_plane_fits_mode(struct kunit *test) +{ + const struct v14_plane_case *c = test->param_value; + struct drm_plane *plane = kunit_kzalloc(test, sizeof(*plane), GFP_KERNEL); + struct drm_crtc *crtc = kunit_kzalloc(test, sizeof(*crtc), GFP_KERNEL); + struct drm_framebuffer *fb = kunit_kzalloc(test, sizeof(*fb), GFP_KERNEL); + struct drm_crtc_state *crtc_state = + kunit_kzalloc(test, sizeof(*crtc_state), GFP_KERNEL); + struct drm_plane_state p; + u32 shown_w, shown_h; + int ret; + + KUNIT_ASSERT_NOT_NULL(test, plane); + KUNIT_ASSERT_NOT_NULL(test, crtc); + KUNIT_ASSERT_NOT_NULL(test, fb); + KUNIT_ASSERT_NOT_NULL(test, crtc_state); + fb->width = c->fb_w; + fb->height = c->fb_h; + crtc_state->crtc = crtc; + crtc_state->enable = true; + crtc_state->mode.hdisplay = c->hdisplay; + crtc_state->mode.vdisplay = c->vdisplay; + p = (struct drm_plane_state) { + .plane = plane, .crtc = crtc, .fb = fb, + .rotation = DRM_MODE_ROTATE_0, + .crtc_x = c->crtc_x, .crtc_y = c->crtc_y, + .crtc_w = c->crtc_w, .crtc_h = c->crtc_h, + .src_x = c->src_x << 16, .src_y = c->src_y << 16, + .src_w = (c->src_w << 16) + c->src_w_frac, + .src_h = c->src_h << 16, + }; + /* As apple_plane_atomic_check() runs it, before the CRTC is checked. */ + ret = drm_atomic_helper_check_plane_state(&p, crtc_state, + DRM_PLANE_NO_SCALING / 2, + DRM_PLANE_NO_SCALING * 4, + true, true); + KUNIT_ASSERT_EQ(test, ret, 0); + KUNIT_ASSERT_TRUE(test, p.visible); + + KUNIT_EXPECT_EQ(test, dcp_v14_plane_fits_mode(&p, c->hdisplay, c->vdisplay, + c->external), c->fits); + if (!c->fits) + return; + /* What iomfb_v14_7_flush() hands the presenter. */ + dcp_v14_plane_scanout_size(&p, c->external, &shown_w, &shown_h); + KUNIT_EXPECT_EQ(test, shown_w, c->shown_w); + KUNIT_EXPECT_EQ(test, shown_h, c->shown_h); +} + +static struct kunit_case v14_plane_test_cases[] = { + KUNIT_CASE_PARAM(v14_plane_fits_mode, v14_plane_gen_params), + {} +}; + +static struct kunit_suite v14_plane_test_suite = { + .name = "apple-dcp-v14-plane", + .test_cases = v14_plane_test_cases, +}; + +kunit_test_suite(v14_plane_test_suite); diff --git a/drivers/gpu/drm/asahi/g15/mod.rs b/drivers/gpu/drm/asahi/g15/mod.rs index 4cb221fb0a5df..9553dc46f3c55 100644 --- a/drivers/gpu/drm/asahi/g15/mod.rs +++ b/drivers/gpu/drm/asahi/g15/mod.rs @@ -202,8 +202,11 @@ impl platform::Driver for Driver<'_> { // after probe_g15 started firmware would return an unbound device. try_pin_init!(Driver { _driver: { + // Not EPROBE_DEFER: a deferred device stays listed in devices_deferred until the + // deferred-probe work runs, even after activate()'s probe fails for good. Activation + // reprobes every unbound device; a device added later sees MODULE_READY set. if !MODULE_READY.load(Ordering::Acquire) { - return Err(EPROBE_DEFER); + return Err(ENODEV); } let cfg = *info.ok_or(ENODEV)?; dev_info!(pdev.as_ref(), "G15: probing ({})\n", cfg.name); diff --git a/drivers/iommu/apple-dart-test.c b/drivers/iommu/apple-dart-test.c index dcb65db633d80..f5c8efc52e7f9 100644 --- a/drivers/iommu/apple-dart-test.c +++ b/drivers/iommu/apple-dart-test.c @@ -90,6 +90,108 @@ static void apple_dart_test_iommu_specifiers(struct kunit *test) } } +static void apple_dart_test_consumer_window(struct kunit *test) +{ + __be32 value[] = { cpu_to_be32(0x100), 0, cpu_to_be32(0x10), 0 }; + struct property property = { + .name = "apple,dma-range", + .length = sizeof(value), + .value = value, + }; + struct device_node node = { .properties = &property }; + struct of_phandle_args args = { .args_count = 1 }; + struct apple_dart *dart; + struct device *dev; + dma_addr_t dma_min, dma_max; + int i, ret; + + dev = kunit_device_register(test, "apple-dart-consumer-window-test"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + dart = kunit_kzalloc(test, sizeof(*dart), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, dart); + dart->ias = 36; + dart->pgsize = SZ_16K; + dev->of_node = &node; + + /* J613's common scanout aperture must survive both DART defaults. */ + for (i = 0; i < 2; i++) { + dart->dma_min = i ? 0 : 0x10000000000; + dart->dma_max = i ? 0xffffeffff : 0x10fffffffff; + ret = apple_dart_parse_dma_window(dev, dart, &args, + &dma_min, &dma_max); + KUNIT_EXPECT_EQ(test, ret, 0); + KUNIT_EXPECT_EQ(test, dma_min, (dma_addr_t)0x10000000000); + KUNIT_EXPECT_EQ(test, dma_max, (dma_addr_t)0x10fffffffff); + } + + /* Domain allocation gives the consumer priority over five-cell args too. */ + args.args_count = 5; + args.args[3] = 0xf; + args.args[4] = 0xffff0000; + ret = apple_dart_parse_dma_window(dev, dart, &args, &dma_min, &dma_max); + KUNIT_EXPECT_EQ(test, ret, 0); + KUNIT_EXPECT_EQ(test, dma_min, (dma_addr_t)0x10000000000); + KUNIT_EXPECT_EQ(test, dma_max, (dma_addr_t)0x10fffffffff); + + /* An override must not make a malformed stream specifier acceptable. */ + args.args[3] = 0; + args.args[4] = 0; + KUNIT_EXPECT_EQ(test, apple_dart_parse_dma_window(dev, dart, &args, + &dma_min, &dma_max), -EINVAL); + + /* PIODMA is a different consumer of the same external display DART. */ + dev->of_node = NULL; + args.args_count = 1; + args.args[0] = 4; + ret = apple_dart_parse_dma_window(dev, dart, &args, &dma_min, &dma_max); + KUNIT_EXPECT_EQ(test, ret, 0); + KUNIT_EXPECT_EQ(test, dma_min, (dma_addr_t)0); + KUNIT_EXPECT_EQ(test, dma_max, (dma_addr_t)0xffffeffff); +} + +static void apple_dart_test_invalid_consumer_window(struct kunit *test) +{ + static const struct { + u64 base, size; + } windows[] = { + { 0, 0 }, + { U64_MAX - SZ_16K + 1, 2 * SZ_16K }, + { 1, SZ_16K }, + { 0, SZ_16K + 1 }, + { 0, BIT_ULL(37) }, + }; + __be64 value[2]; + struct property property = { + .name = "apple,dma-range", + .length = sizeof(value), + .value = value, + }; + struct device_node node = { .properties = &property }; + struct of_phandle_args args = { .args_count = 1 }; + struct apple_dart *dart; + struct device *dev; + dma_addr_t dma_min, dma_max; + int i; + + dev = kunit_device_register(test, "apple-dart-invalid-window-test"); + KUNIT_ASSERT_NOT_ERR_OR_NULL(test, dev); + dart = kunit_kzalloc(test, sizeof(*dart), GFP_KERNEL); + KUNIT_ASSERT_NOT_NULL(test, dart); + dart->ias = 36; + dart->pgsize = SZ_16K; + dev->of_node = &node; + for (i = 0; i < ARRAY_SIZE(windows); i++) { + value[0] = cpu_to_be64(windows[i].base); + value[1] = cpu_to_be64(windows[i].size); + KUNIT_EXPECT_EQ(test, apple_dart_parse_dma_window(dev, dart, &args, + &dma_min, &dma_max), -EINVAL); + } + property.length = sizeof(__be32); + KUNIT_EXPECT_LT(test, apple_dart_parse_dma_window(dev, dart, &args, + &dma_min, &dma_max), 0); + dev->of_node = NULL; +} + static void apple_dart_test_before_attach(struct kunit *test) { struct apple_dart_master_cfg master = {}; @@ -1174,6 +1276,8 @@ static struct kunit_case apple_dart_test_cases[] = { KUNIT_CASE(apple_dart_test_strict_engines), KUNIT_CASE(apple_dart_test_topology), KUNIT_CASE(apple_dart_test_iommu_specifiers), + KUNIT_CASE(apple_dart_test_consumer_window), + KUNIT_CASE(apple_dart_test_invalid_consumer_window), KUNIT_CASE(apple_dart_test_independent_remap_roots), KUNIT_CASE(apple_dart_test_before_attach), KUNIT_CASE(apple_dart_test_locked_handoff), diff --git a/drivers/iommu/apple-dart.c b/drivers/iommu/apple-dart.c index a8b91c7e63316..b69ad96f4e94b 100644 --- a/drivers/iommu/apple-dart.c +++ b/drivers/iommu/apple-dart.c @@ -3583,10 +3583,37 @@ static void apple_dart_domain_free(struct iommu_domain *domain) kfree(dart_domain); } +static int apple_dart_validate_dma_window(struct device *dev, + const struct apple_dart *dart, + dma_addr_t dma_min, dma_addr_t length, + dma_addr_t *dma_max) +{ + if (!length) + return -EINVAL; + if (!IS_ALIGNED(dma_min, dart->pgsize) || !IS_ALIGNED(length, dart->pgsize)) { + dev_err(dev, "Unaligned DMA window %pad, %pad (0x%x)\n", + &dma_min, &length, dart->pgsize); + return -EINVAL; + } + if (check_add_overflow(dma_min, length - 1, dma_max)) { + dev_err(dev, "DMA window length (%pad) overflows range for start %pad\n", + &length, &dma_min); + return -EINVAL; + } + + /* High bits may select an alias, but the window must fit within it. */ + if ((dma_min ^ *dma_max) & ~DMA_BIT_MASK(dart->ias)) { + dev_err(dev, "Invalid DMA window for ias=%d\n", dart->ias); + return -EINVAL; + } + return 0; +} + /* * Work out the DMA window of one "iommus" specifier. One cell is the stream * ID alone and keeps the window of the DART node. Five cells add the 64-bit - * start and length of the window that the device uses. + * start and length of the window that the device uses. A consumer's + * apple,dma-range overrides either default, as it does at domain allocation. */ static int apple_dart_parse_dma_window(struct device *dev, const struct apple_dart *dart, @@ -3595,43 +3622,33 @@ static int apple_dart_parse_dma_window(struct device *dev, dma_addr_t *dma_max) { dma_addr_t length; + u64 window[2]; + int ret; + if (args->args_count != 1 && args->args_count != 5) + return -EINVAL; *dma_min = dart->dma_min; *dma_max = dart->dma_max; - if (args->args_count == 1) - return 0; - if (args->args_count != 5) - return -EINVAL; - - length = ((dma_addr_t)args->args[3] << 32) | args->args[4]; - if (!length) - return -EINVAL; - - if (*dma_min != 0 || *dma_max != DMA_BIT_MASK(dart->ias)) - dev_err(dev, "still using legacy \"apple,dma-range\" property\n"); - - *dma_min = ((dma_addr_t)args->args[1] << 32) | args->args[2]; - - if (!IS_ALIGNED(*dma_min, dart->pgsize) || - !IS_ALIGNED(length, dart->pgsize)) { - dev_err(dev, "Unaligned DMA window %pad, %pad (0x%x)\n", - dma_min, &length, dart->pgsize); - return -EINVAL; - } - if (check_add_overflow(*dma_min, length - 1, dma_max)) { - dev_err(dev, "DMA window length (%pad) overflows range for start %pad\n", - &length, dma_min); - return -EINVAL; - } - - /* Ensure that the DMA window does not exceed the DART's ias. */ - if ((*dma_min ^ *dma_max) & ~DMA_BIT_MASK(dart->ias)) { - dev_err(dev, "Invalid DMA window for ias=%d\n", dart->ias); - return -EINVAL; + if (args->args_count == 5) { + if (*dma_min != 0 || *dma_max != DMA_BIT_MASK(dart->ias)) + dev_err(dev, "still using legacy \"apple,dma-range\" property\n"); + *dma_min = ((dma_addr_t)args->args[1] << 32) | args->args[2]; + length = ((dma_addr_t)args->args[3] << 32) | args->args[4]; + ret = apple_dart_validate_dma_window(dev, dart, *dma_min, length, dma_max); + if (ret) + return ret; } - return 0; + /* Apply the consumer aperture before intersecting its DART windows. */ + if (!of_property_present(dev->of_node, "apple,dma-range")) + return 0; + ret = of_property_read_u64_array(dev->of_node, "apple,dma-range", + window, ARRAY_SIZE(window)); + if (ret) + return ret; + *dma_min = window[0]; + return apple_dart_validate_dma_window(dev, dart, *dma_min, window[1], dma_max); } static int apple_dart_of_xlate(struct device *dev, diff --git a/drivers/media/platform/apple/isp/isp-drv.c b/drivers/media/platform/apple/isp/isp-drv.c index f0410cea88b5f..e5152915bbc43 100644 --- a/drivers/media/platform/apple/isp/isp-drv.c +++ b/drivers/media/platform/apple/isp/isp-drv.c @@ -1028,7 +1028,7 @@ static const struct apple_isp_hw apple_isp_hw_t6020 = { static const struct apple_isp_hw apple_isp_hw_t8122 = { .gen = ISP_GEN_T8112, - .pmu_base = 0x2d07040000, + .pmu_base = 0x2d0704000, .dsid_count = 1, .dsid_clr_base0 = 0x2221c4000, diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c index 2bfee245f4331..ecac0b94a806a 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c @@ -1231,7 +1231,10 @@ static irqreturn_t brcmf_pcie_quick_check_isr(int irq, void *arg) struct brcmf_pciedev_info *devinfo = (struct brcmf_pciedev_info *)arg; if (brcmf_pcie_read_pcie32(devinfo, devinfo->reginfo->mailboxint)) { - brcmf_pcie_intr_disable(devinfo); + /* Mask the dongle only: irq_ready gates ring servicing while the + * rings are not set up or are being torn down, not this IRQ. + */ + brcmf_pcie_write_pcie32(devinfo, devinfo->reginfo->mailboxmask, 0); brcmf_dbg(PCIE, "Enter\n"); return IRQ_WAKE_THREAD; } @@ -1271,8 +1274,13 @@ static irqreturn_t brcmf_pcie_isr_thread(int irq, void *arg) } brcmf_pcie_bus_console_read(devinfo, false); - if (devinfo->state == BRCMFMAC_PCIE_STATE_UP) - brcmf_pcie_intr_enable(devinfo); + /* Unmask, but leave irq_ready to the code that sets the rings up and + * tears them down. + */ + if (devinfo->state == BRCMFMAC_PCIE_STATE_UP && READ_ONCE(devinfo->irq_ready)) + brcmf_pcie_write_pcie32(devinfo, devinfo->reginfo->mailboxmask, + devinfo->reginfo->int_d2h_db | + devinfo->reginfo->int_fn0); devinfo->in_irq = false; return IRQ_HANDLED; } diff --git a/drivers/net/wireless/mediatek/mt7932/association-test.c b/drivers/net/wireless/mediatek/mt7932/association-test.c index 08dc14c6f89e4..8f828f2b29985 100644 --- a/drivers/net/wireless/mediatek/mt7932/association-test.c +++ b/drivers/net/wireless/mediatek/mt7932/association-test.c @@ -176,6 +176,7 @@ enum mt_auth_change { MT_AUTH_NO_PASSWORD, MT_AUTH_WPA, MT_AUTH_PAIR_COUNT, MT_AUTH_PAIR, MT_AUTH_GROUP, MT_AUTH_NO_AKM, MT_AUTH_PSK_FIRST, MT_AUTH_SAE_FIRST, MT_AUTH_OTHER_FIRST, MT_AUTH_OTHER_AKM, MT_AUTH_PSK, + MT_AUTH_OWE, }; static void mt_connect_auth_test(struct kunit *test) @@ -189,6 +190,13 @@ static void mt_connect_auth_test(struct kunit *test) { "pure PSK", MT_AUTH_PSK, 0, WLAN_AKM_SUITE_PSK }, { "PSK missing PMK", MT_AUTH_PSK, 1, -EOPNOTSUPP }, { "PSK required MFP", MT_AUTH_PSK, 2, WLAN_AKM_SUITE_PSK }, + { "PSK TKIP group", MT_AUTH_PSK, 3, WLAN_AKM_SUITE_PSK }, + { "PSK TKIP pairwise", MT_AUTH_PSK, 4, -EOPNOTSUPP }, + { "PSK WEP group", MT_AUTH_PSK, 5, -EOPNOTSUPP }, + { "PSK TKIP group missing PMK", MT_AUTH_PSK, 6, -EOPNOTSUPP }, + { "PSK TKIP group WPA1", MT_AUTH_PSK, 7, -EOPNOTSUPP }, + { "OWE", MT_AUTH_OWE, WLAN_CIPHER_SUITE_CCMP, WLAN_AKM_SUITE_OWE }, + { "OWE TKIP group", MT_AUTH_OWE, WLAN_CIPHER_SUITE_TKIP, -EOPNOTSUPP }, { "pure SAE", MT_AUTH_NONE, 0, WLAN_AKM_SUITE_SAE }, { "optional MFP", MT_AUTH_MFP, NL80211_MFP_OPTIONAL, WLAN_AKM_SUITE_SAE }, { "no MFP", MT_AUTH_MFP, NL80211_MFP_NO, -EOPNOTSUPP }, @@ -213,7 +221,7 @@ static void mt_connect_auth_test(struct kunit *test) { "no pairwise", MT_AUTH_PAIR_COUNT, 0, -EOPNOTSUPP }, { "multiple pairwise", MT_AUTH_PAIR_COUNT, 2, -EOPNOTSUPP }, { "TKIP pairwise", MT_AUTH_PAIR, WLAN_CIPHER_SUITE_TKIP, -EOPNOTSUPP }, - { "TKIP group", MT_AUTH_GROUP, WLAN_CIPHER_SUITE_TKIP, -EOPNOTSUPP }, + { "SAE TKIP group", MT_AUTH_GROUP, WLAN_CIPHER_SUITE_TKIP, -EOPNOTSUPP }, { "no AKM", MT_AUTH_NO_AKM, 0, -EOPNOTSUPP }, { "SAE EXT KEY", MT_AUTH_OTHER_AKM, SUITE(0x000fac, 24), -EOPNOTSUPP }, { "PSK SHA256", MT_AUTH_OTHER_AKM, WLAN_AKM_SUITE_PSK_SHA256, -EOPNOTSUPP }, @@ -226,6 +234,8 @@ static void mt_connect_auth_test(struct kunit *test) { "PSK first mixed versions", MT_AUTH_PSK_FIRST, 4, WLAN_AKM_SUITE_PSK }, { "PSK first VERSION_3 only", MT_AUTH_PSK_FIRST, 5, -EOPNOTSUPP }, { "SAE first mixed versions", MT_AUTH_SAE_FIRST, 2, WLAN_AKM_SUITE_SAE }, + { "SAE first TKIP group", MT_AUTH_SAE_FIRST, 3, -EOPNOTSUPP }, + { "PSK first TKIP group", MT_AUTH_PSK_FIRST, 6, WLAN_AKM_SUITE_PSK }, { "unsupported AKM before SAE", MT_AUTH_OTHER_FIRST, 0, -EOPNOTSUPP }, }; u8 password[64] = {}, pmk[32] = {}; @@ -287,11 +297,26 @@ static void mt_connect_auth_test(struct kunit *test) case MT_AUTH_PSK: p.crypto.wpa_versions = NL80211_WPA_VERSION_2; p.crypto.akm_suites[0] = WLAN_AKM_SUITE_PSK; - p.crypto.psk = value == 1 ? NULL : pmk; + p.crypto.psk = value == 1 || value == 6 ? NULL : pmk; p.crypto.sae_pwd = NULL; p.crypto.sae_pwd_len = 0; p.auth_type = NL80211_AUTHTYPE_AUTOMATIC; p.mfp = value == 2 ? NL80211_MFP_REQUIRED : NL80211_MFP_NO; + if (value == 3 || value == 4 || value == 6 || value == 7) + p.crypto.cipher_group = WLAN_CIPHER_SUITE_TKIP; + if (value == 4) + p.crypto.ciphers_pairwise[0] = WLAN_CIPHER_SUITE_TKIP; + if (value == 5) + p.crypto.cipher_group = WLAN_CIPHER_SUITE_WEP40; + if (value == 7) + p.crypto.wpa_versions = NL80211_WPA_VERSION_1; + break; + case MT_AUTH_OWE: + p.crypto.akm_suites[0] = WLAN_AKM_SUITE_OWE; + p.crypto.cipher_group = value; + p.crypto.sae_pwd = NULL; + p.crypto.sae_pwd_len = 0; + p.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; break; case MT_AUTH_PSK_FIRST: p.crypto.wpa_versions = value == 5 ? NL80211_WPA_VERSION_3 : @@ -305,6 +330,8 @@ static void mt_connect_auth_test(struct kunit *test) p.auth_type = NL80211_AUTHTYPE_OPEN_SYSTEM; p.mfp = value == 2 ? NL80211_MFP_REQUIRED : value == 3 ? NL80211_MFP_NO : NL80211_MFP_OPTIONAL; + if (value == 6) + p.crypto.cipher_group = WLAN_CIPHER_SUITE_TKIP; break; case MT_AUTH_SAE_FIRST: p.crypto.n_akm_suites = 2; @@ -314,6 +341,8 @@ static void mt_connect_auth_test(struct kunit *test) p.crypto.sae_pwd = NULL; if (value == 2) p.crypto.wpa_versions |= NL80211_WPA_VERSION_2; + if (value == 3) + p.crypto.cipher_group = WLAN_CIPHER_SUITE_TKIP; p.mfp = NL80211_MFP_OPTIONAL; break; case MT_AUTH_OTHER_FIRST: diff --git a/drivers/net/wireless/mediatek/mt7932/association.h b/drivers/net/wireless/mediatek/mt7932/association.h index 78189eab6b279..20d5f5c58e904 100644 --- a/drivers/net/wireless/mediatek/mt7932/association.h +++ b/drivers/net/wireless/mediatek/mt7932/association.h @@ -42,6 +42,7 @@ static inline int mt7932_connect_auth(const struct cfg80211_connect_params *p) { u32 versions = p->crypto.wpa_versions; + bool tkip_group = p->crypto.cipher_group == WLAN_CIPHER_SUITE_TKIP; /* SAE offload clients use VERSION_3; older clients use VERSION_2. * A transition request can carry both. The selected AKM still owns @@ -51,7 +52,7 @@ mt7932_connect_auth(const struct cfg80211_connect_params *p) (versions & ~(NL80211_WPA_VERSION_2 | NL80211_WPA_VERSION_3)) || p->crypto.n_ciphers_pairwise != 1 || p->crypto.ciphers_pairwise[0] != WLAN_CIPHER_SUITE_CCMP || - p->crypto.cipher_group != WLAN_CIPHER_SUITE_CCMP || + (p->crypto.cipher_group != WLAN_CIPHER_SUITE_CCMP && !tkip_group) || p->crypto.n_akm_suites < 1) return -EOPNOTSUPP; @@ -60,6 +61,13 @@ mt7932_connect_auth(const struct cfg80211_connect_params *p) p->crypto.sae_pwe)) return -EOPNOTSUPP; + /* WPA/WPA2 mixed-mode APs pair a CCMP unicast key with a TKIP group + * key. The firmware owns the handshake and both keys. Only plain + * WPA2-PSK may do this; pairwise TKIP stays refused. + */ + if (tkip_group && p->crypto.akm_suites[0] != WLAN_AKM_SUITE_PSK) + return -EOPNOTSUPP; + switch (p->crypto.akm_suites[0]) { case WLAN_AKM_SUITE_PSK: /* iwd and wpa_supplicant both send REQUIRED once they have diff --git a/drivers/net/wireless/mediatek/mt7932/startup.c b/drivers/net/wireless/mediatek/mt7932/startup.c index f60651470b216..e0e2b1f729564 100644 --- a/drivers/net/wireless/mediatek/mt7932/startup.c +++ b/drivers/net/wireless/mediatek/mt7932/startup.c @@ -820,7 +820,8 @@ int mt_register_regulatory_gate(struct mt7932 *m) { static const int rates[] = {10,20,55,110,60,90,120,180,240,360,480,540}; static const u32 ciphers[] = { WLAN_CIPHER_SUITE_CCMP, - WLAN_CIPHER_SUITE_AES_CMAC }; + WLAN_CIPHER_SUITE_AES_CMAC, + WLAN_CIPHER_SUITE_TKIP }; static const u32 akms[] = { WLAN_AKM_SUITE_PSK, WLAN_AKM_SUITE_PSK_SHA256, diff --git a/drivers/pci/controller/pcie-apple.c b/drivers/pci/controller/pcie-apple.c index b6c3b98af2c9e..a7dd2059745e4 100644 --- a/drivers/pci/controller/pcie-apple.c +++ b/drivers/pci/controller/pcie-apple.c @@ -3875,7 +3875,7 @@ static int apple_pcie_config_write(struct pci_bus *bus, unsigned int devfn, if (pcie->hw->mps_timers && where == PCIEC_RP_DEVCTL) apple_pcie_update_mps_timers(pcie, FIELD_GET(PCI_EXP_DEVCTL_PAYLOAD, val)); - if (!pcie->kernel_init) + if (!(pcie->kernel_init || pcie->tunnel_cold_init)) return ret; /* Root-port prefetchable window. The port block has to be told too. */ if (where < 0x24 || where >= 0x30) diff --git a/drivers/pmdomain/apple/pmp-report.c b/drivers/pmdomain/apple/pmp-report.c index 7ce01a88bb069..466a853266d5a 100644 --- a/drivers/pmdomain/apple/pmp-report.c +++ b/drivers/pmdomain/apple/pmp-report.c @@ -614,6 +614,42 @@ static int apple_pmp_report_wait_t6030_14(struct device *supplier, unsigned int return ret; } +/* + * The T8122 (M3 MacBook Air) GPU on its 14.8.3 firmware: the unique T8122 + * report linked to this PMP, and its display request (DISP, reg 7) READY and + * acknowledged before AGX. Selected by the T8122 PMP and its linked report + * node; anything else gets -ENODEV. + */ +static int apple_pmp_report_wait_t8122_14(struct device *supplier, unsigned int timeout_ms) +{ + struct device_node *np, *report = NULL, *pmp, *entry; + int ret; + + if (!of_device_is_compatible(supplier->of_node, "apple,t8122-pmp-v2")) + return -ENODEV; + for_each_compatible_node(np, NULL, "apple,t8122-pmp-v2-report") { + if (report) { + of_node_put(np); + of_node_put(report); + return -ENODEV; + } + report = of_node_get(np); + } + if (!report || !of_device_is_available(report) || + of_property_count_u32_elems(report, "apple,pmp") != 1) { + of_node_put(report); + return -ENODEV; + } + pmp = of_parse_phandle(report, "apple,pmp", 0); + entry = apple_pmp_report_t6030_entry(report); + ret = pmp == supplier->of_node && entry ? + apple_pmp_report_wait_ready(entry, msecs_to_jiffies(timeout_ms)) : -ENODEV; + of_node_put(entry); + of_node_put(pmp); + of_node_put(report); + return ret; +} + /* The native 25G83 PMP starts through its supplier topology, after requests * are seeded. Its report is pinned against removal while readiness is read. */ @@ -628,8 +664,12 @@ int apple_pmp_report_wait_supplier_ready(struct device *supplier, unsigned int t int ret; /* A declared report always takes the existing native25 path below. */ - if (!np && !of_property_present(supplier->of_node, "apple,pmp-report")) + if (!np && !of_property_present(supplier->of_node, "apple,pmp-report")) { + ret = apple_pmp_report_wait_t8122_14(supplier, timeout_ms); + if (ret != -ENODEV) + return ret; return apple_pmp_report_wait_t6030_14(supplier, timeout_ms); + } if (!np || !of_device_is_compatible(np, t8132 ? "apple,t8132-pmp-v2-report" : "apple,j613-25g83-pmp-report")) { of_node_put(np); @@ -2441,7 +2481,7 @@ static const struct apple_pmp_report_offsets apple_pmp_offsets_t6031 = { .status = 0x10, .starts_pmp = true, .name = "T6031", - .fallback = "leave out apple_t6031_display.enable=1", + .fallback = "apple_t6031_display.enable=0", .pwrstate = "apple,t6031-pmgr-pwrstate", .devices_ordered = true, }; diff --git a/tools/asahi/g15-probe-init-tests.py b/tools/asahi/g15-probe-init-tests.py index a7b9b900b7af5..88be177882337 100644 --- a/tools/asahi/g15-probe-init-tests.py +++ b/tools/asahi/g15-probe-init-tests.py @@ -82,6 +82,8 @@ def item(text, marker): static EXEC_SHARE_READY: Cell = const { Cell::new(false) }; static ATTACH_ERROR: Cell = const { Cell::new(false) }; static PROBE_ERROR: Cell = const { Cell::new(0) }; + static PRE_ACTIVATION: Cell = const { Cell::new(0) }; + static ATTEMPTED_REGISTRATION: Cell = const { Cell::new(0) }; } struct Core<'a>(PhantomData<&'a ()>); struct Device { data: Cell<*mut core::ffi::c_void> } @@ -184,7 +186,17 @@ def item(text, marker): }; // Model driver_attach and a late driver_add_groups failure. A deferred // worker can also retry G15 while the other registration is in progress. - let _ = callback::>(&PDEV, Some(&&CFG)); + ATTEMPTED_REGISTRATION.set(ATTEMPTED_REGISTRATION.get() + 1); + let ready = MODULE_READY.load(Ordering::Acquire); + let started = PROBES.get(); + let result = callback::>(&PDEV, Some(&&CFG)); + // A probe that started firmware here is the readiness-gate failure, checked below. + if !ready && PROBES.get() == started { + // A deferral would keep the GPU in devices_deferred after a later + // terminal failure; before activation the probe must decline outright. + assert_eq!(result, Err(ENODEV), "pre-activation probe deferred instead of ENODEV"); + PRE_ACTIVATION.set(PRE_ACTIVATION.get() + 1); + } if FAIL_REGISTRATION.get() == stage { return Err(-5); } COMPLETED_REGISTRATION.set(stage); stage @@ -252,7 +264,7 @@ def item(text, marker): PDEV.base.data.set(core::ptr::null_mut()); MODULE_READY.store(false, Ordering::Release); COMPLETED_REGISTRATION.set(0); FAIL_REGISTRATION.set(failure); - ACTIVATED.set(false); ATTACH_ERROR.set(failure == 0); + ACTIVATED.set(false); ATTACH_ERROR.set(failure == 0); PRE_ACTIVATION.set(0); ATTEMPTED_REGISTRATION.set(0); let init = ::init(&MODULE); assert_eq!(PROBES.get(), 0, "module initializer eagerly started firmware"); let result = KBox::pin_init(init, GFP_KERNEL); @@ -269,6 +281,8 @@ def item(text, marker): assert!(!PDEV.base.data.get().is_null()); unsafe { drop(Box::from_raw(PDEV.base.data.get().cast::>())); } } + // Every probe before activation declined: one per completed or failing registration. + assert_eq!(PRE_ACTIVATION.get(), ATTEMPTED_REGISTRATION.get(), "pre-activation probes"); println!("module-registration-{failure}: PASS"); } } @@ -415,9 +429,10 @@ def main(): needle = " None\n" assert probe.count(needle) == 1 variants["retained-error-unbinds"] = (probe.replace(needle, " return Err(error);\n"), module_code) - gate = " if !MODULE_READY.load(Ordering::Acquire) {\n return Err(EPROBE_DEFER);\n }\n" + gate = " if !MODULE_READY.load(Ordering::Acquire) {\n return Err(ENODEV);\n }\n" assert probe.count(gate) == 1 variants["no-registration-readiness-gate"] = (probe.replace(gate, ""), module_code) + variants["pre-activation-defers"] = (probe.replace(gate, gate.replace("ENODEV", "EPROBE_DEFER")), module_code) late = " #[cfg(CONFIG_DRM_ASAHI_G15)]\n _g15_ready: g15::activate(),\n" assert module_code.count(late) == 1 early = module_code.replace(late, "").replace(" _driver <-", late + " _driver <-", 1) @@ -446,7 +461,7 @@ def main(): else: receipt["mutants"][label] = result if r.returncode == 0: raise SystemExit("SURVIVED: " + name) - intended = {"eager-probe-before-allocation": "allocation-before-start: firmware probe before drvdata allocation", "retained-error-unbinds": "retained-start-failure-binds: callback result", "no-registration-readiness-gate": "late registration failure started firmware", "activation-before-last-registration": "activation before all registrations completed", "activation-before-g16-registration": "activation before all registrations completed"}[name] + intended = {"eager-probe-before-allocation": "allocation-before-start: firmware probe before drvdata allocation", "retained-error-unbinds": "retained-start-failure-binds: callback result", "no-registration-readiness-gate": "late registration failure started firmware", "activation-before-last-registration": "activation before all registrations completed", "activation-before-g16-registration": "activation before all registrations completed", "pre-activation-defers": "pre-activation probe deferred instead of ENODEV"}[name] result["intended_failure"] = intended in r.stderr if not result["intended_failure"]: raise SystemExit("INVALID unrelated failure: " + name + "\n" + r.stderr) (out / "result.json").write_text(json.dumps(receipt, indent=2) + "\n") diff --git a/tools/asahi/t6030-pmp-graph-tests.py b/tools/asahi/t6030-pmp-graph-tests.py index 4c85001acf1a8..cedb28929a5b9 100644 --- a/tools/asahi/t6030-pmp-graph-tests.py +++ b/tools/asahi/t6030-pmp-graph-tests.py @@ -60,6 +60,12 @@ def main(): 'static int apple_pmp_report_entry_resume_noirq('] offsets = re.search(r'static const struct apple_pmp_report_offsets apple_pmp_offsets_t6030 = \{.*?\n\};', source, re.S)[0] functions = '\n'.join(extract.function(source, n) for n in names) + # The T8122 14.x wait (no T8122 PMP here, so it returns -ENODEV) precedes the dispatch; it is + # added after the mutations are placed, so they target the T6030 path only. + t8122 = extract.function(source, 'static int apple_pmp_report_wait_t8122_14(') + '\n' + dispatch = 'int apple_pmp_report_wait_supplier_ready(' + def with_t8122(text): + return text.replace(dispatch, t8122 + dispatch, 1) validation = re.sub(r'^#include .*\n', '', (ROOT / 'drivers/pmdomain/apple/pmp-report-validation.h').read_text(), flags=re.M) dram_type = re.search(r'struct apple_pmp_dram \{.*?\n\};', (ROOT / 'drivers/pmdomain/apple/pmp-dram.h').read_text(), re.S)[0] @@ -78,7 +84,7 @@ def main(): '\n' + dram_attrs + '\n' + functions) # The actual overlay must still describe a halted supplier and disabled DMA/mailbox. assert overlay.count('status = \"disabled\";') >= 3 - (args.output / 'production.h').write_text(code) + (args.output / 'production.h').write_text(with_t8122(code)) (args.output / 'overlay.h').write_text('static const struct overlay_entry overlay_entries[] = {\n' + entry_data + '\n};\n') compiler = shlex.split(os.environ.get('CC', 'clang')) command = compiler + ['-std=gnu11', '-g', '-O1', '-Wall', '-Wextra', '-Werror', @@ -133,13 +139,13 @@ def main(): ] for name, old, new in controls: assert code.count(old) == 1, (name, code.count(old)) - (args.output / 'production.h').write_text(code.replace(old, new)) + (args.output / 'production.h').write_text(with_t8122(code.replace(old, new))) built = subprocess.run(command, capture_output=True, text=True) # A mutant must compile; compilation failure is not regression evidence. ran = subprocess.run([str(args.output / 'graph')], capture_output=True, text=True) if not built.returncode else None (args.output / (name + '.log')).write_text(built.stdout + built.stderr + (ran.stdout + ran.stderr if ran else '')) mutations.append({'name': name, 'build_rc': built.returncode, 'run_rc': ran.returncode if ran else None}) - (args.output / 'production.h').write_text(code) + (args.output / 'production.h').write_text(with_t8122(code)) assert all(m['build_rc'] == 0 and m['run_rc'] != 0 for m in mutations), mutations (args.output / 'receipt.json').write_text(json.dumps({'source_ref': args.ref, 'source_sha256': hashlib.sha256(code.encode()).hexdigest(), 'overlay_sha256': hashlib.sha256(overlay.encode()).hexdigest(), 'overlay_entries': entries, diff --git a/tools/asahi/t6030-pmp-supplier-tests.c b/tools/asahi/t6030-pmp-supplier-tests.c index 59c2c0d3cd430..8f90264d0bf95 100644 --- a/tools/asahi/t6030-pmp-supplier-tests.c +++ b/tools/asahi/t6030-pmp-supplier-tests.c @@ -574,7 +574,7 @@ int main(void) RUN((void)0, -ENODEV, 0, 0); assert(!find_calls); #endif - /* T8122 current14 remains unsupported by this supplier API. */ + /* A T8122 PMP without a linked T8122 report node is not waited for. */ RUN(machine = "apple,t8122"; supplier_node.compatible = "apple,t8122-pmp-v2", -ENODEV, 0, 0); /* A declared report, including malformed/unresolved data, never falls back. */ diff --git a/tools/asahi/t6030-pmp-supplier-tests.py b/tools/asahi/t6030-pmp-supplier-tests.py index 269006b36aa4f..a6eff85b7d688 100755 --- a/tools/asahi/t6030-pmp-supplier-tests.py +++ b/tools/asahi/t6030-pmp-supplier-tests.py @@ -148,6 +148,17 @@ def main(): assert code.count(old) == 1, (name, code.count(old)) variants.append((name, code.replace(old, new))) variants.append(("control-after", code)) + # The T8122 14.x wait finds no T8122 report node here and returns -ENODEV; it is added to + # every variant after the T6030 mutations are placed, so they target the T6030 path only. + dispatch = "int apple_pmp_report_wait_supplier_ready(" + t8122 = function(report, "static int apple_pmp_report_wait_t8122_14(") + "\n" + def with_t8122(source): + if dispatch not in source: + return source + return source.replace(dispatch, t8122 + dispatch, 1) + variants = [(name, with_t8122(source)) for name, source in variants] + if baseline_code and "apple_pmp_report_wait_t8122_14(" in baseline_code: + baseline_code = with_t8122(baseline_code) results = [run(args.output, name, source, compiler) for name, source in variants] if baseline_code: results.append(run(args.output, "control-prior-config-off", baseline_code, compiler, (0,))) diff --git a/tools/aurora-bindgen/test.py b/tools/aurora-bindgen/test.py index 6d93f8b35b9d8..e5ae87bd6e8a3 100644 --- a/tools/aurora-bindgen/test.py +++ b/tools/aurora-bindgen/test.py @@ -39,7 +39,7 @@ def run(cmd):return subprocess.run(cmd,capture_output=True,text=True) if fixture == 'bitfields.h' and label == 'baseline':continue cmd=[tool,str(header),'--rust-target','1.85','--no-doc-comments','--use-core','--no-derive-debug','--ctypes-prefix','core::ffi','--','-target',ct,'-x',language,*extra] g=run(cmd);assert g.returncode==0,(fixture,g.stderr) - assert 'const _: ()' in g.stdout and '#[test]' not in g.stdout,'generator did not emit unconditional const layout checks' + assert re.search(r'\bconst\s+_\s*:\s*\(\s*\)\s*=',g.stdout) and not re.search(r'#\s*\[\s*test\s*\]',g.stdout),'generator did not emit unconditional const layout checks' rs=O/(fixture+'.'+label+'.rs');rs.write_text('#![no_std]\n'+g.stdout+(access if fixture=='anonymous-members.h' and label=='fixed' else '')) rcmd=rust+[str(rs),'-o',str(O/(fixture+'.'+label+'.o'))];r=run(rcmd);(O/(fixture+'.'+label+'.log')).write_text(r.stdout+r.stderr) expected=label=='fixed' or fixture=='tag-only.h';assert (r.returncode==0)==expected,(fixture,label,r.stderr)