diff options
author | Ingo Tuchscherer <ingo.tuchscherer@linux.vnet.ibm.com> | 2016-08-25 05:11:30 -0400 |
---|---|---|
committer | Martin Schwidefsky <schwidefsky@de.ibm.com> | 2016-12-14 10:33:37 -0500 |
commit | fc1d3f02544a6fd5f417921b57c663388586a17a (patch) | |
tree | c8992c82bcb429428eaaf6b2277d738029f5def2 | |
parent | b3e8652bcbfa04807e44708d4d0c8cdad39c9215 (diff) |
s390/zcrypt: Move the ap bus into kernel
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>
-rw-r--r-- | drivers/s390/crypto/Makefile | 10 | ||||
-rw-r--r-- | drivers/s390/crypto/ap_bus.c | 27 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_api.c | 7 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype50.c | 6 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype50.h | 2 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype6.c | 6 | ||||
-rw-r--r-- | drivers/s390/crypto/zcrypt_msgtype6.h | 2 |
7 files changed, 40 insertions, 20 deletions
diff --git a/drivers/s390/crypto/Makefile b/drivers/s390/crypto/Makefile index b8ab18676e69..d0549fc87247 100644 --- a/drivers/s390/crypto/Makefile +++ b/drivers/s390/crypto/Makefile | |||
@@ -3,9 +3,9 @@ | |||
3 | # | 3 | # |
4 | 4 | ||
5 | ap-objs := ap_bus.o | 5 | ap-objs := ap_bus.o |
6 | # zcrypt_api depends on ap | 6 | obj-$(subst m,y,$(CONFIG_ZCRYPT)) += ap.o |
7 | obj-$(CONFIG_ZCRYPT) += ap.o zcrypt_api.o | 7 | # zcrypt_api.o and zcrypt_msgtype*.o depend on ap.o |
8 | # msgtype* depend on zcrypt_api | 8 | zcrypt-objs := zcrypt_api.o zcrypt_msgtype6.o zcrypt_msgtype50.o |
9 | obj-$(CONFIG_ZCRYPT) += zcrypt_msgtype6.o zcrypt_msgtype50.o | 9 | obj-$(CONFIG_ZCRYPT) += zcrypt.o |
10 | # adapter drivers depend on ap, zcrypt_api and msgtype* | 10 | # adapter drivers depend on ap.o and zcrypt.o |
11 | obj-$(CONFIG_ZCRYPT) += zcrypt_pcixcc.o zcrypt_cex2a.o zcrypt_cex4.o | 11 | obj-$(CONFIG_ZCRYPT) += zcrypt_pcixcc.o zcrypt_cex2a.o zcrypt_cex4.o |
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c index cac919d63b43..c695219d70c4 100644 --- a/drivers/s390/crypto/ap_bus.c +++ b/drivers/s390/crypto/ap_bus.c | |||
@@ -62,6 +62,7 @@ MODULE_ALIAS_CRYPTO("z90crypt"); | |||
62 | * Module parameter | 62 | * Module parameter |
63 | */ | 63 | */ |
64 | int ap_domain_index = -1; /* Adjunct Processor Domain Index */ | 64 | int ap_domain_index = -1; /* Adjunct Processor Domain Index */ |
65 | static DEFINE_SPINLOCK(ap_domain_lock); | ||
65 | module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP); | 66 | module_param_named(domain, ap_domain_index, int, S_IRUSR|S_IRGRP); |
66 | MODULE_PARM_DESC(domain, "domain index for ap devices"); | 67 | MODULE_PARM_DESC(domain, "domain index for ap devices"); |
67 | EXPORT_SYMBOL(ap_domain_index); | 68 | EXPORT_SYMBOL(ap_domain_index); |
@@ -1481,7 +1482,21 @@ static ssize_t ap_domain_show(struct bus_type *bus, char *buf) | |||
1481 | return snprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index); | 1482 | return snprintf(buf, PAGE_SIZE, "%d\n", ap_domain_index); |
1482 | } | 1483 | } |
1483 | 1484 | ||
1484 | static BUS_ATTR(ap_domain, 0444, ap_domain_show, NULL); | 1485 | static ssize_t ap_domain_store(struct bus_type *bus, |
1486 | const char *buf, size_t count) | ||
1487 | { | ||
1488 | int domain; | ||
1489 | |||
1490 | if (sscanf(buf, "%i\n", &domain) != 1 || | ||
1491 | domain < 0 || domain > ap_max_domain_id) | ||
1492 | return -EINVAL; | ||
1493 | spin_lock_bh(&ap_domain_lock); | ||
1494 | ap_domain_index = domain; | ||
1495 | spin_unlock_bh(&ap_domain_lock); | ||
1496 | return count; | ||
1497 | } | ||
1498 | |||
1499 | static BUS_ATTR(ap_domain, 0644, ap_domain_show, ap_domain_store); | ||
1485 | 1500 | ||
1486 | static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf) | 1501 | static ssize_t ap_control_domain_mask_show(struct bus_type *bus, char *buf) |
1487 | { | 1502 | { |
@@ -1623,9 +1638,12 @@ static int ap_select_domain(void) | |||
1623 | * the "domain=" parameter or the domain with the maximum number | 1638 | * the "domain=" parameter or the domain with the maximum number |
1624 | * of devices. | 1639 | * of devices. |
1625 | */ | 1640 | */ |
1626 | if (ap_domain_index >= 0) | 1641 | spin_lock_bh(&ap_domain_lock); |
1642 | if (ap_domain_index >= 0) { | ||
1627 | /* Domain has already been selected. */ | 1643 | /* Domain has already been selected. */ |
1644 | spin_unlock_bh(&ap_domain_lock); | ||
1628 | return 0; | 1645 | return 0; |
1646 | } | ||
1629 | best_domain = -1; | 1647 | best_domain = -1; |
1630 | max_count = 0; | 1648 | max_count = 0; |
1631 | for (i = 0; i < AP_DOMAINS; i++) { | 1649 | for (i = 0; i < AP_DOMAINS; i++) { |
@@ -1647,8 +1665,10 @@ static int ap_select_domain(void) | |||
1647 | } | 1665 | } |
1648 | if (best_domain >= 0){ | 1666 | if (best_domain >= 0){ |
1649 | ap_domain_index = best_domain; | 1667 | ap_domain_index = best_domain; |
1668 | spin_unlock_bh(&ap_domain_lock); | ||
1650 | return 0; | 1669 | return 0; |
1651 | } | 1670 | } |
1671 | spin_unlock_bh(&ap_domain_lock); | ||
1652 | return -ENODEV; | 1672 | return -ENODEV; |
1653 | } | 1673 | } |
1654 | 1674 | ||
@@ -1677,6 +1697,8 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1677 | if (ap_select_domain() != 0) | 1697 | if (ap_select_domain() != 0) |
1678 | goto out; | 1698 | goto out; |
1679 | 1699 | ||
1700 | |||
1701 | spin_lock_bh(&ap_domain_lock); | ||
1680 | for (i = 0; i < AP_DEVICES; i++) { | 1702 | for (i = 0; i < AP_DEVICES; i++) { |
1681 | qid = AP_MKQID(i, ap_domain_index); | 1703 | qid = AP_MKQID(i, ap_domain_index); |
1682 | dev = bus_find_device(&ap_bus_type, NULL, | 1704 | dev = bus_find_device(&ap_bus_type, NULL, |
@@ -1753,6 +1775,7 @@ static void ap_scan_bus(struct work_struct *unused) | |||
1753 | continue; | 1775 | continue; |
1754 | } | 1776 | } |
1755 | } | 1777 | } |
1778 | spin_unlock_bh(&ap_domain_lock); | ||
1756 | out: | 1779 | out: |
1757 | mod_timer(&ap_config_timer, jiffies + ap_config_time * HZ); | 1780 | mod_timer(&ap_config_timer, jiffies + ap_config_time * HZ); |
1758 | } | 1781 | } |
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c index 5d3d04c040c2..7f61ae1b0b93 100644 --- a/drivers/s390/crypto/zcrypt_api.c +++ b/drivers/s390/crypto/zcrypt_api.c | |||
@@ -45,6 +45,7 @@ | |||
45 | #include "zcrypt_api.h" | 45 | #include "zcrypt_api.h" |
46 | 46 | ||
47 | #include "zcrypt_msgtype6.h" | 47 | #include "zcrypt_msgtype6.h" |
48 | #include "zcrypt_msgtype50.h" | ||
48 | 49 | ||
49 | /* | 50 | /* |
50 | * Module description. | 51 | * Module description. |
@@ -1459,6 +1460,8 @@ int __init zcrypt_api_init(void) | |||
1459 | goto out_misc; | 1460 | goto out_misc; |
1460 | } | 1461 | } |
1461 | 1462 | ||
1463 | zcrypt_msgtype6_init(); | ||
1464 | zcrypt_msgtype50_init(); | ||
1462 | return 0; | 1465 | return 0; |
1463 | 1466 | ||
1464 | out_misc: | 1467 | out_misc: |
@@ -1472,11 +1475,13 @@ out: | |||
1472 | * | 1475 | * |
1473 | * The module termination code. | 1476 | * The module termination code. |
1474 | */ | 1477 | */ |
1475 | void zcrypt_api_exit(void) | 1478 | void __exit zcrypt_api_exit(void) |
1476 | { | 1479 | { |
1477 | remove_proc_entry("driver/z90crypt", NULL); | 1480 | remove_proc_entry("driver/z90crypt", NULL); |
1478 | misc_deregister(&zcrypt_misc_device); | 1481 | misc_deregister(&zcrypt_misc_device); |
1479 | zcrypt_debug_exit(); | 1482 | zcrypt_debug_exit(); |
1483 | zcrypt_msgtype6_exit(); | ||
1484 | zcrypt_msgtype50_exit(); | ||
1480 | } | 1485 | } |
1481 | 1486 | ||
1482 | module_init(zcrypt_api_init); | 1487 | module_init(zcrypt_api_init); |
diff --git a/drivers/s390/crypto/zcrypt_msgtype50.c b/drivers/s390/crypto/zcrypt_msgtype50.c index eedfaa2cf715..7bafba83390a 100644 --- a/drivers/s390/crypto/zcrypt_msgtype50.c +++ b/drivers/s390/crypto/zcrypt_msgtype50.c | |||
@@ -518,16 +518,12 @@ static struct zcrypt_ops zcrypt_msgtype50_ops = { | |||
518 | .variant = MSGTYPE50_VARIANT_DEFAULT, | 518 | .variant = MSGTYPE50_VARIANT_DEFAULT, |
519 | }; | 519 | }; |
520 | 520 | ||
521 | int __init zcrypt_msgtype50_init(void) | 521 | void __init zcrypt_msgtype50_init(void) |
522 | { | 522 | { |
523 | zcrypt_msgtype_register(&zcrypt_msgtype50_ops); | 523 | zcrypt_msgtype_register(&zcrypt_msgtype50_ops); |
524 | return 0; | ||
525 | } | 524 | } |
526 | 525 | ||
527 | void __exit zcrypt_msgtype50_exit(void) | 526 | void __exit zcrypt_msgtype50_exit(void) |
528 | { | 527 | { |
529 | zcrypt_msgtype_unregister(&zcrypt_msgtype50_ops); | 528 | zcrypt_msgtype_unregister(&zcrypt_msgtype50_ops); |
530 | } | 529 | } |
531 | |||
532 | module_init(zcrypt_msgtype50_init); | ||
533 | module_exit(zcrypt_msgtype50_exit); | ||
diff --git a/drivers/s390/crypto/zcrypt_msgtype50.h b/drivers/s390/crypto/zcrypt_msgtype50.h index 0a66e4aeeb50..eeb41c0f34ae 100644 --- a/drivers/s390/crypto/zcrypt_msgtype50.h +++ b/drivers/s390/crypto/zcrypt_msgtype50.h | |||
@@ -35,7 +35,7 @@ | |||
35 | 35 | ||
36 | #define MSGTYPE_ADJUSTMENT 0x08 /*type04 extension (not needed in type50)*/ | 36 | #define MSGTYPE_ADJUSTMENT 0x08 /*type04 extension (not needed in type50)*/ |
37 | 37 | ||
38 | int zcrypt_msgtype50_init(void); | 38 | void zcrypt_msgtype50_init(void); |
39 | void zcrypt_msgtype50_exit(void); | 39 | void zcrypt_msgtype50_exit(void); |
40 | 40 | ||
41 | #endif /* _ZCRYPT_MSGTYPE50_H_ */ | 41 | #endif /* _ZCRYPT_MSGTYPE50_H_ */ |
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c index 21959719daef..f71949685ff5 100644 --- a/drivers/s390/crypto/zcrypt_msgtype6.c +++ b/drivers/s390/crypto/zcrypt_msgtype6.c | |||
@@ -1145,12 +1145,11 @@ static struct zcrypt_ops zcrypt_msgtype6_ep11_ops = { | |||
1145 | .send_ep11_cprb = zcrypt_msgtype6_send_ep11_cprb, | 1145 | .send_ep11_cprb = zcrypt_msgtype6_send_ep11_cprb, |
1146 | }; | 1146 | }; |
1147 | 1147 | ||
1148 | int __init zcrypt_msgtype6_init(void) | 1148 | void __init zcrypt_msgtype6_init(void) |
1149 | { | 1149 | { |
1150 | zcrypt_msgtype_register(&zcrypt_msgtype6_norng_ops); | 1150 | zcrypt_msgtype_register(&zcrypt_msgtype6_norng_ops); |
1151 | zcrypt_msgtype_register(&zcrypt_msgtype6_ops); | 1151 | zcrypt_msgtype_register(&zcrypt_msgtype6_ops); |
1152 | zcrypt_msgtype_register(&zcrypt_msgtype6_ep11_ops); | 1152 | zcrypt_msgtype_register(&zcrypt_msgtype6_ep11_ops); |
1153 | return 0; | ||
1154 | } | 1153 | } |
1155 | 1154 | ||
1156 | void __exit zcrypt_msgtype6_exit(void) | 1155 | void __exit zcrypt_msgtype6_exit(void) |
@@ -1159,6 +1158,3 @@ void __exit zcrypt_msgtype6_exit(void) | |||
1159 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ops); | 1158 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ops); |
1160 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ep11_ops); | 1159 | zcrypt_msgtype_unregister(&zcrypt_msgtype6_ep11_ops); |
1161 | } | 1160 | } |
1162 | |||
1163 | module_init(zcrypt_msgtype6_init); | ||
1164 | module_exit(zcrypt_msgtype6_exit); | ||
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.h b/drivers/s390/crypto/zcrypt_msgtype6.h index 207247570623..5750c4377bfa 100644 --- a/drivers/s390/crypto/zcrypt_msgtype6.h +++ b/drivers/s390/crypto/zcrypt_msgtype6.h | |||
@@ -165,7 +165,7 @@ static inline void rng_type6CPRB_msgX(struct ap_device *ap_dev, | |||
165 | ap_msg->length = sizeof(*msg); | 165 | ap_msg->length = sizeof(*msg); |
166 | } | 166 | } |
167 | 167 | ||
168 | int zcrypt_msgtype6_init(void); | 168 | void zcrypt_msgtype6_init(void); |
169 | void zcrypt_msgtype6_exit(void); | 169 | void zcrypt_msgtype6_exit(void); |
170 | 170 | ||
171 | #endif /* _ZCRYPT_MSGTYPE6_H_ */ | 171 | #endif /* _ZCRYPT_MSGTYPE6_H_ */ |