Commit 50432cb5 authored by Stephen Hemminger's avatar Stephen Hemminger Committed by Jeff Garzik

sky2: memory barriers change

Do some memory barrier changes for safety/perfomance:
Don't need read after update to index, mmiowb() followed by read at end
of irq is sufficient.
Signed-off-by: default avatarStephn Hemminger <shemminger@linux-foundation.org>
Signed-off-by: default avatarJeff Garzik <jeff@garzik.org>
parent 84787e3f
...@@ -844,10 +844,12 @@ static inline struct tx_ring_info *tx_le_re(struct sky2_port *sky2, ...@@ -844,10 +844,12 @@ static inline struct tx_ring_info *tx_le_re(struct sky2_port *sky2,
/* Update chip's next pointer */ /* Update chip's next pointer */
static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx) static inline void sky2_put_idx(struct sky2_hw *hw, unsigned q, u16 idx)
{ {
q = Y2_QADDR(q, PREF_UNIT_PUT_IDX); /* Make sure write' to descriptors are complete before we tell hardware */
wmb(); wmb();
sky2_write16(hw, q, idx); sky2_write16(hw, Y2_QADDR(q, PREF_UNIT_PUT_IDX), idx);
sky2_read16(hw, q);
/* Synchronize I/O on since next processor may write to tail */
mmiowb();
} }
...@@ -979,6 +981,7 @@ static void sky2_rx_stop(struct sky2_port *sky2) ...@@ -979,6 +981,7 @@ static void sky2_rx_stop(struct sky2_port *sky2)
/* reset the Rx prefetch unit */ /* reset the Rx prefetch unit */
sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET); sky2_write32(hw, Y2_QADDR(rxq, PREF_UNIT_CTRL), PREF_UNIT_RST_SET);
mmiowb();
} }
/* Clean out receive buffer area, assumes receiver hardware stopped */ /* Clean out receive buffer area, assumes receiver hardware stopped */
...@@ -1198,7 +1201,7 @@ static int sky2_rx_start(struct sky2_port *sky2) ...@@ -1198,7 +1201,7 @@ static int sky2_rx_start(struct sky2_port *sky2)
} }
/* Tell chip about available buffers */ /* Tell chip about available buffers */
sky2_write16(hw, Y2_QADDR(rxq, PREF_UNIT_PUT_IDX), sky2->rx_put); sky2_put_idx(hw, rxq, sky2->rx_put);
return 0; return 0;
nomem: nomem:
sky2_rx_clean(sky2); sky2_rx_clean(sky2);
...@@ -1540,6 +1543,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done) ...@@ -1540,6 +1543,8 @@ static void sky2_tx_complete(struct sky2_port *sky2, u16 done)
} }
sky2->tx_cons = idx; sky2->tx_cons = idx;
smp_mb();
if (tx_avail(sky2) > MAX_SKB_TX_LE + 4) if (tx_avail(sky2) > MAX_SKB_TX_LE + 4)
netif_wake_queue(dev); netif_wake_queue(dev);
} }
...@@ -2218,6 +2223,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do) ...@@ -2218,6 +2223,7 @@ static int sky2_status_intr(struct sky2_hw *hw, int to_do)
/* Fully processed status ring so clear irq */ /* Fully processed status ring so clear irq */
sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ); sky2_write32(hw, STAT_CTRL, SC_STAT_CLR_IRQ);
mmiowb();
exit_loop: exit_loop:
if (buf_write[0]) { if (buf_write[0]) {
...@@ -2442,6 +2448,7 @@ static int sky2_poll(struct net_device *dev0, int *budget) ...@@ -2442,6 +2448,7 @@ static int sky2_poll(struct net_device *dev0, int *budget)
if (work_done < work_limit) { if (work_done < work_limit) {
netif_rx_complete(dev0); netif_rx_complete(dev0);
/* end of interrupt, re-enables also acts as I/O synchronization */
sky2_read32(hw, B0_Y2_SP_LISR); sky2_read32(hw, B0_Y2_SP_LISR);
return 0; return 0;
} else { } else {
......
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