IB/qib: Fix a possible data corruption when receiving packets
authorRam Vepa <ram.vepa@qlogic.com>
Fri, 23 Dec 2011 13:01:43 +0000 (08:01 -0500)
committerRoland Dreier <roland@purestorage.com>
Wed, 4 Jan 2012 04:53:02 +0000 (20:53 -0800)
Prevent a receive data corruption by ensuring that the write to update
the rcvhdrheadn register to generate an interrupt is at the very end
of the receive processing.

Signed-off-by: Ramkrishna Vepa <ram.vepa@qlogic.com>
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Cc: <stable@kernel.org>
Signed-off-by: Roland Dreier <roland@purestorage.com>
drivers/infiniband/hw/qib/qib_iba6120.c
drivers/infiniband/hw/qib/qib_iba7220.c
drivers/infiniband/hw/qib/qib_iba7322.c

index 781a802a321f069d3a8b6552713a3cb550d52803..4f18e2d332dfd79ba8dcfc66a6c9251347a562c1 100644 (file)
@@ -2076,9 +2076,11 @@ static void qib_6120_config_ctxts(struct qib_devdata *dd)
 static void qib_update_6120_usrhead(struct qib_ctxtdata *rcd, u64 hd,
                                    u32 updegr, u32 egrhd, u32 npkts)
 {
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_6120_hdrqempty(struct qib_ctxtdata *rcd)
index 9dd886cc633a7b869d30cc8cee0459df4b14000b..3c722f79d6f640cf4930a011bd5f3d8ccc2084cd 100644 (file)
@@ -2725,9 +2725,11 @@ static int qib_7220_set_loopback(struct qib_pportdata *ppd, const char *what)
 static void qib_update_7220_usrhead(struct qib_ctxtdata *rcd, u64 hd,
                                    u32 updegr, u32 egrhd, u32 npkts)
 {
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_7220_hdrqempty(struct qib_ctxtdata *rcd)
index abd218d429fe08d93afb196a08677d8167e9d193..e22735402649f31ccbb294984f38a40eb86aac35 100644 (file)
@@ -4083,10 +4083,12 @@ static void qib_update_7322_usrhead(struct qib_ctxtdata *rcd, u64 hd,
         */
        if (hd >> IBA7322_HDRHEAD_PKTINT_SHIFT)
                adjust_rcv_timeout(rcd, npkts);
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
-       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
        if (updegr)
                qib_write_ureg(rcd->dd, ur_rcvegrindexhead, egrhd, rcd->ctxt);
+       mmiowb();
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       qib_write_ureg(rcd->dd, ur_rcvhdrhead, hd, rcd->ctxt);
+       mmiowb();
 }
 
 static u32 qib_7322_hdrqempty(struct qib_ctxtdata *rcd)