xref: /openbmc/linux/arch/x86/kernel/apic/bigsmp_32.c (revision 3af1e415)
1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0
22a05180fSIngo Molnar /*
32a05180fSIngo Molnar  * APIC driver for "bigsmp" xAPIC machines with more than 8 virtual CPUs.
42a05180fSIngo Molnar  *
52a05180fSIngo Molnar  * Drives the local APIC in "clustered mode".
62a05180fSIngo Molnar  */
72a05180fSIngo Molnar #include <linux/cpumask.h>
82a05180fSIngo Molnar #include <linux/dmi.h>
92a05180fSIngo Molnar #include <linux/smp.h>
102a05180fSIngo Molnar 
112a05180fSIngo Molnar #include <asm/apic.h>
1213c01139SIngo Molnar #include <asm/io_apic.h>
138b542da3SThomas Gleixner 
14c94f0718SThomas Gleixner #include "local.h"
152a05180fSIngo Molnar 
bigsmp_get_apic_id(unsigned long x)169694cd6cSJiri Slaby static unsigned bigsmp_get_apic_id(unsigned long x)
172a05180fSIngo Molnar {
182a05180fSIngo Molnar 	return (x >> 24) & 0xFF;
192a05180fSIngo Molnar }
202a05180fSIngo Molnar 
bigsmp_check_apicid_used(physid_mask_t * map,int apicid)2157e0aa44SThomas Gleixner static bool bigsmp_check_apicid_used(physid_mask_t *map, int apicid)
222a05180fSIngo Molnar {
2357e0aa44SThomas Gleixner 	return false;
242a05180fSIngo Molnar }
252a05180fSIngo Molnar 
bigsmp_ioapic_phys_id_map(physid_mask_t * phys_map,physid_mask_t * retmap)267abc0753SCyrill Gorcunov static void bigsmp_ioapic_phys_id_map(physid_mask_t *phys_map, physid_mask_t *retmap)
272a05180fSIngo Molnar {
282a05180fSIngo Molnar 	/* For clustered we don't have a good way to do this yet - hack */
297abc0753SCyrill Gorcunov 	physids_promote(0xFFL, retmap);
302a05180fSIngo Molnar }
312a05180fSIngo Molnar 
bigsmp_phys_pkg_id(int cpuid_apic,int index_msb)329694cd6cSJiri Slaby static int bigsmp_phys_pkg_id(int cpuid_apic, int index_msb)
332a05180fSIngo Molnar {
342a05180fSIngo Molnar 	return cpuid_apic >> index_msb;
352a05180fSIngo Molnar }
362a05180fSIngo Molnar 
bigsmp_send_IPI_allbutself(int vector)379694cd6cSJiri Slaby static void bigsmp_send_IPI_allbutself(int vector)
382a05180fSIngo Molnar {
392a05180fSIngo Molnar 	default_send_IPI_mask_allbutself_phys(cpu_online_mask, vector);
402a05180fSIngo Molnar }
412a05180fSIngo Molnar 
bigsmp_send_IPI_all(int vector)429694cd6cSJiri Slaby static void bigsmp_send_IPI_all(int vector)
432a05180fSIngo Molnar {
44500bd02fSThomas Gleixner 	default_send_IPI_mask_sequence_phys(cpu_online_mask, vector);
452a05180fSIngo Molnar }
462a05180fSIngo Molnar 
472a05180fSIngo Molnar static int dmi_bigsmp; /* can be set by dmi scanners */
482a05180fSIngo Molnar 
hp_ht_bigsmp(const struct dmi_system_id * d)492a05180fSIngo Molnar static int hp_ht_bigsmp(const struct dmi_system_id *d)
502a05180fSIngo Molnar {
512a05180fSIngo Molnar 	printk(KERN_NOTICE "%s detected: force use of apic=bigsmp\n", d->ident);
522a05180fSIngo Molnar 	dmi_bigsmp = 1;
532a05180fSIngo Molnar 
542a05180fSIngo Molnar 	return 0;
552a05180fSIngo Molnar }
562a05180fSIngo Molnar 
572a05180fSIngo Molnar 
582a05180fSIngo Molnar static const struct dmi_system_id bigsmp_dmi_table[] = {
592a05180fSIngo Molnar 	{ hp_ht_bigsmp, "HP ProLiant DL760 G2",
602a05180fSIngo Molnar 		{	DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
612a05180fSIngo Molnar 			DMI_MATCH(DMI_BIOS_VERSION, "P44-"),
622a05180fSIngo Molnar 		}
632a05180fSIngo Molnar 	},
642a05180fSIngo Molnar 
652a05180fSIngo Molnar 	{ hp_ht_bigsmp, "HP ProLiant DL740",
662a05180fSIngo Molnar 		{	DMI_MATCH(DMI_BIOS_VENDOR, "HP"),
672a05180fSIngo Molnar 			DMI_MATCH(DMI_BIOS_VERSION, "P47-"),
682a05180fSIngo Molnar 		}
692a05180fSIngo Molnar 	},
702a05180fSIngo Molnar 	{ } /* NULL entry stops DMI scanning */
712a05180fSIngo Molnar };
722a05180fSIngo Molnar 
probe_bigsmp(void)732a05180fSIngo Molnar static int probe_bigsmp(void)
742a05180fSIngo Molnar {
7579c9a17cSThomas Gleixner 	return dmi_check_system(bigsmp_dmi_table);
762a05180fSIngo Molnar }
772a05180fSIngo Molnar 
78404f6aacSKees Cook static struct apic apic_bigsmp __ro_after_init = {
792a05180fSIngo Molnar 
802a05180fSIngo Molnar 	.name				= "bigsmp",
812a05180fSIngo Molnar 	.probe				= probe_bigsmp,
822a05180fSIngo Molnar 
8372161299SThomas Gleixner 	.delivery_mode			= APIC_DELIVERY_MODE_FIXED,
848c44963bSThomas Gleixner 	.dest_mode_logical		= false,
852a05180fSIngo Molnar 
862a05180fSIngo Molnar 	.disable_esr			= 1,
87e57d04e5SThomas Gleixner 
882a05180fSIngo Molnar 	.check_apicid_used		= bigsmp_check_apicid_used,
892a05180fSIngo Molnar 	.ioapic_phys_id_map		= bigsmp_ioapic_phys_id_map,
904114e168SThomas Gleixner 	.cpu_present_to_apicid		= default_cpu_present_to_apicid,
912a05180fSIngo Molnar 	.phys_pkg_id			= bigsmp_phys_pkg_id,
922a05180fSIngo Molnar 
93d92e5e7cSThomas Gleixner 	.max_apic_id			= 0xFE,
942a05180fSIngo Molnar 	.get_apic_id			= bigsmp_get_apic_id,
952a05180fSIngo Molnar 	.set_apic_id			= NULL,
962a05180fSIngo Molnar 
979f9e3bb1SThomas Gleixner 	.calc_dest_apicid		= apic_default_calc_apicid,
982a05180fSIngo Molnar 
995789a12eSThomas Gleixner 	.send_IPI			= default_send_IPI_single_phys,
100500bd02fSThomas Gleixner 	.send_IPI_mask			= default_send_IPI_mask_sequence_phys,
1012a05180fSIngo Molnar 	.send_IPI_mask_allbutself	= NULL,
1022a05180fSIngo Molnar 	.send_IPI_allbutself		= bigsmp_send_IPI_allbutself,
1032a05180fSIngo Molnar 	.send_IPI_all			= bigsmp_send_IPI_all,
1042a05180fSIngo Molnar 	.send_IPI_self			= default_send_IPI_self,
1052a05180fSIngo Molnar 
1062a05180fSIngo Molnar 	.read				= native_apic_mem_read,
1072a05180fSIngo Molnar 	.write				= native_apic_mem_write,
108185c8f33SThomas Gleixner 	.eoi				= native_apic_mem_eoi,
1092a05180fSIngo Molnar 	.icr_read			= native_apic_icr_read,
1102a05180fSIngo Molnar 	.icr_write			= native_apic_icr_write,
111cfebd007SThomas Gleixner 	.wait_icr_idle			= apic_mem_wait_icr_idle,
112e7b6a023SThomas Gleixner 	.safe_wait_icr_idle		= apic_mem_wait_icr_idle_timeout,
1132a05180fSIngo Molnar };
114107e0e0cSSuresh Siddha 
apic_bigsmp_possible(bool cmdline_override)11579c9a17cSThomas Gleixner bool __init apic_bigsmp_possible(bool cmdline_override)
11669c252ffSSuresh Siddha {
11779c9a17cSThomas Gleixner 	return apic == &apic_bigsmp || !cmdline_override;
11879c9a17cSThomas Gleixner }
119838312beSJan Beulich 
apic_bigsmp_force(void)12079c9a17cSThomas Gleixner void __init apic_bigsmp_force(void)
12179c9a17cSThomas Gleixner {
122*3af1e415SThomas Gleixner 	if (apic != &apic_bigsmp)
123*3af1e415SThomas Gleixner 		apic_install_driver(&apic_bigsmp);
12469c252ffSSuresh Siddha }
12569c252ffSSuresh Siddha 
126107e0e0cSSuresh Siddha apic_driver(apic_bigsmp);
127