Commit 39e3622e authored by Ilias Apalodimas's avatar Ilias Apalodimas Committed by David S. Miller

net: netsec: initialize tx ring on ndo_open

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: 35e07d23 ("net: socionext: remove mmio reads on Tx")
Signed-off-by: default avatarIlias Apalodimas <ilias.apalodimas@linaro.org>
Acked-by: default avatarArd Biesheuvel <ard.biesheuvel@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent e41d4bc5
...@@ -1029,7 +1029,6 @@ static void netsec_free_dring(struct netsec_priv *priv, int id) ...@@ -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) static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
{ {
struct netsec_desc_ring *dring = &priv->desc_ring[id]; struct netsec_desc_ring *dring = &priv->desc_ring[id];
int i;
dring->vaddr = dma_alloc_coherent(priv->dev, DESC_SZ * DESC_NUM, dring->vaddr = dma_alloc_coherent(priv->dev, DESC_SZ * DESC_NUM,
&dring->desc_dma, GFP_KERNEL); &dring->desc_dma, GFP_KERNEL);
...@@ -1040,7 +1039,18 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) ...@@ -1040,7 +1039,18 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
if (!dring->desc) if (!dring->desc)
goto err; goto err;
if (id == NETSEC_RING_TX) { return 0;
err:
netsec_free_dring(priv, 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++) { for (i = 0; i < DESC_NUM; i++) {
struct netsec_de *de; struct netsec_de *de;
...@@ -1051,13 +1061,6 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) ...@@ -1051,13 +1061,6 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id)
*/ */
de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD; de->attr = 1U << NETSEC_TX_SHIFT_OWN_FIELD;
} }
}
return 0;
err:
netsec_free_dring(priv, id);
return -ENOMEM;
} }
static int netsec_setup_rx_dring(struct netsec_priv *priv) static int netsec_setup_rx_dring(struct netsec_priv *priv)
...@@ -1361,6 +1364,7 @@ static int netsec_netdev_open(struct net_device *ndev) ...@@ -1361,6 +1364,7 @@ static int netsec_netdev_open(struct net_device *ndev)
pm_runtime_get_sync(priv->dev); pm_runtime_get_sync(priv->dev);
netsec_setup_tx_dring(priv);
ret = netsec_setup_rx_dring(priv); ret = netsec_setup_rx_dring(priv);
if (ret) { if (ret) {
netif_err(priv, probe, priv->ndev, netif_err(priv, probe, priv->ndev,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment