]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
powerpc/vas, nx-842: Define and use chip_to_vas_id()
authorSukadev Bhattiprolu <sukadev@linux.vnet.ibm.com>
Wed, 8 Nov 2017 02:23:50 +0000 (18:23 -0800)
committerMichael Ellerman <mpe@ellerman.id.au>
Sat, 11 Nov 2017 22:03:08 +0000 (09:03 +1100)
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>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
arch/powerpc/include/asm/vas.h
arch/powerpc/platforms/powernv/vas.c
drivers/crypto/nx/nx-842-powernv.c

index fd5963acd65824d2d6147a4816189637ccff9d73..044748f547f5920a222081f0dda0f6592d35f14b 100644 (file)
@@ -103,6 +103,15 @@ struct vas_tx_win_attr {
        bool rx_win_ord_mode;
 };
 
+/*
+ * 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.
index abb7090a22b4fb73c7ec4544f05b6070ca9875f2..cd9a733d05e233657d0efa8107ddc1a7649faf37 100644 (file)
@@ -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);
index 874ddf5e9087e5a0fc62e09bad3889f964c57d5f..eb221ed9bf0e09b8a80b36bf5144ddfb07fd1f99 100644 (file)
@@ -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);