Print this page
8368 remove warlock leftovers from usr/src/uts

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/ib/adapters/tavor/tavor_mr.c
          +++ new/usr/src/uts/common/io/ib/adapters/tavor/tavor_mr.c
↓ open down ↓ 231 lines elided ↑ open up ↑
 232  232           * must undo the protection domain reference count and the previous
 233  233           * resource allocation.
 234  234           */
 235  235          status = tavor_rsrc_alloc(state, TAVOR_MRHDL, 1, sleep, &rsrc);
 236  236          if (status != DDI_SUCCESS) {
 237  237                  /* Set "status" and "errormsg" and goto failure */
 238  238                  TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed MR handle");
 239  239                  goto mrshared_fail2;
 240  240          }
 241  241          mr = (tavor_mrhdl_t)rsrc->tr_addr;
 242      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr))
 243  242  
 244  243          /*
 245  244           * Setup and validate the memory region access flags.  This means
 246  245           * translating the IBTF's enable flags into the access flags that
 247  246           * will be used in later operations.
 248  247           */
 249  248          mr->mr_accflag = 0;
 250  249          if (mr_attr->mr_flags & IBT_MR_ENABLE_WINDOW_BIND)
 251  250                  mr->mr_accflag |= IBT_MR_WINDOW_BIND;
 252  251          if (mr_attr->mr_flags & IBT_MR_ENABLE_LOCAL_WRITE)
↓ open down ↓ 81 lines elided ↑ open up ↑
 334  333           * matter here of managing the MTT reference count and grabbing the
 335  334           * address of the MTT table entries (for filling in the shared region's
 336  335           * MPT entry).
 337  336           */
 338  337          mr->mr_mttrsrcp   = mrhdl->mr_mttrsrcp;
 339  338          mr->mr_logmttpgsz = mrhdl->mr_logmttpgsz;
 340  339          mr->mr_bindinfo   = mrhdl->mr_bindinfo;
 341  340          mr->mr_mttrefcntp = mrhdl->mr_mttrefcntp;
 342  341          mutex_exit(&mrhdl->mr_lock);
 343  342          bind = &mr->mr_bindinfo;
 344      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
 345  343          mtt = mr->mr_mttrsrcp;
 346  344  
 347  345          /*
 348  346           * Increment the MTT reference count (to reflect the fact that
 349  347           * the MTT is now shared)
 350  348           */
 351  349          (void) tavor_mtt_refcnt_inc(mr->mr_mttrefcntp);
 352  350  
 353  351          /*
 354  352           * Update the new "bind" virtual address.  Do some extra work here
↓ open down ↓ 305 lines elided ↑ open up ↑
 660  658   * tavor_mr_query()
 661  659   *    Context: Can be called from interrupt or base context.
 662  660   */
 663  661  /* ARGSUSED */
 664  662  int
 665  663  tavor_mr_query(tavor_state_t *state, tavor_mrhdl_t mr,
 666  664      ibt_mr_query_attr_t *attr)
 667  665  {
 668  666          TAVOR_TNF_ENTER(tavor_mr_query);
 669  667  
 670      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*attr))
 671      -
 672  668          mutex_enter(&mr->mr_lock);
 673  669  
 674  670          /*
 675  671           * Check here to see if the memory region has already been partially
 676  672           * deregistered as a result of a tavor_umap_umemlock_cb() callback.
 677  673           * If so, this is an error, return failure.
 678  674           */
 679  675          if ((mr->mr_is_umem) && (mr->mr_umemcookie == NULL)) {
 680  676                  mutex_exit(&mr->mr_lock);
 681  677                  TNF_PROBE_0(tavor_mr_query_inv_mrhdl_fail, TAVOR_TNF_ERROR, "");
↓ open down ↓ 272 lines elided ↑ open up ↑
 954  950           * necessary.  If we fail here, we must undo the protection domain
 955  951           * reference count and the previous resource allocation.
 956  952           */
 957  953          status = tavor_rsrc_alloc(state, TAVOR_MRHDL, 1, sleep, &rsrc);
 958  954          if (status != DDI_SUCCESS) {
 959  955                  /* Set "status" and "errormsg" and goto failure */
 960  956                  TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed MR handle");
 961  957                  goto mwalloc_fail2;
 962  958          }
 963  959          mw = (tavor_mwhdl_t)rsrc->tr_addr;
 964      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mw))
 965  960  
 966  961          /*
 967  962           * Calculate an "unbound" RKey from MPT index.  In much the same way
 968  963           * as we do for memory regions (above), this key is constructed from
 969  964           * a "constrained" (which depends on the MPT index) and an
 970  965           * "unconstrained" portion (which may be arbitrarily chosen).
 971  966           */
 972  967          tavor_mr_keycalc(state, mpt->tr_indx, &mw->mr_rkey);
 973  968  
 974  969          /*
↓ open down ↓ 88 lines elided ↑ open up ↑
1063 1058           * Pull all the necessary information from the Tavor Memory Window
1064 1059           * handle.  This is necessary here because the resource for the
1065 1060           * MW handle is going to be freed up as part of the this operation.
1066 1061           */
1067 1062          mw      = *mwhdl;
1068 1063          mutex_enter(&mw->mr_lock);
1069 1064          mpt     = mw->mr_mptrsrcp;
1070 1065          rsrc    = mw->mr_rsrcp;
1071 1066          pd      = mw->mr_pdhdl;
1072 1067          mutex_exit(&mw->mr_lock);
1073      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mw))
1074 1068  
1075 1069          /*
1076 1070           * Reclaim the MPT entry from hardware.  Note: in general, it is
1077 1071           * unexpected for this operation to return an error.
1078 1072           */
1079 1073          status = tavor_cmn_ownership_cmd_post(state, HW2SW_MPT, NULL,
1080 1074              0, mpt->tr_indx, sleep);
1081 1075          if (status != TAVOR_CMD_SUCCESS) {
1082 1076                  cmn_err(CE_CONT, "Tavor: HW2SW_MPT command failed: %08x\n",
1083 1077                      status);
↓ open down ↓ 34 lines elided ↑ open up ↑
1118 1112           * static variable _intentionally_ without any kind of mutex around
1119 1113           * it.  First, single-threading all operations through a single lock
1120 1114           * would be a bad idea (from a performance point-of-view).  Second,
1121 1115           * the upper "unconstrained" bits don't really have to be unique
1122 1116           * because the lower bits are guaranteed to be (although we do make a
1123 1117           * best effort to ensure that they are).  Third, the window for the
1124 1118           * race (where both threads read and update the counter at the same
1125 1119           * time) is incredibly small.
1126 1120           * And, lastly, we'd like to make this into a "random" key XXX
1127 1121           */
1128      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(tavor_debug_memkey_cnt))
1129 1122          log_num_mpt = state->ts_cfg_profile->cp_log_num_mpt;
1130 1123          tmp = (tavor_debug_memkey_cnt++) << log_num_mpt;
1131 1124          *key = tmp | indx;
1132 1125  }
1133 1126  
1134 1127  
1135 1128  /*
1136 1129   * tavor_mr_common_reg()
1137 1130   *    Context: Can be called from interrupt or base context.
1138 1131   */
↓ open down ↓ 96 lines elided ↑ open up ↑
1235 1228           * the protection domain reference count and the previous resource
1236 1229           * allocation.
1237 1230           */
1238 1231          status = tavor_rsrc_alloc(state, TAVOR_MRHDL, 1, sleep, &rsrc);
1239 1232          if (status != DDI_SUCCESS) {
1240 1233                  /* Set "status" and "errormsg" and goto failure */
1241 1234                  TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed MR handle");
1242 1235                  goto mrcommon_fail2;
1243 1236          }
1244 1237          mr = (tavor_mrhdl_t)rsrc->tr_addr;
1245      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr))
1246 1238  
1247 1239          /*
1248 1240           * Setup and validate the memory region access flags.  This means
1249 1241           * translating the IBTF's enable flags into the access flags that
1250 1242           * will be used in later operations.
1251 1243           */
1252 1244          mr->mr_accflag = 0;
1253 1245          if (flags & IBT_MR_ENABLE_WINDOW_BIND)
1254 1246                  mr->mr_accflag |= IBT_MR_WINDOW_BIND;
1255 1247          if (flags & IBT_MR_ENABLE_LOCAL_WRITE)
↓ open down ↓ 38 lines elided ↑ open up ↑
1294 1286                  umem_flags = (DDI_UMEMLOCK_WRITE | DDI_UMEMLOCK_READ |
1295 1287                      DDI_UMEMLOCK_LONGTERM);
1296 1288                  status = umem_lockmemory(umem_addr, umem_len, umem_flags,
1297 1289                      &umem_cookie, &tavor_umem_cbops, NULL);
1298 1290                  if (status != 0) {
1299 1291                          /* Set "status" and "errormsg" and goto failure */
1300 1292                          TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed umem pin");
1301 1293                          goto mrcommon_fail3;
1302 1294                  }
1303 1295  
1304      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
1305      -                _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind->bi_buf))
1306      -
1307 1296                  bind->bi_buf = ddi_umem_iosetup(umem_cookie, 0, umem_len,
1308 1297                      B_WRITE, 0, 0, NULL, DDI_UMEM_SLEEP);
1309 1298                  if (bind->bi_buf == NULL) {
1310 1299                          /* Set "status" and "errormsg" and goto failure */
1311 1300                          TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed iosetup");
1312 1301                          goto mrcommon_fail3;
1313 1302                  }
1314 1303                  bind->bi_type = TAVOR_BINDHDL_UBUF;
1315 1304                  bind->bi_buf->b_flags |= B_READ;
1316 1305  
1317      -                _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*bind->bi_buf))
1318      -                _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*bind))
1319      -
1320 1306                  umapdb = tavor_umap_db_alloc(state->ts_instance,
1321 1307                      (uint64_t)(uintptr_t)umem_cookie, MLNX_UMAP_MRMEM_RSRC,
1322 1308                      (uint64_t)(uintptr_t)rsrc);
1323 1309                  if (umapdb == NULL) {
1324 1310                          /* Set "status" and "errormsg" and goto failure */
1325 1311                          TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed umap add");
1326 1312                          goto mrcommon_fail4;
1327 1313                  }
1328 1314          }
1329 1315  
1330 1316          /*
1331 1317           * Setup the bindinfo for the mtt bind call
1332 1318           */
1333 1319          bh = &mr->mr_bindinfo;
1334      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bh))
1335 1320          bcopy(bind, bh, sizeof (tavor_bind_info_t));
1336 1321          bh->bi_bypass = bind_type;
1337 1322          status = tavor_mr_mtt_bind(state, bh, bind_dmahdl, &mtt,
1338 1323              &mtt_pgsize_bits);
1339 1324          if (status != DDI_SUCCESS) {
1340 1325                  /* Set "status" and "errormsg" and goto failure */
1341 1326                  TAVOR_TNF_FAIL(status, "failed mtt bind");
1342 1327                  /*
1343 1328                   * When mtt_bind fails, freerbuf has already been done,
1344 1329                   * so make sure not to call it again.
↓ open down ↓ 12 lines elided ↑ open up ↑
1357 1342           */
1358 1343          status = tavor_rsrc_alloc(state, TAVOR_REFCNT, 1, sleep,
1359 1344              &mtt_refcnt);
1360 1345          if (status != DDI_SUCCESS) {
1361 1346                  /* Set "status" and "errormsg" and goto failure */
1362 1347                  TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE, "failed refence count");
1363 1348                  goto mrcommon_fail6;
1364 1349          }
1365 1350          mr->mr_mttrefcntp = mtt_refcnt;
1366 1351          swrc_tmp = (tavor_sw_refcnt_t *)mtt_refcnt->tr_addr;
1367      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*swrc_tmp))
1368 1352          TAVOR_MTT_REFCNT_INIT(swrc_tmp);
1369 1353  
1370 1354          /*
1371 1355           * Fill in the MPT entry.  This is the final step before passing
1372 1356           * ownership of the MPT entry to the Tavor hardware.  We use all of
1373 1357           * the information collected/calculated above to fill in the
1374 1358           * requisite portions of the MPT.
1375 1359           */
1376 1360          bzero(&mpt_entry, sizeof (tavor_hw_mpt_t));
1377 1361          mpt_entry.m_io    = TAVOR_MEM_CYCLE_GENERATE;
↓ open down ↓ 82 lines elided ↑ open up ↑
1460 1444                  tavor_umap_db_free(umapdb);
1461 1445          }
1462 1446  mrcommon_fail4:
1463 1447          if (mr_is_umem) {
1464 1448                  /*
1465 1449                   * Free up the memory ddi_umem_iosetup() allocates
1466 1450                   * internally.
1467 1451                   */
1468 1452                  if (bind->bi_type == TAVOR_BINDHDL_UBUF) {
1469 1453                          freerbuf(bind->bi_buf);
1470      -                        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
1471 1454                          bind->bi_type = TAVOR_BINDHDL_NONE;
1472      -                        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*bind))
1473 1455                  }
1474 1456                  ddi_umem_unlock(umem_cookie);
1475 1457          }
1476 1458  mrcommon_fail3:
1477 1459          tavor_rsrc_free(state, &rsrc);
1478 1460  mrcommon_fail2:
1479 1461          tavor_rsrc_free(state, &mpt);
1480 1462  mrcommon_fail1:
1481 1463          tavor_pd_refcnt_dec(pd);
1482 1464  mrcommon_fail:
↓ open down ↓ 50 lines elided ↑ open up ↑
1533 1515           * the Tavor Memory Region handle).  If we fail here, we must undo
1534 1516           * the protection domain reference count and the previous resource
1535 1517           * allocation.
1536 1518           */
1537 1519          status = tavor_rsrc_alloc(state, TAVOR_MRHDL, 1, sleep, &rsrc);
1538 1520          if (status != DDI_SUCCESS) {
1539 1521                  status = IBT_INSUFF_RESOURCE;
1540 1522                  goto mrcommon_fail2;
1541 1523          }
1542 1524          mr = (tavor_mrhdl_t)rsrc->tr_addr;
1543      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*mr))
1544 1525          bzero(mr, sizeof (*mr));
1545 1526  
1546 1527          /*
1547 1528           * Setup and validate the memory region access flags.  This means
1548 1529           * translating the IBTF's enable flags into the access flags that
1549 1530           * will be used in later operations.
1550 1531           */
1551 1532          mr->mr_accflag = 0;
1552 1533          if (flags & IBT_MR_ENABLE_WINDOW_BIND)
1553 1534                  mr->mr_accflag |= IBT_MR_WINDOW_BIND;
↓ open down ↓ 241 lines elided ↑ open up ↑
1795 1776          ibt_mr_flags_t          flags;
1796 1777          tavor_pdhdl_t           pd_to_use;
1797 1778          tavor_hw_mpt_t          mpt_entry;
1798 1779          uint64_t                mtt_addr_to_use, vaddr_to_use, len_to_use;
1799 1780          uint_t                  sleep, dereg_level;
1800 1781          int                     status;
1801 1782          char                    *errormsg;
1802 1783  
1803 1784          TAVOR_TNF_ENTER(tavor_mr_common_rereg);
1804 1785  
1805      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
1806      -
1807 1786          /*
1808 1787           * Check here to see if the memory region corresponds to a userland
1809 1788           * mapping.  Reregistration of userland memory regions is not
1810 1789           * currently supported.  Return failure. XXX
1811 1790           */
1812 1791          if (mr->mr_is_umem) {
1813 1792                  /* Set "status" and "errormsg" and goto failure */
1814 1793                  TAVOR_TNF_FAIL(IBT_MR_HDL_INVALID, "invalid mrhdl");
1815 1794                  goto mrrereg_fail;
1816 1795          }
↓ open down ↓ 587 lines elided ↑ open up ↑
2404 2383                                  tavor_rsrc_free(state, &mtt);
2405 2384                                  *dereg_level =
2406 2385                                      TAVOR_MR_DEREG_NO_HW2SW_MPT_OR_UNBIND;
2407 2386  
2408 2387                                  /* Set "status"/"errormsg", goto failure */
2409 2388                                  TAVOR_TNF_FAIL(IBT_INSUFF_RESOURCE,
2410 2389                                      "failed reference count");
2411 2390                                  goto mrrereghelp_fail;
2412 2391                          }
2413 2392                          swrc_new = (tavor_sw_refcnt_t *)mtt_refcnt->tr_addr;
2414      -                        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*swrc_new))
2415 2393                          TAVOR_MTT_REFCNT_INIT(swrc_new);
2416 2394                  } else {
2417 2395                          mtt_refcnt = mr->mr_mttrefcntp;
2418 2396                  }
2419 2397  
2420 2398                  /*
2421 2399                   * Using the new mapping and the new MTT resources, write the
2422 2400                   * updated entries to MTT
2423 2401                   */
2424 2402                  status = tavor_mr_fast_mtt_write(mtt, bind, mtt_pgsize_bits);
↓ open down ↓ 105 lines elided ↑ open up ↑
2530 2508          uint_t          dma_xfer_mode;
2531 2509          int             status;
2532 2510  
2533 2511          /* bi_type must be set to a meaningful value to get a bind handle */
2534 2512          ASSERT(bind->bi_type == TAVOR_BINDHDL_VADDR ||
2535 2513              bind->bi_type == TAVOR_BINDHDL_BUF ||
2536 2514              bind->bi_type == TAVOR_BINDHDL_UBUF);
2537 2515  
2538 2516          TAVOR_TNF_ENTER(tavor_mr_mem_bind);
2539 2517  
2540      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
2541      -
2542 2518          /* Set the callback flag appropriately */
2543 2519          callback = (sleep == TAVOR_SLEEP) ? DDI_DMA_SLEEP : DDI_DMA_DONTWAIT;
2544 2520  
2545 2521          /* Determine whether to map STREAMING or CONSISTENT */
2546 2522          dma_xfer_mode = (bind->bi_flags & IBT_MR_NONCOHERENT) ?
2547 2523              DDI_DMA_STREAMING : DDI_DMA_CONSISTENT;
2548 2524  
2549 2525          /*
2550 2526           * Initialize many of the default DMA attributes.  Then, if we're
2551 2527           * bypassing the IOMMU, set the DDI_DMA_FORCE_PHYSICAL flag.
↓ open down ↓ 78 lines elided ↑ open up ↑
2630 2606          int     status;
2631 2607  
2632 2608          TAVOR_TNF_ENTER(tavor_mr_mem_unbind);
2633 2609  
2634 2610          /*
2635 2611           * In case of TAVOR_BINDHDL_UBUF, the memory bi_buf points to
2636 2612           * is actually allocated by ddi_umem_iosetup() internally, then
2637 2613           * it's required to free it here. Reset bi_type to TAVOR_BINDHDL_NONE
2638 2614           * not to free it again later.
2639 2615           */
2640      -        _NOTE(NOW_INVISIBLE_TO_OTHER_THREADS(*bind))
2641 2616          if (bind->bi_type == TAVOR_BINDHDL_UBUF) {
2642 2617                  freerbuf(bind->bi_buf);
2643 2618                  bind->bi_type = TAVOR_BINDHDL_NONE;
2644 2619          }
2645      -        _NOTE(NOW_VISIBLE_TO_OTHER_THREADS(*bind))
2646 2620  
2647 2621          /*
2648 2622           * Unbind the DMA memory for the region
2649 2623           *
2650 2624           * Note: The only way ddi_dma_unbind_handle() currently
2651 2625           * can return an error is if the handle passed in is invalid.
2652 2626           * Since this should never happen, we choose to return void
2653 2627           * from this function!  If this does return an error, however,
2654 2628           * then we print a warning message to the console.
2655 2629           */
↓ open down ↓ 52 lines elided ↑ open up ↑
2708 2682                           * Fill in the mapped addresses (calculated above) and
2709 2683                           * set TAVOR_MTT_ENTRY_PRESET flag for each MTT entry.
2710 2684                           */
2711 2685                          mtt_entry = addr | TAVOR_MTT_ENTRY_PRESET;
2712 2686                          ddi_put64(mtt->tr_acchdl, &mtt_table[i], mtt_entry);
2713 2687                          addr += pagesize;
2714 2688                          i++;
2715 2689  
2716 2690                          if (addr == 0) {
2717 2691                                  static int do_once = 1;
2718      -                                _NOTE(SCHEME_PROTECTS_DATA("safe sharing",
2719      -                                    do_once))
2720 2692                                  if (do_once) {
2721 2693                                          do_once = 0;
2722 2694                                          cmn_err(CE_NOTE, "probable error in "
2723 2695                                              "dma_cookie address from caller\n");
2724 2696                                  }
2725 2697                                  break;
2726 2698                          }
2727 2699                  }
2728 2700  
2729 2701                  /*
↓ open down ↓ 56 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX