Received: by 2002:a25:868d:0:0:0:0:0 with SMTP id z13csp347672ybk; Fri, 15 May 2020 02:15:51 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyeYpg/5izCP8x21Utg7xwlTg5z/qQus1NaURUtjC5o3haM0EGIjPVJFsUrrOPxb/wrFTJE X-Received: by 2002:a05:6402:21cc:: with SMTP id bi12mr1855773edb.294.1589534151208; Fri, 15 May 2020 02:15:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1589534151; cv=none; d=google.com; s=arc-20160816; b=ZCwwk6263PjGwlENp03qfWEgFFNWUJh3cE4ZzwAUK8SCwpFEpNnI3Rp63NUvaH1HNH gY+5RyKCgLD4rxM/KWHUjQCnulirEsgRovousjWTmVGKy+lo0afBBWp+OJp2YjURMUk5 14AP0suLVaaIV5Dd9cQKPGfr3aSJ2MYOLimgbeiZSXy+XUg6MnGjCFK4i9xDY6c0lHA5 1BcMG7cMJhGAoT3Dl3/wXO48i6xiZoV5FL9o1T85KB4S2H7033A02ErioQu+XJwqPjmh xi0fyc56RDyeHNsNMPQyP1lj8G2B+021Cu8b95xIxN2mMua+P1n3U7jLFlB3eYC9aqO7 polQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from; bh=bHiHEkxZI8CLVrlI6omtZA1bjr6LAwHpoS3E1fS4Fxk=; b=LX22Bq4o+qY1NQYb3M/hjW5TlXd6EqHjHgldsw9Pd68rp2UZvbSvImWssqlxMM6966 itH0h/hK10DGdy5HcTQiQZFwnFlofjcc44sJi4pP2WLzO5kC2P5NB1DYsZYO8Jk6K8A6 4Qt6guHTtfA/kT2Tulxy5HLlVeICnrlkkX6VePissOOLD3X+Mub1S78Jx8QdxGQQQEms Md+rKWluzM633x1bkqb2n0WJdi8ys4+sBRoFPnz+nR4dWl9MQByPUg126rkkt+bbhrs0 Z00t6E2q6X0rNGB2PxqLj1ckFxqfL9RgRS4EQQ/hoZC3/6hxEPt5Q+aKUlWA1JNwbuun G+9Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id bt16si839328edb.7.2020.05.15.02.15.27; Fri, 15 May 2020 02:15:51 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-crypto-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-crypto-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727857AbgEOJPU (ORCPT + 99 others); Fri, 15 May 2020 05:15:20 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:4788 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727844AbgEOJPU (ORCPT ); Fri, 15 May 2020 05:15:20 -0400 Received: from DGGEMS405-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id CC07E23F0FED4B1D9E48; Fri, 15 May 2020 17:15:18 +0800 (CST) Received: from localhost.localdomain (10.69.192.56) by DGGEMS405-HUB.china.huawei.com (10.3.19.205) with Microsoft SMTP Server id 14.3.487.0; Fri, 15 May 2020 17:15:08 +0800 From: Shukun Tan To: , CC: , , Subject: [PATCH 2/7] crypto: hisilicon/qm - add debugfs to the QM state machine Date: Fri, 15 May 2020 17:13:55 +0800 Message-ID: <1589534040-50725-3-git-send-email-tanshukun1@huawei.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1589534040-50725-1-git-send-email-tanshukun1@huawei.com> References: <1589534040-50725-1-git-send-email-tanshukun1@huawei.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.69.192.56] X-CFilter-Loop: Reflected Sender: linux-crypto-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-crypto@vger.kernel.org From: Longfang Liu The QM driver uses debugfs to provides the current state of the QM state machine Signed-off-by: Longfang Liu Signed-off-by: Shukun Tan Reviewed-by: Zhou Wang --- Documentation/ABI/testing/debugfs-hisi-hpre | 7 ++++++ Documentation/ABI/testing/debugfs-hisi-sec | 7 ++++++ Documentation/ABI/testing/debugfs-hisi-zip | 7 ++++++ drivers/crypto/hisilicon/qm.c | 34 +++++++++++++++++++++++++++++ 4 files changed, 55 insertions(+) diff --git a/Documentation/ABI/testing/debugfs-hisi-hpre b/Documentation/ABI/testing/debugfs-hisi-hpre index 1f96665..093cf46 100644 --- a/Documentation/ABI/testing/debugfs-hisi-hpre +++ b/Documentation/ABI/testing/debugfs-hisi-hpre @@ -86,3 +86,10 @@ Date: Apr 2020 Contact: linux-crypto@vger.kernel.org Description: Dump the number of failed QM mailbox commands. Available for both PF and VF, and take no other effect on HPRE. + +What: /sys/kernel/debug/hisi_hpre//qm/status +Date: Apr 2020 +Contact: linux-crypto@vger.kernel.org +Description: Dump the status of the QM. + Four states: initiated, started, stopped and closed. + Available for both PF and VF, and take no other effect on HPRE. diff --git a/Documentation/ABI/testing/debugfs-hisi-sec b/Documentation/ABI/testing/debugfs-hisi-sec index c3ba09c..54699a1 100644 --- a/Documentation/ABI/testing/debugfs-hisi-sec +++ b/Documentation/ABI/testing/debugfs-hisi-sec @@ -72,3 +72,10 @@ Date: Apr 2020 Contact: linux-crypto@vger.kernel.org Description: Dump the number of failed QM mailbox commands. Available for both PF and VF, and take no other effect on SEC. + +What: /sys/kernel/debug/hisi_sec2//qm/status +Date: Apr 2020 +Contact: linux-crypto@vger.kernel.org +Description: Dump the status of the QM. + Four states: initiated, started, stopped and closed. + Available for both PF and VF, and take no other effect on SEC. diff --git a/Documentation/ABI/testing/debugfs-hisi-zip b/Documentation/ABI/testing/debugfs-hisi-zip index cc568fd..1002a01 100644 --- a/Documentation/ABI/testing/debugfs-hisi-zip +++ b/Documentation/ABI/testing/debugfs-hisi-zip @@ -79,3 +79,10 @@ Date: Apr 2020 Contact: linux-crypto@vger.kernel.org Description: Dump the number of failed QM mailbox commands. Available for both PF and VF, and take no other effect on ZIP. + +What: /sys/kernel/debug/hisi_zip//qm/status +Date: Apr 2020 +Contact: linux-crypto@vger.kernel.org +Description: Dump the status of the QM. + Four states: initiated, started, stopped and closed. + Available for both PF and VF, and take no other effect on ZIP. diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c index 744d131..7c1982f 100644 --- a/drivers/crypto/hisilicon/qm.c +++ b/drivers/crypto/hisilicon/qm.c @@ -175,6 +175,7 @@ #define QM_SQE_DATA_ALIGN_MASK GENMASK(6, 0) #define QMC_ALIGN(sz) ALIGN(sz, 32) +#define QM_DBG_READ_LEN 256 #define QM_DBG_TMP_BUF_LEN 22 #define QM_PCI_COMMAND_INVALID ~0 @@ -2268,6 +2269,37 @@ int hisi_qm_stop(struct hisi_qm *qm) } EXPORT_SYMBOL_GPL(hisi_qm_stop); +static ssize_t qm_status_read(struct file *filp, char __user *buffer, + size_t count, loff_t *pos) +{ + struct hisi_qm *qm = filp->private_data; + char buf[QM_DBG_READ_LEN]; + int val, cp_len, len; + + if (*pos) + return 0; + + if (count < QM_DBG_READ_LEN) + return -ENOSPC; + + val = atomic_read(&qm->status.flags); + len = snprintf(buf, QM_DBG_READ_LEN, "%s\n", qm_s[val]); + if (!len) + return -EFAULT; + + cp_len = copy_to_user(buffer, buf, len); + if (cp_len) + return -EFAULT; + + return (*pos = len); +} + +static const struct file_operations qm_status_fops = { + .owner = THIS_MODULE, + .open = simple_open, + .read = qm_status_read, +}; + static int qm_debugfs_atomic64_set(void *data, u64 val) { if (val) @@ -2314,6 +2346,8 @@ int hisi_qm_debug_init(struct hisi_qm *qm) debugfs_create_file("qm_regs", 0444, qm->debug.qm_d, qm, &qm_regs_fops); + debugfs_create_file("status", 0444, qm->debug.qm_d, qm, + &qm_status_fops); for (i = 0; i < ARRAY_SIZE(qm_dfx_files); i++) { data = (atomic64_t *)((uintptr_t)dfx + qm_dfx_files[i].offset); debugfs_create_file(qm_dfx_files[i].name, -- 2.7.4