All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Hook, Gary" <Gary.Hook@amd.com>
To: "linux-crypto@vger.kernel.org" <linux-crypto@vger.kernel.org>
Cc: "Lendacky, Thomas" <Thomas.Lendacky@amd.com>,
	"herbert@gondor.apana.org.au" <herbert@gondor.apana.org.au>,
	"davem@davemloft.net" <davem@davemloft.net>
Subject: [PATCH 02/11] crypto: ccp - Add a module parameter to specify a queue count
Date: Mon, 24 Jun 2019 19:28:44 +0000	[thread overview]
Message-ID: <156140452269.116890.16300533767199946313.stgit@sosrh3.amd.com> (raw)
In-Reply-To: <156140365456.116890.15736288493305066708.stgit@sosrh3.amd.com>

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(-)

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 {


  parent reply	other threads:[~2019-06-24 19:28 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-24 19:28 [PATCH 00/11] Add module parameters to control CCP activation Hook, Gary
2019-06-24 19:28 ` [PATCH 01/11] crypto: ccp - Make CCP debugfs support optional Hook, Gary
2019-06-24 19:28 ` Hook, Gary [this message]
2019-06-24 21:54   ` [PATCH 02/11] crypto: ccp - Add a module parameter to specify a queue count Lendacky, Thomas
2019-06-24 19:28 ` [PATCH 03/11] crypto: ccp - Expose the value of nqueues in DebugFS Hook, Gary
2019-06-24 21:59   ` Lendacky, Thomas
2019-06-25 13:06     ` Gary R Hook
2019-06-24 19:28 ` [PATCH 04/11] crypto: ccp - module parameter to limit the number of enabled CCPs Hook, Gary
2019-06-24 22:11   ` Lendacky, Thomas
2019-06-24 19:29 ` [PATCH 05/11] crypto: ccp - Expose maxdev through DebugFS Hook, Gary
2019-06-24 19:29 ` [PATCH 06/11] crypto: ccp - Specify a single CCP via PCI device ID Hook, Gary
2019-06-24 22:41   ` Lendacky, Thomas
2019-06-24 19:29 ` [PATCH 07/11] crypto: ccp - expose the pcidev module parameter in debugfs Hook, Gary
2019-06-24 19:29 ` [PATCH 08/11] crypto: ccp - module parameter to allow CCP selection by PCI bus Hook, Gary
2019-06-24 22:42   ` Lendacky, Thomas
2019-06-24 19:29 ` [PATCH 09/11] crypto: ccp - expose pcibus module parameter in debugfs Hook, Gary
2019-06-24 19:29 ` [PATCH 10/11] crypto: ccp - Add a module parameter to control registration for DMA Hook, Gary
2019-06-24 22:45   ` Lendacky, Thomas
2019-06-24 19:29 ` [PATCH 11/11] crypto: ccp - Expose the registerdma module parameter in DFS Hook, Gary

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=156140452269.116890.16300533767199946313.stgit@sosrh3.amd.com \
    --to=gary.hook@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=davem@davemloft.net \
    --cc=herbert@gondor.apana.org.au \
    --cc=linux-crypto@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.