Commit 59f7928c authored by Thomas Gleixner's avatar Thomas Gleixner
Browse files

x86/apic: Use u32 for [gs]et_apic_id()



APIC IDs are used with random data types u16, u32, int, unsigned int,
unsigned long.

Make it all consistently use u32 because that reflects the hardware
register width.

Signed-off-by: default avatarThomas Gleixner <tglx@linutronix.de>
Tested-by: default avatarJuergen Gross <jgross@suse.com>
Tested-by: default avatarSohil Mehta <sohil.mehta@intel.com>
Tested-by: default avatarMichael Kelley <mikelley@microsoft.com>
Tested-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Tested-by: default avatarZhang Rui <rui.zhang@intel.com>
Acked-by: default avatarPeter Zijlstra (Intel) <peterz@infradead.org>
Link: https://lore.kernel.org/r/20230814085113.172569282@linutronix.de
parent 01ccf9bb
Loading
Loading
Loading
Loading
+2 −12
Original line number Diff line number Diff line
@@ -298,8 +298,8 @@ struct apic {
	u32	(*cpu_present_to_apicid)(int mps_cpu);
	u32	(*phys_pkg_id)(u32 cpuid_apic, int index_msb);

	u32	(*get_apic_id)(unsigned long x);
	u32	(*set_apic_id)(unsigned int id);
	u32	(*get_apic_id)(u32 id);
	u32	(*set_apic_id)(u32 apicid);

	/* wakeup_secondary_cpu */
	int	(*wakeup_secondary_cpu)(int apicid, unsigned long start_eip);
@@ -493,16 +493,6 @@ static inline bool lapic_vector_set_in_irr(unsigned int vector)
	return !!(irr & (1U << (vector % 32)));
}

static inline unsigned default_get_apic_id(unsigned long x)
{
	unsigned int ver = GET_APIC_VERSION(apic_read(APIC_LVR));

	if (APIC_XAPIC(ver) || boot_cpu_has(X86_FEATURE_EXTD_APICID))
		return (x >> 24) & 0xFF;
	else
		return (x >> 24) & 0x0F;
}

/*
 * Warm reset vector position:
 */
+2 −2
Original line number Diff line number Diff line
@@ -56,12 +56,12 @@ flat_send_IPI_mask_allbutself(const struct cpumask *cpumask, int vector)
	_flat_send_IPI_mask(mask, vector);
}

static unsigned int flat_get_apic_id(unsigned long x)
static u32 flat_get_apic_id(u32 x)
{
	return (x >> 24) & 0xFF;
}

static u32 set_apic_id(unsigned int id)
static u32 set_apic_id(u32 id)
{
	return (id & 0xFF) << 24;
}
+1 −1
Original line number Diff line number Diff line
@@ -30,7 +30,7 @@ static void noop_apic_icr_write(u32 low, u32 id) { }
static int noop_wakeup_secondary_cpu(int apicid, unsigned long start_eip) { return -1; }
static u64 noop_apic_icr_read(void) { return 0; }
static u32 noop_phys_pkg_id(u32 cpuid_apic, int index_msb) { return 0; }
static unsigned int noop_get_apic_id(unsigned long x) { return 0; }
static u32 noop_get_apic_id(u32 apicid) { return 0; }
static void noop_apic_eoi(void) { }

static u32 noop_apic_read(u32 reg)
+4 −4
Original line number Diff line number Diff line
@@ -25,7 +25,7 @@ static const struct apic apic_numachip1;
static const struct apic apic_numachip2;
static void (*numachip_apic_icr_write)(int apicid, unsigned int val) __read_mostly;

static unsigned int numachip1_get_apic_id(unsigned long x)
static u32 numachip1_get_apic_id(u32 x)
{
	unsigned long value;
	unsigned int id = (x >> 24) & 0xff;
@@ -38,12 +38,12 @@ static unsigned int numachip1_get_apic_id(unsigned long x)
	return id;
}

static u32 numachip1_set_apic_id(unsigned int id)
static u32 numachip1_set_apic_id(u32 id)
{
	return (id & 0xff) << 24;
}

static unsigned int numachip2_get_apic_id(unsigned long x)
static u32 numachip2_get_apic_id(u32 x)
{
	u64 mcfg;

@@ -51,7 +51,7 @@ static unsigned int numachip2_get_apic_id(unsigned long x)
	return ((mcfg >> (28 - 8)) & 0xfff00) | (x >> 24);
}

static u32 numachip2_set_apic_id(unsigned int id)
static u32 numachip2_set_apic_id(u32 id)
{
	return id << 24;
}
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@

#include "local.h"

static unsigned bigsmp_get_apic_id(unsigned long x)
static u32 bigsmp_get_apic_id(u32 x)
{
	return (x >> 24) & 0xFF;
}
Loading