diff mbox series

amd-xgbe: Use platform_irq_count()

Message ID 20220609161457.69614-1-jean-philippe@linaro.org (mailing list archive)
State Accepted
Commit 884c65e4daf3eab8730b2bbd5abc5a2c0403b3f3
Delegated to: Netdev Maintainers
Headers show
Series amd-xgbe: Use platform_irq_count() | expand

Checks

Context Check Description
netdev/tree_selection success Guessed tree name to be net-next
netdev/fixes_present success Fixes tag not required for -next series
netdev/subject_prefix warning Target tree name not specified in the subject
netdev/cover_letter success Single patches do not need cover letters
netdev/patch_count success Link
netdev/header_inline success No static functions without inline keyword in header files
netdev/build_32bit success Errors and warnings before: 0 this patch: 0
netdev/cc_maintainers success CCed 9 of 9 maintainers
netdev/build_clang success Errors and warnings before: 0 this patch: 0
netdev/module_param success Was 0 now: 0
netdev/verify_signedoff success Signed-off-by tag matches author and committer
netdev/check_selftest success No net selftest shell script
netdev/verify_fixes success Fixes tag looks correct
netdev/build_allmodconfig_warn success Errors and warnings before: 0 this patch: 0
netdev/checkpatch success total: 0 errors, 0 warnings, 0 checks, 16 lines checked
netdev/kdoc success Errors and warnings before: 0 this patch: 0
netdev/source_inline success Was 0 now: 0

Commit Message

Jean-Philippe Brucker June 9, 2022, 4:14 p.m. UTC
The AMD XGbE driver currently counts the number of interrupts assigned
to the device by inspecting the pdev->resource array. Since commit
a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT
core") removed IRQs from this array, the driver now attempts to get all
interrupts from 1 to -1U and gives up probing once it reaches an invalid
interrupt index.

Obtain the number of IRQs with platform_irq_count() instead.

Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
---
 drivers/net/ethernet/amd/xgbe/xgbe-platform.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Comments

Rob Herring June 13, 2022, 3:55 p.m. UTC | #1
On Thu, Jun 9, 2022 at 10:20 AM Jean-Philippe Brucker
<jean-philippe@linaro.org> wrote:
>
> The AMD XGbE driver currently counts the number of interrupts assigned
> to the device by inspecting the pdev->resource array. Since commit
> a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT
> core") removed IRQs from this array, the driver now attempts to get all
> interrupts from 1 to -1U and gives up probing once it reaches an invalid
> interrupt index.
>
> Obtain the number of IRQs with platform_irq_count() instead.
>
> Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> ---
>  drivers/net/ethernet/amd/xgbe/xgbe-platform.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> index 4ebd2410185a..4d790a89fe77 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> @@ -338,7 +338,7 @@ static int xgbe_platform_probe(struct platform_device *pdev)
>                  *   the PHY resources listed last
>                  */
>                 phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3;
> -               phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1;
> +               phy_irqnum = platform_irq_count(pdev) - 1;
>                 dma_irqnum = 1;
>                 dma_irqend = phy_irqnum;
>         } else {
> @@ -348,7 +348,7 @@ static int xgbe_platform_probe(struct platform_device *pdev)
>                 phy_memnum = 0;
>                 phy_irqnum = 0;
>                 dma_irqnum = 1;
> -               dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ);
> +               dma_irqend = platform_irq_count(pdev);

This is some ugly code... This clause is for 'old style' DT (which
actually looks more correct to me then 'new style' which seems
influenced by ACPI). Is there a need to continue carrying support for
old DTs? How many users of Seattle with DT are there?

In any case, that's all a separate change on top of this I think.

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

Rob
Tom Lendacky June 13, 2022, 4:39 p.m. UTC | #2
On 6/9/22 11:14, Jean-Philippe Brucker wrote:
> The AMD XGbE driver currently counts the number of interrupts assigned
> to the device by inspecting the pdev->resource array. Since commit
> a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT
> core") removed IRQs from this array, the driver now attempts to get all
> interrupts from 1 to -1U and gives up probing once it reaches an invalid
> interrupt index.
> 
> Obtain the number of IRQs with platform_irq_count() instead.
> 
> Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
> Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>

Acked-by: Tom Lendacky <thomas.lendacky@amd.com>

It looks like the CCP driver does a similar loop looking for IRQ resources 
(sp_get_irqs() in drivers/crypto/ccp/sp-platform.c), have you looked at 
fixing that driver, too? I can submit a patch if you hadn't planned on it.

Thanks,
Tom

> ---
>   drivers/net/ethernet/amd/xgbe/xgbe-platform.c | 4 ++--
>   1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> index 4ebd2410185a..4d790a89fe77 100644
> --- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> +++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
> @@ -338,7 +338,7 @@ static int xgbe_platform_probe(struct platform_device *pdev)
>   		 *   the PHY resources listed last
>   		 */
>   		phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3;
> -		phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1;
> +		phy_irqnum = platform_irq_count(pdev) - 1;
>   		dma_irqnum = 1;
>   		dma_irqend = phy_irqnum;
>   	} else {
> @@ -348,7 +348,7 @@ static int xgbe_platform_probe(struct platform_device *pdev)
>   		phy_memnum = 0;
>   		phy_irqnum = 0;
>   		dma_irqnum = 1;
> -		dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ);
> +		dma_irqend = platform_irq_count(pdev);
>   	}
>   
>   	/* Obtain the mmio areas for the device */
Jean-Philippe Brucker June 13, 2022, 5:28 p.m. UTC | #3
On Mon, Jun 13, 2022 at 11:39:48AM -0500, Tom Lendacky wrote:
> On 6/9/22 11:14, Jean-Philippe Brucker wrote:
> > The AMD XGbE driver currently counts the number of interrupts assigned
> > to the device by inspecting the pdev->resource array. Since commit
> > a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT
> > core") removed IRQs from this array, the driver now attempts to get all
> > interrupts from 1 to -1U and gives up probing once it reaches an invalid
> > interrupt index.
> > 
> > Obtain the number of IRQs with platform_irq_count() instead.
> > 
> > Fixes: a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT core")
> > Signed-off-by: Jean-Philippe Brucker <jean-philippe@linaro.org>
> 
> Acked-by: Tom Lendacky <thomas.lendacky@amd.com>
> 
> It looks like the CCP driver does a similar loop looking for IRQ resources
> (sp_get_irqs() in drivers/crypto/ccp/sp-platform.c), have you looked at
> fixing that driver, too? I can submit a patch if you hadn't planned on it.

Ah no, I did very briefly look for similar issues but missed it, feel free
to send the patch

Thanks,
Jean
patchwork-bot+netdevbpf@kernel.org June 14, 2022, 6:20 a.m. UTC | #4
Hello:

This patch was applied to netdev/net.git (master)
by Jakub Kicinski <kuba@kernel.org>:

On Thu,  9 Jun 2022 17:14:59 +0100 you wrote:
> The AMD XGbE driver currently counts the number of interrupts assigned
> to the device by inspecting the pdev->resource array. Since commit
> a1a2b7125e10 ("of/platform: Drop static setup of IRQ resource from DT
> core") removed IRQs from this array, the driver now attempts to get all
> interrupts from 1 to -1U and gives up probing once it reaches an invalid
> interrupt index.
> 
> [...]

Here is the summary with links:
  - amd-xgbe: Use platform_irq_count()
    https://git.kernel.org/netdev/net/c/884c65e4daf3

You are awesome, thank you!
diff mbox series

Patch

diff --git a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
index 4ebd2410185a..4d790a89fe77 100644
--- a/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
+++ b/drivers/net/ethernet/amd/xgbe/xgbe-platform.c
@@ -338,7 +338,7 @@  static int xgbe_platform_probe(struct platform_device *pdev)
 		 *   the PHY resources listed last
 		 */
 		phy_memnum = xgbe_resource_count(pdev, IORESOURCE_MEM) - 3;
-		phy_irqnum = xgbe_resource_count(pdev, IORESOURCE_IRQ) - 1;
+		phy_irqnum = platform_irq_count(pdev) - 1;
 		dma_irqnum = 1;
 		dma_irqend = phy_irqnum;
 	} else {
@@ -348,7 +348,7 @@  static int xgbe_platform_probe(struct platform_device *pdev)
 		phy_memnum = 0;
 		phy_irqnum = 0;
 		dma_irqnum = 1;
-		dma_irqend = xgbe_resource_count(pdev, IORESOURCE_IRQ);
+		dma_irqend = platform_irq_count(pdev);
 	}
 
 	/* Obtain the mmio areas for the device */