]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
crypto: hisilicon/qm - support get device state
authorWeili Qian <qianweili@huawei.com>
Fri, 12 Jan 2024 10:25:45 +0000 (18:25 +0800)
committerHerbert Xu <herbert@gondor.apana.org.au>
Fri, 26 Jan 2024 08:39:32 +0000 (16:39 +0800)
Support get device current state. The value 0 indicates that
the device is busy, and the value 1 indicates that the
device is idle. When the device is in suspended, 1 is returned.

Signed-off-by: Weili Qian <qianweili@huawei.com>
Signed-off-by: Herbert Xu <herbert@gondor.apana.org.au>
Documentation/ABI/testing/debugfs-hisi-hpre
Documentation/ABI/testing/debugfs-hisi-sec
Documentation/ABI/testing/debugfs-hisi-zip
drivers/crypto/hisilicon/debugfs.c

index 8e8de49c5cc6698704057de6ade9f339898873ce..6ed9258605c70976c7d5673dbbf775274431251b 100644 (file)
@@ -111,6 +111,13 @@ Description:       QM debug registers(regs) read hardware register value. This
                node is used to show the change of the qm register values. This
                node can be help users to check the change of register values.
 
+What:          /sys/kernel/debug/hisi_hpre/<bdf>/qm/qm_state
+Date:          Jan 2024
+Contact:       linux-crypto@vger.kernel.org
+Description:   Dump the state of the device.
+               0: busy, 1: idle.
+               Only available for PF, and take no other effect on HPRE.
+
 What:          /sys/kernel/debug/hisi_hpre/<bdf>/hpre_dfx/diff_regs
 Date:          Mar 2022
 Contact:       linux-crypto@vger.kernel.org
index deeefe2c735ed7822856c5bea84a8e8909a5ec4e..403f5de96318026ccc793b134cc6be39a47c36df 100644 (file)
@@ -91,6 +91,13 @@ Description: QM debug registers(regs) read hardware register value. This
                node is used to show the change of the qm register values. This
                node can be help users to check the change of register values.
 
+What:          /sys/kernel/debug/hisi_sec2/<bdf>/qm/qm_state
+Date:          Jan 2024
+Contact:       linux-crypto@vger.kernel.org
+Description:   Dump the state of the device.
+               0: busy, 1: idle.
+               Only available for PF, and take no other effect on SEC.
+
 What:          /sys/kernel/debug/hisi_sec2/<bdf>/sec_dfx/diff_regs
 Date:          Mar 2022
 Contact:       linux-crypto@vger.kernel.org
index 593714afaed249327778ce82d8263893b8800884..2394e6a3cfe2f45a97b3f4f979865de4330b86ac 100644 (file)
@@ -104,6 +104,13 @@ Description:       QM debug registers(regs) read hardware register value. This
                node is used to show the change of the qm registers value. This
                node can be help users to check the change of register values.
 
+What:          /sys/kernel/debug/hisi_zip/<bdf>/qm/qm_state
+Date:          Jan 2024
+Contact:       linux-crypto@vger.kernel.org
+Description:   Dump the state of the device.
+               0: busy, 1: idle.
+               Only available for PF, and take no other effect on ZIP.
+
 What:          /sys/kernel/debug/hisi_zip/<bdf>/zip_dfx/diff_regs
 Date:          Mar 2022
 Contact:       linux-crypto@vger.kernel.org
index 80ed4b2d209cac85a4ad435bcf882c8bd5ba14d0..615c8e18d8b0e0d355f543aa95dac85c59297ac5 100644 (file)
@@ -24,6 +24,8 @@
 #define QM_DFX_QN_SHIFT                        16
 #define QM_DFX_CNT_CLR_CE              0x100118
 #define QM_DBG_WRITE_LEN               1024
+#define QM_IN_IDLE_ST_REG              0x1040e4
+#define QM_IN_IDLE_STATE               0x1
 
 static const char * const qm_debug_file_name[] = {
        [CURRENT_QM]   = "current_qm",
@@ -1001,6 +1003,30 @@ static int qm_diff_regs_show(struct seq_file *s, void *unused)
 }
 DEFINE_SHOW_ATTRIBUTE(qm_diff_regs);
 
+static int qm_state_show(struct seq_file *s, void *unused)
+{
+       struct hisi_qm *qm = s->private;
+       u32 val;
+       int ret;
+
+       /* If device is in suspended, directly return the idle state. */
+       ret = hisi_qm_get_dfx_access(qm);
+       if (!ret) {
+               val = readl(qm->io_base + QM_IN_IDLE_ST_REG);
+               hisi_qm_put_dfx_access(qm);
+       } else if (ret == -EAGAIN) {
+               val = QM_IN_IDLE_STATE;
+       } else {
+               return ret;
+       }
+
+       seq_printf(s, "%u\n", val);
+
+       return 0;
+}
+
+DEFINE_SHOW_ATTRIBUTE(qm_state);
+
 static ssize_t qm_status_read(struct file *filp, char __user *buffer,
                              size_t count, loff_t *pos)
 {
@@ -1072,6 +1098,9 @@ void hisi_qm_debug_init(struct hisi_qm *qm)
 
        /* only show this in PF */
        if (qm->fun_type == QM_HW_PF) {
+               debugfs_create_file("qm_state", 0444, qm->debug.qm_d,
+                                       qm, &qm_state_fops);
+
                qm_create_debugfs_file(qm, qm->debug.debug_root, CURRENT_QM);
                for (i = CURRENT_Q; i < DEBUG_FILE_NUM; i++)
                        qm_create_debugfs_file(qm, qm->debug.qm_d, i);