sunpm.c (9681b4a1) | sunpm.c (5cff7825) |
---|---|
1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 301 unchanged lines hidden (view full) --- 310 311clock_t pm_min_scan = PM_MIN_SCAN; 312clock_t pm_id_ticks = 5; /* ticks to wait before scan during idle-down */ 313 314static int pm_busop_set_power(dev_info_t *, 315 void *, pm_bus_power_op_t, void *, void *); 316static int pm_busop_match_request(dev_info_t *, void *); 317static int pm_all_to_normal_nexus(dev_info_t *, pm_canblock_t); | 1/* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License (the "License"). 6 * You may not use this file except in compliance with the License. 7 * 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE --- 301 unchanged lines hidden (view full) --- 310 311clock_t pm_min_scan = PM_MIN_SCAN; 312clock_t pm_id_ticks = 5; /* ticks to wait before scan during idle-down */ 313 314static int pm_busop_set_power(dev_info_t *, 315 void *, pm_bus_power_op_t, void *, void *); 316static int pm_busop_match_request(dev_info_t *, void *); 317static int pm_all_to_normal_nexus(dev_info_t *, pm_canblock_t); |
318static void e_pm_set_max_power(dev_info_t *, int, int); 319static int e_pm_get_max_power(dev_info_t *, int); |
|
318 319/* 320 * Dependency Processing is done thru a seperate thread. 321 */ 322kmutex_t pm_dep_thread_lock; 323kcondvar_t pm_dep_thread_cv; 324pm_dep_wk_t *pm_dep_thread_workq = NULL; 325pm_dep_wk_t *pm_dep_thread_tail = NULL; --- 3246 unchanged lines hidden (view full) --- 3572 pwrndx--; 3573 ASSERT(pwrndx >= 0); 3574 nxt_pwr = cp->pmc_comp.pmc_lvals[pwrndx]; 3575 } 3576 return (nxt_pwr); 3577} 3578 3579/* | 320 321/* 322 * Dependency Processing is done thru a seperate thread. 323 */ 324kmutex_t pm_dep_thread_lock; 325kcondvar_t pm_dep_thread_cv; 326pm_dep_wk_t *pm_dep_thread_workq = NULL; 327pm_dep_wk_t *pm_dep_thread_tail = NULL; --- 3246 unchanged lines hidden (view full) --- 3574 pwrndx--; 3575 ASSERT(pwrndx >= 0); 3576 nxt_pwr = cp->pmc_comp.pmc_lvals[pwrndx]; 3577 } 3578 return (nxt_pwr); 3579} 3580 3581/* |
3582 * Update the maxpower (normal) power of a component. Note that the 3583 * component's power level is only changed if it's current power level 3584 * is higher than the new max power. 3585 */ 3586int 3587pm_update_maxpower(dev_info_t *dip, int comp, int level) 3588{ 3589 PMD_FUNC(pmf, "update_maxpower") 3590 int old; 3591 int result; 3592 3593 if (!e_pm_valid_info(dip, NULL) || !e_pm_valid_comp(dip, comp, NULL) || 3594 !e_pm_valid_power(dip, comp, level)) { 3595 PMD(PMD_FAIL, ("%s: validation checks failed for %s@%s(%s#%d) " 3596 "comp=%d level=%d\n", pmf, PM_DEVICE(dip), comp, level)) 3597 return (DDI_FAILURE); 3598 } 3599 old = e_pm_get_max_power(dip, comp); 3600 e_pm_set_max_power(dip, comp, level); 3601 3602 if (pm_set_power(dip, comp, level, PM_LEVEL_DOWNONLY, 3603 PM_CANBLOCK_BLOCK, 0, &result) != DDI_SUCCESS) { 3604 e_pm_set_max_power(dip, comp, old); 3605 PMD(PMD_FAIL, ("%s: %s@%s(%s#%d) pm_set_power failed\n", pmf, 3606 PM_DEVICE(dip))) 3607 return (DDI_FAILURE); 3608 } 3609 return (DDI_SUCCESS); 3610} 3611 3612/* |
|
3580 * Bring all components of device to normal power 3581 */ 3582int 3583pm_all_to_normal(dev_info_t *dip, pm_canblock_t canblock) 3584{ 3585 PMD_FUNC(pmf, "all_to_normal") 3586 int *normal; 3587 int i, ncomps, result; --- 279 unchanged lines hidden (view full) --- 3867 */ 3868static void 3869e_pm_set_max_power(dev_info_t *dip, int component_number, int level) 3870{ 3871 PM_CP(dip, component_number)->pmc_norm_pwr = level; 3872} 3873 3874/* | 3613 * Bring all components of device to normal power 3614 */ 3615int 3616pm_all_to_normal(dev_info_t *dip, pm_canblock_t canblock) 3617{ 3618 PMD_FUNC(pmf, "all_to_normal") 3619 int *normal; 3620 int i, ncomps, result; --- 279 unchanged lines hidden (view full) --- 3900 */ 3901static void 3902e_pm_set_max_power(dev_info_t *dip, int component_number, int level) 3903{ 3904 PM_CP(dip, component_number)->pmc_norm_pwr = level; 3905} 3906 3907/* |
3908 * Get max (previously documented as "normal") power. 3909 */ 3910static int 3911e_pm_get_max_power(dev_info_t *dip, int component_number) 3912{ 3913 return (PM_CP(dip, component_number)->pmc_norm_pwr); 3914} 3915 3916/* |
|
3875 * Internal routine for destroying components 3876 * It is called even when there might not be any, so it must be forgiving. 3877 */ 3878static void 3879e_pm_destroy_components(dev_info_t *dip) 3880{ 3881 int i; 3882 struct pm_component *cp; --- 4681 unchanged lines hidden (view full) --- 8564 /* 8565 * Since we don't know what the actual power level is, 8566 * we place a power hold on the parent no matter what 8567 * component and level is changing. 8568 */ 8569 pm_hold_power(pdip); 8570 } 8571 PM_LOCK_POWER(dip, &circ); | 3917 * Internal routine for destroying components 3918 * It is called even when there might not be any, so it must be forgiving. 3919 */ 3920static void 3921e_pm_destroy_components(dev_info_t *dip) 3922{ 3923 int i; 3924 struct pm_component *cp; --- 4681 unchanged lines hidden (view full) --- 8606 /* 8607 * Since we don't know what the actual power level is, 8608 * we place a power hold on the parent no matter what 8609 * component and level is changing. 8610 */ 8611 pm_hold_power(pdip); 8612 } 8613 PM_LOCK_POWER(dip, &circ); |
8614 /* 8615 * It's possible that a call was made to pm_update_maxpower() 8616 * on another thread before we took the lock above. So, we need to 8617 * make sure that this request isn't processed after the 8618 * change of power executed on behalf of pm_update_maxpower(). 8619 */ 8620 if (nlevel > pm_get_normal_power(dip, comp)) { 8621 PMD(PMD_SET, ("%s: requested level is higher than normal.\n", 8622 pmf)) 8623 ret = DDI_FAILURE; 8624 *iresp = DDI_FAILURE; 8625 goto post_notify; 8626 } |
|
8572 clevel = PM_CURPOWER(dip, comp); 8573 PMD(PMD_SET, ("%s: %s@%s(%s#%d), cmp=%d, olvl=%d, nlvl=%d, clvl=%d, " 8574 "dir=%s\n", pmf, PM_DEVICE(dip), comp, bpc->bpc_olevel, nlevel, 8575 clevel, dir)) 8576 switch (direction) { 8577 case PM_LEVEL_UPONLY: 8578 /* Powering up */ 8579 if (clevel >= nlevel) { --- 531 unchanged lines hidden --- | 8627 clevel = PM_CURPOWER(dip, comp); 8628 PMD(PMD_SET, ("%s: %s@%s(%s#%d), cmp=%d, olvl=%d, nlvl=%d, clvl=%d, " 8629 "dir=%s\n", pmf, PM_DEVICE(dip), comp, bpc->bpc_olevel, nlevel, 8630 clevel, dir)) 8631 switch (direction) { 8632 case PM_LEVEL_UPONLY: 8633 /* Powering up */ 8634 if (clevel >= nlevel) { --- 531 unchanged lines hidden --- |