diff mbox series

[OpenWrt-Devel] octeontx: fix thunderx BGX underflow irq name

Message ID 1572038851-4029-1-git-send-email-tharvey@gateworks.com
State Accepted
Delegated to: John Crispin
Headers show
Series [OpenWrt-Devel] octeontx: fix thunderx BGX underflow irq name | expand

Commit Message

Tim Harvey Oct. 25, 2019, 9:27 p.m. UTC
request_irq requires irq names to be static/allocated and not on the stack

Signed-off-by: Tim Harvey <tharvey@gateworks.com>
---
 ...1-net-thunderx-workaround-BGX-TX-Underflow-issue.patch | 15 +++++++++++----
 1 file changed, 11 insertions(+), 4 deletions(-)

Comments

Hauke Mehrtens Oct. 27, 2019, 1:32 p.m. UTC | #1
On 10/25/19 11:27 PM, Tim Harvey wrote:
> request_irq requires irq names to be static/allocated and not on the stack

It would be nice if this patch could also go to the mainline Linux
kernel, so we do not have to maintain it any more.

John already applied it to OpenWrt.

> 
> Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> ---
>  ...1-net-thunderx-workaround-BGX-TX-Underflow-issue.patch | 15 +++++++++++----
>  1 file changed, 11 insertions(+), 4 deletions(-)
> 
> diff --git a/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch b/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
> index ef7aef3..5743745 100644
> --- a/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
> +++ b/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
> @@ -15,7 +15,15 @@ Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>  
>  --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
>  +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
> -@@ -1344,6 +1344,54 @@ static int bgx_init_phy(struct bgx *bgx)
> +@@ -56,6 +56,7 @@ struct bgx {
> + 	bool                    is_dlm;
> + 	bool                    is_rgx;
> + 	int			phy_mode;
> ++	char			irq_name[7];
> + };
> + 
> + static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
> +@@ -1344,6 +1345,53 @@ static int bgx_init_phy(struct bgx *bgx)
>   	return bgx_init_of_phy(bgx);
>   }
>   
> @@ -49,7 +57,6 @@ Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>  +	struct bgx *bgx = pci_get_drvdata(pdev);
>  +	struct device *dev = &pdev->dev;
>  +	int num_vec, ret;
> -+	char irq_name[32];
>  +
>  +	/* Enable MSI-X */
>  +	num_vec = pci_msix_vec_count(pdev);
> @@ -58,9 +65,9 @@ Signed-off-by: Tim Harvey <tharvey@gateworks.com>
>  +		dev_err(dev, "Req for #%d msix vectors failed\n", num_vec);
>  +		return 1;
>  +	}
> -+	sprintf(irq_name, "BGX%d", bgx->bgx_id);
> ++	sprintf(bgx->irq_name, "BGX%d", bgx->bgx_id);

I would prefer a snprintf here, it should not overflow as long as gx_id
is less than 1000, but just to be safe.

>  +	ret = request_irq(pci_irq_vector(pdev, GMPX_GMI_TX_INT),
> -+		bgx_intr_handler, 0, irq_name, bgx);
> ++		bgx_intr_handler, 0, bgx->irq_name, bgx);
>  +	if (ret)
>  +		return 1;
>  +
>
Tim Harvey Oct. 28, 2019, 4:49 p.m. UTC | #2
On Sun, Oct 27, 2019 at 6:33 AM Hauke Mehrtens <hauke@hauke-m.de> wrote:
>
> On 10/25/19 11:27 PM, Tim Harvey wrote:
> > request_irq requires irq names to be static/allocated and not on the stack
>
> It would be nice if this patch could also go to the mainline Linux
> kernel, so we do not have to maintain it any more.
>
> John already applied it to OpenWrt.

Hauke,

Agreed - it's on my list along with the other patch for octeontx.

>
> <snip>
> > @@ -58,9 +65,9 @@ Signed-off-by: Tim Harvey <tharvey@gateworks.com>
> >  +            dev_err(dev, "Req for #%d msix vectors failed\n", num_vec);
> >  +            return 1;
> >  +    }
> > -+    sprintf(irq_name, "BGX%d", bgx->bgx_id);
> > ++    sprintf(bgx->irq_name, "BGX%d", bgx->bgx_id);
>
> I would prefer a snprintf here, it should not overflow as long as gx_id
> is less than 1000, but just to be safe.
>

Agreed - I'll make a note of that.

Thanks,

Tim
diff mbox series

Patch

diff --git a/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch b/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
index ef7aef3..5743745 100644
--- a/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
+++ b/target/linux/octeontx/patches-4.14/0001-net-thunderx-workaround-BGX-TX-Underflow-issue.patch
@@ -15,7 +15,15 @@  Signed-off-by: Tim Harvey <tharvey@gateworks.com>
 
 --- a/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
 +++ b/drivers/net/ethernet/cavium/thunder/thunder_bgx.c
-@@ -1344,6 +1344,54 @@ static int bgx_init_phy(struct bgx *bgx)
+@@ -56,6 +56,7 @@ struct bgx {
+ 	bool                    is_dlm;
+ 	bool                    is_rgx;
+ 	int			phy_mode;
++	char			irq_name[7];
+ };
+ 
+ static struct bgx *bgx_vnic[MAX_BGX_THUNDER];
+@@ -1344,6 +1345,53 @@ static int bgx_init_phy(struct bgx *bgx)
  	return bgx_init_of_phy(bgx);
  }
  
@@ -49,7 +57,6 @@  Signed-off-by: Tim Harvey <tharvey@gateworks.com>
 +	struct bgx *bgx = pci_get_drvdata(pdev);
 +	struct device *dev = &pdev->dev;
 +	int num_vec, ret;
-+	char irq_name[32];
 +
 +	/* Enable MSI-X */
 +	num_vec = pci_msix_vec_count(pdev);
@@ -58,9 +65,9 @@  Signed-off-by: Tim Harvey <tharvey@gateworks.com>
 +		dev_err(dev, "Req for #%d msix vectors failed\n", num_vec);
 +		return 1;
 +	}
-+	sprintf(irq_name, "BGX%d", bgx->bgx_id);
++	sprintf(bgx->irq_name, "BGX%d", bgx->bgx_id);
 +	ret = request_irq(pci_irq_vector(pdev, GMPX_GMI_TX_INT),
-+		bgx_intr_handler, 0, irq_name, bgx);
++		bgx_intr_handler, 0, bgx->irq_name, bgx);
 +	if (ret)
 +		return 1;
 +