diff options
-rw-r--r-- | drivers/s390/cio/qdio_debug.c | 79 | ||||
-rw-r--r-- | drivers/s390/cio/qdio_debug.h | 2 | ||||
-rw-r--r-- | drivers/s390/cio/qdio_main.c | 9 |
3 files changed, 77 insertions, 13 deletions
diff --git a/drivers/s390/cio/qdio_debug.c b/drivers/s390/cio/qdio_debug.c index 4221b02085ad..f1f3baa8e6e4 100644 --- a/drivers/s390/cio/qdio_debug.c +++ b/drivers/s390/cio/qdio_debug.c | |||
@@ -7,6 +7,7 @@ | |||
7 | #include <linux/debugfs.h> | 7 | #include <linux/debugfs.h> |
8 | #include <linux/uaccess.h> | 8 | #include <linux/uaccess.h> |
9 | #include <linux/export.h> | 9 | #include <linux/export.h> |
10 | #include <linux/slab.h> | ||
10 | #include <asm/debug.h> | 11 | #include <asm/debug.h> |
11 | #include "qdio_debug.h" | 12 | #include "qdio_debug.h" |
12 | #include "qdio.h" | 13 | #include "qdio.h" |
@@ -16,11 +17,51 @@ debug_info_t *qdio_dbf_error; | |||
16 | 17 | ||
17 | static struct dentry *debugfs_root; | 18 | static struct dentry *debugfs_root; |
18 | #define QDIO_DEBUGFS_NAME_LEN 10 | 19 | #define QDIO_DEBUGFS_NAME_LEN 10 |
20 | #define QDIO_DBF_NAME_LEN 20 | ||
19 | 21 | ||
20 | void qdio_allocate_dbf(struct qdio_initialize *init_data, | 22 | struct qdio_dbf_entry { |
23 | char dbf_name[QDIO_DBF_NAME_LEN]; | ||
24 | debug_info_t *dbf_info; | ||
25 | struct list_head dbf_list; | ||
26 | }; | ||
27 | |||
28 | static LIST_HEAD(qdio_dbf_list); | ||
29 | static DEFINE_MUTEX(qdio_dbf_list_mutex); | ||
30 | |||
31 | static debug_info_t *qdio_get_dbf_entry(char *name) | ||
32 | { | ||
33 | struct qdio_dbf_entry *entry; | ||
34 | debug_info_t *rc = NULL; | ||
35 | |||
36 | mutex_lock(&qdio_dbf_list_mutex); | ||
37 | list_for_each_entry(entry, &qdio_dbf_list, dbf_list) { | ||
38 | if (strcmp(entry->dbf_name, name) == 0) { | ||
39 | rc = entry->dbf_info; | ||
40 | break; | ||
41 | } | ||
42 | } | ||
43 | mutex_unlock(&qdio_dbf_list_mutex); | ||
44 | return rc; | ||
45 | } | ||
46 | |||
47 | static void qdio_clear_dbf_list(void) | ||
48 | { | ||
49 | struct qdio_dbf_entry *entry, *tmp; | ||
50 | |||
51 | mutex_lock(&qdio_dbf_list_mutex); | ||
52 | list_for_each_entry_safe(entry, tmp, &qdio_dbf_list, dbf_list) { | ||
53 | list_del(&entry->dbf_list); | ||
54 | debug_unregister(entry->dbf_info); | ||
55 | kfree(entry); | ||
56 | } | ||
57 | mutex_unlock(&qdio_dbf_list_mutex); | ||
58 | } | ||
59 | |||
60 | int qdio_allocate_dbf(struct qdio_initialize *init_data, | ||
21 | struct qdio_irq *irq_ptr) | 61 | struct qdio_irq *irq_ptr) |
22 | { | 62 | { |
23 | char text[20]; | 63 | char text[QDIO_DBF_NAME_LEN]; |
64 | struct qdio_dbf_entry *new_entry; | ||
24 | 65 | ||
25 | DBF_EVENT("qfmt:%1d", init_data->q_format); | 66 | DBF_EVENT("qfmt:%1d", init_data->q_format); |
26 | DBF_HEX(init_data->adapter_name, 8); | 67 | DBF_HEX(init_data->adapter_name, 8); |
@@ -38,11 +79,34 @@ void qdio_allocate_dbf(struct qdio_initialize *init_data, | |||
38 | DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); | 79 | DBF_EVENT("irq:%8lx", (unsigned long)irq_ptr); |
39 | 80 | ||
40 | /* allocate trace view for the interface */ | 81 | /* allocate trace view for the interface */ |
41 | snprintf(text, 20, "qdio_%s", dev_name(&init_data->cdev->dev)); | 82 | snprintf(text, QDIO_DBF_NAME_LEN, "qdio_%s", |
42 | irq_ptr->debug_area = debug_register(text, 2, 1, 16); | 83 | dev_name(&init_data->cdev->dev)); |
43 | debug_register_view(irq_ptr->debug_area, &debug_hex_ascii_view); | 84 | irq_ptr->debug_area = qdio_get_dbf_entry(text); |
44 | debug_set_level(irq_ptr->debug_area, DBF_WARN); | 85 | if (irq_ptr->debug_area) |
45 | DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); | 86 | DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf reused"); |
87 | else { | ||
88 | irq_ptr->debug_area = debug_register(text, 2, 1, 16); | ||
89 | if (!irq_ptr->debug_area) | ||
90 | return -ENOMEM; | ||
91 | if (debug_register_view(irq_ptr->debug_area, | ||
92 | &debug_hex_ascii_view)) { | ||
93 | debug_unregister(irq_ptr->debug_area); | ||
94 | return -ENOMEM; | ||
95 | } | ||
96 | debug_set_level(irq_ptr->debug_area, DBF_WARN); | ||
97 | DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf created"); | ||
98 | new_entry = kzalloc(sizeof(struct qdio_dbf_entry), GFP_KERNEL); | ||
99 | if (!new_entry) { | ||
100 | debug_unregister(irq_ptr->debug_area); | ||
101 | return -ENOMEM; | ||
102 | } | ||
103 | strlcpy(new_entry->dbf_name, text, QDIO_DBF_NAME_LEN); | ||
104 | new_entry->dbf_info = irq_ptr->debug_area; | ||
105 | mutex_lock(&qdio_dbf_list_mutex); | ||
106 | list_add(&new_entry->dbf_list, &qdio_dbf_list); | ||
107 | mutex_unlock(&qdio_dbf_list_mutex); | ||
108 | } | ||
109 | return 0; | ||
46 | } | 110 | } |
47 | 111 | ||
48 | static int qstat_show(struct seq_file *m, void *v) | 112 | static int qstat_show(struct seq_file *m, void *v) |
@@ -300,6 +364,7 @@ int __init qdio_debug_init(void) | |||
300 | 364 | ||
301 | void qdio_debug_exit(void) | 365 | void qdio_debug_exit(void) |
302 | { | 366 | { |
367 | qdio_clear_dbf_list(); | ||
303 | debugfs_remove(debugfs_root); | 368 | debugfs_remove(debugfs_root); |
304 | if (qdio_dbf_setup) | 369 | if (qdio_dbf_setup) |
305 | debug_unregister(qdio_dbf_setup); | 370 | debug_unregister(qdio_dbf_setup); |
diff --git a/drivers/s390/cio/qdio_debug.h b/drivers/s390/cio/qdio_debug.h index dfac9bfefea3..f33ce8577619 100644 --- a/drivers/s390/cio/qdio_debug.h +++ b/drivers/s390/cio/qdio_debug.h | |||
@@ -75,7 +75,7 @@ static inline void DBF_DEV_HEX(struct qdio_irq *dev, void *addr, | |||
75 | } | 75 | } |
76 | } | 76 | } |
77 | 77 | ||
78 | void qdio_allocate_dbf(struct qdio_initialize *init_data, | 78 | int qdio_allocate_dbf(struct qdio_initialize *init_data, |
79 | struct qdio_irq *irq_ptr); | 79 | struct qdio_irq *irq_ptr); |
80 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, | 80 | void qdio_setup_debug_entries(struct qdio_irq *irq_ptr, |
81 | struct ccw_device *cdev); | 81 | struct ccw_device *cdev); |
diff --git a/drivers/s390/cio/qdio_main.c b/drivers/s390/cio/qdio_main.c index f5f42c431409..848e3b64ea6e 100644 --- a/drivers/s390/cio/qdio_main.c +++ b/drivers/s390/cio/qdio_main.c | |||
@@ -1233,12 +1233,10 @@ int qdio_free(struct ccw_device *cdev) | |||
1233 | return -ENODEV; | 1233 | return -ENODEV; |
1234 | 1234 | ||
1235 | DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no); | 1235 | DBF_EVENT("qfree:%4x", cdev->private->schid.sch_no); |
1236 | DBF_DEV_EVENT(DBF_ERR, irq_ptr, "dbf abandoned"); | ||
1236 | mutex_lock(&irq_ptr->setup_mutex); | 1237 | mutex_lock(&irq_ptr->setup_mutex); |
1237 | 1238 | ||
1238 | if (irq_ptr->debug_area != NULL) { | 1239 | irq_ptr->debug_area = NULL; |
1239 | debug_unregister(irq_ptr->debug_area); | ||
1240 | irq_ptr->debug_area = NULL; | ||
1241 | } | ||
1242 | cdev->private->qdio_data = NULL; | 1240 | cdev->private->qdio_data = NULL; |
1243 | mutex_unlock(&irq_ptr->setup_mutex); | 1241 | mutex_unlock(&irq_ptr->setup_mutex); |
1244 | 1242 | ||
@@ -1275,7 +1273,8 @@ int qdio_allocate(struct qdio_initialize *init_data) | |||
1275 | goto out_err; | 1273 | goto out_err; |
1276 | 1274 | ||
1277 | mutex_init(&irq_ptr->setup_mutex); | 1275 | mutex_init(&irq_ptr->setup_mutex); |
1278 | qdio_allocate_dbf(init_data, irq_ptr); | 1276 | if (qdio_allocate_dbf(init_data, irq_ptr)) |
1277 | goto out_rel; | ||
1279 | 1278 | ||
1280 | /* | 1279 | /* |
1281 | * Allocate a page for the chsc calls in qdio_establish. | 1280 | * Allocate a page for the chsc calls in qdio_establish. |