netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [patch-net-next v2 1/3] net: ethernet: cpsw: unroll IRQ request loop
@ 2015-01-14 16:58 Felipe Balbi
  2015-01-14 16:58 ` [patch-net-next v2 2/3] net: ethernet: cpsw: split out IRQ handler Felipe Balbi
  2015-01-14 16:58 ` [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use Felipe Balbi
  0 siblings, 2 replies; 8+ messages in thread
From: Felipe Balbi @ 2015-01-14 16:58 UTC (permalink / raw)
  To: davem
  Cc: Tony Lindgren, Linux OMAP Mailing List, mugunthanvnm, netdev,
	Felipe Balbi

This patch is in preparation for a nicer IRQ
handling scheme where we use different IRQ
handlers for each IRQ line (as it should be).

Later, we will also drop IRQs offset 0 and 3
because they are always disabled in this driver.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 62 ++++++++++++++++++++++++++++++++----------
 1 file changed, 47 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index e61ee8351272..8e1af51e4b76 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -2156,7 +2156,8 @@ static int cpsw_probe(struct platform_device *pdev)
 	void __iomem			*ss_regs;
 	struct resource			*res, *ss_res;
 	u32 slave_offset, sliver_offset, slave_size;
-	int ret = 0, i, k = 0;
+	int ret = 0, i;
+	int irq;
 
 	ndev = alloc_etherdev(sizeof(struct cpsw_priv));
 	if (!ndev) {
@@ -2345,24 +2346,55 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 	}
 
-	while ((res = platform_get_resource(priv->pdev, IORESOURCE_IRQ, k))) {
-		if (k >= ARRAY_SIZE(priv->irqs_table)) {
-			ret = -EINVAL;
-			goto clean_ale_ret;
-		}
+	irq = platform_get_irq(pdev, 0);
+	if (irq < 0)
+		goto clean_ale_ret;
 
-		ret = devm_request_irq(&pdev->dev, res->start, cpsw_interrupt,
-				       0, dev_name(&pdev->dev), priv);
-		if (ret < 0) {
-			dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-			goto clean_ale_ret;
-		}
+	priv->irqs_table[0] = irq;
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+			       0, dev_name(&pdev->dev), priv);
+	if (ret < 0) {
+		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		goto clean_ale_ret;
+	}
 
-		priv->irqs_table[k] = res->start;
-		k++;
+	irq = platform_get_irq(pdev, 1);
+	if (irq < 0)
+		goto clean_ale_ret;
+
+	priv->irqs_table[1] = irq;
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+			       0, dev_name(&pdev->dev), priv);
+	if (ret < 0) {
+		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		goto clean_ale_ret;
+	}
+
+	irq = platform_get_irq(pdev, 2);
+	if (irq < 0)
+		goto clean_ale_ret;
+
+	priv->irqs_table[2] = irq;
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+			       0, dev_name(&pdev->dev), priv);
+	if (ret < 0) {
+		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		goto clean_ale_ret;
+	}
+
+	irq = platform_get_irq(pdev, 3);
+	if (irq < 0)
+		goto clean_ale_ret;
+
+	priv->irqs_table[3] = irq;
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+			       0, dev_name(&pdev->dev), priv);
+	if (ret < 0) {
+		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
+		goto clean_ale_ret;
 	}
 
-	priv->num_irqs = k;
+	priv->num_irqs = 4;
 
 	ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 
-- 
2.2.0

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

* [patch-net-next v2 2/3] net: ethernet: cpsw: split out IRQ handler
  2015-01-14 16:58 [patch-net-next v2 1/3] net: ethernet: cpsw: unroll IRQ request loop Felipe Balbi
@ 2015-01-14 16:58 ` Felipe Balbi
  2015-01-14 16:58 ` [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use Felipe Balbi
  1 sibling, 0 replies; 8+ messages in thread
From: Felipe Balbi @ 2015-01-14 16:58 UTC (permalink / raw)
  To: davem
  Cc: Tony Lindgren, Linux OMAP Mailing List, mugunthanvnm, netdev,
	Felipe Balbi

Now we can introduce dedicated IRQ handlers
for each of the IRQ events. This helps with
cleaning up a little bit of the clutter in
cpsw_interrupt() while also making sure that
TX IRQs will try to handle TX buffers while
RX IRQs will try to handle RX buffers.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 41 ++++++++++++++++++++++++++++++-----------
 1 file changed, 30 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index 8e1af51e4b76..c6c483f3e49f 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -754,18 +754,36 @@ requeue:
 		dev_kfree_skb_any(new_skb);
 }
 
-static irqreturn_t cpsw_interrupt(int irq, void *dev_id)
+static irqreturn_t cpsw_dummy_interrupt(int irq, void *dev_id)
 {
 	struct cpsw_priv *priv = dev_id;
 	int value = irq - priv->irqs_table[0];
 
-	/* NOTICE: Ending IRQ here. The trick with the 'value' variable above
-	 * is to make sure we will always write the correct value to the EOI
-	 * register. Namely 0 for RX_THRESH Interrupt, 1 for RX Interrupt, 2
-	 * for TX Interrupt and 3 for MISC Interrupt.
-	 */
 	cpdma_ctlr_eoi(priv->dma, value);
 
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
+{
+	struct cpsw_priv *priv = dev_id;
+
+	cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_TX);
+	cpdma_chan_process(priv->txch, 128);
+
+	priv = cpsw_get_slave_priv(priv, 1);
+	if (priv)
+		cpdma_chan_process(priv->txch, 128);
+
+	return IRQ_HANDLED;
+}
+
+static irqreturn_t cpsw_rx_interrupt(int irq, void *dev_id)
+{
+	struct cpsw_priv *priv = dev_id;
+
+	cpdma_ctlr_eoi(priv->dma, CPDMA_EOI_RX);
+
 	cpsw_intr_disable(priv);
 	if (priv->irq_enabled == true) {
 		cpsw_disable_irq(priv);
@@ -1617,7 +1635,8 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
 
 	cpsw_intr_disable(priv);
 	cpdma_ctlr_int_ctrl(priv->dma, false);
-	cpsw_interrupt(ndev->irq, priv);
+	cpsw_rx_interrupt(priv->irq[1], priv);
+	cpsw_tx_interrupt(priv->irq[2], priv);
 	cpdma_ctlr_int_ctrl(priv->dma, true);
 	cpsw_intr_enable(priv);
 }
@@ -2351,7 +2370,7 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 
 	priv->irqs_table[0] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_dummy_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
@@ -2363,7 +2382,7 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 
 	priv->irqs_table[1] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
@@ -2375,7 +2394,7 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 
 	priv->irqs_table[2] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
@@ -2387,7 +2406,7 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 
 	priv->irqs_table[3] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_interrupt,
+	ret = devm_request_irq(&pdev->dev, irq, cpsw_dummy_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-- 
2.2.0


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

* [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-14 16:58 [patch-net-next v2 1/3] net: ethernet: cpsw: unroll IRQ request loop Felipe Balbi
  2015-01-14 16:58 ` [patch-net-next v2 2/3] net: ethernet: cpsw: split out IRQ handler Felipe Balbi
@ 2015-01-14 16:58 ` Felipe Balbi
  2015-01-15  7:49   ` Mugunthan V N
  1 sibling, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2015-01-14 16:58 UTC (permalink / raw)
  To: davem
  Cc: Tony Lindgren, Linux OMAP Mailing List, mugunthanvnm, netdev,
	Felipe Balbi

CPSW never uses RX_THRESHOLD or MISC interrupts. In
fact, they are always kept masked in their appropriate
IRQ Enable register.

Instead of allocating an IRQ that never fires, it's best
to remove that code altogether and let future patches
implement it if anybody needs those.

Signed-off-by: Felipe Balbi <balbi@ti.com>
---
 drivers/net/ethernet/ti/cpsw.c | 55 ++++++++++++------------------------------
 1 file changed, 15 insertions(+), 40 deletions(-)

diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c
index c6c483f3e49f..ba09ff3c1695 100644
--- a/drivers/net/ethernet/ti/cpsw.c
+++ b/drivers/net/ethernet/ti/cpsw.c
@@ -754,16 +754,6 @@ requeue:
 		dev_kfree_skb_any(new_skb);
 }
 
-static irqreturn_t cpsw_dummy_interrupt(int irq, void *dev_id)
-{
-	struct cpsw_priv *priv = dev_id;
-	int value = irq - priv->irqs_table[0];
-
-	cpdma_ctlr_eoi(priv->dma, value);
-
-	return IRQ_HANDLED;
-}
-
 static irqreturn_t cpsw_tx_interrupt(int irq, void *dev_id)
 {
 	struct cpsw_priv *priv = dev_id;
@@ -1635,8 +1625,8 @@ static void cpsw_ndo_poll_controller(struct net_device *ndev)
 
 	cpsw_intr_disable(priv);
 	cpdma_ctlr_int_ctrl(priv->dma, false);
-	cpsw_rx_interrupt(priv->irq[1], priv);
-	cpsw_tx_interrupt(priv->irq[2], priv);
+	cpsw_rx_interrupt(priv->irq[0], priv);
+	cpsw_tx_interrupt(priv->irq[1], priv);
 	cpdma_ctlr_int_ctrl(priv->dma, true);
 	cpsw_intr_enable(priv);
 }
@@ -2358,30 +2348,27 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_dma_ret;
 	}
 
-	ndev->irq = platform_get_irq(pdev, 0);
+	ndev->irq = platform_get_irq(pdev, 1);
 	if (ndev->irq < 0) {
 		dev_err(priv->dev, "error getting irq resource\n");
 		ret = -ENOENT;
 		goto clean_ale_ret;
 	}
 
-	irq = platform_get_irq(pdev, 0);
-	if (irq < 0)
-		goto clean_ale_ret;
-
-	priv->irqs_table[0] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_dummy_interrupt,
-			       0, dev_name(&pdev->dev), priv);
-	if (ret < 0) {
-		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-		goto clean_ale_ret;
-	}
+	/* Grab RX and TX IRQs. Note that we also have RX_THRESHOLD and
+	 * MISC IRQs which are always kept disabled with this driver so
+	 * we will not request them.
+	 *
+	 * If anyone wants to implement support for those, make sure to
+	 * first request and append them to irqs_table array.
+	 */
 
+	/* RX IRQ */
 	irq = platform_get_irq(pdev, 1);
 	if (irq < 0)
 		goto clean_ale_ret;
 
-	priv->irqs_table[1] = irq;
+	priv->irqs_table[0] = irq;
 	ret = devm_request_irq(&pdev->dev, irq, cpsw_rx_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
@@ -2389,31 +2376,19 @@ static int cpsw_probe(struct platform_device *pdev)
 		goto clean_ale_ret;
 	}
 
+	/* TX IRQ */
 	irq = platform_get_irq(pdev, 2);
 	if (irq < 0)
 		goto clean_ale_ret;
 
-	priv->irqs_table[2] = irq;
+	priv->irqs_table[1] = irq;
 	ret = devm_request_irq(&pdev->dev, irq, cpsw_tx_interrupt,
 			       0, dev_name(&pdev->dev), priv);
 	if (ret < 0) {
 		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
 		goto clean_ale_ret;
 	}
-
-	irq = platform_get_irq(pdev, 3);
-	if (irq < 0)
-		goto clean_ale_ret;
-
-	priv->irqs_table[3] = irq;
-	ret = devm_request_irq(&pdev->dev, irq, cpsw_dummy_interrupt,
-			       0, dev_name(&pdev->dev), priv);
-	if (ret < 0) {
-		dev_err(priv->dev, "error attaching irq (%d)\n", ret);
-		goto clean_ale_ret;
-	}
-
-	priv->num_irqs = 4;
+	priv->num_irqs = 2;
 
 	ndev->features |= NETIF_F_HW_VLAN_CTAG_FILTER;
 
-- 
2.2.0

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

* Re: [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-14 16:58 ` [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use Felipe Balbi
@ 2015-01-15  7:49   ` Mugunthan V N
  2015-01-15 15:20     ` Felipe Balbi
  0 siblings, 1 reply; 8+ messages in thread
From: Mugunthan V N @ 2015-01-15  7:49 UTC (permalink / raw)
  To: Felipe Balbi, davem; +Cc: Tony Lindgren, Linux OMAP Mailing List, netdev

On Wednesday 14 January 2015 10:28 PM, Felipe Balbi wrote:
> CPSW never uses RX_THRESHOLD or MISC interrupts. In
> fact, they are always kept masked in their appropriate
> IRQ Enable register.
> 
> Instead of allocating an IRQ that never fires, it's best
> to remove that code altogether and let future patches
> implement it if anybody needs those.
> 
> Signed-off-by: Felipe Balbi <balbi@ti.com>

Instead of introducing dummy ISR in previous patch and then removing in
this patch, both can be squashed into a single patch.

Regards
Mugunthan V N

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

* Re: [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-15  7:49   ` Mugunthan V N
@ 2015-01-15 15:20     ` Felipe Balbi
  2015-01-15 23:16       ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2015-01-15 15:20 UTC (permalink / raw)
  To: Mugunthan V N
  Cc: Felipe Balbi, davem, Tony Lindgren, Linux OMAP Mailing List,
	netdev

[-- Attachment #1: Type: text/plain, Size: 754 bytes --]

On Thu, Jan 15, 2015 at 01:19:16PM +0530, Mugunthan V N wrote:
> On Wednesday 14 January 2015 10:28 PM, Felipe Balbi wrote:
> > CPSW never uses RX_THRESHOLD or MISC interrupts. In
> > fact, they are always kept masked in their appropriate
> > IRQ Enable register.
> > 
> > Instead of allocating an IRQ that never fires, it's best
> > to remove that code altogether and let future patches
> > implement it if anybody needs those.
> > 
> > Signed-off-by: Felipe Balbi <balbi@ti.com>
> 
> Instead of introducing dummy ISR in previous patch and then removing in
> this patch, both can be squashed into a single patch.

sure they can. I decided to split to ease review and to make sure only
one thing happens in a single patch.

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-15 15:20     ` Felipe Balbi
@ 2015-01-15 23:16       ` David Miller
  2015-01-16  1:28         ` Felipe Balbi
  0 siblings, 1 reply; 8+ messages in thread
From: David Miller @ 2015-01-15 23:16 UTC (permalink / raw)
  To: balbi; +Cc: mugunthanvnm, tony, linux-omap, netdev

From: Felipe Balbi <balbi@ti.com>
Date: Thu, 15 Jan 2015 09:20:53 -0600

> On Thu, Jan 15, 2015 at 01:19:16PM +0530, Mugunthan V N wrote:
>> On Wednesday 14 January 2015 10:28 PM, Felipe Balbi wrote:
>> > CPSW never uses RX_THRESHOLD or MISC interrupts. In
>> > fact, they are always kept masked in their appropriate
>> > IRQ Enable register.
>> > 
>> > Instead of allocating an IRQ that never fires, it's best
>> > to remove that code altogether and let future patches
>> > implement it if anybody needs those.
>> > 
>> > Signed-off-by: Felipe Balbi <balbi@ti.com>
>> 
>> Instead of introducing dummy ISR in previous patch and then removing in
>> this patch, both can be squashed into a single patch.
> 
> sure they can. I decided to split to ease review and to make sure only
> one thing happens in a single patch.

Indeed, I agree that adding something as a placeholder that just gets
immediately removed should be avoided unless it is extremely difficult
to do so.

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

* Re: [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-15 23:16       ` David Miller
@ 2015-01-16  1:28         ` Felipe Balbi
  2015-01-16  4:36           ` David Miller
  0 siblings, 1 reply; 8+ messages in thread
From: Felipe Balbi @ 2015-01-16  1:28 UTC (permalink / raw)
  To: David Miller; +Cc: balbi, mugunthanvnm, tony, linux-omap, netdev

[-- Attachment #1: Type: text/plain, Size: 1184 bytes --]

On Thu, Jan 15, 2015 at 06:16:15PM -0500, David Miller wrote:
> From: Felipe Balbi <balbi@ti.com>
> Date: Thu, 15 Jan 2015 09:20:53 -0600
> 
> > On Thu, Jan 15, 2015 at 01:19:16PM +0530, Mugunthan V N wrote:
> >> On Wednesday 14 January 2015 10:28 PM, Felipe Balbi wrote:
> >> > CPSW never uses RX_THRESHOLD or MISC interrupts. In
> >> > fact, they are always kept masked in their appropriate
> >> > IRQ Enable register.
> >> > 
> >> > Instead of allocating an IRQ that never fires, it's best
> >> > to remove that code altogether and let future patches
> >> > implement it if anybody needs those.
> >> > 
> >> > Signed-off-by: Felipe Balbi <balbi@ti.com>
> >> 
> >> Instead of introducing dummy ISR in previous patch and then removing in
> >> this patch, both can be squashed into a single patch.
> > 
> > sure they can. I decided to split to ease review and to make sure only
> > one thing happens in a single patch.
> 
> Indeed, I agree that adding something as a placeholder that just gets
> immediately removed should be avoided unless it is extremely difficult
> to do so.

what does this mean ? you prefer both patches to be combined ?

-- 
balbi

[-- Attachment #2: Digital signature --]
[-- Type: application/pgp-signature, Size: 819 bytes --]

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

* Re: [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use
  2015-01-16  1:28         ` Felipe Balbi
@ 2015-01-16  4:36           ` David Miller
  0 siblings, 0 replies; 8+ messages in thread
From: David Miller @ 2015-01-16  4:36 UTC (permalink / raw)
  To: balbi; +Cc: mugunthanvnm, tony, linux-omap, netdev

From: Felipe Balbi <balbi@ti.com>
Date: Thu, 15 Jan 2015 19:28:52 -0600

> On Thu, Jan 15, 2015 at 06:16:15PM -0500, David Miller wrote:
>> Indeed, I agree that adding something as a placeholder that just gets
>> immediately removed should be avoided unless it is extremely difficult
>> to do so.
> 
> what does this mean ? you prefer both patches to be combined ?

Yes, something like that.

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

end of thread, other threads:[~2015-01-16  4:36 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-01-14 16:58 [patch-net-next v2 1/3] net: ethernet: cpsw: unroll IRQ request loop Felipe Balbi
2015-01-14 16:58 ` [patch-net-next v2 2/3] net: ethernet: cpsw: split out IRQ handler Felipe Balbi
2015-01-14 16:58 ` [patch-net-next v2 3/3] net: ethernet: cpsw: don't requests IRQs we don't use Felipe Balbi
2015-01-15  7:49   ` Mugunthan V N
2015-01-15 15:20     ` Felipe Balbi
2015-01-15 23:16       ` David Miller
2015-01-16  1:28         ` Felipe Balbi
2015-01-16  4:36           ` David Miller

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).