From 388cd88cad499c7fc11e6fd4981dab267a785382 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 03:47:22 -0600 Subject: [PATCH 1/7] wifi: centauri T6050 wedge hold (15ms) and transport recovery 15ms scan settle after channels/disconnect (M5 journals: failing gaps 0.34, 2.25, 2.51 ms; good 39.51, 43.04, 46.65 ms; no good pair <10.79 ms). Transport recovery via centauri_t6050.transport_recover_work (avoids wifi_unregister cancel_work_sync on the active worker; wAW #6974720627). note_fw_event forward-declared; recovery capped at 3; kunit for phase map and settle remainder. debugfs force_transport_fault. Based on integration/aurora. --- .../wireless/apple/centauri/t6050/Makefile | 2 +- .../apple/centauri/t6050/centauri_pci.c | 9 +- .../apple/centauri/t6050/centauri_recovery.c | 241 ++++++++++++++++++ .../apple/centauri/t6050/centauri_recovery.h | 25 ++ .../apple/centauri/t6050/centauri_t6050.h | 2 + .../apple/centauri/t6050/centauri_wifi.c | 108 +++++++- 6 files changed, 374 insertions(+), 13 deletions(-) create mode 100644 drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c create mode 100644 drivers/net/wireless/apple/centauri/t6050/centauri_recovery.h diff --git a/drivers/net/wireless/apple/centauri/t6050/Makefile b/drivers/net/wireless/apple/centauri/t6050/Makefile index ec75629ea1272..5632d74c0d127 100644 --- a/drivers/net/wireless/apple/centauri/t6050/Makefile +++ b/drivers/net/wireless/apple/centauri/t6050/Makefile @@ -1,4 +1,4 @@ # SPDX-License-Identifier: GPL-2.0-only obj-$(CONFIG_APPLE_CENTAURI_T6050) += apple_centauri_t6050.o apple_centauri_t6050-y := centauri_pci.o centauri_ipc.o -apple_centauri_t6050-$(CONFIG_APPLE_CENTAURI_T6050_WIFI) += centauri_wifi.o +apple_centauri_t6050-$(CONFIG_APPLE_CENTAURI_T6050_WIFI) += centauri_wifi.o centauri_recovery.o diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_pci.c b/drivers/net/wireless/apple/centauri/t6050/centauri_pci.c index df385daa8da49..fe4d7eda9a0e4 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_pci.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_pci.c @@ -23,6 +23,7 @@ #include #include "centauri_t6050.h" +#include "centauri_recovery.h" /* Registry owns one reference, registrations and queued work own additional ones. */ struct centauri_t6050_rewake { @@ -472,8 +473,10 @@ static void centauri_t6050_boot_worker(struct work_struct *work) break; case CEN_BOOT_IPC: ret = centauri_t6050_start_ipc(c); - if (!ret) + if (!ret) { c->boot_phase = CEN_BOOT_READY; + c->transport_recover_count = 0; + } break; default: goto out; @@ -519,6 +522,8 @@ static int centauri_t6050_probe(struct pci_dev *pdev, const struct pci_device_id c->link_ready = true; mutex_init(&c->boot_lock); INIT_DELAYED_WORK(&c->boot_work, centauri_t6050_boot_worker); + if (IS_ENABLED(CONFIG_APPLE_CENTAURI_T6050_WIFI)) + centauri_t6050_transport_recover_init(c); c->boot_phase = CEN_BOOT_ROM; ret = device_property_read_string(&pdev->dev, "firmware-name", &c->firmware_name); if (ret) @@ -775,6 +780,8 @@ static int centauri_t6050_quiesce(struct centauri_t6050 *c) WRITE_ONCE(c->removing, true); /* Pairs with control_ready: no new consumer can attach. */ smp_store_release(&c->ready, false); + if (IS_ENABLED(CONFIG_APPLE_CENTAURI_T6050_WIFI)) + centauri_t6050_transport_recover_cancel(c); cancel_delayed_work_sync(&c->boot_work); /* Never hold boot_lock over an HCI close or Bluetooth work cancellation. */ ret = centauri_t6050_beta_call(c->recovery, false); diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c new file mode 100644 index 0000000000000..ae733d74a5033 --- /dev/null +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c @@ -0,0 +1,241 @@ +// SPDX-License-Identifier: GPL-2.0-only + +#include +#include +#include +#include +#include +#include + +#include "centauri_recovery.h" + +s64 centauri_fw_event_scan_settle_remainder_ms(bool event_valid, ktime_t event_at, + ktime_t now, unsigned settle_ms) +{ + s64 elapsed; + + if (!event_valid || !settle_ms) + return 0; + elapsed = ktime_to_ms(ktime_sub(now, event_at)); + if (elapsed < 0) + elapsed = 0; + if (elapsed >= settle_ms) + return 0; + return settle_ms - elapsed; +} +EXPORT_SYMBOL_GPL(centauri_fw_event_scan_settle_remainder_ms); + +int centauri_t6050_boot_phase_for_control_stage(u32 control_stage, + enum centauri_t6050_boot_phase *phase) +{ + if (!phase) + return -EINVAL; + + switch (control_stage) { + case 0: + *phase = CEN_BOOT_ROM; + return 0; + case 1: + *phase = CEN_BOOT_IPC; + return 0; + case 4: + *phase = CEN_BOOT_CYCLE; + return 0; + case 2: + case 3: + return -EOPNOTSUPP; + default: + return -EINVAL; + } +} +EXPORT_SYMBOL_GPL(centauri_t6050_boot_phase_for_control_stage); + +#define CEN_TRANSPORT_RECOVER_MAX 3 + +static void centauri_t6050_transport_recover_worker(struct work_struct *work) +{ + struct centauri_t6050 *c = + container_of(work, struct centauri_t6050, transport_recover_work); + + c->transport_recover_count++; + centauri_t6050_schedule_transport_recover(c); +} + +void centauri_t6050_transport_recover_init(struct centauri_t6050 *c) +{ + INIT_WORK(&c->transport_recover_work, centauri_t6050_transport_recover_worker); + c->transport_recover_count = 0; +} + +void centauri_t6050_transport_recover_cancel(struct centauri_t6050 *c) +{ + cancel_work_sync(&c->transport_recover_work); +} + +void centauri_t6050_request_transport_recover(struct centauri_t6050 *c) +{ + if (!c || READ_ONCE(c->removing)) + return; + if (c->transport_recover_count >= CEN_TRANSPORT_RECOVER_MAX) { + dev_err(&c->pdev->dev, + "Wi-Fi transport recovery limit (%u) reached\n", + CEN_TRANSPORT_RECOVER_MAX); + return; + } + schedule_work(&c->transport_recover_work); +} +EXPORT_SYMBOL_GPL(centauri_t6050_request_transport_recover); + +void centauri_t6050_schedule_transport_recover(struct centauri_t6050 *c) +{ + enum centauri_t6050_boot_phase phase; + u32 control; + int ret; + + if (!c || READ_ONCE(c->removing)) + return; + + mutex_lock(&c->boot_lock); + if (c->boot_phase == CEN_BOOT_STOPPED || c->boot_phase == CEN_BOOT_FAILED) + goto out_unlock; + + control = readl(c->bar + 0x8000); + ret = centauri_t6050_boot_phase_for_control_stage(control, &phase); + if (ret) { + dev_err(&c->pdev->dev, + "Wi-Fi transport recovery unsupported (control stage=%#x): %d\n", + control, ret); + c->boot_phase = CEN_BOOT_FAILED; + goto out_unlock; + } + + WRITE_ONCE(c->ready, false); + centauri_t6050_free_ipc(c); + if (phase == CEN_BOOT_ROM) + c->boot_attempted = false; + c->boot_phase = phase; + mutex_unlock(&c->boot_lock); + queue_delayed_work(system_long_wq, &c->boot_work, 0); + return; + +out_unlock: + mutex_unlock(&c->boot_lock); +} +EXPORT_SYMBOL_GPL(centauri_t6050_schedule_transport_recover); + +#if IS_ENABLED(CONFIG_KUNIT) + +#include + +static void recover_phase_rom(struct kunit *test) +{ + enum centauri_t6050_boot_phase phase = CEN_BOOT_FAILED; + + KUNIT_EXPECT_EQ(test, centauri_t6050_boot_phase_for_control_stage(0, &phase), 0); + KUNIT_EXPECT_EQ(test, phase, CEN_BOOT_ROM); +} + +static void recover_phase_ipc(struct kunit *test) +{ + enum centauri_t6050_boot_phase phase = CEN_BOOT_FAILED; + + KUNIT_EXPECT_EQ(test, centauri_t6050_boot_phase_for_control_stage(1, &phase), 0); + KUNIT_EXPECT_EQ(test, phase, CEN_BOOT_IPC); +} + +static void recover_phase_cycle(struct kunit *test) +{ + enum centauri_t6050_boot_phase phase = CEN_BOOT_FAILED; + + KUNIT_EXPECT_EQ(test, centauri_t6050_boot_phase_for_control_stage(4, &phase), 0); + KUNIT_EXPECT_EQ(test, phase, CEN_BOOT_CYCLE); +} + +static void recover_phase_stop23(struct kunit *test) +{ + enum centauri_t6050_boot_phase phase = CEN_BOOT_READY; + + KUNIT_EXPECT_EQ(test, + centauri_t6050_boot_phase_for_control_stage(2, &phase), + -EOPNOTSUPP); + KUNIT_EXPECT_EQ(test, + centauri_t6050_boot_phase_for_control_stage(3, &phase), + -EOPNOTSUPP); +} + +static void recover_phase_null(struct kunit *test) +{ + KUNIT_EXPECT_EQ(test, + centauri_t6050_boot_phase_for_control_stage(1, NULL), + -EINVAL); +} + +static void scan_settle_remainder_inside(struct kunit *test) +{ + ktime_t event = ktime_set(1000, 0); + ktime_t now = ktime_add_ms(event, 2); + + KUNIT_EXPECT_EQ(test, + centauri_fw_event_scan_settle_remainder_ms(true, event, + now, 15), + 13); +} + +static void scan_settle_remainder_waits_out(struct kunit *test) +{ + ktime_t event = ktime_set(0, 0); + ktime_t now = ktime_add_ms(event, 10); + + KUNIT_EXPECT_EQ(test, + centauri_fw_event_scan_settle_remainder_ms(true, event, + now, 15), + 5); +} + +static void scan_settle_remainder_outside(struct kunit *test) +{ + ktime_t event = ktime_set(0, 0); + ktime_t now = ktime_add_ms(event, 15); + + KUNIT_EXPECT_EQ(test, + centauri_fw_event_scan_settle_remainder_ms(true, event, + now, 15), + 0); + now = ktime_add_ms(event, 20); + KUNIT_EXPECT_EQ(test, + centauri_fw_event_scan_settle_remainder_ms(true, event, + now, 15), + 0); +} + +static void scan_settle_remainder_no_event(struct kunit *test) +{ + ktime_t event = ktime_set(0, 0); + ktime_t now = ktime_add_ms(event, 2); + + KUNIT_EXPECT_EQ(test, + centauri_fw_event_scan_settle_remainder_ms(false, event, + now, 15), + 0); +} + +static struct kunit_case centauri_recovery_cases[] = { + KUNIT_CASE(recover_phase_rom), + KUNIT_CASE(recover_phase_ipc), + KUNIT_CASE(recover_phase_cycle), + KUNIT_CASE(recover_phase_stop23), + KUNIT_CASE(recover_phase_null), + KUNIT_CASE(scan_settle_remainder_inside), + KUNIT_CASE(scan_settle_remainder_waits_out), + KUNIT_CASE(scan_settle_remainder_outside), + KUNIT_CASE(scan_settle_remainder_no_event), + {} +}; + +static struct kunit_suite centauri_recovery_suite = { + .name = "centauri_t6050_recovery", + .test_cases = centauri_recovery_cases, +}; +kunit_test_suite(centauri_recovery_suite); + +#endif /* CONFIG_KUNIT */ diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.h b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.h new file mode 100644 index 0000000000000..bf8eb287483fc --- /dev/null +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.h @@ -0,0 +1,25 @@ +/* SPDX-License-Identifier: GPL-2.0-only */ +#ifndef AURORA_CENTAURI_RECOVERY_H +#define AURORA_CENTAURI_RECOVERY_H + +#include +#include "centauri_t6050.h" + +/* + * M5 journal (channels/disconnect event -> scan cmd 0x1000f): failing boots + * 0.34, 2.25, 2.51 ms; good 39.51, 43.04, 46.65 ms; no good pair under 10.79 ms. + */ +#define CEN_FW_EVENT_SCAN_SETTLE_MS 15 + +int centauri_t6050_boot_phase_for_control_stage(u32 control_stage, + enum centauri_t6050_boot_phase *phase); + +void centauri_t6050_transport_recover_init(struct centauri_t6050 *c); +void centauri_t6050_transport_recover_cancel(struct centauri_t6050 *c); +void centauri_t6050_request_transport_recover(struct centauri_t6050 *c); +void centauri_t6050_schedule_transport_recover(struct centauri_t6050 *c); + +s64 centauri_fw_event_scan_settle_remainder_ms(bool event_valid, ktime_t event_at, + ktime_t now, unsigned settle_ms); + +#endif diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_t6050.h b/drivers/net/wireless/apple/centauri/t6050/centauri_t6050.h index 3701dd5619472..41a1b8e6e1c04 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_t6050.h +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_t6050.h @@ -48,6 +48,8 @@ struct centauri_t6050 { struct dentry *debug; struct mutex boot_lock; struct delayed_work boot_work; + struct work_struct transport_recover_work; + unsigned int transport_recover_count; enum centauri_t6050_boot_phase boot_phase; bool removing, ready; void *firmware, *descriptor; diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c index 9e7a379d69fbc..2f5755014acf6 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c @@ -2,6 +2,7 @@ #include #include +#include #include #include #include @@ -12,6 +13,7 @@ #include #include #include "centauri_t6050.h" +#include "centauri_recovery.h" #define CR_BASE 0x100000 #define TR_BASE 0x400000 @@ -58,6 +60,8 @@ struct centauri_t6050_wifi { struct work_struct scan_work; struct work_struct connect_work; struct work_struct link_work; + ktime_t last_fw_event_at; + bool last_fw_event_valid; bool irq_ready; struct cfg80211_scan_request *scan_request; struct mutex lock; /* Serializes firmware commands and ring consumers. */ @@ -113,6 +117,33 @@ struct centauri_t6050_wifi { }; static int query_link_status(struct centauri_t6050_wifi *wifi); +static void note_fw_event(struct centauri_t6050_wifi *wifi); +static void command_fault(struct centauri_t6050_wifi *wifi, u32 id, + u32 wifi_stage, const char *reason); + +static ssize_t force_transport_fault_write(struct file *file, + const char __user *user_buf, + size_t count, loff_t *ppos) +{ + struct centauri_t6050_wifi *wifi = file->private_data; + + if (count == 0) + return 0; + mutex_lock(&wifi->lock); + if (!smp_load_acquire(&wifi->irq_ready)) { + mutex_unlock(&wifi->lock); + return -ENODEV; + } + command_fault(wifi, 0, readl(wifi->a.bar + 8), "debugfs forced"); + mutex_unlock(&wifi->lock); + return count; +} + +static const struct file_operations force_transport_fault_fops = { + .write = force_transport_fault_write, + .open = simple_open, + .llseek = no_llseek, +}; static const u32 rx_buffer[5] = { 0, 0, 0x620000, 0x680000, 0x700000 }; static const u16 ring_size[5] = { 0, 64, 192, 96, 192 }; @@ -604,8 +635,10 @@ static void drain(struct centauri_t6050_wifi *wifi) if (ring == 4) { report_beacon(wifi, packet + 24, size - 24); } else if (command & BIT(31)) { - if (command == 0x80000030) + if (command == 0x80000030) { wifi->channels_seen++; + note_fw_event(wifi); + } if (command == 0x80000005) { wifi->scans_done++; wifi->scan_status = status; @@ -618,6 +651,7 @@ static void drain(struct centauri_t6050_wifi *wifi) command == 0x80000004) { wifi->disconnect_event = true; wifi->disconnect_status = status; + note_fw_event(wifi); } if (command == 0x80000004) wifi->disconnect_pending = false; @@ -652,15 +686,68 @@ static void drain(struct centauri_t6050_wifi *wifi) drain_data_tx(wifi); } +static void note_fw_event(struct centauri_t6050_wifi *wifi) +{ + wifi->last_fw_event_at = ktime_get(); + wifi->last_fw_event_valid = true; +} + +static s64 fw_event_gap_ms(struct centauri_t6050_wifi *wifi) +{ + if (!wifi->last_fw_event_valid) + return -1; + + return ktime_to_ms(ktime_sub(ktime_get(), wifi->last_fw_event_at)); +} + +static void wait_fw_event_before_scan(struct centauri_t6050_wifi *wifi) +{ + s64 remainder; + + for (;;) { + remainder = centauri_fw_event_scan_settle_remainder_ms( + wifi->last_fw_event_valid, wifi->last_fw_event_at, + ktime_get(), CEN_FW_EVENT_SCAN_SETTLE_MS); + if (remainder <= 0) + break; + drain(wifi); + if (remainder > 0) + msleep(remainder); + } +} + +static void log_transport_fault(struct centauri_t6050_wifi *wifi, u32 id, + u32 wifi_stage, const char *reason) +{ + u32 control = wifi->control->ipc ? + readl(wifi->control->bar + 0x8000) : ~0U; + s64 gap_ms = fw_event_gap_ms(wifi); + + if (gap_ms >= 0) { + dev_err(&wifi->control->pdev->dev, + "Wi-Fi transport fault (%s) cmd=%#x wifi_stage=%#x control_stage=%#x gap_ms=%lld rx=%u\n", + reason, id, wifi_stage, control, gap_ms, + wifi->rx_seen[2]); + } else { + dev_err(&wifi->control->pdev->dev, + "Wi-Fi transport fault (%s) cmd=%#x wifi_stage=%#x control_stage=%#x gap_ms=unknown rx=%u\n", + reason, id, wifi_stage, control, wifi->rx_seen[2]); + } +} + /* Caller holds wifi->lock. Unknown completion keeps DMA payloads owned. */ -static void command_fault(struct centauri_t6050_wifi *wifi) +static void command_fault(struct centauri_t6050_wifi *wifi, u32 id, + u32 wifi_stage, const char *reason) { + log_transport_fault(wifi, id, wifi_stage, reason); wifi->command_failed = true; wifi->configured = false; wifi->data_failed = true; - netif_stop_queue(wifi->netdev); + if (wifi->netdev) + netif_stop_queue(wifi->netdev); if (smp_load_acquire(&wifi->irq_ready)) schedule_work(&wifi->link_work); + centauri_t6050_request_transport_recover(wifi->control); } static bool command_payload_consumed(struct centauri_t6050_wifi *wifi, u16 slot) @@ -724,17 +811,14 @@ static int command_reply(struct centauri_t6050_wifi *wifi, u32 id, do { if (READ_ONCE(wifi->stopping) || READ_ONCE(wifi->control->removing)) { - command_fault(wifi); + command_fault(wifi, id, readl(wifi->a.bar + 8), "cancel"); ret = -ECANCELED; goto out; } drain(wifi); stage = readl(wifi->a.bar + 8); if (stage != 2) { - dev_err(&wifi->control->pdev->dev, - "Wi-Fi command %#x lost transport: stage=%#x sequence=%u rx=%u\n", - id, stage, sequence, wifi->rx_seen[2]); - command_fault(wifi); + command_fault(wifi, id, stage, "lost transport"); ret = -EIO; goto out; } @@ -754,9 +838,7 @@ static int command_reply(struct centauri_t6050_wifi *wifi, u32 id, } usleep_range(500, 1000); } while (time_before(jiffies, deadline)); - dev_err(&wifi->control->pdev->dev, - "Wi-Fi command %#x timed out (rx=%u)\n", id, wifi->rx_seen[2]); - command_fault(wifi); + command_fault(wifi, id, readl(wifi->a.bar + 8), "timeout"); ret = -ETIMEDOUT; out: wifi->reply_buffer = NULL; @@ -887,6 +969,7 @@ static void channels_apply(struct centauri_t6050_wifi *wifi) if (!(channel->flags & IEEE80211_CHAN_DISABLED)) counted[band]++; } + note_fw_event(wifi); dev_info(&wifi->control->pdev->dev, "Wi-Fi firmware channels: 2.4 GHz %u, 5 GHz %u, 6 GHz %u (%u entries)\n", counted[0], counted[1], counted[2], list[0]); @@ -1112,6 +1195,7 @@ static int scan_profile27(struct centauri_t6050_wifi *wifi) memcpy(scan + size + 6, ssid->ssid, ssid->ssid_len); size += 6 + ssid->ssid_len; } + wait_fw_event_before_scan(wifi); ret = command(wifi, 65551, scan, size); if (ret) { command_refused(wifi, "scan", ret); @@ -2475,6 +2559,8 @@ int centauri_t6050_wifi_register(struct centauri_t6050 *c) if (ret) goto failed; wifi->registered = true; + debugfs_create_file("force_transport_fault", 0200, wifi->wiphy->debugfsdir, + wifi, &force_transport_fault_fops); debugfs_create_blob("hw_channels", 0400, wifi->wiphy->debugfsdir, &wifi->hw_channels_blob); debugfs_create_blob("system_caps", 0400, wifi->wiphy->debugfsdir, From 37e35bb501110fce1ed0949c88a51d5fd52cf2d4 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 04:46:17 -0600 Subject: [PATCH 2/7] wifi: centauri use noop_llseek for daily 7.3 tree --- drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c index 2f5755014acf6..a3cc082abbedf 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_wifi.c @@ -142,7 +142,7 @@ static ssize_t force_transport_fault_write(struct file *file, static const struct file_operations force_transport_fault_fops = { .write = force_transport_fault_write, .open = simple_open, - .llseek = no_llseek, + .llseek = noop_llseek, }; static const u32 rx_buffer[5] = { 0, 0, 0x620000, 0x680000, 0x700000 }; From 3a56de0f5e7ee55ef4f6320933456b81fe7748db Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 04:55:11 -0600 Subject: [PATCH 3/7] wifi: centauri T6050 kunit overlay for built-in recovery suite --- drivers/net/wireless/apple/centauri/t6050/.kunitconfig | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 drivers/net/wireless/apple/centauri/t6050/.kunitconfig diff --git a/drivers/net/wireless/apple/centauri/t6050/.kunitconfig b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig new file mode 100644 index 0000000000000..d73990b2ac0d8 --- /dev/null +++ b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig @@ -0,0 +1,9 @@ +CONFIG_COMPILE_TEST=y +CONFIG_KUNIT=y +CONFIG_WLAN=y +CONFIG_WLAN_VENDOR_APPLE=y +CONFIG_CFG80211=y +CONFIG_DEBUG_FS=y +CONFIG_PCIE_APPLE=y +CONFIG_APPLE_CENTAURI_T6050=y +CONFIG_APPLE_CENTAURI_T6050_WIFI=y From 3735297dc14e9f5e6981a040b22a0c5dabb0180f Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 04:57:00 -0600 Subject: [PATCH 4/7] wifi: centauri T6050 recovery KUnit as COMPILE_TEST built-in Add APPLE_CENTAURI_T6050_RECOVERY_KUNIT so kunit.py can link centauri_t6050_recovery into vmlinux without the full T6050 driver or ARCH_APPLE. Trim t6050/.kunitconfig to that fragment only. --- drivers/net/wireless/apple/Kconfig | 8 ++++++++ drivers/net/wireless/apple/centauri/Makefile | 1 + drivers/net/wireless/apple/centauri/t6050/.kunitconfig | 6 +----- drivers/net/wireless/apple/centauri/t6050/Makefile | 7 ++++++- .../net/wireless/apple/centauri/t6050/centauri_recovery.c | 2 +- 5 files changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/net/wireless/apple/Kconfig b/drivers/net/wireless/apple/Kconfig index d9b13a9785de2..a62e14a17f706 100644 --- a/drivers/net/wireless/apple/Kconfig +++ b/drivers/net/wireless/apple/Kconfig @@ -41,4 +41,12 @@ config APPLE_CENTAURI_T6050_WIFI help Add scanning and station connections for the T6050 protocol profile. +config APPLE_CENTAURI_T6050_RECOVERY_KUNIT + bool "KUnit: Centauri T6050 recovery helpers (built-in, COMPILE_TEST)" + depends on KUNIT && COMPILE_TEST + depends on !APPLE_CENTAURI_T6050 + help + Build only centauri_recovery.c into vmlinux with its KUnit suite so + kunit.py can run centauri_t6050_recovery without the full T6050 driver. + endif diff --git a/drivers/net/wireless/apple/centauri/Makefile b/drivers/net/wireless/apple/centauri/Makefile index 235e1090294dc..be1d286fdb0e9 100644 --- a/drivers/net/wireless/apple/centauri/Makefile +++ b/drivers/net/wireless/apple/centauri/Makefile @@ -2,3 +2,4 @@ obj-$(CONFIG_APPLE_CENTAURI) += apple_centauri.o apple_centauri-y := centauri_pci.o centauri_port.o centauri_ipc.o centauri_wifi.o obj-$(CONFIG_APPLE_CENTAURI_T6050) += t6050/ +obj-$(CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT) += t6050/ diff --git a/drivers/net/wireless/apple/centauri/t6050/.kunitconfig b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig index d73990b2ac0d8..55b2ca4863ddb 100644 --- a/drivers/net/wireless/apple/centauri/t6050/.kunitconfig +++ b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig @@ -2,8 +2,4 @@ CONFIG_COMPILE_TEST=y CONFIG_KUNIT=y CONFIG_WLAN=y CONFIG_WLAN_VENDOR_APPLE=y -CONFIG_CFG80211=y -CONFIG_DEBUG_FS=y -CONFIG_PCIE_APPLE=y -CONFIG_APPLE_CENTAURI_T6050=y -CONFIG_APPLE_CENTAURI_T6050_WIFI=y +CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT=y \ No newline at end of file diff --git a/drivers/net/wireless/apple/centauri/t6050/Makefile b/drivers/net/wireless/apple/centauri/t6050/Makefile index 5632d74c0d127..239727c5c57f1 100644 --- a/drivers/net/wireless/apple/centauri/t6050/Makefile +++ b/drivers/net/wireless/apple/centauri/t6050/Makefile @@ -1,4 +1,9 @@ # SPDX-License-Identifier: GPL-2.0-only +obj-$(CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT) += centauri_recovery.o + obj-$(CONFIG_APPLE_CENTAURI_T6050) += apple_centauri_t6050.o apple_centauri_t6050-y := centauri_pci.o centauri_ipc.o -apple_centauri_t6050-$(CONFIG_APPLE_CENTAURI_T6050_WIFI) += centauri_wifi.o centauri_recovery.o +apple_centauri_t6050-$(CONFIG_APPLE_CENTAURI_T6050_WIFI) += centauri_wifi.o +ifneq ($(CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT),y) +apple_centauri_t6050-$(CONFIG_APPLE_CENTAURI_T6050_WIFI) += centauri_recovery.o +endif \ No newline at end of file diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c index ae733d74a5033..b8e10e14123c9 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c @@ -123,7 +123,7 @@ void centauri_t6050_schedule_transport_recover(struct centauri_t6050 *c) } EXPORT_SYMBOL_GPL(centauri_t6050_schedule_transport_recover); -#if IS_ENABLED(CONFIG_KUNIT) +#if IS_ENABLED(CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT) #include From ca5663bd87ab863a8be93bac3a6d513501e2ab3b Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 05:00:11 -0600 Subject: [PATCH 5/7] wifi: expand t6050 kunit fragment for netdev deps --- drivers/net/wireless/apple/centauri/t6050/.kunitconfig | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/apple/centauri/t6050/.kunitconfig b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig index 55b2ca4863ddb..9f673918aaa8b 100644 --- a/drivers/net/wireless/apple/centauri/t6050/.kunitconfig +++ b/drivers/net/wireless/apple/centauri/t6050/.kunitconfig @@ -1,5 +1,9 @@ CONFIG_COMPILE_TEST=y CONFIG_KUNIT=y +CONFIG_NET=y +CONFIG_INET=y +CONFIG_NETDEVICES=y +CONFIG_WIRELESS=y CONFIG_WLAN=y CONFIG_WLAN_VENDOR_APPLE=y CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT=y \ No newline at end of file From 7b96634d0d883845caf1bc2e40790b9338020b51 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 05:03:50 -0600 Subject: [PATCH 6/7] wifi: omit T6050 transport recover from RECOVERY_KUNIT link --- drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c index b8e10e14123c9..5eb5d90b909bf 100644 --- a/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c +++ b/drivers/net/wireless/apple/centauri/t6050/centauri_recovery.c @@ -50,6 +50,8 @@ int centauri_t6050_boot_phase_for_control_stage(u32 control_stage, } EXPORT_SYMBOL_GPL(centauri_t6050_boot_phase_for_control_stage); +#if IS_ENABLED(CONFIG_APPLE_CENTAURI_T6050) + #define CEN_TRANSPORT_RECOVER_MAX 3 static void centauri_t6050_transport_recover_worker(struct work_struct *work) @@ -123,6 +125,8 @@ void centauri_t6050_schedule_transport_recover(struct centauri_t6050 *c) } EXPORT_SYMBOL_GPL(centauri_t6050_schedule_transport_recover); +#endif /* CONFIG_APPLE_CENTAURI_T6050 */ + #if IS_ENABLED(CONFIG_APPLE_CENTAURI_T6050_RECOVERY_KUNIT) #include From 4273e3a27a4d15e559672f49e52e31456931b346 Mon Sep 17 00:00:00 2001 From: Joshua Warren <816217+joshuaswarren@users.noreply.github.com> Date: Wed, 18 Nov 2026 05:20:33 -0600 Subject: [PATCH 7/7] wifi: sync centauri host tests with T6050 driver mocks centauri-wifi-pm-tests: match command_fault signature from centauri_wifi.c. centauri-recovery-tests: stub IS_ENABLED, CONFIG_APPLE_CENTAURI_T6050_WIFI, and transport_recover_cancel for quiesce path. Proof: python3 tools/asahi/centauri-wifi-pm-tests.py (+ --negative-controls) && centauri-recovery-tests.py (+ --negative-controls) all pass at this tree. --- tools/asahi/centauri-recovery-tests.py | 4 ++++ tools/asahi/centauri-wifi-pm-tests.py | 4 +++- 2 files changed, 7 insertions(+), 1 deletion(-) mode change 100644 => 100755 tools/asahi/centauri-recovery-tests.py mode change 100644 => 100755 tools/asahi/centauri-wifi-pm-tests.py diff --git a/tools/asahi/centauri-recovery-tests.py b/tools/asahi/centauri-recovery-tests.py old mode 100644 new mode 100755 index 5ffbd92f8baab..fdf05b07fd37e --- a/tools/asahi/centauri-recovery-tests.py +++ b/tools/asahi/centauri-recovery-tests.py @@ -37,6 +37,8 @@ def block(name): #include #include #include +#define CONFIG_APPLE_CENTAURI_T6050_WIFI 1 +#define IS_ENABLED(option) ((option) ? 1 : 0) #define WRITE_ONCE(x,v) ((x)=(v)) #define smp_store_release(p,v) (*(p)=(v)) #define PCI_DEVFN(s,f) (((s)<<3)|(f)) @@ -92,6 +94,8 @@ def block(name): static bool centauri_t6050_ipc_fenced(struct centauri_t6050_ipc *p) { return !p || p->fenced; } static void cancel_delayed_work_sync(int *p) { (void)p; event(STOP_BOOT); } +static void centauri_t6050_transport_recover_cancel(struct centauri_t6050 *c) +{ (void)c; } static int centauri_t6050_beta_call(struct centauri_t6050_rewake *r, bool release) { struct centauri_t6050 *c = r->control->dev.data; diff --git a/tools/asahi/centauri-wifi-pm-tests.py b/tools/asahi/centauri-wifi-pm-tests.py old mode 100644 new mode 100755 index 930c08839bbaf..70e6f023c08ed --- a/tools/asahi/centauri-wifi-pm-tests.py +++ b/tools/asahi/centauri-wifi-pm-tests.py @@ -96,7 +96,9 @@ def block(source, name): static void put_unaligned_le16(u16 value, void *p) { memcpy(p, &value, 2); } static void put_unaligned_le32(u32 value, void *p) { memcpy(p, &value, 4); } static void put_unaligned_le64(uint64_t value, void *p) { memcpy(p, &value, 8); } -static void command_fault(struct centauri_t6050_wifi *wifi) { wifi->command_failed = true; } +static void command_fault(struct centauri_t6050_wifi *wifi, u32 id, + u32 wifi_stage, const char *reason) +{ (void)id; (void)wifi_stage; (void)reason; wifi->command_failed = true; } static void drain(struct centauri_t6050_wifi *wifi) { assert(wifi->lock);