Commit 97975500 authored by Anton Blanchard's avatar Anton Blanchard

[PATCH] tg3 bug

During receive processing, the tg3 card updates rx_producer (the
hardware position in the receive ring) and the opaque cookie. Due to PCI
rules the stores happen in order. However the cpu may reorder the reads.

In these sort of cases there is usually a data dependency between
reading the index and looking up the data (since we use the index to
load the data). I think all cpus except alpha guarantee the reads
happen in order in this case.

However in this particular case we load hw_idx, compare it to sw_idx and
then use sw_idx to locate the opaque cookie. There is no data dependency
in this case. We need a read memory barrier between the read of
rx_producer and the opaque cookie to enforce ordering.

Thanks to Olof Johansson, Michael Chan and Broadcom for their assistance
in finding this bug.
Signed-off-by: default avatarAnton Blanchard <anton@samba.org>
parent a4c553ed
......@@ -2455,6 +2455,11 @@ static int tg3_rx(struct tg3 *tp, int budget)
int received;
hw_idx = tp->hw_status->idx[0].rx_producer;
/*
* We need to order the read of hw_idx and the read of
* the opaque cookie.
*/
rmb();
sw_idx = rx_rcb_ptr % TG3_RX_RCB_RING_SIZE(tp);
work_mask = 0;
received = 0;
......
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