net: sh_eth: fix the rxdesc pointer when rx descriptor empty happens
authorYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Mon, 28 May 2012 23:07:55 +0000 (23:07 +0000)
committerDavid S. Miller <davem@davemloft.net>
Tue, 29 May 2012 21:30:08 +0000 (17:30 -0400)
When Receive Descriptor Empty happens, rxdesc pointer of the driver
and actual next descriptor of the controller may be mismatch.
This patch fixes it.

Signed-off-by: Yoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/renesas/sh_eth.c

index be3c22179161504f39eb2527b85cfa44eb2da685..667169b825263d96402b44ba22784a1696f80c82 100644 (file)
@@ -1101,8 +1101,12 @@ static int sh_eth_rx(struct net_device *ndev)
 
        /* Restart Rx engine if stopped. */
        /* If we don't need to check status, don't. -KDU */
-       if (!(sh_eth_read(ndev, EDRRR) & EDRRR_R))
+       if (!(sh_eth_read(ndev, EDRRR) & EDRRR_R)) {
+               /* fix the values for the next receiving */
+               mdp->cur_rx = mdp->dirty_rx = (sh_eth_read(ndev, RDFAR) -
+                                              sh_eth_read(ndev, RDLAR)) >> 4;
                sh_eth_write(ndev, EDRRR_R, EDRRR);
+       }
 
        return 0;
 }
@@ -1199,8 +1203,6 @@ static void sh_eth_error(struct net_device *ndev, int intr_status)
                /* Receive Descriptor Empty int */
                ndev->stats.rx_over_errors++;
 
-               if (sh_eth_read(ndev, EDRRR) ^ EDRRR_R)
-                       sh_eth_write(ndev, EDRRR_R, EDRRR);
                if (netif_msg_rx_err(mdp))
                        dev_err(&ndev->dev, "Receive Descriptor Empty\n");
        }