[02/11] crypto: ccp - Add a module parameter to specify a queue count
diff mbox series

Message ID 156140452269.116890.16300533767199946313.stgit@sosrh3.amd.com
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series
  • Add module parameters to control CCP activation
Related show

Commit Message

Gary R Hook June 24, 2019, 7:28 p.m. UTC
Add a module parameter to limit the number of queues per CCP. The default
(nqueues=0) is to set up every available queue on each device.

The count of queues starts from the first one found on the device (which
is based on the device ID).

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 drivers/crypto/ccp/ccp-dev-v5.c |    9 ++++++++-
 drivers/crypto/ccp/ccp-dev.h    |   15 +++++++++++++++
 drivers/crypto/ccp/sp-pci.c     |   15 ++++++++++++++-
 3 files changed, 37 insertions(+), 2 deletions(-)

Comments

Tom Lendacky June 24, 2019, 9:54 p.m. UTC | #1
On 6/24/19 2:28 PM, Hook, Gary wrote:
> Add a module parameter to limit the number of queues per CCP. The default
> (nqueues=0) is to set up every available queue on each device.

This doesn't match the code...  nqueues defaults to MAX_HW_QUEUES below.
The way it is coded nqueues=0 and nqueues=1 are exactly the same.

> 
> The count of queues starts from the first one found on the device (which
> is based on the device ID).
> 
> Signed-off-by: Gary R Hook <gary.hook@amd.com>
> ---
>  drivers/crypto/ccp/ccp-dev-v5.c |    9 ++++++++-
>  drivers/crypto/ccp/ccp-dev.h    |   15 +++++++++++++++
>  drivers/crypto/ccp/sp-pci.c     |   15 ++++++++++++++-
>  3 files changed, 37 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
> index a5bd11831b80..ffd546b951b6 100644
> --- a/drivers/crypto/ccp/ccp-dev-v5.c
> +++ b/drivers/crypto/ccp/ccp-dev-v5.c
> @@ -14,12 +14,15 @@
>  #include <linux/kernel.h>
>  #include <linux/pci.h>
>  #include <linux/kthread.h>
> -#include <linux/debugfs.h>
>  #include <linux/dma-mapping.h>
>  #include <linux/interrupt.h>
>  #include <linux/compiler.h>
>  #include <linux/ccp.h>
>  
> +#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
> +#include <linux/debugfs.h>
> +#endif
> +

This belongs in the first patch.

>  #include "ccp-dev.h"
>  
>  /* Allocate the requested number of contiguous LSB slots
> @@ -784,6 +787,7 @@ static irqreturn_t ccp5_irq_handler(int irq, void *data)
>  
>  static int ccp5_init(struct ccp_device *ccp)
>  {
> +	unsigned int nqueues = ccp_get_nqueues_param();
>  	struct device *dev = ccp->dev;
>  	struct ccp_cmd_queue *cmd_q;
>  	struct dma_pool *dma_pool;
> @@ -856,6 +860,9 @@ static int ccp5_init(struct ccp_device *ccp)
>  		init_waitqueue_head(&cmd_q->int_queue);
>  
>  		dev_dbg(dev, "queue #%u available\n", i);
> +
> +		if (ccp->cmd_q_count >= nqueues)
> +			break;

In reference to my comment above, this is where nqueues=0 or 1 results
in the same thing happening.

>  	}
>  
>  	if (ccp->cmd_q_count == 0) {
> diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
> index 6810b65c1939..d812446213ee 100644
> --- a/drivers/crypto/ccp/ccp-dev.h
> +++ b/drivers/crypto/ccp/ccp-dev.h
> @@ -632,6 +632,8 @@ struct ccp5_desc {
>  void ccp_add_device(struct ccp_device *ccp);
>  void ccp_del_device(struct ccp_device *ccp);
>  
> +unsigned int ccp_get_nqueues_param(void);
> +
>  extern void ccp_log_error(struct ccp_device *, int);
>  
>  struct ccp_device *ccp_alloc_struct(struct sp_device *sp);
> @@ -671,4 +673,17 @@ extern const struct ccp_vdata ccpv3;
>  extern const struct ccp_vdata ccpv5a;
>  extern const struct ccp_vdata ccpv5b;
>  
> +
> +#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
> +
> +/* DebugFS stuff */
> +typedef struct _modparam {
> +                char *paramname;
> +                void *param;
> +                umode_t parammode;
> +        } modparam_t;
> +extern void ccp_debugfs_register_modparams(struct dentry *parentdir);
> +
> +#endif
> +

You've created this typedef/struct (which should be just a struct, not
a typedef) which isn't used and reference to a function that doesn't exist
yet.

>  #endif
> diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
> index 41bce0a3f4bb..3fab79585f72 100644
> --- a/drivers/crypto/ccp/sp-pci.c
> +++ b/drivers/crypto/ccp/sp-pci.c
> @@ -1,7 +1,9 @@
> +// SPDX-License-Identifier: GPL-2.0
> +
>  /*
>   * AMD Secure Processor device driver
>   *
> - * Copyright (C) 2013,2018 Advanced Micro Devices, Inc.
> + * Copyright (C) 2013,2019 Advanced Micro Devices, Inc.
>   *
>   * Author: Tom Lendacky <thomas.lendacky@amd.com>
>   * Author: Gary R Hook <gary.hook@amd.com>
> @@ -27,6 +29,17 @@
>  #include "ccp-dev.h"
>  #include "psp-dev.h"
>  
> +/*
> + * Limit CCP use to a specifed number of queues per device.
> + */
> +static unsigned int nqueues = MAX_HW_QUEUES;
> +module_param(nqueues, uint, 0444);
> +MODULE_PARM_DESC(nqueues, "Number of queues per CCP (default: 5)");
> +
> +unsigned int ccp_get_nqueues_param(void) {
> +	return nqueues;
> +}
> +

You should define this module parameter in the file where it is used and
then you won't need the function.

Thanks,
Tom

>  #define MSIX_VECTORS			2
>  
>  struct sp_pci {
>

Patch
diff mbox series

diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index a5bd11831b80..ffd546b951b6 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -14,12 +14,15 @@ 
 #include <linux/kernel.h>
 #include <linux/pci.h>
 #include <linux/kthread.h>
-#include <linux/debugfs.h>
 #include <linux/dma-mapping.h>
 #include <linux/interrupt.h>
 #include <linux/compiler.h>
 #include <linux/ccp.h>
 
+#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
+#include <linux/debugfs.h>
+#endif
+
 #include "ccp-dev.h"
 
 /* Allocate the requested number of contiguous LSB slots
@@ -784,6 +787,7 @@  static irqreturn_t ccp5_irq_handler(int irq, void *data)
 
 static int ccp5_init(struct ccp_device *ccp)
 {
+	unsigned int nqueues = ccp_get_nqueues_param();
 	struct device *dev = ccp->dev;
 	struct ccp_cmd_queue *cmd_q;
 	struct dma_pool *dma_pool;
@@ -856,6 +860,9 @@  static int ccp5_init(struct ccp_device *ccp)
 		init_waitqueue_head(&cmd_q->int_queue);
 
 		dev_dbg(dev, "queue #%u available\n", i);
+
+		if (ccp->cmd_q_count >= nqueues)
+			break;
 	}
 
 	if (ccp->cmd_q_count == 0) {
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index 6810b65c1939..d812446213ee 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -632,6 +632,8 @@  struct ccp5_desc {
 void ccp_add_device(struct ccp_device *ccp);
 void ccp_del_device(struct ccp_device *ccp);
 
+unsigned int ccp_get_nqueues_param(void);
+
 extern void ccp_log_error(struct ccp_device *, int);
 
 struct ccp_device *ccp_alloc_struct(struct sp_device *sp);
@@ -671,4 +673,17 @@  extern const struct ccp_vdata ccpv3;
 extern const struct ccp_vdata ccpv5a;
 extern const struct ccp_vdata ccpv5b;
 
+
+#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
+
+/* DebugFS stuff */
+typedef struct _modparam {
+                char *paramname;
+                void *param;
+                umode_t parammode;
+        } modparam_t;
+extern void ccp_debugfs_register_modparams(struct dentry *parentdir);
+
+#endif
+
 #endif
diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index 41bce0a3f4bb..3fab79585f72 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -1,7 +1,9 @@ 
+// SPDX-License-Identifier: GPL-2.0
+
 /*
  * AMD Secure Processor device driver
  *
- * Copyright (C) 2013,2018 Advanced Micro Devices, Inc.
+ * Copyright (C) 2013,2019 Advanced Micro Devices, Inc.
  *
  * Author: Tom Lendacky <thomas.lendacky@amd.com>
  * Author: Gary R Hook <gary.hook@amd.com>
@@ -27,6 +29,17 @@ 
 #include "ccp-dev.h"
 #include "psp-dev.h"
 
+/*
+ * Limit CCP use to a specifed number of queues per device.
+ */
+static unsigned int nqueues = MAX_HW_QUEUES;
+module_param(nqueues, uint, 0444);
+MODULE_PARM_DESC(nqueues, "Number of queues per CCP (default: 5)");
+
+unsigned int ccp_get_nqueues_param(void) {
+	return nqueues;
+}
+
 #define MSIX_VECTORS			2
 
 struct sp_pci {