]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.42/ib-hfi1-fix-the-allocation-of-rsm-table.patch
Linux 4.19.42
[thirdparty/kernel/stable-queue.git] / releases / 4.19.42 / ib-hfi1-fix-the-allocation-of-rsm-table.patch
1 From cbca3091c6a0589acf261d3278364254d92af6fc Mon Sep 17 00:00:00 2001
2 From: Kaike Wan <kaike.wan@intel.com>
3 Date: Mon, 18 Mar 2019 09:55:49 -0700
4 Subject: IB/hfi1: Fix the allocation of RSM table
5
6 [ Upstream commit d0294344470e6b52d097aa7369173f32d11f2f52 ]
7
8 The receive side mapping (RSM) on hfi1 hardware is a special
9 matching mechanism to direct an incoming packet to a given
10 hardware receive context. It has 4 instances of matching capabilities
11 (RSM0 - RSM3) that share the same RSM table (RMT). The RMT has a total of
12 256 entries, each of which points to a receive context.
13
14 Currently, three instances of RSM have been used:
15 1. RSM0 by QOS;
16 2. RSM1 by PSM FECN;
17 3. RSM2 by VNIC.
18
19 Each RSM instance should reserve enough entries in RMT to function
20 properly. Since both PSM and VNIC could allocate any receive context
21 between dd->first_dyn_alloc_ctxt and dd->num_rcv_contexts, PSM FECN must
22 reserve enough RMT entries to cover the entire receive context index
23 range (dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt) instead of only
24 the user receive contexts allocated for PSM
25 (dd->num_user_contexts). Consequently, the sizing of
26 dd->num_user_contexts in set_up_context_variables is incorrect.
27
28 Fixes: 2280740f01ae ("IB/hfi1: Virtual Network Interface Controller (VNIC) HW support")
29 Reviewed-by: Mike Marciniszyn <mike.marciniszyn@intel.com>
30 Reviewed-by: Michael J. Ruhl <michael.j.ruhl@intel.com>
31 Signed-off-by: Kaike Wan <kaike.wan@intel.com>
32 Signed-off-by: Dennis Dalessandro <dennis.dalessandro@intel.com>
33 Signed-off-by: Jason Gunthorpe <jgg@mellanox.com>
34 Signed-off-by: Sasha Levin <sashal@kernel.org>
35 ---
36 drivers/infiniband/hw/hfi1/chip.c | 26 +++++++++++++++++++-------
37 1 file changed, 19 insertions(+), 7 deletions(-)
38
39 diff --git a/drivers/infiniband/hw/hfi1/chip.c b/drivers/infiniband/hw/hfi1/chip.c
40 index 902d12d6d88b0..b12c8ff8ed666 100644
41 --- a/drivers/infiniband/hw/hfi1/chip.c
42 +++ b/drivers/infiniband/hw/hfi1/chip.c
43 @@ -13388,7 +13388,7 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
44 int total_contexts;
45 int ret;
46 unsigned ngroups;
47 - int qos_rmt_count;
48 + int rmt_count;
49 int user_rmt_reduced;
50 u32 n_usr_ctxts;
51 u32 send_contexts = chip_send_contexts(dd);
52 @@ -13450,10 +13450,20 @@ static int set_up_context_variables(struct hfi1_devdata *dd)
53 n_usr_ctxts = rcv_contexts - total_contexts;
54 }
55
56 - /* each user context requires an entry in the RMT */
57 - qos_rmt_count = qos_rmt_entries(dd, NULL, NULL);
58 - if (qos_rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
59 - user_rmt_reduced = NUM_MAP_ENTRIES - qos_rmt_count;
60 + /*
61 + * The RMT entries are currently allocated as shown below:
62 + * 1. QOS (0 to 128 entries);
63 + * 2. FECN for PSM (num_user_contexts + num_vnic_contexts);
64 + * 3. VNIC (num_vnic_contexts).
65 + * It should be noted that PSM FECN oversubscribe num_vnic_contexts
66 + * entries of RMT because both VNIC and PSM could allocate any receive
67 + * context between dd->first_dyn_alloc_text and dd->num_rcv_contexts,
68 + * and PSM FECN must reserve an RMT entry for each possible PSM receive
69 + * context.
70 + */
71 + rmt_count = qos_rmt_entries(dd, NULL, NULL) + (num_vnic_contexts * 2);
72 + if (rmt_count + n_usr_ctxts > NUM_MAP_ENTRIES) {
73 + user_rmt_reduced = NUM_MAP_ENTRIES - rmt_count;
74 dd_dev_err(dd,
75 "RMT size is reducing the number of user receive contexts from %u to %d\n",
76 n_usr_ctxts,
77 @@ -14441,9 +14451,11 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
78 u64 reg;
79 int i, idx, regoff, regidx;
80 u8 offset;
81 + u32 total_cnt;
82
83 /* there needs to be enough room in the map table */
84 - if (rmt->used + dd->num_user_contexts >= NUM_MAP_ENTRIES) {
85 + total_cnt = dd->num_rcv_contexts - dd->first_dyn_alloc_ctxt;
86 + if (rmt->used + total_cnt >= NUM_MAP_ENTRIES) {
87 dd_dev_err(dd, "User FECN handling disabled - too many user contexts allocated\n");
88 return;
89 }
90 @@ -14497,7 +14509,7 @@ static void init_user_fecn_handling(struct hfi1_devdata *dd,
91 /* add rule 1 */
92 add_rsm_rule(dd, RSM_INS_FECN, &rrd);
93
94 - rmt->used += dd->num_user_contexts;
95 + rmt->used += total_cnt;
96 }
97
98 /* Initialize RSM for VNIC */
99 --
100 2.20.1
101