Print this page
First pass at 4310

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
          +++ new/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
↓ open down ↓ 1055 lines elided ↑ open up ↑
1056 1056          mptsas_t                *mpt = NULL;
1057 1057          int                     instance, i, j;
1058 1058          int                     doneq_thread_num;
1059 1059          char                    intr_added = 0;
1060 1060          char                    map_setup = 0;
1061 1061          char                    config_setup = 0;
1062 1062          char                    hba_attach_setup = 0;
1063 1063          char                    smp_attach_setup = 0;
1064 1064          char                    mutex_init_done = 0;
1065 1065          char                    event_taskq_create = 0;
     1066 +        char                    reset_taskq_create = 0;
1066 1067          char                    dr_taskq_create = 0;
1067 1068          char                    doneq_thread_create = 0;
1068 1069          char                    added_watchdog = 0;
1069 1070          scsi_hba_tran_t         *hba_tran;
1070 1071          uint_t                  mem_bar = MEM_SPACE;
1071 1072          int                     rval = DDI_FAILURE;
1072 1073  
1073 1074          /* CONSTCOND */
1074 1075          ASSERT(NO_COMPETING_THREADS);
1075 1076  
↓ open down ↓ 186 lines elided ↑ open up ↑
1262 1263           */
1263 1264          if ((mpt->m_dr_taskq = ddi_taskq_create(dip,
1264 1265              "mptsas_dr_taskq",
1265 1266              1, TASKQ_DEFAULTPRI, 0)) == NULL) {
1266 1267                  mptsas_log(mpt, CE_NOTE, "ddi_taskq_create for discovery "
1267 1268                      "failed");
1268 1269                  goto fail;
1269 1270          }
1270 1271          dr_taskq_create++;
1271 1272  
     1273 +        /*
     1274 +         * A taskq is created for dealing with reset events
     1275 +         */
     1276 +        if ((mpt->m_reset_taskq = ddi_taskq_create(dip,
     1277 +            "mptsas_reset_taskq",
     1278 +            1, TASKQ_DEFAULTPRI, 0)) == NULL) {
     1279 +                mptsas_log(mpt, CE_NOTE, "ddi_taskq_create for reset "
     1280 +                    "failed");
     1281 +                goto fail;
     1282 +        }
     1283 +        reset_taskq_create++;
     1284 +
1272 1285          mpt->m_doneq_thread_threshold = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
1273 1286              0, "mptsas_doneq_thread_threshold_prop", 10);
1274 1287          mpt->m_doneq_length_threshold = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
1275 1288              0, "mptsas_doneq_length_threshold_prop", 8);
1276 1289          mpt->m_doneq_thread_n = ddi_prop_get_int(DDI_DEV_T_ANY, dip,
1277 1290              0, "mptsas_doneq_thread_n_prop", 8);
1278 1291  
1279 1292          if (mpt->m_doneq_thread_n) {
1280 1293                  cv_init(&mpt->m_doneq_thread_cv, NULL, CV_DRIVER, NULL);
1281 1294                  mutex_init(&mpt->m_doneq_mutex, NULL, MUTEX_DRIVER, NULL);
↓ open down ↓ 304 lines elided ↑ open up ↑
1586 1599                          mutex_exit(&mpt->m_doneq_mutex);
1587 1600                          cv_destroy(&mpt->m_doneq_thread_cv);
1588 1601                          mutex_destroy(&mpt->m_doneq_mutex);
1589 1602                  }
1590 1603                  if (event_taskq_create) {
1591 1604                          ddi_taskq_destroy(mpt->m_event_taskq);
1592 1605                  }
1593 1606                  if (dr_taskq_create) {
1594 1607                          ddi_taskq_destroy(mpt->m_dr_taskq);
1595 1608                  }
     1609 +                if (reset_taskq_create) {
     1610 +                        ddi_taskq_destroy(mpt->m_reset_taskq);
     1611 +                }
1596 1612                  if (mutex_init_done) {
1597 1613                          mutex_destroy(&mpt->m_tx_waitq_mutex);
1598 1614                          mutex_destroy(&mpt->m_passthru_mutex);
1599 1615                          mutex_destroy(&mpt->m_mutex);
1600 1616                          for (i = 0; i < MPTSAS_MAX_PHYS; i++) {
1601 1617                                  mutex_destroy(
1602 1618                                      &mpt->m_phy_info[i].smhba_info.phy_mutex);
1603 1619                          }
1604 1620                          cv_destroy(&mpt->m_cv);
1605 1621                          cv_destroy(&mpt->m_passthru_cv);
↓ open down ↓ 112 lines elided ↑ open up ↑
1718 1734          /* Disable HBA interrupts in hardware */
1719 1735          MPTSAS_DISABLE_INTR(mpt);
1720 1736          /*
1721 1737           * Send RAID action system shutdown to sync IR
1722 1738           */
1723 1739          mptsas_raid_action_system_shutdown(mpt);
1724 1740  
1725 1741          mutex_exit(&mpt->m_mutex);
1726 1742  
1727 1743          /* drain the taskq */
     1744 +        ddi_taskq_wait(mpt->m_reset_taskq);
1728 1745          ddi_taskq_wait(mpt->m_event_taskq);
1729 1746          ddi_taskq_wait(mpt->m_dr_taskq);
1730 1747  
1731 1748          return (DDI_SUCCESS);
1732 1749  }
1733 1750  
1734 1751  #ifdef  __sparc
1735 1752  /*ARGSUSED*/
1736 1753  static int
1737 1754  mptsas_reset(dev_info_t *devi, ddi_reset_cmd_t cmd)
↓ open down ↓ 155 lines elided ↑ open up ↑
1893 1910           * Message Unit Reset. Since after that DMA resource will be freed,
1894 1911           * set ioc to READY state will avoid HBA initiated DMA operation.
1895 1912           */
1896 1913          mutex_enter(&mpt->m_mutex);
1897 1914          MPTSAS_DISABLE_INTR(mpt);
1898 1915          mptsas_raid_action_system_shutdown(mpt);
1899 1916          mpt->m_softstate |= MPTSAS_SS_MSG_UNIT_RESET;
1900 1917          (void) mptsas_ioc_reset(mpt, FALSE);
1901 1918          mutex_exit(&mpt->m_mutex);
1902 1919          mptsas_rem_intrs(mpt);
     1920 +        ddi_taskq_destroy(mpt->m_reset_taskq);
1903 1921          ddi_taskq_destroy(mpt->m_event_taskq);
1904 1922          ddi_taskq_destroy(mpt->m_dr_taskq);
1905 1923  
1906 1924          if (mpt->m_doneq_thread_n) {
1907 1925                  mutex_enter(&mpt->m_doneq_mutex);
1908 1926                  doneq_thread_num = mpt->m_doneq_thread_n;
1909 1927                  for (i = 0; i < mpt->m_doneq_thread_n; i++) {
1910 1928                          mutex_enter(&mpt->m_doneq_thread_id[i].mutex);
1911 1929                          mpt->m_doneq_thread_id[i].flag &=
1912 1930                              (~MPTSAS_DONEQ_THREAD_ACTIVE);
↓ open down ↓ 10817 lines elided ↑ open up ↑
12730 12748                  default:
12731 12749                          status = scsi_hba_ioctl(dev, cmd, data, mode, credp,
12732 12750                              rval);
12733 12751                          break;
12734 12752          }
12735 12753  
12736 12754  out:
12737 12755          return (status);
12738 12756  }
12739 12757  
     12758 +/* Dirty wrapper for taskq */
     12759 +void
     12760 +mptsas_handle_restart_ioc(void *mpt) {
     12761 +    mptsas_restart_ioc((mptsas_t *) mpt);
     12762 +}
     12763 +
12740 12764  int
12741 12765  mptsas_restart_ioc(mptsas_t *mpt)
12742 12766  {
12743 12767          int             rval = DDI_SUCCESS;
12744 12768          mptsas_target_t *ptgt = NULL;
12745 12769  
12746 12770          ASSERT(mutex_owned(&mpt->m_mutex));
12747 12771  
12748 12772          /*
12749 12773           * Set a flag telling I/O path that we're processing a reset.  This is
↓ open down ↓ 3769 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX