2 * SGI UltraViolet TLB flush routines.
4 * (c) 2008-2010 Cliff Wickman <cpw@sgi.com>, SGI.
6 * This code is released under the GNU General Public License version 2 or
9 #include <linux/seq_file.h>
10 #include <linux/proc_fs.h>
11 #include <linux/debugfs.h>
12 #include <linux/kernel.h>
13 #include <linux/slab.h>
14 #include <linux/delay.h>
16 #include <asm/mmu_context.h>
17 #include <asm/uv/uv.h>
18 #include <asm/uv/uv_mmrs.h>
19 #include <asm/uv/uv_hub.h>
20 #include <asm/uv/uv_bau.h>
24 #include <asm/irq_vectors.h>
25 #include <asm/timer.h>
27 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
28 static int timeout_base_ns
[] = {
38 static int timeout_us
;
40 static int baudisabled
;
41 static spinlock_t disable_lock
;
42 static cycles_t congested_cycles
;
45 static int max_bau_concurrent
= MAX_BAU_CONCURRENT
;
46 static int max_bau_concurrent_constant
= MAX_BAU_CONCURRENT
;
47 static int plugged_delay
= PLUGGED_DELAY
;
48 static int plugsb4reset
= PLUGSB4RESET
;
49 static int timeoutsb4reset
= TIMEOUTSB4RESET
;
50 static int ipi_reset_limit
= IPI_RESET_LIMIT
;
51 static int complete_threshold
= COMPLETE_THRESHOLD
;
52 static int congested_response_us
= CONGESTED_RESPONSE_US
;
53 static int congested_reps
= CONGESTED_REPS
;
54 static int congested_period
= CONGESTED_PERIOD
;
55 static struct dentry
*tunables_dir
;
56 static struct dentry
*tunables_file
;
58 static int __init
setup_nobau(char *arg
)
63 early_param("nobau", setup_nobau
);
65 /* base pnode in this partition */
66 static int uv_partition_base_pnode __read_mostly
;
67 /* position of pnode (which is nasid>>1): */
68 static int uv_nshift __read_mostly
;
69 static unsigned long uv_mmask __read_mostly
;
71 static DEFINE_PER_CPU(struct ptc_stats
, ptcstats
);
72 static DEFINE_PER_CPU(struct bau_control
, bau_control
);
73 static DEFINE_PER_CPU(cpumask_var_t
, uv_flush_tlb_mask
);
76 * Determine the first node on a uvhub. 'Nodes' are used for kernel
79 static int __init
uvhub_to_first_node(int uvhub
)
83 for_each_online_node(node
) {
84 b
= uv_node_to_blade_id(node
);
92 * Determine the apicid of the first cpu on a uvhub.
94 static int __init
uvhub_to_first_apicid(int uvhub
)
98 for_each_present_cpu(cpu
)
99 if (uvhub
== uv_cpu_to_blade_id(cpu
))
100 return per_cpu(x86_cpu_to_apicid
, cpu
);
105 * Free a software acknowledge hardware resource by clearing its Pending
106 * bit. This will return a reply to the sender.
107 * If the message has timed out, a reply has already been sent by the
108 * hardware but the resource has not been released. In that case our
109 * clear of the Timeout bit (as well) will free the resource. No reply will
110 * be sent (the hardware will only do one reply per message).
112 static inline void uv_reply_to_message(struct msg_desc
*mdp
,
113 struct bau_control
*bcp
)
116 struct bau_payload_queue_entry
*msg
;
119 if (!msg
->canceled
) {
120 dw
= (msg
->sw_ack_vector
<< UV_SW_ACK_NPENDING
) |
123 UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_ALIAS
, dw
);
126 msg
->sw_ack_vector
= 0;
130 * Process the receipt of a RETRY message
132 static inline void uv_bau_process_retry_msg(struct msg_desc
*mdp
,
133 struct bau_control
*bcp
)
136 int cancel_count
= 0;
138 unsigned long msg_res
;
139 unsigned long mmr
= 0;
140 struct bau_payload_queue_entry
*msg
;
141 struct bau_payload_queue_entry
*msg2
;
142 struct ptc_stats
*stat
;
148 * cancel any message from msg+1 to the retry itself
150 for (msg2
= msg
+1, i
= 0; i
< DEST_Q_SIZE
; msg2
++, i
++) {
151 if (msg2
> mdp
->va_queue_last
)
152 msg2
= mdp
->va_queue_first
;
156 /* same conditions for cancellation as uv_do_reset */
157 if ((msg2
->replied_to
== 0) && (msg2
->canceled
== 0) &&
158 (msg2
->sw_ack_vector
) && ((msg2
->sw_ack_vector
&
159 msg
->sw_ack_vector
) == 0) &&
160 (msg2
->sending_cpu
== msg
->sending_cpu
) &&
161 (msg2
->msg_type
!= MSG_NOOP
)) {
162 slot2
= msg2
- mdp
->va_queue_first
;
163 mmr
= uv_read_local_mmr
164 (UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE
);
165 msg_res
= msg2
->sw_ack_vector
;
167 * This is a message retry; clear the resources held
168 * by the previous message only if they timed out.
169 * If it has not timed out we have an unexpected
170 * situation to report.
172 if (mmr
& (msg_res
<< UV_SW_ACK_NPENDING
)) {
174 * is the resource timed out?
175 * make everyone ignore the cancelled message.
181 UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_ALIAS
,
182 (msg_res
<< UV_SW_ACK_NPENDING
) |
188 stat
->d_nocanceled
++;
192 * Do all the things a cpu should do for a TLB shootdown message.
193 * Other cpu's may come here at the same time for this message.
195 static void uv_bau_process_message(struct msg_desc
*mdp
,
196 struct bau_control
*bcp
)
199 short socket_ack_count
= 0;
200 struct ptc_stats
*stat
;
201 struct bau_payload_queue_entry
*msg
;
202 struct bau_control
*smaster
= bcp
->socket_master
;
205 * This must be a normal message, or retry of a normal message
209 if (msg
->address
== TLB_FLUSH_ALL
) {
213 __flush_tlb_one(msg
->address
);
219 * One cpu on each uvhub has the additional job on a RETRY
220 * of releasing the resource held by the message that is
221 * being retried. That message is identified by sending
224 if (msg
->msg_type
== MSG_RETRY
&& bcp
== bcp
->uvhub_master
)
225 uv_bau_process_retry_msg(mdp
, bcp
);
228 * This is a sw_ack message, so we have to reply to it.
229 * Count each responding cpu on the socket. This avoids
230 * pinging the count's cache line back and forth between
233 socket_ack_count
= atomic_add_short_return(1, (struct atomic_short
*)
234 &smaster
->socket_acknowledge_count
[mdp
->msg_slot
]);
235 if (socket_ack_count
== bcp
->cpus_in_socket
) {
237 * Both sockets dump their completed count total into
238 * the message's count.
240 smaster
->socket_acknowledge_count
[mdp
->msg_slot
] = 0;
241 msg_ack_count
= atomic_add_short_return(socket_ack_count
,
242 (struct atomic_short
*)&msg
->acknowledge_count
);
244 if (msg_ack_count
== bcp
->cpus_in_uvhub
) {
246 * All cpus in uvhub saw it; reply
248 uv_reply_to_message(mdp
, bcp
);
256 * Determine the first cpu on a uvhub.
258 static int uvhub_to_first_cpu(int uvhub
)
261 for_each_present_cpu(cpu
)
262 if (uvhub
== uv_cpu_to_blade_id(cpu
))
268 * Last resort when we get a large number of destination timeouts is
269 * to clear resources held by a given cpu.
270 * Do this with IPI so that all messages in the BAU message queue
271 * can be identified by their nonzero sw_ack_vector field.
273 * This is entered for a single cpu on the uvhub.
274 * The sender want's this uvhub to free a specific message's
278 uv_do_reset(void *ptr
)
284 unsigned long msg_res
;
285 struct bau_control
*bcp
;
286 struct reset_args
*rap
;
287 struct bau_payload_queue_entry
*msg
;
288 struct ptc_stats
*stat
;
290 bcp
= &per_cpu(bau_control
, smp_processor_id());
291 rap
= (struct reset_args
*)ptr
;
296 * We're looking for the given sender, and
297 * will free its sw_ack resource.
298 * If all cpu's finally responded after the timeout, its
299 * message 'replied_to' was set.
301 for (msg
= bcp
->va_queue_first
, i
= 0; i
< DEST_Q_SIZE
; msg
++, i
++) {
302 /* uv_do_reset: same conditions for cancellation as
303 uv_bau_process_retry_msg() */
304 if ((msg
->replied_to
== 0) &&
305 (msg
->canceled
== 0) &&
306 (msg
->sending_cpu
== rap
->sender
) &&
307 (msg
->sw_ack_vector
) &&
308 (msg
->msg_type
!= MSG_NOOP
)) {
310 * make everyone else ignore this message
313 slot
= msg
- bcp
->va_queue_first
;
316 * only reset the resource if it is still pending
318 mmr
= uv_read_local_mmr
319 (UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE
);
320 msg_res
= msg
->sw_ack_vector
;
324 UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE_ALIAS
,
325 (msg_res
<< UV_SW_ACK_NPENDING
) |
334 * Use IPI to get all target uvhubs to release resources held by
335 * a given sending cpu number.
337 static void uv_reset_with_ipi(struct bau_target_uvhubmask
*distribution
,
343 struct reset_args reset_args
;
345 reset_args
.sender
= sender
;
348 /* find a single cpu for each uvhub in this distribution mask */
350 uvhub
< sizeof(struct bau_target_uvhubmask
) * BITSPERBYTE
;
352 if (!bau_uvhub_isset(uvhub
, distribution
))
354 /* find a cpu for this uvhub */
355 cpu
= uvhub_to_first_cpu(uvhub
);
358 /* IPI all cpus; Preemption is already disabled */
359 smp_call_function_many(&mask
, uv_do_reset
, (void *)&reset_args
, 1);
363 static inline unsigned long
364 cycles_2_us(unsigned long long cyc
)
366 unsigned long long ns
;
368 ns
= (cyc
* per_cpu(cyc2ns
, smp_processor_id()))
369 >> CYC2NS_SCALE_FACTOR
;
375 * wait for all cpus on this hub to finish their sends and go quiet
376 * leaves uvhub_quiesce set so that no new broadcasts are started by
377 * bau_flush_send_and_wait()
380 quiesce_local_uvhub(struct bau_control
*hmaster
)
382 atomic_add_short_return(1, (struct atomic_short
*)
383 &hmaster
->uvhub_quiesce
);
387 * mark this quiet-requestor as done
390 end_uvhub_quiesce(struct bau_control
*hmaster
)
392 atomic_add_short_return(-1, (struct atomic_short
*)
393 &hmaster
->uvhub_quiesce
);
397 * Wait for completion of a broadcast software ack message
398 * return COMPLETE, RETRY(PLUGGED or TIMEOUT) or GIVEUP
400 static int uv_wait_completion(struct bau_desc
*bau_desc
,
401 unsigned long mmr_offset
, int right_shift
, int this_cpu
,
402 struct bau_control
*bcp
, struct bau_control
*smaster
, long try)
404 unsigned long descriptor_status
;
406 struct ptc_stats
*stat
= bcp
->statp
;
407 struct bau_control
*hmaster
;
409 hmaster
= bcp
->uvhub_master
;
411 /* spin on the status MMR, waiting for it to go idle */
412 while ((descriptor_status
= (((unsigned long)
413 uv_read_local_mmr(mmr_offset
) >>
414 right_shift
) & UV_ACT_STATUS_MASK
)) !=
417 * Our software ack messages may be blocked because there are
418 * no swack resources available. As long as none of them
419 * has timed out hardware will NACK our message and its
420 * state will stay IDLE.
422 if (descriptor_status
== DESC_STATUS_SOURCE_TIMEOUT
) {
425 } else if (descriptor_status
==
426 DESC_STATUS_DESTINATION_TIMEOUT
) {
428 ttime
= get_cycles();
431 * Our retries may be blocked by all destination
432 * swack resources being consumed, and a timeout
433 * pending. In that case hardware returns the
434 * ERROR that looks like a destination timeout.
436 if (cycles_2_us(ttime
- bcp
->send_message
) <
438 bcp
->conseccompletes
= 0;
439 return FLUSH_RETRY_PLUGGED
;
442 bcp
->conseccompletes
= 0;
443 return FLUSH_RETRY_TIMEOUT
;
446 * descriptor_status is still BUSY
451 bcp
->conseccompletes
++;
452 return FLUSH_COMPLETE
;
455 static inline cycles_t
456 sec_2_cycles(unsigned long sec
)
461 ns
= sec
* 1000000000;
462 cyc
= (ns
<< CYC2NS_SCALE_FACTOR
)/(per_cpu(cyc2ns
, smp_processor_id()));
467 * conditionally add 1 to *v, unless *v is >= u
468 * return 0 if we cannot add 1 to *v because it is >= u
469 * return 1 if we can add 1 to *v because it is < u
472 * This is close to atomic_add_unless(), but this allows the 'u' value
473 * to be lowered below the current 'v'. atomic_add_unless can only stop
476 static inline int atomic_inc_unless_ge(spinlock_t
*lock
, atomic_t
*v
, int u
)
479 if (atomic_read(v
) >= u
) {
489 * Our retries are blocked by all destination swack resources being
490 * in use, and a timeout is pending. In that case hardware immediately
491 * returns the ERROR that looks like a destination timeout.
494 destination_plugged(struct bau_desc
*bau_desc
, struct bau_control
*bcp
,
495 struct bau_control
*hmaster
, struct ptc_stats
*stat
)
497 udelay(bcp
->plugged_delay
);
498 bcp
->plugged_tries
++;
499 if (bcp
->plugged_tries
>= bcp
->plugsb4reset
) {
500 bcp
->plugged_tries
= 0;
501 quiesce_local_uvhub(hmaster
);
502 spin_lock(&hmaster
->queue_lock
);
503 uv_reset_with_ipi(&bau_desc
->distribution
, bcp
->cpu
);
504 spin_unlock(&hmaster
->queue_lock
);
505 end_uvhub_quiesce(hmaster
);
507 stat
->s_resets_plug
++;
512 destination_timeout(struct bau_desc
*bau_desc
, struct bau_control
*bcp
,
513 struct bau_control
*hmaster
, struct ptc_stats
*stat
)
515 hmaster
->max_bau_concurrent
= 1;
516 bcp
->timeout_tries
++;
517 if (bcp
->timeout_tries
>= bcp
->timeoutsb4reset
) {
518 bcp
->timeout_tries
= 0;
519 quiesce_local_uvhub(hmaster
);
520 spin_lock(&hmaster
->queue_lock
);
521 uv_reset_with_ipi(&bau_desc
->distribution
, bcp
->cpu
);
522 spin_unlock(&hmaster
->queue_lock
);
523 end_uvhub_quiesce(hmaster
);
525 stat
->s_resets_timeout
++;
530 * Completions are taking a very long time due to a congested numalink
534 disable_for_congestion(struct bau_control
*bcp
, struct ptc_stats
*stat
)
537 struct bau_control
*tbcp
;
539 /* let only one cpu do this disabling */
540 spin_lock(&disable_lock
);
541 if (!baudisabled
&& bcp
->period_requests
&&
542 ((bcp
->period_time
/ bcp
->period_requests
) > congested_cycles
)) {
543 /* it becomes this cpu's job to turn on the use of the
546 bcp
->set_bau_off
= 1;
547 bcp
->set_bau_on_time
= get_cycles() +
548 sec_2_cycles(bcp
->congested_period
);
549 stat
->s_bau_disabled
++;
550 for_each_present_cpu(tcpu
) {
551 tbcp
= &per_cpu(bau_control
, tcpu
);
552 tbcp
->baudisabled
= 1;
555 spin_unlock(&disable_lock
);
559 * uv_flush_send_and_wait
561 * Send a broadcast and wait for it to complete.
563 * The flush_mask contains the cpus the broadcast is to be sent to including
564 * cpus that are on the local uvhub.
566 * Returns 0 if all flushing represented in the mask was done.
567 * Returns 1 if it gives up entirely and the original cpu mask is to be
568 * returned to the kernel.
570 int uv_flush_send_and_wait(struct bau_desc
*bau_desc
,
571 struct cpumask
*flush_mask
, struct bau_control
*bcp
)
574 int completion_status
= 0;
577 int cpu
= bcp
->uvhub_cpu
;
578 int this_cpu
= bcp
->cpu
;
579 unsigned long mmr_offset
;
584 struct ptc_stats
*stat
= bcp
->statp
;
585 struct bau_control
*smaster
= bcp
->socket_master
;
586 struct bau_control
*hmaster
= bcp
->uvhub_master
;
588 if (!atomic_inc_unless_ge(&hmaster
->uvhub_lock
,
589 &hmaster
->active_descriptor_count
,
590 hmaster
->max_bau_concurrent
)) {
594 } while (!atomic_inc_unless_ge(&hmaster
->uvhub_lock
,
595 &hmaster
->active_descriptor_count
,
596 hmaster
->max_bau_concurrent
));
598 while (hmaster
->uvhub_quiesce
)
601 if (cpu
< UV_CPUS_PER_ACT_STATUS
) {
602 mmr_offset
= UVH_LB_BAU_SB_ACTIVATION_STATUS_0
;
603 right_shift
= cpu
* UV_ACT_STATUS_SIZE
;
605 mmr_offset
= UVH_LB_BAU_SB_ACTIVATION_STATUS_1
;
607 ((cpu
- UV_CPUS_PER_ACT_STATUS
) * UV_ACT_STATUS_SIZE
);
609 time1
= get_cycles();
612 bau_desc
->header
.msg_type
= MSG_REGULAR
;
613 seq_number
= bcp
->message_number
++;
615 bau_desc
->header
.msg_type
= MSG_RETRY
;
616 stat
->s_retry_messages
++;
618 bau_desc
->header
.sequence
= seq_number
;
619 index
= (1UL << UVH_LB_BAU_SB_ACTIVATION_CONTROL_PUSH_SHFT
) |
621 bcp
->send_message
= get_cycles();
622 uv_write_local_mmr(UVH_LB_BAU_SB_ACTIVATION_CONTROL
, index
);
624 completion_status
= uv_wait_completion(bau_desc
, mmr_offset
,
625 right_shift
, this_cpu
, bcp
, smaster
, try);
627 if (completion_status
== FLUSH_RETRY_PLUGGED
) {
628 destination_plugged(bau_desc
, bcp
, hmaster
, stat
);
629 } else if (completion_status
== FLUSH_RETRY_TIMEOUT
) {
630 destination_timeout(bau_desc
, bcp
, hmaster
, stat
);
632 if (bcp
->ipi_attempts
>= bcp
->ipi_reset_limit
) {
633 bcp
->ipi_attempts
= 0;
634 completion_status
= FLUSH_GIVEUP
;
638 } while ((completion_status
== FLUSH_RETRY_PLUGGED
) ||
639 (completion_status
== FLUSH_RETRY_TIMEOUT
));
640 time2
= get_cycles();
641 bcp
->plugged_tries
= 0;
642 bcp
->timeout_tries
= 0;
643 if ((completion_status
== FLUSH_COMPLETE
) &&
644 (bcp
->conseccompletes
> bcp
->complete_threshold
) &&
645 (hmaster
->max_bau_concurrent
<
646 hmaster
->max_bau_concurrent_constant
))
647 hmaster
->max_bau_concurrent
++;
648 while (hmaster
->uvhub_quiesce
)
650 atomic_dec(&hmaster
->active_descriptor_count
);
652 elapsed
= time2
- time1
;
653 stat
->s_time
+= elapsed
;
654 if ((completion_status
== FLUSH_COMPLETE
) && (try == 1)) {
655 bcp
->period_requests
++;
656 bcp
->period_time
+= elapsed
;
657 if ((elapsed
> congested_cycles
) &&
658 (bcp
->period_requests
> bcp
->congested_reps
)) {
659 disable_for_congestion(bcp
, stat
);
664 if (completion_status
== FLUSH_COMPLETE
&& try > 1)
666 else if (completion_status
== FLUSH_GIVEUP
) {
674 * uv_flush_tlb_others - globally purge translation cache of a virtual
675 * address or all TLB's
676 * @cpumask: mask of all cpu's in which the address is to be removed
677 * @mm: mm_struct containing virtual address range
678 * @va: virtual address to be removed (or TLB_FLUSH_ALL for all TLB's on cpu)
679 * @cpu: the current cpu
681 * This is the entry point for initiating any UV global TLB shootdown.
683 * Purges the translation caches of all specified processors of the given
684 * virtual address, or purges all TLB's on specified processors.
686 * The caller has derived the cpumask from the mm_struct. This function
687 * is called only if there are bits set in the mask. (e.g. flush_tlb_page())
689 * The cpumask is converted into a uvhubmask of the uvhubs containing
692 * Note that this function should be called with preemption disabled.
694 * Returns NULL if all remote flushing was done.
695 * Returns pointer to cpumask if some remote flushing remains to be
696 * done. The returned pointer is valid till preemption is re-enabled.
698 const struct cpumask
*uv_flush_tlb_others(const struct cpumask
*cpumask
,
699 struct mm_struct
*mm
,
700 unsigned long va
, unsigned int cpu
)
707 struct bau_desc
*bau_desc
;
708 struct cpumask
*flush_mask
;
709 struct ptc_stats
*stat
;
710 struct bau_control
*bcp
;
711 struct bau_control
*tbcp
;
713 /* kernel was booted 'nobau' */
717 bcp
= &per_cpu(bau_control
, cpu
);
720 /* bau was disabled due to slow response */
721 if (bcp
->baudisabled
) {
722 /* the cpu that disabled it must re-enable it */
723 if (bcp
->set_bau_off
) {
724 if (get_cycles() >= bcp
->set_bau_on_time
) {
725 stat
->s_bau_reenabled
++;
727 for_each_present_cpu(tcpu
) {
728 tbcp
= &per_cpu(bau_control
, tcpu
);
729 tbcp
->baudisabled
= 0;
730 tbcp
->period_requests
= 0;
731 tbcp
->period_time
= 0;
739 * Each sending cpu has a per-cpu mask which it fills from the caller's
740 * cpu mask. All cpus are converted to uvhubs and copied to the
741 * activation descriptor.
743 flush_mask
= (struct cpumask
*)per_cpu(uv_flush_tlb_mask
, cpu
);
744 /* don't actually do a shootdown of the local cpu */
745 cpumask_andnot(flush_mask
, cpumask
, cpumask_of(cpu
));
746 if (cpu_isset(cpu
, *cpumask
))
749 bau_desc
= bcp
->descriptor_base
;
750 bau_desc
+= UV_ITEMS_PER_DESCRIPTOR
* bcp
->uvhub_cpu
;
751 bau_uvhubs_clear(&bau_desc
->distribution
, UV_DISTRIBUTION_SIZE
);
754 for_each_cpu(tcpu
, flush_mask
) {
755 uvhub
= uv_cpu_to_blade_id(tcpu
);
756 bau_uvhub_set(uvhub
, &bau_desc
->distribution
);
757 if (uvhub
== bcp
->uvhub
)
762 if ((locals
+ remotes
) == 0)
765 stat
->s_ntargcpu
+= remotes
+ locals
;
766 stat
->s_ntargremotes
+= remotes
;
767 stat
->s_ntarglocals
+= locals
;
768 remotes
= bau_uvhub_weight(&bau_desc
->distribution
);
770 /* uvhub statistics */
771 hubs
= bau_uvhub_weight(&bau_desc
->distribution
);
773 stat
->s_ntarglocaluvhub
++;
774 stat
->s_ntargremoteuvhub
+= (hubs
- 1);
776 stat
->s_ntargremoteuvhub
+= hubs
;
777 stat
->s_ntarguvhub
+= hubs
;
779 stat
->s_ntarguvhub16
++;
781 stat
->s_ntarguvhub8
++;
783 stat
->s_ntarguvhub4
++;
785 stat
->s_ntarguvhub2
++;
787 stat
->s_ntarguvhub1
++;
789 bau_desc
->payload
.address
= va
;
790 bau_desc
->payload
.sending_cpu
= cpu
;
793 * uv_flush_send_and_wait returns 0 if all cpu's were messaged,
794 * or 1 if it gave up and the original cpumask should be returned.
796 if (!uv_flush_send_and_wait(bau_desc
, flush_mask
, bcp
))
803 * The BAU message interrupt comes here. (registered by set_intr_gate)
806 * We received a broadcast assist message.
808 * Interrupts are disabled; this interrupt could represent
809 * the receipt of several messages.
811 * All cores/threads on this hub get this interrupt.
812 * The last one to see it does the software ack.
813 * (the resource will not be freed until noninterruptable cpus see this
814 * interrupt; hardware may timeout the s/w ack and reply ERROR)
816 void uv_bau_message_interrupt(struct pt_regs
*regs
)
820 struct bau_payload_queue_entry
*msg
;
821 struct bau_control
*bcp
;
822 struct ptc_stats
*stat
;
823 struct msg_desc msgdesc
;
825 time_start
= get_cycles();
826 bcp
= &per_cpu(bau_control
, smp_processor_id());
828 msgdesc
.va_queue_first
= bcp
->va_queue_first
;
829 msgdesc
.va_queue_last
= bcp
->va_queue_last
;
830 msg
= bcp
->bau_msg_head
;
831 while (msg
->sw_ack_vector
) {
833 msgdesc
.msg_slot
= msg
- msgdesc
.va_queue_first
;
834 msgdesc
.sw_ack_slot
= ffs(msg
->sw_ack_vector
) - 1;
836 uv_bau_process_message(&msgdesc
, bcp
);
838 if (msg
> msgdesc
.va_queue_last
)
839 msg
= msgdesc
.va_queue_first
;
840 bcp
->bau_msg_head
= msg
;
842 stat
->d_time
+= (get_cycles() - time_start
);
853 * Each target uvhub (i.e. a uvhub that has no cpu's) needs to have
854 * shootdown message timeouts enabled. The timeout does not cause
855 * an interrupt, but causes an error message to be returned to
858 static void uv_enable_timeouts(void)
863 unsigned long mmr_image
;
865 nuvhubs
= uv_num_possible_blades();
867 for (uvhub
= 0; uvhub
< nuvhubs
; uvhub
++) {
868 if (!uv_blade_nr_possible_cpus(uvhub
))
871 pnode
= uv_blade_to_pnode(uvhub
);
873 uv_read_global_mmr64(pnode
, UVH_LB_BAU_MISC_CONTROL
);
875 * Set the timeout period and then lock it in, in three
876 * steps; captures and locks in the period.
878 * To program the period, the SOFT_ACK_MODE must be off.
880 mmr_image
&= ~((unsigned long)1 <<
881 UVH_LB_BAU_MISC_CONTROL_ENABLE_INTD_SOFT_ACK_MODE_SHFT
);
882 uv_write_global_mmr64
883 (pnode
, UVH_LB_BAU_MISC_CONTROL
, mmr_image
);
885 * Set the 4-bit period.
887 mmr_image
&= ~((unsigned long)0xf <<
888 UVH_LB_BAU_MISC_CONTROL_INTD_SOFT_ACK_TIMEOUT_PERIOD_SHFT
);
889 mmr_image
|= (UV_INTD_SOFT_ACK_TIMEOUT_PERIOD
<<
890 UVH_LB_BAU_MISC_CONTROL_INTD_SOFT_ACK_TIMEOUT_PERIOD_SHFT
);
891 uv_write_global_mmr64
892 (pnode
, UVH_LB_BAU_MISC_CONTROL
, mmr_image
);
894 * Subsequent reversals of the timebase bit (3) cause an
895 * immediate timeout of one or all INTD resources as
896 * indicated in bits 2:0 (7 causes all of them to timeout).
898 mmr_image
|= ((unsigned long)1 <<
899 UVH_LB_BAU_MISC_CONTROL_ENABLE_INTD_SOFT_ACK_MODE_SHFT
);
900 uv_write_global_mmr64
901 (pnode
, UVH_LB_BAU_MISC_CONTROL
, mmr_image
);
905 static void *uv_ptc_seq_start(struct seq_file
*file
, loff_t
*offset
)
907 if (*offset
< num_possible_cpus())
912 static void *uv_ptc_seq_next(struct seq_file
*file
, void *data
, loff_t
*offset
)
915 if (*offset
< num_possible_cpus())
920 static void uv_ptc_seq_stop(struct seq_file
*file
, void *data
)
924 static inline unsigned long long
925 microsec_2_cycles(unsigned long microsec
)
928 unsigned long long cyc
;
930 ns
= microsec
* 1000;
931 cyc
= (ns
<< CYC2NS_SCALE_FACTOR
)/(per_cpu(cyc2ns
, smp_processor_id()));
936 * Display the statistics thru /proc.
937 * 'data' points to the cpu number
939 static int uv_ptc_seq_show(struct seq_file
*file
, void *data
)
941 struct ptc_stats
*stat
;
944 cpu
= *(loff_t
*)data
;
948 "# cpu sent stime self locals remotes ncpus localhub ");
950 "remotehub numuvhubs numuvhubs16 numuvhubs8 ");
952 "numuvhubs4 numuvhubs2 numuvhubs1 dto ");
954 "retries rok resetp resett giveup sto bz throt ");
956 "sw_ack recv rtime all ");
958 "one mult none retry canc nocan reset rcan ");
962 if (cpu
< num_possible_cpus() && cpu_online(cpu
)) {
963 stat
= &per_cpu(ptcstats
, cpu
);
964 /* source side statistics */
966 "cpu %d %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ",
967 cpu
, stat
->s_requestor
, cycles_2_us(stat
->s_time
),
968 stat
->s_ntargself
, stat
->s_ntarglocals
,
969 stat
->s_ntargremotes
, stat
->s_ntargcpu
,
970 stat
->s_ntarglocaluvhub
, stat
->s_ntargremoteuvhub
,
971 stat
->s_ntarguvhub
, stat
->s_ntarguvhub16
);
972 seq_printf(file
, "%ld %ld %ld %ld %ld ",
973 stat
->s_ntarguvhub8
, stat
->s_ntarguvhub4
,
974 stat
->s_ntarguvhub2
, stat
->s_ntarguvhub1
,
976 seq_printf(file
, "%ld %ld %ld %ld %ld %ld %ld %ld ",
977 stat
->s_retry_messages
, stat
->s_retriesok
,
978 stat
->s_resets_plug
, stat
->s_resets_timeout
,
979 stat
->s_giveup
, stat
->s_stimeout
,
980 stat
->s_busy
, stat
->s_throttles
);
982 /* destination side statistics */
984 "%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld ",
985 uv_read_global_mmr64(uv_cpu_to_pnode(cpu
),
986 UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE
),
987 stat
->d_requestee
, cycles_2_us(stat
->d_time
),
988 stat
->d_alltlb
, stat
->d_onetlb
, stat
->d_multmsg
,
989 stat
->d_nomsg
, stat
->d_retries
, stat
->d_canceled
,
990 stat
->d_nocanceled
, stat
->d_resets
,
992 seq_printf(file
, "%ld %ld\n",
993 stat
->s_bau_disabled
, stat
->s_bau_reenabled
);
1000 * Display the tunables thru debugfs
1002 static ssize_t
tunables_read(struct file
*file
, char __user
*userbuf
,
1003 size_t count
, loff_t
*ppos
)
1008 buf
= kasprintf(GFP_KERNEL
, "%s %s %s\n%d %d %d %d %d %d %d %d %d\n",
1009 "max_bau_concurrent plugged_delay plugsb4reset",
1010 "timeoutsb4reset ipi_reset_limit complete_threshold",
1011 "congested_response_us congested_reps congested_period",
1012 max_bau_concurrent
, plugged_delay
, plugsb4reset
,
1013 timeoutsb4reset
, ipi_reset_limit
, complete_threshold
,
1014 congested_response_us
, congested_reps
, congested_period
);
1019 ret
= simple_read_from_buffer(userbuf
, count
, ppos
, buf
, strlen(buf
));
1025 * -1: resetf the statistics
1026 * 0: display meaning of the statistics
1028 static ssize_t
uv_ptc_proc_write(struct file
*file
, const char __user
*user
,
1029 size_t count
, loff_t
*data
)
1034 struct ptc_stats
*stat
;
1036 if (count
== 0 || count
> sizeof(optstr
))
1038 if (copy_from_user(optstr
, user
, count
))
1040 optstr
[count
- 1] = '\0';
1041 if (strict_strtol(optstr
, 10, &input_arg
) < 0) {
1042 printk(KERN_DEBUG
"%s is invalid\n", optstr
);
1046 if (input_arg
== 0) {
1047 printk(KERN_DEBUG
"# cpu: cpu number\n");
1048 printk(KERN_DEBUG
"Sender statistics:\n");
1050 "sent: number of shootdown messages sent\n");
1052 "stime: time spent sending messages\n");
1054 "numuvhubs: number of hubs targeted with shootdown\n");
1056 "numuvhubs16: number times 16 or more hubs targeted\n");
1058 "numuvhubs8: number times 8 or more hubs targeted\n");
1060 "numuvhubs4: number times 4 or more hubs targeted\n");
1062 "numuvhubs2: number times 2 or more hubs targeted\n");
1064 "numuvhubs1: number times 1 hub targeted\n");
1066 "numcpus: number of cpus targeted with shootdown\n");
1068 "dto: number of destination timeouts\n");
1070 "retries: destination timeout retries sent\n");
1072 "rok: : destination timeouts successfully retried\n");
1074 "resetp: ipi-style resource resets for plugs\n");
1076 "resett: ipi-style resource resets for timeouts\n");
1078 "giveup: fall-backs to ipi-style shootdowns\n");
1080 "sto: number of source timeouts\n");
1082 "bz: number of stay-busy's\n");
1084 "throt: number times spun in throttle\n");
1085 printk(KERN_DEBUG
"Destination side statistics:\n");
1087 "sw_ack: image of UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE\n");
1089 "recv: shootdown messages received\n");
1091 "rtime: time spent processing messages\n");
1093 "all: shootdown all-tlb messages\n");
1095 "one: shootdown one-tlb messages\n");
1097 "mult: interrupts that found multiple messages\n");
1099 "none: interrupts that found no messages\n");
1101 "retry: number of retry messages processed\n");
1103 "canc: number messages canceled by retries\n");
1105 "nocan: number retries that found nothing to cancel\n");
1107 "reset: number of ipi-style reset requests processed\n");
1109 "rcan: number messages canceled by reset requests\n");
1111 "disable: number times use of the BAU was disabled\n");
1113 "enable: number times use of the BAU was re-enabled\n");
1114 } else if (input_arg
== -1) {
1115 for_each_present_cpu(cpu
) {
1116 stat
= &per_cpu(ptcstats
, cpu
);
1117 memset(stat
, 0, sizeof(struct ptc_stats
));
1124 static int local_atoi(const char *name
)
1131 val
= 10*val
+(*name
-'0');
1141 * 0 values reset them to defaults
1143 static ssize_t
tunables_write(struct file
*file
, const char __user
*user
,
1144 size_t count
, loff_t
*data
)
1152 struct bau_control
*bcp
;
1154 if (count
== 0 || count
> sizeof(instr
)-1)
1156 if (copy_from_user(instr
, user
, count
))
1159 instr
[count
] = '\0';
1160 /* count the fields */
1161 p
= instr
+ strspn(instr
, WHITESPACE
);
1163 for (; *p
; p
= q
+ strspn(q
, WHITESPACE
)) {
1164 q
= p
+ strcspn(p
, WHITESPACE
);
1170 printk(KERN_INFO
"bau tunable error: should be 9 numbers\n");
1174 p
= instr
+ strspn(instr
, WHITESPACE
);
1176 for (cnt
= 0; *p
; p
= q
+ strspn(q
, WHITESPACE
), cnt
++) {
1177 q
= p
+ strcspn(p
, WHITESPACE
);
1178 val
= local_atoi(p
);
1182 max_bau_concurrent
= MAX_BAU_CONCURRENT
;
1183 max_bau_concurrent_constant
=
1187 bcp
= &per_cpu(bau_control
, smp_processor_id());
1188 if (val
< 1 || val
> bcp
->cpus_in_uvhub
) {
1190 "Error: BAU max concurrent %d is invalid\n",
1194 max_bau_concurrent
= val
;
1195 max_bau_concurrent_constant
= val
;
1199 plugged_delay
= PLUGGED_DELAY
;
1201 plugged_delay
= val
;
1205 plugsb4reset
= PLUGSB4RESET
;
1211 timeoutsb4reset
= TIMEOUTSB4RESET
;
1213 timeoutsb4reset
= val
;
1217 ipi_reset_limit
= IPI_RESET_LIMIT
;
1219 ipi_reset_limit
= val
;
1223 complete_threshold
= COMPLETE_THRESHOLD
;
1225 complete_threshold
= val
;
1229 congested_response_us
= CONGESTED_RESPONSE_US
;
1231 congested_response_us
= val
;
1235 congested_reps
= CONGESTED_REPS
;
1237 congested_reps
= val
;
1241 congested_period
= CONGESTED_PERIOD
;
1243 congested_period
= val
;
1249 for_each_present_cpu(cpu
) {
1250 bcp
= &per_cpu(bau_control
, cpu
);
1251 bcp
->max_bau_concurrent
= max_bau_concurrent
;
1252 bcp
->max_bau_concurrent_constant
= max_bau_concurrent
;
1253 bcp
->plugged_delay
= plugged_delay
;
1254 bcp
->plugsb4reset
= plugsb4reset
;
1255 bcp
->timeoutsb4reset
= timeoutsb4reset
;
1256 bcp
->ipi_reset_limit
= ipi_reset_limit
;
1257 bcp
->complete_threshold
= complete_threshold
;
1258 bcp
->congested_response_us
= congested_response_us
;
1259 bcp
->congested_reps
= congested_reps
;
1260 bcp
->congested_period
= congested_period
;
1265 static const struct seq_operations uv_ptc_seq_ops
= {
1266 .start
= uv_ptc_seq_start
,
1267 .next
= uv_ptc_seq_next
,
1268 .stop
= uv_ptc_seq_stop
,
1269 .show
= uv_ptc_seq_show
1272 static int uv_ptc_proc_open(struct inode
*inode
, struct file
*file
)
1274 return seq_open(file
, &uv_ptc_seq_ops
);
1277 static int tunables_open(struct inode
*inode
, struct file
*file
)
1282 static const struct file_operations proc_uv_ptc_operations
= {
1283 .open
= uv_ptc_proc_open
,
1285 .write
= uv_ptc_proc_write
,
1286 .llseek
= seq_lseek
,
1287 .release
= seq_release
,
1290 static const struct file_operations tunables_fops
= {
1291 .open
= tunables_open
,
1292 .read
= tunables_read
,
1293 .write
= tunables_write
,
1294 .llseek
= default_llseek
,
1297 static int __init
uv_ptc_init(void)
1299 struct proc_dir_entry
*proc_uv_ptc
;
1301 if (!is_uv_system())
1304 proc_uv_ptc
= proc_create(UV_PTC_BASENAME
, 0444, NULL
,
1305 &proc_uv_ptc_operations
);
1307 printk(KERN_ERR
"unable to create %s proc entry\n",
1312 tunables_dir
= debugfs_create_dir(UV_BAU_TUNABLES_DIR
, NULL
);
1313 if (!tunables_dir
) {
1314 printk(KERN_ERR
"unable to create debugfs directory %s\n",
1315 UV_BAU_TUNABLES_DIR
);
1318 tunables_file
= debugfs_create_file(UV_BAU_TUNABLES_FILE
, 0600,
1319 tunables_dir
, NULL
, &tunables_fops
);
1320 if (!tunables_file
) {
1321 printk(KERN_ERR
"unable to create debugfs file %s\n",
1322 UV_BAU_TUNABLES_FILE
);
1329 * initialize the sending side's sending buffers
1332 uv_activation_descriptor_init(int node
, int pnode
)
1339 struct bau_desc
*bau_desc
;
1340 struct bau_desc
*bd2
;
1341 struct bau_control
*bcp
;
1344 * each bau_desc is 64 bytes; there are 8 (UV_ITEMS_PER_DESCRIPTOR)
1345 * per cpu; and one per cpu on the uvhub (UV_ADP_SIZE)
1347 bau_desc
= kmalloc_node(sizeof(struct bau_desc
) * UV_ADP_SIZE
1348 * UV_ITEMS_PER_DESCRIPTOR
, GFP_KERNEL
, node
);
1351 pa
= uv_gpa(bau_desc
); /* need the real nasid*/
1352 n
= pa
>> uv_nshift
;
1355 uv_write_global_mmr64(pnode
, UVH_LB_BAU_SB_DESCRIPTOR_BASE
,
1356 (n
<< UV_DESC_BASE_PNODE_SHIFT
| m
));
1359 * initializing all 8 (UV_ITEMS_PER_DESCRIPTOR) descriptors for each
1360 * cpu even though we only use the first one; one descriptor can
1361 * describe a broadcast to 256 uv hubs.
1363 for (i
= 0, bd2
= bau_desc
; i
< (UV_ADP_SIZE
*UV_ITEMS_PER_DESCRIPTOR
);
1365 memset(bd2
, 0, sizeof(struct bau_desc
));
1366 bd2
->header
.sw_ack_flag
= 1;
1368 * base_dest_nodeid is the nasid of the first uvhub
1369 * in the partition. The bit map will indicate uvhub numbers,
1370 * which are 0-N in a partition. Pnodes are unique system-wide.
1372 bd2
->header
.base_dest_nodeid
= UV_PNODE_TO_NASID(uv_partition_base_pnode
);
1373 bd2
->header
.dest_subnodeid
= 0x10; /* the LB */
1374 bd2
->header
.command
= UV_NET_ENDPOINT_INTD
;
1375 bd2
->header
.int_both
= 1;
1377 * all others need to be set to zero:
1378 * fairness chaining multilevel count replied_to
1381 for_each_present_cpu(cpu
) {
1382 if (pnode
!= uv_blade_to_pnode(uv_cpu_to_blade_id(cpu
)))
1384 bcp
= &per_cpu(bau_control
, cpu
);
1385 bcp
->descriptor_base
= bau_desc
;
1390 * initialize the destination side's receiving buffers
1391 * entered for each uvhub in the partition
1392 * - node is first node (kernel memory notion) on the uvhub
1393 * - pnode is the uvhub's physical identifier
1396 uv_payload_queue_init(int node
, int pnode
)
1402 struct bau_payload_queue_entry
*pqp
;
1403 struct bau_payload_queue_entry
*pqp_malloc
;
1404 struct bau_control
*bcp
;
1406 pqp
= kmalloc_node((DEST_Q_SIZE
+ 1)
1407 * sizeof(struct bau_payload_queue_entry
),
1412 cp
= (char *)pqp
+ 31;
1413 pqp
= (struct bau_payload_queue_entry
*)(((unsigned long)cp
>> 5) << 5);
1415 for_each_present_cpu(cpu
) {
1416 if (pnode
!= uv_cpu_to_pnode(cpu
))
1418 /* for every cpu on this pnode: */
1419 bcp
= &per_cpu(bau_control
, cpu
);
1420 bcp
->va_queue_first
= pqp
;
1421 bcp
->bau_msg_head
= pqp
;
1422 bcp
->va_queue_last
= pqp
+ (DEST_Q_SIZE
- 1);
1425 * need the pnode of where the memory was really allocated
1428 pn
= pa
>> uv_nshift
;
1429 uv_write_global_mmr64(pnode
,
1430 UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST
,
1431 ((unsigned long)pn
<< UV_PAYLOADQ_PNODE_SHIFT
) |
1432 uv_physnodeaddr(pqp
));
1433 uv_write_global_mmr64(pnode
, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_TAIL
,
1434 uv_physnodeaddr(pqp
));
1435 uv_write_global_mmr64(pnode
, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_LAST
,
1437 uv_physnodeaddr(pqp
+ (DEST_Q_SIZE
- 1)));
1438 /* in effect, all msg_type's are set to MSG_NOOP */
1439 memset(pqp
, 0, sizeof(struct bau_payload_queue_entry
) * DEST_Q_SIZE
);
1443 * Initialization of each UV hub's structures
1445 static void __init
uv_init_uvhub(int uvhub
, int vector
)
1449 unsigned long apicid
;
1451 node
= uvhub_to_first_node(uvhub
);
1452 pnode
= uv_blade_to_pnode(uvhub
);
1453 uv_activation_descriptor_init(node
, pnode
);
1454 uv_payload_queue_init(node
, pnode
);
1456 * the below initialization can't be in firmware because the
1457 * messaging IRQ will be determined by the OS
1459 apicid
= uvhub_to_first_apicid(uvhub
) | uv_apicid_hibits
;
1460 uv_write_global_mmr64(pnode
, UVH_BAU_DATA_CONFIG
,
1461 ((apicid
<< 32) | vector
));
1465 * We will set BAU_MISC_CONTROL with a timeout period.
1466 * But the BIOS has set UVH_AGING_PRESCALE_SEL and UVH_TRANSACTION_TIMEOUT.
1467 * So the destination timeout period has be be calculated from them.
1470 calculate_destination_timeout(void)
1472 unsigned long mmr_image
;
1478 unsigned long ts_ns
;
1480 mult1
= UV_INTD_SOFT_ACK_TIMEOUT_PERIOD
& BAU_MISC_CONTROL_MULT_MASK
;
1481 mmr_image
= uv_read_local_mmr(UVH_AGING_PRESCALE_SEL
);
1482 index
= (mmr_image
>> BAU_URGENCY_7_SHIFT
) & BAU_URGENCY_7_MASK
;
1483 mmr_image
= uv_read_local_mmr(UVH_TRANSACTION_TIMEOUT
);
1484 mult2
= (mmr_image
>> BAU_TRANS_SHIFT
) & BAU_TRANS_MASK
;
1485 base
= timeout_base_ns
[index
];
1486 ts_ns
= base
* mult1
* mult2
;
1492 * initialize the bau_control structure for each cpu
1494 static int __init
uv_init_per_cpu(int nuvhubs
)
1502 unsigned short socket_mask
;
1503 unsigned char *uvhub_mask
;
1504 struct bau_control
*bcp
;
1505 struct uvhub_desc
*bdp
;
1506 struct socket_desc
*sdp
;
1507 struct bau_control
*hmaster
= NULL
;
1508 struct bau_control
*smaster
= NULL
;
1509 struct socket_desc
{
1511 short cpu_number
[MAX_CPUS_PER_SOCKET
];
1514 unsigned short socket_mask
;
1518 struct socket_desc socket
[2];
1520 struct uvhub_desc
*uvhub_descs
;
1522 timeout_us
= calculate_destination_timeout();
1524 uvhub_descs
= kmalloc(nuvhubs
* sizeof(struct uvhub_desc
), GFP_KERNEL
);
1525 memset(uvhub_descs
, 0, nuvhubs
* sizeof(struct uvhub_desc
));
1526 uvhub_mask
= kzalloc((nuvhubs
+7)/8, GFP_KERNEL
);
1527 for_each_present_cpu(cpu
) {
1528 bcp
= &per_cpu(bau_control
, cpu
);
1529 memset(bcp
, 0, sizeof(struct bau_control
));
1530 pnode
= uv_cpu_hub_info(cpu
)->pnode
;
1531 uvhub
= uv_cpu_hub_info(cpu
)->numa_blade_id
;
1532 *(uvhub_mask
+ (uvhub
/8)) |= (1 << (uvhub
%8));
1533 bdp
= &uvhub_descs
[uvhub
];
1537 /* kludge: 'assuming' one node per socket, and assuming that
1538 disabling a socket just leaves a gap in node numbers */
1539 socket
= (cpu_to_node(cpu
) & 1);
1540 bdp
->socket_mask
|= (1 << socket
);
1541 sdp
= &bdp
->socket
[socket
];
1542 sdp
->cpu_number
[sdp
->num_cpus
] = cpu
;
1544 if (sdp
->num_cpus
> MAX_CPUS_PER_SOCKET
) {
1545 printk(KERN_EMERG
"%d cpus per socket invalid\n", sdp
->num_cpus
);
1549 for (uvhub
= 0; uvhub
< nuvhubs
; uvhub
++) {
1550 if (!(*(uvhub_mask
+ (uvhub
/8)) & (1 << (uvhub
%8))))
1553 bdp
= &uvhub_descs
[uvhub
];
1554 socket_mask
= bdp
->socket_mask
;
1556 while (socket_mask
) {
1557 if (!(socket_mask
& 1))
1559 sdp
= &bdp
->socket
[socket
];
1560 for (i
= 0; i
< sdp
->num_cpus
; i
++) {
1561 cpu
= sdp
->cpu_number
[i
];
1562 bcp
= &per_cpu(bau_control
, cpu
);
1566 if (!have_hmaster
) {
1571 bcp
->cpus_in_uvhub
= bdp
->num_cpus
;
1572 bcp
->cpus_in_socket
= sdp
->num_cpus
;
1573 bcp
->socket_master
= smaster
;
1574 bcp
->uvhub
= bdp
->uvhub
;
1575 bcp
->uvhub_master
= hmaster
;
1576 bcp
->uvhub_cpu
= uv_cpu_hub_info(cpu
)->
1578 if (bcp
->uvhub_cpu
>= MAX_CPUS_PER_UVHUB
) {
1580 "%d cpus per uvhub invalid\n",
1587 socket_mask
= (socket_mask
>> 1);
1592 for_each_present_cpu(cpu
) {
1593 bcp
= &per_cpu(bau_control
, cpu
);
1594 bcp
->baudisabled
= 0;
1595 bcp
->statp
= &per_cpu(ptcstats
, cpu
);
1596 /* time interval to catch a hardware stay-busy bug */
1597 bcp
->timeout_interval
= microsec_2_cycles(2*timeout_us
);
1598 bcp
->max_bau_concurrent
= max_bau_concurrent
;
1599 bcp
->max_bau_concurrent_constant
= max_bau_concurrent
;
1600 bcp
->plugged_delay
= plugged_delay
;
1601 bcp
->plugsb4reset
= plugsb4reset
;
1602 bcp
->timeoutsb4reset
= timeoutsb4reset
;
1603 bcp
->ipi_reset_limit
= ipi_reset_limit
;
1604 bcp
->complete_threshold
= complete_threshold
;
1605 bcp
->congested_response_us
= congested_response_us
;
1606 bcp
->congested_reps
= congested_reps
;
1607 bcp
->congested_period
= congested_period
;
1613 * Initialization of BAU-related structures
1615 static int __init
uv_bau_init(void)
1624 if (!is_uv_system())
1630 for_each_possible_cpu(cur_cpu
)
1631 zalloc_cpumask_var_node(&per_cpu(uv_flush_tlb_mask
, cur_cpu
),
1632 GFP_KERNEL
, cpu_to_node(cur_cpu
));
1634 uv_nshift
= uv_hub_info
->m_val
;
1635 uv_mmask
= (1UL << uv_hub_info
->m_val
) - 1;
1636 nuvhubs
= uv_num_possible_blades();
1637 spin_lock_init(&disable_lock
);
1638 congested_cycles
= microsec_2_cycles(congested_response_us
);
1640 if (uv_init_per_cpu(nuvhubs
)) {
1645 uv_partition_base_pnode
= 0x7fffffff;
1646 for (uvhub
= 0; uvhub
< nuvhubs
; uvhub
++)
1647 if (uv_blade_nr_possible_cpus(uvhub
) &&
1648 (uv_blade_to_pnode(uvhub
) < uv_partition_base_pnode
))
1649 uv_partition_base_pnode
= uv_blade_to_pnode(uvhub
);
1651 vector
= UV_BAU_MESSAGE
;
1652 for_each_possible_blade(uvhub
)
1653 if (uv_blade_nr_possible_cpus(uvhub
))
1654 uv_init_uvhub(uvhub
, vector
);
1656 uv_enable_timeouts();
1657 alloc_intr_gate(vector
, uv_bau_message_intr1
);
1659 for_each_possible_blade(uvhub
) {
1660 if (uv_blade_nr_possible_cpus(uvhub
)) {
1661 pnode
= uv_blade_to_pnode(uvhub
);
1663 uv_write_global_mmr64(pnode
,
1664 UVH_LB_BAU_SB_ACTIVATION_CONTROL
,
1665 ((unsigned long)1 << 63));
1666 mmr
= 1; /* should be 1 to broadcast to both sockets */
1667 uv_write_global_mmr64(pnode
, UVH_BAU_DATA_BROADCAST
,
1674 core_initcall(uv_bau_init
);
1675 fs_initcall(uv_ptc_init
);