Skip to content

Commit 8502652

Browse files
Longfang Liuherbertx
authored andcommitted
crypto: hisilicon/qm - add debugfs for QM
Add DebugFS method to get the information of IRQ/Requests/QP .etc of QM for HPRE/ZIP/SEC drivers. Signed-off-by: Longfang Liu <[email protected]> Signed-off-by: Shukun Tan <[email protected]> Reviewed-by: Zaibo Xu <[email protected]> Reviewed-by: Zhou Wang <[email protected]> Signed-off-by: Herbert Xu <[email protected]>
1 parent 7795c0b commit 8502652

File tree

5 files changed

+153
-0
lines changed

5 files changed

+153
-0
lines changed

Documentation/ABI/testing/debugfs-hisi-hpre

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,3 +55,34 @@ Description: QM debug registers(qm_regs) read clear control. 1 means enable
5555
Writing to this file has no functional effect, only enable or
5656
disable counters clear after reading of these registers.
5757
Only available for PF.
58+
59+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/err_irq
60+
Date: Apr 2020
61+
62+
Description: Dump the number of invalid interrupts for
63+
QM task completion.
64+
Available for both PF and VF, and take no other effect on HPRE.
65+
66+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/aeq_irq
67+
Date: Apr 2020
68+
69+
Description: Dump the number of QM async event queue interrupts.
70+
Available for both PF and VF, and take no other effect on HPRE.
71+
72+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/abnormal_irq
73+
Date: Apr 2020
74+
75+
Description: Dump the number of interrupts for QM abnormal event.
76+
Available for both PF and VF, and take no other effect on HPRE.
77+
78+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/create_qp_err
79+
Date: Apr 2020
80+
81+
Description: Dump the number of queue allocation errors.
82+
Available for both PF and VF, and take no other effect on HPRE.
83+
84+
What: /sys/kernel/debug/hisi_hpre/<bdf>/qm/mb_err
85+
Date: Apr 2020
86+
87+
Description: Dump the number of failed QM mailbox commands.
88+
Available for both PF and VF, and take no other effect on HPRE.

Documentation/ABI/testing/debugfs-hisi-sec

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,3 +41,34 @@ Description: Enabling/disabling of clear action after reading
4141
the SEC's QM debug registers.
4242
0: disable, 1: enable.
4343
Only available for PF, and take no other effect on SEC.
44+
45+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/err_irq
46+
Date: Apr 2020
47+
48+
Description: Dump the number of invalid interrupts for
49+
QM task completion.
50+
Available for both PF and VF, and take no other effect on SEC.
51+
52+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/aeq_irq
53+
Date: Apr 2020
54+
55+
Description: Dump the number of QM async event queue interrupts.
56+
Available for both PF and VF, and take no other effect on SEC.
57+
58+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/abnormal_irq
59+
Date: Apr 2020
60+
61+
Description: Dump the number of interrupts for QM abnormal event.
62+
Available for both PF and VF, and take no other effect on SEC.
63+
64+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/create_qp_err
65+
Date: Apr 2020
66+
67+
Description: Dump the number of queue allocation errors.
68+
Available for both PF and VF, and take no other effect on SEC.
69+
70+
What: /sys/kernel/debug/hisi_sec2/<bdf>/qm/mb_err
71+
Date: Apr 2020
72+
73+
Description: Dump the number of failed QM mailbox commands.
74+
Available for both PF and VF, and take no other effect on SEC.

Documentation/ABI/testing/debugfs-hisi-zip

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,3 +48,34 @@ Description: QM debug registers(qm_regs) read clear control. 1 means enable
4848
Writing to this file has no functional effect, only enable or
4949
disable counters clear after reading of these registers.
5050
Only available for PF.
51+
52+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/err_irq
53+
Date: Apr 2020
54+
55+
Description: Dump the number of invalid interrupts for
56+
QM task completion.
57+
Available for both PF and VF, and take no other effect on ZIP.
58+
59+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/aeq_irq
60+
Date: Apr 2020
61+
62+
Description: Dump the number of QM async event queue interrupts.
63+
Available for both PF and VF, and take no other effect on ZIP.
64+
65+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/abnormal_irq
66+
Date: Apr 2020
67+
68+
Description: Dump the number of interrupts for QM abnormal event.
69+
Available for both PF and VF, and take no other effect on ZIP.
70+
71+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/create_qp_err
72+
Date: Apr 2020
73+
74+
Description: Dump the number of queue allocation errors.
75+
Available for both PF and VF, and take no other effect on ZIP.
76+
77+
What: /sys/kernel/debug/hisi_zip/<bdf>/qm/mb_err
78+
Date: Apr 2020
79+
80+
Description: Dump the number of failed QM mailbox commands.
81+
Available for both PF and VF, and take no other effect on ZIP.

drivers/crypto/hisilicon/qm.c

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,19 @@ struct hisi_qm_hw_ops {
324324
enum acc_err_result (*hw_error_handle)(struct hisi_qm *qm);
325325
};
326326

327+
struct qm_dfx_item {
328+
const char *name;
329+
u32 offset;
330+
};
331+
332+
static struct qm_dfx_item qm_dfx_files[] = {
333+
{"err_irq", offsetof(struct qm_dfx, err_irq_cnt)},
334+
{"aeq_irq", offsetof(struct qm_dfx, aeq_irq_cnt)},
335+
{"abnormal_irq", offsetof(struct qm_dfx, abnormal_irq_cnt)},
336+
{"create_qp_err", offsetof(struct qm_dfx, create_qp_err_cnt)},
337+
{"mb_err", offsetof(struct qm_dfx, mb_err_cnt)},
338+
};
339+
327340
static const char * const qm_debug_file_name[] = {
328341
[CURRENT_Q] = "current_q",
329342
[CLEAR_ENABLE] = "clear_enable",
@@ -514,6 +527,8 @@ static int qm_mb(struct hisi_qm *qm, u8 cmd, dma_addr_t dma_addr, u16 queue,
514527
busy_unlock:
515528
mutex_unlock(&qm->mailbox_lock);
516529

530+
if (ret)
531+
atomic64_inc(&qm->debug.dfx.mb_err_cnt);
517532
return ret;
518533
}
519534

@@ -671,6 +686,7 @@ static irqreturn_t qm_irq(int irq, void *data)
671686
if (readl(qm->io_base + QM_VF_EQ_INT_SOURCE))
672687
return do_qm_irq(irq, data);
673688

689+
atomic64_inc(&qm->debug.dfx.err_irq_cnt);
674690
dev_err(&qm->pdev->dev, "invalid int source\n");
675691
qm_db(qm, 0, QM_DOORBELL_CMD_EQ, qm->status.eq_head, 0);
676692

@@ -683,6 +699,7 @@ static irqreturn_t qm_aeq_irq(int irq, void *data)
683699
struct qm_aeqe *aeqe = qm->aeqe + qm->status.aeq_head;
684700
u32 type;
685701

702+
atomic64_inc(&qm->debug.dfx.aeq_irq_cnt);
686703
if (!readl(qm->io_base + QM_VF_AEQ_INT_SOURCE))
687704
return IRQ_NONE;
688705

@@ -1192,13 +1209,15 @@ static struct hisi_qp *qm_create_qp_nolock(struct hisi_qm *qm, u8 alg_type)
11921209
if (qm->qp_in_used == qm->qp_num) {
11931210
dev_info_ratelimited(dev, "All %u queues of QM are busy!\n",
11941211
qm->qp_num);
1212+
atomic64_inc(&qm->debug.dfx.create_qp_err_cnt);
11951213
return ERR_PTR(-EBUSY);
11961214
}
11971215

11981216
qp_id = idr_alloc_cyclic(&qm->qp_idr, NULL, 0, qm->qp_num, GFP_ATOMIC);
11991217
if (qp_id < 0) {
12001218
dev_info_ratelimited(dev, "All %u queues of QM are busy!\n",
12011219
qm->qp_num);
1220+
atomic64_inc(&qm->debug.dfx.create_qp_err_cnt);
12021221
return ERR_PTR(-EBUSY);
12031222
}
12041223

@@ -2249,6 +2268,26 @@ int hisi_qm_stop(struct hisi_qm *qm)
22492268
}
22502269
EXPORT_SYMBOL_GPL(hisi_qm_stop);
22512270

2271+
static int qm_debugfs_atomic64_set(void *data, u64 val)
2272+
{
2273+
if (val)
2274+
return -EINVAL;
2275+
2276+
atomic64_set((atomic64_t *)data, 0);
2277+
2278+
return 0;
2279+
}
2280+
2281+
static int qm_debugfs_atomic64_get(void *data, u64 *val)
2282+
{
2283+
*val = atomic64_read((atomic64_t *)data);
2284+
2285+
return 0;
2286+
}
2287+
2288+
DEFINE_DEBUGFS_ATTRIBUTE(qm_atomic64_ops, qm_debugfs_atomic64_get,
2289+
qm_debugfs_atomic64_set, "%llu\n");
2290+
22522291
/**
22532292
* hisi_qm_debug_init() - Initialize qm related debugfs files.
22542293
* @qm: The qm for which we want to add debugfs files.
@@ -2257,7 +2296,9 @@ EXPORT_SYMBOL_GPL(hisi_qm_stop);
22572296
*/
22582297
int hisi_qm_debug_init(struct hisi_qm *qm)
22592298
{
2299+
struct qm_dfx *dfx = &qm->debug.dfx;
22602300
struct dentry *qm_d;
2301+
void *data;
22612302
int i, ret;
22622303

22632304
qm_d = debugfs_create_dir("qm", qm->debug.debug_root);
@@ -2273,6 +2314,15 @@ int hisi_qm_debug_init(struct hisi_qm *qm)
22732314

22742315
debugfs_create_file("qm_regs", 0444, qm->debug.qm_d, qm, &qm_regs_fops);
22752316

2317+
for (i = 0; i < ARRAY_SIZE(qm_dfx_files); i++) {
2318+
data = (atomic64_t *)((uintptr_t)dfx + qm_dfx_files[i].offset);
2319+
debugfs_create_file(qm_dfx_files[i].name,
2320+
0644,
2321+
qm_d,
2322+
data,
2323+
&qm_atomic64_ops);
2324+
}
2325+
22762326
return 0;
22772327

22782328
failed_to_create:
@@ -3311,6 +3361,7 @@ static irqreturn_t qm_abnormal_irq(int irq, void *data)
33113361
struct hisi_qm *qm = data;
33123362
enum acc_err_result ret;
33133363

3364+
atomic64_inc(&qm->debug.dfx.abnormal_irq_cnt);
33143365
ret = qm_process_dev_error(qm);
33153366
if (ret == ACC_ERR_NEED_RESET)
33163367
schedule_work(&qm->rst_work);

drivers/crypto/hisilicon/qm.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,14 @@ enum qm_debug_file {
121121
DEBUG_FILE_NUM,
122122
};
123123

124+
struct qm_dfx {
125+
atomic64_t err_irq_cnt;
126+
atomic64_t aeq_irq_cnt;
127+
atomic64_t abnormal_irq_cnt;
128+
atomic64_t create_qp_err_cnt;
129+
atomic64_t mb_err_cnt;
130+
};
131+
124132
struct debugfs_file {
125133
enum qm_debug_file index;
126134
struct mutex lock;
@@ -129,6 +137,7 @@ struct debugfs_file {
129137

130138
struct qm_debug {
131139
u32 curr_qm_qp_num;
140+
struct qm_dfx dfx;
132141
struct dentry *debug_root;
133142
struct dentry *qm_d;
134143
struct debugfs_file files[DEBUG_FILE_NUM];

0 commit comments

Comments
 (0)