Skip to content

Commit 107c3f4

Browse files
Michael Chandavem330
authored andcommitted
cnic: Prevent status block race conditions with hardware
The status block index is used to acknowledge interrupt events and must be read before checking for the interrupt events, so we need to add rmb() to guarantee that. Signed-off-by: Michael Chan <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1707be1 commit 107c3f4

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

drivers/net/cnic.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2760,6 +2760,8 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)
27602760
u32 status_idx = (u16) *cp->kcq1.status_idx_ptr;
27612761
int kcqe_cnt;
27622762

2763+
/* status block index must be read before reading other fields */
2764+
rmb();
27632765
cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
27642766

27652767
while ((kcqe_cnt = cnic_get_kcqes(dev, &cp->kcq1))) {
@@ -2770,6 +2772,8 @@ static u32 cnic_service_bnx2_queues(struct cnic_dev *dev)
27702772
barrier();
27712773
if (status_idx != *cp->kcq1.status_idx_ptr) {
27722774
status_idx = (u16) *cp->kcq1.status_idx_ptr;
2775+
/* status block index must be read first */
2776+
rmb();
27732777
cp->kwq_con_idx = *cp->kwq_con_idx_ptr;
27742778
} else
27752779
break;
@@ -2888,6 +2892,8 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info)
28882892
u32 last_status = *info->status_idx_ptr;
28892893
int kcqe_cnt;
28902894

2895+
/* status block index must be read before reading the KCQ */
2896+
rmb();
28912897
while ((kcqe_cnt = cnic_get_kcqes(dev, info))) {
28922898

28932899
service_kcqes(dev, kcqe_cnt);
@@ -2898,6 +2904,8 @@ static u32 cnic_service_bnx2x_kcq(struct cnic_dev *dev, struct kcq_info *info)
28982904
break;
28992905

29002906
last_status = *info->status_idx_ptr;
2907+
/* status block index must be read before reading the KCQ */
2908+
rmb();
29012909
}
29022910
return last_status;
29032911
}

0 commit comments

Comments
 (0)