Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1 | /* |
| 2 | * SGI UltraViolet TLB flush routines. |
| 3 | * |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 4 | * (c) 2008-2014 Cliff Wickman <cpw@sgi.com>, SGI. |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 5 | * |
| 6 | * This code is released under the GNU General Public License version 2 or |
| 7 | * later. |
| 8 | */ |
Jeremy Fitzhardinge | aef8f5b | 2008-10-14 21:43:43 -0700 | [diff] [blame] | 9 | #include <linux/seq_file.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 10 | #include <linux/proc_fs.h> |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 11 | #include <linux/debugfs.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 12 | #include <linux/kernel.h> |
Tejun Heo | 5a0e3ad | 2010-03-24 17:04:11 +0900 | [diff] [blame] | 13 | #include <linux/slab.h> |
Jean Delvare | ca444564 | 2011-03-25 15:20:14 +0100 | [diff] [blame] | 14 | #include <linux/delay.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 15 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 16 | #include <asm/mmu_context.h> |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 17 | #include <asm/uv/uv.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 18 | #include <asm/uv/uv_mmrs.h> |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 19 | #include <asm/uv/uv_hub.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 20 | #include <asm/uv/uv_bau.h> |
Ingo Molnar | 7b6aa33 | 2009-02-17 13:58:15 +0100 | [diff] [blame] | 21 | #include <asm/apic.h> |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 22 | #include <asm/idle.h> |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 23 | #include <asm/tsc.h> |
Cliff Wickman | 99dd871 | 2008-08-19 12:51:59 -0500 | [diff] [blame] | 24 | #include <asm/irq_vectors.h> |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 25 | #include <asm/timer.h> |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 26 | |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 27 | /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */ |
| 28 | static int timeout_base_ns[] = { |
| 29 | 20, |
| 30 | 160, |
| 31 | 1280, |
| 32 | 10240, |
| 33 | 81920, |
| 34 | 655360, |
| 35 | 5242880, |
| 36 | 167772160 |
| 37 | }; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 38 | |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 39 | static int timeout_us; |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 40 | static bool nobau = true; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 41 | static int nobau_perm; |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 42 | static cycles_t congested_cycles; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 43 | |
| 44 | /* tunables: */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 45 | static int max_concurr = MAX_BAU_CONCURRENT; |
| 46 | static int max_concurr_const = MAX_BAU_CONCURRENT; |
| 47 | static int plugged_delay = PLUGGED_DELAY; |
| 48 | static int plugsb4reset = PLUGSB4RESET; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 49 | static int giveup_limit = GIVEUP_LIMIT; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 50 | static int timeoutsb4reset = TIMEOUTSB4RESET; |
| 51 | static int ipi_reset_limit = IPI_RESET_LIMIT; |
| 52 | static int complete_threshold = COMPLETE_THRESHOLD; |
| 53 | static int congested_respns_us = CONGESTED_RESPONSE_US; |
| 54 | static int congested_reps = CONGESTED_REPS; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 55 | static int disabled_period = DISABLED_PERIOD; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 56 | |
| 57 | static struct tunables tunables[] = { |
| 58 | {&max_concurr, MAX_BAU_CONCURRENT}, /* must be [0] */ |
| 59 | {&plugged_delay, PLUGGED_DELAY}, |
| 60 | {&plugsb4reset, PLUGSB4RESET}, |
| 61 | {&timeoutsb4reset, TIMEOUTSB4RESET}, |
| 62 | {&ipi_reset_limit, IPI_RESET_LIMIT}, |
| 63 | {&complete_threshold, COMPLETE_THRESHOLD}, |
| 64 | {&congested_respns_us, CONGESTED_RESPONSE_US}, |
| 65 | {&congested_reps, CONGESTED_REPS}, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 66 | {&disabled_period, DISABLED_PERIOD}, |
| 67 | {&giveup_limit, GIVEUP_LIMIT} |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 68 | }; |
| 69 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 70 | static struct dentry *tunables_dir; |
| 71 | static struct dentry *tunables_file; |
| 72 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 73 | /* these correspond to the statistics printed by ptc_seq_show() */ |
| 74 | static char *stat_description[] = { |
| 75 | "sent: number of shootdown messages sent", |
| 76 | "stime: time spent sending messages", |
| 77 | "numuvhubs: number of hubs targeted with shootdown", |
| 78 | "numuvhubs16: number times 16 or more hubs targeted", |
| 79 | "numuvhubs8: number times 8 or more hubs targeted", |
| 80 | "numuvhubs4: number times 4 or more hubs targeted", |
| 81 | "numuvhubs2: number times 2 or more hubs targeted", |
| 82 | "numuvhubs1: number times 1 hub targeted", |
| 83 | "numcpus: number of cpus targeted with shootdown", |
| 84 | "dto: number of destination timeouts", |
| 85 | "retries: destination timeout retries sent", |
| 86 | "rok: : destination timeouts successfully retried", |
| 87 | "resetp: ipi-style resource resets for plugs", |
| 88 | "resett: ipi-style resource resets for timeouts", |
| 89 | "giveup: fall-backs to ipi-style shootdowns", |
| 90 | "sto: number of source timeouts", |
| 91 | "bz: number of stay-busy's", |
| 92 | "throt: number times spun in throttle", |
| 93 | "swack: image of UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE", |
| 94 | "recv: shootdown messages received", |
| 95 | "rtime: time spent processing messages", |
| 96 | "all: shootdown all-tlb messages", |
| 97 | "one: shootdown one-tlb messages", |
| 98 | "mult: interrupts that found multiple messages", |
| 99 | "none: interrupts that found no messages", |
| 100 | "retry: number of retry messages processed", |
| 101 | "canc: number messages canceled by retries", |
| 102 | "nocan: number retries that found nothing to cancel", |
| 103 | "reset: number of ipi-style reset requests processed", |
| 104 | "rcan: number messages canceled by reset requests", |
| 105 | "disable: number times use of the BAU was disabled", |
| 106 | "enable: number times use of the BAU was re-enabled" |
| 107 | }; |
| 108 | |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 109 | static int __init setup_bau(char *arg) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 110 | { |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 111 | int result; |
| 112 | |
| 113 | if (!arg) |
| 114 | return -EINVAL; |
| 115 | |
| 116 | result = strtobool(arg, &nobau); |
| 117 | if (result) |
| 118 | return result; |
| 119 | |
| 120 | /* we need to flip the logic here, so that bau=y sets nobau to false */ |
| 121 | nobau = !nobau; |
| 122 | |
| 123 | if (!nobau) |
| 124 | pr_info("UV BAU Enabled\n"); |
| 125 | else |
| 126 | pr_info("UV BAU Disabled\n"); |
| 127 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 128 | return 0; |
| 129 | } |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 130 | early_param("bau", setup_bau); |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 131 | |
Cliff Wickman | 94ca8e4 | 2009-04-14 10:56:48 -0500 | [diff] [blame] | 132 | /* base pnode in this partition */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 133 | static int uv_base_pnode __read_mostly; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 134 | |
Ingo Molnar | dc163a4 | 2008-06-18 14:15:43 +0200 | [diff] [blame] | 135 | static DEFINE_PER_CPU(struct ptc_stats, ptcstats); |
| 136 | static DEFINE_PER_CPU(struct bau_control, bau_control); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 137 | static DEFINE_PER_CPU(cpumask_var_t, uv_flush_tlb_mask); |
| 138 | |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 139 | static void |
| 140 | set_bau_on(void) |
| 141 | { |
| 142 | int cpu; |
| 143 | struct bau_control *bcp; |
| 144 | |
| 145 | if (nobau_perm) { |
| 146 | pr_info("BAU not initialized; cannot be turned on\n"); |
| 147 | return; |
| 148 | } |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 149 | nobau = false; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 150 | for_each_present_cpu(cpu) { |
| 151 | bcp = &per_cpu(bau_control, cpu); |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 152 | bcp->nobau = false; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 153 | } |
| 154 | pr_info("BAU turned on\n"); |
| 155 | return; |
| 156 | } |
| 157 | |
| 158 | static void |
| 159 | set_bau_off(void) |
| 160 | { |
| 161 | int cpu; |
| 162 | struct bau_control *bcp; |
| 163 | |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 164 | nobau = true; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 165 | for_each_present_cpu(cpu) { |
| 166 | bcp = &per_cpu(bau_control, cpu); |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 167 | bcp->nobau = true; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 168 | } |
| 169 | pr_info("BAU turned off\n"); |
| 170 | return; |
| 171 | } |
| 172 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 173 | /* |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 174 | * Determine the first node on a uvhub. 'Nodes' are used for kernel |
| 175 | * memory allocation. |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 176 | */ |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 177 | static int __init uvhub_to_first_node(int uvhub) |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 178 | { |
| 179 | int node, b; |
| 180 | |
| 181 | for_each_online_node(node) { |
| 182 | b = uv_node_to_blade_id(node); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 183 | if (uvhub == b) |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 184 | return node; |
| 185 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 186 | return -1; |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | /* |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 190 | * Determine the apicid of the first cpu on a uvhub. |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 191 | */ |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 192 | static int __init uvhub_to_first_apicid(int uvhub) |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 193 | { |
| 194 | int cpu; |
| 195 | |
| 196 | for_each_present_cpu(cpu) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 197 | if (uvhub == uv_cpu_to_blade_id(cpu)) |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 198 | return per_cpu(x86_cpu_to_apicid, cpu); |
| 199 | return -1; |
| 200 | } |
| 201 | |
| 202 | /* |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 203 | * Free a software acknowledge hardware resource by clearing its Pending |
| 204 | * bit. This will return a reply to the sender. |
| 205 | * If the message has timed out, a reply has already been sent by the |
| 206 | * hardware but the resource has not been released. In that case our |
| 207 | * clear of the Timeout bit (as well) will free the resource. No reply will |
| 208 | * be sent (the hardware will only do one reply per message). |
| 209 | */ |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 210 | static void reply_to_message(struct msg_desc *mdp, struct bau_control *bcp, |
| 211 | int do_acknowledge) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 212 | { |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 213 | unsigned long dw; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 214 | struct bau_pq_entry *msg; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 215 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 216 | msg = mdp->msg; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 217 | if (!msg->canceled && do_acknowledge) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 218 | dw = (msg->swack_vec << UV_SW_ACK_NPENDING) | msg->swack_vec; |
| 219 | write_mmr_sw_ack(dw); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 220 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 221 | msg->replied_to = 1; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 222 | msg->swack_vec = 0; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 223 | } |
| 224 | |
| 225 | /* |
| 226 | * Process the receipt of a RETRY message |
| 227 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 228 | static void bau_process_retry_msg(struct msg_desc *mdp, |
| 229 | struct bau_control *bcp) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 230 | { |
| 231 | int i; |
| 232 | int cancel_count = 0; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 233 | unsigned long msg_res; |
| 234 | unsigned long mmr = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 235 | struct bau_pq_entry *msg = mdp->msg; |
| 236 | struct bau_pq_entry *msg2; |
| 237 | struct ptc_stats *stat = bcp->statp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 238 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 239 | stat->d_retries++; |
| 240 | /* |
| 241 | * cancel any message from msg+1 to the retry itself |
| 242 | */ |
| 243 | for (msg2 = msg+1, i = 0; i < DEST_Q_SIZE; msg2++, i++) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 244 | if (msg2 > mdp->queue_last) |
| 245 | msg2 = mdp->queue_first; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 246 | if (msg2 == msg) |
| 247 | break; |
| 248 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 249 | /* same conditions for cancellation as do_reset */ |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 250 | if ((msg2->replied_to == 0) && (msg2->canceled == 0) && |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 251 | (msg2->swack_vec) && ((msg2->swack_vec & |
| 252 | msg->swack_vec) == 0) && |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 253 | (msg2->sending_cpu == msg->sending_cpu) && |
| 254 | (msg2->msg_type != MSG_NOOP)) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 255 | mmr = read_mmr_sw_ack(); |
| 256 | msg_res = msg2->swack_vec; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 257 | /* |
| 258 | * This is a message retry; clear the resources held |
| 259 | * by the previous message only if they timed out. |
| 260 | * If it has not timed out we have an unexpected |
| 261 | * situation to report. |
| 262 | */ |
Cliff Wickman | 39847e7 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 263 | if (mmr & (msg_res << UV_SW_ACK_NPENDING)) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 264 | unsigned long mr; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 265 | /* |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 266 | * Is the resource timed out? |
| 267 | * Make everyone ignore the cancelled message. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 268 | */ |
| 269 | msg2->canceled = 1; |
| 270 | stat->d_canceled++; |
| 271 | cancel_count++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 272 | mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res; |
| 273 | write_mmr_sw_ack(mr); |
Cliff Wickman | 39847e7 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 274 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 275 | } |
| 276 | } |
| 277 | if (!cancel_count) |
| 278 | stat->d_nocanceled++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 279 | } |
| 280 | |
| 281 | /* |
| 282 | * Do all the things a cpu should do for a TLB shootdown message. |
| 283 | * Other cpu's may come here at the same time for this message. |
| 284 | */ |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 285 | static void bau_process_message(struct msg_desc *mdp, struct bau_control *bcp, |
| 286 | int do_acknowledge) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 287 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 288 | short socket_ack_count = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 289 | short *sp; |
| 290 | struct atomic_short *asp; |
| 291 | struct ptc_stats *stat = bcp->statp; |
| 292 | struct bau_pq_entry *msg = mdp->msg; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 293 | struct bau_control *smaster = bcp->socket_master; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 294 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 295 | /* |
| 296 | * This must be a normal message, or retry of a normal message |
| 297 | */ |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 298 | if (msg->address == TLB_FLUSH_ALL) { |
| 299 | local_flush_tlb(); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 300 | stat->d_alltlb++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 301 | } else { |
| 302 | __flush_tlb_one(msg->address); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 303 | stat->d_onetlb++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 304 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 305 | stat->d_requestee++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 306 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 307 | /* |
| 308 | * One cpu on each uvhub has the additional job on a RETRY |
| 309 | * of releasing the resource held by the message that is |
| 310 | * being retried. That message is identified by sending |
| 311 | * cpu number. |
| 312 | */ |
| 313 | if (msg->msg_type == MSG_RETRY && bcp == bcp->uvhub_master) |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 314 | bau_process_retry_msg(mdp, bcp); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 315 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 316 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 317 | * This is a swack message, so we have to reply to it. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 318 | * Count each responding cpu on the socket. This avoids |
| 319 | * pinging the count's cache line back and forth between |
| 320 | * the sockets. |
| 321 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 322 | sp = &smaster->socket_acknowledge_count[mdp->msg_slot]; |
| 323 | asp = (struct atomic_short *)sp; |
| 324 | socket_ack_count = atom_asr(1, asp); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 325 | if (socket_ack_count == bcp->cpus_in_socket) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 326 | int msg_ack_count; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 327 | /* |
| 328 | * Both sockets dump their completed count total into |
| 329 | * the message's count. |
| 330 | */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 331 | *sp = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 332 | asp = (struct atomic_short *)&msg->acknowledge_count; |
| 333 | msg_ack_count = atom_asr(socket_ack_count, asp); |
Ingo Molnar | dc163a4 | 2008-06-18 14:15:43 +0200 | [diff] [blame] | 334 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 335 | if (msg_ack_count == bcp->cpus_in_uvhub) { |
| 336 | /* |
| 337 | * All cpus in uvhub saw it; reply |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 338 | * (unless we are in the UV2 workaround) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 339 | */ |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 340 | reply_to_message(mdp, bcp, do_acknowledge); |
Ingo Molnar | dc163a4 | 2008-06-18 14:15:43 +0200 | [diff] [blame] | 341 | } |
| 342 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 343 | |
| 344 | return; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 345 | } |
| 346 | |
| 347 | /* |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 348 | * Determine the first cpu on a pnode. |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 349 | */ |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 350 | static int pnode_to_first_cpu(int pnode, struct bau_control *smaster) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 351 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 352 | int cpu; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 353 | struct hub_and_pnode *hpp; |
| 354 | |
| 355 | for_each_present_cpu(cpu) { |
| 356 | hpp = &smaster->thp[cpu]; |
| 357 | if (pnode == hpp->pnode) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 358 | return cpu; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 359 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 360 | return -1; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 361 | } |
| 362 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 363 | /* |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 364 | * Last resort when we get a large number of destination timeouts is |
| 365 | * to clear resources held by a given cpu. |
| 366 | * Do this with IPI so that all messages in the BAU message queue |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 367 | * can be identified by their nonzero swack_vec field. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 368 | * |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 369 | * This is entered for a single cpu on the uvhub. |
| 370 | * The sender want's this uvhub to free a specific message's |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 371 | * swack resources. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 372 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 373 | static void do_reset(void *ptr) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 374 | { |
| 375 | int i; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 376 | struct bau_control *bcp = &per_cpu(bau_control, smp_processor_id()); |
| 377 | struct reset_args *rap = (struct reset_args *)ptr; |
| 378 | struct bau_pq_entry *msg; |
| 379 | struct ptc_stats *stat = bcp->statp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 380 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 381 | stat->d_resets++; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 382 | /* |
| 383 | * We're looking for the given sender, and |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 384 | * will free its swack resource. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 385 | * If all cpu's finally responded after the timeout, its |
| 386 | * message 'replied_to' was set. |
| 387 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 388 | for (msg = bcp->queue_first, i = 0; i < DEST_Q_SIZE; msg++, i++) { |
| 389 | unsigned long msg_res; |
| 390 | /* do_reset: same conditions for cancellation as |
| 391 | bau_process_retry_msg() */ |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 392 | if ((msg->replied_to == 0) && |
| 393 | (msg->canceled == 0) && |
| 394 | (msg->sending_cpu == rap->sender) && |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 395 | (msg->swack_vec) && |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 396 | (msg->msg_type != MSG_NOOP)) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 397 | unsigned long mmr; |
| 398 | unsigned long mr; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 399 | /* |
| 400 | * make everyone else ignore this message |
| 401 | */ |
| 402 | msg->canceled = 1; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 403 | /* |
| 404 | * only reset the resource if it is still pending |
| 405 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 406 | mmr = read_mmr_sw_ack(); |
| 407 | msg_res = msg->swack_vec; |
| 408 | mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 409 | if (mmr & msg_res) { |
| 410 | stat->d_rcanceled++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 411 | write_mmr_sw_ack(mr); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 412 | } |
| 413 | } |
| 414 | } |
| 415 | return; |
| 416 | } |
| 417 | |
| 418 | /* |
| 419 | * Use IPI to get all target uvhubs to release resources held by |
| 420 | * a given sending cpu number. |
| 421 | */ |
cpw@sgi.com | a456eaa | 2011-06-21 07:21:30 -0500 | [diff] [blame] | 422 | static void reset_with_ipi(struct pnmask *distribution, struct bau_control *bcp) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 423 | { |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 424 | int pnode; |
| 425 | int apnode; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 426 | int maskbits; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 427 | int sender = bcp->cpu; |
cpw@sgi.com | 442d392 | 2011-06-21 07:21:31 -0500 | [diff] [blame] | 428 | cpumask_t *mask = bcp->uvhub_master->cpumask; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 429 | struct bau_control *smaster = bcp->socket_master; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 430 | struct reset_args reset_args; |
| 431 | |
| 432 | reset_args.sender = sender; |
Rusty Russell | 020b37a | 2015-03-02 22:05:49 +1030 | [diff] [blame] | 433 | cpumask_clear(mask); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 434 | /* find a single cpu for each uvhub in this distribution mask */ |
cpw@sgi.com | a456eaa | 2011-06-21 07:21:30 -0500 | [diff] [blame] | 435 | maskbits = sizeof(struct pnmask) * BITSPERBYTE; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 436 | /* each bit is a pnode relative to the partition base pnode */ |
| 437 | for (pnode = 0; pnode < maskbits; pnode++) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 438 | int cpu; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 439 | if (!bau_uvhub_isset(pnode, distribution)) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 440 | continue; |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 441 | apnode = pnode + bcp->partition_base_pnode; |
| 442 | cpu = pnode_to_first_cpu(apnode, smaster); |
Rusty Russell | 020b37a | 2015-03-02 22:05:49 +1030 | [diff] [blame] | 443 | cpumask_set_cpu(cpu, mask); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 444 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 445 | |
| 446 | /* IPI all cpus; preemption is already disabled */ |
cpw@sgi.com | 442d392 | 2011-06-21 07:21:31 -0500 | [diff] [blame] | 447 | smp_call_function_many(mask, do_reset, (void *)&reset_args, 1); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 448 | return; |
| 449 | } |
| 450 | |
Peter Zijlstra | 20d1c86 | 2013-11-29 15:40:29 +0100 | [diff] [blame] | 451 | /* |
| 452 | * Not to be confused with cycles_2_ns() from tsc.c; this gives a relative |
| 453 | * number, not an absolute. It converts a duration in cycles to a duration in |
| 454 | * ns. |
| 455 | */ |
| 456 | static inline unsigned long long cycles_2_ns(unsigned long long cyc) |
| 457 | { |
| 458 | struct cyc2ns_data *data = cyc2ns_read_begin(); |
| 459 | unsigned long long ns; |
| 460 | |
| 461 | ns = mul_u64_u32_shr(cyc, data->cyc2ns_mul, data->cyc2ns_shift); |
| 462 | |
| 463 | cyc2ns_read_end(data); |
| 464 | return ns; |
| 465 | } |
| 466 | |
| 467 | /* |
| 468 | * The reverse of the above; converts a duration in ns to a duration in cycles. |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 469 | */ |
Peter Zijlstra | 20d1c86 | 2013-11-29 15:40:29 +0100 | [diff] [blame] | 470 | static inline unsigned long long ns_2_cycles(unsigned long long ns) |
| 471 | { |
| 472 | struct cyc2ns_data *data = cyc2ns_read_begin(); |
| 473 | unsigned long long cyc; |
| 474 | |
| 475 | cyc = (ns << data->cyc2ns_shift) / data->cyc2ns_mul; |
| 476 | |
| 477 | cyc2ns_read_end(data); |
| 478 | return cyc; |
| 479 | } |
| 480 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 481 | static inline unsigned long cycles_2_us(unsigned long long cyc) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 482 | { |
Peter Zijlstra | 20d1c86 | 2013-11-29 15:40:29 +0100 | [diff] [blame] | 483 | return cycles_2_ns(cyc) / NSEC_PER_USEC; |
| 484 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 485 | |
Peter Zijlstra | 20d1c86 | 2013-11-29 15:40:29 +0100 | [diff] [blame] | 486 | static inline cycles_t sec_2_cycles(unsigned long sec) |
| 487 | { |
| 488 | return ns_2_cycles(sec * NSEC_PER_SEC); |
| 489 | } |
| 490 | |
| 491 | static inline unsigned long long usec_2_cycles(unsigned long usec) |
| 492 | { |
| 493 | return ns_2_cycles(usec * NSEC_PER_USEC); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 494 | } |
| 495 | |
| 496 | /* |
| 497 | * wait for all cpus on this hub to finish their sends and go quiet |
| 498 | * leaves uvhub_quiesce set so that no new broadcasts are started by |
| 499 | * bau_flush_send_and_wait() |
| 500 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 501 | static inline void quiesce_local_uvhub(struct bau_control *hmaster) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 502 | { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 503 | atom_asr(1, (struct atomic_short *)&hmaster->uvhub_quiesce); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 504 | } |
| 505 | |
| 506 | /* |
| 507 | * mark this quiet-requestor as done |
| 508 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 509 | static inline void end_uvhub_quiesce(struct bau_control *hmaster) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 510 | { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 511 | atom_asr(-1, (struct atomic_short *)&hmaster->uvhub_quiesce); |
| 512 | } |
| 513 | |
| 514 | static unsigned long uv1_read_status(unsigned long mmr_offset, int right_shift) |
| 515 | { |
| 516 | unsigned long descriptor_status; |
| 517 | |
| 518 | descriptor_status = uv_read_local_mmr(mmr_offset); |
| 519 | descriptor_status >>= right_shift; |
| 520 | descriptor_status &= UV_ACT_STATUS_MASK; |
| 521 | return descriptor_status; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 522 | } |
| 523 | |
| 524 | /* |
| 525 | * Wait for completion of a broadcast software ack message |
| 526 | * return COMPLETE, RETRY(PLUGGED or TIMEOUT) or GIVEUP |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 527 | */ |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 528 | static int uv1_wait_completion(struct bau_desc *bau_desc, |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 529 | unsigned long mmr_offset, int right_shift, |
| 530 | struct bau_control *bcp, long try) |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 531 | { |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 532 | unsigned long descriptor_status; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 533 | cycles_t ttm; |
Cliff Wickman | 712157a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 534 | struct ptc_stats *stat = bcp->statp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 535 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 536 | descriptor_status = uv1_read_status(mmr_offset, right_shift); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 537 | /* spin on the status MMR, waiting for it to go idle */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 538 | while ((descriptor_status != DS_IDLE)) { |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 539 | /* |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 540 | * Our software ack messages may be blocked because |
| 541 | * there are no swack resources available. As long |
| 542 | * as none of them has timed out hardware will NACK |
| 543 | * our message and its state will stay IDLE. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 544 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 545 | if (descriptor_status == DS_SOURCE_TIMEOUT) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 546 | stat->s_stimeout++; |
| 547 | return FLUSH_GIVEUP; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 548 | } else if (descriptor_status == DS_DESTINATION_TIMEOUT) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 549 | stat->s_dtimeout++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 550 | ttm = get_cycles(); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 551 | |
| 552 | /* |
| 553 | * Our retries may be blocked by all destination |
| 554 | * swack resources being consumed, and a timeout |
| 555 | * pending. In that case hardware returns the |
| 556 | * ERROR that looks like a destination timeout. |
| 557 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 558 | if (cycles_2_us(ttm - bcp->send_message) < timeout_us) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 559 | bcp->conseccompletes = 0; |
| 560 | return FLUSH_RETRY_PLUGGED; |
| 561 | } |
| 562 | |
| 563 | bcp->conseccompletes = 0; |
| 564 | return FLUSH_RETRY_TIMEOUT; |
| 565 | } else { |
| 566 | /* |
| 567 | * descriptor_status is still BUSY |
| 568 | */ |
| 569 | cpu_relax(); |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 570 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 571 | descriptor_status = uv1_read_status(mmr_offset, right_shift); |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 572 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 573 | bcp->conseccompletes++; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 574 | return FLUSH_COMPLETE; |
| 575 | } |
| 576 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 577 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 578 | * UV2 could have an extra bit of status in the ACTIVATION_STATUS_2 register. |
| 579 | * But not currently used. |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 580 | */ |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 581 | static unsigned long uv2_3_read_status(unsigned long offset, int rshft, int desc) |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 582 | { |
| 583 | unsigned long descriptor_status; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 584 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 585 | descriptor_status = |
| 586 | ((read_lmmr(offset) >> rshft) & UV_ACT_STATUS_MASK) << 1; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 587 | return descriptor_status; |
| 588 | } |
| 589 | |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 590 | /* |
| 591 | * Return whether the status of the descriptor that is normally used for this |
| 592 | * cpu (the one indexed by its hub-relative cpu number) is busy. |
| 593 | * The status of the original 32 descriptors is always reflected in the 64 |
| 594 | * bits of UVH_LB_BAU_SB_ACTIVATION_STATUS_0. |
| 595 | * The bit provided by the activation_status_2 register is irrelevant to |
| 596 | * the status if it is only being tested for busy or not busy. |
| 597 | */ |
| 598 | int normal_busy(struct bau_control *bcp) |
| 599 | { |
| 600 | int cpu = bcp->uvhub_cpu; |
| 601 | int mmr_offset; |
| 602 | int right_shift; |
| 603 | |
| 604 | mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_0; |
| 605 | right_shift = cpu * UV_ACT_STATUS_SIZE; |
| 606 | return (((((read_lmmr(mmr_offset) >> right_shift) & |
| 607 | UV_ACT_STATUS_MASK)) << 1) == UV2H_DESC_BUSY); |
| 608 | } |
| 609 | |
| 610 | /* |
| 611 | * Entered when a bau descriptor has gone into a permanent busy wait because |
| 612 | * of a hardware bug. |
| 613 | * Workaround the bug. |
| 614 | */ |
| 615 | int handle_uv2_busy(struct bau_control *bcp) |
| 616 | { |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 617 | struct ptc_stats *stat = bcp->statp; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 618 | |
| 619 | stat->s_uv2_wars++; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 620 | bcp->busy = 1; |
| 621 | return FLUSH_GIVEUP; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 622 | } |
| 623 | |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 624 | static int uv2_3_wait_completion(struct bau_desc *bau_desc, |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 625 | unsigned long mmr_offset, int right_shift, |
| 626 | struct bau_control *bcp, long try) |
| 627 | { |
| 628 | unsigned long descriptor_stat; |
| 629 | cycles_t ttm; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 630 | int desc = bcp->uvhub_cpu; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 631 | long busy_reps = 0; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 632 | struct ptc_stats *stat = bcp->statp; |
| 633 | |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 634 | descriptor_stat = uv2_3_read_status(mmr_offset, right_shift, desc); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 635 | |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 636 | /* spin on the status MMR, waiting for it to go idle */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 637 | while (descriptor_stat != UV2H_DESC_IDLE) { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 638 | if ((descriptor_stat == UV2H_DESC_SOURCE_TIMEOUT)) { |
| 639 | /* |
| 640 | * A h/w bug on the destination side may |
| 641 | * have prevented the message being marked |
| 642 | * pending, thus it doesn't get replied to |
| 643 | * and gets continually nacked until it times |
| 644 | * out with a SOURCE_TIMEOUT. |
| 645 | */ |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 646 | stat->s_stimeout++; |
| 647 | return FLUSH_GIVEUP; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 648 | } else if (descriptor_stat == UV2H_DESC_DEST_TIMEOUT) { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 649 | ttm = get_cycles(); |
| 650 | |
| 651 | /* |
| 652 | * Our retries may be blocked by all destination |
| 653 | * swack resources being consumed, and a timeout |
| 654 | * pending. In that case hardware returns the |
| 655 | * ERROR that looks like a destination timeout. |
| 656 | * Without using the extended status we have to |
| 657 | * deduce from the short time that this was a |
| 658 | * strong nack. |
| 659 | */ |
| 660 | if (cycles_2_us(ttm - bcp->send_message) < timeout_us) { |
| 661 | bcp->conseccompletes = 0; |
| 662 | stat->s_plugged++; |
| 663 | /* FLUSH_RETRY_PLUGGED causes hang on boot */ |
| 664 | return FLUSH_GIVEUP; |
| 665 | } |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 666 | stat->s_dtimeout++; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 667 | bcp->conseccompletes = 0; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 668 | /* FLUSH_RETRY_TIMEOUT causes hang on boot */ |
| 669 | return FLUSH_GIVEUP; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 670 | } else { |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 671 | busy_reps++; |
| 672 | if (busy_reps > 1000000) { |
| 673 | /* not to hammer on the clock */ |
| 674 | busy_reps = 0; |
| 675 | ttm = get_cycles(); |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 676 | if ((ttm - bcp->send_message) > bcp->timeout_interval) |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 677 | return handle_uv2_busy(bcp); |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 678 | } |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 679 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 680 | * descriptor_stat is still BUSY |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 681 | */ |
| 682 | cpu_relax(); |
| 683 | } |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 684 | descriptor_stat = uv2_3_read_status(mmr_offset, right_shift, desc); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 685 | } |
| 686 | bcp->conseccompletes++; |
| 687 | return FLUSH_COMPLETE; |
| 688 | } |
| 689 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 690 | /* |
| 691 | * There are 2 status registers; each and array[32] of 2 bits. Set up for |
| 692 | * which register to read and position in that register based on cpu in |
| 693 | * current hub. |
| 694 | */ |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 695 | static int wait_completion(struct bau_desc *bau_desc, struct bau_control *bcp, long try) |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 696 | { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 697 | int right_shift; |
| 698 | unsigned long mmr_offset; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 699 | int desc = bcp->uvhub_cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 700 | |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 701 | if (desc < UV_CPUS_PER_AS) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 702 | mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_0; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 703 | right_shift = desc * UV_ACT_STATUS_SIZE; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 704 | } else { |
| 705 | mmr_offset = UVH_LB_BAU_SB_ACTIVATION_STATUS_1; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 706 | right_shift = ((desc - UV_CPUS_PER_AS) * UV_ACT_STATUS_SIZE); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 707 | } |
| 708 | |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 709 | if (bcp->uvhub_version == 1) |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 710 | return uv1_wait_completion(bau_desc, mmr_offset, right_shift, bcp, try); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 711 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 712 | return uv2_3_wait_completion(bau_desc, mmr_offset, right_shift, bcp, try); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 713 | } |
| 714 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 715 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 716 | * Our retries are blocked by all destination sw ack resources being |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 717 | * in use, and a timeout is pending. In that case hardware immediately |
| 718 | * returns the ERROR that looks like a destination timeout. |
| 719 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 720 | static void destination_plugged(struct bau_desc *bau_desc, |
| 721 | struct bau_control *bcp, |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 722 | struct bau_control *hmaster, struct ptc_stats *stat) |
| 723 | { |
| 724 | udelay(bcp->plugged_delay); |
| 725 | bcp->plugged_tries++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 726 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 727 | if (bcp->plugged_tries >= bcp->plugsb4reset) { |
| 728 | bcp->plugged_tries = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 729 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 730 | quiesce_local_uvhub(hmaster); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 731 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 732 | spin_lock(&hmaster->queue_lock); |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 733 | reset_with_ipi(&bau_desc->distribution, bcp); |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 734 | spin_unlock(&hmaster->queue_lock); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 735 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 736 | end_uvhub_quiesce(hmaster); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 737 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 738 | bcp->ipi_attempts++; |
| 739 | stat->s_resets_plug++; |
| 740 | } |
| 741 | } |
| 742 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 743 | static void destination_timeout(struct bau_desc *bau_desc, |
| 744 | struct bau_control *bcp, struct bau_control *hmaster, |
| 745 | struct ptc_stats *stat) |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 746 | { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 747 | hmaster->max_concurr = 1; |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 748 | bcp->timeout_tries++; |
| 749 | if (bcp->timeout_tries >= bcp->timeoutsb4reset) { |
| 750 | bcp->timeout_tries = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 751 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 752 | quiesce_local_uvhub(hmaster); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 753 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 754 | spin_lock(&hmaster->queue_lock); |
cpw@sgi.com | 485f07d | 2011-06-21 07:21:29 -0500 | [diff] [blame] | 755 | reset_with_ipi(&bau_desc->distribution, bcp); |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 756 | spin_unlock(&hmaster->queue_lock); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 757 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 758 | end_uvhub_quiesce(hmaster); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 759 | |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 760 | bcp->ipi_attempts++; |
| 761 | stat->s_resets_timeout++; |
| 762 | } |
| 763 | } |
| 764 | |
| 765 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 766 | * Stop all cpus on a uvhub from using the BAU for a period of time. |
| 767 | * This is reversed by check_enable. |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 768 | */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 769 | static void disable_for_period(struct bau_control *bcp, struct ptc_stats *stat) |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 770 | { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 771 | int tcpu; |
| 772 | struct bau_control *tbcp; |
| 773 | struct bau_control *hmaster; |
| 774 | cycles_t tm1; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 775 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 776 | hmaster = bcp->uvhub_master; |
| 777 | spin_lock(&hmaster->disable_lock); |
| 778 | if (!bcp->baudisabled) { |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 779 | stat->s_bau_disabled++; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 780 | tm1 = get_cycles(); |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 781 | for_each_present_cpu(tcpu) { |
| 782 | tbcp = &per_cpu(bau_control, tcpu); |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 783 | if (tbcp->uvhub_master == hmaster) { |
| 784 | tbcp->baudisabled = 1; |
| 785 | tbcp->set_bau_on_time = |
| 786 | tm1 + bcp->disabled_period; |
| 787 | } |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 788 | } |
| 789 | } |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 790 | spin_unlock(&hmaster->disable_lock); |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 791 | } |
| 792 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 793 | static void count_max_concurr(int stat, struct bau_control *bcp, |
| 794 | struct bau_control *hmaster) |
| 795 | { |
| 796 | bcp->plugged_tries = 0; |
| 797 | bcp->timeout_tries = 0; |
| 798 | if (stat != FLUSH_COMPLETE) |
| 799 | return; |
| 800 | if (bcp->conseccompletes <= bcp->complete_threshold) |
| 801 | return; |
| 802 | if (hmaster->max_concurr >= hmaster->max_concurr_const) |
| 803 | return; |
| 804 | hmaster->max_concurr++; |
| 805 | } |
| 806 | |
| 807 | static void record_send_stats(cycles_t time1, cycles_t time2, |
| 808 | struct bau_control *bcp, struct ptc_stats *stat, |
| 809 | int completion_status, int try) |
| 810 | { |
| 811 | cycles_t elapsed; |
| 812 | |
| 813 | if (time2 > time1) { |
| 814 | elapsed = time2 - time1; |
| 815 | stat->s_time += elapsed; |
| 816 | |
| 817 | if ((completion_status == FLUSH_COMPLETE) && (try == 1)) { |
| 818 | bcp->period_requests++; |
| 819 | bcp->period_time += elapsed; |
| 820 | if ((elapsed > congested_cycles) && |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 821 | (bcp->period_requests > bcp->cong_reps) && |
| 822 | ((bcp->period_time / bcp->period_requests) > |
| 823 | congested_cycles)) { |
| 824 | stat->s_congested++; |
| 825 | disable_for_period(bcp, stat); |
| 826 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 827 | } |
| 828 | } else |
| 829 | stat->s_requestor--; |
| 830 | |
| 831 | if (completion_status == FLUSH_COMPLETE && try > 1) |
| 832 | stat->s_retriesok++; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 833 | else if (completion_status == FLUSH_GIVEUP) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 834 | stat->s_giveup++; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 835 | if (get_cycles() > bcp->period_end) |
| 836 | bcp->period_giveups = 0; |
| 837 | bcp->period_giveups++; |
| 838 | if (bcp->period_giveups == 1) |
| 839 | bcp->period_end = get_cycles() + bcp->disabled_period; |
| 840 | if (bcp->period_giveups > bcp->giveup_limit) { |
| 841 | disable_for_period(bcp, stat); |
| 842 | stat->s_giveuplimit++; |
| 843 | } |
| 844 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 845 | } |
| 846 | |
| 847 | /* |
| 848 | * Because of a uv1 hardware bug only a limited number of concurrent |
| 849 | * requests can be made. |
| 850 | */ |
| 851 | static void uv1_throttle(struct bau_control *hmaster, struct ptc_stats *stat) |
| 852 | { |
| 853 | spinlock_t *lock = &hmaster->uvhub_lock; |
| 854 | atomic_t *v; |
| 855 | |
| 856 | v = &hmaster->active_descriptor_count; |
| 857 | if (!atomic_inc_unless_ge(lock, v, hmaster->max_concurr)) { |
| 858 | stat->s_throttles++; |
| 859 | do { |
| 860 | cpu_relax(); |
| 861 | } while (!atomic_inc_unless_ge(lock, v, hmaster->max_concurr)); |
| 862 | } |
| 863 | } |
| 864 | |
| 865 | /* |
| 866 | * Handle the completion status of a message send. |
| 867 | */ |
| 868 | static void handle_cmplt(int completion_status, struct bau_desc *bau_desc, |
| 869 | struct bau_control *bcp, struct bau_control *hmaster, |
| 870 | struct ptc_stats *stat) |
| 871 | { |
| 872 | if (completion_status == FLUSH_RETRY_PLUGGED) |
| 873 | destination_plugged(bau_desc, bcp, hmaster, stat); |
| 874 | else if (completion_status == FLUSH_RETRY_TIMEOUT) |
| 875 | destination_timeout(bau_desc, bcp, hmaster, stat); |
| 876 | } |
| 877 | |
| 878 | /* |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 879 | * Send a broadcast and wait for it to complete. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 880 | * |
Cliff Wickman | f6d8a56 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 881 | * The flush_mask contains the cpus the broadcast is to be sent to including |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 882 | * cpus that are on the local uvhub. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 883 | * |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 884 | * Returns 0 if all flushing represented in the mask was done. |
| 885 | * Returns 1 if it gives up entirely and the original cpu mask is to be |
| 886 | * returned to the kernel. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 887 | */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 888 | int uv_flush_send_and_wait(struct cpumask *flush_mask, struct bau_control *bcp, |
| 889 | struct bau_desc *bau_desc) |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 890 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 891 | int seq_number = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 892 | int completion_stat = 0; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 893 | int uv1 = 0; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 894 | long try = 0; |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 895 | unsigned long index; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 896 | cycles_t time1; |
| 897 | cycles_t time2; |
Cliff Wickman | 712157a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 898 | struct ptc_stats *stat = bcp->statp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 899 | struct bau_control *hmaster = bcp->uvhub_master; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 900 | struct uv1_bau_msg_header *uv1_hdr = NULL; |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 901 | struct uv2_3_bau_msg_header *uv2_3_hdr = NULL; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 902 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 903 | if (bcp->uvhub_version == 1) { |
| 904 | uv1 = 1; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 905 | uv1_throttle(hmaster, stat); |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 906 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 907 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 908 | while (hmaster->uvhub_quiesce) |
| 909 | cpu_relax(); |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 910 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 911 | time1 = get_cycles(); |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 912 | if (uv1) |
| 913 | uv1_hdr = &bau_desc->header.uv1_hdr; |
| 914 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 915 | /* uv2 and uv3 */ |
| 916 | uv2_3_hdr = &bau_desc->header.uv2_3_hdr; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 917 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 918 | do { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 919 | if (try == 0) { |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 920 | if (uv1) |
| 921 | uv1_hdr->msg_type = MSG_REGULAR; |
| 922 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 923 | uv2_3_hdr->msg_type = MSG_REGULAR; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 924 | seq_number = bcp->message_number++; |
| 925 | } else { |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 926 | if (uv1) |
| 927 | uv1_hdr->msg_type = MSG_RETRY; |
| 928 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 929 | uv2_3_hdr->msg_type = MSG_RETRY; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 930 | stat->s_retry_messages++; |
| 931 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 932 | |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 933 | if (uv1) |
| 934 | uv1_hdr->sequence = seq_number; |
| 935 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 936 | uv2_3_hdr->sequence = seq_number; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 937 | index = (1UL << AS_PUSH_SHIFT) | bcp->uvhub_cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 938 | bcp->send_message = get_cycles(); |
| 939 | |
| 940 | write_mmr_activation(index); |
| 941 | |
| 942 | try++; |
| 943 | completion_stat = wait_completion(bau_desc, bcp, try); |
| 944 | |
| 945 | handle_cmplt(completion_stat, bau_desc, bcp, hmaster, stat); |
| 946 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 947 | if (bcp->ipi_attempts >= bcp->ipi_reset_limit) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 948 | bcp->ipi_attempts = 0; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 949 | stat->s_overipilimit++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 950 | completion_stat = FLUSH_GIVEUP; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 951 | break; |
| 952 | } |
| 953 | cpu_relax(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 954 | } while ((completion_stat == FLUSH_RETRY_PLUGGED) || |
| 955 | (completion_stat == FLUSH_RETRY_TIMEOUT)); |
| 956 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 957 | time2 = get_cycles(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 958 | |
| 959 | count_max_concurr(completion_stat, bcp, hmaster); |
| 960 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 961 | while (hmaster->uvhub_quiesce) |
| 962 | cpu_relax(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 963 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 964 | atomic_dec(&hmaster->active_descriptor_count); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 965 | |
| 966 | record_send_stats(time1, time2, bcp, stat, completion_stat, try); |
| 967 | |
| 968 | if (completion_stat == FLUSH_GIVEUP) |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 969 | /* FLUSH_GIVEUP will fall back to using IPI's for tlb flush */ |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 970 | return 1; |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 971 | return 0; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 972 | } |
| 973 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 974 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 975 | * The BAU is disabled for this uvhub. When the disabled time period has |
| 976 | * expired re-enable it. |
| 977 | * Return 0 if it is re-enabled for all cpus on this uvhub. |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 978 | */ |
| 979 | static int check_enable(struct bau_control *bcp, struct ptc_stats *stat) |
| 980 | { |
| 981 | int tcpu; |
| 982 | struct bau_control *tbcp; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 983 | struct bau_control *hmaster; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 984 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 985 | hmaster = bcp->uvhub_master; |
| 986 | spin_lock(&hmaster->disable_lock); |
| 987 | if (bcp->baudisabled && (get_cycles() >= bcp->set_bau_on_time)) { |
| 988 | stat->s_bau_reenabled++; |
| 989 | for_each_present_cpu(tcpu) { |
| 990 | tbcp = &per_cpu(bau_control, tcpu); |
| 991 | if (tbcp->uvhub_master == hmaster) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 992 | tbcp->baudisabled = 0; |
| 993 | tbcp->period_requests = 0; |
| 994 | tbcp->period_time = 0; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 995 | tbcp->period_giveups = 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 996 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 997 | } |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 998 | spin_unlock(&hmaster->disable_lock); |
| 999 | return 0; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1000 | } |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1001 | spin_unlock(&hmaster->disable_lock); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1002 | return -1; |
| 1003 | } |
| 1004 | |
| 1005 | static void record_send_statistics(struct ptc_stats *stat, int locals, int hubs, |
| 1006 | int remotes, struct bau_desc *bau_desc) |
| 1007 | { |
| 1008 | stat->s_requestor++; |
| 1009 | stat->s_ntargcpu += remotes + locals; |
| 1010 | stat->s_ntargremotes += remotes; |
| 1011 | stat->s_ntarglocals += locals; |
| 1012 | |
| 1013 | /* uvhub statistics */ |
| 1014 | hubs = bau_uvhub_weight(&bau_desc->distribution); |
| 1015 | if (locals) { |
| 1016 | stat->s_ntarglocaluvhub++; |
| 1017 | stat->s_ntargremoteuvhub += (hubs - 1); |
| 1018 | } else |
| 1019 | stat->s_ntargremoteuvhub += hubs; |
| 1020 | |
| 1021 | stat->s_ntarguvhub += hubs; |
| 1022 | |
| 1023 | if (hubs >= 16) |
| 1024 | stat->s_ntarguvhub16++; |
| 1025 | else if (hubs >= 8) |
| 1026 | stat->s_ntarguvhub8++; |
| 1027 | else if (hubs >= 4) |
| 1028 | stat->s_ntarguvhub4++; |
| 1029 | else if (hubs >= 2) |
| 1030 | stat->s_ntarguvhub2++; |
| 1031 | else |
| 1032 | stat->s_ntarguvhub1++; |
| 1033 | } |
| 1034 | |
| 1035 | /* |
| 1036 | * Translate a cpu mask to the uvhub distribution mask in the BAU |
| 1037 | * activation descriptor. |
| 1038 | */ |
| 1039 | static int set_distrib_bits(struct cpumask *flush_mask, struct bau_control *bcp, |
| 1040 | struct bau_desc *bau_desc, int *localsp, int *remotesp) |
| 1041 | { |
| 1042 | int cpu; |
| 1043 | int pnode; |
| 1044 | int cnt = 0; |
| 1045 | struct hub_and_pnode *hpp; |
| 1046 | |
| 1047 | for_each_cpu(cpu, flush_mask) { |
| 1048 | /* |
| 1049 | * The distribution vector is a bit map of pnodes, relative |
| 1050 | * to the partition base pnode (and the partition base nasid |
| 1051 | * in the header). |
| 1052 | * Translate cpu to pnode and hub using a local memory array. |
| 1053 | */ |
| 1054 | hpp = &bcp->socket_master->thp[cpu]; |
| 1055 | pnode = hpp->pnode - bcp->partition_base_pnode; |
| 1056 | bau_uvhub_set(pnode, &bau_desc->distribution); |
| 1057 | cnt++; |
| 1058 | if (hpp->uvhub == bcp->uvhub) |
| 1059 | (*localsp)++; |
| 1060 | else |
| 1061 | (*remotesp)++; |
| 1062 | } |
| 1063 | if (!cnt) |
| 1064 | return 1; |
| 1065 | return 0; |
| 1066 | } |
| 1067 | |
| 1068 | /* |
| 1069 | * globally purge translation cache of a virtual address or all TLB's |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1070 | * @cpumask: mask of all cpu's in which the address is to be removed |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1071 | * @mm: mm_struct containing virtual address range |
Alex Shi | 57c4f43 | 2012-12-18 12:22:14 -0800 | [diff] [blame] | 1072 | * @start: start virtual address to be removed from TLB |
| 1073 | * @end: end virtual address to be remove from TLB |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1074 | * @cpu: the current cpu |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1075 | * |
| 1076 | * This is the entry point for initiating any UV global TLB shootdown. |
| 1077 | * |
| 1078 | * Purges the translation caches of all specified processors of the given |
| 1079 | * virtual address, or purges all TLB's on specified processors. |
| 1080 | * |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1081 | * The caller has derived the cpumask from the mm_struct. This function |
| 1082 | * is called only if there are bits set in the mask. (e.g. flush_tlb_page()) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1083 | * |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1084 | * The cpumask is converted into a uvhubmask of the uvhubs containing |
| 1085 | * those cpus. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1086 | * |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1087 | * Note that this function should be called with preemption disabled. |
| 1088 | * |
| 1089 | * Returns NULL if all remote flushing was done. |
| 1090 | * Returns pointer to cpumask if some remote flushing remains to be |
| 1091 | * done. The returned pointer is valid till preemption is re-enabled. |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1092 | */ |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1093 | const struct cpumask *uv_flush_tlb_others(const struct cpumask *cpumask, |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1094 | struct mm_struct *mm, |
| 1095 | unsigned long start, |
| 1096 | unsigned long end, |
| 1097 | unsigned int cpu) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1098 | { |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1099 | int locals = 0; |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1100 | int remotes = 0; |
| 1101 | int hubs = 0; |
Ingo Molnar | dc163a4 | 2008-06-18 14:15:43 +0200 | [diff] [blame] | 1102 | struct bau_desc *bau_desc; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1103 | struct cpumask *flush_mask; |
| 1104 | struct ptc_stats *stat; |
| 1105 | struct bau_control *bcp; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1106 | unsigned long descriptor_status; |
| 1107 | unsigned long status; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1108 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1109 | bcp = &per_cpu(bau_control, cpu); |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1110 | |
| 1111 | if (bcp->nobau) |
| 1112 | return cpumask; |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1113 | |
cpw | 3eae49c | 2013-12-03 17:15:30 -0600 | [diff] [blame] | 1114 | stat = bcp->statp; |
| 1115 | stat->s_enters++; |
| 1116 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1117 | if (bcp->busy) { |
| 1118 | descriptor_status = |
| 1119 | read_lmmr(UVH_LB_BAU_SB_ACTIVATION_STATUS_0); |
| 1120 | status = ((descriptor_status >> (bcp->uvhub_cpu * |
| 1121 | UV_ACT_STATUS_SIZE)) & UV_ACT_STATUS_MASK) << 1; |
| 1122 | if (status == UV2H_DESC_BUSY) |
| 1123 | return cpumask; |
| 1124 | bcp->busy = 0; |
| 1125 | } |
| 1126 | |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1127 | /* bau was disabled due to slow response */ |
| 1128 | if (bcp->baudisabled) { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1129 | if (check_enable(bcp, stat)) { |
| 1130 | stat->s_ipifordisabled++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1131 | return cpumask; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1132 | } |
Cliff Wickman | 50fb55a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1133 | } |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1134 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1135 | /* |
| 1136 | * Each sending cpu has a per-cpu mask which it fills from the caller's |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1137 | * cpu mask. All cpus are converted to uvhubs and copied to the |
| 1138 | * activation descriptor. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1139 | */ |
| 1140 | flush_mask = (struct cpumask *)per_cpu(uv_flush_tlb_mask, cpu); |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1141 | /* don't actually do a shootdown of the local cpu */ |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1142 | cpumask_andnot(flush_mask, cpumask, cpumask_of(cpu)); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1143 | |
Rusty Russell | 020b37a | 2015-03-02 22:05:49 +1030 | [diff] [blame] | 1144 | if (cpumask_test_cpu(cpu, cpumask)) |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1145 | stat->s_ntargself++; |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1146 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1147 | bau_desc = bcp->descriptor_base; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1148 | bau_desc += (ITEMS_PER_DESC * bcp->uvhub_cpu); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1149 | bau_uvhubs_clear(&bau_desc->distribution, UV_DISTRIBUTION_SIZE); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1150 | if (set_distrib_bits(flush_mask, bcp, bau_desc, &locals, &remotes)) |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1151 | return NULL; |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1152 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1153 | record_send_statistics(stat, locals, hubs, remotes, bau_desc); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1154 | |
Alex Shi | 57c4f43 | 2012-12-18 12:22:14 -0800 | [diff] [blame] | 1155 | if (!end || (end - start) <= PAGE_SIZE) |
| 1156 | bau_desc->payload.address = start; |
| 1157 | else |
| 1158 | bau_desc->payload.address = TLB_FLUSH_ALL; |
Tejun Heo | bdbcdd4 | 2009-01-21 17:26:06 +0900 | [diff] [blame] | 1159 | bau_desc->payload.sending_cpu = cpu; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1160 | /* |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1161 | * uv_flush_send_and_wait returns 0 if all cpu's were messaged, |
| 1162 | * or 1 if it gave up and the original cpumask should be returned. |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1163 | */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1164 | if (!uv_flush_send_and_wait(flush_mask, bcp, bau_desc)) |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1165 | return NULL; |
| 1166 | else |
| 1167 | return cpumask; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1168 | } |
| 1169 | |
| 1170 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1171 | * Search the message queue for any 'other' unprocessed message with the |
| 1172 | * same software acknowledge resource bit vector as the 'msg' message. |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1173 | */ |
| 1174 | struct bau_pq_entry *find_another_by_swack(struct bau_pq_entry *msg, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1175 | struct bau_control *bcp) |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1176 | { |
| 1177 | struct bau_pq_entry *msg_next = msg + 1; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1178 | unsigned char swack_vec = msg->swack_vec; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1179 | |
| 1180 | if (msg_next > bcp->queue_last) |
| 1181 | msg_next = bcp->queue_first; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1182 | while (msg_next != msg) { |
| 1183 | if ((msg_next->canceled == 0) && (msg_next->replied_to == 0) && |
| 1184 | (msg_next->swack_vec == swack_vec)) |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1185 | return msg_next; |
| 1186 | msg_next++; |
| 1187 | if (msg_next > bcp->queue_last) |
| 1188 | msg_next = bcp->queue_first; |
| 1189 | } |
| 1190 | return NULL; |
| 1191 | } |
| 1192 | |
| 1193 | /* |
| 1194 | * UV2 needs to work around a bug in which an arriving message has not |
| 1195 | * set a bit in the UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE register. |
| 1196 | * Such a message must be ignored. |
| 1197 | */ |
| 1198 | void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp) |
| 1199 | { |
| 1200 | unsigned long mmr_image; |
| 1201 | unsigned char swack_vec; |
| 1202 | struct bau_pq_entry *msg = mdp->msg; |
| 1203 | struct bau_pq_entry *other_msg; |
| 1204 | |
| 1205 | mmr_image = read_mmr_sw_ack(); |
| 1206 | swack_vec = msg->swack_vec; |
| 1207 | |
| 1208 | if ((swack_vec & mmr_image) == 0) { |
| 1209 | /* |
| 1210 | * This message was assigned a swack resource, but no |
| 1211 | * reserved acknowlegment is pending. |
| 1212 | * The bug has prevented this message from setting the MMR. |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1213 | */ |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1214 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1215 | * Some message has set the MMR 'pending' bit; it might have |
| 1216 | * been another message. Look for that message. |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1217 | */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1218 | other_msg = find_another_by_swack(msg, bcp); |
| 1219 | if (other_msg) { |
| 1220 | /* |
| 1221 | * There is another. Process this one but do not |
| 1222 | * ack it. |
| 1223 | */ |
| 1224 | bau_process_message(mdp, bcp, 0); |
| 1225 | /* |
| 1226 | * Let the natural processing of that other message |
| 1227 | * acknowledge it. Don't get the processing of sw_ack's |
| 1228 | * out of order. |
| 1229 | */ |
| 1230 | return; |
| 1231 | } |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1232 | } |
| 1233 | |
| 1234 | /* |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1235 | * Either the MMR shows this one pending a reply or there is no |
| 1236 | * other message using this sw_ack, so it is safe to acknowledge it. |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1237 | */ |
| 1238 | bau_process_message(mdp, bcp, 1); |
| 1239 | |
| 1240 | return; |
| 1241 | } |
| 1242 | |
| 1243 | /* |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1244 | * The BAU message interrupt comes here. (registered by set_intr_gate) |
| 1245 | * See entry_64.S |
| 1246 | * |
| 1247 | * We received a broadcast assist message. |
| 1248 | * |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1249 | * Interrupts are disabled; this interrupt could represent |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1250 | * the receipt of several messages. |
| 1251 | * |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1252 | * All cores/threads on this hub get this interrupt. |
| 1253 | * The last one to see it does the software ack. |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1254 | * (the resource will not be freed until noninterruptable cpus see this |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1255 | * interrupt; hardware may timeout the s/w ack and reply ERROR) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1256 | */ |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1257 | void uv_bau_message_interrupt(struct pt_regs *regs) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1258 | { |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1259 | int count = 0; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1260 | cycles_t time_start; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1261 | struct bau_pq_entry *msg; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1262 | struct bau_control *bcp; |
| 1263 | struct ptc_stats *stat; |
| 1264 | struct msg_desc msgdesc; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1265 | |
Cliff Wickman | 88ed9dd | 2012-01-16 15:21:46 -0600 | [diff] [blame] | 1266 | ack_APIC_irq(); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1267 | time_start = get_cycles(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1268 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1269 | bcp = &per_cpu(bau_control, smp_processor_id()); |
Cliff Wickman | 712157a | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1270 | stat = bcp->statp; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1271 | |
| 1272 | msgdesc.queue_first = bcp->queue_first; |
| 1273 | msgdesc.queue_last = bcp->queue_last; |
| 1274 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1275 | msg = bcp->bau_msg_head; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1276 | while (msg->swack_vec) { |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1277 | count++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1278 | |
| 1279 | msgdesc.msg_slot = msg - msgdesc.queue_first; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1280 | msgdesc.msg = msg; |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1281 | if (bcp->uvhub_version == 2) |
| 1282 | process_uv2_message(&msgdesc, bcp); |
| 1283 | else |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1284 | /* no error workaround for uv1 or uv3 */ |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1285 | bau_process_message(&msgdesc, bcp, 1); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1286 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1287 | msg++; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1288 | if (msg > msgdesc.queue_last) |
| 1289 | msg = msgdesc.queue_first; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1290 | bcp->bau_msg_head = msg; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1291 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1292 | stat->d_time += (get_cycles() - time_start); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1293 | if (!count) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1294 | stat->d_nomsg++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1295 | else if (count > 1) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1296 | stat->d_multmsg++; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1297 | } |
| 1298 | |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1299 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1300 | * Each target uvhub (i.e. a uvhub that has cpu's) needs to have |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1301 | * shootdown message timeouts enabled. The timeout does not cause |
| 1302 | * an interrupt, but causes an error message to be returned to |
| 1303 | * the sender. |
| 1304 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1305 | static void __init enable_timeouts(void) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1306 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1307 | int uvhub; |
| 1308 | int nuvhubs; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1309 | int pnode; |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1310 | unsigned long mmr_image; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1311 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1312 | nuvhubs = uv_num_possible_blades(); |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1313 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1314 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { |
| 1315 | if (!uv_blade_nr_possible_cpus(uvhub)) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1316 | continue; |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1317 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1318 | pnode = uv_blade_to_pnode(uvhub); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1319 | mmr_image = read_mmr_misc_control(pnode); |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1320 | /* |
| 1321 | * Set the timeout period and then lock it in, in three |
| 1322 | * steps; captures and locks in the period. |
| 1323 | * |
| 1324 | * To program the period, the SOFT_ACK_MODE must be off. |
| 1325 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1326 | mmr_image &= ~(1L << SOFTACK_MSHIFT); |
| 1327 | write_mmr_misc_control(pnode, mmr_image); |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1328 | /* |
| 1329 | * Set the 4-bit period. |
| 1330 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1331 | mmr_image &= ~((unsigned long)0xf << SOFTACK_PSHIFT); |
| 1332 | mmr_image |= (SOFTACK_TIMEOUT_PERIOD << SOFTACK_PSHIFT); |
| 1333 | write_mmr_misc_control(pnode, mmr_image); |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1334 | /* |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1335 | * UV1: |
Cliff Wickman | c4c4688 | 2009-04-03 08:34:32 -0500 | [diff] [blame] | 1336 | * Subsequent reversals of the timebase bit (3) cause an |
| 1337 | * immediate timeout of one or all INTD resources as |
| 1338 | * indicated in bits 2:0 (7 causes all of them to timeout). |
| 1339 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1340 | mmr_image |= (1L << SOFTACK_MSHIFT); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1341 | if (is_uv2_hub()) { |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1342 | /* do not touch the legacy mode bit */ |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1343 | /* hw bug workaround; do not use extended status */ |
| 1344 | mmr_image &= ~(1L << UV2_EXT_SHFT); |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1345 | } else if (is_uv3_hub()) { |
| 1346 | mmr_image &= ~(1L << PREFETCH_HINT_SHFT); |
| 1347 | mmr_image |= (1L << SB_STATUS_SHFT); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1348 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1349 | write_mmr_misc_control(pnode, mmr_image); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1350 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1351 | } |
| 1352 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1353 | static void *ptc_seq_start(struct seq_file *file, loff_t *offset) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1354 | { |
| 1355 | if (*offset < num_possible_cpus()) |
| 1356 | return offset; |
| 1357 | return NULL; |
| 1358 | } |
| 1359 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1360 | static void *ptc_seq_next(struct seq_file *file, void *data, loff_t *offset) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1361 | { |
| 1362 | (*offset)++; |
| 1363 | if (*offset < num_possible_cpus()) |
| 1364 | return offset; |
| 1365 | return NULL; |
| 1366 | } |
| 1367 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1368 | static void ptc_seq_stop(struct seq_file *file, void *data) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1369 | { |
| 1370 | } |
| 1371 | |
| 1372 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1373 | * Display the statistics thru /proc/sgi_uv/ptc_statistics |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1374 | * 'data' points to the cpu number |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1375 | * Note: see the descriptions in stat_description[]. |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1376 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1377 | static int ptc_seq_show(struct seq_file *file, void *data) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1378 | { |
| 1379 | struct ptc_stats *stat; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1380 | struct bau_control *bcp; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1381 | int cpu; |
| 1382 | |
| 1383 | cpu = *(loff_t *)data; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1384 | if (!cpu) { |
Rasmus Villemoes | 3736708 | 2014-11-28 22:03:41 +0100 | [diff] [blame] | 1385 | seq_puts(file, |
| 1386 | "# cpu bauoff sent stime self locals remotes ncpus localhub "); |
| 1387 | seq_puts(file, "remotehub numuvhubs numuvhubs16 numuvhubs8 "); |
| 1388 | seq_puts(file, |
| 1389 | "numuvhubs4 numuvhubs2 numuvhubs1 dto snacks retries "); |
| 1390 | seq_puts(file, |
| 1391 | "rok resetp resett giveup sto bz throt disable "); |
| 1392 | seq_puts(file, |
| 1393 | "enable wars warshw warwaits enters ipidis plugged "); |
| 1394 | seq_puts(file, |
| 1395 | "ipiover glim cong swack recv rtime all one mult "); |
| 1396 | seq_puts(file, "none retry canc nocan reset rcan\n"); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1397 | } |
| 1398 | if (cpu < num_possible_cpus() && cpu_online(cpu)) { |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1399 | bcp = &per_cpu(bau_control, cpu); |
James Custer | fa2a79ce | 2014-11-02 12:16:39 -0600 | [diff] [blame] | 1400 | if (bcp->nobau) { |
| 1401 | seq_printf(file, "cpu %d bau disabled\n", cpu); |
| 1402 | return 0; |
| 1403 | } |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1404 | stat = bcp->statp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1405 | /* source side statistics */ |
| 1406 | seq_printf(file, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1407 | "cpu %d %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ", |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1408 | cpu, bcp->nobau, stat->s_requestor, |
| 1409 | cycles_2_us(stat->s_time), |
Cliff Wickman | 450a007 | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1410 | stat->s_ntargself, stat->s_ntarglocals, |
| 1411 | stat->s_ntargremotes, stat->s_ntargcpu, |
| 1412 | stat->s_ntarglocaluvhub, stat->s_ntargremoteuvhub, |
| 1413 | stat->s_ntarguvhub, stat->s_ntarguvhub16); |
Cliff Wickman | b54bd9b | 2012-01-16 15:22:38 -0600 | [diff] [blame] | 1414 | seq_printf(file, "%ld %ld %ld %ld %ld %ld ", |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1415 | stat->s_ntarguvhub8, stat->s_ntarguvhub4, |
| 1416 | stat->s_ntarguvhub2, stat->s_ntarguvhub1, |
Cliff Wickman | b54bd9b | 2012-01-16 15:22:38 -0600 | [diff] [blame] | 1417 | stat->s_dtimeout, stat->s_strongnacks); |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1418 | seq_printf(file, "%ld %ld %ld %ld %ld %ld %ld %ld ", |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1419 | stat->s_retry_messages, stat->s_retriesok, |
| 1420 | stat->s_resets_plug, stat->s_resets_timeout, |
| 1421 | stat->s_giveup, stat->s_stimeout, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1422 | stat->s_busy, stat->s_throttles); |
| 1423 | seq_printf(file, "%ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ", |
| 1424 | stat->s_bau_disabled, stat->s_bau_reenabled, |
| 1425 | stat->s_uv2_wars, stat->s_uv2_wars_hw, |
| 1426 | stat->s_uv2_war_waits, stat->s_enters, |
| 1427 | stat->s_ipifordisabled, stat->s_plugged, |
| 1428 | stat->s_overipilimit, stat->s_giveuplimit, |
| 1429 | stat->s_congested); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1430 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1431 | /* destination side statistics */ |
| 1432 | seq_printf(file, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1433 | "%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n", |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1434 | read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)), |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1435 | stat->d_requestee, cycles_2_us(stat->d_time), |
| 1436 | stat->d_alltlb, stat->d_onetlb, stat->d_multmsg, |
| 1437 | stat->d_nomsg, stat->d_retries, stat->d_canceled, |
| 1438 | stat->d_nocanceled, stat->d_resets, |
| 1439 | stat->d_rcanceled); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1440 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1441 | return 0; |
| 1442 | } |
| 1443 | |
| 1444 | /* |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1445 | * Display the tunables thru debugfs |
| 1446 | */ |
| 1447 | static ssize_t tunables_read(struct file *file, char __user *userbuf, |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1448 | size_t count, loff_t *ppos) |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1449 | { |
Dan Carpenter | b365a85 | 2010-09-29 10:41:05 +0200 | [diff] [blame] | 1450 | char *buf; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1451 | int ret; |
| 1452 | |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1453 | buf = kasprintf(GFP_KERNEL, "%s %s %s\n%d %d %d %d %d %d %d %d %d %d\n", |
| 1454 | "max_concur plugged_delay plugsb4reset timeoutsb4reset", |
| 1455 | "ipi_reset_limit complete_threshold congested_response_us", |
| 1456 | "congested_reps disabled_period giveup_limit", |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1457 | max_concurr, plugged_delay, plugsb4reset, |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1458 | timeoutsb4reset, ipi_reset_limit, complete_threshold, |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1459 | congested_respns_us, congested_reps, disabled_period, |
| 1460 | giveup_limit); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1461 | |
Dan Carpenter | b365a85 | 2010-09-29 10:41:05 +0200 | [diff] [blame] | 1462 | if (!buf) |
| 1463 | return -ENOMEM; |
| 1464 | |
| 1465 | ret = simple_read_from_buffer(userbuf, count, ppos, buf, strlen(buf)); |
| 1466 | kfree(buf); |
| 1467 | return ret; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1468 | } |
| 1469 | |
| 1470 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1471 | * handle a write to /proc/sgi_uv/ptc_statistics |
| 1472 | * -1: reset the statistics |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1473 | * 0: display meaning of the statistics |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1474 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1475 | static ssize_t ptc_proc_write(struct file *file, const char __user *user, |
| 1476 | size_t count, loff_t *data) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1477 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1478 | int cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1479 | int i; |
| 1480 | int elements; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1481 | long input_arg; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1482 | char optstr[64]; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1483 | struct ptc_stats *stat; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1484 | |
Cliff Wickman | e7eb872 | 2008-06-23 08:32:25 -0500 | [diff] [blame] | 1485 | if (count == 0 || count > sizeof(optstr)) |
Cliff Wickman | cef5327 | 2008-06-19 11:16:24 -0500 | [diff] [blame] | 1486 | return -EINVAL; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1487 | if (copy_from_user(optstr, user, count)) |
| 1488 | return -EFAULT; |
| 1489 | optstr[count - 1] = '\0'; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1490 | |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1491 | if (!strcmp(optstr, "on")) { |
| 1492 | set_bau_on(); |
| 1493 | return count; |
| 1494 | } else if (!strcmp(optstr, "off")) { |
| 1495 | set_bau_off(); |
| 1496 | return count; |
| 1497 | } |
| 1498 | |
Daniel Walter | 164109e | 2014-08-08 14:24:03 -0700 | [diff] [blame] | 1499 | if (kstrtol(optstr, 10, &input_arg) < 0) { |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1500 | printk(KERN_DEBUG "%s is invalid\n", optstr); |
| 1501 | return -EINVAL; |
| 1502 | } |
| 1503 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1504 | if (input_arg == 0) { |
Sasha Levin | 6444174 | 2012-12-20 14:11:34 -0500 | [diff] [blame] | 1505 | elements = ARRAY_SIZE(stat_description); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1506 | printk(KERN_DEBUG "# cpu: cpu number\n"); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1507 | printk(KERN_DEBUG "Sender statistics:\n"); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1508 | for (i = 0; i < elements; i++) |
| 1509 | printk(KERN_DEBUG "%s\n", stat_description[i]); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1510 | } else if (input_arg == -1) { |
| 1511 | for_each_present_cpu(cpu) { |
| 1512 | stat = &per_cpu(ptcstats, cpu); |
| 1513 | memset(stat, 0, sizeof(struct ptc_stats)); |
| 1514 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1515 | } |
| 1516 | |
| 1517 | return count; |
| 1518 | } |
| 1519 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1520 | static int local_atoi(const char *name) |
| 1521 | { |
| 1522 | int val = 0; |
| 1523 | |
| 1524 | for (;; name++) { |
| 1525 | switch (*name) { |
| 1526 | case '0' ... '9': |
| 1527 | val = 10*val+(*name-'0'); |
| 1528 | break; |
| 1529 | default: |
| 1530 | return val; |
| 1531 | } |
| 1532 | } |
| 1533 | } |
| 1534 | |
| 1535 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1536 | * Parse the values written to /sys/kernel/debug/sgi_uv/bau_tunables. |
| 1537 | * Zero values reset them to defaults. |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1538 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1539 | static int parse_tunables_write(struct bau_control *bcp, char *instr, |
| 1540 | int count) |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1541 | { |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1542 | char *p; |
| 1543 | char *q; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1544 | int cnt = 0; |
| 1545 | int val; |
Sasha Levin | 6444174 | 2012-12-20 14:11:34 -0500 | [diff] [blame] | 1546 | int e = ARRAY_SIZE(tunables); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1547 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1548 | p = instr + strspn(instr, WHITESPACE); |
| 1549 | q = p; |
| 1550 | for (; *p; p = q + strspn(q, WHITESPACE)) { |
| 1551 | q = p + strcspn(p, WHITESPACE); |
| 1552 | cnt++; |
| 1553 | if (q == p) |
| 1554 | break; |
| 1555 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1556 | if (cnt != e) { |
| 1557 | printk(KERN_INFO "bau tunable error: should be %d values\n", e); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1558 | return -EINVAL; |
| 1559 | } |
| 1560 | |
| 1561 | p = instr + strspn(instr, WHITESPACE); |
| 1562 | q = p; |
| 1563 | for (cnt = 0; *p; p = q + strspn(q, WHITESPACE), cnt++) { |
| 1564 | q = p + strcspn(p, WHITESPACE); |
| 1565 | val = local_atoi(p); |
| 1566 | switch (cnt) { |
| 1567 | case 0: |
| 1568 | if (val == 0) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1569 | max_concurr = MAX_BAU_CONCURRENT; |
| 1570 | max_concurr_const = MAX_BAU_CONCURRENT; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1571 | continue; |
| 1572 | } |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1573 | if (val < 1 || val > bcp->cpus_in_uvhub) { |
| 1574 | printk(KERN_DEBUG |
| 1575 | "Error: BAU max concurrent %d is invalid\n", |
| 1576 | val); |
| 1577 | return -EINVAL; |
| 1578 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1579 | max_concurr = val; |
| 1580 | max_concurr_const = val; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1581 | continue; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1582 | default: |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1583 | if (val == 0) |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1584 | *tunables[cnt].tunp = tunables[cnt].deflt; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1585 | else |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1586 | *tunables[cnt].tunp = val; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1587 | continue; |
| 1588 | } |
| 1589 | if (q == p) |
| 1590 | break; |
| 1591 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1592 | return 0; |
| 1593 | } |
| 1594 | |
| 1595 | /* |
| 1596 | * Handle a write to debugfs. (/sys/kernel/debug/sgi_uv/bau_tunables) |
| 1597 | */ |
| 1598 | static ssize_t tunables_write(struct file *file, const char __user *user, |
| 1599 | size_t count, loff_t *data) |
| 1600 | { |
| 1601 | int cpu; |
| 1602 | int ret; |
| 1603 | char instr[100]; |
| 1604 | struct bau_control *bcp; |
| 1605 | |
| 1606 | if (count == 0 || count > sizeof(instr)-1) |
| 1607 | return -EINVAL; |
| 1608 | if (copy_from_user(instr, user, count)) |
| 1609 | return -EFAULT; |
| 1610 | |
| 1611 | instr[count] = '\0'; |
| 1612 | |
cpw@sgi.com | 00b30cf | 2011-06-21 07:21:26 -0500 | [diff] [blame] | 1613 | cpu = get_cpu(); |
| 1614 | bcp = &per_cpu(bau_control, cpu); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1615 | ret = parse_tunables_write(bcp, instr, count); |
cpw@sgi.com | 00b30cf | 2011-06-21 07:21:26 -0500 | [diff] [blame] | 1616 | put_cpu(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1617 | if (ret) |
| 1618 | return ret; |
| 1619 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1620 | for_each_present_cpu(cpu) { |
| 1621 | bcp = &per_cpu(bau_control, cpu); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1622 | bcp->max_concurr = max_concurr; |
| 1623 | bcp->max_concurr_const = max_concurr; |
| 1624 | bcp->plugged_delay = plugged_delay; |
| 1625 | bcp->plugsb4reset = plugsb4reset; |
| 1626 | bcp->timeoutsb4reset = timeoutsb4reset; |
| 1627 | bcp->ipi_reset_limit = ipi_reset_limit; |
| 1628 | bcp->complete_threshold = complete_threshold; |
| 1629 | bcp->cong_response_us = congested_respns_us; |
| 1630 | bcp->cong_reps = congested_reps; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1631 | bcp->disabled_period = sec_2_cycles(disabled_period); |
| 1632 | bcp->giveup_limit = giveup_limit; |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1633 | } |
| 1634 | return count; |
| 1635 | } |
| 1636 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1637 | static const struct seq_operations uv_ptc_seq_ops = { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1638 | .start = ptc_seq_start, |
| 1639 | .next = ptc_seq_next, |
| 1640 | .stop = ptc_seq_stop, |
| 1641 | .show = ptc_seq_show |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1642 | }; |
| 1643 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1644 | static int ptc_proc_open(struct inode *inode, struct file *file) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1645 | { |
| 1646 | return seq_open(file, &uv_ptc_seq_ops); |
| 1647 | } |
| 1648 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1649 | static int tunables_open(struct inode *inode, struct file *file) |
| 1650 | { |
| 1651 | return 0; |
| 1652 | } |
| 1653 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1654 | static const struct file_operations proc_uv_ptc_operations = { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1655 | .open = ptc_proc_open, |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1656 | .read = seq_read, |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1657 | .write = ptc_proc_write, |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1658 | .llseek = seq_lseek, |
| 1659 | .release = seq_release, |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1660 | }; |
| 1661 | |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1662 | static const struct file_operations tunables_fops = { |
| 1663 | .open = tunables_open, |
| 1664 | .read = tunables_read, |
| 1665 | .write = tunables_write, |
Arnd Bergmann | 6038f37 | 2010-08-15 18:52:59 +0200 | [diff] [blame] | 1666 | .llseek = default_llseek, |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1667 | }; |
| 1668 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1669 | static int __init uv_ptc_init(void) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1670 | { |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1671 | struct proc_dir_entry *proc_uv_ptc; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1672 | |
| 1673 | if (!is_uv_system()) |
| 1674 | return 0; |
| 1675 | |
Alexey Dobriyan | 10f02d11 | 2009-08-23 23:17:27 +0400 | [diff] [blame] | 1676 | proc_uv_ptc = proc_create(UV_PTC_BASENAME, 0444, NULL, |
| 1677 | &proc_uv_ptc_operations); |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1678 | if (!proc_uv_ptc) { |
| 1679 | printk(KERN_ERR "unable to create %s proc entry\n", |
| 1680 | UV_PTC_BASENAME); |
| 1681 | return -EINVAL; |
| 1682 | } |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1683 | |
| 1684 | tunables_dir = debugfs_create_dir(UV_BAU_TUNABLES_DIR, NULL); |
| 1685 | if (!tunables_dir) { |
| 1686 | printk(KERN_ERR "unable to create debugfs directory %s\n", |
| 1687 | UV_BAU_TUNABLES_DIR); |
| 1688 | return -EINVAL; |
| 1689 | } |
| 1690 | tunables_file = debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600, |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1691 | tunables_dir, NULL, &tunables_fops); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1692 | if (!tunables_file) { |
| 1693 | printk(KERN_ERR "unable to create debugfs file %s\n", |
| 1694 | UV_BAU_TUNABLES_FILE); |
| 1695 | return -EINVAL; |
| 1696 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 1697 | return 0; |
| 1698 | } |
| 1699 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1700 | /* |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1701 | * Initialize the sending side's sending buffers. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1702 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1703 | static void activation_descriptor_init(int node, int pnode, int base_pnode) |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1704 | { |
| 1705 | int i; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1706 | int cpu; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1707 | int uv1 = 0; |
Jack Steiner | 6a469e4 | 2011-09-20 13:55:04 -0700 | [diff] [blame] | 1708 | unsigned long gpa; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1709 | unsigned long m; |
| 1710 | unsigned long n; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1711 | size_t dsize; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1712 | struct bau_desc *bau_desc; |
| 1713 | struct bau_desc *bd2; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1714 | struct uv1_bau_msg_header *uv1_hdr; |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1715 | struct uv2_3_bau_msg_header *uv2_3_hdr; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1716 | struct bau_control *bcp; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1717 | |
Cliff Wickman | 0e2595c | 2009-05-20 08:10:57 -0500 | [diff] [blame] | 1718 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1719 | * each bau_desc is 64 bytes; there are 8 (ITEMS_PER_DESC) |
| 1720 | * per cpu; and one per cpu on the uvhub (ADP_SZ) |
Cliff Wickman | 0e2595c | 2009-05-20 08:10:57 -0500 | [diff] [blame] | 1721 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1722 | dsize = sizeof(struct bau_desc) * ADP_SZ * ITEMS_PER_DESC; |
| 1723 | bau_desc = kmalloc_node(dsize, GFP_KERNEL, node); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1724 | BUG_ON(!bau_desc); |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 1725 | |
Jack Steiner | 6a469e4 | 2011-09-20 13:55:04 -0700 | [diff] [blame] | 1726 | gpa = uv_gpa(bau_desc); |
| 1727 | n = uv_gpa_to_gnode(gpa); |
| 1728 | m = uv_gpa_to_offset(gpa); |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1729 | if (is_uv1_hub()) |
| 1730 | uv1 = 1; |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 1731 | |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1732 | /* the 14-bit pnode */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1733 | write_mmr_descriptor_base(pnode, (n << UV_DESC_PSHIFT | m)); |
Cliff Wickman | 0e2595c | 2009-05-20 08:10:57 -0500 | [diff] [blame] | 1734 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1735 | * Initializing all 8 (ITEMS_PER_DESC) descriptors for each |
Cliff Wickman | 0e2595c | 2009-05-20 08:10:57 -0500 | [diff] [blame] | 1736 | * cpu even though we only use the first one; one descriptor can |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1737 | * describe a broadcast to 256 uv hubs. |
Cliff Wickman | 0e2595c | 2009-05-20 08:10:57 -0500 | [diff] [blame] | 1738 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1739 | for (i = 0, bd2 = bau_desc; i < (ADP_SZ * ITEMS_PER_DESC); i++, bd2++) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1740 | memset(bd2, 0, sizeof(struct bau_desc)); |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1741 | if (uv1) { |
| 1742 | uv1_hdr = &bd2->header.uv1_hdr; |
| 1743 | uv1_hdr->swack_flag = 1; |
| 1744 | /* |
| 1745 | * The base_dest_nasid set in the message header |
| 1746 | * is the nasid of the first uvhub in the partition. |
| 1747 | * The bit map will indicate destination pnode numbers |
| 1748 | * relative to that base. They may not be consecutive |
| 1749 | * if nasid striding is being used. |
| 1750 | */ |
| 1751 | uv1_hdr->base_dest_nasid = |
| 1752 | UV_PNODE_TO_NASID(base_pnode); |
| 1753 | uv1_hdr->dest_subnodeid = UV_LB_SUBNODEID; |
| 1754 | uv1_hdr->command = UV_NET_ENDPOINT_INTD; |
| 1755 | uv1_hdr->int_both = 1; |
| 1756 | /* |
| 1757 | * all others need to be set to zero: |
| 1758 | * fairness chaining multilevel count replied_to |
| 1759 | */ |
| 1760 | } else { |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1761 | /* |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1762 | * BIOS uses legacy mode, but uv2 and uv3 hardware always |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1763 | * uses native mode for selective broadcasts. |
| 1764 | */ |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1765 | uv2_3_hdr = &bd2->header.uv2_3_hdr; |
| 1766 | uv2_3_hdr->swack_flag = 1; |
| 1767 | uv2_3_hdr->base_dest_nasid = |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1768 | UV_PNODE_TO_NASID(base_pnode); |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1769 | uv2_3_hdr->dest_subnodeid = UV_LB_SUBNODEID; |
| 1770 | uv2_3_hdr->command = UV_NET_ENDPOINT_INTD; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 1771 | } |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1772 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1773 | for_each_present_cpu(cpu) { |
| 1774 | if (pnode != uv_blade_to_pnode(uv_cpu_to_blade_id(cpu))) |
| 1775 | continue; |
| 1776 | bcp = &per_cpu(bau_control, cpu); |
| 1777 | bcp->descriptor_base = bau_desc; |
| 1778 | } |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1779 | } |
| 1780 | |
| 1781 | /* |
| 1782 | * initialize the destination side's receiving buffers |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1783 | * entered for each uvhub in the partition |
| 1784 | * - node is first node (kernel memory notion) on the uvhub |
| 1785 | * - pnode is the uvhub's physical identifier |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1786 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1787 | static void pq_init(int node, int pnode) |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1788 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1789 | int cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1790 | size_t plsize; |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 1791 | char *cp; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1792 | void *vp; |
| 1793 | unsigned long pn; |
| 1794 | unsigned long first; |
| 1795 | unsigned long pn_first; |
| 1796 | unsigned long last; |
| 1797 | struct bau_pq_entry *pqp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1798 | struct bau_control *bcp; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1799 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1800 | plsize = (DEST_Q_SIZE + 1) * sizeof(struct bau_pq_entry); |
| 1801 | vp = kmalloc_node(plsize, GFP_KERNEL, node); |
| 1802 | pqp = (struct bau_pq_entry *)vp; |
Ingo Molnar | dc163a4 | 2008-06-18 14:15:43 +0200 | [diff] [blame] | 1803 | BUG_ON(!pqp); |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 1804 | |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1805 | cp = (char *)pqp + 31; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1806 | pqp = (struct bau_pq_entry *)(((unsigned long)cp >> 5) << 5); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1807 | |
| 1808 | for_each_present_cpu(cpu) { |
| 1809 | if (pnode != uv_cpu_to_pnode(cpu)) |
| 1810 | continue; |
| 1811 | /* for every cpu on this pnode: */ |
| 1812 | bcp = &per_cpu(bau_control, cpu); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1813 | bcp->queue_first = pqp; |
| 1814 | bcp->bau_msg_head = pqp; |
| 1815 | bcp->queue_last = pqp + (DEST_Q_SIZE - 1); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1816 | } |
Cliff Wickman | 4ea3c51 | 2009-04-16 07:53:09 -0500 | [diff] [blame] | 1817 | /* |
Jack Steiner | 6a469e4 | 2011-09-20 13:55:04 -0700 | [diff] [blame] | 1818 | * need the gnode of where the memory was really allocated |
Cliff Wickman | 4ea3c51 | 2009-04-16 07:53:09 -0500 | [diff] [blame] | 1819 | */ |
Jack Steiner | 6a469e4 | 2011-09-20 13:55:04 -0700 | [diff] [blame] | 1820 | pn = uv_gpa_to_gnode(uv_gpa(pqp)); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1821 | first = uv_physnodeaddr(pqp); |
| 1822 | pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first; |
| 1823 | last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1)); |
| 1824 | write_mmr_payload_first(pnode, pn_first); |
| 1825 | write_mmr_payload_tail(pnode, first); |
| 1826 | write_mmr_payload_last(pnode, last); |
Cliff Wickman | c5d35d3 | 2012-01-16 15:19:47 -0600 | [diff] [blame] | 1827 | write_gmmr_sw_ack(pnode, 0xffffUL); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1828 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1829 | /* in effect, all msg_type's are set to MSG_NOOP */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1830 | memset(pqp, 0, sizeof(struct bau_pq_entry) * DEST_Q_SIZE); |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1831 | } |
| 1832 | |
| 1833 | /* |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1834 | * Initialization of each UV hub's structures |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1835 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1836 | static void __init init_uvhub(int uvhub, int vector, int base_pnode) |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1837 | { |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 1838 | int node; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1839 | int pnode; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1840 | unsigned long apicid; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1841 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1842 | node = uvhub_to_first_node(uvhub); |
| 1843 | pnode = uv_blade_to_pnode(uvhub); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1844 | |
| 1845 | activation_descriptor_init(node, pnode, base_pnode); |
| 1846 | |
| 1847 | pq_init(node, pnode); |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1848 | /* |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1849 | * The below initialization can't be in firmware because the |
| 1850 | * messaging IRQ will be determined by the OS. |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 1851 | */ |
Dimitri Sivanich | 8191c9f | 2010-11-16 16:23:52 -0600 | [diff] [blame] | 1852 | apicid = uvhub_to_first_apicid(uvhub) | uv_apicid_hibits; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1853 | write_mmr_data_config(pnode, ((apicid << 32) | vector)); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1854 | } |
| 1855 | |
| 1856 | /* |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1857 | * We will set BAU_MISC_CONTROL with a timeout period. |
| 1858 | * But the BIOS has set UVH_AGING_PRESCALE_SEL and UVH_TRANSACTION_TIMEOUT. |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1859 | * So the destination timeout period has to be calculated from them. |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1860 | */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1861 | static int calculate_destination_timeout(void) |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1862 | { |
| 1863 | unsigned long mmr_image; |
| 1864 | int mult1; |
| 1865 | int mult2; |
| 1866 | int index; |
| 1867 | int base; |
| 1868 | int ret; |
| 1869 | unsigned long ts_ns; |
| 1870 | |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1871 | if (is_uv1_hub()) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1872 | mult1 = SOFTACK_TIMEOUT_PERIOD & BAU_MISC_CONTROL_MULT_MASK; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1873 | mmr_image = uv_read_local_mmr(UVH_AGING_PRESCALE_SEL); |
| 1874 | index = (mmr_image >> BAU_URGENCY_7_SHIFT) & BAU_URGENCY_7_MASK; |
| 1875 | mmr_image = uv_read_local_mmr(UVH_TRANSACTION_TIMEOUT); |
| 1876 | mult2 = (mmr_image >> BAU_TRANS_SHIFT) & BAU_TRANS_MASK; |
Cliff Wickman | 11cab71 | 2012-06-22 08:12:12 -0500 | [diff] [blame] | 1877 | ts_ns = timeout_base_ns[index]; |
| 1878 | ts_ns *= (mult1 * mult2); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1879 | ret = ts_ns / 1000; |
| 1880 | } else { |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 1881 | /* same destination timeout for uv2 and uv3 */ |
Cliff Wickman | d059f9f | 2012-01-16 15:18:48 -0600 | [diff] [blame] | 1882 | /* 4 bits 0/1 for 10/80us base, 3 bits of multiplier */ |
| 1883 | mmr_image = uv_read_local_mmr(UVH_LB_BAU_MISC_CONTROL); |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1884 | mmr_image = (mmr_image & UV_SA_MASK) >> UV_SA_SHFT; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1885 | if (mmr_image & (1L << UV2_ACK_UNITS_SHFT)) |
Cliff Wickman | d059f9f | 2012-01-16 15:18:48 -0600 | [diff] [blame] | 1886 | base = 80; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1887 | else |
Cliff Wickman | d059f9f | 2012-01-16 15:18:48 -0600 | [diff] [blame] | 1888 | base = 10; |
| 1889 | mult1 = mmr_image & UV2_ACK_MASK; |
Jack Steiner | 2a91959 | 2011-05-11 12:50:28 -0500 | [diff] [blame] | 1890 | ret = mult1 * base; |
| 1891 | } |
Cliff Wickman | 12a6611 | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 1892 | return ret; |
| 1893 | } |
| 1894 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1895 | static void __init init_per_cpu_tunables(void) |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1896 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1897 | int cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1898 | struct bau_control *bcp; |
| 1899 | |
| 1900 | for_each_present_cpu(cpu) { |
| 1901 | bcp = &per_cpu(bau_control, cpu); |
| 1902 | bcp->baudisabled = 0; |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 1903 | if (nobau) |
Alex Thorlton | 1c532e0 | 2016-03-31 14:18:29 -0500 | [diff] [blame] | 1904 | bcp->nobau = true; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1905 | bcp->statp = &per_cpu(ptcstats, cpu); |
| 1906 | /* time interval to catch a hardware stay-busy bug */ |
| 1907 | bcp->timeout_interval = usec_2_cycles(2*timeout_us); |
| 1908 | bcp->max_concurr = max_concurr; |
| 1909 | bcp->max_concurr_const = max_concurr; |
| 1910 | bcp->plugged_delay = plugged_delay; |
| 1911 | bcp->plugsb4reset = plugsb4reset; |
| 1912 | bcp->timeoutsb4reset = timeoutsb4reset; |
| 1913 | bcp->ipi_reset_limit = ipi_reset_limit; |
| 1914 | bcp->complete_threshold = complete_threshold; |
| 1915 | bcp->cong_response_us = congested_respns_us; |
| 1916 | bcp->cong_reps = congested_reps; |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1917 | bcp->disabled_period = sec_2_cycles(disabled_period); |
| 1918 | bcp->giveup_limit = giveup_limit; |
Cliff Wickman | d2ebc71 | 2012-01-18 09:40:47 -0600 | [diff] [blame] | 1919 | spin_lock_init(&bcp->queue_lock); |
| 1920 | spin_lock_init(&bcp->uvhub_lock); |
Cliff Wickman | 8b6e511 | 2012-06-22 08:14:59 -0500 | [diff] [blame] | 1921 | spin_lock_init(&bcp->disable_lock); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1922 | } |
| 1923 | } |
| 1924 | |
| 1925 | /* |
| 1926 | * Scan all cpus to collect blade and socket summaries. |
| 1927 | */ |
| 1928 | static int __init get_cpu_topology(int base_pnode, |
| 1929 | struct uvhub_desc *uvhub_descs, |
| 1930 | unsigned char *uvhub_mask) |
| 1931 | { |
| 1932 | int cpu; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1933 | int pnode; |
| 1934 | int uvhub; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1935 | int socket; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1936 | struct bau_control *bcp; |
| 1937 | struct uvhub_desc *bdp; |
| 1938 | struct socket_desc *sdp; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1939 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1940 | for_each_present_cpu(cpu) { |
| 1941 | bcp = &per_cpu(bau_control, cpu); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1942 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1943 | memset(bcp, 0, sizeof(struct bau_control)); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1944 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1945 | pnode = uv_cpu_hub_info(cpu)->pnode; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1946 | if ((pnode - base_pnode) >= UV_DISTRIBUTION_SIZE) { |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1947 | printk(KERN_EMERG |
| 1948 | "cpu %d pnode %d-%d beyond %d; BAU disabled\n", |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1949 | cpu, pnode, base_pnode, UV_DISTRIBUTION_SIZE); |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1950 | return 1; |
| 1951 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1952 | |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1953 | bcp->osnode = cpu_to_node(cpu); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1954 | bcp->partition_base_pnode = base_pnode; |
| 1955 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1956 | uvhub = uv_cpu_hub_info(cpu)->numa_blade_id; |
Cliff Wickman | c4026cf | 2010-07-30 14:10:55 -0500 | [diff] [blame] | 1957 | *(uvhub_mask + (uvhub/8)) |= (1 << (uvhub%8)); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1958 | bdp = &uvhub_descs[uvhub]; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1959 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1960 | bdp->num_cpus++; |
| 1961 | bdp->uvhub = uvhub; |
| 1962 | bdp->pnode = pnode; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1963 | |
Cliff Wickman | a8328ee | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1964 | /* kludge: 'assuming' one node per socket, and assuming that |
| 1965 | disabling a socket just leaves a gap in node numbers */ |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 1966 | socket = bcp->osnode & 1; |
Cliff Wickman | a8328ee | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 1967 | bdp->socket_mask |= (1 << socket); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1968 | sdp = &bdp->socket[socket]; |
| 1969 | sdp->cpu_number[sdp->num_cpus] = cpu; |
| 1970 | sdp->num_cpus++; |
Cliff Wickman | cfa6091 | 2011-01-03 12:03:53 -0600 | [diff] [blame] | 1971 | if (sdp->num_cpus > MAX_CPUS_PER_SOCKET) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1972 | printk(KERN_EMERG "%d cpus per socket invalid\n", |
| 1973 | sdp->num_cpus); |
Cliff Wickman | cfa6091 | 2011-01-03 12:03:53 -0600 | [diff] [blame] | 1974 | return 1; |
| 1975 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 1976 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 1977 | return 0; |
| 1978 | } |
| 1979 | |
| 1980 | /* |
| 1981 | * Each socket is to get a local array of pnodes/hubs. |
| 1982 | */ |
| 1983 | static void make_per_cpu_thp(struct bau_control *smaster) |
| 1984 | { |
| 1985 | int cpu; |
| 1986 | size_t hpsz = sizeof(struct hub_and_pnode) * num_possible_cpus(); |
| 1987 | |
| 1988 | smaster->thp = kmalloc_node(hpsz, GFP_KERNEL, smaster->osnode); |
| 1989 | memset(smaster->thp, 0, hpsz); |
| 1990 | for_each_present_cpu(cpu) { |
| 1991 | smaster->thp[cpu].pnode = uv_cpu_hub_info(cpu)->pnode; |
| 1992 | smaster->thp[cpu].uvhub = uv_cpu_hub_info(cpu)->numa_blade_id; |
| 1993 | } |
| 1994 | } |
| 1995 | |
| 1996 | /* |
cpw@sgi.com | 442d392 | 2011-06-21 07:21:31 -0500 | [diff] [blame] | 1997 | * Each uvhub is to get a local cpumask. |
| 1998 | */ |
| 1999 | static void make_per_hub_cpumask(struct bau_control *hmaster) |
| 2000 | { |
| 2001 | int sz = sizeof(cpumask_t); |
| 2002 | |
| 2003 | hmaster->cpumask = kzalloc_node(sz, GFP_KERNEL, hmaster->osnode); |
| 2004 | } |
| 2005 | |
| 2006 | /* |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2007 | * Initialize all the per_cpu information for the cpu's on a given socket, |
| 2008 | * given what has been gathered into the socket_desc struct. |
| 2009 | * And reports the chosen hub and socket masters back to the caller. |
| 2010 | */ |
| 2011 | static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp, |
| 2012 | struct bau_control **smasterp, |
| 2013 | struct bau_control **hmasterp) |
| 2014 | { |
| 2015 | int i; |
| 2016 | int cpu; |
| 2017 | struct bau_control *bcp; |
| 2018 | |
| 2019 | for (i = 0; i < sdp->num_cpus; i++) { |
| 2020 | cpu = sdp->cpu_number[i]; |
| 2021 | bcp = &per_cpu(bau_control, cpu); |
| 2022 | bcp->cpu = cpu; |
| 2023 | if (i == 0) { |
| 2024 | *smasterp = bcp; |
| 2025 | if (!(*hmasterp)) |
| 2026 | *hmasterp = bcp; |
| 2027 | } |
| 2028 | bcp->cpus_in_uvhub = bdp->num_cpus; |
| 2029 | bcp->cpus_in_socket = sdp->num_cpus; |
| 2030 | bcp->socket_master = *smasterp; |
| 2031 | bcp->uvhub = bdp->uvhub; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 2032 | if (is_uv1_hub()) |
| 2033 | bcp->uvhub_version = 1; |
| 2034 | else if (is_uv2_hub()) |
| 2035 | bcp->uvhub_version = 2; |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 2036 | else if (is_uv3_hub()) |
| 2037 | bcp->uvhub_version = 3; |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 2038 | else { |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 2039 | printk(KERN_EMERG "uvhub version not 1, 2 or 3\n"); |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 2040 | return 1; |
| 2041 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2042 | bcp->uvhub_master = *hmasterp; |
Mike Travis | 5627a825 | 2016-04-29 16:54:14 -0500 | [diff] [blame] | 2043 | bcp->uvhub_cpu = uv_cpu_blade_processor_id(cpu); |
| 2044 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2045 | if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) { |
| 2046 | printk(KERN_EMERG "%d cpus per uvhub invalid\n", |
| 2047 | bcp->uvhub_cpu); |
| 2048 | return 1; |
| 2049 | } |
| 2050 | } |
| 2051 | return 0; |
| 2052 | } |
| 2053 | |
| 2054 | /* |
| 2055 | * Summarize the blade and socket topology into the per_cpu structures. |
| 2056 | */ |
| 2057 | static int __init summarize_uvhub_sockets(int nuvhubs, |
| 2058 | struct uvhub_desc *uvhub_descs, |
| 2059 | unsigned char *uvhub_mask) |
| 2060 | { |
| 2061 | int socket; |
| 2062 | int uvhub; |
| 2063 | unsigned short socket_mask; |
| 2064 | |
Cliff Wickman | c4026cf | 2010-07-30 14:10:55 -0500 | [diff] [blame] | 2065 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2066 | struct uvhub_desc *bdp; |
| 2067 | struct bau_control *smaster = NULL; |
| 2068 | struct bau_control *hmaster = NULL; |
| 2069 | |
Cliff Wickman | c4026cf | 2010-07-30 14:10:55 -0500 | [diff] [blame] | 2070 | if (!(*(uvhub_mask + (uvhub/8)) & (1 << (uvhub%8)))) |
| 2071 | continue; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2072 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2073 | bdp = &uvhub_descs[uvhub]; |
Cliff Wickman | a8328ee | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 2074 | socket_mask = bdp->socket_mask; |
| 2075 | socket = 0; |
| 2076 | while (socket_mask) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2077 | struct socket_desc *sdp; |
| 2078 | if ((socket_mask & 1)) { |
| 2079 | sdp = &bdp->socket[socket]; |
| 2080 | if (scan_sock(sdp, bdp, &smaster, &hmaster)) |
Cliff Wickman | cfa6091 | 2011-01-03 12:03:53 -0600 | [diff] [blame] | 2081 | return 1; |
cpw@sgi.com | 9c9153d | 2011-06-21 07:21:28 -0500 | [diff] [blame] | 2082 | make_per_cpu_thp(smaster); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2083 | } |
| 2084 | socket++; |
Cliff Wickman | a8328ee | 2010-06-02 16:22:02 -0500 | [diff] [blame] | 2085 | socket_mask = (socket_mask >> 1); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2086 | } |
cpw@sgi.com | 442d392 | 2011-06-21 07:21:31 -0500 | [diff] [blame] | 2087 | make_per_hub_cpumask(hmaster); |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2088 | } |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2089 | return 0; |
| 2090 | } |
| 2091 | |
| 2092 | /* |
| 2093 | * initialize the bau_control structure for each cpu |
| 2094 | */ |
| 2095 | static int __init init_per_cpu(int nuvhubs, int base_part_pnode) |
| 2096 | { |
| 2097 | unsigned char *uvhub_mask; |
| 2098 | void *vp; |
| 2099 | struct uvhub_desc *uvhub_descs; |
| 2100 | |
| 2101 | timeout_us = calculate_destination_timeout(); |
| 2102 | |
| 2103 | vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL); |
| 2104 | uvhub_descs = (struct uvhub_desc *)vp; |
| 2105 | memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); |
| 2106 | uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); |
| 2107 | |
| 2108 | if (get_cpu_topology(base_part_pnode, uvhub_descs, uvhub_mask)) |
cpw@sgi.com | bbd270e | 2011-06-21 07:21:32 -0500 | [diff] [blame] | 2109 | goto fail; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2110 | |
| 2111 | if (summarize_uvhub_sockets(nuvhubs, uvhub_descs, uvhub_mask)) |
cpw@sgi.com | bbd270e | 2011-06-21 07:21:32 -0500 | [diff] [blame] | 2112 | goto fail; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2113 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2114 | kfree(uvhub_descs); |
Cliff Wickman | c4026cf | 2010-07-30 14:10:55 -0500 | [diff] [blame] | 2115 | kfree(uvhub_mask); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2116 | init_per_cpu_tunables(); |
Cliff Wickman | cfa6091 | 2011-01-03 12:03:53 -0600 | [diff] [blame] | 2117 | return 0; |
cpw@sgi.com | bbd270e | 2011-06-21 07:21:32 -0500 | [diff] [blame] | 2118 | |
| 2119 | fail: |
| 2120 | kfree(uvhub_descs); |
| 2121 | kfree(uvhub_mask); |
| 2122 | return 1; |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 2123 | } |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 2124 | |
| 2125 | /* |
| 2126 | * Initialization of BAU-related structures |
| 2127 | */ |
Cliff Wickman | b194b12 | 2008-06-12 08:23:48 -0500 | [diff] [blame] | 2128 | static int __init uv_bau_init(void) |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 2129 | { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2130 | int uvhub; |
| 2131 | int pnode; |
| 2132 | int nuvhubs; |
Rusty Russell | 2c74d66 | 2009-03-18 08:22:30 +1030 | [diff] [blame] | 2133 | int cur_cpu; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2134 | int cpus; |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2135 | int vector; |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2136 | cpumask_var_t *mask; |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 2137 | |
| 2138 | if (!is_uv_system()) |
| 2139 | return 0; |
| 2140 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2141 | for_each_possible_cpu(cur_cpu) { |
| 2142 | mask = &per_cpu(uv_flush_tlb_mask, cur_cpu); |
| 2143 | zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu)); |
| 2144 | } |
Rusty Russell | 76ba0ec | 2009-03-13 14:49:57 +1030 | [diff] [blame] | 2145 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2146 | nuvhubs = uv_num_possible_blades(); |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2147 | congested_cycles = usec_2_cycles(congested_respns_us); |
Cliff Wickman | 9674f35 | 2009-04-03 08:34:05 -0500 | [diff] [blame] | 2148 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2149 | uv_base_pnode = 0x7fffffff; |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 2150 | for (uvhub = 0; uvhub < nuvhubs; uvhub++) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2151 | cpus = uv_blade_nr_possible_cpus(uvhub); |
| 2152 | if (cpus && (uv_blade_to_pnode(uvhub) < uv_base_pnode)) |
| 2153 | uv_base_pnode = uv_blade_to_pnode(uvhub); |
Cliff Wickman | 77ed23f | 2011-05-10 08:26:43 -0500 | [diff] [blame] | 2154 | } |
| 2155 | |
Cliff Wickman | d059f9f | 2012-01-16 15:18:48 -0600 | [diff] [blame] | 2156 | enable_timeouts(); |
| 2157 | |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2158 | if (init_per_cpu(nuvhubs, uv_base_pnode)) { |
Cliff Wickman | 26ef857 | 2012-06-22 08:13:30 -0500 | [diff] [blame] | 2159 | set_bau_off(); |
| 2160 | nobau_perm = 1; |
Cliff Wickman | cfa6091 | 2011-01-03 12:03:53 -0600 | [diff] [blame] | 2161 | return 0; |
| 2162 | } |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 2163 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2164 | vector = UV_BAU_MESSAGE; |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 2165 | for_each_possible_blade(uvhub) { |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2166 | if (uv_blade_nr_possible_cpus(uvhub)) |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2167 | init_uvhub(uvhub, vector, uv_base_pnode); |
Cliff Wickman | a26fd71 | 2014-05-14 16:15:47 -0500 | [diff] [blame] | 2168 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2169 | |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2170 | alloc_intr_gate(vector, uv_bau_message_intr1); |
| 2171 | |
| 2172 | for_each_possible_blade(uvhub) { |
Cliff Wickman | 93a7ca0 | 2010-07-16 10:11:21 -0500 | [diff] [blame] | 2173 | if (uv_blade_nr_possible_cpus(uvhub)) { |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2174 | unsigned long val; |
| 2175 | unsigned long mmr; |
Cliff Wickman | 93a7ca0 | 2010-07-16 10:11:21 -0500 | [diff] [blame] | 2176 | pnode = uv_blade_to_pnode(uvhub); |
| 2177 | /* INIT the bau */ |
Cliff Wickman | f073cc8 | 2011-05-24 13:07:36 -0500 | [diff] [blame] | 2178 | val = 1L << 63; |
| 2179 | write_gmmr_activation(pnode, val); |
Cliff Wickman | 93a7ca0 | 2010-07-16 10:11:21 -0500 | [diff] [blame] | 2180 | mmr = 1; /* should be 1 to broadcast to both sockets */ |
Cliff Wickman | da87c93 | 2012-01-16 15:17:50 -0600 | [diff] [blame] | 2181 | if (!is_uv1_hub()) |
| 2182 | write_mmr_data_broadcast(pnode, mmr); |
Cliff Wickman | 93a7ca0 | 2010-07-16 10:11:21 -0500 | [diff] [blame] | 2183 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2184 | } |
Ingo Molnar | b4c286e | 2008-06-18 14:28:19 +0200 | [diff] [blame] | 2185 | |
Cliff Wickman | 1812924 | 2008-06-02 08:56:14 -0500 | [diff] [blame] | 2186 | return 0; |
| 2187 | } |
Cliff Wickman | b8f7fb1 | 2010-04-14 11:35:46 -0500 | [diff] [blame] | 2188 | core_initcall(uv_bau_init); |
Cliff Wickman | e8e5e8a | 2010-06-02 16:22:01 -0500 | [diff] [blame] | 2189 | fs_initcall(uv_ptc_init); |