Commit c4a89279 authored by Hook, Gary's avatar Hook, Gary Committed by Herbert Xu

crypto: ccp - Add a module parameter to specify a queue count

Add a module parameter to limit the number of queues per CCP. The default
value (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
varies based on the device ID).
Signed-off-by: default avatarGary R Hook <gary.hook@amd.com>
Signed-off-by: default avatarHerbert Xu <herbert@gondor.apana.org.au>
parent 93308baf
...@@ -379,7 +379,7 @@ static int ccp_init(struct ccp_device *ccp) ...@@ -379,7 +379,7 @@ static int ccp_init(struct ccp_device *ccp)
/* Find available queues */ /* Find available queues */
ccp->qim = 0; ccp->qim = 0;
qmr = ioread32(ccp->io_regs + Q_MASK_REG); qmr = ioread32(ccp->io_regs + Q_MASK_REG);
for (i = 0; i < MAX_HW_QUEUES; i++) { for (i = 0; (i < MAX_HW_QUEUES) && (ccp->cmd_q_count < ccp->max_q_count); i++) {
if (!(qmr & (1 << i))) if (!(qmr & (1 << i)))
continue; continue;
......
...@@ -2,16 +2,14 @@ ...@@ -2,16 +2,14 @@
/* /*
* AMD Cryptographic Coprocessor (CCP) driver * AMD Cryptographic Coprocessor (CCP) driver
* *
* Copyright (C) 2016,2017 Advanced Micro Devices, Inc. * Copyright (C) 2016,2019 Advanced Micro Devices, Inc.
* *
* Author: Gary R Hook <gary.hook@amd.com> * Author: Gary R Hook <gary.hook@amd.com>
*/ */
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/pci.h> #include <linux/pci.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/debugfs.h>
#include <linux/dma-mapping.h> #include <linux/dma-mapping.h>
#include <linux/interrupt.h> #include <linux/interrupt.h>
#include <linux/compiler.h> #include <linux/compiler.h>
...@@ -792,8 +790,7 @@ static int ccp5_init(struct ccp_device *ccp) ...@@ -792,8 +790,7 @@ static int ccp5_init(struct ccp_device *ccp)
/* Find available queues */ /* Find available queues */
qmr = ioread32(ccp->io_regs + Q_MASK_REG); qmr = ioread32(ccp->io_regs + Q_MASK_REG);
for (i = 0; i < MAX_HW_QUEUES; i++) { for (i = 0; (i < MAX_HW_QUEUES) && (ccp->cmd_q_count < ccp->max_q_count); i++) {
if (!(qmr & (1 << i))) if (!(qmr & (1 << i)))
continue; continue;
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
* Author: Gary R Hook <gary.hook@amd.com> * Author: Gary R Hook <gary.hook@amd.com>
*/ */
#include <linux/module.h>
#include <linux/kernel.h> #include <linux/kernel.h>
#include <linux/kthread.h> #include <linux/kthread.h>
#include <linux/sched.h> #include <linux/sched.h>
...@@ -26,6 +27,11 @@ ...@@ -26,6 +27,11 @@
#include "ccp-dev.h" #include "ccp-dev.h"
/* Limit CCP use to a specifed number of queues per device */
static unsigned int nqueues = 0;
module_param(nqueues, uint, 0444);
MODULE_PARM_DESC(nqueues, "Number of queues per CCP (minimum 1; default: all available)");
struct ccp_tasklet_data { struct ccp_tasklet_data {
struct completion completion; struct completion completion;
struct ccp_cmd *cmd; struct ccp_cmd *cmd;
...@@ -592,6 +598,11 @@ int ccp_dev_init(struct sp_device *sp) ...@@ -592,6 +598,11 @@ int ccp_dev_init(struct sp_device *sp)
goto e_err; goto e_err;
sp->ccp_data = ccp; sp->ccp_data = ccp;
if (!nqueues || (nqueues > MAX_HW_QUEUES))
ccp->max_q_count = MAX_HW_QUEUES;
else
ccp->max_q_count = nqueues;
ccp->vdata = (struct ccp_vdata *)sp->dev_vdata->ccp_vdata; ccp->vdata = (struct ccp_vdata *)sp->dev_vdata->ccp_vdata;
if (!ccp->vdata || !ccp->vdata->version) { if (!ccp->vdata || !ccp->vdata->version) {
ret = -ENODEV; ret = -ENODEV;
......
...@@ -379,6 +379,7 @@ struct ccp_device { ...@@ -379,6 +379,7 @@ struct ccp_device {
*/ */
struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES]; struct ccp_cmd_queue cmd_q[MAX_HW_QUEUES];
unsigned int cmd_q_count; unsigned int cmd_q_count;
unsigned int max_q_count;
/* Support for the CCP True RNG /* Support for the CCP True RNG
*/ */
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment