Commit 2b0dfc17 authored by David S. Miller's avatar David S. Miller

Merge branch 'hisilicon-fixes'

Jiangfeng Xiao says:

====================
net: hisilicon: Fix a few problems with hip04_eth

During the use of the hip04_eth driver,
several problems were found,
which solved the hip04_tx_reclaim reentry problem,
fixed the problem that hip04_mac_start_xmit never
returns NETDEV_TX_BUSY
and the dma_map_single failed on the arm64 platform.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 5b0bce24 96a50c0d
...@@ -220,6 +220,7 @@ struct hip04_priv { ...@@ -220,6 +220,7 @@ struct hip04_priv {
unsigned int reg_inten; unsigned int reg_inten;
struct napi_struct napi; struct napi_struct napi;
struct device *dev;
struct net_device *ndev; struct net_device *ndev;
struct tx_desc *tx_desc; struct tx_desc *tx_desc;
...@@ -248,7 +249,7 @@ struct hip04_priv { ...@@ -248,7 +249,7 @@ struct hip04_priv {
static inline unsigned int tx_count(unsigned int head, unsigned int tail) static inline unsigned int tx_count(unsigned int head, unsigned int tail)
{ {
return (head - tail) % (TX_DESC_NUM - 1); return (head - tail) % TX_DESC_NUM;
} }
static void hip04_config_port(struct net_device *ndev, u32 speed, u32 duplex) static void hip04_config_port(struct net_device *ndev, u32 speed, u32 duplex)
...@@ -465,7 +466,7 @@ static int hip04_tx_reclaim(struct net_device *ndev, bool force) ...@@ -465,7 +466,7 @@ static int hip04_tx_reclaim(struct net_device *ndev, bool force)
} }
if (priv->tx_phys[tx_tail]) { if (priv->tx_phys[tx_tail]) {
dma_unmap_single(&ndev->dev, priv->tx_phys[tx_tail], dma_unmap_single(priv->dev, priv->tx_phys[tx_tail],
priv->tx_skb[tx_tail]->len, priv->tx_skb[tx_tail]->len,
DMA_TO_DEVICE); DMA_TO_DEVICE);
priv->tx_phys[tx_tail] = 0; priv->tx_phys[tx_tail] = 0;
...@@ -516,8 +517,8 @@ hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev) ...@@ -516,8 +517,8 @@ hip04_mac_start_xmit(struct sk_buff *skb, struct net_device *ndev)
return NETDEV_TX_BUSY; return NETDEV_TX_BUSY;
} }
phys = dma_map_single(&ndev->dev, skb->data, skb->len, DMA_TO_DEVICE); phys = dma_map_single(priv->dev, skb->data, skb->len, DMA_TO_DEVICE);
if (dma_mapping_error(&ndev->dev, phys)) { if (dma_mapping_error(priv->dev, phys)) {
dev_kfree_skb(skb); dev_kfree_skb(skb);
return NETDEV_TX_OK; return NETDEV_TX_OK;
} }
...@@ -585,6 +586,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) ...@@ -585,6 +586,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
u16 len; u16 len;
u32 err; u32 err;
/* clean up tx descriptors */
tx_remaining = hip04_tx_reclaim(ndev, false);
while (cnt && !last) { while (cnt && !last) {
buf = priv->rx_buf[priv->rx_head]; buf = priv->rx_buf[priv->rx_head];
skb = build_skb(buf, priv->rx_buf_size); skb = build_skb(buf, priv->rx_buf_size);
...@@ -593,7 +597,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) ...@@ -593,7 +597,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
goto refill; goto refill;
} }
dma_unmap_single(&ndev->dev, priv->rx_phys[priv->rx_head], dma_unmap_single(priv->dev, priv->rx_phys[priv->rx_head],
RX_BUF_SIZE, DMA_FROM_DEVICE); RX_BUF_SIZE, DMA_FROM_DEVICE);
priv->rx_phys[priv->rx_head] = 0; priv->rx_phys[priv->rx_head] = 0;
...@@ -622,9 +626,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) ...@@ -622,9 +626,9 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
buf = netdev_alloc_frag(priv->rx_buf_size); buf = netdev_alloc_frag(priv->rx_buf_size);
if (!buf) if (!buf)
goto done; goto done;
phys = dma_map_single(&ndev->dev, buf, phys = dma_map_single(priv->dev, buf,
RX_BUF_SIZE, DMA_FROM_DEVICE); RX_BUF_SIZE, DMA_FROM_DEVICE);
if (dma_mapping_error(&ndev->dev, phys)) if (dma_mapping_error(priv->dev, phys))
goto done; goto done;
priv->rx_buf[priv->rx_head] = buf; priv->rx_buf[priv->rx_head] = buf;
priv->rx_phys[priv->rx_head] = phys; priv->rx_phys[priv->rx_head] = phys;
...@@ -645,8 +649,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget) ...@@ -645,8 +649,7 @@ static int hip04_rx_poll(struct napi_struct *napi, int budget)
} }
napi_complete_done(napi, rx); napi_complete_done(napi, rx);
done: done:
/* clean up tx descriptors and start a new timer if necessary */ /* start a new timer if necessary */
tx_remaining = hip04_tx_reclaim(ndev, false);
if (rx < budget && tx_remaining) if (rx < budget && tx_remaining)
hip04_start_tx_timer(priv); hip04_start_tx_timer(priv);
...@@ -728,9 +731,9 @@ static int hip04_mac_open(struct net_device *ndev) ...@@ -728,9 +731,9 @@ static int hip04_mac_open(struct net_device *ndev)
for (i = 0; i < RX_DESC_NUM; i++) { for (i = 0; i < RX_DESC_NUM; i++) {
dma_addr_t phys; dma_addr_t phys;
phys = dma_map_single(&ndev->dev, priv->rx_buf[i], phys = dma_map_single(priv->dev, priv->rx_buf[i],
RX_BUF_SIZE, DMA_FROM_DEVICE); RX_BUF_SIZE, DMA_FROM_DEVICE);
if (dma_mapping_error(&ndev->dev, phys)) if (dma_mapping_error(priv->dev, phys))
return -EIO; return -EIO;
priv->rx_phys[i] = phys; priv->rx_phys[i] = phys;
...@@ -764,7 +767,7 @@ static int hip04_mac_stop(struct net_device *ndev) ...@@ -764,7 +767,7 @@ static int hip04_mac_stop(struct net_device *ndev)
for (i = 0; i < RX_DESC_NUM; i++) { for (i = 0; i < RX_DESC_NUM; i++) {
if (priv->rx_phys[i]) { if (priv->rx_phys[i]) {
dma_unmap_single(&ndev->dev, priv->rx_phys[i], dma_unmap_single(priv->dev, priv->rx_phys[i],
RX_BUF_SIZE, DMA_FROM_DEVICE); RX_BUF_SIZE, DMA_FROM_DEVICE);
priv->rx_phys[i] = 0; priv->rx_phys[i] = 0;
} }
...@@ -907,6 +910,7 @@ static int hip04_mac_probe(struct platform_device *pdev) ...@@ -907,6 +910,7 @@ static int hip04_mac_probe(struct platform_device *pdev)
return -ENOMEM; return -ENOMEM;
priv = netdev_priv(ndev); priv = netdev_priv(ndev);
priv->dev = d;
priv->ndev = ndev; priv->ndev = ndev;
platform_set_drvdata(pdev, ndev); platform_set_drvdata(pdev, ndev);
SET_NETDEV_DEV(ndev, &pdev->dev); SET_NETDEV_DEV(ndev, &pdev->dev);
......
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