Commit da42761d authored by Linus Torvalds's avatar Linus Torvalds
Browse files

Merge branch 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip

Pull x86 platform updates from Ingo Molnar:
 "UV platform updates (with a 'hubless' variant) and Jailhouse updates
  for better UART support"

* 'x86-platform-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip:
  x86/jailhouse: Only enable platform UARTs if available
  x86/jailhouse: Improve setup data version comparison
  x86/platform/uv: Account for UV Hubless in is_uvX_hub Ops
  x86/platform/uv: Check EFI Boot to set reboot type
  x86/platform/uv: Decode UVsystab Info
  x86/platform/uv: Add UV Hubbed/Hubless Proc FS Files
  x86/platform/uv: Setup UV functions for Hubless UV Systems
  x86/platform/uv: Add return code to UV BIOS Init function
  x86/platform/uv: Return UV Hubless System Type
  x86/platform/uv: Save OEM_ID from ACPI MADT probe
parents 1c134b19 7a56b81c
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -138,7 +138,7 @@ extern s64 uv_bios_change_memprotect(u64, u64, enum uv_memprotect);
extern s64 uv_bios_reserved_page_pa(u64, u64 *, u64 *, u64 *);
extern int uv_bios_set_legacy_vga_target(bool decode, int domain, int bus);

extern void uv_bios_init(void);
extern int uv_bios_init(void);

extern unsigned long sn_rtc_cycles_per_second;
extern int uv_type;
+14 −2
Original line number Diff line number Diff line
@@ -12,6 +12,16 @@ struct mm_struct;
#ifdef CONFIG_X86_UV
#include <linux/efi.h>

#define	UV_PROC_NODE	"sgi_uv"

static inline int uv(int uvtype)
{
	/* uv(0) is "any" */
	if (uvtype >= 0 && uvtype <= 30)
		return 1 << uvtype;
	return 1;
}

extern unsigned long uv_systab_phys;

extern enum uv_system_type get_uv_system_type(void);
@@ -20,7 +30,8 @@ static inline bool is_early_uv_system(void)
	return uv_systab_phys && uv_systab_phys != EFI_INVALID_TABLE_ADDR;
}
extern int is_uv_system(void);
extern int is_uv_hubless(void);
extern int is_uv_hubbed(int uvtype);
extern int is_uv_hubless(int uvtype);
extern void uv_cpu_init(void);
extern void uv_nmi_init(void);
extern void uv_system_init(void);
@@ -32,7 +43,8 @@ extern const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask,
static inline enum uv_system_type get_uv_system_type(void) { return UV_NONE; }
static inline bool is_early_uv_system(void)	{ return 0; }
static inline int is_uv_system(void)	{ return 0; }
static inline int is_uv_hubless(void)	{ return 0; }
static inline int is_uv_hubbed(int uv)	{ return 0; }
static inline int is_uv_hubless(int uv) { return 0; }
static inline void uv_cpu_init(void)	{ }
static inline void uv_system_init(void)	{ }
static inline const struct cpumask *
+20 −41
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
#include <linux/topology.h>
#include <asm/types.h>
#include <asm/percpu.h>
#include <asm/uv/uv.h>
#include <asm/uv/uv_mmrs.h>
#include <asm/uv/bios.h>
#include <asm/irq_vectors.h>
@@ -243,83 +244,61 @@ static inline int uv_hub_info_check(int version)
#define UV4_HUB_REVISION_BASE		7
#define UV4A_HUB_REVISION_BASE		8	/* UV4 (fixed) rev 2 */

#ifdef	UV1_HUB_IS_SUPPORTED
/* WARNING: UVx_HUB_IS_SUPPORTED defines are deprecated and will be removed */
static inline int is_uv1_hub(void)
{
	return uv_hub_info->hub_revision < UV2_HUB_REVISION_BASE;
}
#ifdef	UV1_HUB_IS_SUPPORTED
	return is_uv_hubbed(uv(1));
#else
static inline int is_uv1_hub(void)
{
	return 0;
}
#endif
}

#ifdef	UV2_HUB_IS_SUPPORTED
static inline int is_uv2_hub(void)
{
	return ((uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE) &&
		(uv_hub_info->hub_revision < UV3_HUB_REVISION_BASE));
}
#ifdef	UV2_HUB_IS_SUPPORTED
	return is_uv_hubbed(uv(2));
#else
static inline int is_uv2_hub(void)
{
	return 0;
}
#endif
}

#ifdef	UV3_HUB_IS_SUPPORTED
static inline int is_uv3_hub(void)
{
	return ((uv_hub_info->hub_revision >= UV3_HUB_REVISION_BASE) &&
		(uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE));
}
#ifdef	UV3_HUB_IS_SUPPORTED
	return is_uv_hubbed(uv(3));
#else
static inline int is_uv3_hub(void)
{
	return 0;
}
#endif
}

/* First test "is UV4A", then "is UV4" */
#ifdef	UV4A_HUB_IS_SUPPORTED
static inline int is_uv4a_hub(void)
{
	return (uv_hub_info->hub_revision >= UV4A_HUB_REVISION_BASE);
}
#else
static inline int is_uv4a_hub(void)
{
#ifdef	UV4A_HUB_IS_SUPPORTED
	if (is_uv_hubbed(uv(4)))
		return (uv_hub_info->hub_revision == UV4A_HUB_REVISION_BASE);
#endif
	return 0;
}
#endif

#ifdef	UV4_HUB_IS_SUPPORTED
static inline int is_uv4_hub(void)
{
	return uv_hub_info->hub_revision >= UV4_HUB_REVISION_BASE;
}
#ifdef	UV4_HUB_IS_SUPPORTED
	return is_uv_hubbed(uv(4));
#else
static inline int is_uv4_hub(void)
{
	return 0;
}
#endif
}

static inline int is_uvx_hub(void)
{
	if (uv_hub_info->hub_revision >= UV2_HUB_REVISION_BASE)
		return uv_hub_info->hub_revision;

	return 0;
	return (is_uv_hubbed(-2) >= uv(2));
}

static inline int is_uv_hub(void)
{
#ifdef	UV1_HUB_IS_SUPPORTED
	return uv_hub_info->hub_revision;
#endif
	return is_uvx_hub();
	return is_uv1_hub() || is_uvx_hub();
}

union uvh_apicid {
+16 −9
Original line number Diff line number Diff line
@@ -153,8 +153,11 @@ struct boot_e820_entry {
 * setup data structure.
 */
struct jailhouse_setup_data {
	struct {
		__u16	version;
		__u16	compatible_version;
	} __attribute__((packed)) hdr;
	struct {
		__u16	pm_timer_address;
		__u16	num_cpus;
		__u64	pci_mmconfig_base;
@@ -162,6 +165,10 @@ struct jailhouse_setup_data {
		__u32	apic_khz;
		__u8	standard_ioapic;
		__u8	cpu_ids[255];
	} __attribute__((packed)) v1;
	struct {
		__u32	flags;
	} __attribute__((packed)) v2;
} __attribute__((packed));

/* The so-called "zeropage" */
+163 −21
Original line number Diff line number Diff line
@@ -14,6 +14,8 @@
#include <linux/memory.h>
#include <linux/export.h>
#include <linux/pci.h>
#include <linux/acpi.h>
#include <linux/efi.h>

#include <asm/e820/api.h>
#include <asm/uv/uv_mmrs.h>
@@ -25,12 +27,17 @@
static DEFINE_PER_CPU(int, x2apic_extra_bits);

static enum uv_system_type	uv_system_type;
static bool			uv_hubless_system;
static int			uv_hubbed_system;
static int			uv_hubless_system;
static u64			gru_start_paddr, gru_end_paddr;
static u64			gru_dist_base, gru_first_node_paddr = -1LL, gru_last_node_paddr;
static u64			gru_dist_lmask, gru_dist_umask;
static union uvh_apicid		uvh_apicid;

/* Unpack OEM/TABLE ID's to be NULL terminated strings */
static u8 oem_id[ACPI_OEM_ID_SIZE + 1];
static u8 oem_table_id[ACPI_OEM_TABLE_ID_SIZE + 1];

/* Information derived from CPUID: */
static struct {
	unsigned int apicid_shift;
@@ -248,17 +255,35 @@ static void __init uv_set_apicid_hibit(void)
	}
}

static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
static void __init uv_stringify(int len, char *to, char *from)
{
	/* Relies on 'to' being NULL chars so result will be NULL terminated */
	strncpy(to, from, len-1);
}

static int __init uv_acpi_madt_oem_check(char *_oem_id, char *_oem_table_id)
{
	int pnodeid;
	int uv_apic;

	uv_stringify(sizeof(oem_id), oem_id, _oem_id);
	uv_stringify(sizeof(oem_table_id), oem_table_id, _oem_table_id);

	if (strncmp(oem_id, "SGI", 3) != 0) {
		if (strncmp(oem_id, "NSGI", 4) == 0) {
			uv_hubless_system = true;
			pr_info("UV: OEM IDs %s/%s, HUBLESS\n",
				oem_id, oem_table_id);
		}
		if (strncmp(oem_id, "NSGI", 4) != 0)
			return 0;

		/* UV4 Hubless, CH, (0x11:UV4+Any) */
		if (strncmp(oem_id, "NSGI4", 5) == 0)
			uv_hubless_system = 0x11;

		/* UV3 Hubless, UV300/MC990X w/o hub (0x9:UV3+Any) */
		else
			uv_hubless_system = 0x9;

		pr_info("UV: OEM IDs %s/%s, HUBLESS(0x%x)\n",
			oem_id, oem_table_id, uv_hubless_system);

		return 0;
	}

@@ -286,6 +311,24 @@ static int __init uv_acpi_madt_oem_check(char *oem_id, char *oem_table_id)
	if (uv_hub_info->hub_revision == 0)
		goto badbios;

	switch (uv_hub_info->hub_revision) {
	case UV4_HUB_REVISION_BASE:
		uv_hubbed_system = 0x11;
		break;

	case UV3_HUB_REVISION_BASE:
		uv_hubbed_system = 0x9;
		break;

	case UV2_HUB_REVISION_BASE:
		uv_hubbed_system = 0x5;
		break;

	case UV1_HUB_REVISION_BASE:
		uv_hubbed_system = 0x3;
		break;
	}

	pnodeid = early_get_pnodeid();
	early_get_apic_socketid_shift();

@@ -336,9 +379,15 @@ int is_uv_system(void)
}
EXPORT_SYMBOL_GPL(is_uv_system);

int is_uv_hubless(void)
int is_uv_hubbed(int uvtype)
{
	return (uv_hubbed_system & uvtype);
}
EXPORT_SYMBOL_GPL(is_uv_hubbed);

int is_uv_hubless(int uvtype)
{
	return uv_hubless_system;
	return (uv_hubless_system & uvtype);
}
EXPORT_SYMBOL_GPL(is_uv_hubless);

@@ -1255,7 +1304,8 @@ static int __init decode_uv_systab(void)
	struct uv_systab *st;
	int i;

	if (uv_hub_info->hub_revision < UV4_HUB_REVISION_BASE)
	/* If system is uv3 or lower, there is no extended UVsystab */
	if (is_uv_hubbed(0xfffffe) < uv(4) && is_uv_hubless(0xfffffe) < uv(4))
		return 0;	/* No extended UVsystab required */

	st = uv_systab;
@@ -1434,6 +1484,103 @@ static void __init build_socket_tables(void)
	}
}

/* Check which reboot to use */
static void check_efi_reboot(void)
{
	/* If EFI reboot not available, use ACPI reboot */
	if (!efi_enabled(EFI_BOOT))
		reboot_type = BOOT_ACPI;
}

/* Setup user proc fs files */
static int proc_hubbed_show(struct seq_file *file, void *data)
{
	seq_printf(file, "0x%x\n", uv_hubbed_system);
	return 0;
}

static int proc_hubless_show(struct seq_file *file, void *data)
{
	seq_printf(file, "0x%x\n", uv_hubless_system);
	return 0;
}

static int proc_oemid_show(struct seq_file *file, void *data)
{
	seq_printf(file, "%s/%s\n", oem_id, oem_table_id);
	return 0;
}

static int proc_hubbed_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_hubbed_show, (void *)NULL);
}

static int proc_hubless_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_hubless_show, (void *)NULL);
}

static int proc_oemid_open(struct inode *inode, struct file *file)
{
	return single_open(file, proc_oemid_show, (void *)NULL);
}

/* (struct is "non-const" as open function is set at runtime) */
static struct file_operations proc_version_fops = {
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static const struct file_operations proc_oemid_fops = {
	.open		= proc_oemid_open,
	.read		= seq_read,
	.llseek		= seq_lseek,
	.release	= single_release,
};

static __init void uv_setup_proc_files(int hubless)
{
	struct proc_dir_entry *pde;
	char *name = hubless ? "hubless" : "hubbed";

	pde = proc_mkdir(UV_PROC_NODE, NULL);
	proc_create("oemid", 0, pde, &proc_oemid_fops);
	proc_create(name, 0, pde, &proc_version_fops);
	if (hubless)
		proc_version_fops.open = proc_hubless_open;
	else
		proc_version_fops.open = proc_hubbed_open;
}

/* Initialize UV hubless systems */
static __init int uv_system_init_hubless(void)
{
	int rc;

	/* Setup PCH NMI handler */
	uv_nmi_setup_hubless();

	/* Init kernel/BIOS interface */
	rc = uv_bios_init();
	if (rc < 0)
		return rc;

	/* Process UVsystab */
	rc = decode_uv_systab();
	if (rc < 0)
		return rc;

	/* Create user access node */
	if (rc >= 0)
		uv_setup_proc_files(1);

	check_efi_reboot();

	return rc;
}

static void __init uv_system_init_hub(void)
{
	struct uv_hub_info_s hub_info = {0};
@@ -1559,32 +1706,27 @@ static void __init uv_system_init_hub(void)
	uv_nmi_setup();
	uv_cpu_init();
	uv_scir_register_cpu_notifier();
	proc_mkdir("sgi_uv", NULL);
	uv_setup_proc_files(0);

	/* Register Legacy VGA I/O redirection handler: */
	pci_register_set_vga_state(uv_set_vga_state);

	/*
	 * For a kdump kernel the reset must be BOOT_ACPI, not BOOT_EFI, as
	 * EFI is not enabled in the kdump kernel:
	 */
	if (is_kdump_kernel())
		reboot_type = BOOT_ACPI;
	check_efi_reboot();
}

/*
 * There is a small amount of UV specific code needed to initialize a
 * UV system that does not have a "UV HUB" (referred to as "hubless").
 * There is a different code path needed to initialize a UV system that does
 * not have a "UV HUB" (referred to as "hubless").
 */
void __init uv_system_init(void)
{
	if (likely(!is_uv_system() && !is_uv_hubless()))
	if (likely(!is_uv_system() && !is_uv_hubless(1)))
		return;

	if (is_uv_system())
		uv_system_init_hub();
	else
		uv_nmi_setup_hubless();
		uv_system_init_hubless();
}

apic_driver(apic_x2apic_uv_x);
Loading