Re: [PATCH] crypto: hisilicon - check if debugfs opened

2021-03-30 Thread Greg KH
On Tue, Mar 30, 2021 at 08:40:07PM +0800, tanghui20 wrote:
> 
> 
> On 2021/3/30 20:23, Greg KH wrote:
> > On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:
> > > 
> > > 
> > > On 2021/3/28 23:09, Greg KH wrote:
> > > > On Sat, Mar 27, 2021 at 04:33:00PM +0800, Hui Tang wrote:
> > > > > 'xx_debugfs_init' check if debugfs opened.
> > > > > 
> > > > > Signed-off-by: Hui Tang 
> > > > > ---
> > > > >  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(-)
> > > > > 
> > > > > diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
> > > > > b/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > > > index c7ab06d..f2605c4 100644
> > > > > --- a/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > > > +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > > > @@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
> > > > >   struct device *dev = >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?
> > > > 
> > > 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'.

Never, you should not care about that at all.

thanks,

greg k-h


Re: [PATCH] crypto: hisilicon - check if debugfs opened

2021-03-30 Thread tanghui20




On 2021/3/30 20:23, Greg KH wrote:

On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:



On 2021/3/28 23:09, Greg KH wrote:

On Sat, Mar 27, 2021 at 04:33:00PM +0800, Hui Tang wrote:

'xx_debugfs_init' check if debugfs opened.

Signed-off-by: Hui Tang 
---
 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(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index c7ab06d..f2605c4 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
struct device *dev = >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?


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


Re: [PATCH] crypto: hisilicon - check if debugfs opened

2021-03-30 Thread Greg KH
On Tue, Mar 30, 2021 at 08:09:46PM +0800, tanghui20 wrote:
> 
> 
> On 2021/3/28 23:09, Greg KH wrote:
> > On Sat, Mar 27, 2021 at 04:33:00PM +0800, Hui Tang wrote:
> > > 'xx_debugfs_init' check if debugfs opened.
> > > 
> > > Signed-off-by: Hui Tang 
> > > ---
> > >  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(-)
> > > 
> > > diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
> > > b/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > index c7ab06d..f2605c4 100644
> > > --- a/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
> > > @@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
> > >   struct device *dev = >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?
> > 
> 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


Re: [PATCH] crypto: hisilicon - check if debugfs opened

2021-03-30 Thread tanghui20




On 2021/3/28 23:09, Greg KH wrote:

On Sat, Mar 27, 2021 at 04:33:00PM +0800, Hui Tang wrote:

'xx_debugfs_init' check if debugfs opened.

Signed-off-by: Hui Tang 
---
 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(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index c7ab06d..f2605c4 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
struct device *dev = >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?


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.


Re: [PATCH] crypto: hisilicon - check if debugfs opened

2021-03-28 Thread Greg KH
On Sat, Mar 27, 2021 at 04:33:00PM +0800, Hui Tang wrote:
> 'xx_debugfs_init' check if debugfs opened.
> 
> Signed-off-by: Hui Tang 
> ---
>  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(-)
> 
> diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
> b/drivers/crypto/hisilicon/hpre/hpre_main.c
> index c7ab06d..f2605c4 100644
> --- a/drivers/crypto/hisilicon/hpre/hpre_main.c
> +++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
> @@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
>   struct device *dev = >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


[PATCH] crypto: hisilicon - check if debugfs opened

2021-03-27 Thread Hui Tang
'xx_debugfs_init' check if debugfs opened.

Signed-off-by: Hui Tang 
---
 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(-)

diff --git a/drivers/crypto/hisilicon/hpre/hpre_main.c 
b/drivers/crypto/hisilicon/hpre/hpre_main.c
index c7ab06d..f2605c4 100644
--- a/drivers/crypto/hisilicon/hpre/hpre_main.c
+++ b/drivers/crypto/hisilicon/hpre/hpre_main.c
@@ -779,6 +779,9 @@ static int hpre_debugfs_init(struct hisi_qm *qm)
struct device *dev = >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(>dev, "init debugfs fail!\n");
+   dev_warn(>dev, "init debugfs fail (%d)!\n", ret);
 
ret = hisi_qm_alg_register(qm, _devices);
if (ret < 0) {
diff --git a/drivers/crypto/hisilicon/qm.c b/drivers/crypto/hisilicon/qm.c
index bc23174..14f2656 100644
--- a/drivers/crypto/hisilicon/qm.c
+++ b/drivers/crypto/hisilicon/qm.c
@@ -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;
 
diff --git a/drivers/crypto/hisilicon/sec2/sec_main.c 
b/drivers/crypto/hisilicon/sec2/sec_main.c
index 78a6043..226475d 100644
--- a/drivers/crypto/hisilicon/sec2/sec_main.c
+++ b/drivers/crypto/hisilicon/sec2/sec_main.c
@@ -695,6 +695,9 @@ static int sec_debugfs_init(struct hisi_qm *qm)
struct device *dev = >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, _devices);
if (ret < 0) {
diff --git a/drivers/crypto/hisilicon/zip/zip_main.c 
b/drivers/crypto/hisilicon/zip/zip_main.c
index 02c44572..4b111c0 100644
--- a/drivers/crypto/hisilicon/zip/zip_main.c
+++ b/drivers/crypto/hisilicon/zip/zip_main.c
@@ -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;
-- 
2.8.1