Skip to content

Commit

Permalink
Merge branches 'pm-cpuidle' and 'acpica' into linux-next
Browse files Browse the repository at this point in the history
* pm-cpuidle:
  cpuidle: teo: Rename two local variables in teo_select()
  cpuidle: teo: Fix alternative idle state lookup

* acpica:
  Revert "ACPICA: Fix memory leak caused by _CID repair function"
  • Loading branch information
rafaeljw committed Aug 4, 2021
3 parents 392ac3e + 4adae7d + 6511a8b commit 197da54
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 24 deletions.
7 changes: 0 additions & 7 deletions drivers/acpi/acpica/nsrepair2.c
Original file line number Diff line number Diff line change
Expand Up @@ -379,13 +379,6 @@ acpi_ns_repair_CID(struct acpi_evaluate_info *info,

(*element_ptr)->common.reference_count =
original_ref_count;

/*
* The original_element holds a reference from the package object
* that represents _HID. Since a new element was created by _HID,
* remove the reference from the _CID package.
*/
acpi_ut_remove_reference(original_element);
}

element_ptr++;
Expand Down
48 changes: 31 additions & 17 deletions drivers/cpuidle/governors/teo.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,8 +382,8 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
alt_intercepts = 2 * idx_intercept_sum > cpu_data->total - idx_hit_sum;
alt_recent = idx_recent_sum > NR_RECENT / 2;
if (alt_recent || alt_intercepts) {
s64 last_enabled_span_ns = duration_ns;
int last_enabled_idx = idx;
s64 first_suitable_span_ns = duration_ns;
int first_suitable_idx = idx;

/*
* Look for the deepest idle state whose target residency had
Expand All @@ -397,37 +397,51 @@ static int teo_select(struct cpuidle_driver *drv, struct cpuidle_device *dev,
intercept_sum = 0;
recent_sum = 0;

for (i = idx - 1; i >= idx0; i--) {
for (i = idx - 1; i >= 0; i--) {
struct teo_bin *bin = &cpu_data->state_bins[i];
s64 span_ns;

intercept_sum += bin->intercepts;
recent_sum += bin->recent;

span_ns = teo_middle_of_bin(i, drv);

if ((!alt_recent || 2 * recent_sum > idx_recent_sum) &&
(!alt_intercepts ||
2 * intercept_sum > idx_intercept_sum)) {
if (teo_time_ok(span_ns) &&
!dev->states_usage[i].disable) {
idx = i;
duration_ns = span_ns;
} else {
/*
* The current state is too shallow or
* disabled, so take the first enabled
* deeper state with suitable time span.
*/
idx = first_suitable_idx;
duration_ns = first_suitable_span_ns;
}
break;
}

if (dev->states_usage[i].disable)
continue;

span_ns = teo_middle_of_bin(i, drv);
if (!teo_time_ok(span_ns)) {
/*
* The current state is too shallow, so select
* the first enabled deeper state.
* The current state is too shallow, but if an
* alternative candidate state has been found,
* it may still turn out to be a better choice.
*/
duration_ns = last_enabled_span_ns;
idx = last_enabled_idx;
break;
}
if (first_suitable_idx != idx)
continue;

if ((!alt_recent || 2 * recent_sum > idx_recent_sum) &&
(!alt_intercepts ||
2 * intercept_sum > idx_intercept_sum)) {
idx = i;
duration_ns = span_ns;
break;
}

last_enabled_span_ns = span_ns;
last_enabled_idx = i;
first_suitable_span_ns = span_ns;
first_suitable_idx = i;
}
}

Expand Down

0 comments on commit 197da54

Please sign in to comment.