• Lv Zheng's avatar
    ACPI 2.0 / ECDT: Remove early namespace reference from EC · 59f0aa94
    Lv Zheng authored
    All operation region accesses are allowed by AML interpreter when AML is
    executed, so actually BIOSen are responsible to avoid the operation region
    accesses in AML before OSPM has prepared an operation region driver. This
    is done via _REG control method. So AML code normally sets a global named
    object REGC to 1 when _REG(3, 1) is evaluated.
    
    Then what is ECDT? Quoting from ACPI spec 6.0, 5.2.15 Embedded Controller
    Boot Resources Table (ECDT):
     "The presence of this table allows OSPM to provide Embedded Controller
      operation region space access before the namespace has been evaluated."
    Spec also suggests a compatible mean to indicate the early EC access
    availability:
     Device (EC)
     {
         Name (REGC, Ones)
         Method (_REG, 2)
         {
             If (LEqual (Arg0, 3))
             {
                 Store (Arg1, REGC)
             }
         }
         Method (ECAV)
         {
             If (LEqual (REGC, Ones))
             {
                 If (LGreaterEqual (_REV, 2))
                 {
                     Return (One)
                 }
                 Else
                 {
                     Return (Zero)
                 }
             }
             Else
             {
                 Return (REGC)
             }
         }
     }
    In this way, it allows EC accesses to happen before EC._REG(3, 1) is
    invoked.
    
    But ECAV is not the only way practical BIOSen using to indicate the early
    EC access availibility, the known variations include:
    1. Setting REGC to One in \_SB._INI when _REV >= 2. Since \_SB._INI is the
       first control method evaluated by OSPM during the enumeration, this
       allows EC accesses to happen for the entire enumeration process before
       the namespace EC is enumerated.
    2. Initialize REGC to One by default, this even allows EC accesses to
       happen during the table loading.
    
    Linux is now broken around ECDT support during the long term bug fixing
    work because it has merged many wrong ECDT bug fixes (see details below).
    Linux currently uses namespace EC's settings instead of ECDT settings when
    ECDT is detected. This apparently will result in namespace walk and
    _CRS/_GPE/_REG evaluations. Such stuffs could only happen after namespace
    is ready, while ECDT is purposely to be used before namespace is ready.
    
    The wrong bug fixing story is:
    1. Link 1:
       At Linux ACPI early stages, "no _Lxx/_Exx/_Qxx evaluation can happen
       before the namespace is ready" are not ensured by ACPICA core and Linux.
       This is currently ensured by deferred enabling of GPE and defered
       registering of EC query methods (acpi_ec_register_query_methods).
    2. Link 2:
       Reporters reported buggy ECDTs, expecting quirks for the platform.
       Originally, the quirk is simple, only doing things with ECDT.
       Bug 9399 and 12461 are platforms (Asus L4R, Asus M6R, MSI MS-171F)
       reported to have wrong ECDT IO port addresses, the port addresses are
       reversed.
       Bug 11880 is a platform (Asus X50GL) reported to have 0 valued port
       addresses, we can see that all EC accesses are protected by ECAV on
       this platform, so actually no early EC accesses is required by this
       platform.
    3. Link 3:
       But when the bug fixing developer was requested to provide a handy and
       non-quirk bug fix, he tried to use correct EC settings from namespace
       and broke the spec purpose. We can even see that the developer was
       suffered from many regrssions. One interesting one is 14086, where the
       actual root cause obviously should be: _REG is evaluated too early. But
       unfortunately, the bug is fixed in a totally wrong way.
    
    So everything goes wrong from these commits:
       Commit: c6cb0e87
       Subject: ACPI: EC: Don't trust ECDT tables from ASUS
       Commit: a5032bfd
       Subject: ACPI: EC: Always parse EC device
    
    This patch reverts Linux behavior to simple ECDT quirk support in order to
    stop early _CRS/_GPE/_REG evaluations.
    For Bug 9399, 12461, since it is reported that the platforms require early
    EC accesses, this patch restores the simple ECDT quirks for them.
    For Bug 11880, since it is not reported that the platform requires early EC
    accesses and its ACPI tables contain correct ECAV, we choose an ECDT
    enumeration failure for this platform.
    
    Link 1: https://bugzilla.kernel.org/show_bug.cgi?id=9916
            http://bugzilla.kernel.org/show_bug.cgi?id=10100
            https://lkml.org/lkml/2008/2/25/282
    Link 2: https://bugzilla.kernel.org/show_bug.cgi?id=9399
            https://bugzilla.kernel.org/show_bug.cgi?id=12461
            https://bugzilla.kernel.org/show_bug.cgi?id=11880
    Link 3: https://bugzilla.kernel.org/show_bug.cgi?id=11884
            https://bugzilla.kernel.org/show_bug.cgi?id=14081
            https://bugzilla.kernel.org/show_bug.cgi?id=14086
            https://bugzilla.kernel.org/show_bug.cgi?id=14446
    Link 4: https://bugzilla.kernel.org/show_bug.cgi?id=112911Signed-off-by: default avatarLv Zheng <lv.zheng@intel.com>
    Tested-by: default avatarChris Bainbridge <chris.bainbridge@gmail.com>
    Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
    59f0aa94
ec.c 44.6 KB