9 #include <linux/module.h>
11 #include <asm/sn/addrs.h>
12 #include <asm/sn/arch.h>
17 #include <asm/delay.h>
20 #include <linux/string.h>
21 #include <linux/sched.h>
22 #include <linux/slab.h>
27 #define L1_CACHE_MASK (L1_CACHE_BYTES - 1)
31 #define MAX_INTERFACES_TO_TRY 4
32 #define MAX_NODES_TO_TRY 2
87 unsigned long irq_flags;
88 unsigned long itc_end = 0;
91 int bte_if_index, nasid_index;
94 BTE_PRINTK((
"bte_copy(0x%lx, 0x%lx, 0x%lx, 0x%lx, 0x%p)\n",
95 src, dest, len, mode, notification));
102 BUG_ON(src & L1_CACHE_MASK);
103 BUG_ON(dest & L1_CACHE_MASK);
115 nasid_to_try[1] = my_nasid;
121 nasid_to_try[0] = my_nasid;
133 bte_if_index = bte_first;
138 bte = bte_if_on_node(nasid_to_try[nasid_index],bte_if_index);
156 bte_if_index = (bte_if_index + 1) % btes_per_node;
157 if (bte_if_index == bte_first) {
178 if (notification ==
NULL) {
206 itc_end = ia64_get_itc() + (40000000 *
local_cpu_data->cyc_per_usec);
208 spin_unlock_irqrestore(&bte->
spinlock, irq_flags);
210 if (notification !=
NULL) {
216 if (ia64_get_itc() > itc_end) {
217 BTE_PRINTK((
"BTE timeout nasid 0x%x bte%d IBLS = 0x%lx na 0x%lx\n",
228 BTE_PRINTKV((
" Delay Done. IBLS = 0x%lx, most_rcnt_na = 0x%lx\n",
238 BTE_PRINTK((
"Returning status is 0x%lx and most_rcnt_na is 0x%lx\n",
264 int destFirstCacheOffset;
267 u64 headBcopySrcOffset;
275 char *bteBlock, *bteBlock_unaligned;
283 if (bteBlock_unaligned ==
NULL) {
311 if (headBcopySrcOffset == destFirstCacheOffset) {
319 headBteSource = src & ~L1_CACHE_MASK;
320 headBcopyDest =
dest;
321 if (headBcopySrcOffset) {
326 - headBcopySrcOffset : len);
333 if (len > headBcopyLen) {
334 footBcopyLen = (len - headBcopyLen) & L1_CACHE_MASK;
337 footBteSource = src + len - footBcopyLen;
338 footBcopyDest = dest + len - footBcopyLen;
340 if (footBcopyDest == (headBcopyDest + headBcopyLen)) {
345 headBcopyLen += footBcopyLen;
346 headBteLen += footBteLen;
347 }
else if (footBcopyLen > 0) {
350 footBteLen, mode,
NULL);
352 kfree(bteBlock_unaligned);
357 (
char *)bteBlock, footBcopyLen);
364 if (len > (headBcopyLen + footBcopyLen)) {
369 (len - headBcopyLen -
370 footBcopyLen), mode,
NULL);
372 kfree(bteBlock_unaligned);
387 headBcopyDest =
dest;
390 headBteSource = src - headBcopySrcOffset;
395 if (headBcopyLen > 0) {
397 ia64_tpa((
unsigned long)bteBlock), headBteLen,
400 kfree(bteBlock_unaligned);
404 memcpy(
__va(headBcopyDest), ((
char *)bteBlock +
405 headBcopySrcOffset), headBcopyLen);
407 kfree(bteBlock_unaligned);
449 mynodepda->
bte_if[
i].bte_base_addr = base_addr;
459 mynodepda->
bte_if[
i].most_rcnt_na =
460 &(mynodepda->
bte_if[
i].notify);
464 mynodepda->
bte_if[
i].bte_cnode = cnode;
465 mynodepda->
bte_if[
i].bte_error_count = 0;
467 mynodepda->
bte_if[
i].cleanup_active = 0;
468 mynodepda->
bte_if[
i].bh_error = 0;