bnxt_re: Fix incorrect usage of test_bit()
authorSomnath Kotur <somnath.kotur@broadcom.com>
Fri, 13 Oct 2017 06:08:00 +0000 (11:38 +0530)
committerDoug Ledford <dledford@redhat.com>
Wed, 18 Oct 2017 14:24:12 +0000 (10:24 -0400)
test_bit() takes a bit number while the 'flags' field in
struct bnxt_qplib_rcfw was using actual BIT position converted
values.
Fix this by assigning bit numbers and use consistent APIs
all the flag values.
Also logging a message in case of failure.

Thanks to Dan Carpenter for pointing this out.

Suggested-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Somnath Kotur <somnath.kotur@broadcom.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/bnxt_re/main.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.c
drivers/infiniband/hw/bnxt_re/qplib_rcfw.h

index e7450ea92aa9e11ba0d28792f54fcf373e470a66..87f8a5d5d78f02a7351da2870f2051e11d8e0481 100644 (file)
@@ -1071,9 +1071,10 @@ static int bnxt_re_ib_reg(struct bnxt_re_dev *rdev)
         */
        rc = bnxt_qplib_alloc_rcfw_channel(rdev->en_dev->pdev, &rdev->rcfw,
                                           BNXT_RE_MAX_QPC_COUNT);
-       if (rc)
+       if (rc) {
+               pr_err("Failed to allocate RCFW Channel: %#x\n", rc);
                goto fail;
-
+       }
        rc = bnxt_re_net_ring_alloc
                        (rdev, rdev->rcfw.creq.pbl[PBL_LVL_0].pg_map_arr,
                         rdev->rcfw.creq.pbl[rdev->rcfw.creq.level].pg_count,
index 000e6a1940b9078659c096788fb377f18473ab45..6d116146fa3cab2aea20f6dfc352291b3756f3c1 100644 (file)
@@ -168,14 +168,14 @@ static int __send_message(struct bnxt_qplib_rcfw *rcfw, struct cmdq_base *req,
        rcfw->seq_num++;
 
        cmdq_prod = cmdq->prod;
-       if (rcfw->flags & FIRMWARE_FIRST_FLAG) {
+       if (test_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags)) {
                /* The very first doorbell write
                 * is required to set this flag
                 * which prompts the FW to reset
                 * its internal pointers
                 */
-               cmdq_prod |= FIRMWARE_FIRST_FLAG;
-               rcfw->flags &= ~FIRMWARE_FIRST_FLAG;
+               cmdq_prod |= BIT(FIRMWARE_FIRST_FLAG);
+               clear_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags);
        }
 
        /* ring CMDQ DB */
@@ -618,7 +618,7 @@ int bnxt_qplib_enable_rcfw_channel(struct pci_dev *pdev,
 
        /* General */
        rcfw->seq_num = 0;
-       rcfw->flags = FIRMWARE_FIRST_FLAG;
+       set_bit(FIRMWARE_FIRST_FLAG, &rcfw->flags);
        bmap_size = BITS_TO_LONGS(RCFW_MAX_OUTSTANDING_CMD *
                                  sizeof(unsigned long));
        rcfw->cmdq_bitmap = kzalloc(bmap_size, GFP_KERNEL);
index 85b16da287f99edfee396fcdaa11ccef1c7c8d3b..2946a7cfae82b1f662a65567c5a32e1a69feffdd 100644 (file)
@@ -162,9 +162,9 @@ struct bnxt_qplib_rcfw {
        unsigned long           *cmdq_bitmap;
        u32                     bmap_size;
        unsigned long           flags;
-#define FIRMWARE_INITIALIZED_FLAG      BIT(0)
-#define FIRMWARE_FIRST_FLAG            BIT(31)
-#define FIRMWARE_TIMED_OUT             BIT(3)
+#define FIRMWARE_INITIALIZED_FLAG      0
+#define FIRMWARE_FIRST_FLAG            31
+#define FIRMWARE_TIMED_OUT             3
        wait_queue_head_t       waitq;
        int                     (*aeq_handler)(struct bnxt_qplib_rcfw *,
                                               struct creq_func_event *);