2 * This file is subject to the terms and conditions of the GNU General Public
3 * License. See the file "COPYING" in the main directory of this archive
6 * (C) Copyright 2020 Hewlett Packard Enterprise Development LP
7 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
11 * Cross Partition (XP) uv-based functions.
13 * Architecture specific implementation of common functions.
17 #include <linux/device.h>
18 #include <asm/uv/uv_hub.h>
19 #if defined CONFIG_X86_64
20 #include <asm/uv/bios.h>
22 #include "../sgi-gru/grukservices.h"
26 * Convert a virtual memory address to a physical memory address.
35 * Convert a global physical to socket physical address.
38 xp_socket_pa_uv(unsigned long gpa)
40 return uv_gpa_to_soc_phys_ram(gpa);
44 xp_remote_mmr_read(unsigned long dst_gpa, const unsigned long src_gpa,
48 unsigned long *dst_va = __va(uv_gpa_to_soc_phys_ram(dst_gpa));
50 BUG_ON(!uv_gpa_in_mmr_space(src_gpa));
53 ret = gru_read_gpa(dst_va, src_gpa);
57 dev_err(xp, "gru_read_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
58 "len=%ld\n", dst_gpa, src_gpa, len);
59 return xpGruCopyError;
64 xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
69 if (uv_gpa_in_mmr_space(src_gpa))
70 return xp_remote_mmr_read(dst_gpa, src_gpa, len);
72 ret = gru_copy_gpa(dst_gpa, src_gpa, len);
76 dev_err(xp, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
77 "len=%ld\n", dst_gpa, src_gpa, len);
78 return xpGruCopyError;
82 xp_cpu_to_nasid_uv(int cpuid)
84 /* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */
85 return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid));
89 xp_expand_memprotect_uv(unsigned long phys_addr, unsigned long size)
93 #if defined CONFIG_X86_64
94 ret = uv_bios_change_memprotect(phys_addr, size, UV_MEMPROT_ALLOW_RW);
95 if (ret != BIOS_STATUS_SUCCESS) {
96 dev_err(xp, "uv_bios_change_memprotect(,, "
97 "UV_MEMPROT_ALLOW_RW) failed, ret=%d\n", ret);
101 #error not a supported configuration
106 static enum xp_retval
107 xp_restrict_memprotect_uv(unsigned long phys_addr, unsigned long size)
111 #if defined CONFIG_X86_64
112 ret = uv_bios_change_memprotect(phys_addr, size,
113 UV_MEMPROT_RESTRICT_ACCESS);
114 if (ret != BIOS_STATUS_SUCCESS) {
115 dev_err(xp, "uv_bios_change_memprotect(,, "
116 "UV_MEMPROT_RESTRICT_ACCESS) failed, ret=%d\n", ret);
120 #error not a supported configuration
128 WARN_ON(!is_uv_system());
130 return xpUnsupported;
132 xp_max_npartitions = XP_MAX_NPARTITIONS_UV;
134 xp_partition_id = sn_partition_id;
135 xp_region_size = sn_region_size;
138 xp_socket_pa = xp_socket_pa_uv;
139 xp_remote_memcpy = xp_remote_memcpy_uv;
140 xp_cpu_to_nasid = xp_cpu_to_nasid_uv;
141 xp_expand_memprotect = xp_expand_memprotect_uv;
142 xp_restrict_memprotect = xp_restrict_memprotect_uv;
150 WARN_ON(!is_uv_system());