• Hans de Goede's avatar
    ACPI / button: Delay acpi_lid_initialize_state() until first user space open · 84d3f6b7
    Hans de Goede authored
    ACPI _LID methods may depend on OpRegions and do not always handle
    handlers for those OpRegions not being present properly e.g. :
    
                Method (_LID, 0, NotSerialized)  // _LID: Lid Status
                {
                    If ((^^I2C5.PMI1.AVBL == One) && (^^GPO2.AVBL == One))
                    {
                        Return (^^GPO2.LPOL) /* \_SB_.GPO2.LPOL */
                    }
                }
    
    Note the missing Return (1) when either of the OpRegions is not available,
    this causes (in this case) a report of the lid-switch being closed,
    which causes userspace to do an immediate suspend at boot.
    
    This commit delays getting the initial state and thus calling _LID for
    the first time until userspace opens the /dev/input/event# node. This
    ensures that all drivers will have had a chance to load and registerer
    their OpRegions before the first _LID call, fixing this issue.
    Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    84d3f6b7
button.c 16.8 KB