xref: /openbmc/linux/drivers/misc/sgi-xp/xp_uv.c (revision a812dcc3a298eef650c381e094e2cf41a4ecc9ad)
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 
16*a812dcc3SDean Nelson #include <linux/device.h>
17*a812dcc3SDean Nelson #include <asm/uv/uv_hub.h>
18*a812dcc3SDean Nelson #include "../sgi-gru/grukservices.h"
19bc63d387SDean Nelson #include "xp.h"
20bc63d387SDean Nelson 
21*a812dcc3SDean Nelson /*
22*a812dcc3SDean Nelson  * Convert a virtual memory address to a physical memory address.
23*a812dcc3SDean Nelson  */
24*a812dcc3SDean Nelson static unsigned long
25*a812dcc3SDean Nelson xp_pa_uv(void *addr)
26908787dbSDean Nelson {
27*a812dcc3SDean Nelson 	return uv_gpa(addr);
28*a812dcc3SDean Nelson }
29*a812dcc3SDean Nelson 
30*a812dcc3SDean Nelson static enum xp_retval
31*a812dcc3SDean Nelson xp_remote_memcpy_uv(unsigned long dst_gpa, const unsigned long src_gpa,
32*a812dcc3SDean Nelson 		    size_t len)
33*a812dcc3SDean Nelson {
34*a812dcc3SDean Nelson 	int ret;
35*a812dcc3SDean Nelson 
36*a812dcc3SDean Nelson 	ret = gru_copy_gpa(dst_gpa, src_gpa, len);
37*a812dcc3SDean Nelson 	if (ret == 0)
38*a812dcc3SDean Nelson 		return xpSuccess;
39*a812dcc3SDean Nelson 
40*a812dcc3SDean Nelson 	dev_err(xp, "gru_copy_gpa() failed, dst_gpa=0x%016lx src_gpa=0x%016lx "
41*a812dcc3SDean Nelson 		"len=%ld\n", dst_gpa, src_gpa, len);
42*a812dcc3SDean Nelson 	return xpGruCopyError;
43908787dbSDean Nelson }
44908787dbSDean Nelson 
45bc63d387SDean Nelson enum xp_retval
46bc63d387SDean Nelson xp_init_uv(void)
47bc63d387SDean Nelson {
48bc63d387SDean Nelson 	BUG_ON(!is_uv());
49bc63d387SDean Nelson 
50bc63d387SDean Nelson 	xp_max_npartitions = XP_MAX_NPARTITIONS_UV;
51908787dbSDean Nelson 
52*a812dcc3SDean Nelson 	xp_pa = xp_pa_uv;
53908787dbSDean Nelson 	xp_remote_memcpy = xp_remote_memcpy_uv;
54908787dbSDean Nelson 
55908787dbSDean Nelson 	return xpSuccess;
56bc63d387SDean Nelson }
57bc63d387SDean Nelson 
58bc63d387SDean Nelson void
59bc63d387SDean Nelson xp_exit_uv(void)
60bc63d387SDean Nelson {
61bc63d387SDean Nelson 	BUG_ON(!is_uv());
62bc63d387SDean Nelson }
63