From e6a87596ad7ad39003ddd3a4f47034a5f414c189 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Fri, 20 Nov 2026 01:04:42 +1100 Subject: [PATCH 1/2] media: apple: isp: name the reset drain reads and report a word that stays set isp_reset_coproc(), the reset of every ISP before T8140 and T6040, reads the coprocessor words at 0x818 and 0x81c up to 128 times each until they read 0, with no wait between reads, and then carries on whatever they read. The offsets were bare numbers, the bound had no source, and a word that never cleared went unnoticed: only the WFI poll of the coprocessor status that follows can fail the boot. What the two words are is not known. On T8140 the same step reads two acknowledge words at 0x1600818 and 0x160081c, in the block where the control, status and interrupt mask registers moved from 0x14000xx to 0x16000xx, so the older counterparts may sit at 0x1400818 and 0x140081c instead. That needs a hardware run to settle. Name the words and the bound, and say what is and is not known about them. Read them through one helper that performs the same register accesses as before (the same words, in the same order, at most 128 reads each, stopping at the first 0), warns once if a word is still set after the last read, and reports at debug level how many reads each word took. T8140 and T6040 return before this code and are not reached. Link: https://github.com/aurora-silicon/linux/issues/2318 Signed-off-by: Ryan Murray --- drivers/media/platform/apple/isp/isp-fw.c | 43 ++++++++++++++------- drivers/media/platform/apple/isp/isp-regs.h | 8 ++++ 2 files changed, 38 insertions(+), 13 deletions(-) diff --git a/drivers/media/platform/apple/isp/isp-fw.c b/drivers/media/platform/apple/isp/isp-fw.c index 09b6912286505..a071e3dcb5ad6 100644 --- a/drivers/media/platform/apple/isp/isp-fw.c +++ b/drivers/media/platform/apple/isp/isp-fw.c @@ -371,11 +371,37 @@ static int isp_check_coproc_t6040(struct apple_isp *isp) return 0; } +/* + * The reset of the ISPs before T8140 and T6040 reads two words until they are + * 0, at most this many times each with no wait between reads, and goes on + * whatever they read: the WFI poll that follows is the check that fails the + * boot. The reads, their offsets and this bound come from the original driver + * and have no known source (aurora-silicon/linux#2318). + */ +#define ISP_COPROC_DRAIN_READS 128 + +static void isp_drain_coproc_word(struct apple_isp *isp, u32 reg) +{ + unsigned int reads = 0; + u32 val; + + do { + val = isp_coproc_read32(isp, reg); + reads++; + } while (val && reads < ISP_COPROC_DRAIN_READS); + + if (val) + dev_warn_once(isp->dev, + "coprocessor word %#x still %#x after %u reads\n", + reg, val, reads); + else + isp_dbg(isp, "coprocessor word %#x read 0 after %u reads\n", + reg, reads); +} + static int isp_reset_coproc(struct apple_isp *isp) { - int retries; u32 status; - u32 val; if (isp->hw->gen == ISP_GEN_T8140) return isp_reset_coproc_t8140(isp); @@ -396,17 +422,8 @@ static int isp_reset_coproc(struct apple_isp *isp) isp_coproc_write32(isp, ISP_COPROC_IRQ_MASK_4, 0xffffffff); isp_coproc_write32(isp, ISP_COPROC_IRQ_MASK_5, 0xffffffff); - for (retries = 0; retries < 128; retries++) { - val = isp_coproc_read32(isp, 0x818); - if (val == 0) - break; - } - - for (retries = 0; retries < 128; retries++) { - val = isp_coproc_read32(isp, 0x81c); - if (val == 0) - break; - } + isp_drain_coproc_word(isp, ISP_COPROC_DRAIN_0); + isp_drain_coproc_word(isp, ISP_COPROC_DRAIN_1); if (readl_poll_timeout(isp->coproc + ISP_COPROC_STATUS, status, status & ISP_COPROC_IN_WFI, diff --git a/drivers/media/platform/apple/isp/isp-regs.h b/drivers/media/platform/apple/isp/isp-regs.h index b7f9b2fb87faa..133de67e519bd 100644 --- a/drivers/media/platform/apple/isp/isp-regs.h +++ b/drivers/media/platform/apple/isp/isp-regs.h @@ -23,6 +23,14 @@ #define ISP_COPROC_IRQ_MASK_4 0x1400a10 #define ISP_COPROC_IRQ_MASK_5 0x1400a14 +/* + * Two words the reset before T8140 reads until they are 0. What they are is + * not known; the T8140 reset reads its acknowledge words at 0x1600818 and + * 0x160081c instead. + */ +#define ISP_COPROC_DRAIN_0 0x818 +#define ISP_COPROC_DRAIN_1 0x81c + #define ISP_COPROC_CONTROL_T8140 0x1600044 #define ISP_COPROC_STATUS_T8140 0x1600048 #define ISP_COPROC_QUIESCE_T8140 0x1600040 From 08fe6b59b5e7d07994d214477b623ffb07d875f2 Mon Sep 17 00:00:00 2001 From: Ryan Murray Date: Mon, 23 Nov 2026 10:17:50 +1100 Subject: [PATCH 2/2] media: apple: isp: report both reset drain words at debug level The reset drain helper warned once when a word was still set after the last read. The once-flag sits in the helper, so the two words shared it and the first word to warn hid the other for the rest of the boot: the M1 Pro run showed 0x818 and nothing about 0x81c. The warning also fired on the first camera power-up of every boot on M1 Pro (0x818) and on M2 (0x81c), where the camera delivers every frame, so it reported a fault where there is none. Report each word's last value and its number of reads with isp_dbg(), whether it read 0 or not, on every reset. Warning and error level stay for the WFI poll, which is the check that fails the reset. Say in the comment that a word that stays set is the normal state on those two machines. Link: https://github.com/aurora-silicon/linux/issues/2318 Signed-off-by: Ryan Murray --- drivers/media/platform/apple/isp/isp-fw.c | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/drivers/media/platform/apple/isp/isp-fw.c b/drivers/media/platform/apple/isp/isp-fw.c index a071e3dcb5ad6..dcfef86074fbb 100644 --- a/drivers/media/platform/apple/isp/isp-fw.c +++ b/drivers/media/platform/apple/isp/isp-fw.c @@ -374,9 +374,12 @@ static int isp_check_coproc_t6040(struct apple_isp *isp) /* * The reset of the ISPs before T8140 and T6040 reads two words until they are * 0, at most this many times each with no wait between reads, and goes on - * whatever they read: the WFI poll that follows is the check that fails the - * boot. The reads, their offsets and this bound come from the original driver - * and have no known source (aurora-silicon/linux#2318). + * whatever they read. A word that is still set after the last read is not a + * fault: on M1 Pro the first word and on M2 the second one stays set on every + * boot and the camera works. The WFI poll that follows is the check that + * fails the reset. The reads, their offsets and this bound come from the + * original driver and have no known source (aurora-silicon/linux#2318), so + * each word's last value and number of reads are reported at debug level. */ #define ISP_COPROC_DRAIN_READS 128 @@ -390,13 +393,8 @@ static void isp_drain_coproc_word(struct apple_isp *isp, u32 reg) reads++; } while (val && reads < ISP_COPROC_DRAIN_READS); - if (val) - dev_warn_once(isp->dev, - "coprocessor word %#x still %#x after %u reads\n", - reg, val, reads); - else - isp_dbg(isp, "coprocessor word %#x read 0 after %u reads\n", - reg, reads); + isp_dbg(isp, "coprocessor word %#x read %#x after %u reads\n", reg, val, + reads); } static int isp_reset_coproc(struct apple_isp *isp)