IB/hfi1: Correctly clear the pkey
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Thu, 4 May 2017 12:15:03 +0000 (05:15 -0700)
committerDoug Ledford <dledford@redhat.com>
Thu, 4 May 2017 23:31:46 +0000 (19:31 -0400)
In the close path the context is removed from the device array, and then
the clear pkey function is called.  The pkey function trys to get the
context from the device array, but because it was removed the clearing
does not occur.

Rework pkey clear function to work as expected.  Update the function
variable to reflect the correct size and name of the hw_context.

Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
Signed-off-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
Signed-off-by: Doug Ledford <dledford@redhat.com>
drivers/infiniband/hw/hfi1/chip.c
drivers/infiniband/hw/hfi1/chip.h
drivers/infiniband/hw/hfi1/file_ops.c
drivers/infiniband/hw/hfi1/vnic_main.c

index 5aa95da..9f72d55 100644 (file)
@@ -14528,30 +14528,24 @@ done:
        return ret;
 }
 
-int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt)
+int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, struct hfi1_ctxtdata *ctxt)
 {
-       struct hfi1_ctxtdata *rcd;
-       unsigned sctxt;
-       int ret = 0;
+       u8 hw_ctxt;
        u64 reg;
 
-       if (ctxt < dd->num_rcv_contexts) {
-               rcd = dd->rcd[ctxt];
-       } else {
-               ret = -EINVAL;
-               goto done;
-       }
-       if (!rcd || !rcd->sc) {
-               ret = -EINVAL;
-               goto done;
-       }
-       sctxt = rcd->sc->hw_context;
-       reg = read_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE);
+       if (!ctxt || !ctxt->sc)
+               return -EINVAL;
+
+       if (ctxt->ctxt >= dd->num_rcv_contexts)
+               return -EINVAL;
+
+       hw_ctxt = ctxt->sc->hw_context;
+       reg = read_kctxt_csr(dd, hw_ctxt, SEND_CTXT_CHECK_ENABLE);
        reg &= ~SEND_CTXT_CHECK_ENABLE_CHECK_PARTITION_KEY_SMASK;
-       write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_ENABLE, reg);
-       write_kctxt_csr(dd, sctxt, SEND_CTXT_CHECK_PARTITION_KEY, 0);
-done:
-       return ret;
+       write_kctxt_csr(dd, hw_ctxt, SEND_CTXT_CHECK_ENABLE, reg);
+       write_kctxt_csr(dd, hw_ctxt, SEND_CTXT_CHECK_PARTITION_KEY, 0);
+
+       return 0;
 }
 
 /*
index 4c3c88d..760aa2e 100644 (file)
@@ -1362,7 +1362,7 @@ int hfi1_set_ib_cfg(struct hfi1_pportdata *ppd, int which, u32 val);
 int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey);
 int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt);
 int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt, u16 pkey);
-int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt);
+int hfi1_clear_ctxt_pkey(struct hfi1_devdata *dd, struct hfi1_ctxtdata *ctxt);
 void hfi1_read_link_quality(struct hfi1_devdata *dd, u8 *link_quality);
 void hfi1_init_vnic_rsm(struct hfi1_devdata *dd);
 void hfi1_deinit_vnic_rsm(struct hfi1_devdata *dd);
index 9574fc4..5a62440 100644 (file)
@@ -810,7 +810,7 @@ static int hfi1_file_close(struct inode *inode, struct file *fp)
        dd->rcd[uctxt->ctxt] = NULL;
 
        hfi1_user_exp_rcv_grp_free(uctxt);
-       hfi1_clear_ctxt_pkey(dd, uctxt->ctxt);
+       hfi1_clear_ctxt_pkey(dd, uctxt);
 
        uctxt->rcvwait_to = 0;
        uctxt->piowait_to = 0;
index 392f4d5..b1572c7 100644 (file)
@@ -209,7 +209,7 @@ static void deallocate_vnic_ctxt(struct hfi1_devdata *dd,
        uctxt->event_flags = 0;
 
        hfi1_clear_tids(uctxt);
-       hfi1_clear_ctxt_pkey(dd, uctxt->ctxt);
+       hfi1_clear_ctxt_pkey(dd, uctxt);
 
        hfi1_stats.sps_ctxts--;
        hfi1_free_ctxtdata(dd, uctxt);