All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] iommu/arm-smmu: Use platform_irq_count()
@ 2021-12-23 13:00 ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

Hi All,

This patch series aims to drop using platform_get_resource() for IRQ types
in preparation for removal of static setup of IRQ resource from DT core
code.

Dropping usage of platform_get_resource() was agreed based on
the discussion [0].

[0] https://patchwork.kernel.org/project/linux-renesas-soc/
patch/20211209001056.29774-1-prabhakar.mahadev-lad.rj@bp.renesas.com/

While I was at it created patch 2/2 to propagate errors upstream.

Cheers,
Prabhakar

Lad Prabhakar (2):
  iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  iommu/arm-smmu: Propagate errors from platform_get_irq()

 drivers/iommu/arm/arm-smmu/arm-smmu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.17.1


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

* [PATCH 0/2] iommu/arm-smmu: Use platform_irq_count()
@ 2021-12-23 13:00 ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

Hi All,

This patch series aims to drop using platform_get_resource() for IRQ types
in preparation for removal of static setup of IRQ resource from DT core
code.

Dropping usage of platform_get_resource() was agreed based on
the discussion [0].

[0] https://patchwork.kernel.org/project/linux-renesas-soc/
patch/20211209001056.29774-1-prabhakar.mahadev-lad.rj@bp.renesas.com/

While I was at it created patch 2/2 to propagate errors upstream.

Cheers,
Prabhakar

Lad Prabhakar (2):
  iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  iommu/arm-smmu: Propagate errors from platform_get_irq()

 drivers/iommu/arm/arm-smmu/arm-smmu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 0/2] iommu/arm-smmu: Use platform_irq_count()
@ 2021-12-23 13:00 ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Isaac J. Manjarres, Xin Tan, Lad Prabhakar, Sai Prakash Ranjan,
	linux-kernel, Prabhakar, Rob Herring

Hi All,

This patch series aims to drop using platform_get_resource() for IRQ types
in preparation for removal of static setup of IRQ resource from DT core
code.

Dropping usage of platform_get_resource() was agreed based on
the discussion [0].

[0] https://patchwork.kernel.org/project/linux-renesas-soc/
patch/20211209001056.29774-1-prabhakar.mahadev-lad.rj@bp.renesas.com/

While I was at it created patch 2/2 to propagate errors upstream.

Cheers,
Prabhakar

Lad Prabhakar (2):
  iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  iommu/arm-smmu: Propagate errors from platform_get_irq()

 drivers/iommu/arm/arm-smmu/arm-smmu.c | 14 +++++++-------
 1 file changed, 7 insertions(+), 7 deletions(-)

-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2021-12-23 13:00 ` Lad Prabhakar
  (?)
@ 2021-12-23 13:00   ` Lad Prabhakar
  -1 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_count().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4bc75c4ce402..4844cd075644 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 	if (IS_ERR(smmu))
 		return PTR_ERR(smmu);
 
-	num_irqs = 0;
-	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
-		num_irqs++;
-		if (num_irqs > smmu->num_global_irqs)
-			smmu->num_context_irqs++;
-	}
+	num_irqs = platform_irq_count(pdev);
+	if (num_irqs < 0)
+		return num_irqs;
+
+	if (num_irqs > smmu->num_global_irqs)
+		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
 
 	if (!smmu->num_context_irqs) {
 		dev_err(dev, "found %d interrupts but expected at least %d\n",
-- 
2.17.1


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

* [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 13:00   ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_count().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4bc75c4ce402..4844cd075644 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 	if (IS_ERR(smmu))
 		return PTR_ERR(smmu);
 
-	num_irqs = 0;
-	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
-		num_irqs++;
-		if (num_irqs > smmu->num_global_irqs)
-			smmu->num_context_irqs++;
-	}
+	num_irqs = platform_irq_count(pdev);
+	if (num_irqs < 0)
+		return num_irqs;
+
+	if (num_irqs > smmu->num_global_irqs)
+		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
 
 	if (!smmu->num_context_irqs) {
 		dev_err(dev, "found %d interrupts but expected at least %d\n",
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 13:00   ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Isaac J. Manjarres, Xin Tan, Lad Prabhakar, Sai Prakash Ranjan,
	linux-kernel, Prabhakar, Rob Herring

platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
allocation of IRQ resources in DT core code, this causes an issue
when using hierarchical interrupt domains using "interrupts" property
in the node as this bypasses the hierarchical setup and messes up the
irq chaining.

In preparation for removal of static setup of IRQ resource from DT core
code use platform_get_irq_count().

Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4bc75c4ce402..4844cd075644 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 	if (IS_ERR(smmu))
 		return PTR_ERR(smmu);
 
-	num_irqs = 0;
-	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
-		num_irqs++;
-		if (num_irqs > smmu->num_global_irqs)
-			smmu->num_context_irqs++;
-	}
+	num_irqs = platform_irq_count(pdev);
+	if (num_irqs < 0)
+		return num_irqs;
+
+	if (num_irqs > smmu->num_global_irqs)
+		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
 
 	if (!smmu->num_context_irqs) {
 		dev_err(dev, "found %d interrupts but expected at least %d\n",
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
  2021-12-23 13:00 ` Lad Prabhakar
  (?)
@ 2021-12-23 13:00   ` Lad Prabhakar
  -1 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

The driver overrides the error code returned by platform_get_irq() to
-ENODEV. Switch to propagating the error code upstream so that errors
such as -EPROBE_DEFER are handled.

Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4844cd075644..6cf5612efcda 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 		int irq = platform_get_irq(pdev, i);
 
 		if (irq < 0)
-			return -ENODEV;
+			return irq;
 		smmu->irqs[i] = irq;
 	}
 
-- 
2.17.1


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

* [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
@ 2021-12-23 13:00   ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar, Lad Prabhakar

The driver overrides the error code returned by platform_get_irq() to
-ENODEV. Switch to propagating the error code upstream so that errors
such as -EPROBE_DEFER are handled.

Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4844cd075644..6cf5612efcda 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 		int irq = platform_get_irq(pdev, i);
 
 		if (irq < 0)
-			return -ENODEV;
+			return irq;
 		smmu->irqs[i] = irq;
 	}
 
-- 
2.17.1


_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
@ 2021-12-23 13:00   ` Lad Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad Prabhakar @ 2021-12-23 13:00 UTC (permalink / raw)
  To: Will Deacon, Robin Murphy, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Isaac J. Manjarres, Xin Tan, Lad Prabhakar, Sai Prakash Ranjan,
	linux-kernel, Prabhakar, Rob Herring

The driver overrides the error code returned by platform_get_irq() to
-ENODEV. Switch to propagating the error code upstream so that errors
such as -EPROBE_DEFER are handled.

Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
---
 drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
index 4844cd075644..6cf5612efcda 100644
--- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
+++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
@@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
 		int irq = platform_get_irq(pdev, i);
 
 		if (irq < 0)
-			return -ENODEV;
+			return irq;
 		smmu->irqs[i] = irq;
 	}
 
-- 
2.17.1

_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2021-12-23 13:00   ` Lad Prabhakar
  (?)
@ 2021-12-23 14:14     ` Robin Murphy
  -1 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:14 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2021-12-23 13:00, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypasses the hierarchical setup and messes up the
> irq chaining.
> 
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq_count().

Nit: platform_irq_count()

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4bc75c4ce402..4844cd075644 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   	if (IS_ERR(smmu))
>   		return PTR_ERR(smmu);
>   
> -	num_irqs = 0;
> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> -		num_irqs++;
> -		if (num_irqs > smmu->num_global_irqs)
> -			smmu->num_context_irqs++;
> -	}
> +	num_irqs = platform_irq_count(pdev);
> +	if (num_irqs < 0)
> +		return num_irqs;
> +
> +	if (num_irqs > smmu->num_global_irqs)
> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);

This seems a bit overcomplicated. I reckon:

	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
	if (num_irqs <= smmu->num_global_irqs) {
		dev_err(...

should do it.

However, FYI I have some patches refactoring most of the IRQ stuff here 
that I plan to post next cycle (didn't quite have time to get them done 
for 5.17 as I'd hoped...), so unless this needs to go in right now as an 
urgent fix, I'm happy to take care of removing platform_get_resource() 
as part of that if it's easier.

Thanks,
Robin.

>   
>   	if (!smmu->num_context_irqs) {
>   		dev_err(dev, "found %d interrupts but expected at least %d\n",

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 14:14     ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:14 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Isaac J. Manjarres, Xin Tan, Sai Prakash Ranjan, linux-kernel,
	Prabhakar, Rob Herring

On 2021-12-23 13:00, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypasses the hierarchical setup and messes up the
> irq chaining.
> 
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq_count().

Nit: platform_irq_count()

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4bc75c4ce402..4844cd075644 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   	if (IS_ERR(smmu))
>   		return PTR_ERR(smmu);
>   
> -	num_irqs = 0;
> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> -		num_irqs++;
> -		if (num_irqs > smmu->num_global_irqs)
> -			smmu->num_context_irqs++;
> -	}
> +	num_irqs = platform_irq_count(pdev);
> +	if (num_irqs < 0)
> +		return num_irqs;
> +
> +	if (num_irqs > smmu->num_global_irqs)
> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);

This seems a bit overcomplicated. I reckon:

	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
	if (num_irqs <= smmu->num_global_irqs) {
		dev_err(...

should do it.

However, FYI I have some patches refactoring most of the IRQ stuff here 
that I plan to post next cycle (didn't quite have time to get them done 
for 5.17 as I'd hoped...), so unless this needs to go in right now as an 
urgent fix, I'm happy to take care of removing platform_get_resource() 
as part of that if it's easier.

Thanks,
Robin.

>   
>   	if (!smmu->num_context_irqs) {
>   		dev_err(dev, "found %d interrupts but expected at least %d\n",
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 14:14     ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:14 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2021-12-23 13:00, Lad Prabhakar wrote:
> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> allocation of IRQ resources in DT core code, this causes an issue
> when using hierarchical interrupt domains using "interrupts" property
> in the node as this bypasses the hierarchical setup and messes up the
> irq chaining.
> 
> In preparation for removal of static setup of IRQ resource from DT core
> code use platform_get_irq_count().

Nit: platform_irq_count()

> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>   1 file changed, 6 insertions(+), 6 deletions(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4bc75c4ce402..4844cd075644 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   	if (IS_ERR(smmu))
>   		return PTR_ERR(smmu);
>   
> -	num_irqs = 0;
> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> -		num_irqs++;
> -		if (num_irqs > smmu->num_global_irqs)
> -			smmu->num_context_irqs++;
> -	}
> +	num_irqs = platform_irq_count(pdev);
> +	if (num_irqs < 0)
> +		return num_irqs;
> +
> +	if (num_irqs > smmu->num_global_irqs)
> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);

This seems a bit overcomplicated. I reckon:

	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
	if (num_irqs <= smmu->num_global_irqs) {
		dev_err(...

should do it.

However, FYI I have some patches refactoring most of the IRQ stuff here 
that I plan to post next cycle (didn't quite have time to get them done 
for 5.17 as I'd hoped...), so unless this needs to go in right now as an 
urgent fix, I'm happy to take care of removing platform_get_resource() 
as part of that if it's easier.

Thanks,
Robin.

>   
>   	if (!smmu->num_context_irqs) {
>   		dev_err(dev, "found %d interrupts but expected at least %d\n",

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
  2021-12-23 13:00   ` Lad Prabhakar
  (?)
@ 2021-12-23 14:19     ` Robin Murphy
  -1 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:19 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2021-12-23 13:00, Lad Prabhakar wrote:
> The driver overrides the error code returned by platform_get_irq() to
> -ENODEV. Switch to propagating the error code upstream so that errors
> such as -EPROBE_DEFER are handled.

I wouldn't usually expect an SMMU to be wired up to a secondary 
interrupt controller that could cause deferral, but on the other hand I 
don't think there's any good reason *not* to propagate the original 
error anyway, so sure, why not.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4844cd075644..6cf5612efcda 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   		int irq = platform_get_irq(pdev, i);
>   
>   		if (irq < 0)
> -			return -ENODEV;
> +			return irq;
>   		smmu->irqs[i] = irq;
>   	}
>   

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

* Re: [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
@ 2021-12-23 14:19     ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:19 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Isaac J. Manjarres, Xin Tan, Sai Prakash Ranjan, linux-kernel,
	Prabhakar, Rob Herring

On 2021-12-23 13:00, Lad Prabhakar wrote:
> The driver overrides the error code returned by platform_get_irq() to
> -ENODEV. Switch to propagating the error code upstream so that errors
> such as -EPROBE_DEFER are handled.

I wouldn't usually expect an SMMU to be wired up to a secondary 
interrupt controller that could cause deferral, but on the other hand I 
don't think there's any good reason *not* to propagate the original 
error anyway, so sure, why not.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4844cd075644..6cf5612efcda 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   		int irq = platform_get_irq(pdev, i);
>   
>   		if (irq < 0)
> -			return -ENODEV;
> +			return irq;
>   		smmu->irqs[i] = irq;
>   	}
>   
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq()
@ 2021-12-23 14:19     ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2021-12-23 14:19 UTC (permalink / raw)
  To: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark,
	linux-arm-kernel, iommu
  Cc: Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2021-12-23 13:00, Lad Prabhakar wrote:
> The driver overrides the error code returned by platform_get_irq() to
> -ENODEV. Switch to propagating the error code upstream so that errors
> such as -EPROBE_DEFER are handled.

I wouldn't usually expect an SMMU to be wired up to a secondary 
interrupt controller that could cause deferral, but on the other hand I 
don't think there's any good reason *not* to propagate the original 
error anyway, so sure, why not.

Reviewed-by: Robin Murphy <robin.murphy@arm.com>

> Fixes: 9ec36cafe43b ("of/irq: do irq resolution in platform_get_irq")
> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> ---
>   drivers/iommu/arm/arm-smmu/arm-smmu.c | 2 +-
>   1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> index 4844cd075644..6cf5612efcda 100644
> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> @@ -2129,7 +2129,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>   		int irq = platform_get_irq(pdev, i);
>   
>   		if (irq < 0)
> -			return -ENODEV;
> +			return irq;
>   		smmu->irqs[i] = irq;
>   	}
>   

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2021-12-23 14:14     ` Robin Murphy
  (?)
@ 2021-12-23 17:36       ` Lad, Prabhakar
  -1 siblings, 0 replies; 27+ messages in thread
From: Lad, Prabhakar @ 2021-12-23 17:36 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark, LAK,
	Linux IOMMU, Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres,
	Rob Herring, LKML

Hi Robin,

Thank you for the review.

On Thu, Dec 23, 2021 at 2:14 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> >
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
>
> Nit: platform_irq_count()
>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >       if (IS_ERR(smmu))
> >               return PTR_ERR(smmu);
> >
> > -     num_irqs = 0;
> > -     while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -             num_irqs++;
> > -             if (num_irqs > smmu->num_global_irqs)
> > -                     smmu->num_context_irqs++;
> > -     }
> > +     num_irqs = platform_irq_count(pdev);
> > +     if (num_irqs < 0)
> > +             return num_irqs;
> > +
> > +     if (num_irqs > smmu->num_global_irqs)
> > +             smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>
> This seems a bit overcomplicated. I reckon:
>
>         smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>         if (num_irqs <= smmu->num_global_irqs) {
>                 dev_err(...
>
> should do it.
>
Agreed.

> However, FYI I have some patches refactoring most of the IRQ stuff here
> that I plan to post next cycle (didn't quite have time to get them done
> for 5.17 as I'd hoped...), so unless this needs to go in right now as an
> urgent fix, I'm happy to take care of removing platform_get_resource()
> as part of that if it's easier.
>
Fine by me, let me know if it gets any later than planned I'll send a v2.

Cheers,
Prabhakar

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 17:36       ` Lad, Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad, Prabhakar @ 2021-12-23 17:36 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Rob Clark, Isaac J. Manjarres, Xin Tan, Lad Prabhakar, LKML,
	Linux IOMMU, Rob Herring, Sai Prakash Ranjan, Will Deacon, LAK

Hi Robin,

Thank you for the review.

On Thu, Dec 23, 2021 at 2:14 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> >
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
>
> Nit: platform_irq_count()
>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >       if (IS_ERR(smmu))
> >               return PTR_ERR(smmu);
> >
> > -     num_irqs = 0;
> > -     while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -             num_irqs++;
> > -             if (num_irqs > smmu->num_global_irqs)
> > -                     smmu->num_context_irqs++;
> > -     }
> > +     num_irqs = platform_irq_count(pdev);
> > +     if (num_irqs < 0)
> > +             return num_irqs;
> > +
> > +     if (num_irqs > smmu->num_global_irqs)
> > +             smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>
> This seems a bit overcomplicated. I reckon:
>
>         smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>         if (num_irqs <= smmu->num_global_irqs) {
>                 dev_err(...
>
> should do it.
>
Agreed.

> However, FYI I have some patches refactoring most of the IRQ stuff here
> that I plan to post next cycle (didn't quite have time to get them done
> for 5.17 as I'd hoped...), so unless this needs to go in right now as an
> urgent fix, I'm happy to take care of removing platform_get_resource()
> as part of that if it's easier.
>
Fine by me, let me know if it gets any later than planned I'll send a v2.

Cheers,
Prabhakar
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2021-12-23 17:36       ` Lad, Prabhakar
  0 siblings, 0 replies; 27+ messages in thread
From: Lad, Prabhakar @ 2021-12-23 17:36 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Will Deacon, Joerg Roedel, Rob Clark, LAK,
	Linux IOMMU, Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres,
	Rob Herring, LKML

Hi Robin,

Thank you for the review.

On Thu, Dec 23, 2021 at 2:14 PM Robin Murphy <robin.murphy@arm.com> wrote:
>
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> >
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
>
> Nit: platform_irq_count()
>
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> >
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >       if (IS_ERR(smmu))
> >               return PTR_ERR(smmu);
> >
> > -     num_irqs = 0;
> > -     while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -             num_irqs++;
> > -             if (num_irqs > smmu->num_global_irqs)
> > -                     smmu->num_context_irqs++;
> > -     }
> > +     num_irqs = platform_irq_count(pdev);
> > +     if (num_irqs < 0)
> > +             return num_irqs;
> > +
> > +     if (num_irqs > smmu->num_global_irqs)
> > +             smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>
> This seems a bit overcomplicated. I reckon:
>
>         smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>         if (num_irqs <= smmu->num_global_irqs) {
>                 dev_err(...
>
> should do it.
>
Agreed.

> However, FYI I have some patches refactoring most of the IRQ stuff here
> that I plan to post next cycle (didn't quite have time to get them done
> for 5.17 as I'd hoped...), so unless this needs to go in right now as an
> urgent fix, I'm happy to take care of removing platform_get_resource()
> as part of that if it's easier.
>
Fine by me, let me know if it gets any later than planned I'll send a v2.

Cheers,
Prabhakar

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2021-12-23 14:14     ` Robin Murphy
  (?)
@ 2022-02-08 15:19       ` Will Deacon
  -1 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:19 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> > 
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
> 
> Nit: platform_irq_count()
> 
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >   	if (IS_ERR(smmu))
> >   		return PTR_ERR(smmu);
> > -	num_irqs = 0;
> > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -		num_irqs++;
> > -		if (num_irqs > smmu->num_global_irqs)
> > -			smmu->num_context_irqs++;
> > -	}
> > +	num_irqs = platform_irq_count(pdev);
> > +	if (num_irqs < 0)
> > +		return num_irqs;
> > +
> > +	if (num_irqs > smmu->num_global_irqs)
> > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> 
> This seems a bit overcomplicated. I reckon:
> 
> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> 	if (num_irqs <= smmu->num_global_irqs) {
> 		dev_err(...
> 
> should do it.
> 
> However, FYI I have some patches refactoring most of the IRQ stuff here that
> I plan to post next cycle (didn't quite have time to get them done for 5.17
> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> I'm happy to take care of removing platform_get_resource() as part of that
> if it's easier.

Did you get anywhere with this? December 23rd is long forgotten by now ;)

Will

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:19       ` Will Deacon
  0 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:19 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Rob Clark, Isaac J. Manjarres, Xin Tan, Lad Prabhakar,
	linux-kernel, iommu, Rob Herring, Prabhakar, Sai Prakash Ranjan,
	linux-arm-kernel

On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> > 
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
> 
> Nit: platform_irq_count()
> 
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >   	if (IS_ERR(smmu))
> >   		return PTR_ERR(smmu);
> > -	num_irqs = 0;
> > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -		num_irqs++;
> > -		if (num_irqs > smmu->num_global_irqs)
> > -			smmu->num_context_irqs++;
> > -	}
> > +	num_irqs = platform_irq_count(pdev);
> > +	if (num_irqs < 0)
> > +		return num_irqs;
> > +
> > +	if (num_irqs > smmu->num_global_irqs)
> > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> 
> This seems a bit overcomplicated. I reckon:
> 
> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> 	if (num_irqs <= smmu->num_global_irqs) {
> 		dev_err(...
> 
> should do it.
> 
> However, FYI I have some patches refactoring most of the IRQ stuff here that
> I plan to post next cycle (didn't quite have time to get them done for 5.17
> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> I'm happy to take care of removing platform_get_resource() as part of that
> if it's easier.

Did you get anywhere with this? December 23rd is long forgotten by now ;)

Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:19       ` Will Deacon
  0 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:19 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> On 2021-12-23 13:00, Lad Prabhakar wrote:
> > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > allocation of IRQ resources in DT core code, this causes an issue
> > when using hierarchical interrupt domains using "interrupts" property
> > in the node as this bypasses the hierarchical setup and messes up the
> > irq chaining.
> > 
> > In preparation for removal of static setup of IRQ resource from DT core
> > code use platform_get_irq_count().
> 
> Nit: platform_irq_count()
> 
> > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > ---
> >   drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> >   1 file changed, 6 insertions(+), 6 deletions(-)
> > 
> > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > index 4bc75c4ce402..4844cd075644 100644
> > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> >   	if (IS_ERR(smmu))
> >   		return PTR_ERR(smmu);
> > -	num_irqs = 0;
> > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > -		num_irqs++;
> > -		if (num_irqs > smmu->num_global_irqs)
> > -			smmu->num_context_irqs++;
> > -	}
> > +	num_irqs = platform_irq_count(pdev);
> > +	if (num_irqs < 0)
> > +		return num_irqs;
> > +
> > +	if (num_irqs > smmu->num_global_irqs)
> > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> 
> This seems a bit overcomplicated. I reckon:
> 
> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> 	if (num_irqs <= smmu->num_global_irqs) {
> 		dev_err(...
> 
> should do it.
> 
> However, FYI I have some patches refactoring most of the IRQ stuff here that
> I plan to post next cycle (didn't quite have time to get them done for 5.17
> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> I'm happy to take care of removing platform_get_resource() as part of that
> if it's easier.

Did you get anywhere with this? December 23rd is long forgotten by now ;)

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2022-02-08 15:19       ` Will Deacon
  (?)
@ 2022-02-08 15:28         ` Robin Murphy
  -1 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2022-02-08 15:28 UTC (permalink / raw)
  To: Will Deacon
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2022-02-08 15:19, Will Deacon wrote:
> On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
>> On 2021-12-23 13:00, Lad Prabhakar wrote:
>>> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
>>> allocation of IRQ resources in DT core code, this causes an issue
>>> when using hierarchical interrupt domains using "interrupts" property
>>> in the node as this bypasses the hierarchical setup and messes up the
>>> irq chaining.
>>>
>>> In preparation for removal of static setup of IRQ resource from DT core
>>> code use platform_get_irq_count().
>>
>> Nit: platform_irq_count()
>>
>>> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>>> ---
>>>    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> index 4bc75c4ce402..4844cd075644 100644
>>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>>>    	if (IS_ERR(smmu))
>>>    		return PTR_ERR(smmu);
>>> -	num_irqs = 0;
>>> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
>>> -		num_irqs++;
>>> -		if (num_irqs > smmu->num_global_irqs)
>>> -			smmu->num_context_irqs++;
>>> -	}
>>> +	num_irqs = platform_irq_count(pdev);
>>> +	if (num_irqs < 0)
>>> +		return num_irqs;
>>> +
>>> +	if (num_irqs > smmu->num_global_irqs)
>>> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>>
>> This seems a bit overcomplicated. I reckon:
>>
>> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>> 	if (num_irqs <= smmu->num_global_irqs) {
>> 		dev_err(...
>>
>> should do it.
>>
>> However, FYI I have some patches refactoring most of the IRQ stuff here that
>> I plan to post next cycle (didn't quite have time to get them done for 5.17
>> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
>> I'm happy to take care of removing platform_get_resource() as part of that
>> if it's easier.
> 
> Did you get anywhere with this? December 23rd is long forgotten by now ;)

Yup: 
https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9

I'm still cleaning up the PMU driver that justifies the whole thing, but 
I can send that patch now if you reckon it's not complete nonsense out 
of context. Otherwise, I'll aim to get the whole lot out next week.


Cheers,
Robin.

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:28         ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2022-02-08 15:28 UTC (permalink / raw)
  To: Will Deacon
  Cc: Rob Clark, Isaac J. Manjarres, Xin Tan, Lad Prabhakar,
	linux-kernel, iommu, Rob Herring, Prabhakar, Sai Prakash Ranjan,
	linux-arm-kernel

On 2022-02-08 15:19, Will Deacon wrote:
> On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
>> On 2021-12-23 13:00, Lad Prabhakar wrote:
>>> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
>>> allocation of IRQ resources in DT core code, this causes an issue
>>> when using hierarchical interrupt domains using "interrupts" property
>>> in the node as this bypasses the hierarchical setup and messes up the
>>> irq chaining.
>>>
>>> In preparation for removal of static setup of IRQ resource from DT core
>>> code use platform_get_irq_count().
>>
>> Nit: platform_irq_count()
>>
>>> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>>> ---
>>>    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> index 4bc75c4ce402..4844cd075644 100644
>>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>>>    	if (IS_ERR(smmu))
>>>    		return PTR_ERR(smmu);
>>> -	num_irqs = 0;
>>> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
>>> -		num_irqs++;
>>> -		if (num_irqs > smmu->num_global_irqs)
>>> -			smmu->num_context_irqs++;
>>> -	}
>>> +	num_irqs = platform_irq_count(pdev);
>>> +	if (num_irqs < 0)
>>> +		return num_irqs;
>>> +
>>> +	if (num_irqs > smmu->num_global_irqs)
>>> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>>
>> This seems a bit overcomplicated. I reckon:
>>
>> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>> 	if (num_irqs <= smmu->num_global_irqs) {
>> 		dev_err(...
>>
>> should do it.
>>
>> However, FYI I have some patches refactoring most of the IRQ stuff here that
>> I plan to post next cycle (didn't quite have time to get them done for 5.17
>> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
>> I'm happy to take care of removing platform_get_resource() as part of that
>> if it's easier.
> 
> Did you get anywhere with this? December 23rd is long forgotten by now ;)

Yup: 
https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9

I'm still cleaning up the PMU driver that justifies the whole thing, but 
I can send that patch now if you reckon it's not complete nonsense out 
of context. Otherwise, I'll aim to get the whole lot out next week.


Cheers,
Robin.
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:28         ` Robin Murphy
  0 siblings, 0 replies; 27+ messages in thread
From: Robin Murphy @ 2022-02-08 15:28 UTC (permalink / raw)
  To: Will Deacon
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On 2022-02-08 15:19, Will Deacon wrote:
> On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
>> On 2021-12-23 13:00, Lad Prabhakar wrote:
>>> platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
>>> allocation of IRQ resources in DT core code, this causes an issue
>>> when using hierarchical interrupt domains using "interrupts" property
>>> in the node as this bypasses the hierarchical setup and messes up the
>>> irq chaining.
>>>
>>> In preparation for removal of static setup of IRQ resource from DT core
>>> code use platform_get_irq_count().
>>
>> Nit: platform_irq_count()
>>
>>> Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
>>> ---
>>>    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
>>>    1 file changed, 6 insertions(+), 6 deletions(-)
>>>
>>> diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> index 4bc75c4ce402..4844cd075644 100644
>>> --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
>>> @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
>>>    	if (IS_ERR(smmu))
>>>    		return PTR_ERR(smmu);
>>> -	num_irqs = 0;
>>> -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
>>> -		num_irqs++;
>>> -		if (num_irqs > smmu->num_global_irqs)
>>> -			smmu->num_context_irqs++;
>>> -	}
>>> +	num_irqs = platform_irq_count(pdev);
>>> +	if (num_irqs < 0)
>>> +		return num_irqs;
>>> +
>>> +	if (num_irqs > smmu->num_global_irqs)
>>> +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
>>
>> This seems a bit overcomplicated. I reckon:
>>
>> 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
>> 	if (num_irqs <= smmu->num_global_irqs) {
>> 		dev_err(...
>>
>> should do it.
>>
>> However, FYI I have some patches refactoring most of the IRQ stuff here that
>> I plan to post next cycle (didn't quite have time to get them done for 5.17
>> as I'd hoped...), so unless this needs to go in right now as an urgent fix,
>> I'm happy to take care of removing platform_get_resource() as part of that
>> if it's easier.
> 
> Did you get anywhere with this? December 23rd is long forgotten by now ;)

Yup: 
https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9

I'm still cleaning up the PMU driver that justifies the whole thing, but 
I can send that patch now if you reckon it's not complete nonsense out 
of context. Otherwise, I'll aim to get the whole lot out next week.


Cheers,
Robin.

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
  2022-02-08 15:28         ` Robin Murphy
  (?)
@ 2022-02-08 15:31           ` Will Deacon
  -1 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:31 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On Tue, Feb 08, 2022 at 03:28:50PM +0000, Robin Murphy wrote:
> On 2022-02-08 15:19, Will Deacon wrote:
> > On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> > > On 2021-12-23 13:00, Lad Prabhakar wrote:
> > > > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > > > allocation of IRQ resources in DT core code, this causes an issue
> > > > when using hierarchical interrupt domains using "interrupts" property
> > > > in the node as this bypasses the hierarchical setup and messes up the
> > > > irq chaining.
> > > > 
> > > > In preparation for removal of static setup of IRQ resource from DT core
> > > > code use platform_get_irq_count().
> > > 
> > > Nit: platform_irq_count()
> > > 
> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > ---
> > > >    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> > > >    1 file changed, 6 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > index 4bc75c4ce402..4844cd075644 100644
> > > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> > > >    	if (IS_ERR(smmu))
> > > >    		return PTR_ERR(smmu);
> > > > -	num_irqs = 0;
> > > > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > > > -		num_irqs++;
> > > > -		if (num_irqs > smmu->num_global_irqs)
> > > > -			smmu->num_context_irqs++;
> > > > -	}
> > > > +	num_irqs = platform_irq_count(pdev);
> > > > +	if (num_irqs < 0)
> > > > +		return num_irqs;
> > > > +
> > > > +	if (num_irqs > smmu->num_global_irqs)
> > > > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> > > 
> > > This seems a bit overcomplicated. I reckon:
> > > 
> > > 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> > > 	if (num_irqs <= smmu->num_global_irqs) {
> > > 		dev_err(...
> > > 
> > > should do it.
> > > 
> > > However, FYI I have some patches refactoring most of the IRQ stuff here that
> > > I plan to post next cycle (didn't quite have time to get them done for 5.17
> > > as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> > > I'm happy to take care of removing platform_get_resource() as part of that
> > > if it's easier.
> > 
> > Did you get anywhere with this? December 23rd is long forgotten by now ;)
> 
> Yup: https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9
> 
> I'm still cleaning up the PMU driver that justifies the whole thing, but I
> can send that patch now if you reckon it's not complete nonsense out of
> context. Otherwise, I'll aim to get the whole lot out next week.

Next week is fine, no rush. I was just trying to work out what to do with
Lad's patches in this thread and it sounds like I should ignore them and
wait for your series instead.

Will

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:31           ` Will Deacon
  0 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:31 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Rob Clark, Isaac J. Manjarres, Xin Tan, Lad Prabhakar,
	linux-kernel, iommu, Rob Herring, Prabhakar, Sai Prakash Ranjan,
	linux-arm-kernel

On Tue, Feb 08, 2022 at 03:28:50PM +0000, Robin Murphy wrote:
> On 2022-02-08 15:19, Will Deacon wrote:
> > On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> > > On 2021-12-23 13:00, Lad Prabhakar wrote:
> > > > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > > > allocation of IRQ resources in DT core code, this causes an issue
> > > > when using hierarchical interrupt domains using "interrupts" property
> > > > in the node as this bypasses the hierarchical setup and messes up the
> > > > irq chaining.
> > > > 
> > > > In preparation for removal of static setup of IRQ resource from DT core
> > > > code use platform_get_irq_count().
> > > 
> > > Nit: platform_irq_count()
> > > 
> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > ---
> > > >    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> > > >    1 file changed, 6 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > index 4bc75c4ce402..4844cd075644 100644
> > > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> > > >    	if (IS_ERR(smmu))
> > > >    		return PTR_ERR(smmu);
> > > > -	num_irqs = 0;
> > > > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > > > -		num_irqs++;
> > > > -		if (num_irqs > smmu->num_global_irqs)
> > > > -			smmu->num_context_irqs++;
> > > > -	}
> > > > +	num_irqs = platform_irq_count(pdev);
> > > > +	if (num_irqs < 0)
> > > > +		return num_irqs;
> > > > +
> > > > +	if (num_irqs > smmu->num_global_irqs)
> > > > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> > > 
> > > This seems a bit overcomplicated. I reckon:
> > > 
> > > 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> > > 	if (num_irqs <= smmu->num_global_irqs) {
> > > 		dev_err(...
> > > 
> > > should do it.
> > > 
> > > However, FYI I have some patches refactoring most of the IRQ stuff here that
> > > I plan to post next cycle (didn't quite have time to get them done for 5.17
> > > as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> > > I'm happy to take care of removing platform_get_resource() as part of that
> > > if it's easier.
> > 
> > Did you get anywhere with this? December 23rd is long forgotten by now ;)
> 
> Yup: https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9
> 
> I'm still cleaning up the PMU driver that justifies the whole thing, but I
> can send that patch now if you reckon it's not complete nonsense out of
> context. Otherwise, I'll aim to get the whole lot out next week.

Next week is fine, no rush. I was just trying to work out what to do with
Lad's patches in this thread and it sounds like I should ignore them and
wait for your series instead.

Will
_______________________________________________
iommu mailing list
iommu@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/iommu

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

* Re: [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count
@ 2022-02-08 15:31           ` Will Deacon
  0 siblings, 0 replies; 27+ messages in thread
From: Will Deacon @ 2022-02-08 15:31 UTC (permalink / raw)
  To: Robin Murphy
  Cc: Lad Prabhakar, Joerg Roedel, Rob Clark, linux-arm-kernel, iommu,
	Xin Tan, Sai Prakash Ranjan, Isaac J. Manjarres, Rob Herring,
	linux-kernel, Prabhakar

On Tue, Feb 08, 2022 at 03:28:50PM +0000, Robin Murphy wrote:
> On 2022-02-08 15:19, Will Deacon wrote:
> > On Thu, Dec 23, 2021 at 02:14:35PM +0000, Robin Murphy wrote:
> > > On 2021-12-23 13:00, Lad Prabhakar wrote:
> > > > platform_get_resource(pdev, IORESOURCE_IRQ, ..) relies on static
> > > > allocation of IRQ resources in DT core code, this causes an issue
> > > > when using hierarchical interrupt domains using "interrupts" property
> > > > in the node as this bypasses the hierarchical setup and messes up the
> > > > irq chaining.
> > > > 
> > > > In preparation for removal of static setup of IRQ resource from DT core
> > > > code use platform_get_irq_count().
> > > 
> > > Nit: platform_irq_count()
> > > 
> > > > Signed-off-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
> > > > ---
> > > >    drivers/iommu/arm/arm-smmu/arm-smmu.c | 12 ++++++------
> > > >    1 file changed, 6 insertions(+), 6 deletions(-)
> > > > 
> > > > diff --git a/drivers/iommu/arm/arm-smmu/arm-smmu.c b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > index 4bc75c4ce402..4844cd075644 100644
> > > > --- a/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > +++ b/drivers/iommu/arm/arm-smmu/arm-smmu.c
> > > > @@ -2105,12 +2105,12 @@ static int arm_smmu_device_probe(struct platform_device *pdev)
> > > >    	if (IS_ERR(smmu))
> > > >    		return PTR_ERR(smmu);
> > > > -	num_irqs = 0;
> > > > -	while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) {
> > > > -		num_irqs++;
> > > > -		if (num_irqs > smmu->num_global_irqs)
> > > > -			smmu->num_context_irqs++;
> > > > -	}
> > > > +	num_irqs = platform_irq_count(pdev);
> > > > +	if (num_irqs < 0)
> > > > +		return num_irqs;
> > > > +
> > > > +	if (num_irqs > smmu->num_global_irqs)
> > > > +		smmu->num_context_irqs += (num_irqs - smmu->num_global_irqs);
> > > 
> > > This seems a bit overcomplicated. I reckon:
> > > 
> > > 	smmu->num_context_irqs = num_irqs - smmu->num_global_irqs;
> > > 	if (num_irqs <= smmu->num_global_irqs) {
> > > 		dev_err(...
> > > 
> > > should do it.
> > > 
> > > However, FYI I have some patches refactoring most of the IRQ stuff here that
> > > I plan to post next cycle (didn't quite have time to get them done for 5.17
> > > as I'd hoped...), so unless this needs to go in right now as an urgent fix,
> > > I'm happy to take care of removing platform_get_resource() as part of that
> > > if it's easier.
> > 
> > Did you get anywhere with this? December 23rd is long forgotten by now ;)
> 
> Yup: https://gitlab.arm.com/linux-arm/linux-rm/-/commit/b2a40caaf1622eb35c555074a0d72f4f0513cff9
> 
> I'm still cleaning up the PMU driver that justifies the whole thing, but I
> can send that patch now if you reckon it's not complete nonsense out of
> context. Otherwise, I'll aim to get the whole lot out next week.

Next week is fine, no rush. I was just trying to work out what to do with
Lad's patches in this thread and it sounds like I should ignore them and
wait for your series instead.

Will

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

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

end of thread, other threads:[~2022-02-08 15:33 UTC | newest]

Thread overview: 27+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-23 13:00 [PATCH 0/2] iommu/arm-smmu: Use platform_irq_count() Lad Prabhakar
2021-12-23 13:00 ` Lad Prabhakar
2021-12-23 13:00 ` Lad Prabhakar
2021-12-23 13:00 ` [PATCH 1/2] iommu/arm-smmu: Use platform_irq_count() to get the interrupt count Lad Prabhakar
2021-12-23 13:00   ` Lad Prabhakar
2021-12-23 13:00   ` Lad Prabhakar
2021-12-23 14:14   ` Robin Murphy
2021-12-23 14:14     ` Robin Murphy
2021-12-23 14:14     ` Robin Murphy
2021-12-23 17:36     ` Lad, Prabhakar
2021-12-23 17:36       ` Lad, Prabhakar
2021-12-23 17:36       ` Lad, Prabhakar
2022-02-08 15:19     ` Will Deacon
2022-02-08 15:19       ` Will Deacon
2022-02-08 15:19       ` Will Deacon
2022-02-08 15:28       ` Robin Murphy
2022-02-08 15:28         ` Robin Murphy
2022-02-08 15:28         ` Robin Murphy
2022-02-08 15:31         ` Will Deacon
2022-02-08 15:31           ` Will Deacon
2022-02-08 15:31           ` Will Deacon
2021-12-23 13:00 ` [PATCH 2/2] iommu/arm-smmu: Propagate errors from platform_get_irq() Lad Prabhakar
2021-12-23 13:00   ` Lad Prabhakar
2021-12-23 13:00   ` Lad Prabhakar
2021-12-23 14:19   ` Robin Murphy
2021-12-23 14:19     ` Robin Murphy
2021-12-23 14:19     ` Robin Murphy

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.