@@ -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;
}
@@ -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
@@ -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);
}
Add module parameter pcibus as a read-only variable to the CCP's debugfs info. Signed-off-by: Gary R Hook <gary.hook@amd.com> --- 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(-)