Skip to content

Commit cccd85b

Browse files
Harald FreudenbergerMartin Schwidefsky
authored andcommitted
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>
1 parent bf9f311 commit cccd85b

10 files changed

Lines changed: 190 additions & 143 deletions

File tree

‎drivers/s390/crypto/ap_bus.c‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,9 +47,11 @@
4747
#include <asm/facility.h>
4848
#include <linux/crypto.h>
4949
#include <linux/mod_devicetable.h>
50+
#include <linux/debugfs.h>
5051

5152
#include "ap_bus.h"
5253
#include "ap_asm.h"
54+
#include "ap_debug.h"
5355

5456
/*
5557
* Module description.
@@ -81,6 +83,12 @@ LIST_HEAD(ap_card_list);
8183
static struct ap_config_info *ap_configuration;
8284
static bool initialised;
8385

86+
/*
87+
* AP bus related debug feature things.
88+
*/
89+
static struct dentry *ap_dbf_root;
90+
debug_info_t *ap_dbf_info;
91+
8492
/*
8593
* Workqueue timer for bus rescan.
8694
*/
@@ -568,6 +576,8 @@ static int ap_dev_resume(struct device *dev)
568576

569577
static void ap_bus_suspend(void)
570578
{
579+
AP_DBF(DBF_DEBUG, "ap_bus_suspend running\n");
580+
571581
ap_suspend_flag = 1;
572582
/*
573583
* Disable scanning for devices, thus we do not want to scan
@@ -603,6 +613,8 @@ static void ap_bus_resume(void)
603613
{
604614
int rc;
605615

616+
AP_DBF(DBF_DEBUG, "ap_bus_resume running\n");
617+
606618
/* remove all queue devices */
607619
bus_for_each_dev(&ap_bus_type, NULL, NULL,
608620
__ap_queue_devices_unregister);
@@ -742,6 +754,9 @@ static ssize_t ap_domain_store(struct bus_type *bus,
742754
spin_lock_bh(&ap_domain_lock);
743755
ap_domain_index = domain;
744756
spin_unlock_bh(&ap_domain_lock);
757+
758+
AP_DBF(DBF_DEBUG, "store new default domain=%d\n", domain);
759+
745760
return count;
746761
}
747762

@@ -964,6 +979,8 @@ static void ap_scan_bus(struct work_struct *unused)
964979
unsigned int functions = 0;
965980
int rc, id, dom, borked, domains;
966981

982+
AP_DBF(DBF_DEBUG, "ap_scan_bus running\n");
983+
967984
ap_query_configuration();
968985
if (ap_select_domain() != 0)
969986
goto out;
@@ -1129,6 +1146,23 @@ static struct reset_call ap_reset_call = {
11291146
.fn = ap_reset_all,
11301147
};
11311148

1149+
int __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+
1160+
void ap_debug_exit(void)
1161+
{
1162+
debugfs_remove(ap_dbf_root);
1163+
debug_unregister(ap_dbf_info);
1164+
}
1165+
11321166
/**
11331167
* ap_module_init(): The module initialization code.
11341168
*
@@ -1139,6 +1173,10 @@ int __init ap_module_init(void)
11391173
int max_domain_id;
11401174
int rc, i;
11411175

1176+
rc = ap_debug_init();
1177+
if (rc)
1178+
return rc;
1179+
11421180
if (ap_instructions_available() != 0) {
11431181
pr_warn("The hardware system does not support AP instructions\n");
11441182
return -ENODEV;
@@ -1266,6 +1304,8 @@ void ap_module_exit(void)
12661304
unregister_reset_call(&ap_reset_call);
12671305
if (ap_using_interrupts())
12681306
unregister_adapter_interrupt(&ap_airq);
1307+
1308+
ap_debug_exit();
12691309
}
12701310

12711311
module_init(ap_module_init);

‎drivers/s390/crypto/ap_debug.h‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -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+
23+
extern debug_info_t *ap_dbf_info;
24+
25+
int ap_debug_init(void);
26+
void ap_debug_exit(void);
27+
28+
#endif /* AP_DEBUG_H */

‎drivers/s390/crypto/zcrypt_api.c‎

Lines changed: 14 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@
4141
#include <linux/debugfs.h>
4242
#include <asm/debug.h>
4343

44-
#include "zcrypt_debug.h"
4544
#include "zcrypt_api.h"
45+
#include "zcrypt_debug.h"
4646

4747
#include "zcrypt_msgtype6.h"
4848
#include "zcrypt_msgtype50.h"
@@ -71,10 +71,9 @@ EXPORT_SYMBOL(zcrypt_rescan_req);
7171

7272
static LIST_HEAD(zcrypt_ops_list);
7373

74-
static struct dentry *debugfs_root;
75-
debug_info_t *zcrypt_dbf_common;
76-
debug_info_t *zcrypt_dbf_devices;
77-
debug_info_t *zcrypt_dbf_cards;
74+
/* Zcrypt related debug feature stuff. */
75+
static struct dentry *zcrypt_dbf_root;
76+
debug_info_t *zcrypt_dbf_info;
7877

7978
/**
8079
* Process a rescan of the transport layer.
@@ -87,8 +86,8 @@ static inline int zcrypt_process_rescan(void)
8786
atomic_set(&zcrypt_rescan_req, 0);
8887
atomic_inc(&zcrypt_rescan_count);
8988
ap_bus_force_rescan();
90-
ZCRYPT_DBF_COMMON(DBF_INFO, "rescan%07d",
91-
atomic_inc_return(&zcrypt_rescan_count));
89+
ZCRYPT_DBF(DBF_INFO, "rescan count=%07d",
90+
atomic_inc_return(&zcrypt_rescan_count));
9291
return 1;
9392
}
9493
return 0;
@@ -1363,28 +1362,19 @@ void zcrypt_rng_device_remove(void)
13631362

13641363
int __init zcrypt_debug_init(void)
13651364
{
1366-
debugfs_root = debugfs_create_dir("zcrypt", NULL);
1367-
1368-
zcrypt_dbf_common = debug_register("zcrypt_common", 1, 1, 16);
1369-
debug_register_view(zcrypt_dbf_common, &debug_hex_ascii_view);
1370-
debug_set_level(zcrypt_dbf_common, 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);
1365+
zcrypt_dbf_root = debugfs_create_dir("zcrypt", NULL);
1366+
zcrypt_dbf_info = debug_register("zcrypt", 1, 1,
1367+
DBF_MAX_SPRINTF_ARGS * sizeof(long));
1368+
debug_register_view(zcrypt_dbf_info, &debug_sprintf_view);
1369+
debug_set_level(zcrypt_dbf_info, DBF_ERR);
13791370

13801371
return 0;
13811372
}
13821373

13831374
void zcrypt_debug_exit(void)
13841375
{
1385-
debugfs_remove(debugfs_root);
1386-
debug_unregister(zcrypt_dbf_common);
1387-
debug_unregister(zcrypt_dbf_devices);
1376+
debugfs_remove(zcrypt_dbf_root);
1377+
debug_unregister(zcrypt_dbf_info);
13881378
}
13891379

13901380
/**
@@ -1434,9 +1424,9 @@ void __exit zcrypt_api_exit(void)
14341424
{
14351425
remove_proc_entry("driver/z90crypt", NULL);
14361426
misc_deregister(&zcrypt_misc_device);
1437-
zcrypt_debug_exit();
14381427
zcrypt_msgtype6_exit();
14391428
zcrypt_msgtype50_exit();
1429+
zcrypt_debug_exit();
14401430
}
14411431

14421432
module_init(zcrypt_api_init);

‎drivers/s390/crypto/zcrypt_api.h‎

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,6 @@ struct zcrypt_card {
132132
atomic_t load; /* Utilization of the crypto device */
133133

134134
int request_count; /* # current requests. */
135-
136-
debug_info_t *dbf_area; /* debugging */
137135
};
138136

139137
struct zcrypt_queue {
@@ -149,8 +147,6 @@ struct zcrypt_queue {
149147
int request_count; /* # current requests. */
150148

151149
struct ap_message reply; /* Per-device reply structure. */
152-
153-
debug_info_t *dbf_area; /* debugging */
154150
};
155151

156152
/* transport layer rescanning */
@@ -160,10 +156,6 @@ extern spinlock_t zcrypt_list_lock;
160156
extern int zcrypt_device_count;
161157
extern struct list_head zcrypt_card_list;
162158

163-
extern debug_info_t *zcrypt_dbf_common;
164-
extern debug_info_t *zcrypt_dbf_devices;
165-
extern debug_info_t *zcrypt_dbf_cards;
166-
167159
#define for_each_zcrypt_card(_zc) \
168160
list_for_each_entry(_zc, &zcrypt_card_list, list)
169161

‎drivers/s390/crypto/zcrypt_card.c‎

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ static ssize_t zcrypt_card_online_store(struct device *dev,
7979

8080
zc->online = online;
8181
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+
8385
spin_lock(&zcrypt_list_lock);
8486
list_for_each_entry(zq, &zc->zqueues, list)
8587
zcrypt_queue_force_online(zq, online);
@@ -109,7 +111,6 @@ struct zcrypt_card *zcrypt_card_alloc(void)
109111
return NULL;
110112
INIT_LIST_HEAD(&zc->list);
111113
INIT_LIST_HEAD(&zc->zqueues);
112-
zc->dbf_area = zcrypt_dbf_cards;
113114
kref_init(&zc->refcount);
114115
return zc;
115116
}
@@ -160,6 +161,9 @@ int zcrypt_card_register(struct zcrypt_card *zc)
160161
spin_unlock(&zcrypt_list_lock);
161162

162163
zc->online = 1;
164+
165+
ZCRYPT_DBF(DBF_INFO, "card=%02x register online=1\n", zc->card->id);
166+
163167
return rc;
164168
}
165169
EXPORT_SYMBOL(zcrypt_card_register);
@@ -172,6 +176,8 @@ EXPORT_SYMBOL(zcrypt_card_register);
172176
*/
173177
void zcrypt_card_unregister(struct zcrypt_card *zc)
174178
{
179+
ZCRYPT_DBF(DBF_INFO, "card=%02x unregister\n", zc->card->id);
180+
175181
spin_lock(&zcrypt_list_lock);
176182
list_del_init(&zc->list);
177183
spin_unlock(&zcrypt_list_lock);

‎drivers/s390/crypto/zcrypt_debug.h‎

Lines changed: 13 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,27 @@
11
/*
2-
* Copyright IBM Corp. 2012
2+
* Copyright IBM Corp. 2016
33
* Author(s): Holger Dengler (hd@linux.vnet.ibm.com)
4+
* Harald Freudenberger <freude@de.ibm.com>
45
*/
56
#ifndef ZCRYPT_DEBUG_H
67
#define ZCRYPT_DEBUG_H
78

89
#include <asm/debug.h>
9-
#include "zcrypt_api.h"
1010

11-
/* that gives us 15 characters in the text event views */
12-
#define ZCRYPT_DBF_LEN 16
13-
14-
#define DBF_ERR 3 /* error conditions */
15-
#define DBF_WARN 4 /* warning conditions */
16-
#define DBF_INFO 6 /* informational */
11+
#define DBF_ERR 3 /* error conditions */
12+
#define DBF_WARN 4 /* warning conditions */
13+
#define DBF_INFO 5 /* informational */
14+
#define DBF_DEBUG 6 /* for debugging only */
1715

16+
#define RC2ERR(rc) ((rc) ? DBF_ERR : DBF_INFO)
1817
#define RC2WARN(rc) ((rc) ? DBF_WARN : DBF_INFO)
1918

20-
#define ZCRYPT_DBF_COMMON(level, text...) \
21-
do { \
22-
if (debug_level_enabled(zcrypt_dbf_common, level)) { \
23-
char debug_buffer[ZCRYPT_DBF_LEN]; \
24-
snprintf(debug_buffer, ZCRYPT_DBF_LEN, text); \
25-
debug_text_event(zcrypt_dbf_common, level, \
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)
19+
#define DBF_MAX_SPRINTF_ARGS 5
20+
21+
#define ZCRYPT_DBF(...) \
22+
debug_sprintf_event(zcrypt_dbf_info, ##__VA_ARGS__)
23+
24+
extern debug_info_t *zcrypt_dbf_info;
4925

5026
int zcrypt_debug_init(void);
5127
void zcrypt_debug_exit(void);

0 commit comments

Comments
 (0)