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,307 **** (void) GET8(ip, CSR_INTCTL); /* * Precalculate watchdog times. */ ! ip->tx_timeout = drv_usectohz(TX_WATCHDOG * 1000000); ! ip->rx_timeout = drv_usectohz(RX_WATCHDOG * 1000000); iprb_identify(ip); /* Obtain our factory MAC address */ w = iprb_eeprom_read(ip, 0); --- 296,307 ---- (void) GET8(ip, CSR_INTCTL); /* * Precalculate watchdog times. */ ! 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,711 **** ip->cmd_tail %= NUM_TX; ip->cmd_count--; if (ip->cmd_count == 0) { ip->tx_wdog = 0; } else { ! ip->tx_wdog = ddi_get_time(); } } } int --- 701,711 ---- ip->cmd_tail %= NUM_TX; ip->cmd_count--; if (ip->cmd_count == 0) { ip->tx_wdog = 0; } else { ! ip->tx_wdog = gethrtime(); } } } int
*** 773,783 **** * 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->cmd_last = ip->cmd_head; ip->cmd_head++; ip->cmd_head %= NUM_TX; ip->cmd_count++; --- 773,783 ---- * will not have any effect. */ PUT8(ip, CSR_CMD, CUC_RESUME); (void) GET8(ip, CSR_CMD); /* flush CSR */ ! ip->tx_wdog = gethrtime(); ip->cmd_last = ip->cmd_head; ip->cmd_head++; ip->cmd_head %= NUM_TX; ip->cmd_count++;
*** 1008,1026 **** void iprb_update_stats(iprb_t *ip) { iprb_dma_t *sp = &ip->stats; ! time_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) { return; - } PUTSTAT(sp, STATS_DONE_OFFSET, 0); SYNCSTATS(sp, 0, 0, DDI_DMA_SYNC_FORDEV); if (iprb_cmd_ready(ip) != DDI_SUCCESS) --- 1008,1026 ---- void iprb_update_stats(iprb_t *ip) { iprb_dma_t *sp = &ip->stats; ! hrtime_t tstamp; int i; ASSERT(mutex_owned(&ip->culock)); /* Collect the hardware stats, but don't keep redoing it */ ! 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,1182 **** 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(); 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); --- 1172,1182 ---- SYNCRFD(rfd, RFD_STS_OFFSET, 2, DDI_DMA_SYNC_FORKERNEL); if ((GETRFD16(rfd, RFD_STS_OFFSET) & RFD_STS_C) == 0) { break; } ! 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,1679 **** * 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)) { 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)) { /* transmit/CU hang? */ cmn_err(CE_CONT, "?CU stalled, resetting.\n"); reset = B_TRUE; } --- 1661,1679 ---- * 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)) && ! ((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 && ((gethrtime() - ip->tx_wdog) > ip->tx_timeout)) { /* transmit/CU hang? */ cmn_err(CE_CONT, "?CU stalled, resetting.\n"); reset = B_TRUE; }