]> git.proxmox.com Git - mirror_ubuntu-focal-kernel.git/commitdiff
x86/apic: Add replacement for cpu_mask_to_apicid()
authorThomas Gleixner <tglx@linutronix.de>
Wed, 13 Sep 2017 21:29:37 +0000 (23:29 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 25 Sep 2017 18:51:56 +0000 (20:51 +0200)
As preparation for replacing the vector allocator, provide a new function
which takes a cpu number instead of a cpu mask to calculate/lookup the
resulting APIC destination id.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Tested-by: Juergen Gross <jgross@suse.com>
Tested-by: Yu Chen <yu.c.chen@intel.com>
Acked-by: Juergen Gross <jgross@suse.com>
Cc: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: Marc Zyngier <marc.zyngier@arm.com>
Cc: Alok Kataria <akataria@vmware.com>
Cc: Joerg Roedel <joro@8bytes.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>
Cc: Steven Rostedt <rostedt@goodmis.org>
Cc: Christoph Hellwig <hch@lst.de>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Borislav Petkov <bp@alien8.de>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Rui Zhang <rui.zhang@intel.com>
Cc: "K. Y. Srinivasan" <kys@microsoft.com>
Cc: Arjan van de Ven <arjan@linux.intel.com>
Cc: Dan Williams <dan.j.williams@intel.com>
Cc: Len Brown <lenb@kernel.org>
arch/x86/include/asm/apic.h
arch/x86/kernel/apic/apic_common.c
arch/x86/kernel/apic/apic_flat_64.c
arch/x86/kernel/apic/apic_noop.c
arch/x86/kernel/apic/apic_numachip.c
arch/x86/kernel/apic/bigsmp_32.c
arch/x86/kernel/apic/probe_32.c
arch/x86/kernel/apic/x2apic_cluster.c
arch/x86/kernel/apic/x2apic_phys.c
arch/x86/kernel/apic/x2apic_uv_x.c
arch/x86/xen/apic.c

index ff0bddabaa043707936b6d2b82ea3e03a124d0c1..01bcaa8b62b3f5947db3c50a265f44751cc906ca 100644 (file)
@@ -303,6 +303,7 @@ struct apic {
        int     (*cpu_mask_to_apicid)(const struct cpumask *cpumask,
                                      struct irq_data *irqdata,
                                      unsigned int *apicid);
+       u32     (*calc_dest_apicid)(unsigned int cpu);
 
        /* ICR related functions */
        u64     (*icr_read)(void);
@@ -486,6 +487,10 @@ static inline unsigned int read_apic_id(void)
 extern int default_apic_id_valid(int apicid);
 extern int default_acpi_madt_oem_check(char *, char *);
 extern void default_setup_apic_routing(void);
+
+extern u32 apic_default_calc_apicid(unsigned int cpu);
+extern u32 apic_flat_calc_apicid(unsigned int cpu);
+
 extern int flat_cpu_mask_to_apicid(const struct cpumask *cpumask,
                                   struct irq_data *irqdata,
                                   unsigned int *apicid);
index 4791654cdeb2aed2b343d12d2c6a0744b559e34d..ddc6a4301588321d0378d00406ab371b2ac54410 100644 (file)
@@ -6,6 +6,11 @@
 #include <linux/irq.h>
 #include <asm/apic.h>
 
+u32 apic_default_calc_apicid(unsigned int cpu)
+{
+       return per_cpu(x86_cpu_to_apicid, cpu);
+}
+
 int default_cpu_mask_to_apicid(const struct cpumask *msk, struct irq_data *irqd,
                               unsigned int *apicid)
 {
@@ -18,6 +23,11 @@ int default_cpu_mask_to_apicid(const struct cpumask *msk, struct irq_data *irqd,
        return 0;
 }
 
+u32 apic_flat_calc_apicid(unsigned int cpu)
+{
+       return 1U << cpu;
+}
+
 int flat_cpu_mask_to_apicid(const struct cpumask *mask, struct irq_data *irqd,
                            unsigned int *apicid)
 
index 7ca354dee8afec48d08b497aac5eb5cafca3faf1..697704443fdaa01c9e85c3f9933bba46295acdbb 100644 (file)
@@ -172,6 +172,7 @@ static struct apic apic_flat __ro_after_init = {
        .set_apic_id                    = set_apic_id,
 
        .cpu_mask_to_apicid             = flat_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_flat_calc_apicid,
 
        .send_IPI                       = default_send_IPI_single,
        .send_IPI_mask                  = flat_send_IPI_mask,
@@ -267,6 +268,7 @@ static struct apic apic_physflat __ro_after_init = {
        .set_apic_id                    = set_apic_id,
 
        .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_default_calc_apicid,
 
        .send_IPI                       = default_send_IPI_single_phys,
        .send_IPI_mask                  = default_send_IPI_mask_sequence_phys,
index a8a7cb1347dce6cc6a5d36897d3e67f03cc17fec..d8c24e6f1a1168e35fffdca220120cc53e660982 100644 (file)
@@ -142,6 +142,7 @@ struct apic apic_noop __ro_after_init = {
        .set_apic_id                    = NULL,
 
        .cpu_mask_to_apicid             = flat_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_flat_calc_apicid,
 
        .send_IPI                       = noop_send_IPI,
        .send_IPI_mask                  = noop_send_IPI_mask,
index cc2f8843391f99f6ce4322ebc1e7fe605163bd3a..4ec293b30eb84d7462791793009074b490350dbd 100644 (file)
@@ -267,6 +267,7 @@ static const struct apic apic_numachip1 __refconst = {
        .set_apic_id                    = numachip1_set_apic_id,
 
        .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_default_calc_apicid,
 
        .send_IPI                       = numachip_send_IPI_one,
        .send_IPI_mask                  = numachip_send_IPI_mask,
@@ -317,6 +318,7 @@ static const struct apic apic_numachip2 __refconst = {
        .set_apic_id                    = numachip2_set_apic_id,
 
        .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_default_calc_apicid,
 
        .send_IPI                       = numachip_send_IPI_one,
        .send_IPI_mask                  = numachip_send_IPI_mask,
index 72a1a038554932a6e311d482ee34e8cab03d3a23..de2e8597f2df28ce62e80c011e0c7783240de2c0 100644 (file)
@@ -172,6 +172,7 @@ static struct apic apic_bigsmp __ro_after_init = {
        .set_apic_id                    = NULL,
 
        .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_default_calc_apicid,
 
        .send_IPI                       = default_send_IPI_single_phys,
        .send_IPI_mask                  = default_send_IPI_mask_sequence_phys,
index 95125bfb4e093cbd129eae0e972358c04c8f4ffc..6a9020a3c2434e496b28610768e6e41584fae274 100644 (file)
@@ -127,6 +127,7 @@ static struct apic apic_default __ro_after_init = {
        .set_apic_id                    = NULL,
 
        .cpu_mask_to_apicid             = flat_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_flat_calc_apicid,
 
        .send_IPI                       = default_send_IPI_single,
        .send_IPI_mask                  = default_send_IPI_mask_logical,
index c1684f27226ed09bb25e370b45c658c61dc96d09..17bf63f580d73fd1fa81fb2dc0bf8096050ae5ba 100644 (file)
@@ -114,6 +114,11 @@ x2apic_cpu_mask_to_apicid(const struct cpumask *mask, struct irq_data *irqdata,
        return 0;
 }
 
+static u32 x2apic_calc_apicid(unsigned int cpu)
+{
+       return per_cpu(x86_cpu_to_logical_apicid, cpu);
+}
+
 static void init_x2apic_ldr(void)
 {
        struct cluster_mask *cmsk = this_cpu_read(cluster_masks);
@@ -245,6 +250,7 @@ static struct apic apic_x2apic_cluster __ro_after_init = {
        .set_apic_id                    = x2apic_set_apic_id,
 
        .cpu_mask_to_apicid             = x2apic_cpu_mask_to_apicid,
+       .calc_dest_apicid               = x2apic_calc_apicid,
 
        .send_IPI                       = x2apic_send_IPI,
        .send_IPI_mask                  = x2apic_send_IPI_mask,
index 6903e69a7b608d21603384a8b3603a3af0ddd565..ebad7ddbfdfc16d5fe0fb3aa7181c1d4fe0151c2 100644 (file)
@@ -165,6 +165,7 @@ static struct apic apic_x2apic_phys __ro_after_init = {
        .set_apic_id                    = x2apic_set_apic_id,
 
        .cpu_mask_to_apicid             = default_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_default_calc_apicid,
 
        .send_IPI                       = x2apic_send_IPI,
        .send_IPI_mask                  = x2apic_send_IPI_mask,
index 9f6d551deeb476bce717770fad160d31e9c5868f..99c3c039646d769bef7d280ec4cba0ad347c3c98 100644 (file)
@@ -537,6 +537,11 @@ uv_cpu_mask_to_apicid(const struct cpumask *mask, struct irq_data *irqdata,
        return ret;
 }
 
+static u32 apic_uv_calc_apicid(unsigned int cpu)
+{
+       return apic_default_calc_apicid(cpu) | uv_apicid_hibits;
+}
+
 static unsigned int x2apic_get_apic_id(unsigned long x)
 {
        unsigned int id;
@@ -602,6 +607,7 @@ static struct apic apic_x2apic_uv_x __ro_after_init = {
        .set_apic_id                    = set_apic_id,
 
        .cpu_mask_to_apicid             = uv_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_uv_calc_apicid,
 
        .send_IPI                       = uv_send_IPI_one,
        .send_IPI_mask                  = uv_send_IPI_mask,
index 58776bcf425100b70e0214626e691e7a9a23c4c6..fb8522bed08c49f0aca6204cab7493c375db2ca3 100644 (file)
@@ -178,6 +178,7 @@ static struct apic xen_pv_apic = {
        .set_apic_id                    = xen_set_apic_id, /* Can be NULL on 32-bit. */
 
        .cpu_mask_to_apicid             = flat_cpu_mask_to_apicid,
+       .calc_dest_apicid               = apic_flat_calc_apicid,
 
 #ifdef CONFIG_SMP
        .send_IPI_mask                  = xen_send_IPI_mask,