提交 f34ae074 编写于 作者: W Weili Qian 提交者: Zheng Zengkai

crypto: hisilicon - using 'debugfs_create_file' instead of 'debugfs_create_regset32'

mainline inclusion
from mainline-master
commit 1295292d
category: feature
bugzilla: https://gitee.com/openeuler/kernel/issues/I475PF?from=project-issue
CVE: NA

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git/commit/?id=1295292d65b729fc8b234fcdf884d79ff5a63ca1

----------------------------------------------------------------------

The accelerator devices support runtime PM, when device is in suspended, an
exception will occur if reading registers. Therefore, this patch uses
'debugfs_create_file' instead of 'debugfs_create_regset32' to create
debugfs file, and then the driver can get the device status before
reading the register.
Signed-off-by: NWeili Qian <qianweili@huawei.com>
Signed-off-by: NHerbert Xu <herbert@gondor.apana.org.au>
Reviewed-by: NHao Fang <fanghao11@huawei.com>
Reviewed-by: NMingqiang Ling <lingmingqiang@huawei.com>
Signed-off-by: NZheng Zengkai <zhengzengkai@huawei.com>
上级 6619ec0b
...@@ -763,6 +763,24 @@ static int hpre_debugfs_atomic64_set(void *data, u64 val) ...@@ -763,6 +763,24 @@ static int hpre_debugfs_atomic64_set(void *data, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(hpre_atomic64_ops, hpre_debugfs_atomic64_get, DEFINE_DEBUGFS_ATTRIBUTE(hpre_atomic64_ops, hpre_debugfs_atomic64_get,
hpre_debugfs_atomic64_set, "%llu\n"); hpre_debugfs_atomic64_set, "%llu\n");
static int hpre_com_regs_show(struct seq_file *s, void *unused)
{
hisi_qm_regs_dump(s, s->private);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(hpre_com_regs);
static int hpre_cluster_regs_show(struct seq_file *s, void *unused)
{
hisi_qm_regs_dump(s, s->private);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(hpre_cluster_regs);
static int hpre_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir, static int hpre_create_debugfs_file(struct hisi_qm *qm, struct dentry *dir,
enum hpre_ctrl_dbgfs_file type, int indx) enum hpre_ctrl_dbgfs_file type, int indx)
{ {
...@@ -801,7 +819,9 @@ static int hpre_pf_comm_regs_debugfs_init(struct hisi_qm *qm) ...@@ -801,7 +819,9 @@ static int hpre_pf_comm_regs_debugfs_init(struct hisi_qm *qm)
regset->nregs = ARRAY_SIZE(hpre_com_dfx_regs); regset->nregs = ARRAY_SIZE(hpre_com_dfx_regs);
regset->base = qm->io_base; regset->base = qm->io_base;
debugfs_create_regset32("regs", 0444, qm->debug.debug_root, regset); debugfs_create_file("regs", 0444, qm->debug.debug_root,
regset, &hpre_com_regs_fops);
return 0; return 0;
} }
...@@ -828,7 +848,8 @@ static int hpre_cluster_debugfs_init(struct hisi_qm *qm) ...@@ -828,7 +848,8 @@ static int hpre_cluster_debugfs_init(struct hisi_qm *qm)
regset->nregs = ARRAY_SIZE(hpre_cluster_dfx_regs); regset->nregs = ARRAY_SIZE(hpre_cluster_dfx_regs);
regset->base = qm->io_base + hpre_cluster_offsets[i]; regset->base = qm->io_base + hpre_cluster_offsets[i];
debugfs_create_regset32("regs", 0444, tmp_d, regset); debugfs_create_file("regs", 0444, tmp_d, regset,
&hpre_cluster_regs_fops);
ret = hpre_create_debugfs_file(qm, tmp_d, HPRE_CLUSTER_CTRL, ret = hpre_create_debugfs_file(qm, tmp_d, HPRE_CLUSTER_CTRL,
i + HPRE_CLUSTER_CTRL); i + HPRE_CLUSTER_CTRL);
if (ret) if (ret)
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
#include <linux/acpi.h> #include <linux/acpi.h>
#include <linux/aer.h> #include <linux/aer.h>
#include <linux/bitmap.h> #include <linux/bitmap.h>
#include <linux/debugfs.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/idr.h> #include <linux/idr.h>
#include <linux/io.h> #include <linux/io.h>
...@@ -1337,13 +1336,8 @@ static const struct file_operations qm_debug_fops = { ...@@ -1337,13 +1336,8 @@ static const struct file_operations qm_debug_fops = {
.write = qm_debug_write, .write = qm_debug_write,
}; };
struct qm_dfx_registers {
char *reg_name;
u64 reg_offset;
};
#define CNT_CYC_REGS_NUM 10 #define CNT_CYC_REGS_NUM 10
static struct qm_dfx_registers qm_dfx_regs[] = { static const struct debugfs_reg32 qm_dfx_regs[] = {
/* XXX_CNT are reading clear register */ /* XXX_CNT are reading clear register */
{"QM_ECC_1BIT_CNT ", 0x104000ull}, {"QM_ECC_1BIT_CNT ", 0x104000ull},
{"QM_ECC_MBIT_CNT ", 0x104008ull}, {"QM_ECC_MBIT_CNT ", 0x104008ull},
...@@ -1369,31 +1363,49 @@ static struct qm_dfx_registers qm_dfx_regs[] = { ...@@ -1369,31 +1363,49 @@ static struct qm_dfx_registers qm_dfx_regs[] = {
{"QM_DFX_FF_ST5 ", 0x1040dcull}, {"QM_DFX_FF_ST5 ", 0x1040dcull},
{"QM_DFX_FF_ST6 ", 0x1040e0ull}, {"QM_DFX_FF_ST6 ", 0x1040e0ull},
{"QM_IN_IDLE_ST ", 0x1040e4ull}, {"QM_IN_IDLE_ST ", 0x1040e4ull},
{ NULL, 0}
}; };
static struct qm_dfx_registers qm_vf_dfx_regs[] = { static const struct debugfs_reg32 qm_vf_dfx_regs[] = {
{"QM_DFX_FUNS_ACTIVE_ST ", 0x200ull}, {"QM_DFX_FUNS_ACTIVE_ST ", 0x200ull},
{ NULL, 0}
}; };
static int qm_regs_show(struct seq_file *s, void *unused) /**
* hisi_qm_regs_dump() - Dump registers's value.
* @s: debugfs file handle.
* @regset: accelerator registers information.
*
* Dump accelerator registers.
*/
void hisi_qm_regs_dump(struct seq_file *s, struct debugfs_regset32 *regset)
{ {
struct hisi_qm *qm = s->private; const struct debugfs_reg32 *regs = regset->regs;
struct qm_dfx_registers *regs; int regs_len = regset->nregs;
u32 val; u32 val;
int i;
if (qm->fun_type == QM_HW_PF) for (i = 0; i < regs_len; i++) {
regs = qm_dfx_regs; val = readl(regset->base + regs[i].offset);
else seq_printf(s, "%s= 0x%08x\n", regs[i].name, val);
regs = qm_vf_dfx_regs; }
}
EXPORT_SYMBOL_GPL(hisi_qm_regs_dump);
while (regs->reg_name) { static int qm_regs_show(struct seq_file *s, void *unused)
val = readl(qm->io_base + regs->reg_offset); {
seq_printf(s, "%s= 0x%08x\n", regs->reg_name, val); struct hisi_qm *qm = s->private;
regs++; struct debugfs_regset32 regset;
if (qm->fun_type == QM_HW_PF) {
regset.regs = qm_dfx_regs;
regset.nregs = ARRAY_SIZE(qm_dfx_regs);
} else {
regset.regs = qm_vf_dfx_regs;
regset.nregs = ARRAY_SIZE(qm_vf_dfx_regs);
} }
regset.base = qm->io_base;
hisi_qm_regs_dump(s, &regset);
return 0; return 0;
} }
...@@ -4245,7 +4257,7 @@ EXPORT_SYMBOL_GPL(hisi_qm_debug_init); ...@@ -4245,7 +4257,7 @@ EXPORT_SYMBOL_GPL(hisi_qm_debug_init);
*/ */
void hisi_qm_debug_regs_clear(struct hisi_qm *qm) void hisi_qm_debug_regs_clear(struct hisi_qm *qm)
{ {
struct qm_dfx_registers *regs; const struct debugfs_reg32 *regs;
int i; int i;
/* clear current_qm */ /* clear current_qm */
...@@ -4264,7 +4276,7 @@ void hisi_qm_debug_regs_clear(struct hisi_qm *qm) ...@@ -4264,7 +4276,7 @@ void hisi_qm_debug_regs_clear(struct hisi_qm *qm)
regs = qm_dfx_regs; regs = qm_dfx_regs;
for (i = 0; i < CNT_CYC_REGS_NUM; i++) { for (i = 0; i < CNT_CYC_REGS_NUM; i++) {
readl(qm->io_base + regs->reg_offset); readl(qm->io_base + regs->offset);
regs++; regs++;
} }
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
#define HISI_ACC_QM_H #define HISI_ACC_QM_H
#include <linux/bitfield.h> #include <linux/bitfield.h>
#include <linux/debugfs.h>
#include <linux/iopoll.h> #include <linux/iopoll.h>
#include <linux/module.h> #include <linux/module.h>
#include <linux/pci.h> #include <linux/pci.h>
...@@ -430,4 +431,5 @@ void hisi_qm_dev_shutdown(struct pci_dev *pdev); ...@@ -430,4 +431,5 @@ void hisi_qm_dev_shutdown(struct pci_dev *pdev);
void hisi_qm_wait_task_finish(struct hisi_qm *qm, struct hisi_qm_list *qm_list); void hisi_qm_wait_task_finish(struct hisi_qm *qm, struct hisi_qm_list *qm_list);
int hisi_qm_alg_register(struct hisi_qm *qm, struct hisi_qm_list *qm_list); int hisi_qm_alg_register(struct hisi_qm *qm, struct hisi_qm_list *qm_list);
void hisi_qm_alg_unregister(struct hisi_qm *qm, struct hisi_qm_list *qm_list); void hisi_qm_alg_unregister(struct hisi_qm *qm, struct hisi_qm_list *qm_list);
void hisi_qm_regs_dump(struct seq_file *s, struct debugfs_regset32 *regset);
#endif #endif
...@@ -676,6 +676,15 @@ static int sec_debugfs_atomic64_set(void *data, u64 val) ...@@ -676,6 +676,15 @@ static int sec_debugfs_atomic64_set(void *data, u64 val)
DEFINE_DEBUGFS_ATTRIBUTE(sec_atomic64_ops, sec_debugfs_atomic64_get, DEFINE_DEBUGFS_ATTRIBUTE(sec_atomic64_ops, sec_debugfs_atomic64_get,
sec_debugfs_atomic64_set, "%lld\n"); sec_debugfs_atomic64_set, "%lld\n");
static int sec_regs_show(struct seq_file *s, void *unused)
{
hisi_qm_regs_dump(s, s->private);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(sec_regs);
static int sec_core_debug_init(struct hisi_qm *qm) static int sec_core_debug_init(struct hisi_qm *qm)
{ {
struct sec_dev *sec = container_of(qm, struct sec_dev, qm); struct sec_dev *sec = container_of(qm, struct sec_dev, qm);
...@@ -696,7 +705,7 @@ static int sec_core_debug_init(struct hisi_qm *qm) ...@@ -696,7 +705,7 @@ static int sec_core_debug_init(struct hisi_qm *qm)
regset->base = qm->io_base; regset->base = qm->io_base;
if (qm->pdev->device == SEC_PF_PCI_DEVICE_ID) if (qm->pdev->device == SEC_PF_PCI_DEVICE_ID)
debugfs_create_regset32("regs", 0444, tmp_d, regset); debugfs_create_file("regs", 0444, tmp_d, regset, &sec_regs_fops);
for (i = 0; i < ARRAY_SIZE(sec_dfx_labels); i++) { for (i = 0; i < ARRAY_SIZE(sec_dfx_labels); i++) {
atomic64_t *data = (atomic64_t *)((uintptr_t)dfx + atomic64_t *data = (atomic64_t *)((uintptr_t)dfx +
......
...@@ -564,6 +564,15 @@ static int zip_debugfs_atomic64_get(void *data, u64 *val) ...@@ -564,6 +564,15 @@ static int zip_debugfs_atomic64_get(void *data, u64 *val)
DEFINE_DEBUGFS_ATTRIBUTE(zip_atomic64_ops, zip_debugfs_atomic64_get, DEFINE_DEBUGFS_ATTRIBUTE(zip_atomic64_ops, zip_debugfs_atomic64_get,
zip_debugfs_atomic64_set, "%llu\n"); zip_debugfs_atomic64_set, "%llu\n");
static int hisi_zip_regs_show(struct seq_file *s, void *unused)
{
hisi_qm_regs_dump(s, s->private);
return 0;
}
DEFINE_SHOW_ATTRIBUTE(hisi_zip_regs);
static int hisi_zip_core_debug_init(struct hisi_qm *qm) static int hisi_zip_core_debug_init(struct hisi_qm *qm)
{ {
struct device *dev = &qm->pdev->dev; struct device *dev = &qm->pdev->dev;
...@@ -588,7 +597,8 @@ static int hisi_zip_core_debug_init(struct hisi_qm *qm) ...@@ -588,7 +597,8 @@ static int hisi_zip_core_debug_init(struct hisi_qm *qm)
regset->base = qm->io_base + core_offsets[i]; regset->base = qm->io_base + core_offsets[i];
tmp_d = debugfs_create_dir(buf, qm->debug.debug_root); tmp_d = debugfs_create_dir(buf, qm->debug.debug_root);
debugfs_create_regset32("regs", 0444, tmp_d, regset); debugfs_create_file("regs", 0444, tmp_d, regset,
&hisi_zip_regs_fops);
} }
return 0; return 0;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册
新手
引导
客服 返回
顶部