Merge tag 'x86_acpi_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git...
authorLinus Torvalds <torvalds@linux-foundation.org>
Tue, 25 Apr 2023 17:05:00 +0000 (10:05 -0700)
committerLinus Torvalds <torvalds@linux-foundation.org>
Tue, 25 Apr 2023 17:05:00 +0000 (10:05 -0700)
Pull x86 ACPI update from Borislav Petkov:

 - Improve code generation in ACPI's global lock's acquisition function

* tag 'x86_acpi_for_v6.4_rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/ACPI/boot: Improve __acpi_acquire_global_lock

1  2 
arch/x86/kernel/acpi/boot.c

index 0dac4ab5b55baeac5d3f29d7e9727d1a30d844f7,a08a4a7a03f8a8662de043b752611545d347b819..21b542a6866cf74b303f099ce42f6341186e5a27
@@@ -146,11 -146,7 +146,11 @@@ static int __init acpi_parse_madt(struc
  
                pr_debug("Local APIC address 0x%08x\n", madt->address);
        }
 -      if (madt->header.revision >= 5)
 +
 +      /* ACPI 6.3 and newer support the online capable bit. */
 +      if (acpi_gbl_FADT.header.revision > 6 ||
 +          (acpi_gbl_FADT.header.revision == 6 &&
 +           acpi_gbl_FADT.minor_revision >= 3))
                acpi_support_online_capable = true;
  
        default_acpi_madt_oem_check(madt->header.oem_id,
@@@ -197,8 -193,7 +197,8 @@@ static bool __init acpi_is_processor_us
        if (lapic_flags & ACPI_MADT_ENABLED)
                return true;
  
 -      if (acpi_support_online_capable && (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
 +      if (!acpi_support_online_capable ||
 +          (lapic_flags & ACPI_MADT_ONLINE_CAPABLE))
                return true;
  
        return false;
@@@ -1858,13 -1853,18 +1858,18 @@@ early_param("acpi_sci", setup_acpi_sci)
  
  int __acpi_acquire_global_lock(unsigned int *lock)
  {
-       unsigned int old, new;
+       unsigned int old, new, val;
  
        old = READ_ONCE(*lock);
        do {
-               new = (((old & ~0x3) + 2) + ((old >> 1) & 0x1));
+               val = (old >> 1) & 0x1;
+               new = (old & ~0x3) + 2 + val;
        } while (!try_cmpxchg(lock, &old, new));
-       return ((new & 0x3) < 3) ? -1 : 0;
+       if (val)
+               return 0;
+       return -1;
  }
  
  int __acpi_release_global_lock(unsigned int *lock)