Skip to content
This repository has been archived by the owner on Aug 27, 2022. It is now read-only.

Commit

Permalink
bna: CQ Read Fix
Browse files Browse the repository at this point in the history
Valid bit check for completion needs read fence, so that it does not get
reordered with other loads.

Signed-off-by: Rasesh Mody <rmody@brocade.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
  • Loading branch information
Rasesh Mody authored and davem330 committed Dec 18, 2013
1 parent 66f9513 commit 17a30a1
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion drivers/net/ethernet/brocade/bna/bnad.c
Original file line number Diff line number Diff line change
Expand Up @@ -601,7 +601,18 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget)
cq = ccb->sw_q;
cmpl = &cq[ccb->producer_index];

while (cmpl->valid && (packets < budget)) {
while (packets < budget) {
if (!cmpl->valid)
break;
/* The 'valid' field is set by the adapter, only after writing
* the other fields of completion entry. Hence, do not load
* other fields of completion entry *before* the 'valid' is
* loaded. Adding the rmb() here prevents the compiler and/or
* CPU from reordering the reads which would potentially result
* in reading stale values in completion entry.
*/
rmb();

BNA_UPDATE_PKT_CNT(pkt_rt, ntohs(cmpl->length));

if (bna_is_small_rxq(cmpl->rxq_id))
Expand Down Expand Up @@ -641,6 +652,16 @@ bnad_cq_process(struct bnad *bnad, struct bna_ccb *ccb, int budget)

if (!next_cmpl->valid)
break;
/* The 'valid' field is set by the adapter, only
* after writing the other fields of completion
* entry. Hence, do not load other fields of
* completion entry *before* the 'valid' is
* loaded. Adding the rmb() here prevents the
* compiler and/or CPU from reordering the reads
* which would potentially result in reading
* stale values in completion entry.
*/
rmb();

len = ntohs(next_cmpl->length);
flags = ntohl(next_cmpl->flags);
Expand Down

0 comments on commit 17a30a1

Please sign in to comment.