The iomem_write_smc, iomem_read_smc, and iomem_get_smc_key_type
functions used iowrite32 to write to byte-sized registers at
non-aligned addresses (KEY_DATA_LEN at 0x7D, KEY_SMC_ID at 0x7E,
KEY_CMD at 0x7F). On some T2 Macs (confirmed on MacBook Air 8,1),
the 32-bit writes at these consecutive addresses cause the T2 SMC
to receive corrupted data, resulting in SmcKeySizeMismatch (error
0x87) on every write operation.
This made fan control via t2fanrd completely non-functional since
the F0Md (fan manual mode) key could never be written.
Fix by using iowrite8 for these byte-sized registers, matching the
ioread8 already used to read them. The 4-byte KEY_NAME register at
0x78 correctly remains iowrite32.
Tested on MacBook Air 8,1 (T2) with kernel 6.18.13 - fan control
works after this fix.
The upstream linux-apfs-rw module recently renamed the build variable from CONFIG to APFS_CONFIG. This caused the 8002 patch to fail during the kernel prepare phase. Updated the target lines in the patch to correctly match the new variable name, allowing the out-of-tree instructions to be removed and the driver to build successfully in-tree.