12 #include <linux/kernel.h>
15 #include <linux/sched.h>
20 #include <linux/module.h>
21 #include <linux/bitops.h>
26 #include <asm/processor.h>
29 #include <asm/delay.h>
34 #include <asm/hw_irq.h>
35 #include <asm/current.h>
38 #include <asm/sn/addrs.h>
50 static int sn2_flush_opt = 0;
54 volatile unsigned long *,
unsigned long,
55 volatile unsigned long *,
unsigned long);
58 volatile unsigned long *,
unsigned long,
59 volatile unsigned long *,
unsigned long);
66 #define local_node_uses_ptc_ga(sh1) ((sh1) ? 1 : 0)
67 #define max_active_pio(sh1) ((sh1) ? 32 : 7)
68 #define reset_max_active_on_deadlock() 1
69 #define PTC_LOCK(sh1) ((sh1) ? &sn2_global_ptc_lock : &sn_nodepda->ptc_lock)
88 static inline unsigned long wait_piowc(
void)
90 volatile unsigned long *piows;
91 unsigned long zeroval,
ws;
93 piows =
pda->pio_write_status_addr;
94 zeroval =
pda->pio_write_status_val;
130 sn2_ipi_flush_all_tlb(
struct mm_struct *mm)
134 itc = ia64_get_itc();
136 itc = ia64_get_itc() - itc;
165 unsigned long end,
unsigned long nbits)
167 int i, ibegin, shub1, cnode, mynasid,
cpu, lcpu = 0, nasid;
170 volatile unsigned long *ptc0, *ptc1;
171 unsigned long itc, itc2,
flags,
data0 = 0,
data1 = 0, rr_value, old_rr = 0;
174 int active, max_active, deadlock, flush_opt = sn2_flush_opt;
177 sn2_ipi_flush_all_tlb(mm);
199 start += (1
UL << nbits);
200 }
while (start < end);
214 if (flush_opt == 2) {
215 sn2_ipi_flush_all_tlb(mm);
220 itc = ia64_get_itc();
249 itc = ia64_get_itc();
251 itc2 = ia64_get_itc();
259 if (use_cpu_ptcga && !mymm) {
261 ia64_set_rr(start, (old_rr & 0xff) | (rr_value << 8));
273 for (ibegin = 0, i = 0; i < nix; i++) {
275 if (use_cpu_ptcga &&
unlikely(nasid == mynasid)) {
285 if (active >= max_active || i == (nix - 1)) {
286 if ((deadlock = wait_piowc())) {
297 start += (1
UL << nbits);
298 }
while (start < end);
301 itc2 = ia64_get_itc() - itc2;
311 spin_unlock_irqrestore(
PTC_LOCK(shub1), flags);
313 if (flush_opt == 1 && deadlock) {
315 sn2_ipi_flush_all_tlb(mm);
331 volatile unsigned long *ptc0,
unsigned long data0,
332 volatile unsigned long *ptc1,
unsigned long data1)
335 unsigned long *piows, zeroval,
n;
339 piows = (
unsigned long *)
pda->pio_write_status_addr;
340 zeroval =
pda->pio_write_status_val;
343 for (i=ib; i <= ie; i++) {
377 unsigned long flags = 0;
394 spin_unlock_irqrestore(&sn2_global_ptc_lock, flags);
427 ia64_sn_get_sapic_info(physid, &nasid,
NULL,
NULL);
432 #ifdef CONFIG_HOTPLUG_CPU
447 "Disabling the boot processor is not allowed.\n");
451 "CPU disable is not supported on this system.\n");
457 #ifdef CONFIG_PROC_FS
459 #define PTC_BASENAME "sgi_sn/ptc_statistics"
463 if (*offset < nr_cpu_ids)
468 static void *sn2_ptc_seq_next(
struct seq_file *file,
void *
data, loff_t * offset)
471 if (*offset < nr_cpu_ids)
476 static void sn2_ptc_seq_stop(
struct seq_file *file,
void *data)
480 static int sn2_ptc_seq_show(
struct seq_file *file,
void *data)
485 cpu = *(loff_t *) data;
489 "# cpu ptc_l newrid ptc_flushes nodes_flushed deadlocks lock_nsec shub_nsec shub_nsec_max not_my_mm deadlock2 ipi_fluches ipi_nsec\n");
494 stat = &
per_cpu(ptcstats, cpu);
495 seq_printf(file,
"cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", cpu, stat->
ptc_l,
509 static ssize_t sn2_ptc_proc_write(
struct file *file,
const char __user *
user,
size_t count, loff_t *data)
514 if (count == 0 || count >
sizeof(optstr))
518 optstr[count - 1] =
'\0';
528 .
start = sn2_ptc_seq_start,
529 .next = sn2_ptc_seq_next,
530 .stop = sn2_ptc_seq_stop,
531 .show = sn2_ptc_seq_show
534 static int sn2_ptc_proc_open(
struct inode *
inode,
struct file *file)
536 return seq_open(file, &sn2_ptc_seq_ops);
540 .
open = sn2_ptc_proc_open,
542 .write = sn2_ptc_proc_write,
549 static int __init sn2_ptc_init(
void)
554 proc_sn2_ptc = proc_create(PTC_BASENAME, 0444,
555 NULL, &proc_sn2_ptc_operations);
564 static void __exit sn2_ptc_exit(
void)