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) sn2-based functions.
12 * Architecture specific implementation of common functions.
15 #include <linux/device.h>
16 #include <asm/sn/bte.h>
17 #include <asm/sn/sn_sal.h>
21 * The export of xp_nofault_PIOR needs to happen here since it is defined
22 * in drivers/misc/sgi-xp/xp_nofault.S. The target of the nofault read is
25 EXPORT_SYMBOL_GPL(xp_nofault_PIOR
);
27 u64 xp_nofault_PIOR_target
;
28 EXPORT_SYMBOL_GPL(xp_nofault_PIOR_target
);
31 * Register a nofault code region which performs a cross-partition PIO read.
32 * If the PIO read times out, the MCA handler will consume the error and
33 * return to a kernel-provided instruction to indicate an error. This PIO read
34 * exists because it is guaranteed to timeout if the destination is down
35 * (amo operations do not timeout on at least some CPUs on Shubs <= v1.2,
36 * which unfortunately we have to work around).
39 xp_register_nofault_code_sn2(void)
45 func_addr
= *(u64
*)xp_nofault_PIOR
;
46 err_func_addr
= *(u64
*)xp_error_PIOR
;
47 ret
= sn_register_nofault_code(func_addr
, err_func_addr
, err_func_addr
,
50 dev_err(xp
, "can't register nofault code, error=%d\n", ret
);
54 * Setup the nofault PIO read target. (There is no special reason why
55 * SH_IPI_ACCESS was selected.)
58 xp_nofault_PIOR_target
= SH1_IPI_ACCESS
;
60 xp_nofault_PIOR_target
= SH2_IPI_ACCESS0
;
66 xp_unregister_nofault_code_sn2(void)
68 u64 func_addr
= *(u64
*)xp_nofault_PIOR
;
69 u64 err_func_addr
= *(u64
*)xp_error_PIOR
;
71 /* unregister the PIO read nofault code region */
72 (void)sn_register_nofault_code(func_addr
, err_func_addr
,
77 * Wrapper for bte_copy().
79 * vdst - virtual address of the destination of the transfer.
80 * psrc - physical address of the source of the transfer.
81 * len - number of bytes to transfer from source to destination.
83 * Note: xp_remote_memcpy_sn2() should never be called while holding a spinlock.
86 xp_remote_memcpy_sn2(void *vdst
, const void *psrc
, size_t len
)
89 u64 pdst
= ia64_tpa(vdst
);
90 /* >>> What are the rules governing the src and dst addresses passed in?
91 * >>> Currently we're assuming that dst is a virtual address and src
92 * >>> is a physical address, is this appropriate? Can we allow them to
93 * >>> be whatever and we make the change here without damaging the
98 * Ensure that the physically mapped memory is contiguous.
100 * We do this by ensuring that the memory is from region 7 only.
101 * If the need should arise to use memory from one of the other
102 * regions, then modify the BUG_ON() statement to ensure that the
103 * memory from that region is always physically contiguous.
105 BUG_ON(REGION_NUMBER(vdst
) != RGN_KERNEL
);
107 ret
= bte_copy((u64
)psrc
, pdst
, len
, (BTE_NOTIFY
| BTE_WACQUIRE
), NULL
);
108 if (ret
== BTE_SUCCESS
)
112 dev_err(xp
, "bte_copy() on shub2 failed, error=0x%x\n", ret
);
114 dev_err(xp
, "bte_copy() failed, error=%d\n", ret
);
116 return xpBteCopyError
;
124 xp_max_npartitions
= XP_MAX_NPARTITIONS_SN2
;
126 xp_remote_memcpy
= xp_remote_memcpy_sn2
;
128 return xp_register_nofault_code_sn2();
136 xp_unregister_nofault_code_sn2();