linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
To: Michael Ellerman <mpe@ellerman.id.au>
Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>,
	mikey@neuling.org, hbabu@us.ibm.com, nicholas.piggin@gmail.com,
	linuxppc-dev@ozlabs.org, <linux-kernel@vger.kernel.org>
Subject: [PATCH v3 10/18] powerpc/vas, nx-842: Define and use chip_to_vas_id()
Date: Tue,  7 Nov 2017 18:23:50 -0800	[thread overview]
Message-ID: <1510107838-15181-11-git-send-email-sukadev@linux.vnet.ibm.com> (raw)
In-Reply-To: <1510107838-15181-1-git-send-email-sukadev@linux.vnet.ibm.com>

Define a helper, chip_to_vas_id() to map a given chip id to corresponding
vas id.

Normally, callers of vas_rx_win_open() and vas_tx_win_open() want the VAS
window to be on the same chip where the calling thread is executing. These
callers can pass in -1 for the VAS id.

This interface will be useful if a thread running on one chip wants to open
a window on another chip (like the NX-842 driver does during start up).

Signed-off-by: Sukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
---
 arch/powerpc/include/asm/vas.h       |  9 +++++++++
 arch/powerpc/platforms/powernv/vas.c | 11 +++++++++++
 drivers/crypto/nx/nx-842-powernv.c   | 18 +++---------------
 3 files changed, 23 insertions(+), 15 deletions(-)

diff --git a/arch/powerpc/include/asm/vas.h b/arch/powerpc/include/asm/vas.h
index fd5963a..044748f 100644
--- a/arch/powerpc/include/asm/vas.h
+++ b/arch/powerpc/include/asm/vas.h
@@ -104,6 +104,15 @@ struct vas_tx_win_attr {
 };
 
 /*
+ * Helper to map a chip id to VAS id.
+ * For POWER9, this is a 1:1 mapping. In the future this maybe a 1:N
+ * mapping in which case, we will need to update this helper.
+ *
+ * Return the VAS id or -1 if no matching vasid is found.
+ */
+int chip_to_vas_id(int chipid);
+
+/*
  * Helper to initialize receive window attributes to defaults for an
  * NX window.
  */
diff --git a/arch/powerpc/platforms/powernv/vas.c b/arch/powerpc/platforms/powernv/vas.c
index abb7090..cd9a733 100644
--- a/arch/powerpc/platforms/powernv/vas.c
+++ b/arch/powerpc/platforms/powernv/vas.c
@@ -123,6 +123,17 @@ struct vas_instance *find_vas_instance(int vasid)
 	return NULL;
 }
 
+int chip_to_vas_id(int chipid)
+{
+	int cpu;
+
+	for_each_possible_cpu(cpu) {
+		if (cpu_to_chip_id(cpu) == chipid)
+			return per_cpu(cpu_vas_id, cpu);
+	}
+	return -1;
+}
+
 static int vas_probe(struct platform_device *pdev)
 {
 	return init_vas_instance(pdev);
diff --git a/drivers/crypto/nx/nx-842-powernv.c b/drivers/crypto/nx/nx-842-powernv.c
index 874ddf5..eb221ed 100644
--- a/drivers/crypto/nx/nx-842-powernv.c
+++ b/drivers/crypto/nx/nx-842-powernv.c
@@ -847,24 +847,12 @@ static int __init nx842_powernv_probe_vas(struct device_node *pn)
 		return -EINVAL;
 	}
 
-	for_each_compatible_node(dn, NULL, "ibm,power9-vas-x") {
-		if (of_get_ibm_chip_id(dn) == chip_id)
-			break;
-	}
-
-	if (!dn) {
-		pr_err("Missing VAS device node\n");
+	vasid = chip_to_vas_id(chip_id);
+	if (vasid < 0) {
+		pr_err("Unable to map chip_id %d to vasid\n", chip_id);
 		return -EINVAL;
 	}
 
-	if (of_property_read_u32(dn, "ibm,vas-id", &vasid)) {
-		pr_err("Missing ibm,vas-id device property\n");
-		of_node_put(dn);
-		return -EINVAL;
-	}
-
-	of_node_put(dn);
-
 	for_each_child_of_node(pn, dn) {
 		if (of_device_is_compatible(dn, "ibm,p9-nx-842")) {
 			ret = vas_cfg_coproc_info(dn, chip_id, vasid);
-- 
2.7.4

  parent reply	other threads:[~2017-11-08  2:24 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-11-08  2:23 [PATCH v3 00/18] powerpc/vas: Add support for FTW Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 01/18] powerpc/vas: init missing fields from [rt]xattr Sukadev Bhattiprolu
2017-11-14 11:12   ` [v3,01/18] " Michael Ellerman
2017-11-08  2:23 ` [PATCH v3 02/18] powerpc/vas: Validate window credits Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 03/18] powerpc/vas: Cleanup some debug code Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 04/18] powerpc/vas: Drop poll_window_cast_out() Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 05/18] powerpc/vas: Use helper to unpin/close window Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 06/18] powerpc/vas: Reduce polling interval for busy state Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 07/18] powerpc/vas: Save configured window credits Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 08/18] powerpc/vas: poll for return of " Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 09/18] powerpc/vas: Create cpu to vas id mapping Sukadev Bhattiprolu
2017-11-08  2:23 ` Sukadev Bhattiprolu [this message]
2017-11-20 17:57   ` [PATCH v3 10/18] powerpc/vas, nx-842: Define and use chip_to_vas_id() Josh Boyer
2017-11-22 11:56     ` Michael Ellerman
2017-11-08  2:23 ` [PATCH v3 11/18] powerpc/vas: Export HVWC to debugfs Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 12/18] powerpc: have copy depend on CONFIG_BOOK3S_64 Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 13/18] powerpc: Add support for setting SPRN_TIDR Sukadev Bhattiprolu
2017-11-09 11:53   ` Michael Ellerman
2017-11-08  2:23 ` [PATCH v3 14/18] powerpc: Define set_thread_uses_vas() Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 15/18] powerpc: Emulate paste instruction Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 16/18] powerpc/vas: Define vas_win_paste_addr() Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 17/18] powerpc/vas: Define vas_win_id() Sukadev Bhattiprolu
2017-11-08  2:23 ` [PATCH v3 18/18] powerpc/vas: Add support for user receive window Sukadev Bhattiprolu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1510107838-15181-11-git-send-email-sukadev@linux.vnet.ibm.com \
    --to=sukadev@linux.vnet.ibm.com \
    --cc=benh@kernel.crashing.org \
    --cc=hbabu@us.ibm.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linuxppc-dev@ozlabs.org \
    --cc=mikey@neuling.org \
    --cc=mpe@ellerman.id.au \
    --cc=nicholas.piggin@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).