Skip to contentSkip to conversation

Introduce AMD Secure Processor device

PATCH Superseded Brijesh Singh 3 participants 13 messages Jun 23, 2017 – Jul 6, 2017

Subsystems (2)

v2 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

v2 cover Introduce AMD Secure Processor device

CCP device (drivers/crypto/ccp/ccp.ko) is part of AMD Secure Processor, which is not dedicated solely to crypto. The AMD Secure Processor includes CCP and PSP (Platform Secure Processor) devices.

This patch series adds a framework that allows functional component of the AMD Secure Processor to be initialized and handled appropriately. The series does not makes any logic modification into CCP - it refactors the code to integerate CCP into AMD secure processor framework.

---

Changes since v1:
- remove unused function [sp_get_device()]

Brijesh Singh (3):
crypto: ccp - Use devres interface to allocate PCI/iomap and cleanup
crypto: ccp - Introduce the AMD Secure Processor device
crypto: cpp - Abstract interrupt registeration

 drivers/crypto/Kconfig            |  10 +-
 drivers/crypto/ccp/Kconfig        |  43 +++---
 drivers/crypto/ccp/Makefile       |   6 +-
 drivers/crypto/ccp/ccp-dev-v3.c   |  17 ++-
 drivers/crypto/ccp/ccp-dev-v5.c   |  12 +-
 drivers/crypto/ccp/ccp-dev.c      | 124 ++++++++++------
 drivers/crypto/ccp/ccp-dev.h      |  19 +--
 drivers/crypto/ccp/ccp-pci.c      | 264 ++++++++++++-----------------------
 drivers/crypto/ccp/ccp-platform.c | 165 ++++++++--------------
 drivers/crypto/ccp/sp-dev.c       | 287 ++++++++++++++++++++++++++++++++++++++
 drivers/crypto/ccp/sp-dev.h       | 133 ++++++++++++++++++
 include/linux/ccp.h               |   3 +-
 12 files changed, 712 insertions(+), 371 deletions(-)
 create mode 100644 drivers/crypto/ccp/sp-dev.c
 create mode 100644 drivers/crypto/ccp/sp-dev.h
Signature · 1 line
2.9.4
#1 lore raw

PATCH v2 1/3 crypto: ccp - Use devres interface to allocate PCI/iomap and cleanup

Update pci and platform files to use devres interface to allocate the PCI and iomap resources. Also add helper functions to consolicate module init, exit and power mangagement code duplication.

---
 drivers/crypto/ccp/ccp-dev-v3.c   |   8 +++
 drivers/crypto/ccp/ccp-dev.c      |  61 ++++++++++++++++++++
 drivers/crypto/ccp/ccp-dev.h      |   6 ++
 drivers/crypto/ccp/ccp-pci.c      | 114 +++++++++-----------------------------
 drivers/crypto/ccp/ccp-platform.c |  56 ++-----------------
 5 files changed, 107 insertions(+), 138 deletions(-)
drivers/crypto/ccp/ccp-dev-v3.c +8 -0
index 367c2e3..1cae5a3 100644
@@ -586,6 +586,14 @@ static const struct ccp_actions ccp3_actions = {
 	.irqhandler = ccp_irq_handler,
 };
 
+const struct ccp_vdata ccpv3_platform = {
+	.version = CCP_VERSION(3, 0),
+	.setup = NULL,
+	.perform = &ccp3_actions,
+	.bar = 2,
+	.offset = 0,
+};
+
 const struct ccp_vdata ccpv3 = {
 	.version = CCP_VERSION(3, 0),
 	.setup = NULL,
drivers/crypto/ccp/ccp-dev.c +61 -0

69 lines not on this page · raw message

drivers/crypto/ccp/ccp-dev.h +6 -0
index a70154a..df2e76e 100644
@@ -652,6 +652,11 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp);
 void ccp5_debugfs_setup(struct ccp_device *ccp);
 void ccp5_debugfs_destroy(void);
 
+int ccp_dev_init(struct ccp_device *ccp);
+void ccp_dev_destroy(struct ccp_device *ccp);
+int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state);
+int ccp_dev_resume(struct ccp_device *ccp);
+
 /* Structure for computation functions that are device-specific */
 struct ccp_actions {
 	int (*aes)(struct ccp_op *);
@@ -679,6 +684,7 @@ struct ccp_vdata {
 	const unsigned int offset;
 };
 
+extern const struct ccp_vdata ccpv3_platform;
 extern const struct ccp_vdata ccpv3;
 extern const struct ccp_vdata ccpv5a;
 extern const struct ccp_vdata ccpv5b;
drivers/crypto/ccp/ccp-pci.c +26 -88

178 lines not on this page · raw message

drivers/crypto/ccp/ccp-platform.c +6 -50

100 lines not on this page · raw message

Signature · 1 line
2.9.4
maintainer
#2 lore raw

Re: [PATCH v2 1/3] crypto: ccp - Use devres interface to allocate PCI/iomap and cleanup

Quoted 18 lines · Brijesh Singh

Update pci and platform files to use devres interface to allocate the PCI and iomap resources. Also add helper functions to consolicate module init, exit and power mangagement code duplication.

---
  drivers/crypto/ccp/ccp-dev-v3.c   |   8 +++
  drivers/crypto/ccp/ccp-dev.c      |  61 ++++++++++++++++++++
  drivers/crypto/ccp/ccp-dev.h      |   6 ++
  drivers/crypto/ccp/ccp-pci.c      | 114 +++++++++-----------------------------
  drivers/crypto/ccp/ccp-platform.c |  56 ++-----------------
  5 files changed, 107 insertions(+), 138 deletions(-)
drivers/crypto/ccp/ccp-dev-v3.c +0 -0
index 367c2e3..1cae5a3 100644

drivers/crypto/ccp/ccp-dev-v3.c static const struct ccp_actions ccp3_actions = { · line 593

Quoted 8 lines
drivers/crypto/ccp/ccp-dev-v3.c +5 -0
@@ -586,6 +586,14 @@ static const struct ccp_actions ccp3_actions = {
  	.irqhandler = ccp_irq_handler,
  };
 
+const struct ccp_vdata ccpv3_platform = {
+	.version = CCP_VERSION(3, 0),
+	.setup = NULL,
+	.perform = &ccp3_actions,
+	.bar = 2,

Platform devices don't use BARs so should probably delete this (unless you want to make it more generic and then use this value for the IORESOURCE_MEM entry).

Quoted 55 lines
drivers/crypto/ccp/ccp-dev-v3.c +3 -0
+	.offset = 0,
+};
+
  const struct ccp_vdata ccpv3 = {
  	.version = CCP_VERSION(3, 0),
  	.setup = NULL,
drivers/crypto/ccp/ccp-dev.c +41 -0
index 2506b50..ce35e43 100644
@@ -538,8 +538,69 @@ bool ccp_queues_suspended(struct ccp_device *ccp)
 
  	return ccp->cmd_q_count == suspended;
  }
+
+int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state)
+{
+	unsigned long flags;
+	unsigned int i;
+
+	spin_lock_irqsave(&ccp->cmd_lock, flags);
+
+	ccp->suspending = 1;
+
+	/* Wake all the queue kthreads to prepare for suspend */
+	for (i = 0; i < ccp->cmd_q_count; i++)
+		wake_up_process(ccp->cmd_q[i].kthread);
+
+	spin_unlock_irqrestore(&ccp->cmd_lock, flags);
+
+	/* Wait for all queue kthreads to say they're done */
+	while (!ccp_queues_suspended(ccp))
+		wait_event_interruptible(ccp->suspend_queue,
+					 ccp_queues_suspended(ccp));
+
+	return 0;
+}
+
+int ccp_dev_resume(struct ccp_device *ccp)
+{
+	unsigned long flags;
+	unsigned int i;
+
+	spin_lock_irqsave(&ccp->cmd_lock, flags);
+
+	ccp->suspending = 0;
+
+	/* Wake up all the kthreads */
+	for (i = 0; i < ccp->cmd_q_count; i++) {
+		ccp->cmd_q[i].suspended = 0;
+		wake_up_process(ccp->cmd_q[i].kthread);
+	}
+
+	spin_unlock_irqrestore(&ccp->cmd_lock, flags);
+

drivers/crypto/ccp/ccp-dev.c bool ccp_queues_suspended(struct ccp_device *ccp) · line 591

Quoted 10 lines
drivers/crypto/ccp/ccp-dev.c +8 -0
+	return 0;
+}
  #endif
 
+int ccp_dev_init(struct ccp_device *ccp)
+{
+	if (ccp->vdata->setup)
+		ccp->vdata->setup(ccp);
+
+	ccp->io_regs = ccp->io_map + ccp->vdata->offset;

This should be before the above call to setup().

Thanks,
Tom

Quoted 15 lines
drivers/crypto/ccp/ccp-dev.c +12 -0
+
+	return ccp->vdata->perform->init(ccp);
+}
+
+void ccp_dev_destroy(struct ccp_device *ccp)
+{
+	if (!ccp)
+		return;
+
+	ccp->vdata->perform->destroy(ccp);
+}
+
  static int __init ccp_mod_init(void)
  {
  #ifdef CONFIG_X86
#3 lore raw

Re: [PATCH v2 1/3] crypto: ccp - Use devres interface to allocate PCI/iomap and cleanup

Quoted 10 lines · Tom Lendacky

drivers/crypto/ccp/ccp-dev-v3.c static const struct ccp_actions ccp3_actions = { · line 593

Quoted 5 lines
drivers/crypto/ccp/ccp-dev-v3.c +5 -0
+const struct ccp_vdata ccpv3_platform = {
+    .version = CCP_VERSION(3, 0),
+    .setup = NULL,
+    .perform = &ccp3_actions,
+    .bar = 2,

Platform devices don't use BARs so should probably delete this (unless you want to make it more generic and then use this value for the IORESOURCE_MEM entry).

Yep, we don't need bar for platform device, it was copy paste from existing ccpv3 structure. I will fix it in v3. thanks

Quoted 11 lines

drivers/crypto/ccp/ccp-dev.c bool ccp_queues_suspended(struct ccp_device *ccp) · line 591

Quoted 8 lines
drivers/crypto/ccp/ccp-dev.c +7 -0
+}
  #endif
+int ccp_dev_init(struct ccp_device *ccp)
+{
+    if (ccp->vdata->setup)
+        ccp->vdata->setup(ccp);
+
+    ccp->io_regs = ccp->io_map + ccp->vdata->offset;

This should be before the above call to setup().

Good catch, actually the second patch takes care of it. But I agree with your feedback, I will make sure that io_regs is set before invoking the setup() in the first patch itself.

Thanks
Brijesh

#4 lore raw

PATCH v2 2/3 crypto: ccp - Introduce the AMD Secure Processor device

In reply to Brijesh Singh

The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD Secure Processor to be initialized and handled appropriately.

---
 drivers/crypto/Kconfig            |  10 +--
 drivers/crypto/ccp/Kconfig        |  43 +++++----
 drivers/crypto/ccp/Makefile       |   6 +-
 drivers/crypto/ccp/ccp-dev-v3.c   |   5 +-
 drivers/crypto/ccp/ccp-dev-v5.c   |   5 +-
 drivers/crypto/ccp/ccp-dev.c      | 106 +++++++++-------------
 drivers/crypto/ccp/ccp-dev.h      |  21 +----
 drivers/crypto/ccp/ccp-pci.c      |  81 +++++++++++------
 drivers/crypto/ccp/ccp-platform.c |  70 ++++++++-------
 drivers/crypto/ccp/sp-dev.c       | 180 ++++++++++++++++++++++++++++++++++++++
 drivers/crypto/ccp/sp-dev.h       | 120 +++++++++++++++++++++++++
 include/linux/ccp.h               |   3 +-
 12 files changed, 475 insertions(+), 175 deletions(-)
 create mode 100644 drivers/crypto/ccp/sp-dev.c
 create mode 100644 drivers/crypto/ccp/sp-dev.h
drivers/crypto/Kconfig +5 -5
index 0528a62..418f991 100644
@@ -512,14 +512,14 @@ config CRYPTO_DEV_ATMEL_SHA
 	  To compile this driver as a module, choose M here: the module
 	  will be called atmel-sha.
 
-config CRYPTO_DEV_CCP
-	bool "Support for AMD Cryptographic Coprocessor"
+config CRYPTO_DEV_SP
+	bool "Support for AMD Secure Processor"
 	depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && HAS_IOMEM
 	help
-	  The AMD Cryptographic Coprocessor provides hardware offload support
-	  for encryption, hashing and related operations.
+	  The AMD Secure Processor provides hardware offload support for memory
+	  encryption in virtualization and cryptographic hashing and related operations.
 
-if CRYPTO_DEV_CCP
+if CRYPTO_DEV_SP
 	source "drivers/crypto/ccp/Kconfig"
 endif
 
drivers/crypto/ccp/Kconfig +27 -16

53 lines not on this page · raw message

drivers/crypto/ccp/Makefile +3 -3
index 59493fd..ea42888 100644
@@ -1,9 +1,9 @@
-obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o
-ccp-objs := ccp-dev.o \
+obj-$(CONFIG_CRYPTO_DEV_SP_DD) += ccp.o
+ccp-objs  := sp-dev.o ccp-platform.o
+ccp-$(CONFIG_CRYPTO_DEV_CCP) += ccp-dev.o \
 	    ccp-ops.o \
 	    ccp-dev-v3.o \
 	    ccp-dev-v5.o \
-	    ccp-platform.o \
 	    ccp-dmaengine.o \
 	    ccp-debugfs.o
 ccp-$(CONFIG_PCI) += ccp-pci.o
drivers/crypto/ccp/ccp-dev-v3.c +1 -4
index 1cae5a3..57179034 100644
@@ -359,8 +359,7 @@ static void ccp_irq_bh(unsigned long data)
 
 static irqreturn_t ccp_irq_handler(int irq, void *data)
 {
-	struct device *dev = data;
-	struct ccp_device *ccp = dev_get_drvdata(dev);
+	struct ccp_device *ccp = (struct ccp_device *)data;
 
 	ccp_disable_queue_interrupts(ccp);
 	if (ccp->use_tasklet)
@@ -590,7 +589,6 @@ const struct ccp_vdata ccpv3_platform = {
 	.version = CCP_VERSION(3, 0),
 	.setup = NULL,
 	.perform = &ccp3_actions,
-	.bar = 2,
 	.offset = 0,
 };
 
@@ -598,6 +596,5 @@ const struct ccp_vdata ccpv3 = {
 	.version = CCP_VERSION(3, 0),
 	.setup = NULL,
 	.perform = &ccp3_actions,
-	.bar = 2,
 	.offset = 0x20000,
 };
drivers/crypto/ccp/ccp-dev-v5.c +1 -4
index b10d2d2..8ed2b37 100644
@@ -769,8 +769,7 @@ static void ccp5_irq_bh(unsigned long data)
 
 static irqreturn_t ccp5_irq_handler(int irq, void *data)
 {
-	struct device *dev = data;
-	struct ccp_device *ccp = dev_get_drvdata(dev);
+	struct ccp_device *ccp = (struct ccp_device *)data;
 
 	ccp5_disable_queue_interrupts(ccp);
 	ccp->total_interrupts++;
@@ -1113,7 +1112,6 @@ const struct ccp_vdata ccpv5a = {
 	.version = CCP_VERSION(5, 0),
 	.setup = ccp5_config,
 	.perform = &ccp5_actions,
-	.bar = 2,
 	.offset = 0x0,
 };
 
@@ -1122,6 +1120,5 @@ const struct ccp_vdata ccpv5b = {
 	.dma_chan_attr = DMA_PRIVATE,
 	.setup = ccp5other_config,
 	.perform = &ccp5_actions,
-	.bar = 2,
 	.offset = 0x0,
 };
drivers/crypto/ccp/ccp-dev.c +43 -63

166 lines not on this page · raw message

drivers/crypto/ccp/ccp-dev.h +4 -17
index df2e76e..ca44821 100644
@@ -27,6 +27,8 @@
 #include <linux/irqreturn.h>
 #include <linux/dmaengine.h>
 
+#include "sp-dev.h"
+
 #define MAX_CCP_NAME_LEN		16
 #define MAX_DMAPOOL_NAME_LEN		32
 
@@ -344,6 +346,7 @@ struct ccp_device {
 	char rngname[MAX_CCP_NAME_LEN];
 
 	struct device *dev;
+	struct sp_device *sp;
 
 	/* Bus specific device information
 	 */
@@ -362,7 +365,6 @@ struct ccp_device {
 	 *   them.
 	 */
 	struct mutex req_mutex ____cacheline_aligned;
-	void __iomem *io_map;
 	void __iomem *io_regs;
 
 	/* Master lists that all cmds are queued on. Because there can be
@@ -637,7 +639,7 @@ void ccp_del_device(struct ccp_device *ccp);
 
 extern void ccp_log_error(struct ccp_device *, int);
 
-struct ccp_device *ccp_alloc_struct(struct device *dev);
+struct ccp_device *ccp_alloc_struct(struct sp_device *sp);
 bool ccp_queues_suspended(struct ccp_device *ccp);
 int ccp_cmd_queue_thread(void *data);
 int ccp_trng_read(struct hwrng *rng, void *data, size_t max, bool wait);
@@ -652,11 +654,6 @@ void ccp_dmaengine_unregister(struct ccp_device *ccp);
 void ccp5_debugfs_setup(struct ccp_device *ccp);
 void ccp5_debugfs_destroy(void);
 
-int ccp_dev_init(struct ccp_device *ccp);
-void ccp_dev_destroy(struct ccp_device *ccp);
-int ccp_dev_suspend(struct ccp_device *ccp, pm_message_t state);
-int ccp_dev_resume(struct ccp_device *ccp);
-
 /* Structure for computation functions that are device-specific */
 struct ccp_actions {
 	int (*aes)(struct ccp_op *);
@@ -674,16 +671,6 @@ struct ccp_actions {
 	irqreturn_t (*irqhandler)(int, void *);
 };
 
-/* Structure to hold CCP version-specific values */
-struct ccp_vdata {
-	const unsigned int version;
-	const unsigned int dma_chan_attr;
-	void (*setup)(struct ccp_device *);
-	const struct ccp_actions *perform;
-	const unsigned int bar;
-	const unsigned int offset;
-};
-
 extern const struct ccp_vdata ccpv3_platform;
 extern const struct ccp_vdata ccpv3;
 extern const struct ccp_vdata ccpv5a;
drivers/crypto/ccp/ccp-pci.c +52 -29

183 lines not on this page · raw message

drivers/crypto/ccp/ccp-platform.c +38 -32

174 lines not on this page · raw message

drivers/crypto/ccp/sp-dev.c new file +180 -0

180 lines not on this page · raw message

drivers/crypto/ccp/sp-dev.h new file +120 -0

120 lines not on this page · raw message

include/linux/ccp.h +1 -2
index 3285c94..d341636 100644
@@ -24,8 +24,7 @@
 struct ccp_device;
 struct ccp_cmd;
 
-#if defined(CONFIG_CRYPTO_DEV_CCP_DD) || \
-	defined(CONFIG_CRYPTO_DEV_CCP_DD_MODULE)
+#if defined(CONFIG_CRYPTO_DEV_CCP)
 
 /**
  * ccp_present - check if a CCP device is present
Signature · 1 line
2.9.4
maintainer
#5 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 95 lines · Brijesh Singh

The CCP device is part of the AMD Secure Processor. In order to expand the usage of the AMD Secure Processor, create a framework that allows functional components of the AMD Secure Processor to be initialized and handled appropriately.

---
  drivers/crypto/Kconfig            |  10 +--
  drivers/crypto/ccp/Kconfig        |  43 +++++----
  drivers/crypto/ccp/Makefile       |   6 +-
  drivers/crypto/ccp/ccp-dev-v3.c   |   5 +-
  drivers/crypto/ccp/ccp-dev-v5.c   |   5 +-
  drivers/crypto/ccp/ccp-dev.c      | 106 +++++++++-------------
  drivers/crypto/ccp/ccp-dev.h      |  21 +----
  drivers/crypto/ccp/ccp-pci.c      |  81 +++++++++++------
  drivers/crypto/ccp/ccp-platform.c |  70 ++++++++-------
  drivers/crypto/ccp/sp-dev.c       | 180 ++++++++++++++++++++++++++++++++++++++
  drivers/crypto/ccp/sp-dev.h       | 120 +++++++++++++++++++++++++
  include/linux/ccp.h               |   3 +-
  12 files changed, 475 insertions(+), 175 deletions(-)

create mode 100644 drivers/crypto/ccp/sp-dev.c
create mode 100644 drivers/crypto/ccp/sp-dev.h

drivers/crypto/Kconfig +5 -5
index 0528a62..418f991 100644
@@ -512,14 +512,14 @@ config CRYPTO_DEV_ATMEL_SHA
  	  To compile this driver as a module, choose M here: the module
  	  will be called atmel-sha.
 
-config CRYPTO_DEV_CCP
-	bool "Support for AMD Cryptographic Coprocessor"
+config CRYPTO_DEV_SP
+	bool "Support for AMD Secure Processor"
  	depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && HAS_IOMEM
  	help
-	  The AMD Cryptographic Coprocessor provides hardware offload support
-	  for encryption, hashing and related operations.
+	  The AMD Secure Processor provides hardware offload support for memory
+	  encryption in virtualization and cryptographic hashing and related operations.
 
-if CRYPTO_DEV_CCP
+if CRYPTO_DEV_SP
  	source "drivers/crypto/ccp/Kconfig"
  endif
 
drivers/crypto/ccp/Kconfig +17 -16
index 2238f77..bc08f03 100644
@@ -1,26 +1,37 @@
-config CRYPTO_DEV_CCP_DD
-	tristate "Cryptographic Coprocessor device driver"
-	depends on CRYPTO_DEV_CCP
-	default m
-	select HW_RANDOM
-	select DMA_ENGINE
-	select DMADEVICES
-	select CRYPTO_SHA1
-	select CRYPTO_SHA256
-	help
-	  Provides the interface to use the AMD Cryptographic Coprocessor
-	  which can be used to offload encryption operations such as SHA,
-	  AES and more. If you choose 'M' here, this module will be called
-	  ccp.
-
  config CRYPTO_DEV_CCP_CRYPTO
  	tristate "Encryption and hashing offload support"
-	depends on CRYPTO_DEV_CCP_DD
+	depends on CRYPTO_DEV_SP_DD
  	default m
  	select CRYPTO_HASH
  	select CRYPTO_BLKCIPHER
  	select CRYPTO_AUTHENC
+	select CRYPTO_DEV_CCP
  	help
  	  Support for using the cryptographic API with the AMD Cryptographic
  	  Coprocessor. This module supports offload of SHA and AES algorithms.
  	  If you choose 'M' here, this module will be called ccp_crypto.
+
+config CRYPTO_DEV_SP_DD
+	tristate "Secure Processor device driver"
+	depends on CRYPTO_DEV_SP
+	default m
+	help
+	  Provides the interface to use the AMD Secure Processor. The
+	  AMD Secure Processor support the Platform Security Processor (PSP)
+	  and Cryptographic Coprocessor (CCP). If you choose 'M' here, this
+	  module will be called ccp.
+
+if CRYPTO_DEV_SP_DD
+config CRYPTO_DEV_CCP
+	bool "Cryptographic Coprocessor interface"
+	default y

drivers/crypto/ccp/Kconfig line 37

Quoted 10 lines
drivers/crypto/ccp/Kconfig +10 -0
+	select HW_RANDOM
+	select DMA_ENGINE
+	select DMADEVICES
+	select CRYPTO_SHA1
+	select CRYPTO_SHA256
+	help
+	  Provides the interface to use the AMD Cryptographic Coprocessor
+	  which can be used to offload encryption operations such as SHA,
+	  AES and more.
+endif

I think the Kconfig changes need to be looked at a bit closer. The hierarchy of original version is changed and the number of entries might be able to be reduced.

Thanks,
Tom

#6 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 76 lines · Tom Lendacky
Quoted 76 lines
drivers/crypto/Kconfig +5 -5
index 0528a62..418f991 100644
@@ -512,14 +512,14 @@ config CRYPTO_DEV_ATMEL_SHA
        To compile this driver as a module, choose M here: the module
        will be called atmel-sha.
-config CRYPTO_DEV_CCP
-    bool "Support for AMD Cryptographic Coprocessor"
+config CRYPTO_DEV_SP
+    bool "Support for AMD Secure Processor"
      depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && HAS_IOMEM
      help
-      The AMD Cryptographic Coprocessor provides hardware offload support
-      for encryption, hashing and related operations.
+      The AMD Secure Processor provides hardware offload support for memory
+      encryption in virtualization and cryptographic hashing and related operations.
-if CRYPTO_DEV_CCP
+if CRYPTO_DEV_SP
      source "drivers/crypto/ccp/Kconfig"
  endif
drivers/crypto/ccp/Kconfig +23 -16
index 2238f77..bc08f03 100644
@@ -1,26 +1,37 @@
-config CRYPTO_DEV_CCP_DD
-    tristate "Cryptographic Coprocessor device driver"
-    depends on CRYPTO_DEV_CCP
-    default m
-    select HW_RANDOM
-    select DMA_ENGINE
-    select DMADEVICES
-    select CRYPTO_SHA1
-    select CRYPTO_SHA256
-    help
-      Provides the interface to use the AMD Cryptographic Coprocessor
-      which can be used to offload encryption operations such as SHA,
-      AES and more. If you choose 'M' here, this module will be called
-      ccp.
-
  config CRYPTO_DEV_CCP_CRYPTO
      tristate "Encryption and hashing offload support"
-    depends on CRYPTO_DEV_CCP_DD
+    depends on CRYPTO_DEV_SP_DD
      default m
      select CRYPTO_HASH
      select CRYPTO_BLKCIPHER
      select CRYPTO_AUTHENC
+    select CRYPTO_DEV_CCP
      help
        Support for using the cryptographic API with the AMD Cryptographic
        Coprocessor. This module supports offload of SHA and AES algorithms.
        If you choose 'M' here, this module will be called ccp_crypto.
+
+config CRYPTO_DEV_SP_DD
+    tristate "Secure Processor device driver"
+    depends on CRYPTO_DEV_SP
+    default m
+    help
+      Provides the interface to use the AMD Secure Processor. The
+      AMD Secure Processor support the Platform Security Processor (PSP)
+      and Cryptographic Coprocessor (CCP). If you choose 'M' here, this
+      module will be called ccp.
+
+if CRYPTO_DEV_SP_DD
+config CRYPTO_DEV_CCP
+    bool "Cryptographic Coprocessor interface"
+    default y
+    select HW_RANDOM
+    select DMA_ENGINE
+    select DMADEVICES
+    select CRYPTO_SHA1
+    select CRYPTO_SHA256
+    help
Quoted 9 lines

drivers/crypto/ccp/Kconfig line 37

Quoted 4 lines
drivers/crypto/ccp/Kconfig +4 -0
+      Provides the interface to use the AMD Cryptographic Coprocessor
+      which can be used to offload encryption operations such as SHA,
+      AES and more.
+endif

I think the Kconfig changes need to be looked at a bit closer. The hierarchy of original version is changed and the number of entries might be able to be reduced.

Thanks Tom, how about the below patch?

In this I am leaving the top level config as-is and adding CONFIG_CRYPTO_DEV_SP_CCP to enable the CCP device support inside the SP device driver.

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
<M> Encryption and hashing offload support
-*- Cryptographic Coprocessor device

drivers/crypto/Kconfig +3 -3
index 0528a62..148b516 100644
@@ -513,11 +513,11 @@ config CRYPTO_DEV_ATMEL_SHA
          will be called atmel-sha.
 
 config CRYPTO_DEV_CCP
-       bool "Support for AMD Cryptographic Coprocessor"
+       bool "Support for AMD Secure Processor"
        depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && HAS_IOMEM
        help
-         The AMD Cryptographic Coprocessor provides hardware offload support
-         for encryption, hashing and related operations.
+         The AMD Secure Processor provides hardware offload support for memory
+         encryption in virtualization and cryptographic hashing and related operations.
 
 if CRYPTO_DEV_CCP
        source "drivers/crypto/ccp/Kconfig"
drivers/crypto/ccp/Kconfig +20 -12
index 2238f77..ef3a5fb 100644
@@ -1,26 +1,34 @@
 config CRYPTO_DEV_CCP_DD
-       tristate "Cryptographic Coprocessor device driver"
-       depends on CRYPTO_DEV_CCP
+       tristate "Secure Processor device driver"
        default m
-       select HW_RANDOM
-       select DMA_ENGINE
-       select DMADEVICES
-       select CRYPTO_SHA1
-       select CRYPTO_SHA256
        help
-         Provides the interface to use the AMD Cryptographic Coprocessor
-         which can be used to offload encryption operations such as SHA,
-         AES and more. If you choose 'M' here, this module will be called
-         ccp.
+         Provides AMD Secure Processor device driver.
+         If you choose 'M' here, this module will be called ccp.
+
+if CRYPTO_DEV_CCP_DD
 
 config CRYPTO_DEV_CCP_CRYPTO
        tristate "Encryption and hashing offload support"
-       depends on CRYPTO_DEV_CCP_DD
        default m
        select CRYPTO_HASH
        select CRYPTO_BLKCIPHER
        select CRYPTO_AUTHENC
+       select CRYPTO_DEV_SP_CCP
        help
          Support for using the cryptographic API with the AMD Cryptographic
          Coprocessor. This module supports offload of SHA and AES algorithms.
          If you choose 'M' here, this module will be called ccp_crypto.
+
+config CRYPTO_DEV_SP_CCP
+       bool "Cryptographic Coprocessor device"
+       default y
+       select HW_RANDOM
+       select DMA_ENGINE
+       select DMADEVICES
+       select CRYPTO_SHA1
+       select CRYPTO_SHA256
+       help
+         Provides the support for AMD Cryptographic Coprocessor (CCP) device
+         which can be used to offload encryption operations such as SHA, AES
+         and more.
+endif
drivers/crypto/ccp/Makefile +2 -2
index 59493fd..d2f1b52 100644
@@ -1,9 +1,9 @@
 obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o
-ccp-objs := ccp-dev.o \
+ccp-objs  := sp-dev.o ccp-platform.o
+ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
            ccp-ops.o \
            ccp-dev-v3.o \
            ccp-dev-v5.o \
-           ccp-platform.o \
            ccp-dmaengine.o \
            ccp-debugfs.o
 ccp-$(CONFIG_PCI) += ccp-pci.o
maintainer
#7 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 98 lines · Brijesh Singh
Quoted 83 lines · Tom Lendacky
Quoted 83 lines
drivers/crypto/Kconfig +2 -2
index 0528a62..418f991 100644
@@ -512,14 +512,14 @@ config CRYPTO_DEV_ATMEL_SHA
        To compile this driver as a module, choose M here: the module
        will be called atmel-sha.
-config CRYPTO_DEV_CCP
-    bool "Support for AMD Cryptographic Coprocessor"
+config CRYPTO_DEV_SP
+    bool "Support for AMD Secure Processor"
      depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && 

HAS_IOMEM
help
- The AMD Cryptographic Coprocessor provides hardware offload
support

drivers/crypto/Kconfig +1 -1
-      for encryption, hashing and related operations.
+      The AMD Secure Processor provides hardware offload support for 

memory
+ encryption in virtualization and cryptographic hashing and
related operations.

drivers/crypto/Kconfig +1 -1
-if CRYPTO_DEV_CCP
+if CRYPTO_DEV_SP
      source "drivers/crypto/ccp/Kconfig"
  endif
drivers/crypto/ccp/Kconfig +2 -16
index 2238f77..bc08f03 100644
@@ -1,26 +1,37 @@
-config CRYPTO_DEV_CCP_DD
-    tristate "Cryptographic Coprocessor device driver"
-    depends on CRYPTO_DEV_CCP
-    default m
-    select HW_RANDOM
-    select DMA_ENGINE
-    select DMADEVICES
-    select CRYPTO_SHA1
-    select CRYPTO_SHA256
-    help
-      Provides the interface to use the AMD Cryptographic Coprocessor
-      which can be used to offload encryption operations such as SHA,
-      AES and more. If you choose 'M' here, this module will be called
-      ccp.
-
  config CRYPTO_DEV_CCP_CRYPTO
      tristate "Encryption and hashing offload support"
-    depends on CRYPTO_DEV_CCP_DD
+    depends on CRYPTO_DEV_SP_DD
      default m
      select CRYPTO_HASH
      select CRYPTO_BLKCIPHER
      select CRYPTO_AUTHENC
+    select CRYPTO_DEV_CCP
      help
        Support for using the cryptographic API with the AMD 

Cryptographic
Coprocessor. This module supports offload of SHA and AES
algorithms.
If you choose 'M' here, this module will be called ccp_crypto.

drivers/crypto/ccp/Kconfig +8 -0
+
+config CRYPTO_DEV_SP_DD
+    tristate "Secure Processor device driver"
+    depends on CRYPTO_DEV_SP
+    default m
+    help
+      Provides the interface to use the AMD Secure Processor. The
+      AMD Secure Processor support the Platform Security Processor 

(PSP)

drivers/crypto/ccp/Kconfig +13 -0
+      and Cryptographic Coprocessor (CCP). If you choose 'M' here, this
+      module will be called ccp.
+
+if CRYPTO_DEV_SP_DD
+config CRYPTO_DEV_CCP
+    bool "Cryptographic Coprocessor interface"
+    default y
+    select HW_RANDOM
+    select DMA_ENGINE
+    select DMADEVICES
+    select CRYPTO_SHA1
+    select CRYPTO_SHA256
+    help
Quoted 9 lines

drivers/crypto/ccp/Kconfig

Quoted 4 lines
drivers/crypto/ccp/Kconfig +4 -0
+      Provides the interface to use the AMD Cryptographic Coprocessor
+      which can be used to offload encryption operations such as SHA,
+      AES and more.
+endif

I think the Kconfig changes need to be looked at a bit closer. The hierarchy of original version is changed and the number of entries might be able to be reduced.

Thanks Tom, how about the below patch?

Quoted 7 lines

In this I am leaving the top level config as-is and adding CONFIG_CRYPTO_DEV_SP_CCP to enable the CCP device support inside the SP device driver.

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
<M> Encryption and hashing offload support
-*- Cryptographic Coprocessor device

I think the "Encryption and hashing offload support" should be indented under "Cryptographic Coprocessor device" since it is a function of the CCP and not the SP. Not sure if we can remove a level of menu somehow, something to explore.

Thanks,
Tom

Quoted 96 lines
drivers/crypto/Kconfig +1 -1
index 0528a62..148b516 100644
@@ -513,11 +513,11 @@ config CRYPTO_DEV_ATMEL_SHA
           will be called atmel-sha.
 
  config CRYPTO_DEV_CCP
-       bool "Support for AMD Cryptographic Coprocessor"
+       bool "Support for AMD Secure Processor"
         depends on ((X86 && PCI) || (ARM64 && (OF_ADDRESS || ACPI))) && 

HAS_IOMEM
help
- The AMD Cryptographic Coprocessor provides hardware offload
support

drivers/crypto/Kconfig +1 -1
-         for encryption, hashing and related operations.
+         The AMD Secure Processor provides hardware offload support for 

memory
+ encryption in virtualization and cryptographic hashing and
related operations.

if CRYPTO_DEV_CCP
source "drivers/crypto/ccp/Kconfig"

drivers/crypto/ccp/Kconfig +6 -12
index 2238f77..ef3a5fb 100644
@@ -1,26 +1,34 @@
  config CRYPTO_DEV_CCP_DD
-       tristate "Cryptographic Coprocessor device driver"
-       depends on CRYPTO_DEV_CCP
+       tristate "Secure Processor device driver"
         default m
-       select HW_RANDOM
-       select DMA_ENGINE
-       select DMADEVICES
-       select CRYPTO_SHA1
-       select CRYPTO_SHA256
         help
-         Provides the interface to use the AMD Cryptographic Coprocessor
-         which can be used to offload encryption operations such as SHA,
-         AES and more. If you choose 'M' here, this module will be called
-         ccp.
+         Provides AMD Secure Processor device driver.
+         If you choose 'M' here, this module will be called ccp.
+
+if CRYPTO_DEV_CCP_DD
 
  config CRYPTO_DEV_CCP_CRYPTO
         tristate "Encryption and hashing offload support"
-       depends on CRYPTO_DEV_CCP_DD
         default m
         select CRYPTO_HASH
         select CRYPTO_BLKCIPHER
         select CRYPTO_AUTHENC
+       select CRYPTO_DEV_SP_CCP
         help
           Support for using the cryptographic API with the AMD 

Cryptographic
Coprocessor. This module supports offload of SHA and AES
algorithms.
If you choose 'M' here, this module will be called ccp_crypto.

drivers/crypto/ccp/Kconfig +11 -0
+
+config CRYPTO_DEV_SP_CCP
+       bool "Cryptographic Coprocessor device"
+       default y
+       select HW_RANDOM
+       select DMA_ENGINE
+       select DMADEVICES
+       select CRYPTO_SHA1
+       select CRYPTO_SHA256
+       help
+         Provides the support for AMD Cryptographic Coprocessor (CCP) 

device
+ which can be used to offload encryption operations such as
SHA, AES

drivers/crypto/ccp/Kconfig +2 -0
+         and more.
+endif
drivers/crypto/ccp/Makefile +2 -2
index 59493fd..d2f1b52 100644
@@ -1,9 +1,9 @@
  obj-$(CONFIG_CRYPTO_DEV_CCP_DD) += ccp.o
-ccp-objs := ccp-dev.o \
+ccp-objs  := sp-dev.o ccp-platform.o
+ccp-$(CONFIG_CRYPTO_DEV_SP_CCP) += ccp-dev.o \
             ccp-ops.o \
             ccp-dev-v3.o \
             ccp-dev-v5.o \
-           ccp-platform.o \
             ccp-dmaengine.o \
             ccp-debugfs.o
  ccp-$(CONFIG_PCI) += ccp-pci.o
#8 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 9 lines · Tom Lendacky
Quoted 8 lines

In this I am leaving the top level config as-is and adding CONFIG_CRYPTO_DEV_SP_CCP to enable the CCP device support inside the SP device driver.

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
<M> Encryption and hashing offload support
-*- Cryptographic Coprocessor device

Quoted 4 lines

I think the "Encryption and hashing offload support" should be indented under "Cryptographic Coprocessor device" since it is a function of the CCP and not the SP. Not sure if we can remove a level of menu somehow, something to explore.

Good point, the updated Kconfig looks like this and let me know it works.

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
[*] Cryptographic Coprocessor device
<M> Encryption and hashing offload support

# cat drivers/crypto/ccp/Kconfig

config CRYPTO_DEV_CCP_DD
tristate "Secure Processor device driver" default m
help
Provides AMD Secure Processor device driver. If you choose 'M' here, this module will be called ccp.

config CRYPTO_DEV_SP_CCP
bool "Cryptographic Coprocessor device"
default y
depends on CRYPTO_DEV_CCP_DD
select HW_RANDOM
select DMA_ENGINE
select DMADEVICES
select CRYPTO_SHA1
select CRYPTO_SHA256
help
Provides the support for AMD Cryptographic Coprocessor (CCP) device which can be used to offload encryption operations such as SHA, AES and more.

config CRYPTO_DEV_CCP_CRYPTO
tristate "Encryption and hashing offload support"
default m
depends on CRYPTO_DEV_CCP_DD
depends on CRYPTO_DEV_SP_CCP
select CRYPTO_HASH
select CRYPTO_BLKCIPHER
select CRYPTO_AUTHENC
help
Support for using the cryptographic API with the AMD Cryptographic Coprocessor. This module supports offload of SHA and AES algorithms. If you choose 'M' here, this module will be called ccp_crypto.

maintainer
#9 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 12 lines · Brijesh Singh
Quoted 9 lines · Tom Lendacky
Quoted 8 lines

In this I am leaving the top level config as-is and adding CONFIG_CRYPTO_DEV_SP_CCP to enable the CCP device support inside the SP device driver.

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
<M> Encryption and hashing offload support
-*- Cryptographic Coprocessor device

Quoted 6 lines
Quoted 4 lines

I think the "Encryption and hashing offload support" should be indented under "Cryptographic Coprocessor device" since it is a function of the CCP and not the SP. Not sure if we can remove a level of menu somehow, something to explore.

Good point, the updated Kconfig looks like this and let me know it works.

I think that looks better.

Thanks,
Tom

Quoted 45 lines

[*] Support for AMD Secure Processor
<M> Secure Processor device driver
[*] Cryptographic Coprocessor device
<M> Encryption and hashing offload support

# cat drivers/crypto/ccp/Kconfig

config CRYPTO_DEV_CCP_DD
tristate "Secure Processor device driver" default m
help
Provides AMD Secure Processor device driver. If you choose 'M' here, this module will be called ccp.

config CRYPTO_DEV_SP_CCP
bool "Cryptographic Coprocessor device"
default y
depends on CRYPTO_DEV_CCP_DD
select HW_RANDOM
select DMA_ENGINE
select DMADEVICES
select CRYPTO_SHA1
select CRYPTO_SHA256
help
Provides the support for AMD Cryptographic Coprocessor (CCP)
device
which can be used to offload encryption operations such as
SHA, AES
and more.

config CRYPTO_DEV_CCP_CRYPTO
tristate "Encryption and hashing offload support" default m
depends on CRYPTO_DEV_CCP_DD
depends on CRYPTO_DEV_SP_CCP
select CRYPTO_HASH
select CRYPTO_BLKCIPHER
select CRYPTO_AUTHENC
help
Support for using the cryptographic API with the AMD
Cryptographic
Coprocessor. This module supports offload of SHA and AES
algorithms.
If you choose 'M' here, this module will be called ccp_crypto.

#10 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

In reply to Brijesh Singh
reproduce:

Hi Brijesh,

[auto build test ERROR on cryptodev/master]
[also build test ERROR on next-20170705]
[cannot apply to v4.12]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Brijesh-Singh/Introduce-AMD-Secure-Processor-device/20170625-064400
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: x86_64-randconfig-x016-07060921 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 

All errors (new ones prefixed by >>):

>> ERROR: "ccp_dev_resume" [drivers/crypto/ccp/ccp.ko] undefined!
>> ERROR: "ccp_dev_suspend" [drivers/crypto/ccp/ccp.ko] undefined!

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#11 lore raw

Re: [PATCH v2 2/3] crypto: ccp - Introduce the AMD Secure Processor device

Quoted 15 lines · kbuild test robot

Hi Brijesh,

[auto build test ERROR on cryptodev/master]
[also build test ERROR on next-20170705]
[cannot apply to v4.12]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Brijesh-Singh/Introduce-AMD-Secure-Processor-device/20170625-064400
base:   https://git.kernel.org/pub/scm/linux/kernel/git/herbert/cryptodev-2.6.git master
config: x86_64-randconfig-x016-07060921 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=x86_64 
Quoted 4 lines

All errors (new ones prefixed by >>):

Quoted 2 lines
Quoted 2 lines

ERROR: "ccp_dev_resume" [drivers/crypto/ccp/ccp.ko] undefined!
ERROR: "ccp_dev_suspend" [drivers/crypto/ccp/ccp.ko] undefined!

I will send out v4 soon to fix it. We need to guard sp_dev_resume and sp_dev_suspend with CONFIG_PM. I think in my .config I had CONFIG_PM enabled, whereas the robot config does not have CONFIG_PM.

Quoted 3 lines

---
0-DAY kernel test infrastructure Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all Intel Corporation

#12 lore raw

PATCH v2 3/3 crypto: cpp - Abstract interrupt registeration

In reply to Brijesh Singh

The CCP and PSP devices part of AMD Secure Procesor may share the same interrupt. Hence we expand the SP device to register a common interrupt handler and provide functions to CCP and PSP devices to register their interrupt callback which will be invoked upon interrupt.

---
 drivers/crypto/ccp/ccp-dev-v3.c   |   6 +--
 drivers/crypto/ccp/ccp-dev-v5.c   |   7 ++-
 drivers/crypto/ccp/ccp-dev.c      |   3 +-
 drivers/crypto/ccp/ccp-dev.h      |   2 -
 drivers/crypto/ccp/ccp-pci.c      | 103 +++++++++++-------------------------
 drivers/crypto/ccp/ccp-platform.c |  57 ++++++++++----------
 drivers/crypto/ccp/sp-dev.c       | 107 ++++++++++++++++++++++++++++++++++++++
 drivers/crypto/ccp/sp-dev.h       |  17 +++++-
 8 files changed, 187 insertions(+), 115 deletions(-)
drivers/crypto/ccp/ccp-dev-v3.c +3 -3
index 57179034..695fde8 100644
@@ -453,7 +453,7 @@ static int ccp_init(struct ccp_device *ccp)
 	iowrite32(ccp->qim, ccp->io_regs + IRQ_STATUS_REG);
 
 	/* Request an irq */
-	ret = ccp->get_irq(ccp);
+	ret = sp_request_ccp_irq(ccp->sp, ccp_irq_handler, ccp->name, ccp);
 	if (ret) {
 		dev_err(dev, "unable to allocate an IRQ\n");
 		goto e_pool;
@@ -510,7 +510,7 @@ static int ccp_init(struct ccp_device *ccp)
 		if (ccp->cmd_q[i].kthread)
 			kthread_stop(ccp->cmd_q[i].kthread);
 
-	ccp->free_irq(ccp);
+	sp_free_ccp_irq(ccp->sp, ccp);
 
 e_pool:
 	for (i = 0; i < ccp->cmd_q_count; i++)
@@ -549,7 +549,7 @@ static void ccp_destroy(struct ccp_device *ccp)
 		if (ccp->cmd_q[i].kthread)
 			kthread_stop(ccp->cmd_q[i].kthread);
 
-	ccp->free_irq(ccp);
+	sp_free_ccp_irq(ccp->sp, ccp);
 
 	for (i = 0; i < ccp->cmd_q_count; i++)
 		dma_pool_destroy(ccp->cmd_q[i].dma_pool);
drivers/crypto/ccp/ccp-dev-v5.c +3 -4
index 8ed2b37..b0391f0 100644
@@ -880,7 +880,7 @@ static int ccp5_init(struct ccp_device *ccp)
 
 	dev_dbg(dev, "Requesting an IRQ...\n");
 	/* Request an irq */
-	ret = ccp->get_irq(ccp);
+	ret = sp_request_ccp_irq(ccp->sp, ccp5_irq_handler, ccp->name, ccp);
 	if (ret) {
 		dev_err(dev, "unable to allocate an IRQ\n");
 		goto e_pool;
@@ -986,7 +986,7 @@ static int ccp5_init(struct ccp_device *ccp)
 			kthread_stop(ccp->cmd_q[i].kthread);
 
 e_irq:
-	ccp->free_irq(ccp);
+	sp_free_ccp_irq(ccp->sp, ccp);
 
 e_pool:
 	for (i = 0; i < ccp->cmd_q_count; i++)
@@ -1036,7 +1036,7 @@ static void ccp5_destroy(struct ccp_device *ccp)
 		if (ccp->cmd_q[i].kthread)
 			kthread_stop(ccp->cmd_q[i].kthread);
 
-	ccp->free_irq(ccp);
+	sp_free_ccp_irq(ccp->sp, ccp);
 
 	for (i = 0; i < ccp->cmd_q_count; i++) {
 		cmd_q = &ccp->cmd_q[i];
@@ -1105,7 +1105,6 @@ static const struct ccp_actions ccp5_actions = {
 	.init = ccp5_init,
 	.destroy = ccp5_destroy,
 	.get_free_slots = ccp5_get_free_slots,
-	.irqhandler = ccp5_irq_handler,
 };
 
 const struct ccp_vdata ccpv5a = {
drivers/crypto/ccp/ccp-dev.c +1 -2
index 8a1674a..7c751bf 100644
@@ -599,8 +599,7 @@ int ccp_dev_init(struct sp_device *sp)
 		goto e_err;
 	}
 
-	ccp->get_irq = sp->get_irq;
-	ccp->free_irq = sp->free_irq;
+	ccp->use_tasklet = sp->use_tasklet;
 
 	ccp->io_regs = sp->io_map + ccp->vdata->offset;
 	if (ccp->vdata->setup)
drivers/crypto/ccp/ccp-dev.h +0 -2
index ca44821..193f309 100644
@@ -351,8 +351,6 @@ struct ccp_device {
 	/* Bus specific device information
 	 */
 	void *dev_specific;
-	int (*get_irq)(struct ccp_device *ccp);
-	void (*free_irq)(struct ccp_device *ccp);
 	unsigned int qim;
 	unsigned int irq;
 	bool use_tasklet;
drivers/crypto/ccp/ccp-pci.c +31 -72

176 lines not on this page · raw message

drivers/crypto/ccp/ccp-platform.c +27 -30

92 lines not on this page · raw message

drivers/crypto/ccp/sp-dev.c +107 -0

113 lines not on this page · raw message

drivers/crypto/ccp/sp-dev.h +15 -2
index b958ef9..77f3735 100644
@@ -68,9 +68,15 @@ struct sp_device {
 	unsigned int axcache;
 
 	bool irq_registered;
+	bool use_tasklet;
 
-	int (*get_irq)(struct ccp_device *ccp);
-	void (*free_irq)(struct ccp_device *ccp);
+	unsigned int ccp_irq;
+	irq_handler_t ccp_irq_handler;
+	void *ccp_irq_data;
+
+	unsigned int psp_irq;
+	irq_handler_t psp_irq_handler;
+	void *psp_irq_data;
 
 	void *ccp_data;
 	void *psp_data;
@@ -91,6 +97,13 @@ struct sp_device *sp_get_master(void);
 int sp_suspend(struct sp_device *sp, pm_message_t state);
 int sp_resume(struct sp_device *sp);
 
+int sp_request_ccp_irq(struct sp_device *sp, irq_handler_t handler,
+		       const char *name, void *data);
+void sp_free_ccp_irq(struct sp_device *sp, void *data);
+int sp_request_psp_irq(struct sp_device *sp, irq_handler_t handler,
+		       const char *name, void *data);
+void sp_free_psp_irq(struct sp_device *sp, void *data);
+
 #ifdef CONFIG_CRYPTO_DEV_CCP
 
 int ccp_dev_init(struct sp_device *sp);
Signature · 1 line
2.9.4