[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen master] x86/smp: move and clean APIC helpers
commit 9366a8cc1ca2725d6c18a8217aae013edfadf55e Author: Roger Pau Monné <roger.pau@xxxxxxxxxx> AuthorDate: Mon Jan 20 12:48:05 2020 +0100 Commit: Jan Beulich <jbeulich@xxxxxxxx> CommitDate: Mon Jan 20 12:48:05 2020 +0100 x86/smp: move and clean APIC helpers Move __prepare_ICR{2}, apic_wait_icr_idle and __default_send_IPI_shortcut to the top of the file, since they will be used by send_IPI_mask in future changes. While there, take the opportunity to remove the leading underscores, drop the inline attribute, drop the default prefix from the shorthand helper, change the return type of the prepare helpers to unsigned and do some minor style cleanups. No functional change intended. Signed-off-by: Roger Pau Monné <roger.pau@xxxxxxxxxx> Reviewed-by: Jan Beulich <jbeulich@xxxxxxxx> --- xen/arch/x86/smp.c | 83 +++++++++++++++++++++++++----------------------------- 1 file changed, 39 insertions(+), 44 deletions(-) diff --git a/xen/arch/x86/smp.c b/xen/arch/x86/smp.c index c8e5913e47..c14f304c09 100644 --- a/xen/arch/x86/smp.c +++ b/xen/arch/x86/smp.c @@ -23,6 +23,40 @@ #include <irq_vectors.h> #include <mach_apic.h> +/* Helper functions to prepare APIC register values. */ +static unsigned int prepare_ICR(unsigned int shortcut, int vector) +{ + return APIC_DM_FIXED | shortcut | vector; +} + +static unsigned int prepare_ICR2(unsigned int mask) +{ + return SET_xAPIC_DEST_FIELD(mask); +} + +void apic_wait_icr_idle(void) +{ + if ( x2apic_enabled ) + return; + + while ( apic_read(APIC_ICR) & APIC_ICR_BUSY ) + cpu_relax(); +} + +/* Helper for sending APIC IPIs using a shorthand. */ +static void send_IPI_shortcut(unsigned int shortcut, int vector, + unsigned int dest) +{ + unsigned int cfg; + + /* Wait for idle. */ + apic_wait_icr_idle(); + /* Prepare target chip field. */ + cfg = prepare_ICR(shortcut, vector) | dest; + /* Send the IPI. The write to APIC_ICR fires this off. */ + apic_write(APIC_ICR, cfg); +} + /* * send_IPI_mask(cpumask, vector): sends @vector IPI to CPUs in @cpumask, * excluding the local CPU. @cpumask may be empty. @@ -80,48 +114,9 @@ void send_IPI_self(int vector) * The following functions deal with sending IPIs between CPUs. */ -static inline int __prepare_ICR (unsigned int shortcut, int vector) -{ - return APIC_DM_FIXED | shortcut | vector; -} - -static inline int __prepare_ICR2 (unsigned int mask) -{ - return SET_xAPIC_DEST_FIELD(mask); -} - -void apic_wait_icr_idle(void) -{ - if ( x2apic_enabled ) - return; - - while ( apic_read( APIC_ICR ) & APIC_ICR_BUSY ) - cpu_relax(); -} - -static void __default_send_IPI_shortcut(unsigned int shortcut, int vector, - unsigned int dest) -{ - unsigned int cfg; - - /* - * Wait for idle. - */ - apic_wait_icr_idle(); - - /* - * prepare target chip field - */ - cfg = __prepare_ICR(shortcut, vector) | dest; - /* - * Send the IPI. The write to APIC_ICR fires this off. - */ - apic_write(APIC_ICR, cfg); -} - void send_IPI_self_legacy(uint8_t vector) { - __default_send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); + send_IPI_shortcut(APIC_DEST_SELF, vector, APIC_DEST_PHYSICAL); } void send_IPI_mask_flat(const cpumask_t *cpumask, int vector) @@ -145,13 +140,13 @@ void send_IPI_mask_flat(const cpumask_t *cpumask, int vector) /* * prepare target chip field */ - cfg = __prepare_ICR2(mask); + cfg = prepare_ICR2(mask); apic_write(APIC_ICR2, cfg); /* * program the ICR */ - cfg = __prepare_ICR(0, vector) | APIC_DEST_LOGICAL; + cfg = prepare_ICR(0, vector) | APIC_DEST_LOGICAL; /* * Send the IPI. The write to APIC_ICR fires this off. @@ -181,13 +176,13 @@ void send_IPI_mask_phys(const cpumask_t *mask, int vector) /* * prepare target chip field */ - cfg = __prepare_ICR2(cpu_physical_id(query_cpu)); + cfg = prepare_ICR2(cpu_physical_id(query_cpu)); apic_write(APIC_ICR2, cfg); /* * program the ICR */ - cfg = __prepare_ICR(0, vector) | APIC_DEST_PHYSICAL; + cfg = prepare_ICR(0, vector) | APIC_DEST_PHYSICAL; /* * Send the IPI. The write to APIC_ICR fires this off. -- generated by git-patchbot for /home/xen/git/xen.git#master _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxxx https://lists.xenproject.org/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |