Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 3 Dec 2016 21:12:54 +0100
From:      Oliver Pinter <oliver.pinter@hardenedbsd.org>
To:        Hans Petter Selasky <hselasky@freebsd.org>
Cc:        "src-committers@freebsd.org" <src-committers@freebsd.org>,  "svn-src-all@freebsd.org" <svn-src-all@freebsd.org>,  "svn-src-head@freebsd.org" <svn-src-head@freebsd.org>, freebsd-acpi@freebsd.org
Subject:   Re: svn commit: r309400 - head/sys/dev/acpica
Message-ID:  <CAPQ4ffu38KhH2WkeV8H8uwX9BDKf_x2SuF36X-3cA4%2BJZ1XQWQ@mail.gmail.com>
In-Reply-To: <201612020821.uB28L8s2000195@repo.freebsd.org>
References:  <201612020821.uB28L8s2000195@repo.freebsd.org>

next in thread | previous in thread | raw e-mail | index | archive | help

[-- Attachment #1 --]
On Fri, Dec 2, 2016 at 9:21 AM, Hans Petter Selasky
<hselasky@freebsd.org> wrote:
> Author: hselasky
> Date: Fri Dec  2 08:21:08 2016
> New Revision: 309400
> URL: https://svnweb.freebsd.org/changeset/base/309400
>
> Log:
>   Fix for endless recursion in the ACPI GPE handler during boot.
>
>   When handling a GPE ACPI interrupt object the EcSpaceHandler()
>   function can be called which checks the EC_EVENT_SCI bit and then
>   recurse on the EcGpeQueryHandler() function. If there are multiple GPE
>   events pending the EC_EVENT_SCI bit will be set at the next call to
>   EcSpaceHandler() causing it to recurse again via the
>   EcGpeQueryHandler() function. This leads to a slow never ending
>   recursion during boot which prevents proper system startup, because
>   the EC_EVENT_SCI bit never gets cleared in this scenario.
>
>   The behaviour is reproducible with the ALASKA AMI in combination with
>   a newer Skylake based mainboard in the following way:
>
>   Enter BIOS and adjust the clock one hour forward. Save and exit the
>   BIOS. System fails to boot due to the above mentioned bug in
>   EcGpeQueryHandler() which was observed recursing multiple times.
>
>   This patch adds a simple recursion guard to the EcGpeQueryHandler()
>   function and also also adds logic to detect if new GPE events occurred
>   during the execution of EcGpeQueryHandler() and then loop on this
>   function instead of recursing.
>
>   Reviewed by:          jhb
>   MFC after:            2 weeks
>
> Modified:
>   head/sys/dev/acpica/acpi_ec.c


I have similar error since the latest BIOS update on my gigabyte
H170N-Wifi board. The curiosity of the BIOS update was after upgrading
to this version, there are no possibility to rollback to older
version.

The other weird thing, is that MFCing back this patch does not help. I
get stucked lock in acmtx mutex, as you
could see from the attached log. The other interesting is the ACPI
error at boot time:

[1] ACPI Error: Mutex [0x0] is not acquired, cannot release
(20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release
(20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] cpu1: <ACPI CPU> on acpi0
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release
(20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release
(20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)

(This error is on 10-STABLE.)

>
> Modified: head/sys/dev/acpica/acpi_ec.c
> ==============================================================================
> --- head/sys/dev/acpica/acpi_ec.c       Fri Dec  2 08:15:52 2016        (r309399)
> +++ head/sys/dev/acpica/acpi_ec.c       Fri Dec  2 08:21:08 2016        (r309400)
> @@ -613,16 +613,14 @@ EcCheckStatus(struct acpi_ec_softc *sc,
>  }
>
>  static void
> -EcGpeQueryHandler(void *Context)
> +EcGpeQueryHandlerSub(struct acpi_ec_softc *sc)
>  {
> -    struct acpi_ec_softc       *sc = (struct acpi_ec_softc *)Context;
>      UINT8                      Data;
>      ACPI_STATUS                        Status;
>      int                                retry;
>      char                       qxx[5];
>
>      ACPI_FUNCTION_TRACE((char *)(uintptr_t)__func__);
> -    KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
>
>      /* Serialize user access with EcSpaceHandler(). */
>      Status = EcLock(sc);
> @@ -647,7 +645,6 @@ EcGpeQueryHandler(void *Context)
>             EC_EVENT_INPUT_BUFFER_EMPTY)))
>             break;
>      }
> -    sc->ec_sci_pend = FALSE;
>      if (ACPI_FAILURE(Status)) {
>         EcUnlock(sc);
>         device_printf(sc->ec_dev, "GPE query failed: %s\n",
> @@ -678,6 +675,29 @@ EcGpeQueryHandler(void *Context)
>      }
>  }
>
> +static void
> +EcGpeQueryHandler(void *Context)
> +{
> +    struct acpi_ec_softc *sc = (struct acpi_ec_softc *)Context;
> +    int pending;
> +
> +    KASSERT(Context != NULL, ("EcGpeQueryHandler called with NULL"));
> +
> +    do {
> +       /* Read the current pending count */
> +       pending = atomic_load_acq_int(&sc->ec_sci_pend);
> +
> +       /* Call GPE handler function */
> +       EcGpeQueryHandlerSub(sc);
> +
> +       /*
> +        * Try to reset the pending count to zero. If this fails we
> +        * know another GPE event has occurred while handling the
> +        * current GPE event and need to loop.
> +        */
> +    } while (!atomic_cmpset_int(&sc->ec_sci_pend, pending, 0));
> +}
> +
>  /*
>   * The GPE handler is called when IBE/OBF or SCI events occur.  We are
>   * called from an unknown lock context.
> @@ -706,13 +726,14 @@ EcGpeHandler(ACPI_HANDLE GpeDevice, UINT
>       * It will run the query and _Qxx method later, under the lock.
>       */
>      EcStatus = EC_GET_CSR(sc);
> -    if ((EcStatus & EC_EVENT_SCI) && !sc->ec_sci_pend) {
> +    if ((EcStatus & EC_EVENT_SCI) &&
> +       atomic_fetchadd_int(&sc->ec_sci_pend, 1) == 0) {
>         CTR0(KTR_ACPI, "ec gpe queueing query handler");
>         Status = AcpiOsExecute(OSL_GPE_HANDLER, EcGpeQueryHandler, Context);
> -       if (ACPI_SUCCESS(Status))
> -           sc->ec_sci_pend = TRUE;
> -       else
> +       if (ACPI_FAILURE(Status)) {
>             printf("EcGpeHandler: queuing GPE query handler failed\n");
> +           atomic_store_rel_int(&sc->ec_sci_pend, 0);
> +       }
>      }
>      return (ACPI_REENABLE_GPE);
>  }
> @@ -759,7 +780,8 @@ EcSpaceHandler(UINT32 Function, ACPI_PHY
>       * we call it directly here since our thread taskq is not active yet.
>       */
>      if (cold || rebooting || sc->ec_suspending) {
> -       if ((EC_GET_CSR(sc) & EC_EVENT_SCI)) {
> +       if ((EC_GET_CSR(sc) & EC_EVENT_SCI) &&
> +           atomic_fetchadd_int(&sc->ec_sci_pend, 1) == 0) {
>             CTR0(KTR_ACPI, "ec running gpe handler directly");
>             EcGpeQueryHandler(sc);
>         }
> _______________________________________________
> svn-src-head@freebsd.org mailing list
> https://lists.freebsd.org/mailman/listinfo/svn-src-head
> To unsubscribe, send any mail to "svn-src-head-unsubscribe@freebsd.org"

[-- Attachment #2 --]
procstat -k
--------------------------------------------------------------------------------
  PID    TID COMM             TDNAME           KSTACK                       
47536 100142 sysctl           -                mi_switch sleepq_switch sleepq_catch_signals sleepq_wait_sig _sleep AcpiOsAcquireMutex AcpiUtAcquireMutex AcpiExEnterInterpreter AcpiNsEvaluate AcpiUtEvaluateObject AcpiUtExecute_HID AcpiGetObjectInfo acpi_child_pnpinfo_str_method device_sysctl_handler sysctl_root userland_sysctl sys___sysctl amd64_syscall 

procstat -kk

--------------------------------------------------------------------------------
PID    TID COMM             TDNAME           KSTACK                       
47536 100142 sysctl           -                mi_switch+0x159 sleepq_switch+0x12e sleepq_catch_signals+0x2dc sleepq_wait_sig+0xf _sleep+0x319 AcpiOsAcquireMutex+0x155 AcpiUtAcquireMutex+0x3a AcpiExEnterInterpreter+0xb AcpiNsEvaluate+0x1cb AcpiUtEvaluateObject+0x4c AcpiUtExecute_HID+0x27 AcpiGetObjectInfo+0xde acpi_child_pnpinfo_str_method+0x24 device_sysctl_handler+0x11b sysctl_root+0x1d9 userland_sysctl+0x192 sys___sysctl+0x74 amd64_syscall+0x298 

pciconf
--------------------------------------------------------------------------------
hostb0@pci0:0:0:0:	class=0x060000 card=0x50001458 chip=0x191f8086 rev=0x07 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Skylake Host Bridge/DRAM Registers'
    class      = bridge
    subclass   = HOST-PCI
pcib1@pci0:0:1:0:	class=0x060400 card=0x50001458 chip=0x19018086 rev=0x07 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Skylake PCIe Controller (x16)'
    class      = bridge
    subclass   = PCI-PCI
xhci0@pci0:0:20:0:	class=0x0c0330 card=0x50071458 chip=0xa12f8086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H USB 3.0 xHCI Controller'
    class      = serial bus
    subclass   = USB
none0@pci0:0:22:0:	class=0x078000 card=0x1c3a1458 chip=0xa13a8086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H CSME HECI'
    class      = simple comms
ahci0@pci0:0:23:0:	class=0x010601 card=0xb0051458 chip=0xa1028086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H SATA controller [AHCI mode]'
    class      = mass storage
    subclass   = SATA
pcib2@pci0:0:27:0:	class=0x060400 card=0x50011458 chip=0xa1698086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib3@pci0:0:27:3:	class=0x060400 card=0x50011458 chip=0xa16a8086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib4@pci0:0:28:0:	class=0x060400 card=0x50011458 chip=0xa1128086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib5@pci0:0:28:4:	class=0x060400 card=0x50011458 chip=0xa1148086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib6@pci0:0:28:5:	class=0x060400 card=0x50011458 chip=0xa1158086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib7@pci0:0:28:6:	class=0x060400 card=0x50011458 chip=0xa1168086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib8@pci0:0:28:7:	class=0x060400 card=0x50011458 chip=0xa1178086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
pcib9@pci0:0:29:0:	class=0x060400 card=0x50011458 chip=0xa1188086 rev=0xf1 hdr=0x01
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PCI Express Root Port'
    class      = bridge
    subclass   = PCI-PCI
isab0@pci0:0:31:0:	class=0x060100 card=0x50011458 chip=0xa1448086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H LPC Controller'
    class      = bridge
    subclass   = PCI-ISA
none1@pci0:0:31:2:	class=0x058000 card=0x50011458 chip=0xa1218086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H PMC'
    class      = memory
hdac1@pci0:0:31:3:	class=0x040300 card=0xa1821458 chip=0xa1708086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H HD Audio'
    class      = multimedia
    subclass   = HDA
none2@pci0:0:31:4:	class=0x0c0500 card=0x50011458 chip=0xa1238086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Sunrise Point-H SMBus'
    class      = serial bus
    subclass   = SMBus
em0@pci0:0:31:6:	class=0x020000 card=0xe0001458 chip=0x15b88086 rev=0x31 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Ethernet Connection (2) I219-V'
    class      = network
    subclass   = ethernet
vgapci0@pci0:1:0:0:	class=0x030000 card=0xe164174b chip=0x68f91002 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Cedar [Radeon HD 5000/6000/7350/8350 Series]'
    class      = display
    subclass   = VGA
hdac0@pci0:1:0:1:	class=0x040300 card=0xaa68174b chip=0xaa681002 rev=0x00 hdr=0x00
    vendor     = 'Advanced Micro Devices, Inc. [AMD/ATI]'
    device     = 'Cedar HDMI Audio [Radeon HD 5400/6300/7300 Series]'
    class      = multimedia
    subclass   = HDA
igb0@pci0:5:0:0:	class=0x020000 card=0xe0001458 chip=0x15398086 rev=0x03 hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'I211 Gigabit Network Connection'
    class      = network
    subclass   = ethernet
none3@pci0:6:0:0:	class=0x028000 card=0x00108086 chip=0x24f38086 rev=0x3a hdr=0x00
    vendor     = 'Intel Corporation'
    device     = 'Wireless 8260'
    class      = network

dmesg
--------------------------------------------------------------------------------

[1] CPU: Intel(R) Core(TM) i7-6700 CPU @ 3.40GHz (3408.13-MHz K8-class CPU)
[1]   Origin="GenuineIntel"  Id=0x506e3  Family=0x6  Model=0x5e  Stepping=3
[1]   Features=0xbfebfbff<FPU,VME,DE,PSE,TSC,MSR,PAE,MCE,CX8,APIC,SEP,MTRR,PGE,MCA,CMOV,PAT,PSE36,CLFLUSH,DTS,ACPI,MMX,FXSR,SSE,SSE2,SS,HTT,TM,PBE>
[1]   Features2=0x7ffafbff<SSE3,PCLMULQDQ,DTES64,MON,DS_CPL,VMX,SMX,EST,TM2,SSSE3,SDBG,FMA,CX16,xTPR,PDCM,PCID,SSE4.1,SSE4.2,x2APIC,MOVBE,POPCNT,TSCDLT,AESNI,XSAVE,OSXSAVE,AVX,F16C,RDRAND>
[1]   AMD Features=0x2c100800<SYSCALL,NX,Page1GB,RDTSCP,LM>
[1]   AMD Features2=0x121<LAHF,ABM,Prefetch>
[1]   Structured Extended Features=0x29c6fbf<FSGSBASE,TSCADJ,SGX,BMI1,HLE,AVX2,SMEP,BMI2,ERMS,INVPCID,RTM,NFPUSG,MPX,RDSEED,ADX,SMAP,CLFLUSHOPT,PROCTRACE>
[1]   XSAVE Features=0xf<XSAVEOPT,XSAVEC,XINUSE,XSAVES>
[1]   VT-x: PAT,HLT,MTF,PAUSE,EPT,UG,VPID
[1]   TSC: P-state invariant, performance statistics
[1] real memory  = 17179869184 (16384 MB)
[1] avail memory = 16535982080 (15769 MB)
[1] Event timer "LAPIC" quality 600
[1] ACPI APIC Table: <ALASKA A M I >
[1] FreeBSD/SMP: Multiprocessor System Detected: 8 CPUs
[1] FreeBSD/SMP: 1 package(s) x 4 core(s) x 2 SMT threads
[1]  cpu0 (BSP): APIC ID:  0
[1]  cpu1 (AP): APIC ID:  1
[1]  cpu2 (AP): APIC ID:  2
[1]  cpu3 (AP): APIC ID:  3
[1]  cpu4 (AP): APIC ID:  4
[1]  cpu5 (AP): APIC ID:  5
[1]  cpu6 (AP): APIC ID:  6
[1]  cpu7 (AP): APIC ID:  7

...

[1] acpi0: <ALASKA A M I > on motherboard
[1] acpi0: Power Button (fixed)
[1] cpu0: <ACPI CPU> on acpi0
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release (20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release (20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] cpu1: <ACPI CPU> on acpi0
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release (20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] ACPI Error: Mutex [0x0] is not acquired, cannot release (20160527/utmutex-386)
[1] ACPI Error: Could not release AML Interpreter mutex (20160527/exutils-147)
[1] cpu2: <ACPI CPU> on acpi0
[1] cpu3: <ACPI CPU> on acpi0
[1] cpu4: <ACPI CPU> on acpi0
[1] cpu5: <ACPI CPU> on acpi0
[1] cpu6: <ACPI CPU> on acpi0
[1] cpu7: <ACPI CPU> on acpi0

kenv
--------------------------------------------------------------------------------
smbios.bios.reldate="11/11/2016"
smbios.bios.vendor="American Megatrends Inc."
smbios.bios.version="F20"
smbios.chassis.maker="Default string"
smbios.chassis.serial="Default string"
smbios.chassis.tag="Default string"
smbios.chassis.version="Default string"
smbios.memory.enabled="16777216"
smbios.planar.location="Default string"
smbios.planar.maker="Gigabyte Technology Co., Ltd."
smbios.planar.product="H170N-WIFI-CF"
smbios.planar.serial="Default string"
smbios.planar.tag="Default string"
smbios.planar.version="x.x"
smbios.socket.enabled="1"
smbios.socket.populated="1"
smbios.system.maker="Gigabyte Technology Co., Ltd."
smbios.system.product="H170N-WIFI"
smbios.system.serial="Default string"
smbios.system.uuid="XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX"
smbios.system.version="Default string"
smbios.version="3.0"

Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAPQ4ffu38KhH2WkeV8H8uwX9BDKf_x2SuF36X-3cA4%2BJZ1XQWQ>