Firstly, add a switch to allow/disallow debugfs code to be built
into the CCP driver.
This rest of the patch series implements a set of module parameters
that allow fine-tuned control over which CCPs on a system are enabled
by the driver, and how many queues on each device are activated.
Lastly, a switch to enable/disable DMA engine registration is implemented.
The new parameters are also exposed in DebugFS (when enabled).
Details:
nqueues: configure N queues per CCP (default: 0 - all queues enabled)
maxdev: maximum number of devices to enable (default: 0 - all devices activated)
pcidev: Only consider activating devices with the specified PCI ID (default: unset - all devices activated)
buses: Only consider activating devices on the specified PCI buses (default: unset - all devices activated)
dmareg: Register services with the DMA subsystem (default: true)
The maxdev, pcidev and buses parameters aggregate.
Only activated devices will have their DMA services registered.
---
Gary R Hook (11):
crypto: ccp - Make CCP debugfs support optional
crypto: ccp - Add a module parameter to specify a queue count
crypto: ccp - Expose the value of nqueues in DebugFS
crypto: ccp - module parameter to limit the number of enabled CCPs
crypto: ccp - Expose maxdev through DebugFS
crypto: ccp - Specify a single CCP via PCI device ID
crypto: ccp - expose the pcidev module parameter in debugfs
crypto: ccp - module parameter to allow CCP selection by PCI bus
crypto: ccp - expose pcibus module parameter in debugfs
crypto: ccp - Add a module parameter to control registration for DMA
crypto: ccp - Expose the registerdma module parameter in DFS
drivers/crypto/ccp/Kconfig | 9 ++
drivers/crypto/ccp/Makefile | 4 -
drivers/crypto/ccp/ccp-debugfs.c | 3 +
drivers/crypto/ccp/ccp-dev-v5.c | 24 ++++-
drivers/crypto/ccp/ccp-dev.h | 17 ++++
drivers/crypto/ccp/sp-pci.c | 172 ++++++++++++++++++++++++++++++++++++++
6 files changed, 221 insertions(+), 8 deletions(-)
--
The CCP driver is able to act as a DMA engine. Add a module parameter that
allows this feature to be enabled/disabled.
Signed-off-by: Gary R Hook <[email protected]>
---
drivers/crypto/ccp/ccp-dev-v5.c | 11 +++++++----
drivers/crypto/ccp/ccp-dev.h | 1 +
drivers/crypto/ccp/sp-pci.c | 8 ++++++++
3 files changed, 16 insertions(+), 4 deletions(-)
diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
index ffd546b951b6..dfd803f6fb55 100644
--- a/drivers/crypto/ccp/ccp-dev-v5.c
+++ b/drivers/crypto/ccp/ccp-dev-v5.c
@@ -976,9 +976,11 @@ static int ccp5_init(struct ccp_device *ccp)
goto e_kthread;
/* Register the DMA engine support */
- ret = ccp_dmaengine_register(ccp);
- if (ret)
- goto e_hwrng;
+ if (ccp_register_dma()) {
+ ret = ccp_dmaengine_register(ccp);
+ if (ret)
+ goto e_hwrng;
+ }
#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
/* Set up debugfs entries */
@@ -1013,7 +1015,8 @@ static void ccp5_destroy(struct ccp_device *ccp)
unsigned int i;
/* Unregister the DMA engine */
- ccp_dmaengine_unregister(ccp);
+ if (ccp_register_dma())
+ ccp_dmaengine_unregister(ccp);
/* Unregister the RNG */
ccp_unregister_rng(ccp);
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index cd1bd78d95cc..323f7d8ce454 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -647,6 +647,7 @@ int ccp_register_rng(struct ccp_device *ccp);
void ccp_unregister_rng(struct ccp_device *ccp);
int ccp_dmaengine_register(struct ccp_device *ccp);
void ccp_dmaengine_unregister(struct ccp_device *ccp);
+unsigned int ccp_register_dma(void);
void ccp5_debugfs_setup(struct ccp_device *ccp);
void ccp5_debugfs_destroy(void);
diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index 86dee2a66f00..5b0a9c145c5a 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -57,6 +57,10 @@ static unsigned int nqueues = MAX_HW_QUEUES;
module_param(nqueues, uint, 0444);
MODULE_PARM_DESC(nqueues, "Number of queues per CCP (default: 5)");
+static unsigned int registerdma = 1;
+module_param(registerdma, uint, 0444);
+MODULE_PARM_DESC(registerdma, "Register services with the DMA engine (default: 1)");
+
#define COMMA ','
static void ccp_parse_pci_buses(void)
{
@@ -154,6 +158,10 @@ unsigned int ccp_get_nqueues_param(void) {
return nqueues;
}
+unsigned int ccp_register_dma(void) {
+ return registerdma;
+}
+
#define MSIX_VECTORS 2
struct sp_pci {
Add module parameter pcibus as a read-only variable to the CCP's
debugfs info.
Signed-off-by: Gary R Hook <[email protected]>
---
drivers/crypto/ccp/ccp-debugfs.c | 1 +
drivers/crypto/ccp/ccp-dev.h | 1 +
drivers/crypto/ccp/sp-pci.c | 47 ++++++++++++++++++++++++++++++++++++--
3 files changed, 47 insertions(+), 2 deletions(-)
diff --git a/drivers/crypto/ccp/ccp-debugfs.c b/drivers/crypto/ccp/ccp-debugfs.c
index c4cc0e60fd50..7a223b71eee8 100644
--- a/drivers/crypto/ccp/ccp-debugfs.c
+++ b/drivers/crypto/ccp/ccp-debugfs.c
@@ -318,6 +318,7 @@ void ccp5_debugfs_setup(struct ccp_device *ccp)
}
ccp_debugfs_register_modparams(ccp_debugfs_dir);
+ ccp_debugfs_register_buses(ccp_debugfs_dir);
return;
}
diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
index d812446213ee..cd1bd78d95cc 100644
--- a/drivers/crypto/ccp/ccp-dev.h
+++ b/drivers/crypto/ccp/ccp-dev.h
@@ -683,6 +683,7 @@ typedef struct _modparam {
umode_t parammode;
} modparam_t;
extern void ccp_debugfs_register_modparams(struct dentry *parentdir);
+extern void ccp_debugfs_register_buses(struct dentry *parentdir);
#endif
diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index a563d85b242e..86dee2a66f00 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -62,6 +62,7 @@ static void ccp_parse_pci_buses(void)
{
unsigned int busno;
unsigned int eos = 0;
+ char *busarg;
int ret;
char *comma;
char *tok;
@@ -70,7 +71,9 @@ static void ccp_parse_pci_buses(void)
if (!buses)
return;
- comma = tok = buses;
+ busarg = kstrdup(buses, GFP_KERNEL);
+
+ comma = tok = busarg;
while (!eos && *tok && (n_pcibus < MAXCCPS)) {
while (*comma && *comma != COMMA)
comma++;
@@ -81,11 +84,15 @@ static void ccp_parse_pci_buses(void)
ret = kstrtouint(tok, 0, &busno);
if (ret) {
pr_info("%s: Parsing error (%d) '%s'\n", __func__, ret, buses);
- return;
+ n_pcibus = 0; /* pretend there was no parameter */
+ goto err;
}
pcibus[n_pcibus++] = busno;
tok = ++comma;
}
+
+err:
+ kfree(busarg);
}
#ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
@@ -106,6 +113,41 @@ void ccp_debugfs_register_modparams(struct dentry *parentdir)
moduleparameters[j].param);
}
+static ssize_t ccp_debugfs_buses_read(struct file *filp, char __user *ubuf,
+ size_t count, loff_t *offp)
+{
+ char *string = filp->private_data;
+ unsigned int oboff = 0;
+ unsigned plen = 1023;
+ ssize_t ret;
+ char *obuf;
+
+ if (!string)
+ string = "(ALL)";
+ obuf = kmalloc(plen + 1, GFP_KERNEL);
+ if (!obuf)
+ return -ENOMEM;
+
+ oboff += snprintf(obuf, plen, "%s\n", string);
+
+ ret = simple_read_from_buffer(ubuf, count, offp, obuf, oboff);
+ kfree(obuf);
+
+ return ret;
+}
+
+static const struct file_operations ccp_debugfs_char_ops = {
+ .owner = THIS_MODULE,
+ .open = simple_open,
+ .read = ccp_debugfs_buses_read,
+ .write = NULL,
+};
+
+void ccp_debugfs_register_buses(struct dentry *parentdir)
+{
+ debugfs_create_file("buses", S_IRUSR, parentdir, buses, &ccp_debugfs_char_ops);
+}
+
#endif
unsigned int ccp_get_nqueues_param(void) {
@@ -457,6 +499,7 @@ static struct pci_driver sp_pci_driver = {
int sp_pci_init(void)
{
mutex_init(&devcount_mutex);
+ ccp_parse_pci_buses();
return pci_register_driver(&sp_pci_driver);
}
On 6/24/19 2:29 PM, Hook, Gary wrote:
> The CCP driver is able to act as a DMA engine. Add a module parameter that
> allows this feature to be enabled/disabled.
>
> Signed-off-by: Gary R Hook <[email protected]>
> ---
> drivers/crypto/ccp/ccp-dev-v5.c | 11 +++++++----
> drivers/crypto/ccp/ccp-dev.h | 1 +
> drivers/crypto/ccp/sp-pci.c | 8 ++++++++
> 3 files changed, 16 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/crypto/ccp/ccp-dev-v5.c b/drivers/crypto/ccp/ccp-dev-v5.c
> index ffd546b951b6..dfd803f6fb55 100644
> --- a/drivers/crypto/ccp/ccp-dev-v5.c
> +++ b/drivers/crypto/ccp/ccp-dev-v5.c
> @@ -976,9 +976,11 @@ static int ccp5_init(struct ccp_device *ccp)
> goto e_kthread;
>
> /* Register the DMA engine support */
> - ret = ccp_dmaengine_register(ccp);
> - if (ret)
> - goto e_hwrng;
> + if (ccp_register_dma()) {
> + ret = ccp_dmaengine_register(ccp);
> + if (ret)
> + goto e_hwrng;
> + }
>
> #ifdef CONFIG_CRYPTO_DEV_CCP_DEBUGFS
> /* Set up debugfs entries */
> @@ -1013,7 +1015,8 @@ static void ccp5_destroy(struct ccp_device *ccp)
> unsigned int i;
>
> /* Unregister the DMA engine */
> - ccp_dmaengine_unregister(ccp);
> + if (ccp_register_dma())
> + ccp_dmaengine_unregister(ccp);
>
> /* Unregister the RNG */
> ccp_unregister_rng(ccp);
> diff --git a/drivers/crypto/ccp/ccp-dev.h b/drivers/crypto/ccp/ccp-dev.h
> index cd1bd78d95cc..323f7d8ce454 100644
> --- a/drivers/crypto/ccp/ccp-dev.h
> +++ b/drivers/crypto/ccp/ccp-dev.h
> @@ -647,6 +647,7 @@ int ccp_register_rng(struct ccp_device *ccp);
> void ccp_unregister_rng(struct ccp_device *ccp);
> int ccp_dmaengine_register(struct ccp_device *ccp);
> void ccp_dmaengine_unregister(struct ccp_device *ccp);
> +unsigned int ccp_register_dma(void);
>
> void ccp5_debugfs_setup(struct ccp_device *ccp);
> void ccp5_debugfs_destroy(void);
> diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
> index 86dee2a66f00..5b0a9c145c5a 100644
> --- a/drivers/crypto/ccp/sp-pci.c
> +++ b/drivers/crypto/ccp/sp-pci.c
> @@ -57,6 +57,10 @@ static unsigned int nqueues = MAX_HW_QUEUES;
> module_param(nqueues, uint, 0444);
> MODULE_PARM_DESC(nqueues, "Number of queues per CCP (default: 5)");
>
> +static unsigned int registerdma = 1;
> +module_param(registerdma, uint, 0444);
> +MODULE_PARM_DESC(registerdma, "Register services with the DMA engine (default: 1)");
Same comment as earlier, this can live in the CCP related files. Also,
only doing this for v5, not v3 too?
Thanks,
Tom
> +
> #define COMMA ','
> static void ccp_parse_pci_buses(void)
> {
> @@ -154,6 +158,10 @@ unsigned int ccp_get_nqueues_param(void) {
> return nqueues;
> }
>
> +unsigned int ccp_register_dma(void) {
> + return registerdma;
> +}
> +
> #define MSIX_VECTORS 2
>
> struct sp_pci {
>