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