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>

@@ -296,12 +296,12 @@
         (void) GET8(ip, CSR_INTCTL);
 
         /*
          * Precalculate watchdog times.
          */
-        ip->tx_timeout = drv_usectohz(TX_WATCHDOG * 1000000);
-        ip->rx_timeout = drv_usectohz(RX_WATCHDOG * 1000000);
+        ip->tx_timeout = TX_WATCHDOG;
+        ip->rx_timeout = RX_WATCHDOG;
 
         iprb_identify(ip);
 
         /* Obtain our factory MAC address */
         w = iprb_eeprom_read(ip, 0);

@@ -701,11 +701,11 @@
                 ip->cmd_tail %= NUM_TX;
                 ip->cmd_count--;
                 if (ip->cmd_count == 0) {
                         ip->tx_wdog = 0;
                 } else {
-                        ip->tx_wdog = ddi_get_time();
+                        ip->tx_wdog = gethrtime();
                 }
         }
 }
 
 int

@@ -773,11 +773,11 @@
          * will not have any effect.
          */
         PUT8(ip, CSR_CMD, CUC_RESUME);
         (void) GET8(ip, CSR_CMD);       /* flush CSR */
 
-        ip->tx_wdog = ddi_get_time();
+        ip->tx_wdog = gethrtime();
         ip->cmd_last = ip->cmd_head;
         ip->cmd_head++;
         ip->cmd_head %= NUM_TX;
         ip->cmd_count++;
 

@@ -1008,19 +1008,19 @@
 
 void
 iprb_update_stats(iprb_t *ip)
 {
         iprb_dma_t      *sp = &ip->stats;
-        time_t          tstamp;
+        hrtime_t        tstamp;
         int             i;
 
         ASSERT(mutex_owned(&ip->culock));
 
         /* Collect the hardware stats, but don't keep redoing it */
-        if ((tstamp = ddi_get_time()) == ip->stats_time) {
+        tstamp = gethrtime();
+        if (tstamp / NANOSEC == ip->stats_time / NANOSEC)
                 return;
-        }
 
         PUTSTAT(sp, STATS_DONE_OFFSET, 0);
         SYNCSTATS(sp, 0, 0, DDI_DMA_SYNC_FORDEV);
 
         if (iprb_cmd_ready(ip) != DDI_SUCCESS)

@@ -1172,11 +1172,11 @@
                 SYNCRFD(rfd, RFD_STS_OFFSET, 2, DDI_DMA_SYNC_FORKERNEL);
                 if ((GETRFD16(rfd, RFD_STS_OFFSET) & RFD_STS_C) == 0) {
                         break;
                 }
 
-                ip->rx_wdog = ddi_get_time();
+                ip->rx_wdog = gethrtime();
 
                 SYNCRFD(rfd, 0, 0, DDI_DMA_SYNC_FORKERNEL);
                 cnt = GETRFD16(rfd, RFD_CNT_OFFSET);
                 cnt &= ~(RFD_CNT_EOF | RFD_CNT_F);
                 sts = GETRFD16(rfd, RFD_STS_OFFSET);

@@ -1661,19 +1661,19 @@
          * is up, then it might be a hung chip.  This problem
          * reportedly only occurs at 10 Mbps.
          */
         if (ip->rxhangbug &&
             ((ip->miih == NULL) || (mii_get_speed(ip->miih) == 10000000)) &&
-            ((ddi_get_time() - ip->rx_wdog) > ip->rx_timeout)) {
+            ((gethrtime() - ip->rx_wdog) > ip->rx_timeout)) {
                 cmn_err(CE_CONT, "?Possible RU hang, resetting.\n");
                 reset = B_TRUE;
         }
 
         /* update the statistics */
         mutex_enter(&ip->culock);
 
-        if (ip->tx_wdog && ((ddi_get_time() - ip->tx_wdog) > ip->tx_timeout)) {
+        if (ip->tx_wdog && ((gethrtime() - ip->tx_wdog) > ip->tx_timeout)) {
                 /* transmit/CU hang? */
                 cmn_err(CE_CONT, "?CU stalled, resetting.\n");
                 reset = B_TRUE;
         }