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

[XEN][RFC PATCH v4 10/16] asm/smp.h: move cpu related function to asm/cpu.h


  • To: <xen-devel@xxxxxxxxxxxxxxxxxxxx>
  • From: Vikram Garhwal <vikram.garhwal@xxxxxxx>
  • Date: Tue, 6 Dec 2022 22:18:09 -0800
  • Arc-authentication-results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); 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=w+Sq6+5nUDNMD9hP99qzhfGlSEZu9BK2xepwW4V56QI=; b=Fniblm45wnL1kmFFwur/0YAlBRFG3GPO+PR/zBSKIXi96RP9UjEUMMqAKN3mos5CNCtDNMCIlQc2m5rIjpXIl6D3X3wy88cdYNr2aO6qbSDmKvhvC1tvTCSUblJnSNHymKjmtpRZue0tu/ih+ejlqSDOEzewIbv4zdCeLb/g9AR5Tikk/xiNT6Yv313y8vG4qtpTCkIiUdVW6PAN5ieK+6px3qOIULZT+f0RVF3cf0nlOoWizbZiV3KmyggT/pMLFziT2ctffY33++MFw3nrUl8vhbtX9yMfkODp4LJZvAmKuOBl4IB8BqF+Nh2IPW8LUUCffpivxdeldIvBY1rpvA==
  • Arc-seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=mXOzTNpk/5BMKH+TTIPgyuM2zRgpk8eUMR+vB2kT4ztNRkDbpzX0gwX9UCramvCpFcX9In3nH7nuuNVDMFqjWk45KMDjsdglKOSw7dUiPgUK68dxNK5lbObABq4rMP1YiSrAz5r0sLbpsJsZWUULxjfBvm+jHMyI1ZYlHjp5oeB/44CLy/TbTvwbmzbaiDrK63p86ChJoRCHi1yuBTL98MOX+J+BbgHDPOFm6k972WFdaZIF7eKEW2+B/mgnX6WmYgd/3rn/s23/Q/Zl240hTyqQRJ0bZxSEj1CCHKUYtrxZgjpKr9exSM49Liy/R6I7Gi6pSnMyCHaRc6q8Ac6lPQ==
  • Cc: <sstabellini@xxxxxxxxxx>, <julien@xxxxxxx>, <vikram.garhwal@xxxxxxx>, <Luca.Fancellu@xxxxxxx>, Bertrand Marquis <bertrand.marquis@xxxxxxx>, Volodymyr Babchuk <Volodymyr_Babchuk@xxxxxxxx>, Andrew Cooper <andrew.cooper3@xxxxxxxxxx>, George Dunlap <george.dunlap@xxxxxxxxxx>, "Jan Beulich" <jbeulich@xxxxxxxx>, Wei Liu <wl@xxxxxxx>
  • Delivery-date: Wed, 07 Dec 2022 06:18:39 +0000
  • List-id: Xen developer discussion <xen-devel.lists.xenproject.org>

Dynamic programming ops will modify the dt_host and there might be other
function which are browsing the dt_host at the same time. To avoid the race
conditions, adding rwlock for browsing the dt_host. But adding rwlock in
device_tree.h causes following circular dependency:
    device_tree.h->rwlock.h->smp.h->asm/smp.h->device_tree.h

Inside arch/arm/include/asm/smp.h, there is one function which needs
device_tree.h, moved the cpu related function to a new file:
arch/arm/include/asm/cpu.h

Signed-off-by: Vikram Garhwal <vikram.garhwal@xxxxxxx>
---
 xen/arch/arm/efi/efi-boot.h       |  1 +
 xen/arch/arm/include/asm/cpu.h    | 35 +++++++++++++++++++++++++++++++
 xen/arch/arm/include/asm/domain.h |  1 +
 xen/arch/arm/include/asm/psci.h   |  1 +
 xen/arch/arm/include/asm/smp.h    | 24 ---------------------
 xen/include/xen/cpu.h             |  4 ++++
 xen/include/xen/softirq.h         |  4 ++++
 7 files changed, 46 insertions(+), 24 deletions(-)
 create mode 100644 xen/arch/arm/include/asm/cpu.h

diff --git a/xen/arch/arm/efi/efi-boot.h b/xen/arch/arm/efi/efi-boot.h
index 43a836c3a7..ca40c6f73f 100644
--- a/xen/arch/arm/efi/efi-boot.h
+++ b/xen/arch/arm/efi/efi-boot.h
@@ -5,6 +5,7 @@
  */
 #include <xen/device_tree.h>
 #include <xen/libfdt/libfdt.h>
+#include <asm/cpu.h>
 #include <asm/setup.h>
 #include <asm/smp.h>
 
diff --git a/xen/arch/arm/include/asm/cpu.h b/xen/arch/arm/include/asm/cpu.h
new file mode 100644
index 0000000000..4df80ca1b5
--- /dev/null
+++ b/xen/arch/arm/include/asm/cpu.h
@@ -0,0 +1,35 @@
+#ifndef __ASM_CPU_H
+#define __ASM_CPU_H
+
+#ifndef __ASSEMBLY__
+#include <xen/cpumask.h>
+#include <xen/device_tree.h>
+#include <asm/current.h>
+#endif
+
+DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
+DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
+
+#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
+
+/*
+ * Do we, for platform reasons, need to actually keep CPUs online when we
+ * would otherwise prefer them to be off?
+ */
+#define park_offline_cpus false
+
+extern void noreturn stop_cpu(void);
+
+extern int arch_cpu_init(int cpu, struct dt_device_node *dn);
+extern int arch_cpu_up(int cpu);
+
+int cpu_up_send_sgi(int cpu);
+
+/* Secondary CPU entry point */
+extern void init_secondary(void);
+
+#define cpu_physical_id(cpu) cpu_logical_map(cpu)
+
+#endif
+
+
diff --git a/xen/arch/arm/include/asm/domain.h 
b/xen/arch/arm/include/asm/domain.h
index 2ce6764322..f9440e5c7e 100644
--- a/xen/arch/arm/include/asm/domain.h
+++ b/xen/arch/arm/include/asm/domain.h
@@ -3,6 +3,7 @@
 
 #include <xen/cache.h>
 #include <xen/timer.h>
+#include <asm/cpu.h>
 #include <asm/page.h>
 #include <asm/p2m.h>
 #include <asm/vfp.h>
diff --git a/xen/arch/arm/include/asm/psci.h b/xen/arch/arm/include/asm/psci.h
index 832f77afff..74c1bc6368 100644
--- a/xen/arch/arm/include/asm/psci.h
+++ b/xen/arch/arm/include/asm/psci.h
@@ -1,6 +1,7 @@
 #ifndef __ASM_PSCI_H__
 #define __ASM_PSCI_H__
 
+#include <asm/cpu.h>
 #include <asm/smccc.h>
 
 /* PSCI return values (inclusive of all PSCI versions) */
diff --git a/xen/arch/arm/include/asm/smp.h b/xen/arch/arm/include/asm/smp.h
index 8133d5c295..76944b07f7 100644
--- a/xen/arch/arm/include/asm/smp.h
+++ b/xen/arch/arm/include/asm/smp.h
@@ -3,40 +3,16 @@
 
 #ifndef __ASSEMBLY__
 #include <xen/cpumask.h>
-#include <xen/device_tree.h>
 #include <asm/current.h>
 #endif
 
-DECLARE_PER_CPU(cpumask_var_t, cpu_sibling_mask);
-DECLARE_PER_CPU(cpumask_var_t, cpu_core_mask);
-
-#define cpu_is_offline(cpu) unlikely(!cpu_online(cpu))
-
 #define smp_processor_id() get_processor_id()
 
-/*
- * Do we, for platform reasons, need to actually keep CPUs online when we
- * would otherwise prefer them to be off?
- */
-#define park_offline_cpus false
-
-extern void noreturn stop_cpu(void);
-
 extern int arch_smp_init(void);
-extern int arch_cpu_init(int cpu, struct dt_device_node *dn);
-extern int arch_cpu_up(int cpu);
-
-int cpu_up_send_sgi(int cpu);
-
-/* Secondary CPU entry point */
-extern void init_secondary(void);
 
 extern void smp_init_cpus(void);
 extern void smp_clear_cpu_maps (void);
 extern unsigned int smp_get_max_cpus(void);
-
-#define cpu_physical_id(cpu) cpu_logical_map(cpu)
-
 #endif
 
 /*
diff --git a/xen/include/xen/cpu.h b/xen/include/xen/cpu.h
index e8eeb217a0..ce93eb0003 100644
--- a/xen/include/xen/cpu.h
+++ b/xen/include/xen/cpu.h
@@ -5,6 +5,10 @@
 #include <xen/spinlock.h>
 #include <xen/notifier.h>
 
+#ifdef CONFIG_ARM
+#include <asm/cpu.h>
+#endif
+
 /* Safely access cpu_online_map, cpu_present_map, etc. */
 bool get_cpu_maps(void);
 void put_cpu_maps(void);
diff --git a/xen/include/xen/softirq.h b/xen/include/xen/softirq.h
index 1f6c4783da..cc98a65287 100644
--- a/xen/include/xen/softirq.h
+++ b/xen/include/xen/softirq.h
@@ -19,6 +19,10 @@ enum {
 #include <asm/hardirq.h>
 #include <asm/softirq.h>
 
+#ifdef CONFIG_ARM
+#include <asm/cpu.h>
+#endif
+
 #define NR_SOFTIRQS (NR_COMMON_SOFTIRQS + NR_ARCH_SOFTIRQS)
 
 typedef void (*softirq_handler)(void);
-- 
2.17.1




 


Rackspace

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