Print this page
4778 iprb shouldn't abuse ddi_get_time(9f)
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Garrett D'Amore <garrett@damore.org>

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/io/iprb/iprb.c
          +++ new/usr/src/uts/common/io/iprb/iprb.c
↓ open down ↓ 290 lines elided ↑ open up ↑
 291  291          PUT32(ip, CSR_PORT, PORT_SEL_RESET);
 292  292          drv_usecwait(10);
 293  293          PUT32(ip, CSR_PORT, PORT_SW_RESET);
 294  294          drv_usecwait(10);
 295  295          PUT8(ip, CSR_INTCTL, INTCTL_MASK);
 296  296          (void) GET8(ip, CSR_INTCTL);
 297  297  
 298  298          /*
 299  299           * Precalculate watchdog times.
 300  300           */
 301      -        ip->tx_timeout = drv_usectohz(TX_WATCHDOG * 1000000);
 302      -        ip->rx_timeout = drv_usectohz(RX_WATCHDOG * 1000000);
      301 +        ip->tx_timeout = TX_WATCHDOG;
      302 +        ip->rx_timeout = RX_WATCHDOG;
 303  303  
 304  304          iprb_identify(ip);
 305  305  
 306  306          /* Obtain our factory MAC address */
 307  307          w = iprb_eeprom_read(ip, 0);
 308  308          ip->factaddr[0] = w & 0xff;
 309  309          ip->factaddr[1] = w >> 8;
 310  310          w = iprb_eeprom_read(ip, 1);
 311  311          ip->factaddr[2] = w & 0xff;
 312  312          ip->factaddr[3] = w >> 8;
↓ open down ↓ 383 lines elided ↑ open up ↑
 696  696                  if ((GETCB16(cb, CB_STS_OFFSET) & CB_STS_C) == 0) {
 697  697                          break;
 698  698                  }
 699  699  
 700  700                  ip->cmd_tail++;
 701  701                  ip->cmd_tail %= NUM_TX;
 702  702                  ip->cmd_count--;
 703  703                  if (ip->cmd_count == 0) {
 704  704                          ip->tx_wdog = 0;
 705  705                  } else {
 706      -                        ip->tx_wdog = ddi_get_time();
      706 +                        ip->tx_wdog = gethrtime();
 707  707                  }
 708  708          }
 709  709  }
 710  710  
 711  711  int
 712  712  iprb_cmd_drain(iprb_t *ip)
 713  713  {
 714  714          for (int i = 1000000; i; i -= 10) {
 715  715                  iprb_cmd_reclaim(ip);
 716  716                  if (ip->cmd_count == 0)
↓ open down ↓ 51 lines elided ↑ open up ↑
 768  768  
 769  769          /*
 770  770           * Finally we can resume the CU.  Note that if this the first
 771  771           * command in the sequence (i.e. if the CU is IDLE), or if the
 772  772           * CU is already busy working, then this CU resume command
 773  773           * will not have any effect.
 774  774           */
 775  775          PUT8(ip, CSR_CMD, CUC_RESUME);
 776  776          (void) GET8(ip, CSR_CMD);       /* flush CSR */
 777  777  
 778      -        ip->tx_wdog = ddi_get_time();
      778 +        ip->tx_wdog = gethrtime();
 779  779          ip->cmd_last = ip->cmd_head;
 780  780          ip->cmd_head++;
 781  781          ip->cmd_head %= NUM_TX;
 782  782          ip->cmd_count++;
 783  783  
 784  784          return (DDI_SUCCESS);
 785  785  }
 786  786  
 787  787  iprb_dma_t *
 788  788  iprb_cmd_next(iprb_t *ip)
↓ open down ↓ 214 lines elided ↑ open up ↑
1003 1003          PUT8(ip, CSR_INTCTL, 0);
1004 1004          (void) GET8(ip, CSR_INTCTL);
1005 1005  
1006 1006          return (DDI_SUCCESS);
1007 1007  }
1008 1008  
1009 1009  void
1010 1010  iprb_update_stats(iprb_t *ip)
1011 1011  {
1012 1012          iprb_dma_t      *sp = &ip->stats;
1013      -        time_t          tstamp;
     1013 +        hrtime_t        tstamp;
1014 1014          int             i;
1015 1015  
1016 1016          ASSERT(mutex_owned(&ip->culock));
1017 1017  
1018 1018          /* Collect the hardware stats, but don't keep redoing it */
1019      -        if ((tstamp = ddi_get_time()) == ip->stats_time) {
     1019 +        tstamp = gethrtime();
     1020 +        if (tstamp / NANOSEC == ip->stats_time / NANOSEC)
1020 1021                  return;
1021      -        }
1022 1022  
1023 1023          PUTSTAT(sp, STATS_DONE_OFFSET, 0);
1024 1024          SYNCSTATS(sp, 0, 0, DDI_DMA_SYNC_FORDEV);
1025 1025  
1026 1026          if (iprb_cmd_ready(ip) != DDI_SUCCESS)
1027 1027                  return;
1028 1028          PUT32(ip, CSR_GEN_PTR, sp->paddr);
1029 1029          PUT8(ip, CSR_CMD, CUC_STATSBASE);
1030 1030          (void) GET8(ip, CSR_CMD);
1031 1031  
↓ open down ↓ 135 lines elided ↑ open up ↑
1167 1167          mplist = NULL;
1168 1168          mpp = &mplist;
1169 1169  
1170 1170          for (i = 0; i < NUM_RX; i++) {
1171 1171                  rfd = &ip->rxb[ip->rx_index];
1172 1172                  SYNCRFD(rfd, RFD_STS_OFFSET, 2, DDI_DMA_SYNC_FORKERNEL);
1173 1173                  if ((GETRFD16(rfd, RFD_STS_OFFSET) & RFD_STS_C) == 0) {
1174 1174                          break;
1175 1175                  }
1176 1176  
1177      -                ip->rx_wdog = ddi_get_time();
     1177 +                ip->rx_wdog = gethrtime();
1178 1178  
1179 1179                  SYNCRFD(rfd, 0, 0, DDI_DMA_SYNC_FORKERNEL);
1180 1180                  cnt = GETRFD16(rfd, RFD_CNT_OFFSET);
1181 1181                  cnt &= ~(RFD_CNT_EOF | RFD_CNT_F);
1182 1182                  sts = GETRFD16(rfd, RFD_STS_OFFSET);
1183 1183  
1184 1184                  if (cnt > (ETHERMAX + VLAN_TAGSZ)) {
1185 1185                          ip->toolong++;
1186 1186                          iprb_rx_add(ip);
1187 1187                          continue;
↓ open down ↓ 468 lines elided ↑ open up ↑
1656 1656                  return;
1657 1657          }
1658 1658  
1659 1659          /*
1660 1660           * If we haven't received a packet in a while, and if the link
1661 1661           * is up, then it might be a hung chip.  This problem
1662 1662           * reportedly only occurs at 10 Mbps.
1663 1663           */
1664 1664          if (ip->rxhangbug &&
1665 1665              ((ip->miih == NULL) || (mii_get_speed(ip->miih) == 10000000)) &&
1666      -            ((ddi_get_time() - ip->rx_wdog) > ip->rx_timeout)) {
     1666 +            ((gethrtime() - ip->rx_wdog) > ip->rx_timeout)) {
1667 1667                  cmn_err(CE_CONT, "?Possible RU hang, resetting.\n");
1668 1668                  reset = B_TRUE;
1669 1669          }
1670 1670  
1671 1671          /* update the statistics */
1672 1672          mutex_enter(&ip->culock);
1673 1673  
1674      -        if (ip->tx_wdog && ((ddi_get_time() - ip->tx_wdog) > ip->tx_timeout)) {
     1674 +        if (ip->tx_wdog && ((gethrtime() - ip->tx_wdog) > ip->tx_timeout)) {
1675 1675                  /* transmit/CU hang? */
1676 1676                  cmn_err(CE_CONT, "?CU stalled, resetting.\n");
1677 1677                  reset = B_TRUE;
1678 1678          }
1679 1679  
1680 1680          if (reset) {
1681 1681                  /* We want to reconfigure */
1682 1682                  iprb_stop(ip);
1683 1683                  if (iprb_start(ip) != DDI_SUCCESS) {
1684 1684                          iprb_error(ip, "unable to restart chip");
↓ open down ↓ 115 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX