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@xxxxxxx> --- 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 + #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@xxxxxxx> * Author: Gary R Hook <gary.hook@xxxxxxx> @@ -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 {