Print this page
4782 usba shouldn't abuse ddi_get_time(9f)
Reviewed by: Robert Mustacchi <rm@joyent.com>
@@ -19,10 +19,11 @@
* CDDL HEADER END
*/
/*
* Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
+ * Copyright 2014 Nexenta Systems, Inc. All rights reserved.
*/
/*
* USBA: Solaris USB Architecture support for the hub
* including root hub
@@ -747,11 +748,11 @@
/*
* Don't go to lower power if haven't been at full power for enough
* time to let hotplug thread kickoff.
*/
- if (ddi_get_time() < (hubpm->hubp_time_at_full_power +
+ if (gethrtime() < (hubpm->hubp_time_at_full_power +
hubpm->hubp_min_pm_threshold)) {
return (USB_FAILURE);
}
@@ -1718,11 +1719,11 @@
/* Issue USB D0 command to the device here */
rval = usb_set_device_pwrlvl0(hubd->h_dip);
ASSERT(rval == USB_SUCCESS);
hubd->h_dev_state = USB_DEV_ONLINE;
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
hubd_start_polling(hubd, 0);
/* FALLTHRU */
case USB_DEV_ONLINE:
/* we are already in full power */
@@ -3710,11 +3711,11 @@
if (hubd->h_dev_state == USB_DEV_PWRED_DOWN) {
hubpm = hubd->h_hubpm;
/* mark the root hub as full power */
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
"hubd_hotplug_thread: call pm_power_has_changed");
@@ -7271,12 +7272,12 @@
hubd->h_hubpm = hubpm;
hubpm->hubp_hubd = hubd;
hubpm->hubp_pm_capabilities = 0;
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
- hubpm->hubp_min_pm_threshold = hubdi_min_pm_threshold;
+ hubpm->hubp_time_at_full_power = gethrtime();
+ hubpm->hubp_min_pm_threshold = hubdi_min_pm_threshold * NANOSEC;
/* alloc memory to save power states of children */
hubpm->hubp_child_pwrstate = (uint8_t *)
kmem_zalloc(MAX_PORTS + 1, KM_SLEEP);
@@ -8707,11 +8708,11 @@
(hubd->h_dev_state == USB_DEV_PWRED_DOWN)) {
hubpm = hubd->h_hubpm;
/* mark the root hub as full power */
hubpm->hubp_current_power = USB_DEV_OS_FULL_PWR;
- hubpm->hubp_time_at_full_power = ddi_get_time();
+ hubpm->hubp_time_at_full_power = gethrtime();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
"hubd_reset_thread: call pm_power_has_changed");