Skip to contentSkip to conversation

crypto: hisilicon - check if debugfs opened

PATCH In review Hui Tang 2 participants 6 messages Mar 27, 2021 – Mar 30, 2021

Subsystems (5)
lore
Share & tools
lore

Hui Tang

author
#0 lore raw

PATCH 1/1 crypto: hisilicon - check if debugfs opened

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +4 -1
index c7ab06d..f2605c4 100644
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
+	if (!debugfs_initialized())
+		return -ENOENT;
+
 	qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
 						  hpre_debugfs_root);
 
@@ -949,7 +952,7 @@ static int hpre_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	ret = hpre_debugfs_init(qm);
 	if (ret)
-		dev_warn(&pdev->dev, "init debugfs fail!\n");
+		dev_warn(&pdev->dev, "init debugfs fail (%d)!\n", ret);
 
 	ret = hisi_qm_alg_register(qm, &hpre_devices);
 	if (ret < 0) {
drivers/crypto/hisilicon/qm.c +3 -0
index bc23174..14f2656 100644
@@ -2926,6 +2926,9 @@ void hisi_qm_debug_init(struct hisi_qm *qm)
 	void *data;
 	int i;
 
+	if (!debugfs_initialized())
+		return;
+
 	qm_d = debugfs_create_dir("qm", qm->debug.debug_root);
 	qm->debug.qm_d = qm_d;
 
drivers/crypto/hisilicon/sec2/sec_main.c +4 -1
index 78a6043..226475d 100644
@@ -695,6 +695,9 @@ static int sec_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
+	if (!debugfs_initialized())
+		return -ENOENT;
+
 	qm->debug.debug_root = debugfs_create_dir(dev_name(dev),
 						  sec_debugfs_root);
 	qm->debug.sqe_mask_offset = SEC_SQE_MASK_OFFSET;
@@ -928,7 +931,7 @@ static int sec_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	ret = sec_debugfs_init(qm);
 	if (ret)
-		pci_warn(pdev, "Failed to init debugfs!\n");
+		pci_warn(pdev, "Failed to init debugfs (%d)!\n", ret);
 
 	ret = hisi_qm_alg_register(qm, &sec_devices);
 	if (ret < 0) {
drivers/crypto/hisilicon/zip/zip_main.c +3 -0
index 02c44572..4b111c0 100644
@@ -600,6 +600,9 @@ static int hisi_zip_debugfs_init(struct hisi_qm *qm)
 	struct dentry *dev_d;
 	int ret;
 
+	if (!debugfs_initialized())
+		return -ENOENT;
+
 	dev_d = debugfs_create_dir(dev_name(dev), hzip_debugfs_root);
 
 	qm->debug.sqe_mask_offset = HZIP_SQE_MASK_OFFSET;
Signature · 1 line
2.8.1
#1 lore raw
Quoted 15 lines · Hui Tang

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +0 -0
index c7ab06d..f2605c4 100644

drivers/crypto/hisilicon/hpre/hpre_main.c static int hpre_debugfs_init(struct hisi_qm *qm) · line 783

Quoted 5 lines
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -0
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
+	if (!debugfs_initialized())
+		return -ENOENT;

Why? What does this help with? Why does the code care if debugfs is running or not?

thanks,

greg k-h

author
#2 lore raw
Quoted 19 lines · Greg KH
Quoted 18 lines · Hui Tang

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +0 -0
index c7ab06d..f2605c4 100644
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
Quoted 6 lines

drivers/crypto/hisilicon/hpre/hpre_main.c static int hpre_debugfs_init(struct hisi_qm *qm) · line 783

Quoted 2 lines
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -0
+	if (!debugfs_initialized())
+		return -ENOENT;

Why? What does this help with? Why does the code care if debugfs is running or not?

When !CONFIG_DEBUG_FS, there is no problem if debugfs is not checked, but if checking debugfs, a series of stub functions of debugfs can be skipped and 'xx_debugfs_init' will be return immediately.

Thanks.

#3 lore raw
Quoted 28 lines · On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:
Quoted 19 lines · Greg KH
Quoted 18 lines · Hui Tang

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +0 -0
index c7ab06d..f2605c4 100644
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
Quoted 6 lines

drivers/crypto/hisilicon/hpre/hpre_main.c static int hpre_debugfs_init(struct hisi_qm *qm) · line 783

Quoted 2 lines
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -0
+	if (!debugfs_initialized())
+		return -ENOENT;

Why? What does this help with? Why does the code care if debugfs is running or not?

Quoted 3 lines

When !CONFIG_DEBUG_FS, there is no problem if debugfs is not checked, but if checking debugfs, a series of stub functions of debugfs can be skipped and 'xx_debugfs_init' will be return immediately.

And have you measured an actual speed difference for that? I would be amazed if you could...

thanks,

greg k-h

author
#4 lore raw
Quoted 29 lines · Greg KH
Quoted 28 lines · On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:
Quoted 25 lines · Greg KH
Quoted 15 lines · Hui Tang

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +0 -0
index c7ab06d..f2605c4 100644

drivers/crypto/hisilicon/hpre/hpre_main.c static int hpre_debugfs_init(struct hisi_qm *qm) · line 783

Quoted 5 lines
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -0
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
+	if (!debugfs_initialized())
+		return -ENOENT;

Why? What does this help with? Why does the code care if debugfs is running or not?

Quoted 7 lines
Quoted 3 lines

When !CONFIG_DEBUG_FS, there is no problem if debugfs is not checked, but if checking debugfs, a series of stub functions of debugfs can be skipped and 'xx_debugfs_init' will be return immediately.

And have you measured an actual speed difference for that? I would be amazed if you could...

I think what you said makes sense.
I am confused when to use 'debugfs_initialized'.

Thanks

#5 lore raw
Quoted 36 lines · On Tue, Mar 30, 2021 at 08:40:07PM +0800, tanghui20 wrote:
Quoted 33 lines · Greg KH
Quoted 31 lines · On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:
Quoted 19 lines · Greg KH
Quoted 18 lines · Hui Tang

'xx_debugfs_init' check if debugfs opened.

---
 drivers/crypto/hisilicon/hpre/hpre_main.c | 5 ++++-
 drivers/crypto/hisilicon/qm.c             | 3 +++
 drivers/crypto/hisilicon/sec2/sec_main.c  | 5 ++++-
 drivers/crypto/hisilicon/zip/zip_main.c   | 3 +++
 4 files changed, 14 insertions(+), 2 deletions(-)
drivers/crypto/hisilicon/hpre/hpre_main.c +0 -0
index c7ab06d..f2605c4 100644
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
 	struct device *dev = &qm->pdev->dev;
 	int ret;
 
Quoted 6 lines

drivers/crypto/hisilicon/hpre/hpre_main.c static int hpre_debugfs_init(struct hisi_qm *qm) · line 783

Quoted 2 lines
drivers/crypto/hisilicon/hpre/hpre_main.c +2 -0
+	if (!debugfs_initialized())
+		return -ENOENT;

Why? What does this help with? Why does the code care if debugfs is running or not?

When !CONFIG_DEBUG_FS, there is no problem if debugfs is not checked, but if checking debugfs, a series of stub functions of debugfs can be skipped and 'xx_debugfs_init' will be return immediately.

Quoted 6 lines
Quoted 3 lines

And have you measured an actual speed difference for that? I would be amazed if you could...

I think what you said makes sense.
I am confused when to use 'debugfs_initialized'.

Never, you should not care about that at all.

thanks,

greg k-h