aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHarald Freudenberger <freude@linux.vnet.ibm.com>2016-11-24 00:45:21 -0500
committerMartin Schwidefsky <schwidefsky@de.ibm.com>2016-12-14 10:33:39 -0500
commitcccd85bfb7bf6787302435c669ceec23b5a5301c (patch)
treec646f0474f1344372596c37adff268dbdb4f07c3
parentbf9f31190aa176c43c15cf58b60818d325e0f851 (diff)
s390/zcrypt: Rework debug feature invocations.
Rework the debug feature calls and initialization. There are now two debug feature entries used by the zcrypt code. The first is 'ap' with all the AP bus related stuff and the second is 'zcrypt' with all the zcrypt and devices and driver related entries. However, there isn't much traffic on both debug features. The ap bus code emits only some debug info and for zcrypt devices on appearance and disappearance there is an entry written. The new dbf invocations use the sprintf buffer layout, whereas the old implementation used the ascii dbf buffer. There are now 5*8=40 bytes used for each entry, resulting in 5 parameters per call. As the sprintf buffer needs a format string the first parameter provides this and so up to 4 more parameters can be used. Alltogehter the new layout should be much more human readable for customers and test. Signed-off-by: Harald Freudenberger <freude@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
-rw-r--r--drivers/s390/crypto/ap_bus.c40
-rw-r--r--drivers/s390/crypto/ap_debug.h28
-rw-r--r--drivers/s390/crypto/zcrypt_api.c38
-rw-r--r--drivers/s390/crypto/zcrypt_api.h8
-rw-r--r--drivers/s390/crypto/zcrypt_card.c10
-rw-r--r--drivers/s390/crypto/zcrypt_debug.h50
-rw-r--r--drivers/s390/crypto/zcrypt_error.h35
-rw-r--r--drivers/s390/crypto/zcrypt_msgtype50.c23
-rw-r--r--drivers/s390/crypto/zcrypt_msgtype6.c80
-rw-r--r--drivers/s390/crypto/zcrypt_queue.c21
10 files changed, 190 insertions, 143 deletions
diff --git a/drivers/s390/crypto/ap_bus.c b/drivers/s390/crypto/ap_bus.c
index 78c99ae42b1f..6d75984a3d85 100644
--- a/drivers/s390/crypto/ap_bus.c
+++ b/drivers/s390/crypto/ap_bus.c
@@ -47,9 +47,11 @@
47#include <asm/facility.h> 47#include <asm/facility.h>
48#include <linux/crypto.h> 48#include <linux/crypto.h>
49#include <linux/mod_devicetable.h> 49#include <linux/mod_devicetable.h>
50#include <linux/debugfs.h>
50 51
51#include "ap_bus.h" 52#include "ap_bus.h"
52#include "ap_asm.h" 53#include "ap_asm.h"
54#include "ap_debug.h"
53 55
54/* 56/*
55 * Module description. 57 * Module description.
@@ -82,6 +84,12 @@ static struct ap_config_info *ap_configuration;
82static bool initialised; 84static bool initialised;
83 85
84/* 86/*
87 * AP bus related debug feature things.
88 */
89static struct dentry *ap_dbf_root;
90debug_info_t *ap_dbf_info;
91
92/*
85 * Workqueue timer for bus rescan. 93 * Workqueue timer for bus rescan.
86 */ 94 */
87static struct timer_list ap_config_timer; 95static struct timer_list ap_config_timer;
@@ -568,6 +576,8 @@ static int ap_dev_resume(struct device *dev)
568 576
569static void ap_bus_suspend(void) 577static void ap_bus_suspend(void)
570{ 578{
579 AP_DBF(DBF_DEBUG, "ap_bus_suspend running\n");
580
571 ap_suspend_flag = 1; 581 ap_suspend_flag = 1;
572 /* 582 /*
573 * Disable scanning for devices, thus we do not want to scan 583 * Disable scanning for devices, thus we do not want to scan
@@ -603,6 +613,8 @@ static void ap_bus_resume(void)
603{ 613{
604 int rc; 614 int rc;
605 615
616 AP_DBF(DBF_DEBUG, "ap_bus_resume running\n");
617
606 /* remove all queue devices */ 618 /* remove all queue devices */
607 bus_for_each_dev(&ap_bus_type, NULL, NULL, 619 bus_for_each_dev(&ap_bus_type, NULL, NULL,
608 __ap_queue_devices_unregister); 620 __ap_queue_devices_unregister);
@@ -742,6 +754,9 @@ static ssize_t ap_domain_store(struct bus_type *bus,
742 spin_lock_bh(&ap_domain_lock); 754 spin_lock_bh(&ap_domain_lock);
743 ap_domain_index = domain; 755 ap_domain_index = domain;
744 spin_unlock_bh(&ap_domain_lock); 756 spin_unlock_bh(&ap_domain_lock);
757
758 AP_DBF(DBF_DEBUG, "store new default domain=%d\n", domain);
759
745 return count; 760 return count;
746} 761}
747 762
@@ -964,6 +979,8 @@ static void ap_scan_bus(struct work_struct *unused)
964 unsigned int functions = 0; 979 unsigned int functions = 0;
965 int rc, id, dom, borked, domains; 980 int rc, id, dom, borked, domains;
966 981
982 AP_DBF(DBF_DEBUG, "ap_scan_bus running\n");
983
967 ap_query_configuration(); 984 ap_query_configuration();
968 if (ap_select_domain() != 0) 985 if (ap_select_domain() != 0)
969 goto out; 986 goto out;
@@ -1129,6 +1146,23 @@ static struct reset_call ap_reset_call = {
1129 .fn = ap_reset_all, 1146 .fn = ap_reset_all,
1130}; 1147};
1131 1148
1149int __init ap_debug_init(void)
1150{
1151 ap_dbf_root = debugfs_create_dir("ap", NULL);
1152 ap_dbf_info = debug_register("ap", 1, 1,
1153 DBF_MAX_SPRINTF_ARGS * sizeof(long));
1154 debug_register_view(ap_dbf_info, &debug_sprintf_view);
1155 debug_set_level(ap_dbf_info, DBF_ERR);
1156
1157 return 0;
1158}
1159
1160void ap_debug_exit(void)
1161{
1162 debugfs_remove(ap_dbf_root);
1163 debug_unregister(ap_dbf_info);
1164}
1165
1132/** 1166/**
1133 * ap_module_init(): The module initialization code. 1167 * ap_module_init(): The module initialization code.
1134 * 1168 *
@@ -1139,6 +1173,10 @@ int __init ap_module_init(void)
1139 int max_domain_id; 1173 int max_domain_id;
1140 int rc, i; 1174 int rc, i;
1141 1175
1176 rc = ap_debug_init();
1177 if (rc)
1178 return rc;
1179
1142 if (ap_instructions_available() != 0) { 1180 if (ap_instructions_available() != 0) {
1143 pr_warn("The hardware system does not support AP instructions\n"); 1181 pr_warn("The hardware system does not support AP instructions\n");
1144 return -ENODEV; 1182 return -ENODEV;
@@ -1266,6 +1304,8 @@ void ap_module_exit(void)
1266 unregister_reset_call(&ap_reset_call); 1304 unregister_reset_call(&ap_reset_call);
1267 if (ap_using_interrupts()) 1305 if (ap_using_interrupts())
1268 unregister_adapter_interrupt(&ap_airq); 1306 unregister_adapter_interrupt(&ap_airq);
1307
1308 ap_debug_exit();
1269} 1309}
1270 1310
1271module_init(ap_module_init); 1311module_init(ap_module_init);
diff --git a/drivers/s390/crypto/ap_debug.h b/drivers/s390/crypto/ap_debug.h
new file mode 100644
index 000000000000..78dbff842dae
--- /dev/null
+++ b/drivers/s390/crypto/ap_debug.h
@@ -0,0 +1,28 @@
1/*
2 * Copyright IBM Corp. 2016
3 * Author(s): Harald Freudenberger <freude@de.ibm.com>
4 */
5#ifndef AP_DEBUG_H
6#define AP_DEBUG_H
7
8#include <asm/debug.h>
9
10#define DBF_ERR 3 /* error conditions */
11#define DBF_WARN 4 /* warning conditions */
12#define DBF_INFO 5 /* informational */
13#define DBF_DEBUG 6 /* for debugging only */
14
15#define RC2ERR(rc) ((rc) ? DBF_ERR : DBF_INFO)
16#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
17
18#define DBF_MAX_SPRINTF_ARGS 5
19
20#define AP_DBF(...) \
21 debug_sprintf_event(ap_dbf_info, ##__VA_ARGS__)
22
23extern debug_info_t *ap_dbf_info;
24
25int ap_debug_init(void);
26void ap_debug_exit(void);
27
28#endif /* AP_DEBUG_H */
diff --git a/drivers/s390/crypto/zcrypt_api.c b/drivers/s390/crypto/zcrypt_api.c
index 71e298fe339f..7ca25e77bd6a 100644
--- a/drivers/s390/crypto/zcrypt_api.c
+++ b/drivers/s390/crypto/zcrypt_api.c
@@ -41,8 +41,8 @@
41#include <linux/debugfs.h> 41#include <linux/debugfs.h>
42#include <asm/debug.h> 42#include <asm/debug.h>
43 43
44#include "zcrypt_debug.h"
45#include "zcrypt_api.h" 44#include "zcrypt_api.h"
45#include "zcrypt_debug.h"
46 46
47#include "zcrypt_msgtype6.h" 47#include "zcrypt_msgtype6.h"
48#include "zcrypt_msgtype50.h" 48#include "zcrypt_msgtype50.h"
@@ -71,10 +71,9 @@ EXPORT_SYMBOL(zcrypt_rescan_req);
71 71
72static LIST_HEAD(zcrypt_ops_list); 72static LIST_HEAD(zcrypt_ops_list);
73 73
74static struct dentry *debugfs_root; 74/* Zcrypt related debug feature stuff. */
75debug_info_t *zcrypt_dbf_common; 75static struct dentry *zcrypt_dbf_root;
76debug_info_t *zcrypt_dbf_devices; 76debug_info_t *zcrypt_dbf_info;
77debug_info_t *zcrypt_dbf_cards;
78 77
79/** 78/**
80 * Process a rescan of the transport layer. 79 * Process a rescan of the transport layer.
@@ -87,8 +86,8 @@ static inline int zcrypt_process_rescan(void)
87 atomic_set(&zcrypt_rescan_req, 0); 86 atomic_set(&zcrypt_rescan_req, 0);
88 atomic_inc(&zcrypt_rescan_count); 87 atomic_inc(&zcrypt_rescan_count);
89 ap_bus_force_rescan(); 88 ap_bus_force_rescan();
90 ZCRYPT_DBF_COMMON(DBF_INFO, "rescan%07d", 89 ZCRYPT_DBF(DBF_INFO, "rescan count=%07d",
91 atomic_inc_return(&zcrypt_rescan_count)); 90 atomic_inc_return(&zcrypt_rescan_count));
92 return 1; 91 return 1;
93 } 92 }
94 return 0; 93 return 0;
@@ -1363,28 +1362,19 @@ void zcrypt_rng_device_remove(void)
1363 1362
1364int __init zcrypt_debug_init(void) 1363int __init zcrypt_debug_init(void)
1365{ 1364{
1366 debugfs_root = debugfs_create_dir("zcrypt", NULL); 1365 zcrypt_dbf_root = debugfs_create_dir("zcrypt", NULL);
1367 1366 zcrypt_dbf_info = debug_register("zcrypt", 1, 1,
1368 zcrypt_dbf_common = debug_register("zcrypt_common", 1, 1, 16); 1367 DBF_MAX_SPRINTF_ARGS * sizeof(long));
1369 debug_register_view(zcrypt_dbf_common, &debug_hex_ascii_view); 1368 debug_register_view(zcrypt_dbf_info, &debug_sprintf_view);
1370 debug_set_level(zcrypt_dbf_common, DBF_ERR); 1369 debug_set_level(zcrypt_dbf_info, DBF_ERR);
1371
1372 zcrypt_dbf_devices = debug_register("zcrypt_devices", 1, 1, 16);
1373 debug_register_view(zcrypt_dbf_devices, &debug_hex_ascii_view);
1374 debug_set_level(zcrypt_dbf_devices, DBF_ERR);
1375
1376 zcrypt_dbf_cards = debug_register("zcrypt_cards", 1, 1, 16);
1377 debug_register_view(zcrypt_dbf_cards, &debug_hex_ascii_view);
1378 debug_set_level(zcrypt_dbf_cards, DBF_ERR);
1379 1370
1380 return 0; 1371 return 0;
1381} 1372}
1382 1373
1383void zcrypt_debug_exit(void) 1374void zcrypt_debug_exit(void)
1384{ 1375{
1385 debugfs_remove(debugfs_root); 1376 debugfs_remove(zcrypt_dbf_root);
1386 debug_unregister(zcrypt_dbf_common); 1377 debug_unregister(zcrypt_dbf_info);
1387 debug_unregister(zcrypt_dbf_devices);
1388} 1378}
1389 1379
1390/** 1380/**
@@ -1434,9 +1424,9 @@ void __exit zcrypt_api_exit(void)
1434{ 1424{
1435 remove_proc_entry("driver/z90crypt", NULL); 1425 remove_proc_entry("driver/z90crypt", NULL);
1436 misc_deregister(&zcrypt_misc_device); 1426 misc_deregister(&zcrypt_misc_device);
1437 zcrypt_debug_exit();
1438 zcrypt_msgtype6_exit(); 1427 zcrypt_msgtype6_exit();
1439 zcrypt_msgtype50_exit(); 1428 zcrypt_msgtype50_exit();
1429 zcrypt_debug_exit();
1440} 1430}
1441 1431
1442module_init(zcrypt_api_init); 1432module_init(zcrypt_api_init);
diff --git a/drivers/s390/crypto/zcrypt_api.h b/drivers/s390/crypto/zcrypt_api.h
index 4fb892b99f41..274a59051534 100644
--- a/drivers/s390/crypto/zcrypt_api.h
+++ b/drivers/s390/crypto/zcrypt_api.h
@@ -132,8 +132,6 @@ struct zcrypt_card {
132 atomic_t load; /* Utilization of the crypto device */ 132 atomic_t load; /* Utilization of the crypto device */
133 133
134 int request_count; /* # current requests. */ 134 int request_count; /* # current requests. */
135
136 debug_info_t *dbf_area; /* debugging */
137}; 135};
138 136
139struct zcrypt_queue { 137struct zcrypt_queue {
@@ -149,8 +147,6 @@ struct zcrypt_queue {
149 int request_count; /* # current requests. */ 147 int request_count; /* # current requests. */
150 148
151 struct ap_message reply; /* Per-device reply structure. */ 149 struct ap_message reply; /* Per-device reply structure. */
152
153 debug_info_t *dbf_area; /* debugging */
154}; 150};
155 151
156/* transport layer rescanning */ 152/* transport layer rescanning */
@@ -160,10 +156,6 @@ extern spinlock_t zcrypt_list_lock;
160extern int zcrypt_device_count; 156extern int zcrypt_device_count;
161extern struct list_head zcrypt_card_list; 157extern struct list_head zcrypt_card_list;
162 158
163extern debug_info_t *zcrypt_dbf_common;
164extern debug_info_t *zcrypt_dbf_devices;
165extern debug_info_t *zcrypt_dbf_cards;
166
167#define for_each_zcrypt_card(_zc) \ 159#define for_each_zcrypt_card(_zc) \
168 list_for_each_entry(_zc, &zcrypt_card_list, list) 160 list_for_each_entry(_zc, &zcrypt_card_list, list)
169 161
diff --git a/drivers/s390/crypto/zcrypt_card.c b/drivers/s390/crypto/zcrypt_card.c
index 57873d775e95..53436ea52230 100644
--- a/drivers/s390/crypto/zcrypt_card.c
+++ b/drivers/s390/crypto/zcrypt_card.c
@@ -79,7 +79,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev,
79 79
80 zc->online = online; 80 zc->online = online;
81 id = zc->card->id; 81 id = zc->card->id;
82 ZCRYPT_DBF_DEV(DBF_INFO, zc, "card%02xo%dman", id, online); 82
83 ZCRYPT_DBF(DBF_INFO, "card=%02x online=%d\n", id, online);
84
83 spin_lock(&zcrypt_list_lock); 85 spin_lock(&zcrypt_list_lock);
84 list_for_each_entry(zq, &zc->zqueues, list) 86 list_for_each_entry(zq, &zc->zqueues, list)
85 zcrypt_queue_force_online(zq, online); 87 zcrypt_queue_force_online(zq, online);
@@ -109,7 +111,6 @@ struct zcrypt_card *zcrypt_card_alloc(void)
109 return NULL; 111 return NULL;
110 INIT_LIST_HEAD(&zc->list); 112 INIT_LIST_HEAD(&zc->list);
111 INIT_LIST_HEAD(&zc->zqueues); 113 INIT_LIST_HEAD(&zc->zqueues);
112 zc->dbf_area = zcrypt_dbf_cards;
113 kref_init(&zc->refcount); 114 kref_init(&zc->refcount);
114 return zc; 115 return zc;
115} 116}
@@ -160,6 +161,9 @@ int zcrypt_card_register(struct zcrypt_card *zc)
160 spin_unlock(&zcrypt_list_lock); 161 spin_unlock(&zcrypt_list_lock);
161 162
162 zc->online = 1; 163 zc->online = 1;
164
165 ZCRYPT_DBF(DBF_INFO, "card=%02x register online=1\n", zc->card->id);
166
163 return rc; 167 return rc;
164} 168}
165EXPORT_SYMBOL(zcrypt_card_register); 169EXPORT_SYMBOL(zcrypt_card_register);
@@ -172,6 +176,8 @@ EXPORT_SYMBOL(zcrypt_card_register);
172 */ 176 */
173void zcrypt_card_unregister(struct zcrypt_card *zc) 177void zcrypt_card_unregister(struct zcrypt_card *zc)
174{ 178{
179 ZCRYPT_DBF(DBF_INFO, "card=%02x unregister\n", zc->card->id);
180
175 spin_lock(&zcrypt_list_lock); 181 spin_lock(&zcrypt_list_lock);
176 list_del_init(&zc->list); 182 list_del_init(&zc->list);
177 spin_unlock(&zcrypt_list_lock); 183 spin_unlock(&zcrypt_list_lock);
diff --git a/drivers/s390/crypto/zcrypt_debug.h b/drivers/s390/crypto/zcrypt_debug.h
index 28d9349de1ad..13e38defb6b8 100644
--- a/drivers/s390/crypto/zcrypt_debug.h
+++ b/drivers/s390/crypto/zcrypt_debug.h
@@ -1,51 +1,27 @@
1/* 1/*
2 * Copyright IBM Corp. 2012 2 * Copyright IBM Corp. 2016
3 * Author(s): Holger Dengler (hd@linux.vnet.ibm.com) 3 * Author(s): Holger Dengler (hd@linux.vnet.ibm.com)
4 * Harald Freudenberger <freude@de.ibm.com>
4 */ 5 */
5#ifndef ZCRYPT_DEBUG_H 6#ifndef ZCRYPT_DEBUG_H
6#define ZCRYPT_DEBUG_H 7#define ZCRYPT_DEBUG_H
7 8
8#include <asm/debug.h> 9#include <asm/debug.h>
9#include "zcrypt_api.h"
10 10
11/* that gives us 15 characters in the text event views */ 11#define DBF_ERR 3 /* error conditions */
12#define ZCRYPT_DBF_LEN 16 12#define DBF_WARN 4 /* warning conditions */
13 13#define DBF_INFO 5 /* informational */
14#define DBF_ERR 3 /* error conditions */ 14#define DBF_DEBUG 6 /* for debugging only */
15#define DBF_WARN 4 /* warning conditions */
16#define DBF_INFO 6 /* informational */
17 15
16#define RC2ERR(rc) ((rc) ? DBF_ERR : DBF_INFO)
18#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO) 17#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
19 18
20#define ZCRYPT_DBF_COMMON(level, text...) \ 19#define DBF_MAX_SPRINTF_ARGS 5
21 do { \ 20
22 if (debug_level_enabled(zcrypt_dbf_common, level)) { \ 21#define ZCRYPT_DBF(...) \
23 char debug_buffer[ZCRYPT_DBF_LEN]; \ 22 debug_sprintf_event(zcrypt_dbf_info, ##__VA_ARGS__)
24 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \ 23
25 debug_text_event(zcrypt_dbf_common, level, \ 24extern debug_info_t *zcrypt_dbf_info;
26 debug_buffer); \
27 } \
28 } while (0)
29
30#define ZCRYPT_DBF_DEVICES(level, text...) \
31 do { \
32 if (debug_level_enabled(zcrypt_dbf_devices, level)) { \
33 char debug_buffer[ZCRYPT_DBF_LEN]; \
34 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
35 debug_text_event(zcrypt_dbf_devices, level, \
36 debug_buffer); \
37 } \
38 } while (0)
39
40#define ZCRYPT_DBF_DEV(level, device, text...) \
41 do { \
42 if (debug_level_enabled(device->dbf_area, level)) { \
43 char debug_buffer[ZCRYPT_DBF_LEN]; \
44 snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
45 debug_text_event(device->dbf_area, level, \
46 debug_buffer); \
47 } \
48 } while (0)
49 25
50int zcrypt_debug_init(void); 26int zcrypt_debug_init(void);
51void zcrypt_debug_exit(void); 27void zcrypt_debug_exit(void);
diff --git a/drivers/s390/crypto/zcrypt_error.h b/drivers/s390/crypto/zcrypt_error.h
index 865978879661..13df60209ed3 100644
--- a/drivers/s390/crypto/zcrypt_error.h
+++ b/drivers/s390/crypto/zcrypt_error.h
@@ -93,6 +93,8 @@ static inline int convert_error(struct zcrypt_queue *zq,
93 struct ap_message *reply) 93 struct ap_message *reply)
94{ 94{
95 struct error_hdr *ehdr = reply->message; 95 struct error_hdr *ehdr = reply->message;
96 int card = AP_QID_CARD(zq->queue->qid);
97 int queue = AP_QID_QUEUE(zq->queue->qid);
96 98
97 switch (ehdr->reply_code) { 99 switch (ehdr->reply_code) {
98 case REP82_ERROR_OPERAND_INVALID: 100 case REP82_ERROR_OPERAND_INVALID:
@@ -105,6 +107,9 @@ static inline int convert_error(struct zcrypt_queue *zq,
105 // REP88_ERROR_OPERAND // '84' CEX2A 107 // REP88_ERROR_OPERAND // '84' CEX2A
106 // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A 108 // REP88_ERROR_OPERAND_EVEN_MOD // '85' CEX2A
107 /* Invalid input data. */ 109 /* Invalid input data. */
110 ZCRYPT_DBF(DBF_WARN,
111 "device=%02x.%04x reply=0x%02x => rc=EINVAL\n",
112 card, queue, ehdr->reply_code);
108 return -EINVAL; 113 return -EINVAL;
109 case REP82_ERROR_MESSAGE_TYPE: 114 case REP82_ERROR_MESSAGE_TYPE:
110 // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A 115 // REP88_ERROR_MESSAGE_TYPE // '20' CEX2A
@@ -116,12 +121,10 @@ static inline int convert_error(struct zcrypt_queue *zq,
116 atomic_set(&zcrypt_rescan_req, 1); 121 atomic_set(&zcrypt_rescan_req, 1);
117 zq->online = 0; 122 zq->online = 0;
118 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 123 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
119 AP_QID_CARD(zq->queue->qid), 124 card, queue);
120 AP_QID_QUEUE(zq->queue->qid)); 125 ZCRYPT_DBF(DBF_ERR,
121 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", 126 "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
122 AP_QID_CARD(zq->queue->qid), 127 card, queue, ehdr->reply_code);
123 AP_QID_QUEUE(zq->queue->qid), zq->online,
124 ehdr->reply_code);
125 return -EAGAIN; 128 return -EAGAIN;
126 case REP82_ERROR_TRANSPORT_FAIL: 129 case REP82_ERROR_TRANSPORT_FAIL:
127 case REP82_ERROR_MACHINE_FAILURE: 130 case REP82_ERROR_MACHINE_FAILURE:
@@ -130,22 +133,18 @@ static inline int convert_error(struct zcrypt_queue *zq,
130 atomic_set(&zcrypt_rescan_req, 1); 133 atomic_set(&zcrypt_rescan_req, 1);
131 zq->online = 0; 134 zq->online = 0;
132 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 135 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
133 AP_QID_CARD(zq->queue->qid), 136 card, queue);
134 AP_QID_QUEUE(zq->queue->qid)); 137 ZCRYPT_DBF(DBF_ERR,
135 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", 138 "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
136 AP_QID_CARD(zq->queue->qid), 139 card, queue, ehdr->reply_code);
137 AP_QID_QUEUE(zq->queue->qid), zq->online,
138 ehdr->reply_code);
139 return -EAGAIN; 140 return -EAGAIN;
140 default: 141 default:
141 zq->online = 0; 142 zq->online = 0;
142 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 143 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
143 AP_QID_CARD(zq->queue->qid), 144 card, queue);
144 AP_QID_QUEUE(zq->queue->qid)); 145 ZCRYPT_DBF(DBF_ERR,
145 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", 146 "device=%02x.%04x reply=0x%02x => online=0 rc=EAGAIN\n",
146 AP_QID_CARD(zq->queue->qid), 147 card, queue, ehdr->reply_code);
147 AP_QID_QUEUE(zq->queue->qid), zq->online,
148 ehdr->reply_code);
149 return -EAGAIN; /* repeat the request on a different device. */ 148 return -EAGAIN; /* repeat the request on a different device. */
150 } 149 }
151} 150}
diff --git a/drivers/s390/crypto/zcrypt_msgtype50.c b/drivers/s390/crypto/zcrypt_msgtype50.c
index a9873b436115..6dd5d7c58dd0 100644
--- a/drivers/s390/crypto/zcrypt_msgtype50.c
+++ b/drivers/s390/crypto/zcrypt_msgtype50.c
@@ -367,11 +367,11 @@ static int convert_type80(struct zcrypt_queue *zq,
367 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 367 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
368 AP_QID_CARD(zq->queue->qid), 368 AP_QID_CARD(zq->queue->qid),
369 AP_QID_QUEUE(zq->queue->qid)); 369 AP_QID_QUEUE(zq->queue->qid));
370 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", 370 ZCRYPT_DBF(DBF_ERR,
371 AP_QID_CARD(zq->queue->qid), 371 "device=%02x.%04x code=0x%02x => online=0 rc=EAGAIN\n",
372 AP_QID_QUEUE(zq->queue->qid), 372 AP_QID_CARD(zq->queue->qid),
373 zq->online, t80h->code); 373 AP_QID_QUEUE(zq->queue->qid),
374 374 t80h->code);
375 return -EAGAIN; /* repeat the request on a different device. */ 375 return -EAGAIN; /* repeat the request on a different device. */
376 } 376 }
377 if (zq->zcard->user_space_type == ZCRYPT_CEX2A) 377 if (zq->zcard->user_space_type == ZCRYPT_CEX2A)
@@ -390,7 +390,9 @@ static int convert_response(struct zcrypt_queue *zq,
390 unsigned int outputdatalength) 390 unsigned int outputdatalength)
391{ 391{
392 /* Response type byte is the second byte in the response. */ 392 /* Response type byte is the second byte in the response. */
393 switch (((unsigned char *) reply->message)[1]) { 393 unsigned char rtype = ((unsigned char *) reply->message)[1];
394
395 switch (rtype) {
394 case TYPE82_RSP_CODE: 396 case TYPE82_RSP_CODE:
395 case TYPE88_RSP_CODE: 397 case TYPE88_RSP_CODE:
396 return convert_error(zq, reply); 398 return convert_error(zq, reply);
@@ -402,10 +404,11 @@ static int convert_response(struct zcrypt_queue *zq,
402 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 404 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
403 AP_QID_CARD(zq->queue->qid), 405 AP_QID_CARD(zq->queue->qid),
404 AP_QID_QUEUE(zq->queue->qid)); 406 AP_QID_QUEUE(zq->queue->qid));
405 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", 407 ZCRYPT_DBF(DBF_ERR,
406 AP_QID_CARD(zq->queue->qid), 408 "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
407 AP_QID_QUEUE(zq->queue->qid), 409 AP_QID_CARD(zq->queue->qid),
408 zq->online); 410 AP_QID_QUEUE(zq->queue->qid),
411 (unsigned int) rtype);
409 return -EAGAIN; /* repeat the request on a different device. */ 412 return -EAGAIN; /* repeat the request on a different device. */
410 } 413 }
411} 414}
diff --git a/drivers/s390/crypto/zcrypt_msgtype6.c b/drivers/s390/crypto/zcrypt_msgtype6.c
index c6cfb9acec19..e5563ffeb839 100644
--- a/drivers/s390/crypto/zcrypt_msgtype6.c
+++ b/drivers/s390/crypto/zcrypt_msgtype6.c
@@ -638,30 +638,37 @@ static int convert_type86_ica(struct zcrypt_queue *zq,
638 service_rc = msg->cprbx.ccp_rtcode; 638 service_rc = msg->cprbx.ccp_rtcode;
639 if (unlikely(service_rc != 0)) { 639 if (unlikely(service_rc != 0)) {
640 service_rs = msg->cprbx.ccp_rscode; 640 service_rs = msg->cprbx.ccp_rscode;
641 if (service_rc == 8 && service_rs == 66) 641 if ((service_rc == 8 && service_rs == 66) ||
642 return -EINVAL; 642 (service_rc == 8 && service_rs == 65) ||
643 if (service_rc == 8 && service_rs == 65) 643 (service_rc == 8 && service_rs == 72) ||
644 return -EINVAL; 644 (service_rc == 8 && service_rs == 770) ||
645 if (service_rc == 8 && service_rs == 770) 645 (service_rc == 12 && service_rs == 769)) {
646 ZCRYPT_DBF(DBF_DEBUG,
647 "device=%02x.%04x rc/rs=%d/%d => rc=EINVAL\n",
648 AP_QID_CARD(zq->queue->qid),
649 AP_QID_QUEUE(zq->queue->qid),
650 (int) service_rc, (int) service_rs);
646 return -EINVAL; 651 return -EINVAL;
652 }
647 if (service_rc == 8 && service_rs == 783) { 653 if (service_rc == 8 && service_rs == 783) {
648 zq->zcard->min_mod_size = 654 zq->zcard->min_mod_size =
649 PCIXCC_MIN_MOD_SIZE_OLD; 655 PCIXCC_MIN_MOD_SIZE_OLD;
656 ZCRYPT_DBF(DBF_DEBUG,
657 "device=%02x.%04x rc/rs=%d/%d => rc=EAGAIN\n",
658 AP_QID_CARD(zq->queue->qid),
659 AP_QID_QUEUE(zq->queue->qid),
660 (int) service_rc, (int) service_rs);
650 return -EAGAIN; 661 return -EAGAIN;
651 } 662 }
652 if (service_rc == 12 && service_rs == 769)
653 return -EINVAL;
654 if (service_rc == 8 && service_rs == 72)
655 return -EINVAL;
656 zq->online = 0; 663 zq->online = 0;
657 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 664 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
658 AP_QID_CARD(zq->queue->qid), 665 AP_QID_CARD(zq->queue->qid),
659 AP_QID_QUEUE(zq->queue->qid)); 666 AP_QID_QUEUE(zq->queue->qid));
660 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%drc%d", 667 ZCRYPT_DBF(DBF_ERR,
661 AP_QID_CARD(zq->queue->qid), 668 "device=%02x.%04x rc/rs=%d/%d => online=0 rc=EAGAIN\n",
662 AP_QID_QUEUE(zq->queue->qid), 669 AP_QID_CARD(zq->queue->qid),
663 zq->online, 670 AP_QID_QUEUE(zq->queue->qid),
664 msg->hdr.reply_code); 671 (int) service_rc, (int) service_rs);
665 return -EAGAIN; /* repeat the request on a different device. */ 672 return -EAGAIN; /* repeat the request on a different device. */
666 } 673 }
667 data = msg->text; 674 data = msg->text;
@@ -776,8 +783,7 @@ static int convert_response_ica(struct zcrypt_queue *zq,
776{ 783{
777 struct type86x_reply *msg = reply->message; 784 struct type86x_reply *msg = reply->message;
778 785
779 /* Response type byte is the second byte in the response. */ 786 switch (msg->hdr.type) {
780 switch (((unsigned char *) reply->message)[1]) {
781 case TYPE82_RSP_CODE: 787 case TYPE82_RSP_CODE:
782 case TYPE88_RSP_CODE: 788 case TYPE88_RSP_CODE:
783 return convert_error(zq, reply); 789 return convert_error(zq, reply);
@@ -803,10 +809,11 @@ static int convert_response_ica(struct zcrypt_queue *zq,
803 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 809 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
804 AP_QID_CARD(zq->queue->qid), 810 AP_QID_CARD(zq->queue->qid),
805 AP_QID_QUEUE(zq->queue->qid)); 811 AP_QID_QUEUE(zq->queue->qid));
806 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", 812 ZCRYPT_DBF(DBF_ERR,
807 AP_QID_CARD(zq->queue->qid), 813 "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
808 AP_QID_QUEUE(zq->queue->qid), 814 AP_QID_CARD(zq->queue->qid),
809 zq->online); 815 AP_QID_QUEUE(zq->queue->qid),
816 (int) msg->hdr.type);
810 return -EAGAIN; /* repeat the request on a different device. */ 817 return -EAGAIN; /* repeat the request on a different device. */
811 } 818 }
812} 819}
@@ -817,8 +824,7 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
817{ 824{
818 struct type86x_reply *msg = reply->message; 825 struct type86x_reply *msg = reply->message;
819 826
820 /* Response type byte is the second byte in the response. */ 827 switch (msg->hdr.type) {
821 switch (((unsigned char *) reply->message)[1]) {
822 case TYPE82_RSP_CODE: 828 case TYPE82_RSP_CODE:
823 case TYPE88_RSP_CODE: 829 case TYPE88_RSP_CODE:
824 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */ 830 xcRB->status = 0x0008044DL; /* HDD_InvalidParm */
@@ -838,10 +844,11 @@ static int convert_response_xcrb(struct zcrypt_queue *zq,
838 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 844 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
839 AP_QID_CARD(zq->queue->qid), 845 AP_QID_CARD(zq->queue->qid),
840 AP_QID_QUEUE(zq->queue->qid)); 846 AP_QID_QUEUE(zq->queue->qid));
841 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", 847 ZCRYPT_DBF(DBF_ERR,
842 AP_QID_CARD(zq->queue->qid), 848 "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
843 AP_QID_QUEUE(zq->queue->qid), 849 AP_QID_CARD(zq->queue->qid),
844 zq->online); 850 AP_QID_QUEUE(zq->queue->qid),
851 (int) msg->hdr.type);
845 return -EAGAIN; /* repeat the request on a different device. */ 852 return -EAGAIN; /* repeat the request on a different device. */
846 } 853 }
847} 854}
@@ -851,8 +858,7 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq,
851{ 858{
852 struct type86_ep11_reply *msg = reply->message; 859 struct type86_ep11_reply *msg = reply->message;
853 860
854 /* Response type byte is the second byte in the response. */ 861 switch (msg->hdr.type) {
855 switch (((unsigned char *)reply->message)[1]) {
856 case TYPE82_RSP_CODE: 862 case TYPE82_RSP_CODE:
857 case TYPE87_RSP_CODE: 863 case TYPE87_RSP_CODE:
858 return convert_error(zq, reply); 864 return convert_error(zq, reply);
@@ -867,10 +873,11 @@ static int convert_response_ep11_xcrb(struct zcrypt_queue *zq,
867 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 873 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
868 AP_QID_CARD(zq->queue->qid), 874 AP_QID_CARD(zq->queue->qid),
869 AP_QID_QUEUE(zq->queue->qid)); 875 AP_QID_QUEUE(zq->queue->qid));
870 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", 876 ZCRYPT_DBF(DBF_ERR,
871 AP_QID_CARD(zq->queue->qid), 877 "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
872 AP_QID_QUEUE(zq->queue->qid), 878 AP_QID_CARD(zq->queue->qid),
873 zq->online); 879 AP_QID_QUEUE(zq->queue->qid),
880 (int) msg->hdr.type);
874 return -EAGAIN; /* repeat the request on a different device. */ 881 return -EAGAIN; /* repeat the request on a different device. */
875 } 882 }
876} 883}
@@ -897,10 +904,11 @@ static int convert_response_rng(struct zcrypt_queue *zq,
897 pr_err("Cryptographic device %02x.%04x failed and was set offline\n", 904 pr_err("Cryptographic device %02x.%04x failed and was set offline\n",
898 AP_QID_CARD(zq->queue->qid), 905 AP_QID_CARD(zq->queue->qid),
899 AP_QID_QUEUE(zq->queue->qid)); 906 AP_QID_QUEUE(zq->queue->qid));
900 ZCRYPT_DBF_DEV(DBF_ERR, zq, "dev%02x%04xo%dfail", 907 ZCRYPT_DBF(DBF_ERR,
901 AP_QID_CARD(zq->queue->qid), 908 "device=%02x.%04x rtype=0x%02x => online=0 rc=EAGAIN\n",
902 AP_QID_QUEUE(zq->queue->qid), 909 AP_QID_CARD(zq->queue->qid),
903 zq->online); 910 AP_QID_QUEUE(zq->queue->qid),
911 (int) msg->hdr.type);
904 return -EAGAIN; /* repeat the request on a different device. */ 912 return -EAGAIN; /* repeat the request on a different device. */
905 } 913 }
906} 914}
diff --git a/drivers/s390/crypto/zcrypt_queue.c b/drivers/s390/crypto/zcrypt_queue.c
index c70b2528d9a3..a303f3b2c328 100644
--- a/drivers/s390/crypto/zcrypt_queue.c
+++ b/drivers/s390/crypto/zcrypt_queue.c
@@ -70,9 +70,12 @@ static ssize_t zcrypt_queue_online_store(struct device *dev,
70 if (online && !zc->online) 70 if (online && !zc->online)
71 return -EINVAL; 71 return -EINVAL;
72 zq->online = online; 72 zq->online = online;
73 ZCRYPT_DBF_DEV(DBF_INFO, zq, "dev%02x%04xo%dman", 73
74 AP_QID_CARD(zq->queue->qid), 74 ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x online=%d\n",
75 AP_QID_QUEUE(zq->queue->qid), online); 75 AP_QID_CARD(zq->queue->qid),
76 AP_QID_QUEUE(zq->queue->qid),
77 online);
78
76 if (!online) 79 if (!online)
77 ap_flush_queue(zq->queue); 80 ap_flush_queue(zq->queue);
78 return count; 81 return count;
@@ -109,7 +112,6 @@ struct zcrypt_queue *zcrypt_queue_alloc(size_t max_response_size)
109 goto out_free; 112 goto out_free;
110 zq->reply.length = max_response_size; 113 zq->reply.length = max_response_size;
111 INIT_LIST_HEAD(&zq->list); 114 INIT_LIST_HEAD(&zq->list);
112 zq->dbf_area = zcrypt_dbf_devices;
113 kref_init(&zq->refcount); 115 kref_init(&zq->refcount);
114 return zq; 116 return zq;
115 117
@@ -161,10 +163,10 @@ int zcrypt_queue_register(struct zcrypt_queue *zq)
161 zcrypt_card_get(zc); 163 zcrypt_card_get(zc);
162 zq->zcard = zc; 164 zq->zcard = zc;
163 zq->online = 1; /* New devices are online by default. */ 165 zq->online = 1; /* New devices are online by default. */
164 ZCRYPT_DBF_DEV(DBF_INFO, zq, "dev%02x%04xo%dreg", 166
165 AP_QID_CARD(zq->queue->qid), 167 ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x register online=1\n",
166 AP_QID_QUEUE(zq->queue->qid), 168 AP_QID_CARD(zq->queue->qid), AP_QID_QUEUE(zq->queue->qid));
167 zq->online); 169
168 list_add_tail(&zq->list, &zc->zqueues); 170 list_add_tail(&zq->list, &zc->zqueues);
169 zcrypt_device_count++; 171 zcrypt_device_count++;
170 spin_unlock(&zcrypt_list_lock); 172 spin_unlock(&zcrypt_list_lock);
@@ -205,6 +207,9 @@ void zcrypt_queue_unregister(struct zcrypt_queue *zq)
205{ 207{
206 struct zcrypt_card *zc; 208 struct zcrypt_card *zc;
207 209
210 ZCRYPT_DBF(DBF_INFO, "queue=%02x.%04x unregister\n",
211 AP_QID_CARD(zq->queue->qid), AP_QID_QUEUE(zq->queue->qid));
212
208 zc = zq->zcard; 213 zc = zq->zcard;
209 spin_lock(&zcrypt_list_lock); 214 spin_lock(&zcrypt_list_lock);
210 list_del_init(&zq->list); 215 list_del_init(&zq->list);