]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
s390/zcrypt: Move the ap bus into kernel
authorIngo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com>
Thu, 25 Aug 2016 09:11:30 +0000 (11:11 +0200)
committerMartin Schwidefsky <schwidefsky@de.ibm.com>
Wed, 14 Dec 2016 15:33:37 +0000 (16:33 +0100)
Move the ap bus into the kernel and make it general available.
Additionally include the message types and the API layer as a
preparation for the workload management facility.

Signed-off-by: Ingo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com>
Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
drivers/s390/crypto/Makefile
drivers/s390/crypto/ap_bus.c
drivers/s390/crypto/zcrypt_api.c
drivers/s390/crypto/zcrypt_msgtype50.c
drivers/s390/crypto/zcrypt_msgtype50.h
drivers/s390/crypto/zcrypt_msgtype6.c
drivers/s390/crypto/zcrypt_msgtype6.h

index b8ab18676e69a39d2077fa3b5ff7c192ed3d3fe9..d0549fc8724786296874063b689db9dca5f7b3d0 100644 (file)
@@ -3,9 +3,9 @@
 #
 
 ap-objs := ap_bus.o
-# zcrypt_api depends on ap
-obj-$(CONFIG_ZCRYPT) += ap.o zcrypt_api.o
-# msgtype* depend on zcrypt_api
-obj-$(CONFIG_ZCRYPT) += zcrypt_msgtype6.o zcrypt_msgtype50.o
-# adapter drivers depend on ap, zcrypt_api and msgtype*
+obj-$(subst m,y,$(CONFIG_ZCRYPT)) += ap.o
+# zcrypt_api.o and zcrypt_msgtype*.o depend on ap.o
+zcrypt-objs := zcrypt_api.o zcrypt_msgtype6.o zcrypt_msgtype50.o
+obj-$(CONFIG_ZCRYPT) += zcrypt.o
+# adapter drivers depend on ap.o and zcrypt.o
 obj-$(CONFIG_ZCRYPT) += zcrypt_pcixcc.o zcrypt_cex2a.o zcrypt_cex4.o
index cac919d63b43e26cbbfed168ef97d88120f95bfe..c695219d70c4fd9f9aaaa450917bbab1bfa1ee94 100644 (file)
@@ -62,6 +62,7 @@ MODULE_ALIAS_CRYPTO("z90crypt");
  * Module parameter
  */
 int ap_domain_index = -1;      /* Adjunct Processor Domain Index */
+static DEFINE_SPINLOCK(ap_domain_lock);
 module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP);
 MODULE_PARM_DESC(domain, "domain index for ap devices");
 EXPORT_SYMBOL(ap_domain_index);
@@ -1481,7 +1482,21 @@ static ssize_t ap_domain_show(struct bus_type *bus, char *buf)
        return snprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index);
 }
 
-static BUS_ATTR(ap_domain, 0444, ap_domain_show, NULL);
+static ssize_t ap_domain_store(struct bus_type *bus,
+                              const char *buf, size_t count)
+{
+       int domain;
+
+       if (sscanf(buf, "%i\n", &domain) != 1 ||
+           domain < 0 || domain > ap_max_domain_id)
+               return -EINVAL;
+       spin_lock_bh(&ap_domain_lock);
+       ap_domain_index = domain;
+       spin_unlock_bh(&ap_domain_lock);
+       return count;
+}
+
+static BUS_ATTR(ap_domain, 0644, ap_domain_show, ap_domain_store);
 
 static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf)
 {
@@ -1623,9 +1638,12 @@ static int ap_select_domain(void)
         * the "domain=" parameter or the domain with the maximum number
         * of devices.
         */
-       if (ap_domain_index >= 0)
+       spin_lock_bh(&ap_domain_lock);
+       if (ap_domain_index >= 0) {
                /* Domain has already been selected. */
+               spin_unlock_bh(&ap_domain_lock);
                return 0;
+       }
        best_domain = -1;
        max_count = 0;
        for (i = 0; i < AP_DOMAINS; i++) {
@@ -1647,8 +1665,10 @@ static int ap_select_domain(void)
        }
        if (best_domain >= 0){
                ap_domain_index = best_domain;
+               spin_unlock_bh(&ap_domain_lock);
                return 0;
        }
+       spin_unlock_bh(&ap_domain_lock);
        return -ENODEV;
 }
 
@@ -1677,6 +1697,8 @@ static void ap_scan_bus(struct work_struct *unused)
        if (ap_select_domain() != 0)
                goto out;
 
+
+       spin_lock_bh(&ap_domain_lock);
        for (i = 0; i < AP_DEVICES; i++) {
                qid = AP_MKQID(i, ap_domain_index);
                dev = bus_find_device(&ap_bus_type, NULL,
@@ -1753,6 +1775,7 @@ static void ap_scan_bus(struct work_struct *unused)
                        continue;
                }
        }
+       spin_unlock_bh(&ap_domain_lock);
 out:
        mod_timer(&ap_config_timer, jiffies + ap_config_time * HZ);
 }
index 5d3d04c040c2be15af34d6977d17c658e35aaad5..7f61ae1b0b93f3fb8dcccfdcebefced337cd3156 100644 (file)
@@ -45,6 +45,7 @@
 #include "zcrypt_api.h"
 
 #include "zcrypt_msgtype6.h"
+#include "zcrypt_msgtype50.h"
 
 /*
  * Module description.
@@ -1459,6 +1460,8 @@ int __init zcrypt_api_init(void)
                goto out_misc;
        }
 
+       zcrypt_msgtype6_init();
+       zcrypt_msgtype50_init();
        return 0;
 
 out_misc:
@@ -1472,11 +1475,13 @@ int __init zcrypt_api_init(void)
  *
  * The module termination code.
  */
-void zcrypt_api_exit(void)
+void __exit zcrypt_api_exit(void)
 {
        remove_proc_entry("driver/z90crypt", NULL);
        misc_deregister(&zcrypt_misc_device);
        zcrypt_debug_exit();
+       zcrypt_msgtype6_exit();
+       zcrypt_msgtype50_exit();
 }
 
 module_init(zcrypt_api_init);
index eedfaa2cf715f698db447c1a79e857f170727dc5..7bafba83390aceedf42f033850dc80c4f2ce1c0c 100644 (file)
@@ -518,16 +518,12 @@ static struct zcrypt_ops zcrypt_msgtype50_ops = {
        .variant = MSGTYPE50_VARIANT_DEFAULT,
 };
 
-int __init zcrypt_msgtype50_init(void)
+void __init zcrypt_msgtype50_init(void)
 {
        zcrypt_msgtype_register(&zcrypt_msgtype50_ops);
-       return 0;
 }
 
 void __exit zcrypt_msgtype50_exit(void)
 {
        zcrypt_msgtype_unregister(&zcrypt_msgtype50_ops);
 }
-
-module_init(zcrypt_msgtype50_init);
-module_exit(zcrypt_msgtype50_exit);
index 0a66e4aeeb5047fb1c4cb3bfad63e665da8736f1..eeb41c0f34ae35b0d2b284b59d221600a7d91cdc 100644 (file)
@@ -35,7 +35,7 @@
 
 #define MSGTYPE_ADJUSTMENT             0x08  /*type04 extension (not needed in type50)*/
 
-int zcrypt_msgtype50_init(void);
+void zcrypt_msgtype50_init(void);
 void zcrypt_msgtype50_exit(void);
 
 #endif /* _ZCRYPT_MSGTYPE50_H_ */
index 21959719daef94a00bd3f40282a2022077ec1344..f71949685ff581c01e7135037c008620f9ea34e4 100644 (file)
@@ -1145,12 +1145,11 @@ static struct zcrypt_ops zcrypt_msgtype6_ep11_ops = {
        .send_ep11_cprb = zcrypt_msgtype6_send_ep11_cprb,
 };
 
-int __init zcrypt_msgtype6_init(void)
+void __init zcrypt_msgtype6_init(void)
 {
        zcrypt_msgtype_register(&zcrypt_msgtype6_norng_ops);
        zcrypt_msgtype_register(&zcrypt_msgtype6_ops);
        zcrypt_msgtype_register(&zcrypt_msgtype6_ep11_ops);
-       return 0;
 }
 
 void __exit zcrypt_msgtype6_exit(void)
@@ -1159,6 +1158,3 @@ void __exit zcrypt_msgtype6_exit(void)
        zcrypt_msgtype_unregister(&zcrypt_msgtype6_ops);
        zcrypt_msgtype_unregister(&zcrypt_msgtype6_ep11_ops);
 }
-
-module_init(zcrypt_msgtype6_init);
-module_exit(zcrypt_msgtype6_exit);
index 207247570623709c946f3a7708d3e3bfc7a0313e..5750c4377bfa1628f9d892ad2aa1d919735c5185 100644 (file)
@@ -165,7 +165,7 @@ static inline void rng_type6CPRB_msgX(struct ap_device *ap_dev,
        ap_msg->length = sizeof(*msg);
 }
 
-int zcrypt_msgtype6_init(void);
+void zcrypt_msgtype6_init(void);
 void zcrypt_msgtype6_exit(void);
 
 #endif /* _ZCRYPT_MSGTYPE6_H_ */