diff --git a/drivers/acpi/cppc_acpi.c b/drivers/acpi/cppc_acpi.c index 05a547bbe936..b4cf93dec18b 100644 --- a/drivers/acpi/cppc_acpi.c +++ b/drivers/acpi/cppc_acpi.c @@ -2081,6 +2081,15 @@ int acpi_cppc_processor_probe(struct acpi_processor *pr) cpc_apply_platform_quirks(gas_t, i - 2, platform_quirks); + /* EPP interfaces require the full 0-255 preference range. */ + if (i - 2 == ENERGY_PERF && gas_t->bit_width < 8 && + !IS_NULL_REG(gas_t)) { + pr_debug("CPU%d: EPP register width %u is not supported\n", + pr->id, gas_t->bit_width); + ret = -EOPNOTSUPP; + goto out_free; + } + /* * The PCC Subspace index is encoded inside * the CPC table entries. The same PCC index @@ -2940,9 +2949,9 @@ int cppc_get_perf_caps(int cpunum, struct cppc_perf_caps *perf_caps) if (!high || !low || !nom || !ref || !min_nonlinear || high > U32_MAX || low > U32_MAX || guaranteed > U32_MAX || nom > U32_MAX || ref > U32_MAX || min_nonlinear > U32_MAX || - high < nom || nom < min_nonlinear || min_nonlinear < low || + high < min_nonlinear || min_nonlinear < low || (CPC_SUPPORTED(guaranteed_reg) && - (guaranteed < low || guaranteed > nom))) { + (guaranteed < low || guaranteed > high))) { ret = -EFAULT; goto out_err; } diff --git a/drivers/acpi/device_pm.c b/drivers/acpi/device_pm.c index 76104f715efa..d975700936e8 100644 --- a/drivers/acpi/device_pm.c +++ b/drivers/acpi/device_pm.c @@ -365,14 +365,25 @@ int acpi_bus_init_power(struct acpi_device *device) * fails, ACPI power management will not be used for the device going * forward. */ - result = acpi_device_init_power(device); - if (result) { - device->flags.power_manageable = 0; - device->power.state = ACPI_D_STATE_INVALID; - acpi_handle_info(device->handle, - "Initial power state undetermined, ACPI PM disabled\n"); + if (!acpi_device_is_present(device)) { + acpi_handle_debug(device->handle, + "Device not present, ACPI PM disabled\n"); + result = -ENXIO; + goto fail; } + result = acpi_device_init_power(device); + if (result) { + acpi_handle_info(device->handle, + "Initial power state undetermined, ACPI PM disabled\n"); + goto fail; + } + + return 0; + +fail: + device->flags.power_manageable = 0; + device->power.state = ACPI_D_STATE_INVALID; return result; } diff --git a/drivers/acpi/glue.c b/drivers/acpi/glue.c index 0959f58cb77c..4e8616d2e5c8 100644 --- a/drivers/acpi/glue.c +++ b/drivers/acpi/glue.c @@ -108,14 +108,10 @@ static bool acpi_dev_has_children(struct acpi_device *adev) static int find_child_checks(struct acpi_device *adev, bool check_children) { - unsigned long long sta; - acpi_status status; - if (check_children && !acpi_dev_has_children(adev)) return -ENODEV; - status = acpi_evaluate_integer(adev->handle, "_STA", NULL, &sta); - if (status == AE_NOT_FOUND) { + if (!acpi_has_method(adev->handle, METHOD_NAME__STA)) { /* * Special case: backlight device objects without _STA are * preferred to other objects with the same _ADR value, because @@ -127,7 +123,7 @@ static int find_child_checks(struct acpi_device *adev, bool check_children) return FIND_CHILD_MIN_SCORE; } - if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_ENABLED)) + if (!acpi_device_is_present(adev)) return -ENODEV; /* diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 957fa7775260..b2af24ae5008 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c @@ -714,7 +714,17 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) pr_debug("Unsupported CPU co-ord type: %d\n", policy->shared_type); ret = -EFAULT; - goto out; + goto out_put; + } + + /* + * Enable CPPC. The Enable register is optional - some platforms + * may not support it. + */ + ret = cppc_set_enable(cpu, true); + if (ret && ret != -EOPNOTSUPP) { + pr_err("Failed to enable CPPC for CPU%u (%d)\n", cpu, ret); + goto out_put; } policy->fast_switch_possible = cppc_allow_fast_switch(policy->cpus); @@ -742,6 +752,8 @@ static int cppc_cpufreq_cpu_init(struct cpufreq_policy *policy) return 0; out: + cppc_set_enable(cpu, false); +out_put: cppc_cpufreq_put_cpu_data(policy); return ret; } diff --git a/drivers/cpufreq/cpufreq.c b/drivers/cpufreq/cpufreq.c index 24319b214d7b..4332cb114070 100644 --- a/drivers/cpufreq/cpufreq.c +++ b/drivers/cpufreq/cpufreq.c @@ -2452,6 +2452,14 @@ int cpufreq_driver_target(struct cpufreq_policy *policy, { guard(cpufreq_policy_write)(policy); + /* + * The last CPU in the policy may have gone offline after the caller + * obtained it, in which case the policy is inactive and must not be + * used for changing the frequency. + */ + if (unlikely(policy_is_inactive(policy))) + return -EBUSY; + return __cpufreq_driver_target(policy, target_freq, relation); } EXPORT_SYMBOL_GPL(cpufreq_driver_target);