Skip to content

Commit

Permalink
Merge branch 'sh_eth'
Browse files Browse the repository at this point in the history
Ben Hutchings says:

====================
Fixes for sh_eth #2

I'm continuing review and testing of Ethernet support on the R-Car H2
chip.  This series fixes more of the issues I've found, but it won't be
the last set.

These are not tested on any of the other supported chips.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
David S. Miller committed Jan 27, 2015
2 parents 02a5416 + 283e38d commit 9d08da9
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 30 deletions.
84 changes: 54 additions & 30 deletions drivers/net/ethernet/renesas/sh_eth.c
Original file line number Diff line number Diff line change
Expand Up @@ -1316,8 +1316,10 @@ static int sh_eth_dev_init(struct net_device *ndev, bool start)
RFLR);

sh_eth_write(ndev, sh_eth_read(ndev, EESR), EESR);
if (start)
if (start) {
mdp->irq_enabled = true;
sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR);
}

/* PAUSE Prohibition */
val = (sh_eth_read(ndev, ECMR) & ECMR_DM) |
Expand Down Expand Up @@ -1653,7 +1655,12 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
if (intr_status & (EESR_RX_CHECK | cd->tx_check | cd->eesr_err_check))
ret = IRQ_HANDLED;
else
goto other_irq;
goto out;

if (!likely(mdp->irq_enabled)) {
sh_eth_write(ndev, 0, EESIPR);
goto out;
}

if (intr_status & EESR_RX_CHECK) {
if (napi_schedule_prep(&mdp->napi)) {
Expand Down Expand Up @@ -1684,7 +1691,7 @@ static irqreturn_t sh_eth_interrupt(int irq, void *netdev)
sh_eth_error(ndev, intr_status);
}

other_irq:
out:
spin_unlock(&mdp->lock);

return ret;
Expand Down Expand Up @@ -1712,7 +1719,8 @@ static int sh_eth_poll(struct napi_struct *napi, int budget)
napi_complete(napi);

/* Reenable Rx interrupts */
sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR);
if (mdp->irq_enabled)
sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR);
out:
return budget - quota;
}
Expand Down Expand Up @@ -1968,40 +1976,52 @@ static int sh_eth_set_ringparam(struct net_device *ndev,
return -EINVAL;

if (netif_running(ndev)) {
netif_device_detach(ndev);
netif_tx_disable(ndev);
/* Disable interrupts by clearing the interrupt mask. */

/* Serialise with the interrupt handler and NAPI, then
* disable interrupts. We have to clear the
* irq_enabled flag first to ensure that interrupts
* won't be re-enabled.
*/
mdp->irq_enabled = false;
synchronize_irq(ndev->irq);
napi_synchronize(&mdp->napi);
sh_eth_write(ndev, 0x0000, EESIPR);

/* Stop the chip's Tx and Rx processes. */
sh_eth_write(ndev, 0, EDTRR);
sh_eth_write(ndev, 0, EDRRR);
synchronize_irq(ndev->irq);
}

/* Free all the skbuffs in the Rx queue. */
sh_eth_ring_free(ndev);
/* Free DMA buffer */
sh_eth_free_dma_buffer(mdp);
/* Free all the skbuffs in the Rx queue. */
sh_eth_ring_free(ndev);
/* Free DMA buffer */
sh_eth_free_dma_buffer(mdp);
}

/* Set new parameters */
mdp->num_rx_ring = ring->rx_pending;
mdp->num_tx_ring = ring->tx_pending;

ret = sh_eth_ring_init(ndev);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_ring_init failed.\n", __func__);
return ret;
}
ret = sh_eth_dev_init(ndev, false);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_dev_init failed.\n", __func__);
return ret;
}

if (netif_running(ndev)) {
ret = sh_eth_ring_init(ndev);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_ring_init failed.\n",
__func__);
return ret;
}
ret = sh_eth_dev_init(ndev, false);
if (ret < 0) {
netdev_err(ndev, "%s: sh_eth_dev_init failed.\n",
__func__);
return ret;
}

mdp->irq_enabled = true;
sh_eth_write(ndev, mdp->cd->eesipr_value, EESIPR);
/* Setting the Rx mode will start the Rx process. */
sh_eth_write(ndev, EDRRR_R, EDRRR);
netif_wake_queue(ndev);
netif_device_attach(ndev);
}

return 0;
Expand Down Expand Up @@ -2117,6 +2137,9 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
}
spin_unlock_irqrestore(&mdp->lock, flags);

if (skb_padto(skb, ETH_ZLEN))
return NETDEV_TX_OK;

entry = mdp->cur_tx % mdp->num_tx_ring;
mdp->tx_skbuff[entry] = skb;
txdesc = &mdp->tx_ring[entry];
Expand All @@ -2126,10 +2149,7 @@ static int sh_eth_start_xmit(struct sk_buff *skb, struct net_device *ndev)
skb->len + 2);
txdesc->addr = dma_map_single(&ndev->dev, skb->data, skb->len,
DMA_TO_DEVICE);
if (skb->len < ETH_ZLEN)
txdesc->buffer_length = ETH_ZLEN;
else
txdesc->buffer_length = skb->len;
txdesc->buffer_length = skb->len;

if (entry >= mdp->num_tx_ring - 1)
txdesc->status |= cpu_to_edmac(mdp, TD_TACT | TD_TDLE);
Expand Down Expand Up @@ -2181,7 +2201,13 @@ static int sh_eth_close(struct net_device *ndev)

netif_stop_queue(ndev);

/* Disable interrupts by clearing the interrupt mask. */
/* Serialise with the interrupt handler and NAPI, then disable
* interrupts. We have to clear the irq_enabled flag first to
* ensure that interrupts won't be re-enabled.
*/
mdp->irq_enabled = false;
synchronize_irq(ndev->irq);
napi_disable(&mdp->napi);
sh_eth_write(ndev, 0x0000, EESIPR);

/* Stop the chip's Tx and Rx processes. */
Expand All @@ -2198,8 +2224,6 @@ static int sh_eth_close(struct net_device *ndev)

free_irq(ndev->irq, ndev);

napi_disable(&mdp->napi);

/* Free all the skbuffs in the Rx queue. */
sh_eth_ring_free(ndev);

Expand Down
1 change: 1 addition & 0 deletions drivers/net/ethernet/renesas/sh_eth.h
Original file line number Diff line number Diff line change
Expand Up @@ -513,6 +513,7 @@ struct sh_eth_private {
u32 rx_buf_sz; /* Based on MTU+slack. */
int edmac_endian;
struct napi_struct napi;
bool irq_enabled;
/* MII transceiver section. */
u32 phy_id; /* PHY ID */
struct mii_bus *mii_bus; /* MDIO bus control */
Expand Down

0 comments on commit 9d08da9

Please sign in to comment.