]> www.infradead.org Git - users/jedix/linux-maple.git/commitdiff
sif: sqflush: Fix wrong casting in the calculation of CQ full
authorWei Lin Guay <wei.lin.guay@oracle.com>
Mon, 26 Sep 2016 14:09:27 +0000 (16:09 +0200)
committerKnut Omang <knut.omang@oracle.com>
Mon, 3 Oct 2016 12:02:26 +0000 (14:02 +0200)
Orabug: 24735772

The CQ full is calculated via last posted seq number (last_seq)
minus the last completion seq number (head_seq). Both last_seq
and head_seq are defined as u16. However, in the calculation to
verify that the CQ is not full, a wrong casting is performed.
This causes a false negative of CQ full in the wrapped case.

Signed-off-by: Wei Lin Guay <wei.lin.guay@oracle.com>
Reviewed-by: Knut Omang <knut.omang@oracle.com>
drivers/infiniband/hw/sif/sif_defs.h
drivers/infiniband/hw/sif/sif_r3.c

index 4ed1b076a4e29e5a6d2ec0d4b01134299b5cbf9c..a093f03f75ba4812e71453744295de17c2de4c40 100644 (file)
@@ -36,6 +36,7 @@ struct xchar {
 };
 
 #define GREATER_16(a, b) ((s16)((s16)(a) - (s16)(b)) > 0)
+#define GREATER_32(a, b) ((s32)((s32)(a) - (s32)(b)) > 0)
 #define LESS_OR_EQUAL_16(a, b) (!(GREATER_16((a), (b))))
 #define PSIF_WC_STATUS_DUPL_COMPL_ERR (PSIF_WC_STATUS_FIELD_MAX - 1)
 #define PSIF_WC_STATUS_GEN_TRANSL_COMPL_ERR (PSIF_WC_STATUS_FIELD_MAX - 2)
index c3c0009fdea08141c23afc22bdba34855122542a..948c25ffdba6d100763333cf80802707754f5f0b 100644 (file)
@@ -696,9 +696,9 @@ flush_sq_again:
                last_seq, last_gen_seq);
 
        for (; (LESS_OR_EQUAL_16(last_seq, last_gen_seq)); ++last_seq) {
-               if (unlikely(cq->entries < ((u32) (last_seq - sq_sw->head_seq)))) {
+               if (unlikely(GREATER_32((u16)(last_seq - sq_sw->head_seq), cq->entries))) {
                        sif_log(sdev, SIF_INFO, "cq (%d) is  full! (len = %d, used = %d)",
-                               cq->index, cq->entries, last_seq - sq_sw->head_seq - 1);
+                               cq->index, cq->entries, (u16)(last_seq - sq_sw->head_seq));
                        goto err_post_wa4074;
                }