Lines Matching +defs:level +defs:list
11 * notice, this list of conditions and the following disclaimer.
13 * notice, this list of conditions and the following disclaimer in the
62 struct cf_level level;
104 static int cf_set_method(device_t dev, const struct cf_level *level,
106 static int cf_get_method(device_t dev, struct cf_level *level);
239 cf_set_method(device_t dev, const struct cf_level *level, int priority)
254 EVENTHANDLER_INVOKE(cpufreq_pre_change, level, &error);
256 EVENTHANDLER_INVOKE(cpufreq_post_change, level, error);
282 * If the requested level has a lower priority, don't allow
283 * the new level right now.
293 * If the caller didn't specify a level and one is saved, prepare to
294 * restore the saved level. If none has been saved, return an error.
296 if (level == NULL) {
299 CF_DEBUG("NULL level, no saved level\n");
303 level = &saved_freq->level;
305 CF_DEBUG("restoring saved level, freq %d prio %d\n",
306 level->total_set.freq, priority);
310 if (level->total_set.freq < cf_lowest_freq) {
312 level->total_set.freq, cf_lowest_freq);
317 /* If already at this level, just return. */
318 if (sc->curr_level.total_set.freq == level->total_set.freq) {
319 CF_DEBUG("skipping freq %d, same as current level %d\n",
320 level->total_set.freq, sc->curr_level.total_set.freq);
325 set = &level->abs_set;
358 for (i = 0; i < level->rel_count; i++) {
359 set = &level->rel_set[i];
387 * Before recording the current level, check if we're going to a
388 * higher priority. If so, save the previous level and priority.
392 CF_DEBUG("saving level, freq %d prio %d\n",
399 curr_freq->level = sc->curr_level;
403 sc->curr_level = *level;
408 CF_DEBUG("resetting saved level\n");
421 EVENTHANDLER_INVOKE(cpufreq_post_change, level, error);
455 * Used by the cpufreq core, this function will populate *level with the current
457 * case the lower level driver has set the CPUFREQ_FLAG_UNCACHED flag, it will
461 cf_get_method(device_t dev, struct cf_level *level)
503 * We need to figure out the current level. Loop through every
505 * match of settings against each level.
520 * Reacquire the lock and search for the given level.
523 * through each level and compare both absolute and relative
532 CF_DEBUG("Couldn't find supported level for %s\n",
542 * match against a level.
563 *level = sc->curr_level;
572 * Either directly obtain settings from the cpufreq driver, or build a list of
690 /* Create a combined list of absolute + relative levels. */
701 /* Finally, output the list of levels. */
734 * sorted order in the specified list.
740 struct cf_level_lst *list;
741 struct cf_level *level, *search;
746 list = &sc->all_levels;
748 level = malloc(sizeof(*level), M_TEMP, M_NOWAIT | M_ZERO);
749 if (level == NULL)
751 level->abs_set = sets[i];
752 level->total_set = sets[i];
753 level->total_set.dev = NULL;
757 if (TAILQ_EMPTY(list)) {
760 TAILQ_INSERT_HEAD(list, level, link);
764 TAILQ_FOREACH_REVERSE(search, list, cf_level_lst, link)
768 TAILQ_INSERT_AFTER(list, search, level, link);
774 TAILQ_FOREACH(search, list, link)
778 TAILQ_INSERT_BEFORE(search, level, link);
803 * For instance, a level of 50 Mhz derived from 100 Mhz + 50% is
808 /* Add each setting to the level, duplicating if necessary. */
813 * If this setting is less than 100%, split the level
814 * into two and add this setting to the new level.
821 * The new level was a duplicate of an existing
822 * level or its absolute setting is too high
824 * derived level of 1000 MHz/25% if a level
831 /* Add this setting to the existing or new level. */
838 "expand set added rel setting %d%% to %d level\n",
850 struct cf_level_lst *list;
858 * Create a new level, copy it from the old one, and update the
882 * If we copied an old level that we already modified (say, at 100%),
896 * Insert the new level in sorted order. If it is a duplicate of an
897 * existing level (1) or has an absolute setting higher than the
898 * existing level (2), do not add it. We can do this since any such
899 * level is guaranteed use less power. For example (1), a level with
902 * Also for example (2), a level of 800 Mhz/75% is preferable to
905 list = &sc->all_levels;
906 KASSERT(!TAILQ_EMPTY(list), ("all levels list empty in dup set"));
907 TAILQ_FOREACH_REVERSE(itr, list, cf_level_lst, link) {
917 "dup done, inserting new level %d after %d\n",
919 TAILQ_INSERT_AFTER(list, itr, fill, link);
930 /* We didn't find a good place for this new level so free it. */
932 CF_DEBUG("dup set freeing new level %d (not optimal)\n",