diff mbox series

[06/11] crypto: ccp - Specify a single CCP via PCI device ID

Message ID 156140455020.116890.2457308391471121920.stgit@sosrh3.amd.com (mailing list archive)
State Changes Requested
Delegated to: Herbert Xu
Headers show
Series Add module parameters to control CCP activation | expand

Commit Message

Gary R Hook June 24, 2019, 7:29 p.m. UTC
Some processors contain multiple CCPs with differing device IDs. Enable
the selection of specific devices based on ID. The parameter value is
a single PCI ID.

Signed-off-by: Gary R Hook <gary.hook@amd.com>
---
 drivers/crypto/ccp/sp-pci.c |    7 +++++++
 1 file changed, 7 insertions(+)

Comments

Tom Lendacky June 24, 2019, 10:41 p.m. UTC | #1
On 6/24/19 2:29 PM, Hook, Gary wrote:
> Some processors contain multiple CCPs with differing device IDs. Enable
> the selection of specific devices based on ID. The parameter value is
> a single PCI ID.
> 
> Signed-off-by: Gary R Hook <gary.hook@amd.com>
> ---
>  drivers/crypto/ccp/sp-pci.c |    7 +++++++
>  1 file changed, 7 insertions(+)
> 
> diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
> index 29177d113c90..b024b92fb749 100644
> --- a/drivers/crypto/ccp/sp-pci.c
> +++ b/drivers/crypto/ccp/sp-pci.c
> @@ -36,6 +36,9 @@
>  /*
>   * Limit CCP use to a specifed number of queues per device.
>   */
> +static unsigned int pcidev;
> +module_param(pcidev, uint, 0444);
> +MODULE_PARM_DESC(pcidev, "Device number for a specific CCP");
>  
>  static struct mutex devcount_mutex ____cacheline_aligned;
>  static unsigned int devcount = 0;
> @@ -204,6 +207,10 @@ static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
>  	if (maxdev && (devcount >= maxdev)) /* Too many devices? */
>  		return 0;
>  
> +	/* If a specific device ID has been specified, filter for it */
> +        if (pcidev && (pdev->device != pcidev))
> +                        return 0;
> +

Again, this could interfere with devices that support the CCP and PSP, so
additional checking. You could get away with this check for the ccpv5b
device, but not the ccpv5a device.

Thanks,
Tom

>  	ret = -ENOMEM;
>  	sp = sp_alloc_struct(dev);
>  	if (!sp)
>
diff mbox series

Patch

diff --git a/drivers/crypto/ccp/sp-pci.c b/drivers/crypto/ccp/sp-pci.c
index 29177d113c90..b024b92fb749 100644
--- a/drivers/crypto/ccp/sp-pci.c
+++ b/drivers/crypto/ccp/sp-pci.c
@@ -36,6 +36,9 @@ 
 /*
  * Limit CCP use to a specifed number of queues per device.
  */
+static unsigned int pcidev;
+module_param(pcidev, uint, 0444);
+MODULE_PARM_DESC(pcidev, "Device number for a specific CCP");
 
 static struct mutex devcount_mutex ____cacheline_aligned;
 static unsigned int devcount = 0;
@@ -204,6 +207,10 @@  static int sp_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
 	if (maxdev && (devcount >= maxdev)) /* Too many devices? */
 		return 0;
 
+	/* If a specific device ID has been specified, filter for it */
+        if (pcidev && (pdev->device != pcidev))
+                        return 0;
+
 	ret = -ENOMEM;
 	sp = sp_alloc_struct(dev);
 	if (!sp)