Re: [PATCH v2 4/5] apple-gmux: support MMIO gmux on T2 Macs
From: Hans de Goede
Date: Sat Feb 18 2023 - 05:50:44 EST
Hi,
On 2/17/23 13:02, Orlando Chamberlain wrote:
> On Fri, 17 Feb 2023 11:05:31 +1100
> Orlando Chamberlain <orlandoch.dev@xxxxxxxxx> wrote:
>>>
>>> Question are we not worried about MacBooks with an "APP000B"
>>> ACPI device (with a value IORSOURCE_MEM entry) but which do not
>>> actually have a gmux, because they are iGPU only ?
>>
>> It looks like iMac20,1, iMac20,2, and iMacPro1,1 have APP000B:
>>
>> apple_gmux: Failed to find gmux I/O resource
>>
>> iMac20,2: https://linux-hardware.org/?probe=ec2af584b3&log=dmesg
>> iMac20,1: https://linux-hardware.org/?probe=fee7644b9c&log=dmesg
>> iMacPro1,1: https://linux-hardware.org/?probe=6c26c9ff8c&log=dmesg
>>
>> But I'm not sure if they actually have it or not. I'll see if I can
>> get people with those models to test if it's a real gmux. There does
>> seem to be a pattern in that those three all have AMD GPU's.
>
> Kerem Karabay managed to find the acpi tables and macOS's ioreg from and
> iMacPro1,1:
>
> https://github.com/khronokernel/DarwinDumped/blob/master/iMacPro/iMacPro1%2C1/Darwin%20Dumper/DarwinDumper_3.0.4_30.12_15.30.40_iMacPro1%2C1_Apple_X64_High%20Sierra_17C2120_apple/ACPI%20Tables/DSL/DSDT.dsl#L10423
> https://github.com/khronokernel/DarwinDumped/blob/master/iMacPro/iMacPro1%2C1/Darwin%20Dumper/DarwinDumper_3.0.4_30.12_15.30.40_iMacPro1%2C1_Apple_X64_High%20Sierra_17C2120_apple/IORegistry/IOReg.txt#L5096
>
> The DSDT table has the same APP000B device as MacBooks with actual gmux,
> while the ioreg has no mention of Apple's driver AppleMuxControl2 being
> used for that device.
>
> I think that confirms Apple has not fixed the issue of putting
> APP000B's where they don't need to.
>
> Solutions to this I can think of are:
>
> - Use DMI matching to ignore product_names "iMacPro1,1" "iMac20,1",
> "iMac20,2"
> - Maybe check if the MMIO region for gmux is filled with 0xff*
>
> *I don't know if this would work or not as I don't have a machine to
> check with. On my machine everything surrounding the 16 bytes used for
> gmux is 0xff:
>
> # hexdump -n48 -C -s 0xfe0b01f0 /dev/mem
> fe0b01f0 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
> fe0b0200 00 00 3e 4f 00 00 00 00 00 00 00 00 00 00 14 00 |..>O............|
> fe0b0210 ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff ff |................|
>
> so maybe on the iMacPro and iMac's, this would all be 0xff.
Yes checking for a regular ioread32 returning 0xffffffff sounds
like it should work. Can you add a check for that in the next version
please ? Note this means we still need to do an iomap + unmap as
you pointed out in another email, but I see no way around that.
Regards,
Hans
>
>>
>> I've looked at dmesg or at least lsmod on all the models with the T2
>> chip and there wasn't evidence of any other models having that error
>> or having apple-gmux loaded on any models that shouldn't have a gmux,
>> other than the three mentioned above. Of course I don't know if its
>> possible for there to be firmware versions where this isn't the case.
>>
>>>
>>> I have learned the hard way (through backlight control regressions
>>> in 6.1) that at least some older model MacBooks with an IO resource
>>> have an APP000B ACPI device without them actually having a gmux,
>>> these get caught by the version check and then do not pass the
>>> indexed check so that apple_gmux_detect() properly returns false.
>>>
>>> Maybe make gmux_mmio_read32() a static inline inside
>>> include/linux/apple-gmux.h and try to read the version here ?
>>
>> For that would we need to ioremap() and iounmap()?
>>>
>>> Has this been tested on iGPU only T2 Macs?
>>
>> I don't think so.
>>
>>>
>>> Regards,
>>>
>>> Hans
>>>
>>>
>>
>