diff mbox series

[v2,3/4] crypto: ccp: Allow PSP driver to load without SEV/TEE support

Message ID 20220329164117.1449-4-mario.limonciello@amd.com (mailing list archive)
State Superseded
Delegated to: Herbert Xu
Headers show
Series Export PSP security attributes | expand

Commit Message

Mario Limonciello March 29, 2022, 4:41 p.m. UTC
Previously the PSP probe routine would fail if both SEV and TEE were
missing.  This is possibly the case for some client parts.

As capabilities can now be accessed from userspace, it may still be
useful to have the PSP driver finish loading so that those capabilities
can be read.

Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
 * Whitespace fixes
---
 drivers/crypto/ccp/psp-dev.c | 2 +-
 drivers/crypto/ccp/sp-dev.c  | 6 ++++++
 2 files changed, 7 insertions(+), 1 deletion(-)

Comments

Tom Lendacky March 31, 2022, 8:10 p.m. UTC | #1
On 3/29/22 11:41, Mario Limonciello wrote:
> Previously the PSP probe routine would fail if both SEV and TEE were
> missing.  This is possibly the case for some client parts.
> 
> As capabilities can now be accessed from userspace, it may still be
> useful to have the PSP driver finish loading so that those capabilities
> can be read.
> 
> Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
> ---
> v1->v2:
>   * Whitespace fixes
> ---
>   drivers/crypto/ccp/psp-dev.c | 2 +-
>   drivers/crypto/ccp/sp-dev.c  | 6 ++++++
>   2 files changed, 7 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
> index 8cd404121cd5..3f47b2d81e3c 100644
> --- a/drivers/crypto/ccp/psp-dev.c
> +++ b/drivers/crypto/ccp/psp-dev.c
> @@ -158,7 +158,7 @@ int psp_dev_init(struct sp_device *sp)
>   
>   	ret = psp_check_support(psp);
>   	if (ret)
> -		goto e_disable;
> +		return 0;
>   
>   	/* Disable and clear interrupts until ready */
>   	iowrite32(0, psp->io_regs + psp->vdata->inten_reg);
> diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
> index 7eb3e4668286..3486ab2a8982 100644
> --- a/drivers/crypto/ccp/sp-dev.c
> +++ b/drivers/crypto/ccp/sp-dev.c
> @@ -132,6 +132,9 @@ int sp_request_psp_irq(struct sp_device *sp, irq_handler_t handler,
>   
>   void sp_free_ccp_irq(struct sp_device *sp, void *data)
>   {
> +	if (!sp->irq_registered)
> +		return;
> +

I just noticed that irq_registered is only set when a single interrupt 
ends up being used. When both the CCP and PSP get their own interrupts 
(the common case), this will result in free_irq() not being called.

So this needs to be fixed. I would think just allowing the IRQs to be 
requested and freed whenever the driver is loaded (regardless of whether 
they would be used) might be the best way forward.

Thanks,
Tom

>   	if ((sp->psp_irq == sp->ccp_irq) && sp->dev_vdata->psp_vdata) {
>   		/* Using common routine to manage all interrupts */
>   		if (!sp->psp_irq_handler) {
> @@ -151,6 +154,9 @@ void sp_free_ccp_irq(struct sp_device *sp, void *data)
>   
>   void sp_free_psp_irq(struct sp_device *sp, void *data)
>   {
> +	if (!sp->irq_registered)
> +		return;
> +
>   	if ((sp->psp_irq == sp->ccp_irq) && sp->dev_vdata->ccp_vdata) {
>   		/* Using common routine to manage all interrupts */
>   		if (!sp->ccp_irq_handler) {
diff mbox series

Patch

diff --git a/drivers/crypto/ccp/psp-dev.c b/drivers/crypto/ccp/psp-dev.c
index 8cd404121cd5..3f47b2d81e3c 100644
--- a/drivers/crypto/ccp/psp-dev.c
+++ b/drivers/crypto/ccp/psp-dev.c
@@ -158,7 +158,7 @@  int psp_dev_init(struct sp_device *sp)
 
 	ret = psp_check_support(psp);
 	if (ret)
-		goto e_disable;
+		return 0;
 
 	/* Disable and clear interrupts until ready */
 	iowrite32(0, psp->io_regs + psp->vdata->inten_reg);
diff --git a/drivers/crypto/ccp/sp-dev.c b/drivers/crypto/ccp/sp-dev.c
index 7eb3e4668286..3486ab2a8982 100644
--- a/drivers/crypto/ccp/sp-dev.c
+++ b/drivers/crypto/ccp/sp-dev.c
@@ -132,6 +132,9 @@  int sp_request_psp_irq(struct sp_device *sp, irq_handler_t handler,
 
 void sp_free_ccp_irq(struct sp_device *sp, void *data)
 {
+	if (!sp->irq_registered)
+		return;
+
 	if ((sp->psp_irq == sp->ccp_irq) && sp->dev_vdata->psp_vdata) {
 		/* Using common routine to manage all interrupts */
 		if (!sp->psp_irq_handler) {
@@ -151,6 +154,9 @@  void sp_free_ccp_irq(struct sp_device *sp, void *data)
 
 void sp_free_psp_irq(struct sp_device *sp, void *data)
 {
+	if (!sp->irq_registered)
+		return;
+
 	if ((sp->psp_irq == sp->ccp_irq) && sp->dev_vdata->ccp_vdata) {
 		/* Using common routine to manage all interrupts */
 		if (!sp->ccp_irq_handler) {