linux-crypto.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count()
@ 2022-06-13 19:16 Tom Lendacky
  2022-06-13 21:30 ` Rob Herring
  2022-06-24  9:14 ` Herbert Xu
  0 siblings, 2 replies; 3+ messages in thread
From: Tom Lendacky @ 2022-06-13 19:16 UTC (permalink / raw)
  To: linux-crypto, linux-kernel
  Cc: Herbert Xu, David S. Miller, John Allen, Rob Herring,
	Marc Zyngier, Lad Prabhakar

The ccp driver loops through the platform device resources array to get
the IRQ count for the device. With commit a1a2b7125e10 ("of/platform: Drop
static setup of IRQ resource from DT core"), the IRQ resources are no
longer stored in the platform device resource array. As a result, the IRQ
count is now always zero. This causes the driver to issue a second call to
platform_get_irq(), which fails if the IRQ count is really 1, causing the
loading of the driver to fail.

Replace looping through the resources array to count the number of IRQs
with a call to platform_irq_count().

Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 drivers/crypto/ccp/sp-platform.c | 12 ++----------
 1 file changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/crypto/ccp/sp-platform.c b/drivers/crypto/ccp/sp-platform.c
index 9dba52fbee99..7d79a8744f9a 100644
--- a/drivers/crypto/ccp/sp-platform.c
+++ b/drivers/crypto/ccp/sp-platform.c
@@ -85,17 +85,9 @@ static int sp_get_irqs(struct sp_device *sp)
 	struct sp_platform *sp_platform = sp->dev_specific;
 	struct device *dev = sp->dev;
 	struct platform_device *pdev = to_platform_device(dev);
-	unsigned int i, count;
 	int ret;
 
-	for (i = 0, count = 0; i < pdev->num_resources; i++) {
-		struct resource *res = &pdev->resource[i];
-
-		if (resource_type(res) == IORESOURCE_IRQ)
-			count++;
-	}
-
-	sp_platform->irq_count = count;
+	sp_platform->irq_count = platform_irq_count(pdev);
 
 	ret = platform_get_irq(pdev, 0);
 	if (ret < 0) {
@@ -104,7 +96,7 @@ static int sp_get_irqs(struct sp_device *sp)
 	}
 
 	sp->psp_irq = ret;
-	if (count == 1) {
+	if (sp_platform->irq_count == 1) {
 		sp->ccp_irq = ret;
 	} else {
 		ret = platform_get_irq(pdev, 1);
-- 
2.36.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count()
  2022-06-13 19:16 [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count() Tom Lendacky
@ 2022-06-13 21:30 ` Rob Herring
  2022-06-24  9:14 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Rob Herring @ 2022-06-13 21:30 UTC (permalink / raw)
  To: Tom Lendacky
  Cc: open list:HARDWARE RANDOM NUMBER GENERATOR CORE, linux-kernel,
	Herbert Xu, David S. Miller, John Allen, Marc Zyngier,
	Lad Prabhakar

On Mon, Jun 13, 2022 at 1:16 PM Tom Lendacky <thomas.lendacky@amd.com> wrote:
>
> The ccp driver loops through the platform device resources array to get
> the IRQ count for the device. With commit a1a2b7125e10 ("of/platform: Drop
> static setup of IRQ resource from DT core"), the IRQ resources are no
> longer stored in the platform device resource array. As a result, the IRQ
> count is now always zero. This causes the driver to issue a second call to
> platform_get_irq(), which fails if the IRQ count is really 1, causing the
> loading of the driver to fail.
>
> Replace looping through the resources array to count the number of IRQs
> with a call to platform_irq_count().
>
> Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  drivers/crypto/ccp/sp-platform.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)

Reviewed-by: Rob Herring <robh@kernel.org>

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count()
  2022-06-13 19:16 [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count() Tom Lendacky
  2022-06-13 21:30 ` Rob Herring
@ 2022-06-24  9:14 ` Herbert Xu
  1 sibling, 0 replies; 3+ messages in thread
From: Herbert Xu @ 2022-06-24  9:14 UTC (permalink / raw)
  To: Tom Lendacky
  Cc: linux-crypto, linux-kernel, David S. Miller, John Allen,
	Rob Herring, Marc Zyngier, Lad Prabhakar

On Mon, Jun 13, 2022 at 02:16:27PM -0500, Tom Lendacky wrote:
> The ccp driver loops through the platform device resources array to get
> the IRQ count for the device. With commit a1a2b7125e10 ("of/platform: Drop
> static setup of IRQ resource from DT core"), the IRQ resources are no
> longer stored in the platform device resource array. As a result, the IRQ
> count is now always zero. This causes the driver to issue a second call to
> platform_get_irq(), which fails if the IRQ count is really 1, causing the
> loading of the driver to fail.
> 
> Replace looping through the resources array to count the number of IRQs
> with a call to platform_irq_count().
> 
> Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
> Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
> ---
>  drivers/crypto/ccp/sp-platform.c | 12 ++----------
>  1 file changed, 2 insertions(+), 10 deletions(-)

Patch applied.  Thanks.
-- 
Email: Herbert Xu <herbert@gondor.apana.org.au>
Home Page: http://gondor.apana.org.au/~herbert/
PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2022-06-24  9:14 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-13 19:16 [PATCH] crypto: ccp - Fix device IRQ counting by using platform_irq_count() Tom Lendacky
2022-06-13 21:30 ` Rob Herring
2022-06-24  9:14 ` Herbert Xu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).