Print this page
*** NO COMMENTS ***

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/mr_sas/mr_sas.c
          +++ new/usr/src/uts/common/io/mr_sas/mr_sas.c
↓ open down ↓ 728 lines elided ↑ open up ↑
 729  729                  /* setup the mfi based low level driver */
 730  730                  if (mrsas_init_adapter(instance) != DDI_SUCCESS) {
 731  731                          cmn_err(CE_WARN, "mr_sas: "
 732  732                              "could not initialize the low level driver");
 733  733  
 734  734                          goto fail_attach;
 735  735                  }
 736  736  
 737  737                  /* Initialize all Mutex */
 738  738                  INIT_LIST_HEAD(&instance->completed_pool_list);
 739      -                mutex_init(&instance->completed_pool_mtx,
 740      -                    "completed_pool_mtx", MUTEX_DRIVER,
 741      -                    DDI_INTR_PRI(instance->intr_pri));
      739 +                mutex_init(&instance->completed_pool_mtx, NULL,
      740 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 742  741  
 743      -                mutex_init(&instance->sync_map_mtx,
 744      -                    "sync_map_mtx", MUTEX_DRIVER,
 745      -                    DDI_INTR_PRI(instance->intr_pri));
      742 +                mutex_init(&instance->sync_map_mtx, NULL,
      743 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 746  744  
 747      -                mutex_init(&instance->app_cmd_pool_mtx,
 748      -                    "app_cmd_pool_mtx", MUTEX_DRIVER,
 749      -                    DDI_INTR_PRI(instance->intr_pri));
      745 +                mutex_init(&instance->app_cmd_pool_mtx, NULL,
      746 +                    MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 750  747  
 751      -                mutex_init(&instance->config_dev_mtx, "config_dev_mtx",
      748 +                mutex_init(&instance->config_dev_mtx, NULL,
 752  749                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 753  750  
 754      -                mutex_init(&instance->cmd_pend_mtx, "cmd_pend_mtx",
      751 +                mutex_init(&instance->cmd_pend_mtx, NULL,
 755  752                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 756  753  
 757      -                mutex_init(&instance->ocr_flags_mtx, "ocr_flags_mtx",
      754 +                mutex_init(&instance->ocr_flags_mtx, NULL,
 758  755                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 759  756  
 760      -                mutex_init(&instance->int_cmd_mtx, "int_cmd_mtx",
      757 +                mutex_init(&instance->int_cmd_mtx, NULL,
 761  758                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 762  759                  cv_init(&instance->int_cmd_cv, NULL, CV_DRIVER, NULL);
 763  760  
 764      -                mutex_init(&instance->cmd_pool_mtx, "cmd_pool_mtx",
      761 +                mutex_init(&instance->cmd_pool_mtx, NULL,
 765  762                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 766  763  
 767      -                mutex_init(&instance->reg_write_mtx, "reg_write_mtx",
      764 +                mutex_init(&instance->reg_write_mtx, NULL,
 768  765                      MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 769  766  
 770  767                  if (instance->tbolt) {
 771      -                        mutex_init(&instance->cmd_app_pool_mtx,
 772      -                            "cmd_app_pool_mtx", MUTEX_DRIVER,
 773      -                            DDI_INTR_PRI(instance->intr_pri));
      768 +                        mutex_init(&instance->cmd_app_pool_mtx, NULL,
      769 +                            MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 774  770  
 775      -                        mutex_init(&instance->chip_mtx,
 776      -                            "chip_mtx", MUTEX_DRIVER,
 777      -                            DDI_INTR_PRI(instance->intr_pri));
      771 +                        mutex_init(&instance->chip_mtx, NULL,
      772 +                            MUTEX_DRIVER, DDI_INTR_PRI(instance->intr_pri));
 778  773  
 779  774                  }
 780  775  
 781  776                  instance->unroll.mutexs = 1;
 782  777  
 783  778                  instance->timeout_id = (timeout_id_t)-1;
 784  779  
 785  780                  /* Register our soft-isr for highlevel interrupts. */
 786  781                  instance->isr_level = instance->intr_pri;
 787  782                  if (!(instance->tbolt)) {
↓ open down ↓ 147 lines elided ↑ open up ↑
 935  930                          goto fail_attach;
 936  931                  }
 937  932                  if (mrsas_check_acc_handle(instance->pci_handle) !=
 938  933                      DDI_SUCCESS) {
 939  934                          goto fail_attach;
 940  935                  }
 941  936  
 942  937                  instance->mr_ld_list =
 943  938                      kmem_zalloc(MRDRV_MAX_LD * sizeof (struct mrsas_ld),
 944  939                      KM_SLEEP);
 945      -                if (instance->mr_ld_list == NULL) {
 946      -                        cmn_err(CE_WARN, "mr_sas attach(): "
 947      -                            "failed to allocate ld_list array");
 948      -                        goto fail_attach;
 949      -                }
 950  940                  instance->unroll.ldlist_buff = 1;
 951  941  
 952  942  #ifdef PDSUPPORT
 953  943                  if (instance->tbolt) {
 954  944                          instance->mr_tbolt_pd_max = MRSAS_TBOLT_PD_TGT_MAX;
 955  945                          instance->mr_tbolt_pd_list =
 956  946                              kmem_zalloc(MRSAS_TBOLT_GET_PD_MAX(instance) *
 957  947                              sizeof (struct mrsas_tbolt_pd), KM_SLEEP);
 958  948                          ASSERT(instance->mr_tbolt_pd_list);
 959  949                          for (i = 0; i < instance->mr_tbolt_pd_max; i++) {
↓ open down ↓ 478 lines elided ↑ open up ↑
1438 1428          instance = ddi_get_soft_state(mrsas_state, MINOR2INST(getminor(dev)));
1439 1429  
1440 1430          if (instance == NULL) {
1441 1431                  /* invalid minor number */
1442 1432                  con_log(CL_ANN, (CE_WARN, "mr_sas: adapter not found."));
1443 1433                  return (ENXIO);
1444 1434          }
1445 1435  
1446 1436          ioctl = (struct mrsas_ioctl *)kmem_zalloc(sizeof (struct mrsas_ioctl),
1447 1437              KM_SLEEP);
1448      -        if (ioctl == NULL) {
1449      -                /* Failed to allocate memory for ioctl  */
1450      -                con_log(CL_ANN, (CE_WARN, "mr_sas_ioctl: "
1451      -                    "failed to allocate memory for ioctl"));
1452      -                return (ENOMEM);
1453      -        }
     1438 +        ASSERT(ioctl);
1454 1439  
1455 1440          switch ((uint_t)cmd) {
1456 1441                  case MRSAS_IOCTL_FIRMWARE:
1457 1442                          if (ddi_copyin((void *)arg, ioctl,
1458 1443                              sizeof (struct mrsas_ioctl), mode)) {
1459 1444                                  con_log(CL_ANN, (CE_WARN, "mrsas_ioctl: "
1460 1445                                      "ERROR IOCTL copyin"));
1461 1446                                  kmem_free(ioctl, sizeof (struct mrsas_ioctl));
1462 1447                                  return (EFAULT);
1463 1448                          }
↓ open down ↓ 6 lines elided ↑ open up ↑
1470 1455  
1471 1456                          if (ddi_copyout((void *)ioctl, (void *)arg,
1472 1457                              (sizeof (struct mrsas_ioctl) - 1), mode)) {
1473 1458                                  con_log(CL_ANN, (CE_WARN,
1474 1459                                      "mrsas_ioctl: copy_to_user failed"));
1475 1460                                  rval = 1;
1476 1461                          }
1477 1462  
1478 1463                          break;
1479 1464                  case MRSAS_IOCTL_AEN:
1480      -                        con_log(CL_ANN,
1481      -                            (CE_NOTE, "mrsas_ioctl: IOCTL Register AEN.\n"));
1482      -
1483 1465                          if (ddi_copyin((void *) arg, &aen,
1484 1466                              sizeof (struct mrsas_aen), mode)) {
1485 1467                                  con_log(CL_ANN, (CE_WARN,
1486 1468                                      "mrsas_ioctl: ERROR AEN copyin"));
1487 1469                                  kmem_free(ioctl, sizeof (struct mrsas_ioctl));
1488 1470                                  return (EFAULT);
1489 1471                          }
1490 1472  
1491 1473                          rval = handle_mfi_aen(instance, &aen);
1492 1474  
↓ open down ↓ 1699 lines elided ↑ open up ↑
3192 3174  
3193 3175  
3194 3176          sz = sizeof (struct mrsas_cmd *) * max_cmd;
3195 3177  
3196 3178          /*
3197 3179           * instance->cmd_list is an array of struct mrsas_cmd pointers.
3198 3180           * Allocate the dynamic array first and then allocate individual
3199 3181           * commands.
3200 3182           */
3201 3183          instance->cmd_list = kmem_zalloc(sz, KM_SLEEP);
3202      -        if (instance->cmd_list == NULL) {
3203      -                con_log(CL_NONE, (CE_WARN,
3204      -                    "Failed to allocate memory for cmd_list"));
3205      -                return (DDI_FAILURE);
3206      -        }
     3184 +        ASSERT(instance->cmd_list);
3207 3185  
3208 3186          /* create a frame pool and assign one frame to each cmd */
3209 3187          for (count = 0; count < max_cmd; count++) {
3210 3188                  instance->cmd_list[count] =
3211 3189                      kmem_zalloc(sizeof (struct mrsas_cmd), KM_SLEEP);
3212      -                if (instance->cmd_list[count] == NULL) {
3213      -                        con_log(CL_NONE, (CE_WARN,
3214      -                            "Failed to allocate memory for mrsas_cmd"));
3215      -                        goto mrsas_undo_cmds;
3216      -                }
     3190 +                ASSERT(instance->cmd_list[count]);
3217 3191          }
3218 3192  
3219 3193          /* add all the commands to command pool */
3220 3194  
3221 3195          INIT_LIST_HEAD(&instance->cmd_pool_list);
3222 3196          INIT_LIST_HEAD(&instance->cmd_pend_list);
3223 3197          INIT_LIST_HEAD(&instance->app_cmd_pool_list);
3224 3198  
3225 3199          reserve_cmd = MRSAS_APP_RESERVED_CMDS;
3226 3200  
↓ open down ↓ 496 lines elided ↑ open up ↑
3723 3697          if (!get_ctrl_info(instance, &ctrl_info)) {
3724 3698                  instance->max_sectors_per_req = ctrl_info.max_request_size;
3725 3699                  con_log(CL_ANN1, (CE_NOTE,
3726 3700                      "product name %s ld present %d",
3727 3701                      ctrl_info.product_name, ctrl_info.ld_present_count));
3728 3702          } else {
3729 3703                  instance->max_sectors_per_req = instance->max_num_sge *
3730 3704                      PAGESIZE / 512;
3731 3705          }
3732 3706  
3733      -        if (ctrl_info.properties.on_off_properties & DISABLE_OCR_PROP_FLAG) {
     3707 +        if (ctrl_info.properties.on_off_properties & DISABLE_OCR_PROP_FLAG)
3734 3708                  instance->disable_online_ctrl_reset = 1;
3735      -                con_log(CL_ANN1,
3736      -                    (CE_NOTE, "Disable online control Flag is set\n"));
3737      -        } else {
3738      -                con_log(CL_ANN1,
3739      -                    (CE_NOTE, "Disable online control Flag is not set\n"));
3740      -        }
3741 3709  
3742 3710          return (DDI_SUCCESS);
3743 3711  
3744 3712  }
3745 3713  
3746 3714  
3747 3715  
3748 3716  static int
3749 3717  mrsas_issue_init_mfi(struct mrsas_instance *instance)
3750 3718  {
↓ open down ↓ 262 lines elided ↑ open up ↑
4013 3981                   * - Abort all outstanding commands (bit 0).
4014 3982                   * - Transition from OPERATIONAL to READY state (bit 1).
4015 3983                   * - Discard (possible) low MFA posted in 64-bit mode (bit-2).
4016 3984                   * - Set to release FW to continue running (i.e. BIOS handshake
4017 3985                   *   (bit 3).
4018 3986                   */
4019 3987                  WR_IB_DOORBELL(0xF, instance);
4020 3988          }
4021 3989  
4022 3990          if (mrsas_check_acc_handle(instance->regmap_handle) != DDI_SUCCESS) {
4023      -                return (ENODEV);
     3991 +                return (EIO);
4024 3992          }
4025 3993  
4026 3994          return (DDI_SUCCESS);
4027 3995  }
4028 3996  
4029 3997  /*
4030 3998   * get_seq_num
4031 3999   */
4032 4000  static int
4033 4001  get_seq_num(struct mrsas_instance *instance,
↓ open down ↓ 837 lines elided ↑ open up ↑
4871 4839  
4872 4840          return (cookie_cnt);
4873 4841  }
4874 4842  
4875 4843  /*
4876 4844   * mrsas_free_dma_obj(struct mrsas_instance *, dma_obj_t)
4877 4845   *
4878 4846   * De-allocate the memory and other resources for an dma object, which must
4879 4847   * have been alloated by a previous call to mrsas_alloc_dma_obj()
4880 4848   */
4881      -/* ARGSUSED */
4882 4849  int
4883 4850  mrsas_free_dma_obj(struct mrsas_instance *instance, dma_obj_t obj)
4884 4851  {
4885 4852  
4886 4853          if ((obj.dma_handle == NULL) || (obj.acc_handle == NULL)) {
4887 4854                  return (DDI_SUCCESS);
4888 4855          }
4889 4856  
4890 4857          /*
4891 4858           * NOTE: These check-handle functions fail if *_handle == NULL, but
↓ open down ↓ 693 lines elided ↑ open up ↑
5585 5552  
5586 5553                  for (i = 0; i < sense_len; i++) {
5587 5554                          if (ddi_copyout(
5588 5555                              (uint8_t *)cmd->sense+i,
5589 5556                              (uint8_t *)sense_ubuf+i, 1, mode)) {
5590 5557                                  con_log(CL_ANN, (CE_WARN,
5591 5558                                      "issue_mfi_pthru : "
5592 5559                                      "copy to user space failed"));
5593 5560                          }
5594 5561                          con_log(CL_DLEVEL1, (CE_WARN,
5595      -                            "Copying Sense info sense_buff[%d] = 0x%X\n",
     5562 +                            "Copying Sense info sense_buff[%d] = 0x%X",
5596 5563                              i, *((uint8_t *)cmd->sense + i)));
5597 5564                  }
5598 5565          }
5599 5566          (void) ddi_dma_sync(cmd->frame_dma_obj.dma_handle, 0, 0,
5600 5567              DDI_DMA_SYNC_FORDEV);
5601 5568  
5602 5569          if (xferlen) {
5603 5570                  /* free kernel buffer */
5604 5571                  if (mrsas_free_dma_obj(instance, pthru_dma_obj) != DDI_SUCCESS)
5605 5572                          return (DDI_FAILURE);
↓ open down ↓ 16 lines elided ↑ open up ↑
5622 5589          uint32_t        model;
5623 5590          dma_obj_t       dcmd_dma_obj;
5624 5591          struct mrsas_dcmd_frame *kdcmd;
5625 5592          struct mrsas_dcmd_frame *dcmd;
5626 5593          ddi_acc_handle_t        acc_handle = cmd->frame_dma_obj.acc_handle;
5627 5594          int i;
5628 5595          dcmd = &cmd->frame->dcmd;
5629 5596          kdcmd = (struct mrsas_dcmd_frame *)&ioctl->frame[0];
5630 5597  
5631 5598          if (instance->adapterresetinprogress) {
5632      -                con_log(CL_ANN1, (CE_WARN, "Reset flag set, "
5633      -                "returning mfi_pkt and setting TRAN_BUSY\n"));
     5599 +                con_log(CL_ANN1, (CE_NOTE, "Reset flag set, "
     5600 +                "returning mfi_pkt and setting TRAN_BUSY"));
5634 5601                  return (DDI_FAILURE);
5635 5602          }
5636 5603          model = ddi_model_convert_from(mode & FMODELS);
5637 5604          if (model == DDI_MODEL_ILP32) {
5638 5605                  con_log(CL_ANN1, (CE_CONT, "issue_mfi_dcmd: DDI_MODEL_ILP32"));
5639 5606  
5640 5607                  xferlen = kdcmd->sgl.sge32[0].length;
5641 5608  
5642 5609                  ubuf    = (void *)(ulong_t)kdcmd->sgl.sge32[0].phys_addr;
5643 5610          } else {
↓ open down ↓ 1390 lines elided ↑ open up ↑
7034 7001          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: magic number written "
7035 7002              "to write sequence register\n"));
7036 7003          delay(100 * drv_usectohz(MILLISEC));
7037 7004          status = RD_OB_DRWE(instance);
7038 7005  
7039 7006          while (!(status & DIAG_WRITE_ENABLE)) {
7040 7007                  delay(100 * drv_usectohz(MILLISEC));
7041 7008                  status = RD_OB_DRWE(instance);
7042 7009                  if (retry++ == 100) {
7043 7010                          cmn_err(CE_WARN, "mrsas_reset_ppc: DRWE bit "
7044      -                            "check retry count %d\n", retry);
     7011 +                            "check retry count %d", retry);
7045 7012                          return (DDI_FAILURE);
7046 7013                  }
7047 7014          }
7048 7015          WR_IB_DRWE(status | DIAG_RESET_ADAPTER, instance);
7049 7016          delay(100 * drv_usectohz(MILLISEC));
7050 7017          status = RD_OB_DRWE(instance);
7051 7018          while (status & DIAG_RESET_ADAPTER) {
7052 7019                  delay(100 * drv_usectohz(MILLISEC));
7053 7020                  status = RD_OB_DRWE(instance);
7054 7021                  if (retry++ == 100) {
7055 7022                          cmn_err(CE_WARN, "mrsas_reset_ppc: "
7056      -                            "RESET FAILED. KILL adapter called\n.");
     7023 +                            "RESET FAILED. KILL adapter called.");
7057 7024  
7058 7025                          (void) mrsas_kill_adapter(instance);
7059 7026                          return (DDI_FAILURE);
7060 7027                  }
7061 7028          }
7062 7029          con_log(CL_ANN, (CE_NOTE, "mrsas_reset_ppc: Adapter reset complete"));
7063 7030          con_log(CL_ANN1, (CE_NOTE, "mrsas_reset_ppc: "
7064 7031              "Calling mfi_state_transition_to_ready"));
7065 7032  
7066 7033          /* Mark HBA as bad, if FW is fault after 3 continuous resets */
↓ open down ↓ 306 lines elided ↑ open up ↑
7373 7340                  count = 1;
7374 7341          }
7375 7342  
7376 7343          /*
7377 7344           * Allocate an array of interrupt handlers. Currently we support
7378 7345           * only one interrupt. The framework can be extended later.
7379 7346           */
7380 7347          instance->intr_htable_size = count * sizeof (ddi_intr_handle_t);
7381 7348          instance->intr_htable = kmem_zalloc(instance->intr_htable_size,
7382 7349              KM_SLEEP);
7383      -        if (instance->intr_htable == NULL) {
7384      -                con_log(CL_ANN, (CE_WARN, "mrsas_add_intrs: "
7385      -                    "failed to allocate memory for intr-handle table"));
7386      -                instance->intr_htable_size = 0;
7387      -                return (DDI_FAILURE);
7388      -        }
     7350 +        ASSERT(instance->intr_htable);
7389 7351  
7390 7352          flag = ((intr_type == DDI_INTR_TYPE_MSI) ||
7391 7353              (intr_type == DDI_INTR_TYPE_MSIX)) ?
7392 7354              DDI_INTR_ALLOC_STRICT : DDI_INTR_ALLOC_NORMAL;
7393 7355  
7394 7356          /* Allocate interrupt */
7395 7357          ret = ddi_intr_alloc(dip, instance->intr_htable, intr_type, 0,
7396 7358              count, &actual, flag);
7397 7359  
7398 7360          if ((ret != DDI_SUCCESS) || (actual == 0)) {
↓ open down ↓ 278 lines elided ↑ open up ↑
7677 7639                              MRSAS_EVT_UNCONFIG_TGT, NULL);
7678 7640                          con_log(CL_ANN1, (CE_WARN,
7679 7641                              "mr_sas: DELETING STALE ENTRY rval = %d "
7680 7642                              "tgt id = %d ", rval, tgt));
7681 7643                          return (NDI_FAILURE);
7682 7644                  }
7683 7645                  return (NDI_SUCCESS);
7684 7646          }
7685 7647  
7686 7648          sd = kmem_zalloc(sizeof (struct scsi_device), KM_SLEEP);
7687      -        if (sd == NULL) {
7688      -                con_log(CL_ANN1, (CE_WARN, "mrsas_config_ld: "
7689      -                    "failed to allocate mem for scsi_device"));
7690      -                return (NDI_FAILURE);
7691      -        }
7692 7649          sd->sd_address.a_hba_tran = instance->tran;
7693 7650          sd->sd_address.a_target = (uint16_t)tgt;
7694 7651          sd->sd_address.a_lun = (uint8_t)lun;
7695 7652  
7696 7653          if (scsi_hba_probe(sd, NULL) == SCSIPROBE_EXISTS)
7697 7654                  rval = mrsas_config_scsi_device(instance, sd, ldip);
7698 7655          else
7699 7656                  rval = NDI_FAILURE;
7700 7657  
7701 7658          /* sd_unprobe is blank now. Free buffer manually */
↓ open down ↓ 267 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX