xref: /openbmc/linux/drivers/misc/sgi-xp/xp_uv.c (revision 5b8669dfd110a62a74eea525a009342f73987ea0)
1bc63d387SDean Nelson /*
2bc63d387SDean Nelson  * This file is subject to the terms and conditions of the GNU General Public
3bc63d387SDean Nelson  * License.  See the file "COPYING" in the main directory of this archive
4bc63d387SDean Nelson  * for more details.
5bc63d387SDean Nelson  *
6bc63d387SDean Nelson  * Copyright (c) 2008 Silicon Graphics, Inc.  All Rights Reserved.
7bc63d387SDean Nelson  */
8bc63d387SDean Nelson 
9bc63d387SDean Nelson /*
10bc63d387SDean Nelson  * Cross Partition (XP) uv-based functions.
11bc63d387SDean Nelson  *
12bc63d387SDean Nelson  *      Architecture specific implementation of common functions.
13bc63d387SDean Nelson  *
14bc63d387SDean Nelson  */
15bc63d387SDean Nelson 
16a812dcc3SDean Nelson #include <linux/device.h>
17a812dcc3SDean Nelson #include <asm/uv/uv_hub.h>
18a812dcc3SDean Nelson #include "../sgi-gru/grukservices.h"
19bc63d387SDean Nelson #include "xp.h"
20bc63d387SDean Nelson 
21a812dcc3SDean Nelson /*
22a812dcc3SDean Nelson  * Convert a virtual memory address to a physical memory address.
23a812dcc3SDean Nelson  */
24a812dcc3SDean Nelson static unsigned long
25a812dcc3SDean Nelson xp_pa_uv(void *addr)
26908787dbSDean Nelson {
27a812dcc3SDean Nelson 	return uv_gpa(addr);
28a812dcc3SDean Nelson }
29a812dcc3SDean Nelson 
30a812dcc3SDean Nelson static enum xp_retval
31a812dcc3SDean Nelson xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
32a812dcc3SDean Nelson 		    size_t len)
33a812dcc3SDean Nelson {
34a812dcc3SDean Nelson 	int ret;
35a812dcc3SDean Nelson 
36a812dcc3SDean Nelson 	ret = gru_copy_gpa(dst_gpa, src_gpa, len);
37a812dcc3SDean Nelson 	if (ret == 0)
38a812dcc3SDean Nelson 		return xpSuccess;
39a812dcc3SDean Nelson 
40a812dcc3SDean Nelson 	dev_err(xp, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
41a812dcc3SDean Nelson 		"len=%ld\n", dst_gpa, src_gpa, len);
42a812dcc3SDean Nelson 	return xpGruCopyError;
43908787dbSDean Nelson }
44908787dbSDean Nelson 
45*5b8669dfSDean Nelson static int
46*5b8669dfSDean Nelson xp_cpu_to_nasid_uv(int cpuid)
47*5b8669dfSDean Nelson {
48*5b8669dfSDean Nelson 	/* ??? Is this same as sn2 nasid in mach/part bitmaps set up by SAL? */
49*5b8669dfSDean Nelson 	return UV_PNODE_TO_NASID(uv_cpu_to_pnode(cpuid));
50*5b8669dfSDean Nelson }
51*5b8669dfSDean Nelson 
52bc63d387SDean Nelson enum xp_retval
53bc63d387SDean Nelson xp_init_uv(void)
54bc63d387SDean Nelson {
55bc63d387SDean Nelson 	BUG_ON(!is_uv());
56bc63d387SDean Nelson 
57bc63d387SDean Nelson 	xp_max_npartitions = XP_MAX_NPARTITIONS_UV;
58*5b8669dfSDean Nelson 	xp_partition_id = 0;	/* !!! not correct value */
59*5b8669dfSDean Nelson 	xp_region_size = 0;	/* !!! not correct value */
60908787dbSDean Nelson 
61a812dcc3SDean Nelson 	xp_pa = xp_pa_uv;
62908787dbSDean Nelson 	xp_remote_memcpy = xp_remote_memcpy_uv;
63*5b8669dfSDean Nelson 	xp_cpu_to_nasid = xp_cpu_to_nasid_uv;
64908787dbSDean Nelson 
65908787dbSDean Nelson 	return xpSuccess;
66bc63d387SDean Nelson }
67bc63d387SDean Nelson 
68bc63d387SDean Nelson void
69bc63d387SDean Nelson xp_exit_uv(void)
70bc63d387SDean Nelson {
71bc63d387SDean Nelson 	BUG_ON(!is_uv());
72bc63d387SDean Nelson }
73