linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU
@ 2016-09-20 22:31 Andrew Banman
  2016-09-20 22:31 ` [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
                   ` (10 more replies)
  0 siblings, 11 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The following patch set adds support for UV4 architecture to the Broadcast
Assist Unit (BAU). Major hardware changes to the BAU require these fixes to
ensure correct operation and to avoid illegal MMR writes.

The patch set can be thought of in three logical groups:

1) General cleanup.

 [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks
 [PATCH 2/9] arch/x86/platform/uv: BAU cleanup: pq_init
 [PATCH 3/9] arch/x86/platform/uv: BAU replace uv_physnodeaddr

 These housekeeping patches make the subsequent UV4 patches clearer,
 and they should be done in any case.


2) Implement a new scheme to abstract UV version-specific functions.

 [PATCH 4/9] arch/x86/platform/uv: BAU add generic function pointers
 [PATCH 5/9] arch/x86/platform/uv: BAU use generic function pointers

 We add a struct of function pointers to define version-specific BAU
 operations. The philosophy is to abstract functions that perform the same
 operation on all UV versions but have different implementations. This will
 simplify their use in the body of the driver code and greatly simplify the
 UV4 patches to follow.


3) Add UV4 functionality.

 [PATCH 6/9] arch/x86/platform/uv: BAU UV4 populate uvhub_version
 [PATCH 7/9] arch/x86/platform/uv: BAU UV4 disable software timeout
 [PATCH 8/9] arch/x86/platform/uv: BAU UV4 fix payload queue setup
 [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific

 These patches feature a minimal set of changes to make the BAU on UV4
 operational.


This patch set has been tested for regressions on pre-UV4 architectures and
for correct functionality on UV4. The patches apply cleanly to 4.8-rc7.
Fine-tuned performance tweaking for UV4 will come in a future patch set.


Thank you,

Andrew Banman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 2/9] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
                   ` (9 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Replace all uses of printk with the appropriate pr_* function.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index fdb4d42..7baea46 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1497,16 +1497,16 @@ static ssize_t ptc_proc_write(struct file *file, const char __user *user,
 	}
 
 	if (kstrtol(optstr, 10, &input_arg) < 0) {
-		printk(KERN_DEBUG "%s is invalid\n", optstr);
+		pr_debug("%s is invalid\n", optstr);
 		return -EINVAL;
 	}
 
 	if (input_arg == 0) {
 		elements = ARRAY_SIZE(stat_description);
-		printk(KERN_DEBUG "# cpu:      cpu number\n");
-		printk(KERN_DEBUG "Sender statistics:\n");
+		pr_debug("# cpu:      cpu number\n");
+		pr_debug("Sender statistics:\n");
 		for (i = 0; i < elements; i++)
-			printk(KERN_DEBUG "%s\n", stat_description[i]);
+			pr_debug("%s\n", stat_description[i]);
 	} else if (input_arg == -1) {
 		for_each_present_cpu(cpu) {
 			stat = &per_cpu(ptcstats, cpu);
@@ -1554,7 +1554,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 			break;
 	}
 	if (cnt != e) {
-		printk(KERN_INFO "bau tunable error: should be %d values\n", e);
+		pr_info("bau tunable error: should be %d values\n", e);
 		return -EINVAL;
 	}
 
@@ -1571,7 +1571,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 				continue;
 			}
 			if (val < 1 || val > bcp->cpus_in_uvhub) {
-				printk(KERN_DEBUG
+				pr_debug(
 				"Error: BAU max concurrent %d is invalid\n",
 				val);
 				return -EINVAL;
@@ -1676,21 +1676,21 @@ static int __init uv_ptc_init(void)
 	proc_uv_ptc = proc_create(UV_PTC_BASENAME, 0444, NULL,
 				  &proc_uv_ptc_operations);
 	if (!proc_uv_ptc) {
-		printk(KERN_ERR "unable to create %s proc entry\n",
+		pr_err("unable to create %s proc entry\n",
 		       UV_PTC_BASENAME);
 		return -EINVAL;
 	}
 
 	tunables_dir = debugfs_create_dir(UV_BAU_TUNABLES_DIR, NULL);
 	if (!tunables_dir) {
-		printk(KERN_ERR "unable to create debugfs directory %s\n",
+		pr_err("unable to create debugfs directory %s\n",
 		       UV_BAU_TUNABLES_DIR);
 		return -EINVAL;
 	}
 	tunables_file = debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600,
 					tunables_dir, NULL, &tunables_fops);
 	if (!tunables_file) {
-		printk(KERN_ERR "unable to create debugfs file %s\n",
+		pr_err("unable to create debugfs file %s\n",
 		       UV_BAU_TUNABLES_FILE);
 		return -EINVAL;
 	}
@@ -1944,7 +1944,7 @@ static int __init get_cpu_topology(int base_pnode,
 
 		pnode = uv_cpu_hub_info(cpu)->pnode;
 		if ((pnode - base_pnode) >= UV_DISTRIBUTION_SIZE) {
-			printk(KERN_EMERG
+			pr_emerg(
 				"cpu %d pnode %d-%d beyond %d; BAU disabled\n",
 				cpu, pnode, base_pnode, UV_DISTRIBUTION_SIZE);
 			return 1;
@@ -1969,7 +1969,7 @@ static int __init get_cpu_topology(int base_pnode,
 		sdp->cpu_number[sdp->num_cpus] = cpu;
 		sdp->num_cpus++;
 		if (sdp->num_cpus > MAX_CPUS_PER_SOCKET) {
-			printk(KERN_EMERG "%d cpus per socket invalid\n",
+			pr_emerg("%d cpus per socket invalid\n",
 				sdp->num_cpus);
 			return 1;
 		}
@@ -2036,14 +2036,14 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
 		else {
-			printk(KERN_EMERG "uvhub version not 1, 2 or 3\n");
+			pr_emerg("uvhub version not 1, 2, or 3\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;
 		bcp->uvhub_cpu = uv_cpu_blade_processor_id(cpu);
 
 		if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) {
-			printk(KERN_EMERG "%d cpus per uvhub invalid\n",
+			pr_emerg("%d cpus per uvhub invalid\n",
 				bcp->uvhub_cpu);
 			return 1;
 		}
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 2/9] arch/x86/platform/uv: BAU cleanup: pq_init
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
  2016-09-20 22:31 ` [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 3/9] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
                   ` (8 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The payload queue first MMR requires the physical memory address and hub
GNODE where the payload queue, but the associated variables are named as if
the PNODE were used. Rename gnode-related variables and clarify the
definitions of the payload queue head, last, and tail pointers.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/include/asm/uv/uv_bau.h |  2 +-
 arch/x86/platform/uv/tlb_uv.c    | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc44d92..cc058c6 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -49,7 +49,7 @@
 #define UV_NET_ENDPOINT_INTD		(is_uv1_hub() ?			\
 			UV1_NET_ENDPOINT_INTD : UV2_NET_ENDPOINT_INTD)
 #define UV_DESC_PSHIFT			49
-#define UV_PAYLOADQ_PNODE_SHIFT		49
+#define UV_PAYLOADQ_GNODE_SHIFT		49
 #define UV_PTC_BASENAME			"sgi_uv/ptc_statistics"
 #define UV_BAU_BASENAME			"sgi_uv/bau_tunables"
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 7baea46..e8c2d2f 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1790,10 +1790,7 @@ static void pq_init(int node, int pnode)
 	size_t plsize;
 	char *cp;
 	void *vp;
-	unsigned long pn;
-	unsigned long first;
-	unsigned long pn_first;
-	unsigned long last;
+	unsigned long gnode, first, last, tail;
 	struct bau_pq_entry *pqp;
 	struct bau_control *bcp;
 
@@ -1814,16 +1811,16 @@ static void pq_init(int node, int pnode)
 		bcp->bau_msg_head	= pqp;
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
-	/*
-	 * need the gnode of where the memory was really allocated
-	 */
-	pn = uv_gpa_to_gnode(uv_gpa(pqp));
+
 	first = uv_physnodeaddr(pqp);
-	pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
 	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
-	write_mmr_payload_first(pnode, pn_first);
-	write_mmr_payload_tail(pnode, first);
+	tail = first;
+	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+
+	write_mmr_payload_first(pnode, first);
 	write_mmr_payload_last(pnode, last);
+	write_mmr_payload_tail(pnode, tail);
 	write_gmmr_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 3/9] arch/x86/platform/uv: BAU replace uv_physnodeaddr
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
  2016-09-20 22:31 ` [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
  2016-09-20 22:31 ` [PATCH 2/9] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 4/9] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
                   ` (7 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The BAU driver should use the functions provided by uv_hub.h rather than
its own implementations. uv_physnodeaddr converts vaddrs to paddrs for
BAU MMR fields, but this is done better by uv_gpa_to_offset.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/include/asm/uv/uv_bau.h | 2 --
 arch/x86/platform/uv/tlb_uv.c    | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc058c6..a46f270 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -55,8 +55,6 @@
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
 #define UV_BAU_TUNABLES_FILE		"bau_tunables"
 #define WHITESPACE			" \t\n"
-#define uv_mmask			((1UL << uv_hub_info->m_val) - 1)
-#define uv_physnodeaddr(x)		((__pa((unsigned long)(x)) & uv_mmask))
 #define cpubit_isset(cpu, bau_local_cpumask) \
 	test_bit((cpu), (bau_local_cpumask).bits)
 
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index e8c2d2f..98f1d43 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1812,8 +1812,8 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_physnodeaddr(pqp);
-	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
+	first = uv_gpa_to_offset(uv_gpa(pqp));
+	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 4/9] arch/x86/platform/uv: BAU add generic function pointers
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (2 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 3/9] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 5/9] arch/x86/platform/uv: BAU use " Andrew Banman
                   ` (6 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Many BAU functions have different implementations depending on the UV
version. Rather than switching on the uvhub_version throughout the driver,
we can define a set of operations for each version. This is especially
beneficial for UV4, which will require many new MMR read/write functions.

Currently, the set of abstracted functions are the same for UV1, UV2, and
UV3. The functions were chosen because each one will have a different
implementation for UV4. Other functions will be added as needed to handle
new implementations or to cleanup the existing differences between UV1,
UV2, and UV3, i.e. read_status and wait_completion.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/include/asm/uv/uv_bau.h | 11 +++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a46f270..a7a93a5 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -385,6 +385,17 @@ struct uv2_3_bau_msg_header {
 	/* bits 127:120 */
 };
 
+/* Abstracted BAU functions */
+struct bau_operations {
+	unsigned long (*read_l_sw_ack)(void);
+	unsigned long (*read_g_sw_ack)(int pnode);
+	unsigned long (*bau_gpa_to_offset)(unsigned long vaddr);
+	void (*write_l_sw_ack)(unsigned long mmr);
+	void (*write_g_sw_ack)(int pnode, unsigned long mmr);
+	void (*write_payload_first)(int pnode, unsigned long mmr);
+	void (*write_payload_last)(int pnode, unsigned long mmr);
+};
+
 /*
  * The activation descriptor:
  * The format of the message to send, plus all accompanying control
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 98f1d43..045da97 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -24,6 +24,18 @@
 #include <asm/irq_vectors.h>
 #include <asm/timer.h>
 
+static struct bau_operations ops;
+
+static struct bau_operations uv123_bau_ops = {
+	.bau_gpa_to_offset = uv_gpa_to_offset,
+	.read_l_sw_ack = read_mmr_sw_ack,
+	.read_g_sw_ack = read_gmmr_sw_ack,
+	.write_l_sw_ack = write_mmr_sw_ack,
+	.write_g_sw_ack = write_gmmr_sw_ack,
+	.write_payload_first = write_mmr_payload_first,
+	.write_payload_last = write_mmr_payload_last,
+};
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2135,6 +2147,13 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
+	if (is_uv3_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv2_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv1_hub())
+		ops = uv123_bau_ops;
+
 	for_each_possible_cpu(cur_cpu) {
 		mask = &per_cpu(uv_flush_tlb_mask, cur_cpu);
 		zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 5/9] arch/x86/platform/uv: BAU use generic function pointers
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (3 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 4/9] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 6/9] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
                   ` (5 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Convert the use of UV version-specific functions to their abstracted
counterparts.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 045da97..bfeb382 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -228,7 +228,7 @@ static void reply_to_message(struct msg_desc *mdp, struct bau_control *bcp,
 	msg = mdp->msg;
 	if (!msg->canceled && do_acknowledge) {
 		dw = (msg->swack_vec << UV_SW_ACK_NPENDING) | msg->swack_vec;
-		write_mmr_sw_ack(dw);
+		ops.write_l_sw_ack(dw);
 	}
 	msg->replied_to = 1;
 	msg->swack_vec = 0;
@@ -264,7 +264,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 			msg->swack_vec) == 0) &&
 		    (msg2->sending_cpu == msg->sending_cpu) &&
 		    (msg2->msg_type != MSG_NOOP)) {
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg2->swack_vec;
 			/*
 			 * This is a message retry; clear the resources held
@@ -282,7 +282,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 				stat->d_canceled++;
 				cancel_count++;
 				mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -415,12 +415,12 @@ static void do_reset(void *ptr)
 			/*
 			 * only reset the resource if it is still pending
 			 */
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg->swack_vec;
 			mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
 			if (mmr & msg_res) {
 				stat->d_rcanceled++;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -1214,7 +1214,7 @@ void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
 	struct bau_pq_entry *msg = mdp->msg;
 	struct bau_pq_entry *other_msg;
 
-	mmr_image = read_mmr_sw_ack();
+	mmr_image = ops.read_l_sw_ack();
 	swack_vec = msg->swack_vec;
 
 	if ((swack_vec & mmr_image) == 0) {
@@ -1443,7 +1443,7 @@ static int ptc_seq_show(struct seq_file *file, void *data)
 		/* destination side statistics */
 		seq_printf(file,
 			"%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
-			   read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)),
+			   ops.read_g_sw_ack(uv_cpu_to_pnode(cpu)),
 			   stat->d_requestee, cycles_2_us(stat->d_time),
 			   stat->d_alltlb, stat->d_onetlb, stat->d_multmsg,
 			   stat->d_nomsg, stat->d_retries, stat->d_canceled,
@@ -1737,7 +1737,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 
 	gpa = uv_gpa(bau_desc);
 	n = uv_gpa_to_gnode(gpa);
-	m = uv_gpa_to_offset(gpa);
+	m = ops.bau_gpa_to_offset(gpa);
 	if (is_uv1_hub())
 		uv1 = 1;
 
@@ -1824,16 +1824,16 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_gpa_to_offset(uv_gpa(pqp));
-	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
+	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
+	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_first(pnode, first);
-	write_mmr_payload_last(pnode, last);
 	write_mmr_payload_tail(pnode, tail);
-	write_gmmr_sw_ack(pnode, 0xffffUL);
+	ops.write_payload_first(pnode, first);
+	ops.write_payload_last(pnode, last);
+	ops.write_g_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */
 	memset(pqp, 0, sizeof(struct bau_pq_entry) * DEST_Q_SIZE);
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 6/9] arch/x86/platform/uv: BAU UV4 populate uvhub_version
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (4 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 5/9] arch/x86/platform/uv: BAU use " Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 7/9] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
                   ` (4 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/platform/uv/tlb_uv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index bfeb382..67a31d0 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2044,8 +2044,10 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 			bcp->uvhub_version = 2;
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
+		else if (is_uv4_hub())
+			bcp->uvhub_version = 4;
 		else {
-			pr_emerg("uvhub version not 1, 2, or 3\n");
+			pr_emerg("uvhub version not 1, 2, 3, or 4\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 7/9] arch/x86/platform/uv: BAU UV4 disable software timeout
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (5 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 6/9] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:31 ` [PATCH 8/9] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
                   ` (3 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Software timeouts are not currently supported on BAU for UV4. Instead, the
BAU will rely on hardware-level fairness protocols to determine broadcast
timeouts.

Do not call enable_timeouts or calculate_destination_timeout on UV4. These
functions write to pre-UV4 MMRs so they generate error messages on UV4.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/platform/uv/tlb_uv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 67a31d0..bfd03db 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2109,7 +2109,8 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
 	void *vp;
 	struct uvhub_desc *uvhub_descs;
 
-	timeout_us = calculate_destination_timeout();
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		timeout_us = calculate_destination_timeout();
 
 	vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
 	uvhub_descs = (struct uvhub_desc *)vp;
@@ -2171,7 +2172,9 @@ static int __init uv_bau_init(void)
 			uv_base_pnode = uv_blade_to_pnode(uvhub);
 	}
 
-	enable_timeouts();
+	/* software timeouts are not supported on UV4 */
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		enable_timeouts();
 
 	if (init_per_cpu(nuvhubs, uv_base_pnode)) {
 		set_bau_off();
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 8/9] arch/x86/platform/uv: BAU UV4 fix payload queue setup
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (6 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 7/9] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
@ 2016-09-20 22:31 ` Andrew Banman
  2016-09-20 22:32 ` [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
                   ` (2 subsequent siblings)
  10 siblings, 0 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:31 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The BAU on UV4 does not need to maintain the payload queue tail pointer. Do
not initialize the tail pointer MMR on UV4.

Note that write_payload_tail is not an abstracted BAU function since it is
an operation specific to pre-UV4 versions. Then we must switch on the UV
version to control its usage, for which we use uvhub_version rather than
is_uv*_hub because it is quicker/more concise.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/platform/uv/tlb_uv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index bfd03db..56d12eb 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1826,11 +1826,19 @@ static void pq_init(int node, int pnode)
 
 	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
 	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
-	tail = first;
-	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
-	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_tail(pnode, tail);
+	/*
+	 * Pre UV4, the gnode is required to locate the payload queue
+	 * and the payload queue tail must be maintained by the kernel.
+	 */
+	bcp = &per_cpu(bau_control, smp_processor_id());
+	if (bcp->uvhub_version <= 3) {
+		tail = first;
+		gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+		first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+		write_mmr_payload_tail(pnode, tail);
+	}
+
 	ops.write_payload_first(pnode, first);
 	ops.write_payload_last(pnode, last);
 	ops.write_g_sw_ack(pnode, 0xffffUL);
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (7 preceding siblings ...)
  2016-09-20 22:31 ` [PATCH 8/9] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
@ 2016-09-20 22:32 ` Andrew Banman
  2016-09-21 12:55   ` Ingo Molnar
  2016-09-21 14:55 ` [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Thomas Gleixner
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
  10 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-20 22:32 UTC (permalink / raw)
  To: mingo, akpm; +Cc: tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Add the UV4-specific function definitions and define an operations struct
to implement them in the BAU driver.

Many BAU MMRs, although functionally the same, have new addresses on UV4
due to hardware changes. Each MMR requires new read/write functions, but
their implementation in the driver does not change. Thus, it is enough to
enumerate them in the operations struct for the changes to take effect.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
---
 arch/x86/include/asm/uv/uv_bau.h | 30 ++++++++++++++++++++++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 15 ++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a7a93a5..57ab86d 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -664,6 +664,16 @@ static inline void write_gmmr_activation(int pnode, unsigned long mmr_image)
 	write_gmmr(pnode, UVH_LB_BAU_SB_ACTIVATION_CONTROL, mmr_image);
 }
 
+static inline void write_mmr_proc_payload_first(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_FIRST, mmr_image);
+}
+
+static inline void write_mmr_proc_payload_last(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_LAST, mmr_image);
+}
+
 static inline void write_mmr_payload_first(int pnode, unsigned long mmr_image)
 {
 	write_gmmr(pnode, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST, mmr_image);
@@ -709,6 +719,26 @@ static inline unsigned long read_gmmr_sw_ack(int pnode)
 	return read_gmmr(pnode, UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE);
 }
 
+static inline void write_mmr_proc_sw_ack(unsigned long mr)
+{
+	uv_write_local_mmr(UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline void write_gmmr_proc_sw_ack(int pnode, unsigned long mr)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline unsigned long read_mmr_proc_sw_ack(void)
+{
+	return read_lmmr(UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
+static inline unsigned long read_gmmr_proc_sw_ack(int pnode)
+{
+	return read_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
 static inline void write_mmr_data_config(int pnode, unsigned long mr)
 {
 	uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, mr);
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 56d12eb..470d73c 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -36,6 +36,17 @@ static struct bau_operations uv123_bau_ops = {
 	.write_payload_last = write_mmr_payload_last,
 };
 
+static struct bau_operations uv4_bau_ops = {
+	.bau_gpa_to_offset = uv_gpa_to_soc_phys_ram,
+	.read_l_sw_ack = read_mmr_proc_sw_ack,
+	.read_g_sw_ack = read_gmmr_proc_sw_ack,
+	.write_l_sw_ack = write_mmr_proc_sw_ack,
+	.write_g_sw_ack = write_gmmr_proc_sw_ack,
+	.write_payload_first = write_mmr_proc_payload_first,
+	.write_payload_last = write_mmr_proc_payload_last,
+};
+
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2158,7 +2169,9 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
-	if (is_uv3_hub())
+	if (is_uv4_hub())
+		ops = uv4_bau_ops;
+	else if (is_uv3_hub())
 		ops = uv123_bau_ops;
 	else if (is_uv2_hub())
 		ops = uv123_bau_ops;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* Re: [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions
  2016-09-20 22:32 ` [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
@ 2016-09-21 12:55   ` Ingo Molnar
  2016-09-21 15:53     ` andrew banman
  0 siblings, 1 reply; 34+ messages in thread
From: Ingo Molnar @ 2016-09-21 12:55 UTC (permalink / raw)
  To: Andrew Banman
  Cc: mingo, akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel


* Andrew Banman <abanman@sgi.com> wrote:

> Add the UV4-specific function definitions and define an operations struct
> to implement them in the BAU driver.
> 
> Many BAU MMRs, although functionally the same, have new addresses on UV4
> due to hardware changes. Each MMR requires new read/write functions, but
> their implementation in the driver does not change. Thus, it is enough to
> enumerate them in the operations struct for the changes to take effect.
> 
> Signed-off-by: Andrew Banman <abanman@sgi.com>
> Acked-by: Mike Travis <travis@sgi.com>
> Acked-by: Dimitri Sivanich <sivanich@sgi.com>
> ---
>  arch/x86/include/asm/uv/uv_bau.h | 30 ++++++++++++++++++++++++++++++
>  arch/x86/platform/uv/tlb_uv.c    | 15 ++++++++++++++-
>  2 files changed, 44 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
> index a7a93a5..57ab86d 100644
> --- a/arch/x86/include/asm/uv/uv_bau.h
> +++ b/arch/x86/include/asm/uv/uv_bau.h
> @@ -664,6 +664,16 @@ static inline void write_gmmr_activation(int pnode, unsigned long mmr_image)
>  	write_gmmr(pnode, UVH_LB_BAU_SB_ACTIVATION_CONTROL, mmr_image);
>  }
>  
> +static inline void write_mmr_proc_payload_first(int pnode, unsigned long mmr_image)
> +{
> +	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_FIRST, mmr_image);
> +}
> +
> +static inline void write_mmr_proc_payload_last(int pnode, unsigned long mmr_image)
> +{
> +	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_LAST, mmr_image);
> +}
> +
>  static inline void write_mmr_payload_first(int pnode, unsigned long mmr_image)
>  {
>  	write_gmmr(pnode, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST, mmr_image);
> @@ -709,6 +719,26 @@ static inline unsigned long read_gmmr_sw_ack(int pnode)
>  	return read_gmmr(pnode, UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE);
>  }
>  
> +static inline void write_mmr_proc_sw_ack(unsigned long mr)
> +{
> +	uv_write_local_mmr(UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
> +}
> +
> +static inline void write_gmmr_proc_sw_ack(int pnode, unsigned long mr)
> +{
> +	write_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
> +}
> +
> +static inline unsigned long read_mmr_proc_sw_ack(void)
> +{
> +	return read_lmmr(UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
> +}
> +
> +static inline unsigned long read_gmmr_proc_sw_ack(int pnode)
> +{
> +	return read_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
> +}
> +
>  static inline void write_mmr_data_config(int pnode, unsigned long mr)
>  {
>  	uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, mr);
> diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
> index 56d12eb..470d73c 100644
> --- a/arch/x86/platform/uv/tlb_uv.c
> +++ b/arch/x86/platform/uv/tlb_uv.c
> @@ -36,6 +36,17 @@ static struct bau_operations uv123_bau_ops = {
>  	.write_payload_last = write_mmr_payload_last,
>  };
>  
> +static struct bau_operations uv4_bau_ops = {
> +	.bau_gpa_to_offset = uv_gpa_to_soc_phys_ram,
> +	.read_l_sw_ack = read_mmr_proc_sw_ack,
> +	.read_g_sw_ack = read_gmmr_proc_sw_ack,
> +	.write_l_sw_ack = write_mmr_proc_sw_ack,
> +	.write_g_sw_ack = write_gmmr_proc_sw_ack,
> +	.write_payload_first = write_mmr_proc_payload_first,
> +	.write_payload_last = write_mmr_proc_payload_last,
> +};

The series looks mostly good to me, only a minor nit: could you please organize 
such initializations vertically?

Something like:

	.bau_gpa_to_offset	= uv_gpa_to_soc_phys_ram,
	.read_l_sw_ack		= read_mmr_proc_sw_ack,
	.read_g_sw_ack		= read_gmmr_proc_sw_ack,
	.write_l_sw_ack		= write_mmr_proc_sw_ack,
	.write_g_sw_ack		= write_gmmr_proc_sw_ack,
	.write_payload_first	= write_mmr_proc_payload_first,
	.write_payload_last	= write_mmr_proc_payload_last,

would make it more readable. Same might apply to other patches too in the series.

Plus it might make sense to do the same to the existing tunables[] structure as 
well.

Thanks,

	Ingo

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (8 preceding siblings ...)
  2016-09-20 22:32 ` [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
@ 2016-09-21 14:55 ` Thomas Gleixner
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
  10 siblings, 0 replies; 34+ messages in thread
From: Thomas Gleixner @ 2016-09-21 14:55 UTC (permalink / raw)
  To: Andrew Banman; +Cc: mingo, akpm, hpa, travis, rja, sivanich, x86, linux-kernel

On Tue, 20 Sep 2016, Andrew Banman wrote:

> The following patch set adds support for UV4 architecture to the Broadcast
> Assist Unit (BAU). Major hardware changes to the BAU require these fixes to
> ensure correct operation and to avoid illegal MMR writes.

Nice work and aside of the nitpicks Ingo had:

Acked-by: Thomas Gleixner <tglx@linutronix.de>

^ permalink raw reply	[flat|nested] 34+ messages in thread

* Re: [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions
  2016-09-21 12:55   ` Ingo Molnar
@ 2016-09-21 15:53     ` andrew banman
  0 siblings, 0 replies; 34+ messages in thread
From: andrew banman @ 2016-09-21 15:53 UTC (permalink / raw)
  To: Ingo Molnar
  Cc: Andrew Banman, mingo, akpm, tglx, hpa, travis, rja, sivanich,
	x86, linux-kernel

On Wed, Sep 21, 2016 at 02:55:27PM +0200, Ingo Molnar wrote:
> 
> * Andrew Banman <abanman@sgi.com> wrote:
> 
> > Add the UV4-specific function definitions and define an operations struct
> > to implement them in the BAU driver.
> > 
> > Many BAU MMRs, although functionally the same, have new addresses on UV4
> > due to hardware changes. Each MMR requires new read/write functions, but
> > their implementation in the driver does not change. Thus, it is enough to
> > enumerate them in the operations struct for the changes to take effect.
> > 
> > Signed-off-by: Andrew Banman <abanman@sgi.com>
> > Acked-by: Mike Travis <travis@sgi.com>
> > Acked-by: Dimitri Sivanich <sivanich@sgi.com>
> > ---
> >  arch/x86/include/asm/uv/uv_bau.h | 30 ++++++++++++++++++++++++++++++
> >  arch/x86/platform/uv/tlb_uv.c    | 15 ++++++++++++++-
> >  2 files changed, 44 insertions(+), 1 deletion(-)
> > 
> > diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
> > index a7a93a5..57ab86d 100644
> > --- a/arch/x86/include/asm/uv/uv_bau.h
> > +++ b/arch/x86/include/asm/uv/uv_bau.h
> > @@ -664,6 +664,16 @@ static inline void write_gmmr_activation(int pnode, unsigned long mmr_image)
> >  	write_gmmr(pnode, UVH_LB_BAU_SB_ACTIVATION_CONTROL, mmr_image);
> >  }
> >  
> > +static inline void write_mmr_proc_payload_first(int pnode, unsigned long mmr_image)
> > +{
> > +	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_FIRST, mmr_image);
> > +}
> > +
> > +static inline void write_mmr_proc_payload_last(int pnode, unsigned long mmr_image)
> > +{
> > +	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_LAST, mmr_image);
> > +}
> > +
> >  static inline void write_mmr_payload_first(int pnode, unsigned long mmr_image)
> >  {
> >  	write_gmmr(pnode, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST, mmr_image);
> > @@ -709,6 +719,26 @@ static inline unsigned long read_gmmr_sw_ack(int pnode)
> >  	return read_gmmr(pnode, UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE);
> >  }
> >  
> > +static inline void write_mmr_proc_sw_ack(unsigned long mr)
> > +{
> > +	uv_write_local_mmr(UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
> > +}
> > +
> > +static inline void write_gmmr_proc_sw_ack(int pnode, unsigned long mr)
> > +{
> > +	write_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
> > +}
> > +
> > +static inline unsigned long read_mmr_proc_sw_ack(void)
> > +{
> > +	return read_lmmr(UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
> > +}
> > +
> > +static inline unsigned long read_gmmr_proc_sw_ack(int pnode)
> > +{
> > +	return read_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
> > +}
> > +
> >  static inline void write_mmr_data_config(int pnode, unsigned long mr)
> >  {
> >  	uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, mr);
> > diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
> > index 56d12eb..470d73c 100644
> > --- a/arch/x86/platform/uv/tlb_uv.c
> > +++ b/arch/x86/platform/uv/tlb_uv.c
> > @@ -36,6 +36,17 @@ static struct bau_operations uv123_bau_ops = {
> >  	.write_payload_last = write_mmr_payload_last,
> >  };
> >  
> > +static struct bau_operations uv4_bau_ops = {
> > +	.bau_gpa_to_offset = uv_gpa_to_soc_phys_ram,
> > +	.read_l_sw_ack = read_mmr_proc_sw_ack,
> > +	.read_g_sw_ack = read_gmmr_proc_sw_ack,
> > +	.write_l_sw_ack = write_mmr_proc_sw_ack,
> > +	.write_g_sw_ack = write_gmmr_proc_sw_ack,
> > +	.write_payload_first = write_mmr_proc_payload_first,
> > +	.write_payload_last = write_mmr_proc_payload_last,
> > +};
> 
> The series looks mostly good to me, only a minor nit: could you please organize 
> such initializations vertically?
> 
> Something like:
> 
> 	.bau_gpa_to_offset	= uv_gpa_to_soc_phys_ram,
> 	.read_l_sw_ack		= read_mmr_proc_sw_ack,
> 	.read_g_sw_ack		= read_gmmr_proc_sw_ack,
> 	.write_l_sw_ack		= write_mmr_proc_sw_ack,
> 	.write_g_sw_ack		= write_gmmr_proc_sw_ack,
> 	.write_payload_first	= write_mmr_proc_payload_first,
> 	.write_payload_last	= write_mmr_proc_payload_last,
> 
> would make it more readable. Same might apply to other patches too in the series.
> 
> Plus it might make sense to do the same to the existing tunables[] structure as 
> well.
> 
> Thanks,
> 
> 	Ingo

I will add another cleanup patch to fix the alignment of those code blocks and
resubmit. Thank you for the review, Ingo!

Andrew

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCHv2 0/10] arch/x86/platform/uv: add UV4 support to BAU
  2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
                   ` (9 preceding siblings ...)
  2016-09-21 14:55 ` [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Thomas Gleixner
@ 2016-09-21 16:09 ` Andrew Banman
  2016-09-21 16:09   ` [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment Andrew Banman
                     ` (9 more replies)
  10 siblings, 10 replies; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

This is version 2 of a patch set to add UV4 support to the BAU. The only
changes from the the original version are whitespace sytle fixes (PATCH 1).

The following patch set adds support for UV4 architecture to the Broadcast
Assist Unit (BAU). Major hardware changes to the BAU require these fixes to
ensure correct operation and to avoid illegal MMR writes.

The patch set can be thought of in three logical groups:

1) General cleanup.

 [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment
 [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks
 [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init
 [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr

 These housekeeping patches make the subsequent UV4 patches clearer,
 and they should be done in any case.


2) Implement a new scheme to abstract UV version-specific functions.

 [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers
 [PATCH 06/10] arch/x86/platform/uv: BAU use generic function pointers

 We add a struct of function pointers to define version-specific BAU
 operations. The philosophy is to abstract functions that perform the same
 operation on all UV versions but have different implementations. This will
 simplify their use in the body of the driver code and greatly simplify the
 UV4 patches to follow.


3) Add UV4 functionality.

 [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version
 [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout
 [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup
 [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific

 These patches feature a minimal set of changes to make the BAU on UV4
 operational.


This patch set has been tested for regressions on pre-UV4 architectures and
for correct functionality on UV4. The patches apply cleanly to 4.8-rc7.
Fine-tuned performance tweaking for UV4 will come in a future patch set.


Thank you,

Andrew Banman

^ permalink raw reply	[flat|nested] 34+ messages in thread

* [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:28     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up " tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
                     ` (8 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Fix whitespace on blocks of code to be vertically aligned.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index fdb4d42..b84c2a2 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -55,16 +55,16 @@ static int congested_reps	= CONGESTED_REPS;
 static int disabled_period	= DISABLED_PERIOD;
 
 static struct tunables tunables[] = {
-	{&max_concurr, MAX_BAU_CONCURRENT}, /* must be [0] */
-	{&plugged_delay, PLUGGED_DELAY},
-	{&plugsb4reset, PLUGSB4RESET},
-	{&timeoutsb4reset, TIMEOUTSB4RESET},
-	{&ipi_reset_limit, IPI_RESET_LIMIT},
-	{&complete_threshold, COMPLETE_THRESHOLD},
-	{&congested_respns_us, CONGESTED_RESPONSE_US},
-	{&congested_reps, CONGESTED_REPS},
-	{&disabled_period, DISABLED_PERIOD},
-	{&giveup_limit, GIVEUP_LIMIT}
+	{&max_concurr,           MAX_BAU_CONCURRENT}, /* must be [0] */
+	{&plugged_delay,         PLUGGED_DELAY},
+	{&plugsb4reset,          PLUGSB4RESET},
+	{&timeoutsb4reset,       TIMEOUTSB4RESET},
+	{&ipi_reset_limit,       IPI_RESET_LIMIT},
+	{&complete_threshold,    COMPLETE_THRESHOLD},
+	{&congested_respns_us,   CONGESTED_RESPONSE_US},
+	{&congested_reps,        CONGESTED_REPS},
+	{&disabled_period,       DISABLED_PERIOD},
+	{&giveup_limit,          GIVEUP_LIMIT}
 };
 
 static struct dentry *tunables_dir;
@@ -1619,17 +1619,17 @@ static ssize_t tunables_write(struct file *file, const char __user *user,
 
 	for_each_present_cpu(cpu) {
 		bcp = &per_cpu(bau_control, cpu);
-		bcp->max_concurr =		max_concurr;
-		bcp->max_concurr_const =	max_concurr;
-		bcp->plugged_delay =		plugged_delay;
-		bcp->plugsb4reset =		plugsb4reset;
-		bcp->timeoutsb4reset =		timeoutsb4reset;
-		bcp->ipi_reset_limit =		ipi_reset_limit;
-		bcp->complete_threshold =	complete_threshold;
-		bcp->cong_response_us =		congested_respns_us;
-		bcp->cong_reps =		congested_reps;
-		bcp->disabled_period =		sec_2_cycles(disabled_period);
-		bcp->giveup_limit =		giveup_limit;
+		bcp->max_concurr         = max_concurr;
+		bcp->max_concurr_const   = max_concurr;
+		bcp->plugged_delay       = plugged_delay;
+		bcp->plugsb4reset        = plugsb4reset;
+		bcp->timeoutsb4reset     = timeoutsb4reset;
+		bcp->ipi_reset_limit     = ipi_reset_limit;
+		bcp->complete_threshold  = complete_threshold;
+		bcp->cong_response_us    = congested_respns_us;
+		bcp->cong_reps           = congested_reps;
+		bcp->disabled_period     = sec_2_cycles(disabled_period);
+		bcp->giveup_limit        = giveup_limit;
 	}
 	return count;
 }
@@ -1740,7 +1740,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 		memset(bd2, 0, sizeof(struct bau_desc));
 		if (uv1) {
 			uv1_hdr = &bd2->header.uv1_hdr;
-			uv1_hdr->swack_flag =	1;
+			uv1_hdr->swack_flag = 1;
 			/*
 			 * The base_dest_nasid set in the message header
 			 * is the nasid of the first uvhub in the partition.
@@ -1749,10 +1749,10 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 			 * if nasid striding is being used.
 			 */
 			uv1_hdr->base_dest_nasid =
-						UV_PNODE_TO_NASID(base_pnode);
-			uv1_hdr->dest_subnodeid =	UV_LB_SUBNODEID;
-			uv1_hdr->command =		UV_NET_ENDPOINT_INTD;
-			uv1_hdr->int_both =		1;
+			                          UV_PNODE_TO_NASID(base_pnode);
+			uv1_hdr->dest_subnodeid  = UV_LB_SUBNODEID;
+			uv1_hdr->command         = UV_NET_ENDPOINT_INTD;
+			uv1_hdr->int_both        = 1;
 			/*
 			 * all others need to be set to zero:
 			 *   fairness chaining multilevel count replied_to
@@ -1763,11 +1763,11 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 			 * uses native mode for selective broadcasts.
 			 */
 			uv2_3_hdr = &bd2->header.uv2_3_hdr;
-			uv2_3_hdr->swack_flag =	1;
+			uv2_3_hdr->swack_flag      = 1;
 			uv2_3_hdr->base_dest_nasid =
-						UV_PNODE_TO_NASID(base_pnode);
-			uv2_3_hdr->dest_subnodeid =	UV_LB_SUBNODEID;
-			uv2_3_hdr->command =		UV_NET_ENDPOINT_INTD;
+			                          UV_PNODE_TO_NASID(base_pnode);
+			uv2_3_hdr->dest_subnodeid  = UV_LB_SUBNODEID;
+			uv2_3_hdr->command         = UV_NET_ENDPOINT_INTD;
 		}
 	}
 	for_each_present_cpu(cpu) {
@@ -1914,8 +1914,8 @@ static void __init init_per_cpu_tunables(void)
 		bcp->complete_threshold		= complete_threshold;
 		bcp->cong_response_us		= congested_respns_us;
 		bcp->cong_reps			= congested_reps;
-		bcp->disabled_period =		sec_2_cycles(disabled_period);
-		bcp->giveup_limit =		giveup_limit;
+		bcp->disabled_period		= sec_2_cycles(disabled_period);
+		bcp->giveup_limit		= giveup_limit;
 		spin_lock_init(&bcp->queue_lock);
 		spin_lock_init(&bcp->uvhub_lock);
 		spin_lock_init(&bcp->disable_lock);
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
  2016-09-21 16:09   ` [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:29     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up and " tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
                     ` (7 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Replace all uses of printk with the appropriate pr_* function.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index b84c2a2..8462fd1 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1497,16 +1497,16 @@ static ssize_t ptc_proc_write(struct file *file, const char __user *user,
 	}
 
 	if (kstrtol(optstr, 10, &input_arg) < 0) {
-		printk(KERN_DEBUG "%s is invalid\n", optstr);
+		pr_debug("%s is invalid\n", optstr);
 		return -EINVAL;
 	}
 
 	if (input_arg == 0) {
 		elements = ARRAY_SIZE(stat_description);
-		printk(KERN_DEBUG "# cpu:      cpu number\n");
-		printk(KERN_DEBUG "Sender statistics:\n");
+		pr_debug("# cpu:      cpu number\n");
+		pr_debug("Sender statistics:\n");
 		for (i = 0; i < elements; i++)
-			printk(KERN_DEBUG "%s\n", stat_description[i]);
+			pr_debug("%s\n", stat_description[i]);
 	} else if (input_arg == -1) {
 		for_each_present_cpu(cpu) {
 			stat = &per_cpu(ptcstats, cpu);
@@ -1554,7 +1554,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 			break;
 	}
 	if (cnt != e) {
-		printk(KERN_INFO "bau tunable error: should be %d values\n", e);
+		pr_info("bau tunable error: should be %d values\n", e);
 		return -EINVAL;
 	}
 
@@ -1571,7 +1571,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 				continue;
 			}
 			if (val < 1 || val > bcp->cpus_in_uvhub) {
-				printk(KERN_DEBUG
+				pr_debug(
 				"Error: BAU max concurrent %d is invalid\n",
 				val);
 				return -EINVAL;
@@ -1676,21 +1676,21 @@ static int __init uv_ptc_init(void)
 	proc_uv_ptc = proc_create(UV_PTC_BASENAME, 0444, NULL,
 				  &proc_uv_ptc_operations);
 	if (!proc_uv_ptc) {
-		printk(KERN_ERR "unable to create %s proc entry\n",
+		pr_err("unable to create %s proc entry\n",
 		       UV_PTC_BASENAME);
 		return -EINVAL;
 	}
 
 	tunables_dir = debugfs_create_dir(UV_BAU_TUNABLES_DIR, NULL);
 	if (!tunables_dir) {
-		printk(KERN_ERR "unable to create debugfs directory %s\n",
+		pr_err("unable to create debugfs directory %s\n",
 		       UV_BAU_TUNABLES_DIR);
 		return -EINVAL;
 	}
 	tunables_file = debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600,
 					tunables_dir, NULL, &tunables_fops);
 	if (!tunables_file) {
-		printk(KERN_ERR "unable to create debugfs file %s\n",
+		pr_err("unable to create debugfs file %s\n",
 		       UV_BAU_TUNABLES_FILE);
 		return -EINVAL;
 	}
@@ -1944,7 +1944,7 @@ static int __init get_cpu_topology(int base_pnode,
 
 		pnode = uv_cpu_hub_info(cpu)->pnode;
 		if ((pnode - base_pnode) >= UV_DISTRIBUTION_SIZE) {
-			printk(KERN_EMERG
+			pr_emerg(
 				"cpu %d pnode %d-%d beyond %d; BAU disabled\n",
 				cpu, pnode, base_pnode, UV_DISTRIBUTION_SIZE);
 			return 1;
@@ -1969,7 +1969,7 @@ static int __init get_cpu_topology(int base_pnode,
 		sdp->cpu_number[sdp->num_cpus] = cpu;
 		sdp->num_cpus++;
 		if (sdp->num_cpus > MAX_CPUS_PER_SOCKET) {
-			printk(KERN_EMERG "%d cpus per socket invalid\n",
+			pr_emerg("%d cpus per socket invalid\n",
 				sdp->num_cpus);
 			return 1;
 		}
@@ -2036,14 +2036,14 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
 		else {
-			printk(KERN_EMERG "uvhub version not 1, 2 or 3\n");
+			pr_emerg("uvhub version not 1, 2, or 3\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;
 		bcp->uvhub_cpu = uv_cpu_blade_processor_id(cpu);
 
 		if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) {
-			printk(KERN_EMERG "%d cpus per uvhub invalid\n",
+			pr_emerg("%d cpus per uvhub invalid\n",
 				bcp->uvhub_cpu);
 			return 1;
 		}
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
  2016-09-21 16:09   ` [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment Andrew Banman
  2016-09-21 16:09   ` [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:29     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up pq_init() tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
                     ` (6 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The payload queue first MMR requires the physical memory address and hub
GNODE of where the payload queue resides in memory, but the associated
variables are named as if the PNODE were used. Rename gnode-related
variables and clarify the definitions of the payload queue head, last, and
tail pointers.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/uv/uv_bau.h |  2 +-
 arch/x86/platform/uv/tlb_uv.c    | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc44d92..cc058c6 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -49,7 +49,7 @@
 #define UV_NET_ENDPOINT_INTD		(is_uv1_hub() ?			\
 			UV1_NET_ENDPOINT_INTD : UV2_NET_ENDPOINT_INTD)
 #define UV_DESC_PSHIFT			49
-#define UV_PAYLOADQ_PNODE_SHIFT		49
+#define UV_PAYLOADQ_GNODE_SHIFT		49
 #define UV_PTC_BASENAME			"sgi_uv/ptc_statistics"
 #define UV_BAU_BASENAME			"sgi_uv/bau_tunables"
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 8462fd1..f6bc43b 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1790,10 +1790,7 @@ static void pq_init(int node, int pnode)
 	size_t plsize;
 	char *cp;
 	void *vp;
-	unsigned long pn;
-	unsigned long first;
-	unsigned long pn_first;
-	unsigned long last;
+	unsigned long gnode, first, last, tail;
 	struct bau_pq_entry *pqp;
 	struct bau_control *bcp;
 
@@ -1814,16 +1811,16 @@ static void pq_init(int node, int pnode)
 		bcp->bau_msg_head	= pqp;
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
-	/*
-	 * need the gnode of where the memory was really allocated
-	 */
-	pn = uv_gpa_to_gnode(uv_gpa(pqp));
+
 	first = uv_physnodeaddr(pqp);
-	pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
 	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
-	write_mmr_payload_first(pnode, pn_first);
-	write_mmr_payload_tail(pnode, first);
+	tail = first;
+	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+
+	write_mmr_payload_first(pnode, first);
 	write_mmr_payload_last(pnode, last);
+	write_mmr_payload_tail(pnode, tail);
 	write_gmmr_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (2 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:30     ` [tip:x86/platform] x86/platform/uv/BAU: Convert uv_physnodeaddr() use to uv_gpa_to_offset() tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
                     ` (5 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The BAU driver should use the functions provided by uv_hub.h rather than
its own implementations. uv_physnodeaddr converts vaddrs to paddrs for
BAU MMR fields, but this is done better by uv_gpa_to_offset.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/uv/uv_bau.h | 2 --
 arch/x86/platform/uv/tlb_uv.c    | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc058c6..a46f270 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -55,8 +55,6 @@
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
 #define UV_BAU_TUNABLES_FILE		"bau_tunables"
 #define WHITESPACE			" \t\n"
-#define uv_mmask			((1UL << uv_hub_info->m_val) - 1)
-#define uv_physnodeaddr(x)		((__pa((unsigned long)(x)) & uv_mmask))
 #define cpubit_isset(cpu, bau_local_cpumask) \
 	test_bit((cpu), (bau_local_cpumask).bits)
 
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index f6bc43b..34b2a48 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1812,8 +1812,8 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_physnodeaddr(pqp);
-	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
+	first = uv_gpa_to_offset(uv_gpa(pqp));
+	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (3 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:30     ` [tip:x86/platform] x86/platform/uv/BAU: Add " tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 06/10] arch/x86/platform/uv: BAU use " Andrew Banman
                     ` (4 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Many BAU functions have different implementations depending on the UV
version. Rather than switching on the uvhub_version throughout the driver,
we can define a set of operations for each version. This is especially
beneficial for UV4, which will require many new MMR read/write functions.

Currently, the set of abstracted functions are the same for UV1, UV2, and
UV3. The functions were chosen because each one will have a different
implementation for UV4. Other functions will be added as needed to handle
new implementations or to cleanup the existing differences between UV1,
UV2, and UV3, i.e. read_status and wait_completion.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/uv/uv_bau.h | 11 +++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a46f270..a7a93a5 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -385,6 +385,17 @@ struct uv2_3_bau_msg_header {
 	/* bits 127:120 */
 };
 
+/* Abstracted BAU functions */
+struct bau_operations {
+	unsigned long (*read_l_sw_ack)(void);
+	unsigned long (*read_g_sw_ack)(int pnode);
+	unsigned long (*bau_gpa_to_offset)(unsigned long vaddr);
+	void (*write_l_sw_ack)(unsigned long mmr);
+	void (*write_g_sw_ack)(int pnode, unsigned long mmr);
+	void (*write_payload_first)(int pnode, unsigned long mmr);
+	void (*write_payload_last)(int pnode, unsigned long mmr);
+};
+
 /*
  * The activation descriptor:
  * The format of the message to send, plus all accompanying control
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 34b2a48..a33a433 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -24,6 +24,18 @@
 #include <asm/irq_vectors.h>
 #include <asm/timer.h>
 
+static struct bau_operations ops;
+
+static struct bau_operations uv123_bau_ops = {
+	.bau_gpa_to_offset       = uv_gpa_to_offset,
+	.read_l_sw_ack           = read_mmr_sw_ack,
+	.read_g_sw_ack           = read_gmmr_sw_ack,
+	.write_l_sw_ack          = write_mmr_sw_ack,
+	.write_g_sw_ack          = write_gmmr_sw_ack,
+	.write_payload_first     = write_mmr_payload_first,
+	.write_payload_last      = write_mmr_payload_last,
+};
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2135,6 +2147,13 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
+	if (is_uv3_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv2_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv1_hub())
+		ops = uv123_bau_ops;
+
 	for_each_possible_cpu(cur_cpu) {
 		mask = &per_cpu(uv_flush_tlb_mask, cur_cpu);
 		zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 06/10] arch/x86/platform/uv: BAU use generic function pointers
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (4 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:31     ` [tip:x86/platform] x86/platform/uv/BAU: Use " tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
                     ` (3 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Convert the use of UV version-specific functions to their abstracted
counterparts.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index a33a433..030d452 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -228,7 +228,7 @@ static void reply_to_message(struct msg_desc *mdp, struct bau_control *bcp,
 	msg = mdp->msg;
 	if (!msg->canceled && do_acknowledge) {
 		dw = (msg->swack_vec << UV_SW_ACK_NPENDING) | msg->swack_vec;
-		write_mmr_sw_ack(dw);
+		ops.write_l_sw_ack(dw);
 	}
 	msg->replied_to = 1;
 	msg->swack_vec = 0;
@@ -264,7 +264,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 			msg->swack_vec) == 0) &&
 		    (msg2->sending_cpu == msg->sending_cpu) &&
 		    (msg2->msg_type != MSG_NOOP)) {
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg2->swack_vec;
 			/*
 			 * This is a message retry; clear the resources held
@@ -282,7 +282,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 				stat->d_canceled++;
 				cancel_count++;
 				mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -415,12 +415,12 @@ static void do_reset(void *ptr)
 			/*
 			 * only reset the resource if it is still pending
 			 */
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg->swack_vec;
 			mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
 			if (mmr & msg_res) {
 				stat->d_rcanceled++;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -1214,7 +1214,7 @@ void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
 	struct bau_pq_entry *msg = mdp->msg;
 	struct bau_pq_entry *other_msg;
 
-	mmr_image = read_mmr_sw_ack();
+	mmr_image = ops.read_l_sw_ack();
 	swack_vec = msg->swack_vec;
 
 	if ((swack_vec & mmr_image) == 0) {
@@ -1443,7 +1443,7 @@ static int ptc_seq_show(struct seq_file *file, void *data)
 		/* destination side statistics */
 		seq_printf(file,
 			"%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
-			   read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)),
+			   ops.read_g_sw_ack(uv_cpu_to_pnode(cpu)),
 			   stat->d_requestee, cycles_2_us(stat->d_time),
 			   stat->d_alltlb, stat->d_onetlb, stat->d_multmsg,
 			   stat->d_nomsg, stat->d_retries, stat->d_canceled,
@@ -1737,7 +1737,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 
 	gpa = uv_gpa(bau_desc);
 	n = uv_gpa_to_gnode(gpa);
-	m = uv_gpa_to_offset(gpa);
+	m = ops.bau_gpa_to_offset(gpa);
 	if (is_uv1_hub())
 		uv1 = 1;
 
@@ -1824,16 +1824,16 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_gpa_to_offset(uv_gpa(pqp));
-	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
+	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
+	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_first(pnode, first);
-	write_mmr_payload_last(pnode, last);
 	write_mmr_payload_tail(pnode, tail);
-	write_gmmr_sw_ack(pnode, 0xffffUL);
+	ops.write_payload_first(pnode, first);
+	ops.write_payload_last(pnode, last);
+	ops.write_g_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */
 	memset(pqp, 0, sizeof(struct bau_pq_entry) * DEST_Q_SIZE);
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (5 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 06/10] arch/x86/platform/uv: BAU use " Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:31     ` [tip:x86/platform] x86/platform/uv/BAU: Populate ->uvhub_version with UV4 version information tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
                     ` (2 subsequent siblings)
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 030d452..ddbeb16 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2044,8 +2044,10 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 			bcp->uvhub_version = 2;
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
+		else if (is_uv4_hub())
+			bcp->uvhub_version = 4;
 		else {
-			pr_emerg("uvhub version not 1, 2, or 3\n");
+			pr_emerg("uvhub version not 1, 2, 3, or 4\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (6 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:32     ` [tip:x86/platform] x86/platform/uv/BAU: Disable software timeout on UV4 hardware tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
  2016-09-21 16:09   ` [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Software timeouts are not currently supported on BAU for UV4. Instead, the
BAU will rely on hardware-level fairness protocols to determine broadcast
timeouts.

Do not call enable_timeouts or calculate_destination_timeout on UV4. These
functions write to pre-UV4 MMRs so they generate error messages on UV4.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index ddbeb16..72a5de7 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2109,7 +2109,8 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
 	void *vp;
 	struct uvhub_desc *uvhub_descs;
 
-	timeout_us = calculate_destination_timeout();
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		timeout_us = calculate_destination_timeout();
 
 	vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
 	uvhub_descs = (struct uvhub_desc *)vp;
@@ -2171,7 +2172,9 @@ static int __init uv_bau_init(void)
 			uv_base_pnode = uv_blade_to_pnode(uvhub);
 	}
 
-	enable_timeouts();
+	/* software timeouts are not supported on UV4 */
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		enable_timeouts();
 
 	if (init_per_cpu(nuvhubs, uv_base_pnode)) {
 		set_bau_off();
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (7 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:32     ` [tip:x86/platform] x86/platform/uv/BAU: Fix payload queue setup on UV4 hardware tip-bot for Andrew Banman
  2016-09-21 16:09   ` [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

The BAU on UV4 does not need to maintain the payload queue tail pointer. Do
not initialize the tail pointer MMR on UV4.

Note that write_payload_tail is not an abstracted BAU function since it is
an operation specific to pre-UV4 versions. Then we must switch on the UV
version to control its usage, for which we use uvhub_version rather than
is_uv*_hub because it is quicker/more concise.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/platform/uv/tlb_uv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 72a5de7..7ca0e5c 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1826,11 +1826,19 @@ static void pq_init(int node, int pnode)
 
 	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
 	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
-	tail = first;
-	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
-	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_tail(pnode, tail);
+	/*
+	 * Pre UV4, the gnode is required to locate the payload queue
+	 * and the payload queue tail must be maintained by the kernel.
+	 */
+	bcp = &per_cpu(bau_control, smp_processor_id());
+	if (bcp->uvhub_version <= 3) {
+		tail = first;
+		gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+		first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+		write_mmr_payload_tail(pnode, tail);
+	}
+
 	ops.write_payload_first(pnode, first);
 	ops.write_payload_last(pnode, last);
 	ops.write_g_sw_ack(pnode, 0xffffUL);
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific functions
  2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
                     ` (8 preceding siblings ...)
  2016-09-21 16:09   ` [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
@ 2016-09-21 16:09   ` Andrew Banman
  2016-09-22 10:33     ` [tip:x86/platform] x86/platform/uv/BAU: Add UV4-specific functions tip-bot for Andrew Banman
  9 siblings, 1 reply; 34+ messages in thread
From: Andrew Banman @ 2016-09-21 16:09 UTC (permalink / raw)
  To: mingo; +Cc: akpm, tglx, hpa, travis, rja, sivanich, x86, linux-kernel, abanman

Add the UV4-specific function definitions and define an operations struct
to implement them in the BAU driver.

Many BAU MMRs, although functionally the same, have new addresses on UV4
due to hardware changes. Each MMR requires new read/write functions, but
their implementation in the driver does not change. Thus, it is enough to
enumerate them in the operations struct for the changes to take effect.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
---
 arch/x86/include/asm/uv/uv_bau.h | 30 ++++++++++++++++++++++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 15 ++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a7a93a5..57ab86d 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -664,6 +664,16 @@ static inline void write_gmmr_activation(int pnode, unsigned long mmr_image)
 	write_gmmr(pnode, UVH_LB_BAU_SB_ACTIVATION_CONTROL, mmr_image);
 }
 
+static inline void write_mmr_proc_payload_first(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_FIRST, mmr_image);
+}
+
+static inline void write_mmr_proc_payload_last(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_LAST, mmr_image);
+}
+
 static inline void write_mmr_payload_first(int pnode, unsigned long mmr_image)
 {
 	write_gmmr(pnode, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST, mmr_image);
@@ -709,6 +719,26 @@ static inline unsigned long read_gmmr_sw_ack(int pnode)
 	return read_gmmr(pnode, UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE);
 }
 
+static inline void write_mmr_proc_sw_ack(unsigned long mr)
+{
+	uv_write_local_mmr(UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline void write_gmmr_proc_sw_ack(int pnode, unsigned long mr)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline unsigned long read_mmr_proc_sw_ack(void)
+{
+	return read_lmmr(UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
+static inline unsigned long read_gmmr_proc_sw_ack(int pnode)
+{
+	return read_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
 static inline void write_mmr_data_config(int pnode, unsigned long mr)
 {
 	uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, mr);
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 7ca0e5c..56c5a3a 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -36,6 +36,17 @@ static struct bau_operations uv123_bau_ops = {
 	.write_payload_last      = write_mmr_payload_last,
 };
 
+static struct bau_operations uv4_bau_ops = {
+	.bau_gpa_to_offset       = uv_gpa_to_soc_phys_ram,
+	.read_l_sw_ack           = read_mmr_proc_sw_ack,
+	.read_g_sw_ack           = read_gmmr_proc_sw_ack,
+	.write_l_sw_ack          = write_mmr_proc_sw_ack,
+	.write_g_sw_ack          = write_gmmr_proc_sw_ack,
+	.write_payload_first     = write_mmr_proc_payload_first,
+	.write_payload_last      = write_mmr_proc_payload_last,
+};
+
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2158,7 +2169,9 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
-	if (is_uv3_hub())
+	if (is_uv4_hub())
+		ops = uv4_bau_ops;
+	else if (is_uv3_hub())
 		ops = uv123_bau_ops;
 	else if (is_uv2_hub())
 		ops = uv123_bau_ops;
-- 
1.8.5.6

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Clean up vertical alignment
  2016-09-21 16:09   ` [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment Andrew Banman
@ 2016-09-22 10:28     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:28 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, hpa, sivanich, linux-kernel, abanman, mingo, peterz,
	travis, tglx

Commit-ID:  67492c86b33db0a8a056c72293d4802b37ac8ac6
Gitweb:     http://git.kernel.org/tip/67492c86b33db0a8a056c72293d4802b37ac8ac6
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:12 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:12 +0200

x86/platform/uv/BAU: Clean up vertical alignment

Fix whitespace on blocks of code to be vertically aligned.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-2-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 64 +++++++++++++++++++++----------------------
 1 file changed, 32 insertions(+), 32 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index fdb4d42..b84c2a2 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -55,16 +55,16 @@ static int congested_reps	= CONGESTED_REPS;
 static int disabled_period	= DISABLED_PERIOD;
 
 static struct tunables tunables[] = {
-	{&max_concurr, MAX_BAU_CONCURRENT}, /* must be [0] */
-	{&plugged_delay, PLUGGED_DELAY},
-	{&plugsb4reset, PLUGSB4RESET},
-	{&timeoutsb4reset, TIMEOUTSB4RESET},
-	{&ipi_reset_limit, IPI_RESET_LIMIT},
-	{&complete_threshold, COMPLETE_THRESHOLD},
-	{&congested_respns_us, CONGESTED_RESPONSE_US},
-	{&congested_reps, CONGESTED_REPS},
-	{&disabled_period, DISABLED_PERIOD},
-	{&giveup_limit, GIVEUP_LIMIT}
+	{&max_concurr,           MAX_BAU_CONCURRENT}, /* must be [0] */
+	{&plugged_delay,         PLUGGED_DELAY},
+	{&plugsb4reset,          PLUGSB4RESET},
+	{&timeoutsb4reset,       TIMEOUTSB4RESET},
+	{&ipi_reset_limit,       IPI_RESET_LIMIT},
+	{&complete_threshold,    COMPLETE_THRESHOLD},
+	{&congested_respns_us,   CONGESTED_RESPONSE_US},
+	{&congested_reps,        CONGESTED_REPS},
+	{&disabled_period,       DISABLED_PERIOD},
+	{&giveup_limit,          GIVEUP_LIMIT}
 };
 
 static struct dentry *tunables_dir;
@@ -1619,17 +1619,17 @@ static ssize_t tunables_write(struct file *file, const char __user *user,
 
 	for_each_present_cpu(cpu) {
 		bcp = &per_cpu(bau_control, cpu);
-		bcp->max_concurr =		max_concurr;
-		bcp->max_concurr_const =	max_concurr;
-		bcp->plugged_delay =		plugged_delay;
-		bcp->plugsb4reset =		plugsb4reset;
-		bcp->timeoutsb4reset =		timeoutsb4reset;
-		bcp->ipi_reset_limit =		ipi_reset_limit;
-		bcp->complete_threshold =	complete_threshold;
-		bcp->cong_response_us =		congested_respns_us;
-		bcp->cong_reps =		congested_reps;
-		bcp->disabled_period =		sec_2_cycles(disabled_period);
-		bcp->giveup_limit =		giveup_limit;
+		bcp->max_concurr         = max_concurr;
+		bcp->max_concurr_const   = max_concurr;
+		bcp->plugged_delay       = plugged_delay;
+		bcp->plugsb4reset        = plugsb4reset;
+		bcp->timeoutsb4reset     = timeoutsb4reset;
+		bcp->ipi_reset_limit     = ipi_reset_limit;
+		bcp->complete_threshold  = complete_threshold;
+		bcp->cong_response_us    = congested_respns_us;
+		bcp->cong_reps           = congested_reps;
+		bcp->disabled_period     = sec_2_cycles(disabled_period);
+		bcp->giveup_limit        = giveup_limit;
 	}
 	return count;
 }
@@ -1740,7 +1740,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 		memset(bd2, 0, sizeof(struct bau_desc));
 		if (uv1) {
 			uv1_hdr = &bd2->header.uv1_hdr;
-			uv1_hdr->swack_flag =	1;
+			uv1_hdr->swack_flag = 1;
 			/*
 			 * The base_dest_nasid set in the message header
 			 * is the nasid of the first uvhub in the partition.
@@ -1749,10 +1749,10 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 			 * if nasid striding is being used.
 			 */
 			uv1_hdr->base_dest_nasid =
-						UV_PNODE_TO_NASID(base_pnode);
-			uv1_hdr->dest_subnodeid =	UV_LB_SUBNODEID;
-			uv1_hdr->command =		UV_NET_ENDPOINT_INTD;
-			uv1_hdr->int_both =		1;
+			                          UV_PNODE_TO_NASID(base_pnode);
+			uv1_hdr->dest_subnodeid  = UV_LB_SUBNODEID;
+			uv1_hdr->command         = UV_NET_ENDPOINT_INTD;
+			uv1_hdr->int_both        = 1;
 			/*
 			 * all others need to be set to zero:
 			 *   fairness chaining multilevel count replied_to
@@ -1763,11 +1763,11 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 			 * uses native mode for selective broadcasts.
 			 */
 			uv2_3_hdr = &bd2->header.uv2_3_hdr;
-			uv2_3_hdr->swack_flag =	1;
+			uv2_3_hdr->swack_flag      = 1;
 			uv2_3_hdr->base_dest_nasid =
-						UV_PNODE_TO_NASID(base_pnode);
-			uv2_3_hdr->dest_subnodeid =	UV_LB_SUBNODEID;
-			uv2_3_hdr->command =		UV_NET_ENDPOINT_INTD;
+			                          UV_PNODE_TO_NASID(base_pnode);
+			uv2_3_hdr->dest_subnodeid  = UV_LB_SUBNODEID;
+			uv2_3_hdr->command         = UV_NET_ENDPOINT_INTD;
 		}
 	}
 	for_each_present_cpu(cpu) {
@@ -1914,8 +1914,8 @@ static void __init init_per_cpu_tunables(void)
 		bcp->complete_threshold		= complete_threshold;
 		bcp->cong_response_us		= congested_respns_us;
 		bcp->cong_reps			= congested_reps;
-		bcp->disabled_period =		sec_2_cycles(disabled_period);
-		bcp->giveup_limit =		giveup_limit;
+		bcp->disabled_period		= sec_2_cycles(disabled_period);
+		bcp->giveup_limit		= giveup_limit;
 		spin_lock_init(&bcp->queue_lock);
 		spin_lock_init(&bcp->uvhub_lock);
 		spin_lock_init(&bcp->disable_lock);

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Clean up and update printks
  2016-09-21 16:09   ` [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
@ 2016-09-22 10:29     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, sivanich, hpa, linux-kernel, peterz, abanman, tglx,
	torvalds, travis

Commit-ID:  efa59ab3e7526650265f0fd9696ef8be8d88ec13
Gitweb:     http://git.kernel.org/tip/efa59ab3e7526650265f0fd9696ef8be8d88ec13
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:13 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:12 +0200

x86/platform/uv/BAU: Clean up and update printks

Replace all uses of printk with the appropriate pr_*() function.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-3-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index b84c2a2..8462fd1 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1497,16 +1497,16 @@ static ssize_t ptc_proc_write(struct file *file, const char __user *user,
 	}
 
 	if (kstrtol(optstr, 10, &input_arg) < 0) {
-		printk(KERN_DEBUG "%s is invalid\n", optstr);
+		pr_debug("%s is invalid\n", optstr);
 		return -EINVAL;
 	}
 
 	if (input_arg == 0) {
 		elements = ARRAY_SIZE(stat_description);
-		printk(KERN_DEBUG "# cpu:      cpu number\n");
-		printk(KERN_DEBUG "Sender statistics:\n");
+		pr_debug("# cpu:      cpu number\n");
+		pr_debug("Sender statistics:\n");
 		for (i = 0; i < elements; i++)
-			printk(KERN_DEBUG "%s\n", stat_description[i]);
+			pr_debug("%s\n", stat_description[i]);
 	} else if (input_arg == -1) {
 		for_each_present_cpu(cpu) {
 			stat = &per_cpu(ptcstats, cpu);
@@ -1554,7 +1554,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 			break;
 	}
 	if (cnt != e) {
-		printk(KERN_INFO "bau tunable error: should be %d values\n", e);
+		pr_info("bau tunable error: should be %d values\n", e);
 		return -EINVAL;
 	}
 
@@ -1571,7 +1571,7 @@ static int parse_tunables_write(struct bau_control *bcp, char *instr,
 				continue;
 			}
 			if (val < 1 || val > bcp->cpus_in_uvhub) {
-				printk(KERN_DEBUG
+				pr_debug(
 				"Error: BAU max concurrent %d is invalid\n",
 				val);
 				return -EINVAL;
@@ -1676,21 +1676,21 @@ static int __init uv_ptc_init(void)
 	proc_uv_ptc = proc_create(UV_PTC_BASENAME, 0444, NULL,
 				  &proc_uv_ptc_operations);
 	if (!proc_uv_ptc) {
-		printk(KERN_ERR "unable to create %s proc entry\n",
+		pr_err("unable to create %s proc entry\n",
 		       UV_PTC_BASENAME);
 		return -EINVAL;
 	}
 
 	tunables_dir = debugfs_create_dir(UV_BAU_TUNABLES_DIR, NULL);
 	if (!tunables_dir) {
-		printk(KERN_ERR "unable to create debugfs directory %s\n",
+		pr_err("unable to create debugfs directory %s\n",
 		       UV_BAU_TUNABLES_DIR);
 		return -EINVAL;
 	}
 	tunables_file = debugfs_create_file(UV_BAU_TUNABLES_FILE, 0600,
 					tunables_dir, NULL, &tunables_fops);
 	if (!tunables_file) {
-		printk(KERN_ERR "unable to create debugfs file %s\n",
+		pr_err("unable to create debugfs file %s\n",
 		       UV_BAU_TUNABLES_FILE);
 		return -EINVAL;
 	}
@@ -1944,7 +1944,7 @@ static int __init get_cpu_topology(int base_pnode,
 
 		pnode = uv_cpu_hub_info(cpu)->pnode;
 		if ((pnode - base_pnode) >= UV_DISTRIBUTION_SIZE) {
-			printk(KERN_EMERG
+			pr_emerg(
 				"cpu %d pnode %d-%d beyond %d; BAU disabled\n",
 				cpu, pnode, base_pnode, UV_DISTRIBUTION_SIZE);
 			return 1;
@@ -1969,7 +1969,7 @@ static int __init get_cpu_topology(int base_pnode,
 		sdp->cpu_number[sdp->num_cpus] = cpu;
 		sdp->num_cpus++;
 		if (sdp->num_cpus > MAX_CPUS_PER_SOCKET) {
-			printk(KERN_EMERG "%d cpus per socket invalid\n",
+			pr_emerg("%d cpus per socket invalid\n",
 				sdp->num_cpus);
 			return 1;
 		}
@@ -2036,14 +2036,14 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
 		else {
-			printk(KERN_EMERG "uvhub version not 1, 2 or 3\n");
+			pr_emerg("uvhub version not 1, 2, or 3\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;
 		bcp->uvhub_cpu = uv_cpu_blade_processor_id(cpu);
 
 		if (bcp->uvhub_cpu >= MAX_CPUS_PER_UVHUB) {
-			printk(KERN_EMERG "%d cpus per uvhub invalid\n",
+			pr_emerg("%d cpus per uvhub invalid\n",
 				bcp->uvhub_cpu);
 			return 1;
 		}

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Clean up pq_init()
  2016-09-21 16:09   ` [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
@ 2016-09-22 10:29     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:29 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: travis, hpa, peterz, torvalds, linux-kernel, mingo, sivanich,
	abanman, tglx

Commit-ID:  d2a57afa53f3fdf9f68d1f4240ace85a7d20ca20
Gitweb:     http://git.kernel.org/tip/d2a57afa53f3fdf9f68d1f4240ace85a7d20ca20
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:14 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:13 +0200

x86/platform/uv/BAU: Clean up pq_init()

The payload queue first MMR requires the physical memory address and hub
GNODE of where the payload queue resides in memory, but the associated
variables are named as if the PNODE were used. Rename gnode-related
variables and clarify the definitions of the payload queue head, last, and
tail pointers.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-4-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/uv/uv_bau.h |  2 +-
 arch/x86/platform/uv/tlb_uv.c    | 19 ++++++++-----------
 2 files changed, 9 insertions(+), 12 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc44d92..cc058c6 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -49,7 +49,7 @@
 #define UV_NET_ENDPOINT_INTD		(is_uv1_hub() ?			\
 			UV1_NET_ENDPOINT_INTD : UV2_NET_ENDPOINT_INTD)
 #define UV_DESC_PSHIFT			49
-#define UV_PAYLOADQ_PNODE_SHIFT		49
+#define UV_PAYLOADQ_GNODE_SHIFT		49
 #define UV_PTC_BASENAME			"sgi_uv/ptc_statistics"
 #define UV_BAU_BASENAME			"sgi_uv/bau_tunables"
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 8462fd1..f6bc43b 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1790,10 +1790,7 @@ static void pq_init(int node, int pnode)
 	size_t plsize;
 	char *cp;
 	void *vp;
-	unsigned long pn;
-	unsigned long first;
-	unsigned long pn_first;
-	unsigned long last;
+	unsigned long gnode, first, last, tail;
 	struct bau_pq_entry *pqp;
 	struct bau_control *bcp;
 
@@ -1814,16 +1811,16 @@ static void pq_init(int node, int pnode)
 		bcp->bau_msg_head	= pqp;
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
-	/*
-	 * need the gnode of where the memory was really allocated
-	 */
-	pn = uv_gpa_to_gnode(uv_gpa(pqp));
+
 	first = uv_physnodeaddr(pqp);
-	pn_first = ((unsigned long)pn << UV_PAYLOADQ_PNODE_SHIFT) | first;
 	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
-	write_mmr_payload_first(pnode, pn_first);
-	write_mmr_payload_tail(pnode, first);
+	tail = first;
+	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+
+	write_mmr_payload_first(pnode, first);
 	write_mmr_payload_last(pnode, last);
+	write_mmr_payload_tail(pnode, tail);
 	write_gmmr_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Convert uv_physnodeaddr() use to uv_gpa_to_offset()
  2016-09-21 16:09   ` [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
@ 2016-09-22 10:30     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, mingo, linux-kernel, torvalds, abanman, travis, tglx,
	sivanich, hpa

Commit-ID:  60e1c842c7ea3dd6a65660864554565cc737dd86
Gitweb:     http://git.kernel.org/tip/60e1c842c7ea3dd6a65660864554565cc737dd86
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:15 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:13 +0200

x86/platform/uv/BAU: Convert uv_physnodeaddr() use to uv_gpa_to_offset()

The BAU driver should use the functions provided by uv_hub.h rather than
its own implementations. uv_physnodeaddr converts vaddrs to paddrs for
BAU MMR fields, but this is done better by uv_gpa_to_offset.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-5-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/uv/uv_bau.h | 2 --
 arch/x86/platform/uv/tlb_uv.c    | 4 ++--
 2 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index cc058c6..a46f270 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -55,8 +55,6 @@
 #define UV_BAU_TUNABLES_DIR		"sgi_uv"
 #define UV_BAU_TUNABLES_FILE		"bau_tunables"
 #define WHITESPACE			" \t\n"
-#define uv_mmask			((1UL << uv_hub_info->m_val) - 1)
-#define uv_physnodeaddr(x)		((__pa((unsigned long)(x)) & uv_mmask))
 #define cpubit_isset(cpu, bau_local_cpumask) \
 	test_bit((cpu), (bau_local_cpumask).bits)
 
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index f6bc43b..34b2a48 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1812,8 +1812,8 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_physnodeaddr(pqp);
-	last = uv_physnodeaddr(pqp + (DEST_Q_SIZE - 1));
+	first = uv_gpa_to_offset(uv_gpa(pqp));
+	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Add generic function pointers
  2016-09-21 16:09   ` [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
@ 2016-09-22 10:30     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:30 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, tglx, torvalds, hpa, peterz, sivanich, travis, abanman,
	linux-kernel

Commit-ID:  5e4f96fe2a61c759d5d47f8112813618805c85a0
Gitweb:     http://git.kernel.org/tip/5e4f96fe2a61c759d5d47f8112813618805c85a0
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:16 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:13 +0200

x86/platform/uv/BAU: Add generic function pointers

Many BAU functions have different implementations depending on the UV
version. Rather than switching on the uvhub_version throughout the driver,
we can define a set of operations for each version. This is especially
beneficial for UV4, which will require many new MMR read/write functions.

Currently, the set of abstracted functions are the same for UV1, UV2, and
UV3. The functions were chosen because each one will have a different
implementation for UV4. Other functions will be added as needed to handle
new implementations or to cleanup the existing differences between UV1,
UV2, and UV3, i.e. read_status and wait_completion.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-6-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/uv/uv_bau.h | 11 +++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 19 +++++++++++++++++++
 2 files changed, 30 insertions(+)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a46f270..a7a93a5 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -385,6 +385,17 @@ struct uv2_3_bau_msg_header {
 	/* bits 127:120 */
 };
 
+/* Abstracted BAU functions */
+struct bau_operations {
+	unsigned long (*read_l_sw_ack)(void);
+	unsigned long (*read_g_sw_ack)(int pnode);
+	unsigned long (*bau_gpa_to_offset)(unsigned long vaddr);
+	void (*write_l_sw_ack)(unsigned long mmr);
+	void (*write_g_sw_ack)(int pnode, unsigned long mmr);
+	void (*write_payload_first)(int pnode, unsigned long mmr);
+	void (*write_payload_last)(int pnode, unsigned long mmr);
+};
+
 /*
  * The activation descriptor:
  * The format of the message to send, plus all accompanying control
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 34b2a48..a33a433 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -24,6 +24,18 @@
 #include <asm/irq_vectors.h>
 #include <asm/timer.h>
 
+static struct bau_operations ops;
+
+static struct bau_operations uv123_bau_ops = {
+	.bau_gpa_to_offset       = uv_gpa_to_offset,
+	.read_l_sw_ack           = read_mmr_sw_ack,
+	.read_g_sw_ack           = read_gmmr_sw_ack,
+	.write_l_sw_ack          = write_mmr_sw_ack,
+	.write_g_sw_ack          = write_gmmr_sw_ack,
+	.write_payload_first     = write_mmr_payload_first,
+	.write_payload_last      = write_mmr_payload_last,
+};
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2135,6 +2147,13 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
+	if (is_uv3_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv2_hub())
+		ops = uv123_bau_ops;
+	else if (is_uv1_hub())
+		ops = uv123_bau_ops;
+
 	for_each_possible_cpu(cur_cpu) {
 		mask = &per_cpu(uv_flush_tlb_mask, cur_cpu);
 		zalloc_cpumask_var_node(mask, GFP_KERNEL, cpu_to_node(cur_cpu));

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Use generic function pointers
  2016-09-21 16:09   ` [PATCH 06/10] arch/x86/platform/uv: BAU use " Andrew Banman
@ 2016-09-22 10:31     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: peterz, torvalds, abanman, mingo, sivanich, linux-kernel, hpa,
	travis, tglx

Commit-ID:  21e3f12fc0e12181102ad0400bcb50bc7a027106
Gitweb:     http://git.kernel.org/tip/21e3f12fc0e12181102ad0400bcb50bc7a027106
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:17 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:14 +0200

x86/platform/uv/BAU: Use generic function pointers

Convert the use of UV version-specific functions to their abstracted
counterparts.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-7-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 26 +++++++++++++-------------
 1 file changed, 13 insertions(+), 13 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index a33a433..030d452 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -228,7 +228,7 @@ static void reply_to_message(struct msg_desc *mdp, struct bau_control *bcp,
 	msg = mdp->msg;
 	if (!msg->canceled && do_acknowledge) {
 		dw = (msg->swack_vec << UV_SW_ACK_NPENDING) | msg->swack_vec;
-		write_mmr_sw_ack(dw);
+		ops.write_l_sw_ack(dw);
 	}
 	msg->replied_to = 1;
 	msg->swack_vec = 0;
@@ -264,7 +264,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 			msg->swack_vec) == 0) &&
 		    (msg2->sending_cpu == msg->sending_cpu) &&
 		    (msg2->msg_type != MSG_NOOP)) {
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg2->swack_vec;
 			/*
 			 * This is a message retry; clear the resources held
@@ -282,7 +282,7 @@ static void bau_process_retry_msg(struct msg_desc *mdp,
 				stat->d_canceled++;
 				cancel_count++;
 				mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -415,12 +415,12 @@ static void do_reset(void *ptr)
 			/*
 			 * only reset the resource if it is still pending
 			 */
-			mmr = read_mmr_sw_ack();
+			mmr = ops.read_l_sw_ack();
 			msg_res = msg->swack_vec;
 			mr = (msg_res << UV_SW_ACK_NPENDING) | msg_res;
 			if (mmr & msg_res) {
 				stat->d_rcanceled++;
-				write_mmr_sw_ack(mr);
+				ops.write_l_sw_ack(mr);
 			}
 		}
 	}
@@ -1214,7 +1214,7 @@ void process_uv2_message(struct msg_desc *mdp, struct bau_control *bcp)
 	struct bau_pq_entry *msg = mdp->msg;
 	struct bau_pq_entry *other_msg;
 
-	mmr_image = read_mmr_sw_ack();
+	mmr_image = ops.read_l_sw_ack();
 	swack_vec = msg->swack_vec;
 
 	if ((swack_vec & mmr_image) == 0) {
@@ -1443,7 +1443,7 @@ static int ptc_seq_show(struct seq_file *file, void *data)
 		/* destination side statistics */
 		seq_printf(file,
 			"%lx %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
-			   read_gmmr_sw_ack(uv_cpu_to_pnode(cpu)),
+			   ops.read_g_sw_ack(uv_cpu_to_pnode(cpu)),
 			   stat->d_requestee, cycles_2_us(stat->d_time),
 			   stat->d_alltlb, stat->d_onetlb, stat->d_multmsg,
 			   stat->d_nomsg, stat->d_retries, stat->d_canceled,
@@ -1737,7 +1737,7 @@ static void activation_descriptor_init(int node, int pnode, int base_pnode)
 
 	gpa = uv_gpa(bau_desc);
 	n = uv_gpa_to_gnode(gpa);
-	m = uv_gpa_to_offset(gpa);
+	m = ops.bau_gpa_to_offset(gpa);
 	if (is_uv1_hub())
 		uv1 = 1;
 
@@ -1824,16 +1824,16 @@ static void pq_init(int node, int pnode)
 		bcp->queue_last		= pqp + (DEST_Q_SIZE - 1);
 	}
 
-	first = uv_gpa_to_offset(uv_gpa(pqp));
-	last = uv_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
+	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
+	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
 	tail = first;
 	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
 	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_first(pnode, first);
-	write_mmr_payload_last(pnode, last);
 	write_mmr_payload_tail(pnode, tail);
-	write_gmmr_sw_ack(pnode, 0xffffUL);
+	ops.write_payload_first(pnode, first);
+	ops.write_payload_last(pnode, last);
+	ops.write_g_sw_ack(pnode, 0xffffUL);
 
 	/* in effect, all msg_type's are set to MSG_NOOP */
 	memset(pqp, 0, sizeof(struct bau_pq_entry) * DEST_Q_SIZE);

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Populate ->uvhub_version with UV4 version information
  2016-09-21 16:09   ` [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
@ 2016-09-22 10:31     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:31 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: mingo, sivanich, torvalds, linux-kernel, tglx, travis, peterz,
	abanman, hpa

Commit-ID:  58d4ab46f21e7e800a7597f271a23ec602796247
Gitweb:     http://git.kernel.org/tip/58d4ab46f21e7e800a7597f271a23ec602796247
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:18 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:14 +0200

x86/platform/uv/BAU: Populate ->uvhub_version with UV4 version information

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-8-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 030d452..ddbeb16 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2044,8 +2044,10 @@ static int scan_sock(struct socket_desc *sdp, struct uvhub_desc *bdp,
 			bcp->uvhub_version = 2;
 		else if (is_uv3_hub())
 			bcp->uvhub_version = 3;
+		else if (is_uv4_hub())
+			bcp->uvhub_version = 4;
 		else {
-			pr_emerg("uvhub version not 1, 2, or 3\n");
+			pr_emerg("uvhub version not 1, 2, 3, or 4\n");
 			return 1;
 		}
 		bcp->uvhub_master = *hmasterp;

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Disable software timeout on UV4 hardware
  2016-09-21 16:09   ` [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
@ 2016-09-22 10:32     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: torvalds, mingo, sivanich, tglx, linux-kernel, peterz, travis,
	hpa, abanman

Commit-ID:  e879c1124a6c5c3367f20a254909605e7ee938c1
Gitweb:     http://git.kernel.org/tip/e879c1124a6c5c3367f20a254909605e7ee938c1
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:19 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:14 +0200

x86/platform/uv/BAU: Disable software timeout on UV4 hardware

Software timeouts are not currently supported on BAU for UV4. Instead, the
BAU will rely on hardware-level fairness protocols to determine broadcast
timeouts.

Do not call enable_timeouts or calculate_destination_timeout on UV4. These
functions write to pre-UV4 MMRs so they generate error messages on UV4.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-9-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index ddbeb16..72a5de7 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -2109,7 +2109,8 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
 	void *vp;
 	struct uvhub_desc *uvhub_descs;
 
-	timeout_us = calculate_destination_timeout();
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		timeout_us = calculate_destination_timeout();
 
 	vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
 	uvhub_descs = (struct uvhub_desc *)vp;
@@ -2171,7 +2172,9 @@ static int __init uv_bau_init(void)
 			uv_base_pnode = uv_blade_to_pnode(uvhub);
 	}
 
-	enable_timeouts();
+	/* software timeouts are not supported on UV4 */
+	if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
+		enable_timeouts();
 
 	if (init_per_cpu(nuvhubs, uv_base_pnode)) {
 		set_bau_off();

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Fix payload queue setup on UV4 hardware
  2016-09-21 16:09   ` [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
@ 2016-09-22 10:32     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:32 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: linux-kernel, tglx, peterz, abanman, sivanich, hpa, mingo,
	travis, torvalds

Commit-ID:  6d78059bbc0ace5461938aaea8cda95eb6719898
Gitweb:     http://git.kernel.org/tip/6d78059bbc0ace5461938aaea8cda95eb6719898
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:20 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:15 +0200

x86/platform/uv/BAU: Fix payload queue setup on UV4 hardware

The BAU on UV4 does not need to maintain the payload queue tail pointer. Do
not initialize the tail pointer MMR on UV4.

Note that write_payload_tail is not an abstracted BAU function since it is
an operation specific to pre-UV4 versions. Then we must switch on the UV
version to control its usage, for which we use uvhub_version rather than
is_uv*_hub because it is quicker/more concise.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-10-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/platform/uv/tlb_uv.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 72a5de7..7ca0e5c 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -1826,11 +1826,19 @@ static void pq_init(int node, int pnode)
 
 	first = ops.bau_gpa_to_offset(uv_gpa(pqp));
 	last = ops.bau_gpa_to_offset(uv_gpa(pqp + (DEST_Q_SIZE - 1)));
-	tail = first;
-	gnode = uv_gpa_to_gnode(uv_gpa(pqp));
-	first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
 
-	write_mmr_payload_tail(pnode, tail);
+	/*
+	 * Pre UV4, the gnode is required to locate the payload queue
+	 * and the payload queue tail must be maintained by the kernel.
+	 */
+	bcp = &per_cpu(bau_control, smp_processor_id());
+	if (bcp->uvhub_version <= 3) {
+		tail = first;
+		gnode = uv_gpa_to_gnode(uv_gpa(pqp));
+		first = (gnode << UV_PAYLOADQ_GNODE_SHIFT) | tail;
+		write_mmr_payload_tail(pnode, tail);
+	}
+
 	ops.write_payload_first(pnode, first);
 	ops.write_payload_last(pnode, last);
 	ops.write_g_sw_ack(pnode, 0xffffUL);

^ permalink raw reply related	[flat|nested] 34+ messages in thread

* [tip:x86/platform] x86/platform/uv/BAU: Add UV4-specific functions
  2016-09-21 16:09   ` [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
@ 2016-09-22 10:33     ` tip-bot for Andrew Banman
  0 siblings, 0 replies; 34+ messages in thread
From: tip-bot for Andrew Banman @ 2016-09-22 10:33 UTC (permalink / raw)
  To: linux-tip-commits
  Cc: travis, tglx, hpa, abanman, linux-kernel, torvalds, peterz,
	sivanich, mingo

Commit-ID:  4f059d514f7119a4fdd9934189ff31f2c26b2647
Gitweb:     http://git.kernel.org/tip/4f059d514f7119a4fdd9934189ff31f2c26b2647
Author:     Andrew Banman <abanman@sgi.com>
AuthorDate: Wed, 21 Sep 2016 11:09:21 -0500
Committer:  Ingo Molnar <mingo@kernel.org>
CommitDate: Thu, 22 Sep 2016 11:16:15 +0200

x86/platform/uv/BAU: Add UV4-specific functions

Add the UV4-specific function definitions and define an operations struct
to implement them in the BAU driver.

Many BAU MMRs, although functionally the same, have new addresses on UV4
due to hardware changes. Each MMR requires new read/write functions, but
their implementation in the driver does not change. Thus, it is enough to
enumerate them in the operations struct for the changes to take effect.

Signed-off-by: Andrew Banman <abanman@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Acked-by: Mike Travis <travis@sgi.com>
Acked-by: Dimitri Sivanich <sivanich@sgi.com>
Acked-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: akpm@linux-foundation.org
Cc: rja@sgi.com
Link: http://lkml.kernel.org/r/1474474161-265604-11-git-send-email-abanman@sgi.com
Signed-off-by: Ingo Molnar <mingo@kernel.org>
---
 arch/x86/include/asm/uv/uv_bau.h | 30 ++++++++++++++++++++++++++++++
 arch/x86/platform/uv/tlb_uv.c    | 15 ++++++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/arch/x86/include/asm/uv/uv_bau.h b/arch/x86/include/asm/uv/uv_bau.h
index a7a93a5..57ab86d 100644
--- a/arch/x86/include/asm/uv/uv_bau.h
+++ b/arch/x86/include/asm/uv/uv_bau.h
@@ -664,6 +664,16 @@ static inline void write_gmmr_activation(int pnode, unsigned long mmr_image)
 	write_gmmr(pnode, UVH_LB_BAU_SB_ACTIVATION_CONTROL, mmr_image);
 }
 
+static inline void write_mmr_proc_payload_first(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_FIRST, mmr_image);
+}
+
+static inline void write_mmr_proc_payload_last(int pnode, unsigned long mmr_image)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_QUEUE_LAST, mmr_image);
+}
+
 static inline void write_mmr_payload_first(int pnode, unsigned long mmr_image)
 {
 	write_gmmr(pnode, UVH_LB_BAU_INTD_PAYLOAD_QUEUE_FIRST, mmr_image);
@@ -709,6 +719,26 @@ static inline unsigned long read_gmmr_sw_ack(int pnode)
 	return read_gmmr(pnode, UVH_LB_BAU_INTD_SOFTWARE_ACKNOWLEDGE);
 }
 
+static inline void write_mmr_proc_sw_ack(unsigned long mr)
+{
+	uv_write_local_mmr(UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline void write_gmmr_proc_sw_ack(int pnode, unsigned long mr)
+{
+	write_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_CLEAR, mr);
+}
+
+static inline unsigned long read_mmr_proc_sw_ack(void)
+{
+	return read_lmmr(UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
+static inline unsigned long read_gmmr_proc_sw_ack(int pnode)
+{
+	return read_gmmr(pnode, UV4H_LB_PROC_INTD_SOFT_ACK_PENDING);
+}
+
 static inline void write_mmr_data_config(int pnode, unsigned long mr)
 {
 	uv_write_global_mmr64(pnode, UVH_BAU_DATA_CONFIG, mr);
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c
index 7ca0e5c..56c5a3a 100644
--- a/arch/x86/platform/uv/tlb_uv.c
+++ b/arch/x86/platform/uv/tlb_uv.c
@@ -36,6 +36,17 @@ static struct bau_operations uv123_bau_ops = {
 	.write_payload_last      = write_mmr_payload_last,
 };
 
+static struct bau_operations uv4_bau_ops = {
+	.bau_gpa_to_offset       = uv_gpa_to_soc_phys_ram,
+	.read_l_sw_ack           = read_mmr_proc_sw_ack,
+	.read_g_sw_ack           = read_gmmr_proc_sw_ack,
+	.write_l_sw_ack          = write_mmr_proc_sw_ack,
+	.write_g_sw_ack          = write_gmmr_proc_sw_ack,
+	.write_payload_first     = write_mmr_proc_payload_first,
+	.write_payload_last      = write_mmr_proc_payload_last,
+};
+
+
 /* timeouts in nanoseconds (indexed by UVH_AGING_PRESCALE_SEL urgency7 30:28) */
 static int timeout_base_ns[] = {
 		20,
@@ -2158,7 +2169,9 @@ static int __init uv_bau_init(void)
 	if (!is_uv_system())
 		return 0;
 
-	if (is_uv3_hub())
+	if (is_uv4_hub())
+		ops = uv4_bau_ops;
+	else if (is_uv3_hub())
 		ops = uv123_bau_ops;
 	else if (is_uv2_hub())
 		ops = uv123_bau_ops;

^ permalink raw reply related	[flat|nested] 34+ messages in thread

end of thread, other threads:[~2016-09-22 10:33 UTC | newest]

Thread overview: 34+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-20 22:31 [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Andrew Banman
2016-09-20 22:31 ` [PATCH 1/9] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
2016-09-20 22:31 ` [PATCH 2/9] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
2016-09-20 22:31 ` [PATCH 3/9] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
2016-09-20 22:31 ` [PATCH 4/9] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
2016-09-20 22:31 ` [PATCH 5/9] arch/x86/platform/uv: BAU use " Andrew Banman
2016-09-20 22:31 ` [PATCH 6/9] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
2016-09-20 22:31 ` [PATCH 7/9] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
2016-09-20 22:31 ` [PATCH 8/9] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
2016-09-20 22:32 ` [PATCH 9/9] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
2016-09-21 12:55   ` Ingo Molnar
2016-09-21 15:53     ` andrew banman
2016-09-21 14:55 ` [PATCH 0/9] arch/x86/platform/uv: add UV4 support to BAU Thomas Gleixner
2016-09-21 16:09 ` [PATCHv2 0/10] " Andrew Banman
2016-09-21 16:09   ` [PATCH 01/10] arch/x86/platform/uv: BAU cleanup: vertical alignment Andrew Banman
2016-09-22 10:28     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up " tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 02/10] arch/x86/platform/uv: BAU cleanup: update printks Andrew Banman
2016-09-22 10:29     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up and " tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 03/10] arch/x86/platform/uv: BAU cleanup: pq_init Andrew Banman
2016-09-22 10:29     ` [tip:x86/platform] x86/platform/uv/BAU: Clean up pq_init() tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 04/10] arch/x86/platform/uv: BAU replace uv_physnodeaddr Andrew Banman
2016-09-22 10:30     ` [tip:x86/platform] x86/platform/uv/BAU: Convert uv_physnodeaddr() use to uv_gpa_to_offset() tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 05/10] arch/x86/platform/uv: BAU add generic function pointers Andrew Banman
2016-09-22 10:30     ` [tip:x86/platform] x86/platform/uv/BAU: Add " tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 06/10] arch/x86/platform/uv: BAU use " Andrew Banman
2016-09-22 10:31     ` [tip:x86/platform] x86/platform/uv/BAU: Use " tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 07/10] arch/x86/platform/uv: BAU UV4 populate uvhub_version Andrew Banman
2016-09-22 10:31     ` [tip:x86/platform] x86/platform/uv/BAU: Populate ->uvhub_version with UV4 version information tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 08/10] arch/x86/platform/uv: BAU UV4 disable software timeout Andrew Banman
2016-09-22 10:32     ` [tip:x86/platform] x86/platform/uv/BAU: Disable software timeout on UV4 hardware tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 09/10] arch/x86/platform/uv: BAU UV4 fix payload queue setup Andrew Banman
2016-09-22 10:32     ` [tip:x86/platform] x86/platform/uv/BAU: Fix payload queue setup on UV4 hardware tip-bot for Andrew Banman
2016-09-21 16:09   ` [PATCH 10/10] arch/x86/platform/uv: BAU UV4 add version-specific functions Andrew Banman
2016-09-22 10:33     ` [tip:x86/platform] x86/platform/uv/BAU: Add UV4-specific functions tip-bot for Andrew Banman

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).