···238238239239#endif240240241241-int acpi_processor_set_thermal_limit(acpi_handle handle, int type)242242-{243243- int result = 0;244244- struct acpi_processor *pr = NULL;245245- struct acpi_device *device = NULL;246246- int tx = 0, max_tx_px = 0;247247-248248-249249- if ((type < ACPI_PROCESSOR_LIMIT_NONE)250250- || (type > ACPI_PROCESSOR_LIMIT_DECREMENT))251251- return -EINVAL;252252-253253- result = acpi_bus_get_device(handle, &device);254254- if (result)255255- return result;256256-257257- pr = acpi_driver_data(device);258258- if (!pr)259259- return -ENODEV;260260-261261- /* Thermal limits are always relative to the current Px/Tx state. */262262- if (pr->flags.throttling)263263- pr->limit.thermal.tx = pr->throttling.state;264264-265265- /*266266- * Our default policy is to only use throttling at the lowest267267- * performance state.268268- */269269-270270- tx = pr->limit.thermal.tx;271271-272272- switch (type) {273273-274274- case ACPI_PROCESSOR_LIMIT_NONE:275275- do {276276- result = acpi_thermal_cpufreq_decrease(pr->id);277277- } while (!result);278278- tx = 0;279279- break;280280-281281- case ACPI_PROCESSOR_LIMIT_INCREMENT:282282- /* if going up: P-states first, T-states later */283283-284284- result = acpi_thermal_cpufreq_increase(pr->id);285285- if (!result)286286- goto end;287287- else if (result == -ERANGE)288288- ACPI_DEBUG_PRINT((ACPI_DB_INFO,289289- "At maximum performance state\n"));290290-291291- if (pr->flags.throttling) {292292- if (tx == (pr->throttling.state_count - 1))293293- ACPI_DEBUG_PRINT((ACPI_DB_INFO,294294- "At maximum throttling state\n"));295295- else296296- tx++;297297- }298298- break;299299-300300- case ACPI_PROCESSOR_LIMIT_DECREMENT:301301- /* if going down: T-states first, P-states later */302302-303303- if (pr->flags.throttling) {304304- if (tx == 0) {305305- max_tx_px = 1;306306- ACPI_DEBUG_PRINT((ACPI_DB_INFO,307307- "At minimum throttling state\n"));308308- } else {309309- tx--;310310- goto end;311311- }312312- }313313-314314- result = acpi_thermal_cpufreq_decrease(pr->id);315315- if (result) {316316- /*317317- * We only could get -ERANGE, 1 or 0.318318- * In the first two cases we reached max freq again.319319- */320320- ACPI_DEBUG_PRINT((ACPI_DB_INFO,321321- "At minimum performance state\n"));322322- max_tx_px = 1;323323- } else324324- max_tx_px = 0;325325-326326- break;327327- }328328-329329- end:330330- if (pr->flags.throttling) {331331- pr->limit.thermal.px = 0;332332- pr->limit.thermal.tx = tx;333333-334334- result = acpi_processor_apply_limit(pr);335335- if (result)336336- printk(KERN_ERR PREFIX "Unable to set thermal limit\n");337337-338338- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Thermal limit now (P%d:T%d)\n",339339- pr->limit.thermal.px, pr->limit.thermal.tx));340340- } else341341- result = 0;342342- if (max_tx_px)343343- return 1;344344- else345345- return result;346346-}347347-348241int acpi_processor_get_limit_info(struct acpi_processor *pr)349242{350243
-2
include/acpi/acpi_drivers.h
···115115#define ACPI_PROCESSOR_LIMIT_INCREMENT 0x01116116#define ACPI_PROCESSOR_LIMIT_DECREMENT 0x02117117118118-int acpi_processor_set_thermal_limit(acpi_handle handle, int type);119119-120118/*--------------------------------------------------------------------------121119 Dock Station122120 -------------------------------------------------------------------------- */