Print this page
4782 usba shouldn't abuse ddi_get_time(9f)
Reviewed by: Robert Mustacchi <rm@joyent.com>
*** 19,28 ****
--- 19,29 ----
* 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,757 ****
/*
* 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 +
hubpm->hubp_min_pm_threshold)) {
return (USB_FAILURE);
}
--- 748,758 ----
/*
* Don't go to lower power if haven't been at full power for enough
* time to let hotplug thread kickoff.
*/
! if (gethrtime() < (hubpm->hubp_time_at_full_power +
hubpm->hubp_min_pm_threshold)) {
return (USB_FAILURE);
}
*** 1718,1728 ****
/* 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();
hubd_start_polling(hubd, 0);
/* FALLTHRU */
case USB_DEV_ONLINE:
/* we are already in full power */
--- 1719,1729 ----
/* 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 = gethrtime();
hubd_start_polling(hubd, 0);
/* FALLTHRU */
case USB_DEV_ONLINE:
/* we are already in full power */
*** 3710,3720 ****
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();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L4(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
"hubd_hotplug_thread: call pm_power_has_changed");
--- 3711,3721 ----
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 = 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,7282 ****
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;
/* alloc memory to save power states of children */
hubpm->hubp_child_pwrstate = (uint8_t *)
kmem_zalloc(MAX_PORTS + 1, KM_SLEEP);
--- 7272,7283 ----
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 = 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,8717 ****
(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();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
"hubd_reset_thread: call pm_power_has_changed");
--- 8708,8718 ----
(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 = gethrtime();
mutex_exit(HUBD_MUTEX(hubd));
USB_DPRINTF_L3(DPRINT_MASK_HOTPLUG, hubd->h_log_handle,
"hubd_reset_thread: call pm_power_has_changed");