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 * Convert a global physical to socket physical address.
39 xp_socket_pa_uv(unsigned long gpa
)
41 return uv_gpa_to_soc_phys_ram(gpa
);
45 xp_remote_mmr_read(unsigned long dst_gpa
, const unsigned long src_gpa
,
49 unsigned long *dst_va
= __va(uv_gpa_to_soc_phys_ram(dst_gpa
));
51 BUG_ON(!uv_gpa_in_mmr_space(src_gpa
));
54 ret
= gru_read_gpa(dst_va
, src_gpa
);
58 dev_err(xp
, "gru_read_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
59 "len=%ld\n", dst_gpa
, src_gpa
, len
);
60 return xpGruCopyError
;
65 xp_remote_memcpy_uv(unsigned long dst_gpa
, const unsigned long src_gpa
,
70 if (uv_gpa_in_mmr_space(src_gpa
))
71 return xp_remote_mmr_read(dst_gpa
, src_gpa
, len
);
73 ret
= gru_copy_gpa(dst_gpa
, src_gpa
, len
);
77 dev_err(xp
, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
78 "len=%ld\n", dst_gpa
, src_gpa
, len
);
79 return xpGruCopyError
;
83 xp_cpu_to_nasid_uv(int cpuid
)
85 /* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */
86 return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid
));
90 xp_expand_memprotect_uv(unsigned long phys_addr
, unsigned long size
)
94 #if defined CONFIG_X86_64
95 ret
= uv_bios_change_memprotect(phys_addr
, size
, UV_MEMPROT_ALLOW_RW
);
96 if (ret
!= BIOS_STATUS_SUCCESS
) {
97 dev_err(xp
, "uv_bios_change_memprotect(,, "
98 "UV_MEMPROT_ALLOW_RW) failed, ret=%d\n", ret
);
102 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
105 ret
= sn_change_memprotect(phys_addr
, size
, SN_MEMPROT_ACCESS_CLASS_1
,
108 dev_err(xp
, "sn_change_memprotect(,, "
109 "SN_MEMPROT_ACCESS_CLASS_1,) failed ret=%d\n", ret
);
113 #error not a supported configuration
118 static enum xp_retval
119 xp_restrict_memprotect_uv(unsigned long phys_addr
, unsigned long size
)
123 #if defined CONFIG_X86_64
124 ret
= uv_bios_change_memprotect(phys_addr
, size
,
125 UV_MEMPROT_RESTRICT_ACCESS
);
126 if (ret
!= BIOS_STATUS_SUCCESS
) {
127 dev_err(xp
, "uv_bios_change_memprotect(,, "
128 "UV_MEMPROT_RESTRICT_ACCESS) failed, ret=%d\n", ret
);
132 #elif defined CONFIG_IA64_GENERIC || defined CONFIG_IA64_SGI_UV
135 ret
= sn_change_memprotect(phys_addr
, size
, SN_MEMPROT_ACCESS_CLASS_0
,
138 dev_err(xp
, "sn_change_memprotect(,, "
139 "SN_MEMPROT_ACCESS_CLASS_0,) failed ret=%d\n", ret
);
143 #error not a supported configuration
153 xp_max_npartitions
= XP_MAX_NPARTITIONS_UV
;
154 xp_partition_id
= sn_partition_id
;
155 xp_region_size
= sn_region_size
;
158 xp_socket_pa
= xp_socket_pa_uv
;
159 xp_remote_memcpy
= xp_remote_memcpy_uv
;
160 xp_cpu_to_nasid
= xp_cpu_to_nasid_uv
;
161 xp_expand_memprotect
= xp_expand_memprotect_uv
;
162 xp_restrict_memprotect
= xp_restrict_memprotect_uv
;