Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma

Pull rdma fixes from Doug Ledford:
"Second -rc update for 4.14.

Both Mellanox and Intel had a series of -rc fixes that landed this
week. The Mellanox bunch is spread throughout the stack and not just
in their driver, where as the Intel bunch was mostly in the hfi1
driver. And, several of the fixes in the hfi1 driver were more than
just simple 5 line fixes. As a result, the hfi1 driver fixes has a
sizable LOC count.

Everything else is as one would expect in an RC cycle in terms of LOC
count. One item that might jump out and make you think "That's not an
rc item" is the fix that corrects a typo. But, that change fixes a
typo in a user visible API that was just added in this merge window,
so if we fix it now, we can fix it. If we don't, the typo is in the
API forever. Another that might not appear to be a fix at first glance
is the Simplify mlx5_ib_cont_pages patch, but the simplification
allows them to fix a bug in the existing function whenever the length
of an SGE exceeded page size. We also had to revert one patch from the
merge window that was wrong.

Summary:

- a few core fixes
- a few ipoib fixes
- a few mlx5 fixes
- a 7-patch hfi1 related series"

* tag 'for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/dledford/rdma:
IB/hfi1: Unsuccessful PCIe caps tuning should not fail driver load
IB/hfi1: On error, fix use after free during user context setup
Revert "IB/ipoib: Update broadcast object if PKey value was changed in index 0"
IB/hfi1: Return correct value in general interrupt handler
IB/hfi1: Check eeprom config partition validity
IB/hfi1: Only reset QSFP after link up and turn off AOC TX
IB/hfi1: Turn off AOC TX after offline substates
IB/mlx5: Fix NULL deference on mlx5_ib_update_xlt failure
IB/mlx5: Simplify mlx5_ib_cont_pages
IB/ipoib: Fix inconsistency with free_netdev and free_rdma_netdev
IB/ipoib: Fix sysfs Pkey create<->remove possible deadlock
IB: Correct MR length field to be 64-bit
IB/core: Fix qp_sec use after free access
IB/core: Fix typo in the name of the tag-matching cap struct

+231 -164
+3 -1
drivers/infiniband/core/security.c
··· 432 432 atomic_set(&qp->qp_sec->error_list_count, 0); 433 433 init_completion(&qp->qp_sec->error_complete); 434 434 ret = security_ib_alloc_security(&qp->qp_sec->security); 435 - if (ret) 435 + if (ret) { 436 436 kfree(qp->qp_sec); 437 + qp->qp_sec = NULL; 438 + } 437 439 438 440 return ret; 439 441 }
+7 -7
drivers/infiniband/core/uverbs_cmd.c
··· 3869 3869 resp.raw_packet_caps = attr.raw_packet_caps; 3870 3870 resp.response_length += sizeof(resp.raw_packet_caps); 3871 3871 3872 - if (ucore->outlen < resp.response_length + sizeof(resp.xrq_caps)) 3872 + if (ucore->outlen < resp.response_length + sizeof(resp.tm_caps)) 3873 3873 goto end; 3874 3874 3875 - resp.xrq_caps.max_rndv_hdr_size = attr.xrq_caps.max_rndv_hdr_size; 3876 - resp.xrq_caps.max_num_tags = attr.xrq_caps.max_num_tags; 3877 - resp.xrq_caps.max_ops = attr.xrq_caps.max_ops; 3878 - resp.xrq_caps.max_sge = attr.xrq_caps.max_sge; 3879 - resp.xrq_caps.flags = attr.xrq_caps.flags; 3880 - resp.response_length += sizeof(resp.xrq_caps); 3875 + resp.tm_caps.max_rndv_hdr_size = attr.tm_caps.max_rndv_hdr_size; 3876 + resp.tm_caps.max_num_tags = attr.tm_caps.max_num_tags; 3877 + resp.tm_caps.max_ops = attr.tm_caps.max_ops; 3878 + resp.tm_caps.max_sge = attr.tm_caps.max_sge; 3879 + resp.tm_caps.flags = attr.tm_caps.flags; 3880 + resp.response_length += sizeof(resp.tm_caps); 3881 3881 end: 3882 3882 err = ib_copy_to_udata(ucore, &resp, resp.response_length); 3883 3883 return err;
+78 -23
drivers/infiniband/hw/hfi1/chip.c
··· 1066 1066 static int thermal_init(struct hfi1_devdata *dd); 1067 1067 1068 1068 static void update_statusp(struct hfi1_pportdata *ppd, u32 state); 1069 + static int wait_phys_link_offline_substates(struct hfi1_pportdata *ppd, 1070 + int msecs); 1069 1071 static int wait_logical_linkstate(struct hfi1_pportdata *ppd, u32 state, 1070 1072 int msecs); 1071 1073 static void log_state_transition(struct hfi1_pportdata *ppd, u32 state); ··· 8240 8238 u64 regs[CCE_NUM_INT_CSRS]; 8241 8239 u32 bit; 8242 8240 int i; 8241 + irqreturn_t handled = IRQ_NONE; 8243 8242 8244 8243 this_cpu_inc(*dd->int_counter); 8245 8244 ··· 8261 8258 for_each_set_bit(bit, (unsigned long *)&regs[0], 8262 8259 CCE_NUM_INT_CSRS * 64) { 8263 8260 is_interrupt(dd, bit); 8261 + handled = IRQ_HANDLED; 8264 8262 } 8265 8263 8266 - return IRQ_HANDLED; 8264 + return handled; 8267 8265 } 8268 8266 8269 8267 static irqreturn_t sdma_interrupt(int irq, void *data) ··· 9417 9413 write_csr(dd, dd->hfi1_id ? ASIC_QSFP2_MASK : ASIC_QSFP1_MASK, mask); 9418 9414 } 9419 9415 9420 - void reset_qsfp(struct hfi1_pportdata *ppd) 9416 + int reset_qsfp(struct hfi1_pportdata *ppd) 9421 9417 { 9422 9418 struct hfi1_devdata *dd = ppd->dd; 9423 9419 u64 mask, qsfp_mask; ··· 9447 9443 * for alarms and warnings 9448 9444 */ 9449 9445 set_qsfp_int_n(ppd, 1); 9446 + 9447 + /* 9448 + * After the reset, AOC transmitters are enabled by default. They need 9449 + * to be turned off to complete the QSFP setup before they can be 9450 + * enabled again. 9451 + */ 9452 + return set_qsfp_tx(ppd, 0); 9450 9453 } 9451 9454 9452 9455 static int handle_qsfp_error_conditions(struct hfi1_pportdata *ppd, ··· 10316 10305 { 10317 10306 struct hfi1_devdata *dd = ppd->dd; 10318 10307 u32 previous_state; 10308 + int offline_state_ret; 10319 10309 int ret; 10320 10310 10321 10311 update_lcb_cache(dd); ··· 10338 10326 ppd->offline_disabled_reason = 10339 10327 HFI1_ODR_MASK(OPA_LINKDOWN_REASON_TRANSIENT); 10340 10328 10341 - /* 10342 - * Wait for offline transition. It can take a while for 10343 - * the link to go down. 10344 - */ 10345 - ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 10000); 10346 - if (ret < 0) 10347 - return ret; 10329 + offline_state_ret = wait_phys_link_offline_substates(ppd, 10000); 10330 + if (offline_state_ret < 0) 10331 + return offline_state_ret; 10348 10332 10349 - /* 10350 - * Now in charge of LCB - must be after the physical state is 10351 - * offline.quiet and before host_link_state is changed. 10352 - */ 10353 - set_host_lcb_access(dd); 10354 - write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */ 10355 - 10356 - /* make sure the logical state is also down */ 10357 - ret = wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000); 10358 - if (ret) 10359 - force_logical_link_state_down(ppd); 10360 - 10361 - ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */ 10362 - 10333 + /* Disabling AOC transmitters */ 10363 10334 if (ppd->port_type == PORT_TYPE_QSFP && 10364 10335 ppd->qsfp_info.limiting_active && 10365 10336 qsfp_mod_present(ppd)) { ··· 10358 10363 "Unable to acquire lock to turn off QSFP TX\n"); 10359 10364 } 10360 10365 } 10366 + 10367 + /* 10368 + * Wait for the offline.Quiet transition if it hasn't happened yet. It 10369 + * can take a while for the link to go down. 10370 + */ 10371 + if (offline_state_ret != PLS_OFFLINE_QUIET) { 10372 + ret = wait_physical_linkstate(ppd, PLS_OFFLINE, 30000); 10373 + if (ret < 0) 10374 + return ret; 10375 + } 10376 + 10377 + /* 10378 + * Now in charge of LCB - must be after the physical state is 10379 + * offline.quiet and before host_link_state is changed. 10380 + */ 10381 + set_host_lcb_access(dd); 10382 + write_csr(dd, DC_LCB_ERR_EN, ~0ull); /* watch LCB errors */ 10383 + 10384 + /* make sure the logical state is also down */ 10385 + ret = wait_logical_linkstate(ppd, IB_PORT_DOWN, 1000); 10386 + if (ret) 10387 + force_logical_link_state_down(ppd); 10388 + 10389 + ppd->host_link_state = HLS_LINK_COOLDOWN; /* LCB access allowed */ 10361 10390 10362 10391 /* 10363 10392 * The LNI has a mandatory wait time after the physical state ··· 10415 10396 & (HLS_DN_POLL | HLS_VERIFY_CAP | HLS_GOING_UP)) { 10416 10397 /* went down while attempting link up */ 10417 10398 check_lni_states(ppd); 10399 + 10400 + /* The QSFP doesn't need to be reset on LNI failure */ 10401 + ppd->qsfp_info.reset_needed = 0; 10418 10402 } 10419 10403 10420 10404 /* the active link width (downgrade) is 0 on link down */ ··· 12824 12802 12825 12803 log_state_transition(ppd, state); 12826 12804 return 0; 12805 + } 12806 + 12807 + /* 12808 + * wait_phys_link_offline_quiet_substates - wait for any offline substate 12809 + * @ppd: port device 12810 + * @msecs: the number of milliseconds to wait 12811 + * 12812 + * Wait up to msecs milliseconds for any offline physical link 12813 + * state change to occur. 12814 + * Returns 0 if at least one state is reached, otherwise -ETIMEDOUT. 12815 + */ 12816 + static int wait_phys_link_offline_substates(struct hfi1_pportdata *ppd, 12817 + int msecs) 12818 + { 12819 + u32 read_state; 12820 + unsigned long timeout; 12821 + 12822 + timeout = jiffies + msecs_to_jiffies(msecs); 12823 + while (1) { 12824 + read_state = read_physical_state(ppd->dd); 12825 + if ((read_state & 0xF0) == PLS_OFFLINE) 12826 + break; 12827 + if (time_after(jiffies, timeout)) { 12828 + dd_dev_err(ppd->dd, 12829 + "timeout waiting for phy link offline.quiet substates. Read state 0x%x, %dms\n", 12830 + read_state, msecs); 12831 + return -ETIMEDOUT; 12832 + } 12833 + usleep_range(1950, 2050); /* sleep 2ms-ish */ 12834 + } 12835 + 12836 + log_state_transition(ppd, read_state); 12837 + return read_state; 12827 12838 } 12828 12839 12829 12840 #define CLEAR_STATIC_RATE_CONTROL_SMASK(r) \
+2 -1
drivers/infiniband/hw/hfi1/chip.h
··· 204 204 #define PLS_OFFLINE_READY_TO_QUIET_LT 0x92 205 205 #define PLS_OFFLINE_REPORT_FAILURE 0x93 206 206 #define PLS_OFFLINE_READY_TO_QUIET_BCC 0x94 207 + #define PLS_OFFLINE_QUIET_DURATION 0x95 207 208 #define PLS_POLLING 0x20 208 209 #define PLS_POLLING_QUIET 0x20 209 210 #define PLS_POLLING_ACTIVE 0x21 ··· 723 722 void handle_link_bounce(struct work_struct *work); 724 723 void handle_start_link(struct work_struct *work); 725 724 void handle_sma_message(struct work_struct *work); 726 - void reset_qsfp(struct hfi1_pportdata *ppd); 725 + int reset_qsfp(struct hfi1_pportdata *ppd); 727 726 void qsfp_event(struct work_struct *work); 728 727 void start_freeze_handling(struct hfi1_pportdata *ppd, int flags); 729 728 int send_idle_sma(struct hfi1_devdata *dd, u64 message);
+15 -5
drivers/infiniband/hw/hfi1/eprom.c
··· 204 204 return ret; 205 205 } 206 206 207 - /* magic character sequence that trails an image */ 207 + /* magic character sequence that begins an image */ 208 + #define IMAGE_START_MAGIC "APO=" 209 + 210 + /* magic character sequence that might trail an image */ 208 211 #define IMAGE_TRAIL_MAGIC "egamiAPO" 209 212 210 213 /* EPROM file types */ ··· 253 250 { 254 251 void *buffer; 255 252 void *p; 253 + u32 length; 256 254 int ret; 257 255 258 256 buffer = kmalloc(P1_SIZE, GFP_KERNEL); ··· 266 262 return ret; 267 263 } 268 264 269 - /* scan for image magic that may trail the actual data */ 270 - p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE); 271 - if (!p) { 265 + /* config partition is valid only if it starts with IMAGE_START_MAGIC */ 266 + if (memcmp(buffer, IMAGE_START_MAGIC, strlen(IMAGE_START_MAGIC))) { 272 267 kfree(buffer); 273 268 return -ENOENT; 274 269 } 275 270 271 + /* scan for image magic that may trail the actual data */ 272 + p = strnstr(buffer, IMAGE_TRAIL_MAGIC, P1_SIZE); 273 + if (p) 274 + length = p - buffer; 275 + else 276 + length = P1_SIZE; 277 + 276 278 *data = buffer; 277 - *size = p - buffer; 279 + *size = length; 278 280 return 0; 279 281 } 280 282
+22 -19
drivers/infiniband/hw/hfi1/file_ops.c
··· 930 930 switch (ret) { 931 931 case 0: 932 932 ret = setup_base_ctxt(fd, uctxt); 933 - if (uctxt->subctxt_cnt) { 934 - /* 935 - * Base context is done (successfully or not), notify 936 - * anybody using a sub-context that is waiting for 937 - * this completion. 938 - */ 939 - clear_bit(HFI1_CTXT_BASE_UNINIT, &uctxt->event_flags); 940 - wake_up(&uctxt->wait); 941 - } 933 + if (ret) 934 + deallocate_ctxt(uctxt); 942 935 break; 943 936 case 1: 944 937 ret = complete_subctxt(fd); ··· 1298 1305 /* Now allocate the RcvHdr queue and eager buffers. */ 1299 1306 ret = hfi1_create_rcvhdrq(dd, uctxt); 1300 1307 if (ret) 1301 - return ret; 1308 + goto done; 1302 1309 1303 1310 ret = hfi1_setup_eagerbufs(uctxt); 1304 1311 if (ret) 1305 - goto setup_failed; 1312 + goto done; 1306 1313 1307 1314 /* If sub-contexts are enabled, do the appropriate setup */ 1308 1315 if (uctxt->subctxt_cnt) 1309 1316 ret = setup_subctxt(uctxt); 1310 1317 if (ret) 1311 - goto setup_failed; 1318 + goto done; 1312 1319 1313 1320 ret = hfi1_alloc_ctxt_rcv_groups(uctxt); 1314 1321 if (ret) 1315 - goto setup_failed; 1322 + goto done; 1316 1323 1317 1324 ret = init_user_ctxt(fd, uctxt); 1318 1325 if (ret) 1319 - goto setup_failed; 1326 + goto done; 1320 1327 1321 1328 user_init(uctxt); 1322 1329 ··· 1324 1331 fd->uctxt = uctxt; 1325 1332 hfi1_rcd_get(uctxt); 1326 1333 1327 - return 0; 1334 + done: 1335 + if (uctxt->subctxt_cnt) { 1336 + /* 1337 + * On error, set the failed bit so sub-contexts will clean up 1338 + * correctly. 1339 + */ 1340 + if (ret) 1341 + set_bit(HFI1_CTXT_BASE_FAILED, &uctxt->event_flags); 1328 1342 1329 - setup_failed: 1330 - /* Set the failed bit so sub-context init can do the right thing */ 1331 - set_bit(HFI1_CTXT_BASE_FAILED, &uctxt->event_flags); 1332 - deallocate_ctxt(uctxt); 1343 + /* 1344 + * Base context is done (successfully or not), notify anybody 1345 + * using a sub-context that is waiting for this completion. 1346 + */ 1347 + clear_bit(HFI1_CTXT_BASE_UNINIT, &uctxt->event_flags); 1348 + wake_up(&uctxt->wait); 1349 + } 1333 1350 1334 1351 return ret; 1335 1352 }
+21 -29
drivers/infiniband/hw/hfi1/pcie.c
··· 68 68 /* 69 69 * Code to adjust PCIe capabilities. 70 70 */ 71 - static int tune_pcie_caps(struct hfi1_devdata *); 71 + static void tune_pcie_caps(struct hfi1_devdata *); 72 72 73 73 /* 74 74 * Do all the common PCIe setup and initialization. ··· 351 351 */ 352 352 int request_msix(struct hfi1_devdata *dd, u32 msireq) 353 353 { 354 - int nvec, ret; 354 + int nvec; 355 355 356 356 nvec = pci_alloc_irq_vectors(dd->pcidev, 1, msireq, 357 357 PCI_IRQ_MSIX | PCI_IRQ_LEGACY); ··· 360 360 return nvec; 361 361 } 362 362 363 - ret = tune_pcie_caps(dd); 364 - if (ret) { 365 - dd_dev_err(dd, "tune_pcie_caps() failed: %d\n", ret); 366 - pci_free_irq_vectors(dd->pcidev); 367 - return ret; 368 - } 363 + tune_pcie_caps(dd); 369 364 370 365 /* check for legacy IRQ */ 371 366 if (nvec == 1 && !dd->pcidev->msix_enabled) ··· 497 502 module_param_named(aspm, aspm_mode, uint, S_IRUGO); 498 503 MODULE_PARM_DESC(aspm, "PCIe ASPM: 0: disable, 1: enable, 2: dynamic"); 499 504 500 - static int tune_pcie_caps(struct hfi1_devdata *dd) 505 + static void tune_pcie_caps(struct hfi1_devdata *dd) 501 506 { 502 507 struct pci_dev *parent; 503 508 u16 rc_mpss, rc_mps, ep_mpss, ep_mps; ··· 508 513 * Turn on extended tags in DevCtl in case the BIOS has turned it off 509 514 * to improve WFR SDMA bandwidth 510 515 */ 511 - ret = pcie_capability_read_word(dd->pcidev, 512 - PCI_EXP_DEVCTL, &ectl); 513 - if (ret) { 514 - dd_dev_err(dd, "Unable to read from PCI config\n"); 515 - return ret; 516 - } 517 - 518 - if (!(ectl & PCI_EXP_DEVCTL_EXT_TAG)) { 516 + ret = pcie_capability_read_word(dd->pcidev, PCI_EXP_DEVCTL, &ectl); 517 + if ((!ret) && !(ectl & PCI_EXP_DEVCTL_EXT_TAG)) { 519 518 dd_dev_info(dd, "Enabling PCIe extended tags\n"); 520 519 ectl |= PCI_EXP_DEVCTL_EXT_TAG; 521 520 ret = pcie_capability_write_word(dd->pcidev, 522 521 PCI_EXP_DEVCTL, ectl); 523 - if (ret) { 524 - dd_dev_err(dd, "Unable to write to PCI config\n"); 525 - return ret; 526 - } 522 + if (ret) 523 + dd_dev_info(dd, "Unable to write to PCI config\n"); 527 524 } 528 525 /* Find out supported and configured values for parent (root) */ 529 526 parent = dd->pcidev->bus->self; ··· 523 536 * The driver cannot perform the tuning if it does not have 524 537 * access to the upstream component. 525 538 */ 526 - if (!parent) 527 - return -EINVAL; 539 + if (!parent) { 540 + dd_dev_info(dd, "Parent not found\n"); 541 + return; 542 + } 528 543 if (!pci_is_root_bus(parent->bus)) { 529 544 dd_dev_info(dd, "Parent not root\n"); 530 - return -EINVAL; 545 + return; 531 546 } 532 - 533 - if (!pci_is_pcie(parent) || !pci_is_pcie(dd->pcidev)) 534 - return -EINVAL; 547 + if (!pci_is_pcie(parent)) { 548 + dd_dev_info(dd, "Parent is not PCI Express capable\n"); 549 + return; 550 + } 551 + if (!pci_is_pcie(dd->pcidev)) { 552 + dd_dev_info(dd, "PCI device is not PCI Express capable\n"); 553 + return; 554 + } 535 555 rc_mpss = parent->pcie_mpss; 536 556 rc_mps = ffs(pcie_get_mps(parent)) - 8; 537 557 /* Find out supported and configured values for endpoint (us) */ ··· 584 590 ep_mrrs = max_mrrs; 585 591 pcie_set_readrq(dd->pcidev, ep_mrrs); 586 592 } 587 - 588 - return 0; 589 593 } 590 594 591 595 /* End of PCIe capability tuning */
+3 -1
drivers/infiniband/hw/hfi1/platform.c
··· 790 790 * reuse of stale settings established in our previous pass through. 791 791 */ 792 792 if (ppd->qsfp_info.reset_needed) { 793 - reset_qsfp(ppd); 793 + ret = reset_qsfp(ppd); 794 + if (ret) 795 + return ret; 794 796 refresh_qsfp_cache(ppd, &ppd->qsfp_info); 795 797 } else { 796 798 ppd->qsfp_info.reset_needed = 1;
+5 -5
drivers/infiniband/hw/mlx5/main.c
··· 778 778 } 779 779 780 780 if (MLX5_CAP_GEN(mdev, tag_matching)) { 781 - props->xrq_caps.max_rndv_hdr_size = MLX5_TM_MAX_RNDV_MSG_SIZE; 782 - props->xrq_caps.max_num_tags = 781 + props->tm_caps.max_rndv_hdr_size = MLX5_TM_MAX_RNDV_MSG_SIZE; 782 + props->tm_caps.max_num_tags = 783 783 (1 << MLX5_CAP_GEN(mdev, log_tag_matching_list_sz)) - 1; 784 - props->xrq_caps.flags = IB_TM_CAP_RC; 785 - props->xrq_caps.max_ops = 784 + props->tm_caps.flags = IB_TM_CAP_RC; 785 + props->tm_caps.max_ops = 786 786 1 << MLX5_CAP_GEN(mdev, log_max_qp_sz); 787 - props->xrq_caps.max_sge = MLX5_TM_MAX_SGE; 787 + props->tm_caps.max_sge = MLX5_TM_MAX_SGE; 788 788 } 789 789 790 790 if (field_avail(typeof(resp), cqe_comp_caps, uhw->outlen)) {
+17 -30
drivers/infiniband/hw/mlx5/mem.c
··· 50 50 { 51 51 unsigned long tmp; 52 52 unsigned long m; 53 - int i, k; 54 - u64 base = 0; 55 - int p = 0; 56 - int skip; 57 - int mask; 58 - u64 len; 59 - u64 pfn; 53 + u64 base = ~0, p = 0; 54 + u64 len, pfn; 55 + int i = 0; 60 56 struct scatterlist *sg; 61 57 int entry; 62 58 unsigned long page_shift = umem->page_shift; ··· 72 76 m = find_first_bit(&tmp, BITS_PER_LONG); 73 77 if (max_page_shift) 74 78 m = min_t(unsigned long, max_page_shift - page_shift, m); 75 - skip = 1 << m; 76 - mask = skip - 1; 77 - i = 0; 79 + 78 80 for_each_sg(umem->sg_head.sgl, sg, umem->nmap, entry) { 79 81 len = sg_dma_len(sg) >> page_shift; 80 82 pfn = sg_dma_address(sg) >> page_shift; 81 - for (k = 0; k < len; k++) { 82 - if (!(i & mask)) { 83 - tmp = (unsigned long)pfn; 84 - m = min_t(unsigned long, m, find_first_bit(&tmp, BITS_PER_LONG)); 85 - skip = 1 << m; 86 - mask = skip - 1; 87 - base = pfn; 88 - p = 0; 89 - } else { 90 - if (base + p != pfn) { 91 - tmp = (unsigned long)p; 92 - m = find_first_bit(&tmp, BITS_PER_LONG); 93 - skip = 1 << m; 94 - mask = skip - 1; 95 - base = pfn; 96 - p = 0; 97 - } 98 - } 99 - p++; 100 - i++; 83 + if (base + p != pfn) { 84 + /* If either the offset or the new 85 + * base are unaligned update m 86 + */ 87 + tmp = (unsigned long)(pfn | p); 88 + if (!IS_ALIGNED(tmp, 1 << m)) 89 + m = find_first_bit(&tmp, BITS_PER_LONG); 90 + 91 + base = pfn; 92 + p = 0; 101 93 } 94 + 95 + p += len; 96 + i += len; 102 97 } 103 98 104 99 if (i) {
+17 -10
drivers/infiniband/hw/mlx5/mr.c
··· 47 47 48 48 #define MLX5_UMR_ALIGN 2048 49 49 50 - static int clean_mr(struct mlx5_ib_mr *mr); 50 + static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr); 51 + static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr); 51 52 static int mr_cache_max_order(struct mlx5_ib_dev *dev); 52 53 static int unreg_umr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr); 53 54 ··· 1271 1270 1272 1271 err = mlx5_ib_update_xlt(mr, 0, ncont, page_shift, 1273 1272 update_xlt_flags); 1273 + 1274 1274 if (err) { 1275 - mlx5_ib_dereg_mr(&mr->ibmr); 1275 + dereg_mr(dev, mr); 1276 1276 return ERR_PTR(err); 1277 1277 } 1278 1278 } ··· 1358 1356 err = mr_umem_get(pd, addr, len, access_flags, &mr->umem, 1359 1357 &npages, &page_shift, &ncont, &order); 1360 1358 if (err < 0) { 1361 - clean_mr(mr); 1359 + clean_mr(dev, mr); 1362 1360 return err; 1363 1361 } 1364 1362 } ··· 1412 1410 if (err) { 1413 1411 mlx5_ib_warn(dev, "Failed to rereg UMR\n"); 1414 1412 ib_umem_release(mr->umem); 1415 - clean_mr(mr); 1413 + clean_mr(dev, mr); 1416 1414 return err; 1417 1415 } 1418 1416 } ··· 1471 1469 } 1472 1470 } 1473 1471 1474 - static int clean_mr(struct mlx5_ib_mr *mr) 1472 + static int clean_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) 1475 1473 { 1476 - struct mlx5_ib_dev *dev = to_mdev(mr->ibmr.device); 1477 1474 int allocated_from_cache = mr->allocated_from_cache; 1478 1475 int err; 1479 1476 ··· 1508 1507 return 0; 1509 1508 } 1510 1509 1511 - int mlx5_ib_dereg_mr(struct ib_mr *ibmr) 1510 + static int dereg_mr(struct mlx5_ib_dev *dev, struct mlx5_ib_mr *mr) 1512 1511 { 1513 - struct mlx5_ib_dev *dev = to_mdev(ibmr->device); 1514 - struct mlx5_ib_mr *mr = to_mmr(ibmr); 1515 1512 int npages = mr->npages; 1516 1513 struct ib_umem *umem = mr->umem; 1517 1514 ··· 1538 1539 } 1539 1540 #endif 1540 1541 1541 - clean_mr(mr); 1542 + clean_mr(dev, mr); 1542 1543 1543 1544 if (umem) { 1544 1545 ib_umem_release(umem); ··· 1546 1547 } 1547 1548 1548 1549 return 0; 1550 + } 1551 + 1552 + int mlx5_ib_dereg_mr(struct ib_mr *ibmr) 1553 + { 1554 + struct mlx5_ib_dev *dev = to_mdev(ibmr->device); 1555 + struct mlx5_ib_mr *mr = to_mmr(ibmr); 1556 + 1557 + return dereg_mr(dev, mr); 1549 1558 } 1550 1559 1551 1560 struct ib_mr *mlx5_ib_alloc_mr(struct ib_pd *pd,
+2 -2
drivers/infiniband/hw/nes/nes_verbs.c
··· 3232 3232 mr->ibmr.iova); 3233 3233 set_wqe_32bit_value(wqe->wqe_words, 3234 3234 NES_IWARP_SQ_FMR_WQE_LENGTH_LOW_IDX, 3235 - mr->ibmr.length); 3235 + lower_32_bits(mr->ibmr.length)); 3236 3236 set_wqe_32bit_value(wqe->wqe_words, 3237 3237 NES_IWARP_SQ_FMR_WQE_LENGTH_HIGH_IDX, 0); 3238 3238 set_wqe_32bit_value(wqe->wqe_words, ··· 3274 3274 mr->npages * 8); 3275 3275 3276 3276 nes_debug(NES_DBG_IW_TX, "SQ_REG_MR: iova_start: %llx, " 3277 - "length: %d, rkey: %0x, pgl_paddr: %llx, " 3277 + "length: %lld, rkey: %0x, pgl_paddr: %llx, " 3278 3278 "page_list_len: %u, wqe_misc: %x\n", 3279 3279 (unsigned long long) mr->ibmr.iova, 3280 3280 mr->ibmr.length,
-13
drivers/infiniband/ulp/ipoib/ipoib_ib.c
··· 1000 1000 */ 1001 1001 priv->dev->broadcast[8] = priv->pkey >> 8; 1002 1002 priv->dev->broadcast[9] = priv->pkey & 0xff; 1003 - 1004 - /* 1005 - * Update the broadcast address in the priv->broadcast object, 1006 - * in case it already exists, otherwise no one will do that. 1007 - */ 1008 - if (priv->broadcast) { 1009 - spin_lock_irq(&priv->lock); 1010 - memcpy(priv->broadcast->mcmember.mgid.raw, 1011 - priv->dev->broadcast + 4, 1012 - sizeof(union ib_gid)); 1013 - spin_unlock_irq(&priv->lock); 1014 - } 1015 - 1016 1003 return 0; 1017 1004 } 1018 1005
+11 -4
drivers/infiniband/ulp/ipoib/ipoib_main.c
··· 2180 2180 { 2181 2181 struct ipoib_dev_priv *priv; 2182 2182 struct ib_port_attr attr; 2183 + struct rdma_netdev *rn; 2183 2184 int result = -ENOMEM; 2184 2185 2185 2186 priv = ipoib_intf_alloc(hca, port, format); ··· 2280 2279 ipoib_dev_cleanup(priv->dev); 2281 2280 2282 2281 device_init_failed: 2283 - free_netdev(priv->dev); 2282 + rn = netdev_priv(priv->dev); 2283 + rn->free_rdma_netdev(priv->dev); 2284 2284 kfree(priv); 2285 2285 2286 2286 alloc_mem_failed: ··· 2330 2328 return; 2331 2329 2332 2330 list_for_each_entry_safe(priv, tmp, dev_list, list) { 2333 - struct rdma_netdev *rn = netdev_priv(priv->dev); 2331 + struct rdma_netdev *parent_rn = netdev_priv(priv->dev); 2334 2332 2335 2333 ib_unregister_event_handler(&priv->event_handler); 2336 2334 flush_workqueue(ipoib_workqueue); ··· 2352 2350 unregister_netdev(priv->dev); 2353 2351 mutex_unlock(&priv->sysfs_mutex); 2354 2352 2355 - rn->free_rdma_netdev(priv->dev); 2353 + parent_rn->free_rdma_netdev(priv->dev); 2356 2354 2357 - list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) 2355 + list_for_each_entry_safe(cpriv, tcpriv, &priv->child_intfs, list) { 2356 + struct rdma_netdev *child_rn; 2357 + 2358 + child_rn = netdev_priv(cpriv->dev); 2359 + child_rn->free_rdma_netdev(cpriv->dev); 2358 2360 kfree(cpriv); 2361 + } 2359 2362 2360 2363 kfree(priv); 2361 2364 }
+22 -8
drivers/infiniband/ulp/ipoib/ipoib_vlan.c
··· 141 141 return restart_syscall(); 142 142 } 143 143 144 - priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name); 145 - if (!priv) { 144 + if (!down_write_trylock(&ppriv->vlan_rwsem)) { 146 145 rtnl_unlock(); 147 146 mutex_unlock(&ppriv->sysfs_mutex); 148 - return -ENOMEM; 147 + return restart_syscall(); 149 148 } 150 149 151 - down_write(&ppriv->vlan_rwsem); 150 + priv = ipoib_intf_alloc(ppriv->ca, ppriv->port, intf_name); 151 + if (!priv) { 152 + result = -ENOMEM; 153 + goto out; 154 + } 152 155 153 156 /* 154 157 * First ensure this isn't a duplicate. We check the parent device and ··· 178 175 rtnl_unlock(); 179 176 mutex_unlock(&ppriv->sysfs_mutex); 180 177 181 - if (result) { 182 - free_netdev(priv->dev); 178 + if (result && priv) { 179 + struct rdma_netdev *rn; 180 + 181 + rn = netdev_priv(priv->dev); 182 + rn->free_rdma_netdev(priv->dev); 183 183 kfree(priv); 184 184 } 185 185 ··· 210 204 return restart_syscall(); 211 205 } 212 206 213 - down_write(&ppriv->vlan_rwsem); 207 + if (!down_write_trylock(&ppriv->vlan_rwsem)) { 208 + rtnl_unlock(); 209 + mutex_unlock(&ppriv->sysfs_mutex); 210 + return restart_syscall(); 211 + } 212 + 214 213 list_for_each_entry_safe(priv, tpriv, &ppriv->child_intfs, list) { 215 214 if (priv->pkey == pkey && 216 215 priv->child_type == IPOIB_LEGACY_CHILD) { ··· 235 224 mutex_unlock(&ppriv->sysfs_mutex); 236 225 237 226 if (dev) { 238 - free_netdev(dev); 227 + struct rdma_netdev *rn; 228 + 229 + rn = netdev_priv(dev); 230 + rn->free_rdma_netdev(priv->dev); 239 231 kfree(priv); 240 232 return 0; 241 233 }
+1 -1
drivers/infiniband/ulp/iser/iser_memory.c
··· 154 154 { 155 155 int i; 156 156 157 - iser_err("page vec npages %d data length %d\n", 157 + iser_err("page vec npages %d data length %lld\n", 158 158 page_vec->npages, page_vec->fake_mr.length); 159 159 for (i = 0; i < page_vec->npages; i++) 160 160 iser_err("vec[%d]: %llx\n", i, page_vec->pages[i]);
+3 -3
include/rdma/ib_verbs.h
··· 285 285 IB_TM_CAP_RC = 1 << 0, 286 286 }; 287 287 288 - struct ib_xrq_caps { 288 + struct ib_tm_caps { 289 289 /* Max size of RNDV header */ 290 290 u32 max_rndv_hdr_size; 291 291 /* Max number of entries in tag matching list */ ··· 358 358 struct ib_rss_caps rss_caps; 359 359 u32 max_wq_type_rq; 360 360 u32 raw_packet_caps; /* Use ib_raw_packet_caps enum */ 361 - struct ib_xrq_caps xrq_caps; 361 + struct ib_tm_caps tm_caps; 362 362 }; 363 363 364 364 enum ib_mtu { ··· 1739 1739 u32 lkey; 1740 1740 u32 rkey; 1741 1741 u64 iova; 1742 - u32 length; 1742 + u64 length; 1743 1743 unsigned int page_size; 1744 1744 bool need_inval; 1745 1745 union {
+1 -1
include/uapi/rdma/ib_user_verbs.h
··· 261 261 struct ib_uverbs_rss_caps rss_caps; 262 262 __u32 max_wq_type_rq; 263 263 __u32 raw_packet_caps; 264 - struct ib_uverbs_tm_caps xrq_caps; 264 + struct ib_uverbs_tm_caps tm_caps; 265 265 }; 266 266 267 267 struct ib_uverbs_query_port {
+1 -1
net/sunrpc/xprtrdma/frwr_ops.c
··· 401 401 if (unlikely(n != mw->mw_nents)) 402 402 goto out_mapmr_err; 403 403 404 - dprintk("RPC: %s: Using frmr %p to map %u segments (%u bytes)\n", 404 + dprintk("RPC: %s: Using frmr %p to map %u segments (%llu bytes)\n", 405 405 __func__, frmr, mw->mw_nents, mr->length); 406 406 407 407 key = (u8)(mr->rkey & 0x000000FF);