]> asedeno.scripts.mit.edu Git - linux.git/commitdiff
IB/hfi1: Size rcd array index correctly and consistently
authorMichael J. Ruhl <michael.j.ruhl@intel.com>
Mon, 24 Jul 2017 14:45:55 +0000 (07:45 -0700)
committerDoug Ledford <dledford@redhat.com>
Mon, 31 Jul 2017 19:17:55 +0000 (15:17 -0400)
The array index for the rcd array is sized several different ways
throughout the code.

Use the user interface size (u16) as the standard size and update the
necessary code to reflect this.

u16 is large enough for the largest amount of supported contexts.

Reviewed-by: Dennis Dalessandro <dennis.dalessandro@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/aspm.h
drivers/infiniband/hw/hfi1/chip.c
drivers/infiniband/hw/hfi1/chip.h
drivers/infiniband/hw/hfi1/driver.c
drivers/infiniband/hw/hfi1/file_ops.c
drivers/infiniband/hw/hfi1/hfi.h
drivers/infiniband/hw/hfi1/init.c
drivers/infiniband/hw/hfi1/trace_rx.h
drivers/infiniband/hw/hfi1/user_sdma.h
drivers/infiniband/hw/hfi1/vnic_main.c

index 794e6814a5313cfe49ca6c510ebe4b6c6a0ffe03..3f9a071ccac36be1c166cd946969f70e021004a5 100644 (file)
@@ -237,7 +237,7 @@ static inline void aspm_disable_all(struct hfi1_devdata *dd)
 {
        struct hfi1_ctxtdata *rcd;
        unsigned long flags;
-       unsigned i;
+       u16 i;
 
        for (i = 0; i < dd->first_dyn_alloc_ctxt; i++) {
                rcd = dd->rcd[i];
@@ -256,7 +256,7 @@ static inline void aspm_enable_all(struct hfi1_devdata *dd)
 {
        struct hfi1_ctxtdata *rcd;
        unsigned long flags;
-       unsigned i;
+       u16 i;
 
        aspm_enable(dd);
 
@@ -284,7 +284,7 @@ static inline void aspm_ctx_init(struct hfi1_ctxtdata *rcd)
 
 static inline void aspm_init(struct hfi1_devdata *dd)
 {
-       unsigned i;
+       u16 i;
 
        spin_lock_init(&dd->aspm_lock);
        dd->aspm_supported = aspm_hw_l1_supported(dd);
index 4fce173c86671a4a535ba8fb17fcbb94023c5268..06a79a268d2ea9aef3c3edeedf87020c24a4d73f 100644 (file)
@@ -6802,7 +6802,7 @@ static void rxe_freeze(struct hfi1_devdata *dd)
 static void rxe_kernel_unfreeze(struct hfi1_devdata *dd)
 {
        u32 rcvmask;
-       int i;
+       u16 i;
 
        /* enable all kernel contexts */
        for (i = 0; i < dd->num_rcv_contexts; i++) {
@@ -11722,7 +11722,7 @@ static u32 encoded_size(u32 size)
        return 0x1;     /* if invalid, go with the minimum size */
 }
 
-void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt)
+void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, u16 ctxt)
 {
        struct hfi1_ctxtdata *rcd;
        u64 rcvctrl, reg;
@@ -14542,7 +14542,7 @@ static void init_txe(struct hfi1_devdata *dd)
                write_csr(dd, SEND_CM_TIMER_CTRL, HFI1_CREDIT_RETURN_RATE);
 }
 
-int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey)
+int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, u16 ctxt, u16 jkey)
 {
        struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
        unsigned sctxt;
@@ -14579,7 +14579,7 @@ int hfi1_set_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt, u16 jkey)
        return ret;
 }
 
-int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt)
+int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, u16 ctxt)
 {
        struct hfi1_ctxtdata *rcd = dd->rcd[ctxt];
        unsigned sctxt;
@@ -14608,7 +14608,7 @@ int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, unsigned ctxt)
        return ret;
 }
 
-int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, unsigned ctxt, u16 pkey)
+int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, u16 ctxt, u16 pkey)
 {
        struct hfi1_ctxtdata *rcd;
        unsigned sctxt;
index d3622cb74b3f586405eb26950e987ac356b24bde..008c970412ec20ab89b3cec6bfb49485572f744d 100644 (file)
@@ -1352,14 +1352,14 @@ void hfi1_init_ctxt(struct send_context *sc);
 void hfi1_put_tid(struct hfi1_devdata *dd, u32 index,
                  u32 type, unsigned long pa, u16 order);
 void hfi1_quiet_serdes(struct hfi1_pportdata *ppd);
-void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, int ctxt);
+void hfi1_rcvctrl(struct hfi1_devdata *dd, unsigned int op, u16 ctxt);
 u32 hfi1_read_cntrs(struct hfi1_devdata *dd, char **namep, u64 **cntrp);
 u32 hfi1_read_portcntrs(struct hfi1_pportdata *ppd, char **namep, u64 **cntrp);
 int hfi1_get_ib_cfg(struct hfi1_pportdata *ppd, int which);
 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_set_ctxt_jkey(struct hfi1_devdata *dd, u16 ctxt, u16 jkey);
+int hfi1_clear_ctxt_jkey(struct hfi1_devdata *dd, u16 ctxt);
+int hfi1_set_ctxt_pkey(struct hfi1_devdata *dd, u16 ctxt, u16 pkey);
 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);
index 4a149cca47180885a3e639c8436574f6283898be..01235d4757a593f747901b08c3119905f4c2ff03 100644 (file)
@@ -837,9 +837,9 @@ int handle_receive_interrupt_dma_rtail(struct hfi1_ctxtdata *rcd, int thread)
        return last;
 }
 
-static inline void set_nodma_rtail(struct hfi1_devdata *dd, u8 ctxt)
+static inline void set_nodma_rtail(struct hfi1_devdata *dd, u16 ctxt)
 {
-       int i;
+       u16 i;
 
        /*
         * For dynamically allocated kernel contexts (like vnic) switch
@@ -857,9 +857,9 @@ static inline void set_nodma_rtail(struct hfi1_devdata *dd, u8 ctxt)
                        &handle_receive_interrupt_nodma_rtail;
 }
 
-static inline void set_dma_rtail(struct hfi1_devdata *dd, u8 ctxt)
+static inline void set_dma_rtail(struct hfi1_devdata *dd, u16 ctxt)
 {
-       int i;
+       u16 i;
 
        /*
         * For dynamically allocated kernel contexts (like vnic) switch
@@ -879,7 +879,7 @@ static inline void set_dma_rtail(struct hfi1_devdata *dd, u8 ctxt)
 
 void set_all_slowpath(struct hfi1_devdata *dd)
 {
-       int i;
+       u16 i;
 
        /* HFI1_CTRL_CTXT must always use the slow path interrupt handler */
        for (i = HFI1_CTRL_CTXT + 1; i < dd->num_rcv_contexts; i++) {
@@ -1068,7 +1068,7 @@ void receive_interrupt_work(struct work_struct *work)
        struct hfi1_pportdata *ppd = container_of(work, struct hfi1_pportdata,
                                                  linkstate_active_work);
        struct hfi1_devdata *dd = ppd->dd;
-       int i;
+       u16 i;
 
        /* Received non-SC15 packet implies neighbor_normal */
        ppd->neighbor_normal = 1;
@@ -1269,7 +1269,8 @@ void hfi1_start_led_override(struct hfi1_pportdata *ppd, unsigned int timeon,
  */
 int hfi1_reset_device(int unit)
 {
-       int ret, i;
+       int ret;
+       u16 i;
        struct hfi1_devdata *dd = hfi1_lookup(unit);
        struct hfi1_pportdata *ppd;
        unsigned long flags;
index e10f526d2dc1ffe3e9a5590b70be6edc1fa9e40c..c8f34bc6b620584f398485364e802570a65591a9 100644 (file)
@@ -927,7 +927,7 @@ static int assign_ctxt(struct hfi1_filedata *fd, struct hfi1_user_info *uinfo)
 static int find_sub_ctxt(struct hfi1_filedata *fd,
                         const struct hfi1_user_info *uinfo)
 {
-       int i;
+       u16 i;
        struct hfi1_devdata *dd = fd->dd;
        u16 subctxt;
 
@@ -978,7 +978,7 @@ static int allocate_ctxt(struct hfi1_filedata *fd, struct hfi1_devdata *dd,
                         struct hfi1_user_info *uinfo)
 {
        struct hfi1_ctxtdata *uctxt;
-       unsigned int ctxt;
+       u16 ctxt;
        int ret, numa;
 
        if (dd->flags & HFI1_FROZEN) {
@@ -1429,7 +1429,7 @@ int hfi1_set_uevent_bits(struct hfi1_pportdata *ppd, const int evtbit)
 {
        struct hfi1_ctxtdata *uctxt;
        struct hfi1_devdata *dd = ppd->dd;
-       unsigned ctxt;
+       u16 ctxt;
        int ret = 0;
        unsigned long flags;
 
index 7877ebc0b7ae6f2c2a55a5bf5f323136d3dcc23d..2ce3fc58b61bb6276308cdecb10a46419835f165 100644 (file)
@@ -217,7 +217,7 @@ struct hfi1_ctxtdata {
        struct kref kref;
 
        /* Device context index */
-       unsigned ctxt;
+       u16 ctxt;
        /*
         * non-zero if ctxt can be shared, and defines the maximum number of
         * sub-contexts for this device context.
@@ -1264,7 +1264,7 @@ void handle_user_interrupt(struct hfi1_ctxtdata *rcd);
 int hfi1_create_rcvhdrq(struct hfi1_devdata *dd, struct hfi1_ctxtdata *rcd);
 int hfi1_setup_eagerbufs(struct hfi1_ctxtdata *rcd);
 int hfi1_create_ctxts(struct hfi1_devdata *dd);
-struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
+struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u16 ctxt,
                                           int numa);
 void hfi1_init_pportdata(struct pci_dev *pdev, struct hfi1_pportdata *ppd,
                         struct hfi1_devdata *dd, u8 hw_pidx, u8 port);
index dfdb4126ca05e937db795a8ce5c50fa64c6658ee..818a4b87af605f0c4116f60e9a309bde4c889400 100644 (file)
@@ -131,7 +131,7 @@ unsigned long *hfi1_cpulist;
  */
 int hfi1_create_ctxts(struct hfi1_devdata *dd)
 {
-       unsigned i;
+       u16 i;
        int ret;
 
        /* Control context has to be always 0 */
@@ -233,7 +233,7 @@ void hfi1_rcd_get(struct hfi1_ctxtdata *rcd)
 /*
  * Common code for user and kernel context setup.
  */
-struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u32 ctxt,
+struct hfi1_ctxtdata *hfi1_create_ctxtdata(struct hfi1_pportdata *ppd, u16 ctxt,
                                           int numa)
 {
        struct hfi1_devdata *dd = ppd->dd;
@@ -615,7 +615,7 @@ static int init_after_reset(struct hfi1_devdata *dd)
 static void enable_chip(struct hfi1_devdata *dd)
 {
        u32 rcvmask;
-       u32 i;
+       u16 i;
 
        /* enable PIO send */
        pio_send_control(dd, PSC_GLOBAL_ENABLE);
@@ -692,7 +692,8 @@ static int create_workqueues(struct hfi1_devdata *dd)
 int hfi1_init(struct hfi1_devdata *dd, int reinit)
 {
        int ret = 0, pidx, lastfail = 0;
-       unsigned i, len;
+       unsigned long len;
+       u16 i;
        struct hfi1_ctxtdata *rcd;
        struct hfi1_pportdata *ppd;
 
index 84929578cfe62e8105d1762eebb2f48dc7f850e9..bebf0a8f214dc1bd79ac04ce80868088e7833318 100644 (file)
@@ -114,7 +114,7 @@ TRACE_EVENT(hfi1_rcvhdr,
 );
 
 TRACE_EVENT(hfi1_receive_interrupt,
-           TP_PROTO(struct hfi1_devdata *dd, u32 ctxt),
+           TP_PROTO(struct hfi1_devdata *dd, u16 ctxt),
            TP_ARGS(dd, ctxt),
            TP_STRUCT__entry(DD_DEV_ENTRY(dd)
                             __field(u32, ctxt)
index 161fdfddbb302ae09cd2a975fe08bf2413867cdc..73c2455189d3ce42ccc06868b1e4427fc4e13392 100644 (file)
@@ -56,7 +56,7 @@
 extern uint extended_psn;
 
 struct hfi1_user_sdma_pkt_q {
-       unsigned ctxt;
+       u16 ctxt;
        u16 subctxt;
        u16 n_max_reqs;
        atomic_t n_reqs;
index 5a3f80ba9752d7c4edf6ec943af413d97c310c8e..9bd274408f324ce3eb66a432ad43a8a79eb428ee 100644 (file)
@@ -106,7 +106,7 @@ static int allocate_vnic_ctxt(struct hfi1_devdata *dd,
                              struct hfi1_ctxtdata **vnic_ctxt)
 {
        struct hfi1_ctxtdata *uctxt;
-       unsigned int ctxt;
+       u16 ctxt;
        int ret;
 
        if (dd->flags & HFI1_FROZEN)