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 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
10 * Cross Partition (XP) uv-based functions.
12 * Architecture specific implementation of common functions.
16 #include <linux/device.h>
17 #include <asm/uv/uv_hub.h>
18 #if defined CONFIG_X86_64
19 #include <asm/uv/bios.h>
20 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
21 #include <asm/sn/sn_sal.h>
23 #include "../sgi-gru/grukservices.h"
27 * Convert a virtual memory address to a physical memory address.
36 xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
41 ret = gru_copy_gpa(dst_gpa, src_gpa, len);
45 dev_err(xp, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
46 "len=%ld\n", dst_gpa, src_gpa, len);
47 return xpGruCopyError;
51 xp_cpu_to_nasid_uv(int cpuid)
53 /* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */
54 return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid));
58 xp_expand_memprotect_uv(unsigned long phys_addr, unsigned long size)
62 #if defined CONFIG_X86_64
63 ret = uv_bios_change_memprotect(phys_addr, size, UV_MEMPROT_ALLOW_RW);
64 if (ret != BIOS_STATUS_SUCCESS) {
65 dev_err(xp, "uv_bios_change_memprotect(,, "
66 "UV_MEMPROT_ALLOW_RW) failed, ret=%d\n", ret);
70 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
73 ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_1,
76 dev_err(xp, "sn_change_memprotect(,, "
77 "SN_MEMPROT_ACCESS_CLASS_1,) failed ret=%d\n", ret);
81 #error not a supported configuration
87 xp_restrict_memprotect_uv(unsigned long phys_addr, unsigned long size)
91 #if defined CONFIG_X86_64
92 ret = uv_bios_change_memprotect(phys_addr, size,
93 UV_MEMPROT_RESTRICT_ACCESS);
94 if (ret != BIOS_STATUS_SUCCESS) {
95 dev_err(xp, "uv_bios_change_memprotect(,, "
96 "UV_MEMPROT_RESTRICT_ACCESS) failed, ret=%d\n", ret);
100 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
103 ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_0,
106 dev_err(xp, "sn_change_memprotect(,, "
107 "SN_MEMPROT_ACCESS_CLASS_0,) failed ret=%d\n", ret);
111 #error not a supported configuration
121 xp_max_npartitions = XP_MAX_NPARTITIONS_UV;
122 xp_partition_id = sn_partition_id;
123 xp_region_size = sn_region_size;
126 xp_remote_memcpy = xp_remote_memcpy_uv;
127 xp_cpu_to_nasid = xp_cpu_to_nasid_uv;
128 xp_expand_memprotect = xp_expand_memprotect_uv;
129 xp_restrict_memprotect = xp_restrict_memprotect_uv;