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

arch/x86/kernel/acpi/boot.c

index 0dac4ab5b55baeac5d3f29d7e9727d1a30d844f7..21b542a6866cf74b303f099ce42f6341186e5a27 100644 (file)
@@ -1858,13 +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)