Repository navigation
pinctrl: apple: clear bit 4 of the GPIO mode on the T6050 - #2004
joshuaswarren wants to merge 1 commit into
Conversation
Codex Review Summary: ❌ FailedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
The account paying for this security review has reached its Codex usage limits. The payer can check the Codex usage dashboard. For personal accounts, using credits requires enabling “Use credits for security reviews” in Code review settings. If you do not manage the paying account, contact this repository's admins. |
|
GREEN on 729b14a Checked the one-line diff against the file at this head and the claims against the code. Modes 0 to 7 unchanged: verified arithmetically - FIELD_PREP of any value 0-7 into GENMASK(4,1) produces the same v<<1 bit pattern as into GENMASK(3,1) (bit 4 is only reachable by values >= 8), so the written mode encodings are identical; the change affects only the clear side, where direction_input, direction_output and the IRQ-type setter now also clear bit 4 in the read-modify-write. The get_direction effect on a bit-4-set pin is exactly what the Not-checked section says: FIELD_GET over the widened mask returns a value that no longer equals REG_GPIOx_OUT (0x12 reads 9, not 1), so such a pin now reports not-output - and given the register evidence that DATA does not latch with the bit set, reading it as not a working output is the truthful direction. apple_gpio_get correspondingly takes the live-register path for such pins. The K114c read-backs in the commit message are self-consistent (0x474212 has bit 4 set and reads back unchanged when DATA is written; 0x474203 without the bit latches). The Validated-on section claims nothing beyond the register reads and the in-stack validation, and says plainly that the commit was not booted alone and no other Mac was run. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
GREEN on 729b14a Independent review. This is one fix in one file, and the commit and the PR text are clean: no hostnames, home paths or lab names. I read the driver at this head. I did not compile it: the local tree I had lacked the generated headers, and the PR already reports an object build. I did not boot anything. Whether the width is right on other SoCs is not something a reader can prove, so that is the first note. No blocking items. Non-blocking notes:
|
729b14a to
aea7476
Compare
|
GREEN on aea7476 Re-review at the scoped head, read against the file at this commit. The redesign addresses the reach concern from the earlier all-SoCs form the right way: bit 4 joins the mode mask only through a per-hw mode_hi flag on the new apple,t6050-pinctrl entry (a new of_match row with its own hw struct), so every other SoC keeps the exact three-bit behavior - the set of machines the bit was never checked on is no longer exposed. The mask helper (REG_GPIOx_MODE | mode_hi) feeds the same comparison and write paths as before, so the semantics I verified earlier carry: writes clear bit 4 on t6050, get_direction/get read a bit-4-set pin as not-output, and FIELD_PREP of modes 0-7 is unchanged. The commit message now carries the Tested line in the honest form: build-only on the M1 with and without the change, register read-backs from the K114c, the earlier all-SoCs form booted in the touch stack, and this T6050-only form explicitly not booted. Model: zai/glm-5.3 (live from lane_models.py this turn). |
|
GREEN on aea7476 Re-review after my earlier notes. Both are addressed. No blocking items. What I checked in
I did not compile or boot it. Non-blocking notes:
|
On the K114c the NUB GPIO block comes out of iBoot with bit 4 of the touch-screen reset and power pins set (0x474210, 0x474212 as read through /dev/mem). With that bit set, the DATA bit does not latch in output mode: writing 0x474213 reads back 0x474212, writing 0x474203 reads back 0x474203. direction_output wrote only bits 1-3 of the mode, so the pin stayed in a state where the driver's output value never took effect. Add a hw table entry for apple,t6050-pinctrl that treats bits 1-4 as the mode: direction_input, direction_output and the interrupt mode writes clear bit 4, and get_direction and get read it. Every other SoC keeps the three-bit mode, since the bit was not checked on them. Modes 0-7 are unchanged, and a working output (the PERST# pin of the K114c, register 0x00076a03) has the bit clear. Tested: drivers/pinctrl/pinctrl-apple-gpio.o builds with gcc 16.1.1 and W=1, no warnings, with and without the change, on a depth-1 checkout of integration/aurora (580e911) on a 13-inch M1 MacBook. The register read-backs above are from the 14-inch M5 Max MacBook Pro (K114c). An earlier form of this change (all SoCs, mode bits 1-4) was booted there in the touch screen stack; this T6050-only form was not booted. Signed-off-by: Joshua Warren <816217+joshuaswarren@users.noreply.github.com>
aea7476 to
a0609dc
Compare
joshuaswarren
left a comment
There was a problem hiding this comment.
GREEN on a0609dc
Model: cognition/swe-2-flash-medium
Full-file read at head. The mode_hi design is correct: pctl->mode_hi is set only when the hw table says so (t6050 gets apple_gpio_t6050_hw with no_regcache preserved; t8140/t8132 keep uncached_hw, t8103/pinctrl get NULL hw so the guard if (hw && hw->mode_hi) leaves mode_hi 0 and the mask is bit-identical to the old GENMASK(3,1)).
Every mode access now goes through apple_gpio_mode_mask: get_direction and get compare (reg & mask) == FIELD_PREP(REG_GPIOx_MODE, OUT) - for non-T6050 this is exactly the old FIELD_GET==1; for T6050 a set bit 4 reads as not-OUT, which matches the measured wedge (output value cannot latch while bit 4 is set). direction_input, direction_output, irq_mask, irq_unmask and irq_set_type all pass the widened mask to apple_gpio_set_reg -> regmap_update_bits, so bit 4 is cleared on every mode write while FIELD_PREP(REG_GPIOx_MODE, ...) still only sets bits 1-3. pinmux_set touches only PERIPH|INPUT_ENABLE, correctly outside the mode field.
Resume path checked: saved_valid only covers touched pins and regmap_write restores the full saved word; since driver writes now clear bit 4 before the value is saved, restore cannot resurrect the wedge on a pin the driver configured. Untouched pins are never saved or restored.
No other REG_GPIOx_MODE mask position remains unconverted (grep at head: all mask args use apple_gpio_mode_mask; remaining bare uses are FIELD_PREP values, correct). Disclosed risk stands: the T6050-only form was compile-checked, not booted - acceptable for review, the boot evidence belongs to the PR thread.
|
Thanks for the precise register read-backs. They make the touch-screen problem very clear. One request on scope. The four-bit mode is enabled only on T6050 match data ( The fix itself, clearing bit 4 when setting a pin's mode, looks harmless wherever bit 4 is part of the mode field. Could you either make the four-bit mode the default for every SoC, or keep the flag with a comment naming a known hardware difference on the older blocks? We are happy to run GPIO and boot rows on our M1 Pro, M2, M4 Pro and A18 Pro to check the wider change. |
|
[Joshua's agent] Replying to @RyanTheTide scope question. We will keep the four-bit mode behind What is measured (T6050 only, K114c): NUB touch reset/power pins left iBoot with bit 4 set (0x474210 / 0x474212 via What is not measured: GPIO mode read-backs on M1/M2/M3/M4/M5 Pro, or on the AP/AOP T6050 pinctrl nodes, for whether bit 4 is spare or re-used. We do not have a documented alternate meaning of bit 4 on older blocks—only absence of data. M1 was compile-only ( Why not default four-bit for every compatible yet: Making four-bit the default would apply bit-4 clear/read to every Mac that loads this driver without the read-backs above. The clearing operation is likely harmless if bit 4 is part of the mode field on those blocks, but we will not widen on that inference alone. Plan: Revise the PR text to say the flag marks where we have register proof, not "older SoCs differ." If your M1 Pro / M2 / M4 Pro / A18 Pro GPIO rows show bit 4 unused or matching this layout, we will either drop the flag or promote four-bit default in a follow-up with your numbers attached—whichever matches what you measure. This T6050-only head still needs a boot + touch check on K114c; read-backs above are from before the scoped patch landed. |
|
Thanks for separating what was measured from what was not. Under the convention here, a gate stays only for a known hardware difference (another meaning of bit 4, a different block revision, measured breakage); missing data on the other SoCs is not one. Since you are open to widening once there is data, we will take the bit-4 GPIO mode read-backs on our M1 Pro, M2, M4 Pro and A18 Pro and post them here. If they match your layout, could the four-bit mode become the default in this PR rather than a follow-up? If one differs, that result is the comment the flag needs. The K114c boot and touch check on this head is still open. |
[Joshua's agent]
Split out of #1605 (the K114c touch screen), one fix per PR. #1605 lists this PR as a dependency.
On the K114c the NUB GPIO block comes out of iBoot with bit 4 of the touch-screen reset and power pins set (0x474210 and 0x474212, read through
/dev/mem). With that bit set the DATA bit does not latch in output mode: writing 0x474213 reads back 0x474212, while writing 0x474203 reads back 0x474203.direction_outputwrote only bits 1-3 of the mode, so the pin stayed in a state where the driver's output value never took effect.The change adds a hw table entry for
apple,t6050-pinctrl(apple_gpio_t6050_hw,mode_hi). On a T6050 block the mode is bits 1-4:direction_input,direction_outputand the interrupt mode writes clear bit 4, andget_directionandgetread it. Every other SoC keeps the three-bit mode, because bit 4 was not checked on them. Modes 0-7 are unchanged, and a working output (the PERST# pin of the K114c, register 0x00076a03) has the bit clear. One file,drivers/pinctrl/pinctrl-apple-gpio.c. All three T6050 pinctrl nodes in the tree already listapple,t6050-pinctrlfirst.Changed after review (RevAne421): the first form made the mode four bits wide for every SoC. It is now T6050 only.
Validated on, and reach
What ran where:
Kiwi interface ready with status:0appeared. This T6050-only form was not booted, and no finger events were checked.drivers/pinctrl/pinctrl-apple-gpio.ocompiles with and without the change with gcc 16.1.1 andW=1, no warnings, on a depth-1 checkout ofintegration/aurora(580e9119). Not a full tree build and not booted.Not checked: any other Mac. The T6050 hw table also applies to the other two T6050 pinctrl blocks (AP and AOP); on those the mode bit 4 was not read. No M1, M2, M3, M4 or M5 Pro machine was run.
m tester (omarchy-m-testing.org): no feature row covers a GPIO mode; no tester run is linked to this change.