GUI: Fix Tomato RAF theme for all builds. Compilation typo.
[tomato.git] / release / src-rt-6.x.4708 / linux / linux-2.6.36 / drivers / misc / sgi-xp / xp_sn2.c
blobb83ca742a6418232cdddd53adad787b7a33b2164
1 /*
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
4 * for more details.
6 * Copyright (c) 2008 Silicon Graphics, Inc. All Rights Reserved.
7 */
9 /*
10 * Cross Partition (XP) sn2-based functions.
12 * Architecture specific implementation of common functions.
15 #include <linux/module.h>
16 #include <linux/device.h>
17 #include <asm/sn/bte.h>
18 #include <asm/sn/sn_sal.h>
19 #include "xp.h"
22 * The export of xp_nofault_PIOR needs to happen here since it is defined
23 * in drivers/misc/sgi-xp/xp_nofault.S. The target of the nofault read is
24 * defined here.
26 EXPORT_SYMBOL_GPL(xp_nofault_PIOR);
28 u64 xp_nofault_PIOR_target;
29 EXPORT_SYMBOL_GPL(xp_nofault_PIOR_target);
31 static enum xp_retval
32 xp_register_nofault_code_sn2(void)
34 int ret;
35 u64 func_addr;
36 u64 err_func_addr;
38 func_addr = *(u64 *)xp_nofault_PIOR;
39 err_func_addr = *(u64 *)xp_error_PIOR;
40 ret = sn_register_nofault_code(func_addr, err_func_addr, err_func_addr,
41 1, 1);
42 if (ret != 0) {
43 dev_err(xp, "can't register nofault code, error=%d\n", ret);
44 return xpSalError;
47 * Setup the nofault PIO read target. (There is no special reason why
48 * SH_IPI_ACCESS was selected.)
50 if (is_shub1())
51 xp_nofault_PIOR_target = SH1_IPI_ACCESS;
52 else if (is_shub2())
53 xp_nofault_PIOR_target = SH2_IPI_ACCESS0;
55 return xpSuccess;
58 static void
59 xp_unregister_nofault_code_sn2(void)
61 u64 func_addr = *(u64 *)xp_nofault_PIOR;
62 u64 err_func_addr = *(u64 *)xp_error_PIOR;
64 /* unregister the PIO read nofault code region */
65 (void)sn_register_nofault_code(func_addr, err_func_addr,
66 err_func_addr, 1, 0);
70 * Convert a virtual memory address to a physical memory address.
72 static unsigned long
73 xp_pa_sn2(void *addr)
75 return __pa(addr);
79 * Convert a global physical to a socket physical address.
81 static unsigned long
82 xp_socket_pa_sn2(unsigned long gpa)
84 return gpa;
88 * Wrapper for bte_copy().
90 * dst_pa - physical address of the destination of the transfer.
91 * src_pa - physical address of the source of the transfer.
92 * len - number of bytes to transfer from source to destination.
94 * Note: xp_remote_memcpy_sn2() should never be called while holding a spinlock.
96 static enum xp_retval
97 xp_remote_memcpy_sn2(unsigned long dst_pa, const unsigned long src_pa,
98 size_t len)
100 bte_result_t ret;
102 ret = bte_copy(src_pa, dst_pa, len, (BTE_NOTIFY | BTE_WACQUIRE), NULL);
103 if (ret == BTE_SUCCESS)
104 return xpSuccess;
106 if (is_shub2()) {
107 dev_err(xp, "bte_copy() on shub2 failed, error=0x%x dst_pa="
108 "0x%016lx src_pa=0x%016lx len=%ld\\n", ret, dst_pa,
109 src_pa, len);
110 } else {
111 dev_err(xp, "bte_copy() failed, error=%d dst_pa=0x%016lx "
112 "src_pa=0x%016lx len=%ld\\n", ret, dst_pa, src_pa, len);
115 return xpBteCopyError;
118 static int
119 xp_cpu_to_nasid_sn2(int cpuid)
121 return cpuid_to_nasid(cpuid);
124 static enum xp_retval
125 xp_expand_memprotect_sn2(unsigned long phys_addr, unsigned long size)
127 u64 nasid_array = 0;
128 int ret;
130 ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_1,
131 &nasid_array);
132 if (ret != 0) {
133 dev_err(xp, "sn_change_memprotect(,, "
134 "SN_MEMPROT_ACCESS_CLASS_1,) failed ret=%d\n", ret);
135 return xpSalError;
137 return xpSuccess;
140 static enum xp_retval
141 xp_restrict_memprotect_sn2(unsigned long phys_addr, unsigned long size)
143 u64 nasid_array = 0;
144 int ret;
146 ret = sn_change_memprotect(phys_addr, size, SN_MEMPROT_ACCESS_CLASS_0,
147 &nasid_array);
148 if (ret != 0) {
149 dev_err(xp, "sn_change_memprotect(,, "
150 "SN_MEMPROT_ACCESS_CLASS_0,) failed ret=%d\n", ret);
151 return xpSalError;
153 return xpSuccess;
156 enum xp_retval
157 xp_init_sn2(void)
159 BUG_ON(!is_shub());
161 xp_max_npartitions = XP_MAX_NPARTITIONS_SN2;
162 xp_partition_id = sn_partition_id;
163 xp_region_size = sn_region_size;
165 xp_pa = xp_pa_sn2;
166 xp_socket_pa = xp_socket_pa_sn2;
167 xp_remote_memcpy = xp_remote_memcpy_sn2;
168 xp_cpu_to_nasid = xp_cpu_to_nasid_sn2;
169 xp_expand_memprotect = xp_expand_memprotect_sn2;
170 xp_restrict_memprotect = xp_restrict_memprotect_sn2;
172 return xp_register_nofault_code_sn2();
175 void
176 xp_exit_sn2(void)
178 BUG_ON(!is_shub());
180 xp_unregister_nofault_code_sn2();