diff mbox series

[net-next,1/2] net: netsec: initialize tx ring on ndo_open

Message ID 1560931034-6810-1-git-send-email-ilias.apalodimas@linaro.org
State Superseded
Headers show
Series [net-next,1/2] net: netsec: initialize tx ring on ndo_open | expand

Commit Message

Ilias Apalodimas June 19, 2019, 7:57 a.m. UTC
Since we changed the Tx ring handling and now depend not 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

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

Signed-off-by: Ilias Apalodimas <ilias.apalodimas@linaro.org>

---
 drivers/net/ethernet/socionext/netsec.c | 32 ++++++++++++++-----------
 1 file changed, 18 insertions(+), 14 deletions(-)

-- 
2.20.1

Comments

Ard Biesheuvel June 19, 2019, 9:40 a.m. UTC | #1
On Wed, 19 Jun 2019 at 09:57, Ilias Apalodimas
<ilias.apalodimas@linaro.org> wrote:
>

> Since we changed the Tx ring handling and now depend not bit31 to figure


s/not/on/

> 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

>

> Fixes: 35e07d23473972b8876f98bcfc631ebcf779e870 ("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

>
diff mbox series

Patch

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,