• Armin Wolf's avatar
    platform/x86: lg-laptop: Add operation region support · 3573fee8
    Armin Wolf authored
    The LEGX0820 ACPI device is expected to provide a custom operation
    region:
    
    	OperationRegion (XIN1, 0x8F, Zero, 0x04B0)
            Field (XIN1, AnyAcc, Lock, Preserve)
            {
                DMSG,   8,
                HDAP,   8,
                Offset (0x03),
                AFNM,   8,
                Offset (0x10),
                P80B,   8,
                P81B,   8,
                P82B,   8,
                P83B,   8,
                P84B,   8,
                P85B,   8,
                P86B,   8,
                P87B,   8,
                Offset (0x20),
                DTTM,   8,
                TMP1,   8,
                LTP1,   8,
                HTP1,   8,
                TMP2,   8,
                LTP2,   8,
                HTP2,   8,
                Offset (0x3E8),
                PMSG,   1600
            }
    
    The PMSG field is used by AML code to log debug messages when DMSG is
    true. Since those debug messages are already logged using the standard
    ACPI Debug object, we set DMSG unconditionally to 0x00 and ignore any
    writes to PMSG.
    
    The TMPx, LTPx, HTPx and AFNM fields are used to inform the driver when
    the temperature/(presumably) trip points/fan mode changes. This only
    happens when the DTTM flag is set.
    
    Unfortunately we have to implement support for this operation region
    because the AML codes uses code constructs like this one:
    
    	If (((\_SB.XINI.PLAV != Zero) && (\_SB.XINI.DTTM != Zero)))
    
    The PLAV field gets set to 1 when the driver registers its address space
    handler, so by default XIN1 should not be accessed.
    
    However ACPI does not use short-circuit evaluation when evaluating
    logical conditions. This causes the DTTM field to be accessed even
    when PLAV is 0, which results in an ACPI error.
    Since this check happens inside various thermal-related ACPI control
    methods, various thermal zone become unusable since any attempt to
    read their temperature results in an ACPI error.
    
    Fix this by providing support for this operation region. I suspect
    that the problem does not happen under Windows (which seemingly does
    not use short-circuit evaluation either) because the necessary driver
    comes preinstalled with the machine.
    Tested-by: default avatarChris <ghostwind@gmail.com>
    Signed-off-by: default avatarArmin Wolf <W_Armin@gmx.de>
    Link: https://lore.kernel.org/r/20240813022903.20567-1-W_Armin@gmx.deReviewed-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    3573fee8
lg-laptop.c 20.9 KB