netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open
@ 2019-06-19 10:04 Ilias Apalodimas
  2019-06-19 10:04 ` [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process Ilias Apalodimas
  2019-06-19 14:28 ` [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open David Miller
  0 siblings, 2 replies; 4+ messages in thread
From: Ilias Apalodimas @ 2019-06-19 10:04 UTC (permalink / raw)
  To: jaswinder.singh
  Cc: netdev, ard.biesheuvel, masahisa.kojima, davem, Ilias Apalodimas

Since we changed the Tx ring handling and now depends on bit31 to figure
out the owner of the descriptor, we should initialize this every time
the device goes down-up instead of doing it once on driver init. If the
value is not correctly initialized the device won't have any available
descriptors

Changes since v1:
- Typo fixes

Fixes: 35e07d234739 ("net: socionext: remove mmio reads on Tx")

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 32 ++++++++++++++-----------
 1 file changed, 18 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index cba5881b2746..a10ef700f16d 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -1029,7 +1029,6 @@ static void netsec_free_dring(struct netsec_priv *priv, int id)
 static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
 {
 	struct netsec_desc_ring *dring = &priv->desc_ring[id];
-	int i;
 
 	dring->vaddr = dma_alloc_coherent(priv->dev, DESC_SZ * DESC_NUM,
 					  &dring->desc_dma, GFP_KERNEL);
@@ -1040,19 +1039,6 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
 	if (!dring->desc)
 		goto err;
 
-	if (id == NETSEC_RING_TX) {
-		for (i = 0; i < DESC_NUM; i++) {
-			struct netsec_de *de;
-
-			de = dring->vaddr + (DESC_SZ * i);
-			/* de->attr is not going to be accessed by the NIC
-			 * until netsec_set_tx_de() is called.
-			 * No need for a dma_wmb() here
-			 */
-			de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD;
-		}
-	}
-
 	return 0;
 err:
 	netsec_free_dring(priv, id);
@@ -1060,6 +1046,23 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
 	return -ENOMEM;
 }
 
+static void netsec_setup_tx_dring(struct netsec_priv *priv)
+{
+	struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_TX];
+	int i;
+
+	for (i = 0; i < DESC_NUM; i++) {
+		struct netsec_de *de;
+
+		de = dring->vaddr + (DESC_SZ * i);
+		/* de->attr is not going to be accessed by the NIC
+		 * until netsec_set_tx_de() is called.
+		 * No need for a dma_wmb() here
+		 */
+		de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD;
+	}
+}
+
 static int netsec_setup_rx_dring(struct netsec_priv *priv)
 {
 	struct netsec_desc_ring *dring = &priv->desc_ring[NETSEC_RING_RX];
@@ -1361,6 +1364,7 @@ static int netsec_netdev_open(struct net_device *ndev)
 
 	pm_runtime_get_sync(priv->dev);
 
+	netsec_setup_tx_dring(priv);
 	ret = netsec_setup_rx_dring(priv);
 	if (ret) {
 		netif_err(priv, probe, priv->ndev,
-- 
2.20.1


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

* [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process
  2019-06-19 10:04 [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open Ilias Apalodimas
@ 2019-06-19 10:04 ` Ilias Apalodimas
  2019-06-19 14:29   ` David Miller
  2019-06-19 14:28 ` [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open David Miller
  1 sibling, 1 reply; 4+ messages in thread
From: Ilias Apalodimas @ 2019-06-19 10:04 UTC (permalink / raw)
  To: jaswinder.singh
  Cc: netdev, ard.biesheuvel, masahisa.kojima, davem, Ilias Apalodimas

netsec_process_rx was running in a loop trying to process as many packets
as possible before re-enabling interrupts. With the recent DMA changes
this is not needed anymore as we manage to consume all the budget without
looping over the function.
Since it has no performance penalty let's remove that and simplify the Rx
path a bit

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>
---
 drivers/net/ethernet/socionext/netsec.c | 11 ++---------
 1 file changed, 2 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c
index a10ef700f16d..48fd7448b513 100644
--- a/drivers/net/ethernet/socionext/netsec.c
+++ b/drivers/net/ethernet/socionext/netsec.c
@@ -820,19 +820,12 @@ static int netsec_process_rx(struct netsec_priv *priv, int budget)
 static int netsec_napi_poll(struct napi_struct *napi, int budget)
 {
 	struct netsec_priv *priv;
-	int rx, done, todo;
+	int done;
 
 	priv = container_of(napi, struct netsec_priv, napi);
 
 	netsec_process_tx(priv);
-
-	todo = budget;
-	do {
-		rx = netsec_process_rx(priv, todo);
-		todo -= rx;
-	} while (rx);
-
-	done = budget - todo;
+	done = netsec_process_rx(priv, budget);
 
 	if (done < budget && napi_complete_done(napi, done)) {
 		unsigned long flags;
-- 
2.20.1


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

* Re: [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open
  2019-06-19 10:04 [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open Ilias Apalodimas
  2019-06-19 10:04 ` [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process Ilias Apalodimas
@ 2019-06-19 14:28 ` David Miller
  1 sibling, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-19 14:28 UTC (permalink / raw)
  To: ilias.apalodimas; +Cc: jaswinder.singh, netdev, ard.biesheuvel, masahisa.kojima

From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Wed, 19 Jun 2019 13:04:00 +0300

> Since we changed the Tx ring handling and now depends on bit31 to figure
> out the owner of the descriptor, we should initialize this every time
> the device goes down-up instead of doing it once on driver init. If the
> value is not correctly initialized the device won't have any available
> descriptors
> 
> Changes since v1:
> - Typo fixes
> 
> Fixes: 35e07d234739 ("net: socionext: remove mmio reads on Tx")
> 
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Applied, please do not put an empty line between the Fixes and other
tags.  Keep all the tags together in one group.

Thanks.

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

* Re: [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process
  2019-06-19 10:04 ` [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process Ilias Apalodimas
@ 2019-06-19 14:29   ` David Miller
  0 siblings, 0 replies; 4+ messages in thread
From: David Miller @ 2019-06-19 14:29 UTC (permalink / raw)
  To: ilias.apalodimas; +Cc: jaswinder.singh, netdev, ard.biesheuvel, masahisa.kojima

From: Ilias Apalodimas <ilias.apalodimas@linaro.org>
Date: Wed, 19 Jun 2019 13:04:01 +0300

> netsec_process_rx was running in a loop trying to process as many packets
> as possible before re-enabling interrupts. With the recent DMA changes
> this is not needed anymore as we manage to consume all the budget without
> looping over the function.
> Since it has no performance penalty let's remove that and simplify the Rx
> path a bit
> 
> Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>
> Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

Applied.

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

end of thread, other threads:[~2019-06-19 14:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-06-19 10:04 [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open Ilias Apalodimas
2019-06-19 10:04 ` [net-next, PATCH 2/2, v2] net: netsec: remove loops in napi Rx process Ilias Apalodimas
2019-06-19 14:29   ` David Miller
2019-06-19 14:28 ` [net-next, PATCH 1/2, v2] net: netsec: initialize tx ring on ndo_open 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).