diff options
author | Mike Marciniszyn <mike.marciniszyn@qlogic.com> | 2011-09-23 13:16:39 -0400 |
---|---|---|
committer | Roland Dreier <roland@purestorage.com> | 2011-10-21 12:38:52 -0400 |
commit | 9e1c0e43257b6df1ef012dd37c3f0f93b1ee47af (patch) | |
tree | be40833860d385491b1ac8fa13dffe414954ee76 /drivers/infiniband | |
parent | cc6ea1385b43487f6ef03bdc91416c8366d28311 (diff) |
IB/qib: Eliminate divide/mod in converting idx to egr buf pointer
The context init now saves a shift from rcvegrbufs_perchunk
rcvegrbufs_perchunk_shift using ilog2. A BUG_ON() protects the
power of 2 assumption.
Signed-off-by: Mike Marciniszyn <mike.marciniszyn@qlogic.com>
Signed-off-by: Roland Dreier <roland@purestorage.com>
Diffstat (limited to 'drivers/infiniband')
-rw-r--r-- | drivers/infiniband/hw/qib/qib.h | 8 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_driver.c | 6 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_iba6120.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_iba7220.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_iba7322.c | 2 | ||||
-rw-r--r-- | drivers/infiniband/hw/qib/qib_init.c | 3 |
6 files changed, 18 insertions, 5 deletions
diff --git a/drivers/infiniband/hw/qib/qib.h b/drivers/infiniband/hw/qib/qib.h index ee993e725d38..97e623383e1a 100644 --- a/drivers/infiniband/hw/qib/qib.h +++ b/drivers/infiniband/hw/qib/qib.h | |||
@@ -171,7 +171,9 @@ struct qib_ctxtdata { | |||
171 | /* how many alloc_pages() chunks in rcvegrbuf_pages */ | 171 | /* how many alloc_pages() chunks in rcvegrbuf_pages */ |
172 | u32 rcvegrbuf_chunks; | 172 | u32 rcvegrbuf_chunks; |
173 | /* how many egrbufs per chunk */ | 173 | /* how many egrbufs per chunk */ |
174 | u32 rcvegrbufs_perchunk; | 174 | u16 rcvegrbufs_perchunk; |
175 | /* ilog2 of above */ | ||
176 | u16 rcvegrbufs_perchunk_shift; | ||
175 | /* order for rcvegrbuf_pages */ | 177 | /* order for rcvegrbuf_pages */ |
176 | size_t rcvegrbuf_size; | 178 | size_t rcvegrbuf_size; |
177 | /* rcvhdrq size (for freeing) */ | 179 | /* rcvhdrq size (for freeing) */ |
@@ -940,7 +942,9 @@ struct qib_devdata { | |||
940 | /* chip address space used by 4k pio buffers */ | 942 | /* chip address space used by 4k pio buffers */ |
941 | u32 align4k; | 943 | u32 align4k; |
942 | /* size of each rcvegrbuffer */ | 944 | /* size of each rcvegrbuffer */ |
943 | u32 rcvegrbufsize; | 945 | u16 rcvegrbufsize; |
946 | /* log2 of above */ | ||
947 | u16 rcvegrbufsize_shift; | ||
944 | /* localbus width (1, 2,4,8,16,32) from config space */ | 948 | /* localbus width (1, 2,4,8,16,32) from config space */ |
945 | u32 lbus_width; | 949 | u32 lbus_width; |
946 | /* localbus speed in MHz */ | 950 | /* localbus speed in MHz */ |
diff --git a/drivers/infiniband/hw/qib/qib_driver.c b/drivers/infiniband/hw/qib/qib_driver.c index 23e584f4c36c..89264ffc7ee9 100644 --- a/drivers/infiniband/hw/qib/qib_driver.c +++ b/drivers/infiniband/hw/qib/qib_driver.c | |||
@@ -279,10 +279,10 @@ bail: | |||
279 | */ | 279 | */ |
280 | static inline void *qib_get_egrbuf(const struct qib_ctxtdata *rcd, u32 etail) | 280 | static inline void *qib_get_egrbuf(const struct qib_ctxtdata *rcd, u32 etail) |
281 | { | 281 | { |
282 | const u32 chunk = etail / rcd->rcvegrbufs_perchunk; | 282 | const u32 chunk = etail >> rcd->rcvegrbufs_perchunk_shift; |
283 | const u32 idx = etail % rcd->rcvegrbufs_perchunk; | 283 | const u32 idx = etail & ((u32)rcd->rcvegrbufs_perchunk - 1); |
284 | 284 | ||
285 | return rcd->rcvegrbuf[chunk] + idx * rcd->dd->rcvegrbufsize; | 285 | return rcd->rcvegrbuf[chunk] + (idx << rcd->dd->rcvegrbufsize_shift); |
286 | } | 286 | } |
287 | 287 | ||
288 | /* | 288 | /* |
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c index d8ca0a0b970d..781a802a321f 100644 --- a/drivers/infiniband/hw/qib/qib_iba6120.c +++ b/drivers/infiniband/hw/qib/qib_iba6120.c | |||
@@ -3273,6 +3273,8 @@ static int init_6120_variables(struct qib_devdata *dd) | |||
3273 | /* we always allocate at least 2048 bytes for eager buffers */ | 3273 | /* we always allocate at least 2048 bytes for eager buffers */ |
3274 | ret = ib_mtu_enum_to_int(qib_ibmtu); | 3274 | ret = ib_mtu_enum_to_int(qib_ibmtu); |
3275 | dd->rcvegrbufsize = ret != -1 ? max(ret, 2048) : QIB_DEFAULT_MTU; | 3275 | dd->rcvegrbufsize = ret != -1 ? max(ret, 2048) : QIB_DEFAULT_MTU; |
3276 | BUG_ON(!is_power_of_2(dd->rcvegrbufsize)); | ||
3277 | dd->rcvegrbufsize_shift = ilog2(dd->rcvegrbufsize); | ||
3276 | 3278 | ||
3277 | qib_6120_tidtemplate(dd); | 3279 | qib_6120_tidtemplate(dd); |
3278 | 3280 | ||
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c index e1f947446c2a..3f1d562ba898 100644 --- a/drivers/infiniband/hw/qib/qib_iba7220.c +++ b/drivers/infiniband/hw/qib/qib_iba7220.c | |||
@@ -4085,6 +4085,8 @@ static int qib_init_7220_variables(struct qib_devdata *dd) | |||
4085 | /* we always allocate at least 2048 bytes for eager buffers */ | 4085 | /* we always allocate at least 2048 bytes for eager buffers */ |
4086 | ret = ib_mtu_enum_to_int(qib_ibmtu); | 4086 | ret = ib_mtu_enum_to_int(qib_ibmtu); |
4087 | dd->rcvegrbufsize = ret != -1 ? max(ret, 2048) : QIB_DEFAULT_MTU; | 4087 | dd->rcvegrbufsize = ret != -1 ? max(ret, 2048) : QIB_DEFAULT_MTU; |
4088 | BUG_ON(!is_power_of_2(dd->rcvegrbufsize)); | ||
4089 | dd->rcvegrbufsize_shift = ilog2(dd->rcvegrbufsize); | ||
4088 | 4090 | ||
4089 | qib_7220_tidtemplate(dd); | 4091 | qib_7220_tidtemplate(dd); |
4090 | 4092 | ||
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 5ea9ece23b33..f3f4b55262c2 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c | |||
@@ -6205,6 +6205,8 @@ static int qib_init_7322_variables(struct qib_devdata *dd) | |||
6205 | 6205 | ||
6206 | /* we always allocate at least 2048 bytes for eager buffers */ | 6206 | /* we always allocate at least 2048 bytes for eager buffers */ |
6207 | dd->rcvegrbufsize = max(mtu, 2048); | 6207 | dd->rcvegrbufsize = max(mtu, 2048); |
6208 | BUG_ON(!is_power_of_2(dd->rcvegrbufsize)); | ||
6209 | dd->rcvegrbufsize_shift = ilog2(dd->rcvegrbufsize); | ||
6208 | 6210 | ||
6209 | qib_7322_tidtemplate(dd); | 6211 | qib_7322_tidtemplate(dd); |
6210 | 6212 | ||
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 021636dbeae6..21ffa7c0915f 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c | |||
@@ -183,6 +183,9 @@ struct qib_ctxtdata *qib_create_ctxtdata(struct qib_pportdata *ppd, u32 ctxt) | |||
183 | rcd->rcvegrbuf_chunks = (rcd->rcvegrcnt + | 183 | rcd->rcvegrbuf_chunks = (rcd->rcvegrcnt + |
184 | rcd->rcvegrbufs_perchunk - 1) / | 184 | rcd->rcvegrbufs_perchunk - 1) / |
185 | rcd->rcvegrbufs_perchunk; | 185 | rcd->rcvegrbufs_perchunk; |
186 | BUG_ON(!is_power_of_2(rcd->rcvegrbufs_perchunk)); | ||
187 | rcd->rcvegrbufs_perchunk_shift = | ||
188 | ilog2(rcd->rcvegrbufs_perchunk); | ||
186 | } | 189 | } |
187 | return rcd; | 190 | return rcd; |
188 | } | 191 | } |