diff mbox series

[5/9] ravb: Support separate Line0 (Desc), Line1 (Err) and Line2 (Mgmt) irqs

Message ID 20220504145454.71287-6-phil.edworthy@renesas.com (mailing list archive)
State Superseded
Delegated to: Geert Uytterhoeven
Headers show
Series Add Renesas RZ/V2M Ethernet support | expand

Commit Message

Phil Edworthy May 4, 2022, 2:54 p.m. UTC
R-Car has a combined interrupt line, ch22 = Line0_DiA | Line1_A | Line2_A.
RZ/V2M has separate interrupt lines for each of these, so add a feature
that allows the driver to get these interrupts and call the common handler.

We keep the "ch22" name for Line0_DiA and "ch24" for Line3 interrupts to
keep the code simple.

Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
---
 drivers/net/ethernet/renesas/ravb.h      |  3 ++
 drivers/net/ethernet/renesas/ravb_main.c | 41 ++++++++++++++++++++++--
 2 files changed, 42 insertions(+), 2 deletions(-)

Comments

Sergey Shtylyov May 5, 2022, 7:40 p.m. UTC | #1
On 5/4/22 5:54 PM, Phil Edworthy wrote:

> R-Car has a combined interrupt line, ch22 = Line0_DiA | Line1_A | Line2_A.

   R-Car gen3, you mean? Because R-Car gen2 has single IRQ...

> RZ/V2M has separate interrupt lines for each of these, so add a feature
> that allows the driver to get these interrupts and call the common handler.
> 
> We keep the "ch22" name for Line0_DiA and "ch24" for Line3 interrupts to
> keep the code simple.

   Not sure I agree with such simplification -- at least about "ch22"...

> Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>

[...]
> diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
> index d0b9688074ca..f12a23b9c391 100644
> --- a/drivers/net/ethernet/renesas/ravb_main.c
> +++ b/drivers/net/ethernet/renesas/ravb_main.c
[...]
> @@ -2167,6 +2184,10 @@ static int ravb_close(struct net_device *ndev)
>  		free_irq(priv->rx_irqs[RAVB_BE], ndev);
>  		free_irq(priv->emac_irq, ndev);
>  	}
> +	if (info->err_mgmt_irqs) {
> +		free_irq(priv->erra_irq, ndev);
> +		free_irq(priv->mgmta_irq, ndev);
> +	}

   Shouldn't this be under:

	if (info->multi_irqs) {

above?

>  	free_irq(ndev->irq, ndev);
>  
>  	if (info->nc_queues)
> @@ -2665,6 +2686,22 @@ static int ravb_probe(struct platform_device *pdev)
>  		}
>  	}
>  
> +	if (info->err_mgmt_irqs) {
> +		irq = platform_get_irq_byname(pdev, "err_a");
> +		if (irq < 0) {
> +			error = irq;
> +			goto out_release;
> +		}
> +		priv->erra_irq = irq;
> +
> +		irq = platform_get_irq_byname(pdev, "mgmt_a");
> +		if (irq < 0) {
> +			error = irq;
> +			goto out_release;
> +		}
> +		priv->mgmta_irq = irq;
> +	}
> +

   Same here... 

>  	priv->clk = devm_clk_get(&pdev->dev, NULL);
>  	if (IS_ERR(priv->clk)) {
>  		error = PTR_ERR(priv->clk);

MBR, Sergey
Phil Edworthy May 9, 2022, 8 a.m. UTC | #2
Hi Sergey,

On 05 May 2022 20:41 Sergey Shtylyov wrote:
> On 5/4/22 5:54 PM, Phil Edworthy wrote:
> 
> > R-Car has a combined interrupt line, ch22 = Line0_DiA | Line1_A |
> Line2_A.
> 
>    R-Car gen3, you mean? Because R-Car gen2 has single IRQ...
> 
> > RZ/V2M has separate interrupt lines for each of these, so add a
> > feature that allows the driver to get these interrupts and call the
> common handler.
> >
> > We keep the "ch22" name for Line0_DiA and "ch24" for Line3 interrupts
> > to keep the code simple.
> 
>    Not sure I agree with such simplification -- at least about "ch22"...
Ok, I can change it.


> > Signed-off-by: Phil Edworthy <phil.edworthy@renesas.com>
> > Reviewed-by: Biju Das <biju.das.jz@bp.renesas.com>
> 
> [...]
> > diff --git a/drivers/net/ethernet/renesas/ravb_main.c
> > b/drivers/net/ethernet/renesas/ravb_main.c
> > index d0b9688074ca..f12a23b9c391 100644
> > --- a/drivers/net/ethernet/renesas/ravb_main.c
> > +++ b/drivers/net/ethernet/renesas/ravb_main.c
> [...]
> > @@ -2167,6 +2184,10 @@ static int ravb_close(struct net_device *ndev)
> >  		free_irq(priv->rx_irqs[RAVB_BE], ndev);
> >  		free_irq(priv->emac_irq, ndev);
> >  	}
> > +	if (info->err_mgmt_irqs) {
> > +		free_irq(priv->erra_irq, ndev);
> > +		free_irq(priv->mgmta_irq, ndev);
> > +	}
> 
>    Shouldn't this be under:
> 
> 	if (info->multi_irqs) {
> 
> above?
Can do, though I guess we could also have devices in the future that
have separate err and mgmt interrupts, but not use the multiple channel
interrupts.
I'm easy either way.

> >  	free_irq(ndev->irq, ndev);
> >
> >  	if (info->nc_queues)
> > @@ -2665,6 +2686,22 @@ static int ravb_probe(struct platform_device
> *pdev)
> >  		}
> >  	}
> >
> > +	if (info->err_mgmt_irqs) {
> > +		irq = platform_get_irq_byname(pdev, "err_a");
> > +		if (irq < 0) {
> > +			error = irq;
> > +			goto out_release;
> > +		}
> > +		priv->erra_irq = irq;
> > +
> > +		irq = platform_get_irq_byname(pdev, "mgmt_a");
> > +		if (irq < 0) {
> > +			error = irq;
> > +			goto out_release;
> > +		}
> > +		priv->mgmta_irq = irq;
> > +	}
> > +
> 
>    Same here...
> 
> >  	priv->clk = devm_clk_get(&pdev->dev, NULL);
> >  	if (IS_ERR(priv->clk)) {
> >  		error = PTR_ERR(priv->clk);


Thanks
Phil
diff mbox series

Patch

diff --git a/drivers/net/ethernet/renesas/ravb.h b/drivers/net/ethernet/renesas/ravb.h
index 67a240665cd2..73976a392457 100644
--- a/drivers/net/ethernet/renesas/ravb.h
+++ b/drivers/net/ethernet/renesas/ravb.h
@@ -1028,6 +1028,7 @@  struct ravb_hw_info {
 	unsigned carrier_counters:1;	/* E-MAC has carrier counters */
 	unsigned multi_irqs:1;		/* AVB-DMAC and E-MAC has multiple irqs */
 	unsigned irq_en_dis_regs:1;	/* Has separate irq enable and disable regs */
+	unsigned err_mgmt_irqs:1;	/* Line1 (Err) and Line2 (Mgmt) irqs are separate */
 	unsigned gptp:1;		/* AVB-DMAC has gPTP support */
 	unsigned ccc_gac:1;		/* AVB-DMAC has gPTP support active in config mode */
 	unsigned gptp_ptm_gic:1;	/* gPTP enables Presentation Time Match irq via GIC */
@@ -1079,6 +1080,8 @@  struct ravb_private {
 	int msg_enable;
 	int speed;
 	int emac_irq;
+	int erra_irq;
+	int mgmta_irq;
 	int rx_irqs[NUM_RX_QUEUE];
 	int tx_irqs[NUM_TX_QUEUE];
 
diff --git a/drivers/net/ethernet/renesas/ravb_main.c b/drivers/net/ethernet/renesas/ravb_main.c
index d0b9688074ca..f12a23b9c391 100644
--- a/drivers/net/ethernet/renesas/ravb_main.c
+++ b/drivers/net/ethernet/renesas/ravb_main.c
@@ -1798,12 +1798,23 @@  static int ravb_open(struct net_device *ndev)
 				      ndev, dev, "ch19:tx_nc");
 		if (error)
 			goto out_free_irq_nc_rx;
+
+		if (info->err_mgmt_irqs) {
+			error = ravb_hook_irq(priv->erra_irq, ravb_multi_interrupt,
+					      ndev, dev, "err_a");
+			if (error)
+				goto out_free_irq_nc_tx;
+			error = ravb_hook_irq(priv->mgmta_irq, ravb_multi_interrupt,
+					      ndev, dev, "mgmt_a");
+			if (error)
+				goto out_free_irq_erra;
+		}
 	}
 
 	/* Device init */
 	error = ravb_dmac_init(ndev);
 	if (error)
-		goto out_free_irq_nc_tx;
+		goto out_free_irq_mgmta;
 	ravb_emac_init(ndev);
 
 	/* Initialise PTP Clock driver */
@@ -1823,9 +1834,15 @@  static int ravb_open(struct net_device *ndev)
 	/* Stop PTP Clock driver */
 	if (info->gptp)
 		ravb_ptp_stop(ndev);
-out_free_irq_nc_tx:
+out_free_irq_mgmta:
 	if (!info->multi_irqs)
 		goto out_free_irq;
+	if (info->err_mgmt_irqs)
+		free_irq(priv->mgmta_irq, ndev);
+out_free_irq_erra:
+	if (info->err_mgmt_irqs)
+		free_irq(priv->erra_irq, ndev);
+out_free_irq_nc_tx:
 	free_irq(priv->tx_irqs[RAVB_NC], ndev);
 out_free_irq_nc_rx:
 	free_irq(priv->rx_irqs[RAVB_NC], ndev);
@@ -2167,6 +2184,10 @@  static int ravb_close(struct net_device *ndev)
 		free_irq(priv->rx_irqs[RAVB_BE], ndev);
 		free_irq(priv->emac_irq, ndev);
 	}
+	if (info->err_mgmt_irqs) {
+		free_irq(priv->erra_irq, ndev);
+		free_irq(priv->mgmta_irq, ndev);
+	}
 	free_irq(ndev->irq, ndev);
 
 	if (info->nc_queues)
@@ -2665,6 +2686,22 @@  static int ravb_probe(struct platform_device *pdev)
 		}
 	}
 
+	if (info->err_mgmt_irqs) {
+		irq = platform_get_irq_byname(pdev, "err_a");
+		if (irq < 0) {
+			error = irq;
+			goto out_release;
+		}
+		priv->erra_irq = irq;
+
+		irq = platform_get_irq_byname(pdev, "mgmt_a");
+		if (irq < 0) {
+			error = irq;
+			goto out_release;
+		}
+		priv->mgmta_irq = irq;
+	}
+
 	priv->clk = devm_clk_get(&pdev->dev, NULL);
 	if (IS_ERR(priv->clk)) {
 		error = PTR_ERR(priv->clk);