x86, UV: Calculate BAU destination timeout

Calculate the Broadcast Assist Unit's destination timeout period from the
values in the relevant MMR's.

Store it in each cpu's per-cpu BAU structure so that a destination
timeout can be differentiated from a 'plugged' situation in which all
software ack resources are already allocated and a timeout is pending.
That case returns an immediate destination error.

Signed-off-by: Cliff Wickman <cpw@sgi.com>
Cc: gregkh@suse.de
LKML-Reference: <E1OJvNx-0004Zq-RK@eag09.americas.sgi.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>

authored by Cliff Wickman and committed by Ingo Molnar 12a6611f 3975d167

+59 -4
+12
arch/x86/include/asm/uv/uv_bau.h
··· 49 49 #define UV_ENABLE_INTD_SOFT_ACK_MODE_SHIFT 15 50 50 #define UV_INTD_SOFT_ACK_TIMEOUT_PERIOD_SHIFT 16 51 51 #define UV_INTD_SOFT_ACK_TIMEOUT_PERIOD 0x000000000bUL 52 + /* [19:16] SOFT_ACK timeout period 19: 1 is urgency 7 17:16 1 is multiplier */ 53 + #define BAU_MISC_CONTROL_MULT_MASK 3 54 + 55 + #define UVH_AGING_PRESCALE_SEL 0x000000b000UL 56 + /* [30:28] URGENCY_7 an index into a table of times */ 57 + #define BAU_URGENCY_7_SHIFT 28 58 + #define BAU_URGENCY_7_MASK 7 59 + 60 + #define UVH_TRANSACTION_TIMEOUT 0x000000b200UL 61 + /* [45:40] BAU - BAU transaction timeout select - a multiplier */ 62 + #define BAU_TRANS_SHIFT 40 63 + #define BAU_TRANS_MASK 0x3f 52 64 53 65 /* 54 66 * bits in UVH_LB_BAU_SB_ACTIVATION_STATUS_0/1
+47 -4
arch/x86/kernel/tlb_uv.c
··· 30 30 struct bau_payload_queue_entry *va_queue_last; 31 31 }; 32 32 33 + /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */ 34 + static int timeout_base_ns[] = { 35 + 20, 36 + 160, 37 + 1280, 38 + 10240, 39 + 81920, 40 + 655360, 41 + 5242880, 42 + 167772160 43 + }; 44 + static int timeout_us; 45 + 33 46 #define UV_INTD_SOFT_ACK_TIMEOUT_PERIOD 0x000000000bUL 34 47 35 48 static int uv_bau_max_concurrent __read_mostly; ··· 436 423 * pending. In that case hardware returns the 437 424 * ERROR that looks like a destination timeout. 438 425 */ 439 - if (cycles_2_us(ttime - bcp->send_message) < BIOS_TO) { 426 + if (cycles_2_us(ttime - bcp->send_message) < 427 + timeout_us) { 440 428 bcp->conseccompletes = 0; 441 429 return FLUSH_RETRY_PLUGGED; 442 430 } ··· 922 908 } 923 909 924 910 static inline unsigned long long 925 - millisec_2_cycles(unsigned long millisec) 911 + microsec_2_cycles(unsigned long microsec) 926 912 { 927 913 unsigned long ns; 928 914 unsigned long long cyc; 929 915 930 - ns = millisec * 1000; 916 + ns = microsec * 1000; 931 917 cyc = (ns << CYC2NS_SCALE_FACTOR)/(per_cpu(cyc2ns, smp_processor_id())); 932 918 return cyc; 933 919 } ··· 1273 1259 } 1274 1260 1275 1261 /* 1262 + * We will set BAU_MISC_CONTROL with a timeout period. 1263 + * But the BIOS has set UVH_AGING_PRESCALE_SEL and UVH_TRANSACTION_TIMEOUT. 1264 + * So the destination timeout period has be be calculated from them. 1265 + */ 1266 + static int 1267 + calculate_destination_timeout(void) 1268 + { 1269 + unsigned long mmr_image; 1270 + int mult1; 1271 + int mult2; 1272 + int index; 1273 + int base; 1274 + int ret; 1275 + unsigned long ts_ns; 1276 + 1277 + mult1 = UV_INTD_SOFT_ACK_TIMEOUT_PERIOD & BAU_MISC_CONTROL_MULT_MASK; 1278 + mmr_image = uv_read_local_mmr(UVH_AGING_PRESCALE_SEL); 1279 + index = (mmr_image >> BAU_URGENCY_7_SHIFT) & BAU_URGENCY_7_MASK; 1280 + mmr_image = uv_read_local_mmr(UVH_TRANSACTION_TIMEOUT); 1281 + mult2 = (mmr_image >> BAU_TRANS_SHIFT) & BAU_TRANS_MASK; 1282 + base = timeout_base_ns[index]; 1283 + ts_ns = base * mult1 * mult2; 1284 + ret = ts_ns / 1000; 1285 + return ret; 1286 + } 1287 + 1288 + /* 1276 1289 * initialize the bau_control structure for each cpu 1277 1290 */ 1278 1291 static void uv_init_per_cpu(int nuvhubs) ··· 1327 1286 }; 1328 1287 struct uvhub_desc *uvhub_descs; 1329 1288 1289 + timeout_us = calculate_destination_timeout(); 1290 + 1330 1291 uvhub_descs = (struct uvhub_desc *) 1331 1292 kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL); 1332 1293 memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); ··· 1344 1301 bdp->uvhub = uvhub; 1345 1302 bdp->pnode = pnode; 1346 1303 /* time interval to catch a hardware stay-busy bug */ 1347 - bcp->timeout_interval = millisec_2_cycles(3); 1304 + bcp->timeout_interval = microsec_2_cycles(2*timeout_us); 1348 1305 /* kludge: assume uv_hub.h is constant */ 1349 1306 socket = (cpu_physical_id(cpu)>>5)&1; 1350 1307 if (socket >= bdp->num_sockets)