Commit Graph

341 Commits

Author SHA1 Message Date
David Arcari f8f5e9eb64 ACPI/processor_idle: Add FFH state handling
JIRA: https://issues.redhat.com/browse/RHEL-85522

commit 541ddf31e30022b8e6f44b3a943964e8f0989d15
Author: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
Date:   Wed Feb 5 17:52:09 2025 +0200

    ACPI/processor_idle: Add FFH state handling

    Recent Intel platforms will depend on the idle driver to pass the
    correct hint for playing dead via mwait_play_dead_with_hint(). Expand
    the existing enter_dead interface with handling for FFH states and pass
    the MWAIT hint to the mwait_play_dead code.

    Suggested-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
    Signed-off-by: Patryk Wlazlyn <patryk.wlazlyn@linux.intel.com>
    Signed-off-by: Artem Bityutskiy <artem.bityutskiy@linux.intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://lore.kernel.org/all/20250205155211.329780-3-artem.bityutskiy%40linux.intel.com

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-31 17:38:11 -04:00
David Arcari 11d0c95664 cpuidle: Change :enter_dead() driver callback return type to void
JIRA: https://issues.redhat.com/browse/RHEL-85522

commit 9cf9f2e70bea4e66a2c8b8c4743489beb21258a8
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Fri Nov 15 22:00:25 2024 +0100

    cpuidle: Change :enter_dead() driver callback return type to void

    After a previous change, cpuidle_play_dead(), which is the only caller
    of idle state :enter_dead() callbacks, ignores their return values, so
    they may as well be void.

    Suggested-by: Peter Zijlstra <peterz@infradead.org>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: Gautham R. Shenoy <gautham.shenoy@amd.com>
    Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
    Link: https://patch.msgid.link/2285569.iZASKD2KPV@rjwysocki.net

Signed-off-by: David Arcari <darcari@redhat.com>
2025-03-31 15:20:53 -04:00
Mark Langsdorf 5e1ed4e65d ACPI: processor_idle: Fix invalid comparison with insertion sort for latency
JIRA: https://issues.redhat.com/browse/RHEL-54149

commit 233323f9b9f828cd7cd5145ad811c1990b692542
Author: Kuan-Wei Chiu <visitorckw@gmail.com>
Date: Tue, 02 Jul 2024 20:35:29 +0000

The acpi_cst_latency_cmp() comparison function currently used for
sorting C-state latencies does not satisfy transitivity, causing
incorrect sorting results.

Specifically, if there are two valid acpi_processor_cx elements A and B
and one invalid element C, it may occur that A < B, A = C, and B = C.
Sorting algorithms assume that if A < B and A = C, then C < B, leading
to incorrect ordering.

Given the small size of the array (<=8), we replace the library sort
function with a simple insertion sort that properly ignores invalid
elements and sorts valid ones based on latency. This change ensures
correct ordering of the C-state latencies.

Fixes: 65ea8f2c6e ("ACPI: processor idle: Fix up C-state latency if not ordered")
Reported-by: Julian Sikorski <belegdol@gmail.com>
Closes: https://lore.kernel.org/lkml/70674dc7-5586-4183-8953-8095567e73df@gmail.com
Signed-off-by: Kuan-Wei Chiu <visitorckw@gmail.com>
Tested-by: Julian Sikorski <belegdol@gmail.com>
Cc: All applicable <stable@vger.kernel.org>
Link: https://patch.msgid.link/20240701205639.117194-1-visitorckw@gmail.com
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-08-22 11:22:34 -04:00
Mark Langsdorf a540b4e2ec ACPI: processor_idle: Fix memory leak in acpi_processor_power_exit()
JIRA: https://issues.redhat.com/browse/RHEL-33200
CVE: CVE-2024-26894

commit e18afcb7b2a12b635ac10081f943fcf84ddacc51
Author: Armin Wolf <W_Armin@gmx.de>
Date:   Tue Feb 13 01:41:58 2024 +0100

After unregistering the CPU idle device, the memory associated with
it is not freed, leading to a memory leak:

unreferenced object 0xffff896282f6c000 (size 1024):
  comm "swapper/0", pid 1, jiffies 4294893170
  hex dump (first 32 bytes):
    00 00 00 00 0b 00 00 00 00 00 00 00 00 00 00 00  ................
    00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00  ................
  backtrace (crc 8836a742):
    [<ffffffff993495ed>] kmalloc_trace+0x29d/0x340
    [<ffffffff9972f3b3>] acpi_processor_power_init+0xf3/0x1c0
    [<ffffffff9972d263>] __acpi_processor_start+0xd3/0xf0
    [<ffffffff9972d2bc>] acpi_processor_start+0x2c/0x50
    [<ffffffff99805872>] really_probe+0xe2/0x480
    [<ffffffff99805c98>] __driver_probe_device+0x78/0x160
    [<ffffffff99805daf>] driver_probe_device+0x1f/0x90
    [<ffffffff9980601e>] __driver_attach+0xce/0x1c0
    [<ffffffff99803170>] bus_for_each_dev+0x70/0xc0
    [<ffffffff99804822>] bus_add_driver+0x112/0x210
    [<ffffffff99807245>] driver_register+0x55/0x100
    [<ffffffff9aee4acb>] acpi_processor_driver_init+0x3b/0xc0
    [<ffffffff990012d1>] do_one_initcall+0x41/0x300
    [<ffffffff9ae7c4b0>] kernel_init_freeable+0x320/0x470
    [<ffffffff99b231f6>] kernel_init+0x16/0x1b0
    [<ffffffff99042e6d>] ret_from_fork+0x2d/0x50

Fix this by freeing the CPU idle device after unregistering it.

Fixes: 3d339dcbb5 ("cpuidle / ACPI : move cpuidle_device field out of the acpi_processor_power structure")
Signed-off-by: Armin Wolf <W_Armin@gmx.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-06-24 10:47:02 -04:00
Mark Langsdorf f18cf00e3d ACPI: processor_idle: use raw_safe_halt() in acpi_idle_play_dead()
JIRA: https://issues.redhat.com/browse/RHEL-26871

commit 9bb69ba4c177dccaa1f5b5cbdf80b67813328348
Author: David Woodhouse <dwmw@amazon.co.uk>
Date: Mon, 20 Nov 2023 17:26:20 +0000

Xen HVM guests were observed taking triple-faults when attempting to
online a previously offlined vCPU.

Investigation showed that the fault was coming from a failing call
to lockdep_assert_irqs_disabled(), in load_current_idt() which was
too early in the CPU bringup to actually catch the exception and
report the failure cleanly.

This was a false positive, caused by acpi_idle_play_dead() setting
the per-cpu hardirqs_enabled flag by calling safe_halt(). Switch it
to use raw_safe_halt() instead, which doesn't do so.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Acked-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Cc: 6.6+ <stable@vger.kernel.org> # 6.6+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-04-05 17:00:48 -04:00
Mark Langsdorf a95c204c45 cpuidle, ACPI: Evaluate LPI arch_flags for broadcast timer
JIRA: https://issues.redhat.com/browse/RHEL-26871
Conflicts:
	arch/arm64/include/asm/acpi.h - minor context
differences

commit 4785aa8028536c2be656d22c74ec1995b97056f3
Author: Oza Pawandeep <quic_poza@quicinc.com>
Date: Wed, 04 Oct 2023 16:31:27 +0000

Arm® Functional Fixed Hardware Specification defines LPI states,
which provide an architectural context loss flags field that can
be used to describe the context that might be lost when an LPI
state is entered.

- Core context Lost
        - General purpose registers.
        - Floating point and SIMD registers.
        - System registers, include the System register based
        - generic timer for the core.
        - Debug register in the core power domain.
        - PMU registers in the core power domain.
        - Trace register in the core power domain.
- Trace context loss
- GICR
- GICD

Qualcomm's custom CPUs preserves the architectural state,
including keeping the power domain for local timers active.
when core is power gated, the local timers are sufficient to
wake the core up without needing broadcast timer.

The patch fixes the evaluation of cpuidle arch_flags, and moves only to
broadcast timer if core context lost is defined in ACPI LPI.

Fixes: a36a7fecfe ("ACPI / processor_idle: Add support for Low Power Idle(LPI) states")
Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Oza Pawandeep <quic_poza@quicinc.com>
Link: https://lore.kernel.org/r/20231003173333.2865323-1-quic_poza@quicinc.com
Signed-off-by: Will Deacon <will@kernel.org>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-04-05 17:00:45 -04:00
Prarit Bhargava bb6ffe0c15 cpuidle, ACPI: Make noinstr clean
JIRA: https://issues.redhat.com/browse/RHEL-25415

commit 6a123d6ae6ea930b9bb3c595ceac2b2f93039f67
Author: Peter Zijlstra <peterz@infradead.org>
Date:   Thu Jan 12 20:43:46 2023 +0100

    cpuidle, ACPI: Make noinstr clean

    objtool found cases where ACPI methods called out into instrumentation code:

      vmlinux.o: warning: objtool: io_idle+0xc: call to __inb.isra.0() leaves .noinstr.text section
      vmlinux.o: warning: objtool: acpi_idle_enter+0xfe: call to num_online_cpus() leaves .noinstr.text section
      vmlinux.o: warning: objtool: acpi_idle_enter+0x115: call to acpi_idle_fallback_to_c1.isra.0() leaves .noinstr.text section

    Fix this by: marking the IO in/out, acpi_idle_fallback_to_c1() and
    num_online_cpus() methods as __always_inline.

    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Signed-off-by: Ingo Molnar <mingo@kernel.org>
    Tested-by: Tony Lindgren <tony@atomide.com>
    Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
    Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Acked-by: Frederic Weisbecker <frederic@kernel.org>
    Link: https://lore.kernel.org/r/20230112195541.294846301@infradead.org

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
2024-03-20 09:42:54 -04:00
David Arcari c918a6603c x86/smpboot: Remove the CPU0 hotplug kludge
JIRA: https://issues.redhat.com/browse/RHEL-15512

commit 5475abbde77f6d78a052a81e5d5de70e59f7181e
Author: Thomas Gleixner <tglx@linutronix.de>
Date:   Fri May 12 23:07:06 2023 +0200

    x86/smpboot: Remove the CPU0 hotplug kludge

    This was introduced with commit e1c467e690 ("x86, hotplug: Wake up CPU0
    via NMI instead of INIT, SIPI, SIPI") to eventually support physical
    hotplug of CPU0:

     "We'll change this code in the future to wake up hard offlined CPU0 if
      real platform and request are available."

    11 years later this has not happened and physical hotplug is not officially
    supported. Remove the cruft.

    Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
    Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
    Tested-by: Michael Kelley <mikelley@microsoft.com>
    Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
    Tested-by: Helge Deller <deller@gmx.de> # parisc
    Tested-by: Guilherme G. Piccoli <gpiccoli@igalia.com> # Steam Deck
    Link: https://lore.kernel.org/r/20230512205255.768845190@linutronix.de

Signed-off-by: David Arcari <darcari@redhat.com>
2023-12-05 11:56:51 -05:00
Jan Stancek 40b987719b Merge: update drivers/cpuidle to match v6.3
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-9/-/merge_requests/2651

Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2181277

A few qcom and RISC-V commits had to be dropped as centos-stream-9 did not have support for the underlying drivers.

Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>

Approved-by: Eric Chanudet <echanude@redhat.com>
Approved-by: Adrien Thierry <athierry@redhat.com>
Approved-by: Prarit Bhargava <prarit@redhat.com>
Approved-by: Phil Auld <pauld@redhat.com>
Approved-by: David Arcari <darcari@redhat.com>

Signed-off-by: Jan Stancek <jstancek@redhat.com>
2023-07-26 14:50:12 +02:00
David Arcari 097854ade1 ACPI: processor idle: avoid call to raw_local_irq_disable() from acpi_safe_halt()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2217308
Upstream Status: RHEL-only

Although it works upstream, for some reason calling raw_local_irq_disable()
results in the following error during cpu idle:

WARNING: CPU: 0 PID: 0 at kernel/sched/clock.c:397 sched_clock_tick+0xfa/0x150

For now call local_irq_disable() on RHEL until this issue is resolved.

Signed-off-by: David Arcari <darcari@redhat.com>
2023-06-27 15:14:33 -04:00
Mark Langsdorf c1855ad3c5 cpuidle: Fix ct_idle_*() usage
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2181277
Conflicts:
	arch/arm/mach-imx/cpuidle-imx6sx.c,
arch/arm/mach-omap2/cpuidle34xx.c, ch/arm/mach-omap2/cpuidle44xx.c,
drivers/cpuidle/cpuidle-riscv-sbi.c - none of these drivers are
meaningfully supported in centos-stream-9, so these parts of the
commit were dropped.

commit a01353cf1896ea5b8a7bbc5e2b2d38feed8b7aaa
Author: Peter Zijlstra <peterz@infradead.org>
Date: Fri, 13 Jan 2023 11:48:15 +0000

The whole disable-RCU, enable-IRQS dance is very intricate since
changing IRQ state is traced, which depends on RCU.

Add two helpers for the cpuidle case that mirror the entry code:

  ct_cpuidle_enter()
  ct_cpuidle_exit()

And fix all the cases where the enter/exit dance was buggy.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Tony Lindgren <tony@atomide.com>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20230112195540.130014793@infradead.org
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-06-09 13:18:10 -04:00
Mark Langsdorf 7a634af53f cpuidle, dt: Push RCU-idle into driver
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2181277

commit 0c5ffc3d7b15978c6b184938cd6b8af06e436424
Author: Peter Zijlstra <peterz@infradead.org>
Date: Fri, 13 Jan 2023 11:48:00 +0000

Doing RCU-idle outside the driver, only to then temporarily enable it
again before going idle is suboptimal.

Notably: this converts all dt_init_idle_driver() and
__CPU_PM_CPU_IDLE_ENTER() users for they are inextrably intertwined.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Tony Lindgren <tony@atomide.com>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20230112195540.068981667@infradead.org
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-06-09 11:27:26 -04:00
Mark Langsdorf 7405b1ac79 acpi_idle: Remove tracing
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554

commit 8ce78470bf2dd1d08107736e813fa62e09aa4647
Author: Peter Zijlstra <peterz@infradead.org>
Date: Thu, 12 Jan 2023 20:43:29 +0100

All the idle routines are called with RCU disabled, as such there must
not be any tracing inside.

While there; clean-up the io-port idle thing.

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Tested-by: Tony Lindgren <tony@atomide.com>
Tested-by: Ulf Hansson <ulf.hansson@linaro.org>
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Acked-by: Frederic Weisbecker <frederic@kernel.org>
Link: https://lore.kernel.org/r/20230112195540.251666856@infradead.org
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-05-18 15:46:34 -04:00
Mark Langsdorf f8ebe56d1a ACPI: processor: idle: Drop unnecessary (void *) conversion
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554

commit fbf757e55afbd8b4d36f4808a6ae9107afeb79f3
Author: Zhou jie <zhoujie@nfschina.com>
Date: Fri, 23 Dec 2022 17:02:15 +0800

The (void *) type pointer does not need to be cast, so don't do
that in lapic_timer_check_state().

Signed-off-by: Zhou jie <zhoujie@nfschina.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-05-18 15:46:34 -04:00
Mark Langsdorf 8e62aa4b53 ACPI: processor: idle: Drop unnecessary statements and parens
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554

commit b697b812d455b7917a0a31db91ae8a0863b35934
Author: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Date: Mon, 5 Dec 2022 19:58:25 +0100

Drop a redundant "else", a "return" statement at the end of a void
function and redundant parentheses around an unsigent int variable
name from the ACPI processor idle driver.

No expected functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-05-18 15:46:33 -04:00
Mark Langsdorf 188678c1b7 ACPI: processor: idle: Check acpi_fetch_acpi_dev() return value
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554

commit 2437513a814b3e93bd02879740a8a06e52e2cf7d
Author: Li Zhong <floridsleeves@gmail.com>
Date: Fri, 2 Sep 2022 00:37:30 -0700

The return value of acpi_fetch_acpi_dev() could be NULL, which would
cause a NULL pointer dereference to occur in acpi_device_hid().

Signed-off-by: Li Zhong <floridsleeves@gmail.com>
[ rjw: Subject and changelog edits, added empty line after if () ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-05-18 15:46:31 -04:00
Mark Langsdorf 6978cfdd04 ACPI: move from strlcpy() with unused retval to strscpy()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2176554

commit b75d2cd06b33956b7ec35c6316e717c25a196ee5
Author: Wolfram Sang <wsa+renesas@sang-engineering.com>
Date: Thu, 18 Aug 2022 22:59:55 +0200

Follow the advice of the below link and prefer 'strscpy' in this
subsystem. Conversion is 1:1 because the return value is not used.
Generated by a coccinelle script.

Link: https://lore.kernel.org/r/CAHk-=wgfRnXz0W3D37d01q3JFkr_i_uTL=V6A6G1oUZcprmknw@mail.gmail.com/
Signed-off-by: Wolfram Sang <wsa+renesas@sang-engineering.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2023-05-11 15:46:59 -04:00
Waiman Long 034dc8d70a context_tracking: Take idle eqs entrypoints over RCU
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2169516

commit e67198cc05b8ecbb7b8e2d8ef9fb5c8d26821873
Author: Frederic Weisbecker <frederic@kernel.org>
Date:   Wed, 8 Jun 2022 16:40:25 +0200

    context_tracking: Take idle eqs entrypoints over RCU

    The RCU dynticks counter is going to be merged into the context tracking
    subsystem. Start with moving the idle extended quiescent states
    entrypoints to context tracking. For now those are dumb redirections to
    existing RCU calls.

    [ paulmck: Apply kernel test robot feedback. ]

    Signed-off-by: Frederic Weisbecker <frederic@kernel.org>
    Cc: Peter Zijlstra <peterz@infradead.org>
    Cc: Thomas Gleixner <tglx@linutronix.de>
    Cc: Neeraj Upadhyay <quic_neeraju@quicinc.com>
    Cc: Uladzislau Rezki <uladzislau.rezki@sony.com>
    Cc: Joel Fernandes <joel@joelfernandes.org>
    Cc: Boqun Feng <boqun.feng@gmail.com>
    Cc: Nicolas Saenz Julienne <nsaenz@kernel.org>
    Cc: Marcelo Tosatti <mtosatti@redhat.com>
    Cc: Xiongfeng Wang <wangxiongfeng2@huawei.com>
    Cc: Yu Liao <liaoyu15@huawei.com>
    Cc: Phil Auld <pauld@redhat.com>
    Cc: Paul Gortmaker<paul.gortmaker@windriver.com>
    Cc: Alex Belits <abelits@marvell.com>
    Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
    Reviewed-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>
    Tested-by: Nicolas Saenz Julienne <nsaenzju@redhat.com>

Signed-off-by: Waiman Long <longman@redhat.com>
2023-03-30 08:36:16 -04:00
Mark Langsdorf 6bacae9311 ACPI: processor/idle: Annotate more functions to live in cpuidle section
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122317

commit 409dfdcaffb266acfc1f33529a26b1443c9332d4
Author: "Guilherme G. Piccoli" <gpiccoli@igalia.com>
Date: Tue, 7 Jun 2022 19:24:58 -0300

Commit 6727ad9e20 ("nmi_backtrace: generate one-line reports for idle cpus")
introduced a new text section called cpuidle; with that, we have a mechanism
to add idling functions in such section and skip them from nmi_backtrace
output, since they're useless and potentially flooding for such report.

Happens that inlining might cause some real idle functions to end-up
outside of such section; this is currently the case of ACPI processor_idle
driver; the functions acpi_idle_enter_* do inline acpi_idle_do_entry(),
hence they stay out of the cpuidle section.
Fix that by marking such functions to also live in the cpuidle section.

Fixes: 6727ad9e20 ("nmi_backtrace: generate one-line reports for idle cpus")
Signed-off-by: Guilherme G. Piccoli <gpiccoli@igalia.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-11-01 11:03:57 -04:00
Mark Langsdorf 1d535c1370 ACPI: processor: idle: Expose max_cstate/nocst/bm_check_disable read-only in sysfs
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122317

commit 27263b3428f5b2b73be97adf3d679125b6065271
Author: Yajun Deng <yajun.deng@linux.dev>
Date: Thu, 28 Apr 2022 17:54:13 +0800

This will allow super users to verify the module parameters in question
when changed via kernel command line.

The parameters "nocst/bm_check_disable" are only used for enable/disable,
so change them from integer to bool.

Signed-off-by: Yajun Deng <yajun.deng@linux.dev>
[ rjw: Changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-11-01 11:03:53 -04:00
Mark Langsdorf 2aabb1f662 ACPI: Add perf low power callback
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2122317

commit 2a606a18cd672a16343d146a126721b34cc6adbd
Author: Stephane Eranian <eranian@google.com>
Date: Tue, 22 Mar 2022 15:15:12 -0700

Add an optional callback needed by some PMU features, e.g., AMD
BRS, to give a chance to the perf_events code to change its state before
a CPU goes to low power and after it comes back.

The callback is void when the PERF_NEEDS_LOPWR_CB flag is not set.
This flag must be set in arch specific perf_event.h header whenever needed.
When not set, there is no impact on the ACPI code.

Signed-off-by: Stephane Eranian <eranian@google.com>
[peterz: build fix]
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20220322221517.2510440-9-eranian@google.com
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-11-01 11:01:27 -04:00
Wei Huang b4f5c2c826 ACPI: processor idle: Practically limit "Dummy wait" workaround to old Intel systems
Bugzilla: https://bugzilla.redhat.com/2130652
Conflicts: None

commit e400ad8b7e6a1b9102123c6240289a811501f7d9
Author: Dave Hansen <dave.hansen@intel.com>
Date:   Thu Sep 22 11:47:45 2022 -0700

    ACPI: processor idle: Practically limit "Dummy wait" workaround to old Intel systems

    Old, circa 2002 chipsets have a bug: they don't go idle when they are
    supposed to.  So, a workaround was added to slow the CPU down and
    ensure that the CPU waits a bit for the chipset to actually go idle.
    This workaround is ancient and has been in place in some form since
    the original kernel ACPI implementation.

    But, this workaround is very painful on modern systems.  The "inl()"
    can take thousands of cycles (see Link: for some more detailed
    numbers and some fun kernel archaeology).

    First and foremost, modern systems should not be using this code.
    Typical Intel systems have not used it in over a decade because it is
    horribly inferior to MWAIT-based idle.

    Despite this, people do seem to be tripping over this workaround on
    AMD system today.

    Limit the "dummy wait" workaround to Intel systems.  Keep Modern AMD
    systems from tripping over the workaround.  Remotely modern Intel
    systems use intel_idle instead of this code and will, in practice,
    remain unaffected by the dummy wait.

    Reported-by: K Prateek Nayak <kprateek.nayak@amd.com>
    Suggested-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Signed-off-by: Dave Hansen <dave.hansen@linux.intel.com>
    Reviewed-by: Mario Limonciello <mario.limonciello@amd.com>
    Tested-by: K Prateek Nayak <kprateek.nayak@amd.com>
    Link: https://lore.kernel.org/all/20220921063638.2489-1-kprateek.nayak@amd.com/
    Link: https://lkml.kernel.org/r/20220922184745.3252932-1-dave.hansen@intel.com

Signed-off-by: Wei Huang <wehuang@redhat.com>
2022-09-30 12:05:30 -05:00
Mark Langsdorf d71ad75638 ACPI: processor idle: Check for architectural support for LPI
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067297

commit eb087f305919ee8169ad65665610313e74260463
Author: Mario Limonciello <mario.limonciello@amd.com>
Date: Fri, 25 Feb 2022 13:06:46 -0600

When `osc_pc_lpi_support_confirmed` is set through `_OSC` and `_LPI` is
populated then the cpuidle driver assumes that LPI is fully functional.

However currently the kernel only provides architectural support for LPI
on ARM.  This leads to high power consumption on X86 platforms that
otherwise try to enable LPI.

So probe whether or not LPI support is implemented before enabling LPI in
the kernel.  This is done by overloading `acpi_processor_ffh_lpi_probe` to
check whether it returns `-EOPNOTSUPP`. It also means that all future
implementations of `acpi_processor_ffh_lpi_probe` will need to follow
these semantics as well.

Reviewed-by: Sudeep Holla <sudeep.holla@arm.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-08-01 10:50:38 -04:00
Mark Langsdorf acfb3f0ca8 ACPI: Use acpi_fetch_acpi_dev() instead of acpi_bus_get_device()
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067294

commit 99ece713773bfa17fdb4ee2a1fb3b7bee82e4b1a
Author: "Rafael J. Wysocki" <rafael.j.wysocki@intel.com>
Date: Fri, 3 Dec 2021 17:37:10 +0100

Modify the ACPI code to use acpi_fetch_acpi_dev() instead of
acpi_bus_get_device() where applicable.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Reviewed-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-07 10:50:14 -04:00
Mark Langsdorf 7c9ccb0950 ACPI: processor idle: Use swap() instead of open coding it
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=2067294

commit 0e6078c3c6737df7d0bd0c890fbadf24a27fffbb
Author: Guo Zhengkui <guozhengkui@vivo.com>
Date: Tue, 9 Nov 2021 15:50:51 +0800

Address the following coccicheck warning:

./drivers/net/ethernet/mellanox/mlx5/core/en/tc_ct.c:914:40-41:
WARNING opportunity for swap().

by using swap() for the swapping of variable values and drop
the tmp variable that is not needed any more.

Signed-off-by: Guo Zhengkui <guozhengkui@vivo.com>
[ rjw: Subject and changelog rewrite ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-06-07 10:47:23 -04:00
Mark Langsdorf d649ed3085 ACPI: processor: idle: Avoid falling back to C3 type C-states
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1998271

commit fc45e55ebc58dbf622cb89ddbf797589c7a5510b
Author: Ville Syrjl <ville.syrjala@linux.intel.com>
Date:   Thu Apr 21 16:36:34 2022 +0300

The "safe state" index is used by acpi_idle_enter_bm() to avoid
entering a C-state that may require bus mastering to be disabled
on entry in the cases when this is not going to happen.  For this
reason, it should not be set to point to C3 type of C-states, because
they may require bus mastering to be disabled on entry in principle.

This was broken by commit d6b88ce2eb9d ("ACPI: processor idle: Allow
playing dead in C3 state") which inadvertently allowed the "safe
state" index to point to C3 type of C-states.

This results in a machine that won't boot past the point when it first
enters C3. Restore the correct behaviour (either demote to C1/C2, or
use C3 but also set ARB_DIS=1).

I hit this on a Fujitsu Siemens Lifebook S6010 (P3) machine.

Fixes: d6b88ce2eb9d ("ACPI: processor idle: Allow playing dead in C3 state")
Cc: 5.16+ <stable@vger.kernel.org> # 5.16+
Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
Tested-by: Woody Suwalski <wsuwalski@gmail.com>
[ rjw: Subject and changelog adjustments ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-05-05 14:57:10 -04:00
Mark Langsdorf b0eaae9cc5 ACPI: processor idle: Allow playing dead in C3 state
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1998271

commit d6b88ce2eb9d2698eb24451eb92c0a1649b17bb1
Author: Richard Gong <richard.gong@amd.com>
Date: Wed, 22 Sep 2021 08:31:16 -0500

When some cores are disabled on AMD platforms, the system will no longer
be able to enter suspend-to-idle s0ix.

Update to allow playing dead in C3 state so that the CPUs can enter the
deepest state on AMD platforms.

BugLink: https://gitlab.freedesktop.org/drm/amd/-/issues/1708
Suggested-by: Mario Limonciello <mario.limonciello@amd.com>
Signed-off-by: Richard Gong <richard.gong@amd.com>
[ rjw: Fixed coding style ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2022-05-05 14:07:03 -04:00
Prarit Bhargava a8b0f3dd31 ACPI: processor: Replace deprecated CPU-hotplug functions
Bugzilla: http://bugzilla.redhat.com/2023079

commit 95ac706744de78a93a7ec98d603c35fb21de8400
Author: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Date:   Tue Aug 3 16:16:12 2021 +0200

    ACPI: processor: Replace deprecated CPU-hotplug functions

    The functions cpu_hotplug_begin, cpu_hotplug_done, get_online_cpus() and
    put_online_cpus() have been deprecated during the CPU hotplug rework. They map
    directly to cpus_write_lock(), cpus_write_unlock, cpus_read_lock() and
    cpus_read_unlock().

    Replace deprecated CPU-hotplug functions with the official version.
    The behavior remains unchanged.

    Signed-off-by: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Signed-off-by: Prarit Bhargava <prarit@redhat.com>
2021-12-09 09:04:08 -05:00
Mario Limonciello 65ea8f2c6e ACPI: processor idle: Fix up C-state latency if not ordered
Generally, the C-state latency is provided by the _CST method or
FADT, but some OEM platforms using AMD Picasso, Renoir, Van Gogh,
and Cezanne set the C2 latency greater than C3's which causes the
C2 state to be skipped.

That will block the core entering PC6, which prevents S0ix working
properly on Linux systems.

In other operating systems, the latency values are not validated and
this does not cause problems by skipping states.

To avoid this issue on Linux, detect when latencies are not an
arithmetic progression and sort them.

Link: 026d186e45
Link: https://gitlab.freedesktop.org/drm/amd/-/issues/1230#note_712174
Suggested-by: Prike Liang <Prike.Liang@amd.com>
Suggested-by: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
[ rjw: Subject and changelog edits ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-05-17 17:05:30 +02:00
Rafael J. Wysocki 25d9576326 Merge branches 'acpi-pci' and 'acpi-processor'
* acpi-pci:
  ACPI: PCI: Replace direct printk() invocations in pci_link.c
  ACPI: PCI: Drop ACPI_PCI_COMPONENT that is not used any more
  ACPI: PCI: Replace ACPI_DEBUG_PRINT() and ACPI_EXCEPTION()
  ACPI: PCI: IRQ: Consolidate printing diagnostic messages

* acpi-processor:
  ACPI: processor: perflib: Eliminate redundant status check
  ACPI: processor: Get rid of ACPICA message printing
  ACPI: processor: idle: Drop extra prefix from pr_notice()
  ACPI: processor: Remove initialization of static variable
2021-04-26 17:03:05 +02:00
Vitaly Kuznetsov fa26d0c778 ACPI: processor: Fix build when CONFIG_ACPI_PROCESSOR=m
Commit 8cdddd182b ("ACPI: processor: Fix CPU0 wakeup in
acpi_idle_play_dead()") tried to fix CPU0 hotplug breakage by copying
wakeup_cpu0() + start_cpu0() logic from hlt_play_dead()//mwait_play_dead()
into acpi_idle_play_dead(). The problem is that these functions are not
exported to modules so when CONFIG_ACPI_PROCESSOR=m build fails.

The issue could've been fixed by exporting both wakeup_cpu0()/start_cpu0()
(the later from assembly) but it seems putting the whole pattern into a
new function and exporting it instead is better.

Reported-by: kernel test robot <lkp@intel.com>
Fixes: 8cdddd182b ("CPI: processor: Fix CPU0 wakeup in acpi_idle_play_dead()")
Cc: <stable@vger.kernel.org> # 5.10+
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-04-07 19:02:43 +02:00
Rafael J. Wysocki 1c29f6a0f0 Merge back 'acpi-processor' material for v5.13. 2021-04-06 15:00:13 +02:00
Vitaly Kuznetsov 8cdddd182b ACPI: processor: Fix CPU0 wakeup in acpi_idle_play_dead()
Commit 496121c021 ("ACPI: processor: idle: Allow probing on platforms
with one ACPI C-state") broke CPU0 hotplug on certain systems, e.g.
I'm observing the following on AWS Nitro (e.g r5b.xlarge but other
instance types are affected as well):

 # echo 0 > /sys/devices/system/cpu/cpu0/online
 # echo 1 > /sys/devices/system/cpu/cpu0/online
 <10 seconds delay>
 -bash: echo: write error: Input/output error

In fact, the above mentioned commit only revealed the problem and did
not introduce it. On x86, to wakeup CPU an NMI is being used and
hlt_play_dead()/mwait_play_dead() loops are prepared to handle it:

	/*
	 * If NMI wants to wake up CPU0, start CPU0.
	 */
	if (wakeup_cpu0())
		start_cpu0();

cpuidle_play_dead() -> acpi_idle_play_dead() (which is now being called on
systems where it wasn't called before the above mentioned commit) serves
the same purpose but it doesn't have a path for CPU0. What happens now on
wakeup is:
 - NMI is sent to CPU0
 - wakeup_cpu0_nmi() works as expected
 - we get back to while (1) loop in acpi_idle_play_dead()
 - safe_halt() puts CPU0 to sleep again.

The straightforward/minimal fix is add the special handling for CPU0 on x86
and that's what the patch is doing.

Fixes: 496121c021 ("ACPI: processor: idle: Allow probing on platforms with one ACPI C-state")
Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
Cc: 5.10+ <stable@vger.kernel.org> # 5.10+
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2021-04-01 13:37:55 +02:00
Rafael J. Wysocki 52af99c3f5 ACPI: processor: Get rid of ACPICA message printing
The ACPI_DEBUG_PRINT() and ACPI_EXCEPTION() macros are used for
message printing in the ACPICA code and they should not be used
elsewhere.  Special configuration (either kernel command line or
sysfs-based) is needed to see the messages printed by them and
the format of those messages is also special and convoluted.

For this reason, replace all of the ACPI_DEBUG_PRINT() and
ACPI_EXCEPTION() instances in the ACPI processor driver with
corresponding dev_*(), acpi_handle_*() and pr_*() calls depending
on the context in which they appear.

Also drop the ACPI_PROCESSOR_COMPONENT definition that is not going
to be necessary any more.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
2021-03-08 16:51:19 +01:00
Rafael J. Wysocki 54e0519207 ACPI: processor: idle: Drop extra prefix from pr_notice()
Drop "ACPI: " from the pr_noitice() instance in
acpi_processor_cstate_first_run_checks(), because pr_fmt() causes
that prefix to be added to the message already.

Reported-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Hanjun Guo <guohanjun@huawei.com>
2021-03-08 16:51:19 +01:00
Hanjun Guo eb37ba316f ACPI: processor: Remove the duplicated ACPI_PROCESSOR_CLASS macro
The ACPI_PROCESSOR_CLASS macro is defined in <acpi/processor.h>,
and ACPI drivers for processor already included <acpi/processor.h>,
so we can remove those duplicated ACPI_PROCESSOR_CLASS macros.

Signed-off-by: Hanjun Guo <guohanjun@huawei.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-11-17 18:12:34 +01:00
Rafael J. Wysocki 955921289d ACPI: processor: Fix build for ARCH_APICTIMER_STOPS_ON_C3 unset
Fix the lapic_timer_needs_broadcast() stub for
ARCH_APICTIMER_STOPS_ON_C3 unset to actually return
a value.

Fixes: aa6b43d57f ("ACPI: processor: Use CPUIDLE_FLAG_TIMER_STOP")
Reported-by: Guenter Roeck <linux@roeck-us.net>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-09-23 13:50:12 +02:00
Peter Zijlstra 1fecfdbb7a ACPI: processor: Take over RCU-idle for C3-BM idle
The C3 BusMaster idle code takes lock in a number of places, some deep
inside the ACPI code. Instead of wrapping it all in RCU_NONIDLE, have
the driver take over RCU-idle duty and avoid flipping RCU state back
and forth a lot.

( by marking 'C3 && bm_check' as RCU_IDLE, we _must_ call enter_bm() for
  that combination, otherwise we'll loose RCU-idle, this requires
  shuffling some code around )

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-09-16 19:36:26 +02:00
Peter Zijlstra a889a23a98 ACPI: processor: Use CPUIDLE_FLAG_TLB_FLUSHED
Make acpi_processor_idle() use the generic TLB flushing code.
This again removes RCU usage after rcu_idle_enter().

(XXX make every C3 invalidate TLBs, not just C3-BM)

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-09-16 19:36:25 +02:00
Peter Zijlstra aa6b43d57f ACPI: processor: Use CPUIDLE_FLAG_TIMER_STOP
Make acpi_processor_idle use the common broadcast code, there's no
reason not to. This also removes some RCU usage after
rcu_idle_enter().

Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Reported-by: Borislav Petkov <bp@suse.de>
Tested-by: Borislav Petkov <bp@suse.de>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-09-16 19:36:25 +02:00
Linus Torvalds 2baa85d692 ACPI updates for 5.9-rc1
- Eliminate significant AML processing overhead related to using
    operation regions in system memory by reworking the management
    of memory mappings in the ACPI code to defer unmap operations
    (to do them outside of the ACPICA locks, among other things) and
    making the memory operation reagion handler avoid releasing memory
    mappings created by it too early (Rafael Wysocki).
 
  - Update the ACPICA code in the kernel to upstream revision
    20200717:
 
    * Prevent operation region reference counts from overflowing in
      some cases (Erik Kaneda).
 
    * Replace one-element array with flexible-array (Gustavo A. R.
      Silva).
 
  - Fix ACPI PCI hotplug reference counting (Rafael Wysocki).
 
  - Drop last bits of the ACPI procfs interface (Thomas Renninger).
 
  - Drop some redundant checks from the code parsing ACPI tables
    related to NUMA (Hanjun Guo).
 
  - Avoid redundant object evaluation in the ACPI device properties
    handling code (Heikki Krogerus).
 
  - Avoid unecessary memory overhead related to storing the signatures
    of the ACPI tables recognized by the kernel (Ard Biesheuvel).
 
  - Add missing newline characters when printing module parameter
    values in some places (Xiongfeng Wang).
 
  - Update the link to the ACPI specifications in some places (Tiezhu
    Yang).
 
  - Use the fallthrough pseudo-keyword in the ACPI code (Gustavo A. R.
    Silva).
 
  - Drop redundant variable initialization from the APEI code (Colin
    Ian King).
 
  - Drop uninitialized_var() from the ACPI PAD driver (Jason Yan).
 
  - Replace HTTP links with HTTPS ones in the ACPI code (Alexander A.
    Klimov).
 -----BEGIN PGP SIGNATURE-----
 
 iQJGBAABCAAwFiEE4fcc61cGeeHD/fCwgsRv/nhiVHEFAl8oO8gSHHJqd0Byand5
 c29ja2kubmV0AAoJEILEb/54YlRx2nUP/iSRAW0DK4PYDNLDV1Q+y5RrQw44iMDf
 yfLQu3agardM1KGtPuYw5zmU0UoEYtW8s2r027bxw9Hvn0IzBh5TiDvcVjMEnbVC
 +6m/fWg3EStfZ9w2dxDzXDMIk/oiEZsjtWSRaDTfAIH2jc/xVcSXDojlMgBPQDu5
 hIITjMbGGx783o4PNCYbIZy1ReJgd8MNQ+Xp3MCpTgbFgHMHKBOJ6B/nS8aTfilO
 eE5JvzhXED7qITaXYWxI9OZpRTPTNQ3eaEPbWvnw4KJ5boMfyREMGdTBipXO+kSA
 SwKhFysYEUAZM7Ffq0eTnWSCU7VWogAsTauIgs4+d9z8VrGhWi5+b6N/E/uwTKtj
 HF98xtk+Loe8V24LwN0snvv51O7P5nAH47QxwIBvQssfR8ZSgdwHtUQcckybAJhx
 LLmPtJrM8ZAefc9H4o0eVqumjoh1amGKC9dTY0g1j0UIE0y3ZIFHTvDNvhpTzgBk
 5uUHHEiolGNWHVrs1LIMOEejqx62m+EjVc9b8XUdJqHoboTccMM73DRk/00meP/7
 br/VfMI0aTjPLssvSC/ZSlTZt+ddrBm+cXw9eqruDQwdQaqxpJu+D3odjdaYSjpg
 luiYQrQdoDmIDh4UNuJbvG/Hub3CLzvJSqGWLExNbX7nWXxH4HIx/8PcNtVkKZRV
 qBXotIc+i4VD
 =Nn2Q
 -----END PGP SIGNATURE-----

Merge tag 'acpi-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm

Pull ACPI updates from Rafael Wysocki:
 "These eliminate significant AML processing overhead related to using
  operation regions in system memory, update the ACPICA code in the
  kernel to upstream revision 20200717 (including a fix to prevent
  operation region reference counts from overflowing in some cases),
  remove the last bits of the (long deprecated) ACPI procfs interface
  and do some assorted cleanups.

  Specifics:

   - Eliminate significant AML processing overhead related to using
     operation regions in system memory by reworking the management of
     memory mappings in the ACPI code to defer unmap operations (to do
     them outside of the ACPICA locks, among other things) and making
     the memory operation reagion handler avoid releasing memory
     mappings created by it too early (Rafael Wysocki).

   - Update the ACPICA code in the kernel to upstream revision 20200717:

       * Prevent operation region reference counts from overflowing in
         some cases (Erik Kaneda).

       * Replace one-element array with flexible-array (Gustavo A. R.
         Silva).

   - Fix ACPI PCI hotplug reference counting (Rafael Wysocki).

   - Drop last bits of the ACPI procfs interface (Thomas Renninger).

   - Drop some redundant checks from the code parsing ACPI tables
     related to NUMA (Hanjun Guo).

   - Avoid redundant object evaluation in the ACPI device properties
     handling code (Heikki Krogerus).

   - Avoid unecessary memory overhead related to storing the signatures
     of the ACPI tables recognized by the kernel (Ard Biesheuvel).

   - Add missing newline characters when printing module parameter
     values in some places (Xiongfeng Wang).

   - Update the link to the ACPI specifications in some places (Tiezhu
     Yang).

   - Use the fallthrough pseudo-keyword in the ACPI code (Gustavo A. R.
     Silva).

   - Drop redundant variable initialization from the APEI code (Colin
     Ian King).

   - Drop uninitialized_var() from the ACPI PAD driver (Jason Yan).

   - Replace HTTP links with HTTPS ones in the ACPI code (Alexander A.
     Klimov)"

* tag 'acpi-5.9-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rafael/linux-pm: (22 commits)
  ACPI: APEI: remove redundant assignment to variable rc
  ACPI: NUMA: Remove the useless 'node >= MAX_NUMNODES' check
  ACPI: NUMA: Remove the useless sub table pointer check
  ACPI: tables: Remove the duplicated checks for acpi_parse_entries_array()
  ACPICA: Update version to 20200717
  ACPICA: Do not increment operation_region reference counts for field units
  ACPICA: Replace one-element array with flexible-array
  ACPI: Replace HTTP links with HTTPS ones
  ACPI: Use valid link to the ACPI specification
  ACPI: OSL: Clean up the removal of unused memory mappings
  ACPI: OSL: Use deferred unmapping in acpi_os_unmap_iomem()
  ACPI: OSL: Use deferred unmapping in acpi_os_unmap_generic_address()
  ACPICA: Preserve memory opregion mappings
  ACPI: OSL: Implement deferred unmapping of ACPI memory
  ACPI: Use fallthrough pseudo-keyword
  PCI: hotplug: ACPI: Fix context refcounting in acpiphp_grab_context()
  ACPI: tables: avoid relocations for table signature array
  ACPI: PAD: Eliminate usage of uninitialized_var() macro
  ACPI: sysfs: add newlines when printing module parameters
  ACPI: EC: add newline when printing 'ec_event_clearing' module parameter
  ...
2020-08-03 20:37:22 -07:00
Neal Liu 0a398945d6 cpuidle: ACPI: fix 'return' with no value build warning
Add return value to fix return-type build warning introduced by
commit efe9711214 ("cpuidle: change enter_s2idle() prototype").

Fixes: efe9711214 ("cpuidle: change enter_s2idle() prototype")
Signed-off-by: Neal Liu <neal.liu@mediatek.com>
[ rjw: Subject & changelog edits, make acpi_idle_enter_s2idle()
  return 0 in all cases ]
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-07-31 13:29:13 +02:00
Neal Liu efe9711214 cpuidle: change enter_s2idle() prototype
Control Flow Integrity(CFI) is a security mechanism that disallows
changes to the original control flow graph of a compiled binary,
making it significantly harder to perform such attacks.

init_state_node() assign same function callback to different
function pointer declarations.

static int init_state_node(struct cpuidle_state *idle_state,
                           const struct of_device_id *matches,
                           struct device_node *state_node) { ...
        idle_state->enter = match_id->data; ...
        idle_state->enter_s2idle = match_id->data; }

Function declarations:

struct cpuidle_state { ...
        int (*enter) (struct cpuidle_device *dev,
                      struct cpuidle_driver *drv,
                      int index);

        void (*enter_s2idle) (struct cpuidle_device *dev,
                              struct cpuidle_driver *drv,
                              int index); };

In this case, either enter() or enter_s2idle() would cause CFI check
failed since they use same callee.

Align function prototype of enter() since it needs return value for
some use cases. The return value of enter_s2idle() is no
need currently.

Signed-off-by: Neal Liu <neal.liu@mediatek.com>
Reviewed-by: Sami Tolvanen <samitolvanen@google.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-07-29 18:38:30 +02:00
Gustavo A. R. Silva 57d2dd4bd1 ACPI: Use fallthrough pseudo-keyword
Replace the existing /* fall through */ comments and its variants with
the new pseudo-keyword macro fallthrough[1]. Also, remove unnecessary
fall-through markings when it is the case.

Link: https://www.kernel.org/doc/html/latest/process/deprecated.html?highlight=fallthrough#implicit-switch-case-fall-through # [1]
Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-07-09 14:09:28 +02:00
Zhang Rui 496121c021 ACPI: processor: idle: Allow probing on platforms with one ACPI C-state
It is possible for ACPI _CST to return only one ACPI C-state, for
example, when deep cstate disabled in the BIOS.

And it is better for the acpi_idle driver to probe succesfully in
this case as well for consistency.

Signed-off-by: Zhang Rui <rui.zhang@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2020-04-27 10:32:44 +02:00
Rafael J. Wysocki 77fb4e0a55 ACPI: processor: Export acpi_processor_evaluate_cst()
The intel_idle driver will be modified to use ACPI _CST subsequently
and it will need to call acpi_processor_evaluate_cst(), so move that
function to acpi_processor.c so that it is always present (which is
required by intel_idle) and export it to modules to allow the ACPI
processor driver (which is modular) to call it.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-27 11:02:07 +01:00
Rafael J. Wysocki aa659a3fca ACPI: processor: Clean up acpi_processor_evaluate_cst()
Clean up acpi_processor_evaluate_cst() in multiple ways:

 * Rename current_count to last_index which matches the purpose of
   the variable better.

 * Consistently use acpi_handle_*() for printing messages and make
   the messages cleaner.

 * Drop redundant parens and braces.

 * Rewrite and clarify comments.

 * Rearrange checks and drop the redundant ones.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-16 12:06:18 +01:00
Rafael J. Wysocki 987c785319 ACPI: processor: Introduce acpi_processor_evaluate_cst()
In order to separate the ACPI _CST evaluation from checks
specific to the ACPI processor driver, move the majority of
the acpi_processor_get_power_info_cst() function body to a new
function, acpi_processor_evaluate_cst(), that will extract
the C-states information from _CST output, and redefine
acpi_processor_get_power_info_cst() as a wrapper around it.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-16 12:06:18 +01:00
Rafael J. Wysocki bc94638886 ACPI: processor: Export function to claim _CST control
The intel_idle driver will be modified to use ACPI _CST subsequently
and it will need to notify the platform firmware of that if
acpi_gbl_FADT.cst_control is set, so add a routine for this purpose,
acpi_processor_claim_cst_control(), to acpi_processor.c (so that it
is always present which is required by intel_idle) and export it
to allow the ACPI processor driver (which is modular) to call it.

No intentional functional impact.

Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-12-16 12:06:18 +01:00
Yin Fengwei fa583f71a9 ACPI: processor_idle: Skip dummy wait if kernel is in guest
In function acpi_idle_do_entry(), an ioport access is used for
dummy wait to guarantee hardware behavior. But it could trigger
unnecessary VMexit if kernel is running as guest in virtualization
environment.

If it's in virtualization environment, the deeper C state enter
operation (inb()) will trap to hypervisor. It's not needed to do
dummy wait after the inb() call. So we could just remove the
dummy io port access to avoid unnecessary VMexit.

And keep dummy io port access to maintain timing for native
environment.

Signed-off-by: Yin Fengwei <fengwei.yin@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
2019-10-25 10:33:20 +02:00