[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v4] acpi/processor: fix evaluating _PDC method when running as Xen dom0


  • To: linux-kernel@xxxxxxxxxxxxxxx
  • From: Roger Pau Monne <roger.pau@xxxxxxxxxx>
  • Date: Thu, 16 Mar 2023 17:42:56 +0100
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=citrix.com; dmarc=pass action=none header.from=citrix.com; dkim=pass header.d=citrix.com; arc=none
  • Arc-message-signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=FnsesX4MP7QQGRTtFMaZrcVrqunX9YwGekrbHQ4HpvA=; b=kABW4WmNfemYHHUGON1YauA+uZC0v+PbaNbAqnBJDHVm80WfCGXBs+pzmqV8f2JxXr5l5+N6o3rLlQY69BtyjtzY9aFgVTEFLxNxawpBAJ3hFePTcA7J/6R1ri86EOorCEfHNNDpFJcNLsFx9zTwSJeo71JZS5Af8O0yYaoSMeWLZ45qezHSLZmAq6oAM503Y0qA8Kjsj7Kp7RMQ3/tmcnDnb7bOJ548t2jAYz8XRBfM3s4t5VVkcBSPtJG3z6k/5TVja97IaNCRMTYYfDvHHCKLO5RkzNymqLPKJE1l/6ddg8H6DYn5aJ6IFKiSDz6Y+yxUxAqjIw37bVNH7/q2vA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=YxAM+vcZJVkPHNmAS0LEekjTgYauiQ1Lx42/O2tbOp/POzsuNXkGHGacstzo8L3Nxxeu3qrOlj/A0NeSPuHtWp1fKdMtO/KhWfLj+JA71MHA+RpNgCJ180lC6mr0t775SYR1ef3GXI2edxCO9wszpcc8ATPcs6x6j/KQmoEHecbURVAVaOR/Ft4v7BFQuREE3oEcfKw64pp6rhBgaxTsUNqoPwj5GTjTIzfZIiTmW9uaPkIj6GQpAa6MSdkO1WPImCO3IyPyO5GdunY0LuG6Z4/BMGdZxUoDMwJVw+Bu2RJhU0IhT6Ikyd5n4cpaGZivHAJ6PMVKOPiN/Is3SMLO4A==
  • Authentication-results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=citrix.com;
  • Cc: xen-devel@xxxxxxxxxxxxxxxxxxxx, josef@xxxxxxxxxxx, Roger Pau Monne <roger.pau@xxxxxxxxxx>, Juergen Gross <jgross@xxxxxxxx>, Boris Ostrovsky <boris.ostrovsky@xxxxxxxxxx>, Thomas Gleixner <tglx@xxxxxxxxxxxxx>, Ingo Molnar <mingo@xxxxxxxxxx>, Borislav Petkov <bp@xxxxxxxxx>, Dave Hansen <dave.hansen@xxxxxxxxxxxxxxx>, x86@xxxxxxxxxx, "H. Peter Anvin" <hpa@xxxxxxxxx>, "Rafael J. Wysocki" <rafael@xxxxxxxxxx>, Len Brown <lenb@xxxxxxxxxx>, Stefano Stabellini <sstabellini@xxxxxxxxxx>, Oleksandr Tyshchenko <oleksandr_tyshchenko@xxxxxxxx>, Venkatesh Pallipadi <venkatesh.pallipadi@xxxxxxxxx>, Alex Chiang <achiang@xxxxxx>, linux-acpi@xxxxxxxxxxxxxxx
  • Delivery-date: Thu, 16 Mar 2023 16:43:23 +0000
  • Ironport-data: A9a23:gwb1nKIwbm9WaehNFE+RI5UlxSXFcZb7ZxGr2PjKsXjdYENS1TBVz GtNDW3VaKmPajegeNp3OYW18B8E75PTnYAwHgFlqX01Q3x08seUXt7xwmUcnc+xBpaaEB84t ZV2hv3odp1coqr0/0/1WlTZhSAgk/rOHvykU7Ss1hlZHWdMUD0mhQ9oh9k3i4tphcnRKw6Ws Jb5rta31GWNglaYCUpJrfPTwP9TlK6q4mhA5QVgPa8jUGL2zBH5MrpOfcldEFOgKmVkNrbSb /rOyri/4lTY838FYj9yuu+mGqGiaue60Tmm0hK6aYD76vRxjnVa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dS9qBDnhOZICOsqTNGftWDd0QPCTL2Ki7GSpwEIcxeeygc379 YYT0ERMqyWMbFMt7eB3OB6KbodKRu8nZxASd2w8548d3AIV0i51XYINu9AKDwJeOCaP+tEKH NB3Ls3m9LOEU5nEfhTz0NqY9T+
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

In ACPI systems, the OS can direct power management, as opposed to the
firmware.  This OS-directed Power Management is called OSPM.  Part of
telling the firmware that the OS going to direct power management is
making ACPI "_PDC" (Processor Driver Capabilities) calls.  These _PDC
methods must be evaluated for every processor object.  If these _PDC
calls are not completed for every processor it can lead to
inconsistency and later failures in things like the CPU frequency
driver.

In a Xen system, the dom0 kernel is responsible for system-wide power
management.  The dom0 kernel is in charge of OSPM.  However, the
number of CPUs available to dom0 can be different than the number of
CPUs physically present on the system.

This leads to a problem: the dom0 kernel needs to evaluate _PDC for
all the processors, but it can't always see them.

In dom0 kernels, ignore the existing ACPI method for determining if a
processor is physically present because it might not be accurate.
Instead, ask the hypervisor for this information.

Fix this by introducing a custom function to use when running as Xen
dom0 in order to check whether a processor object matches a CPU that's
online.  Such checking is done using the existing information fetched
by the Xen pCPU subsystem, extending it to also store the ACPI ID.

This ensures that _PDC method gets evaluated for all physically online
CPUs, regardless of the number of CPUs made available to dom0.

Fixes: 5d554a7bb064 ('ACPI: processor: add internal 
processor_physically_present()')
Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx>
---
Changes since v3:
 - Protect xen_processor_present() definition with CONFIG_ACPI.

Changes since v2:
 - Extend and use the existing pcpu functionality.

Changes since v1:
 - Reword commit message.
---
 arch/x86/include/asm/xen/hypervisor.h | 10 ++++++++++
 drivers/acpi/processor_pdc.c          | 11 +++++++++++
 drivers/xen/pcpu.c                    | 21 +++++++++++++++++++++
 3 files changed, 42 insertions(+)

diff --git a/arch/x86/include/asm/xen/hypervisor.h 
b/arch/x86/include/asm/xen/hypervisor.h
index 5fc35f889cd1..990a1609677e 100644
--- a/arch/x86/include/asm/xen/hypervisor.h
+++ b/arch/x86/include/asm/xen/hypervisor.h
@@ -63,4 +63,14 @@ void __init xen_pvh_init(struct boot_params *boot_params);
 void __init mem_map_via_hcall(struct boot_params *boot_params_p);
 #endif
 
+#if defined(CONFIG_XEN_DOM0) && defined(CONFIG_ACPI)
+bool __init xen_processor_present(uint32_t acpi_id);
+#else
+static inline bool xen_processor_present(uint32_t acpi_id)
+{
+       BUG();
+       return false;
+}
+#endif
+
 #endif /* _ASM_X86_XEN_HYPERVISOR_H */
diff --git a/drivers/acpi/processor_pdc.c b/drivers/acpi/processor_pdc.c
index 8c3f82c9fff3..18fb04523f93 100644
--- a/drivers/acpi/processor_pdc.c
+++ b/drivers/acpi/processor_pdc.c
@@ -14,6 +14,8 @@
 #include <linux/acpi.h>
 #include <acpi/processor.h>
 
+#include <xen/xen.h>
+
 #include "internal.h"
 
 static bool __init processor_physically_present(acpi_handle handle)
@@ -47,6 +49,15 @@ static bool __init processor_physically_present(acpi_handle 
handle)
                return false;
        }
 
+       if (xen_initial_domain())
+               /*
+                * When running as a Xen dom0 the number of processors Linux
+                * sees can be different from the real number of processors on
+                * the system, and we still need to execute _PDC for all of
+                * them.
+                */
+               return xen_processor_present(acpi_id);
+
        type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0;
        cpuid = acpi_get_cpuid(handle, type, acpi_id);
 
diff --git a/drivers/xen/pcpu.c b/drivers/xen/pcpu.c
index fd3a644b0855..034d05e56507 100644
--- a/drivers/xen/pcpu.c
+++ b/drivers/xen/pcpu.c
@@ -58,6 +58,7 @@ struct pcpu {
        struct list_head list;
        struct device dev;
        uint32_t cpu_id;
+       uint32_t acpi_id;
        uint32_t flags;
 };
 
@@ -249,6 +250,7 @@ static struct pcpu *create_and_register_pcpu(struct 
xenpf_pcpuinfo *info)
 
        INIT_LIST_HEAD(&pcpu->list);
        pcpu->cpu_id = info->xen_cpuid;
+       pcpu->acpi_id = info->acpi_id;
        pcpu->flags = info->flags;
 
        /* Need hold on xen_pcpu_lock before pcpu list manipulations */
@@ -381,3 +383,22 @@ static int __init xen_pcpu_init(void)
        return ret;
 }
 arch_initcall(xen_pcpu_init);
+
+#ifdef CONFIG_ACPI
+bool __init xen_processor_present(uint32_t acpi_id)
+{
+       struct pcpu *pcpu;
+       bool online = false;
+
+       mutex_lock(&xen_pcpu_lock);
+       list_for_each_entry(pcpu, &xen_pcpus, list)
+               if (pcpu->acpi_id == acpi_id) {
+                       online = pcpu->flags & XEN_PCPU_FLAGS_ONLINE;
+                       break;
+               }
+
+       mutex_unlock(&xen_pcpu_lock);
+
+       return online;
+}
+#endif
-- 
2.39.0




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.