ACPI: Lindent processor throttling code
Signed-off-by: Len Brown <len.brown@intel.com>
This commit is contained in:
parent
01854e697a
commit
ff55a9ceba
@ -102,7 +102,8 @@ static int acpi_processor_get_throttling_control(struct acpi_processor *pr)
|
|||||||
if ((obj.type != ACPI_TYPE_BUFFER)
|
if ((obj.type != ACPI_TYPE_BUFFER)
|
||||||
|| (obj.buffer.length < sizeof(struct acpi_ptc_register))
|
|| (obj.buffer.length < sizeof(struct acpi_ptc_register))
|
||||||
|| (obj.buffer.pointer == NULL)) {
|
|| (obj.buffer.pointer == NULL)) {
|
||||||
printk(KERN_ERR PREFIX "Invalid _PTC data (control_register)\n");
|
printk(KERN_ERR PREFIX
|
||||||
|
"Invalid _PTC data (control_register)\n");
|
||||||
result = -EFAULT;
|
result = -EFAULT;
|
||||||
goto end;
|
goto end;
|
||||||
}
|
}
|
||||||
@ -168,7 +169,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
|
|||||||
|
|
||||||
for (i = 0; i < pr->throttling.state_count; i++) {
|
for (i = 0; i < pr->throttling.state_count; i++) {
|
||||||
|
|
||||||
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[i]);
|
struct acpi_processor_tx_tss *tx =
|
||||||
|
(struct acpi_processor_tx_tss *)&(pr->throttling.
|
||||||
|
states_tss[i]);
|
||||||
|
|
||||||
state.length = sizeof(struct acpi_processor_tx_tss);
|
state.length = sizeof(struct acpi_processor_tx_tss);
|
||||||
state.pointer = tx;
|
state.pointer = tx;
|
||||||
@ -266,7 +269,6 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
|
|||||||
u32 duty_mask = 0;
|
u32 duty_mask = 0;
|
||||||
u32 duty_value = 0;
|
u32 duty_value = 0;
|
||||||
|
|
||||||
|
|
||||||
if (!pr)
|
if (!pr)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -306,17 +308,20 @@ static int acpi_processor_get_throttling_fadt(struct acpi_processor *pr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_read_throttling_status(struct acpi_processor_throttling *throttling)
|
static int acpi_read_throttling_status(struct acpi_processor_throttling
|
||||||
|
*throttling)
|
||||||
{
|
{
|
||||||
int value = -1;
|
int value = -1;
|
||||||
switch (throttling->status_register.space_id) {
|
switch (throttling->status_register.space_id) {
|
||||||
case ACPI_ADR_SPACE_SYSTEM_IO:
|
case ACPI_ADR_SPACE_SYSTEM_IO:
|
||||||
acpi_os_read_port((acpi_io_address)throttling->status_register.address,
|
acpi_os_read_port((acpi_io_address) throttling->status_register.
|
||||||
&value,
|
address, &value,
|
||||||
(u32)throttling->status_register.bit_width*8);
|
(u32) throttling->status_register.bit_width *
|
||||||
|
8);
|
||||||
break;
|
break;
|
||||||
case ACPI_ADR_SPACE_FIXED_HARDWARE:
|
case ACPI_ADR_SPACE_FIXED_HARDWARE:
|
||||||
printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n");
|
printk(KERN_ERR PREFIX
|
||||||
|
"HARDWARE addr space,NOT supported yet\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
|
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
|
||||||
@ -325,19 +330,22 @@ static int acpi_read_throttling_status(struct acpi_processor_throttling *throttl
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int acpi_write_throttling_state(struct acpi_processor_throttling *throttling,int value)
|
static int acpi_write_throttling_state(struct acpi_processor_throttling
|
||||||
|
*throttling, int value)
|
||||||
{
|
{
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
|
||||||
switch (throttling->control_register.space_id) {
|
switch (throttling->control_register.space_id) {
|
||||||
case ACPI_ADR_SPACE_SYSTEM_IO:
|
case ACPI_ADR_SPACE_SYSTEM_IO:
|
||||||
acpi_os_write_port((acpi_io_address)throttling->control_register.address,
|
acpi_os_write_port((acpi_io_address) throttling->
|
||||||
value,
|
control_register.address, value,
|
||||||
(u32)throttling->control_register.bit_width*8);
|
(u32) throttling->control_register.
|
||||||
|
bit_width * 8);
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
case ACPI_ADR_SPACE_FIXED_HARDWARE:
|
case ACPI_ADR_SPACE_FIXED_HARDWARE:
|
||||||
printk(KERN_ERR PREFIX "HARDWARE addr space,NOT supported yet\n");
|
printk(KERN_ERR PREFIX
|
||||||
|
"HARDWARE addr space,NOT supported yet\n");
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
|
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
|
||||||
@ -351,7 +359,9 @@ static int acpi_get_throttling_state(struct acpi_processor *pr,int value)
|
|||||||
int i;
|
int i;
|
||||||
|
|
||||||
for (i = 0; i < pr->throttling.state_count; i++) {
|
for (i = 0; i < pr->throttling.state_count; i++) {
|
||||||
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[i]);
|
struct acpi_processor_tx_tss *tx =
|
||||||
|
(struct acpi_processor_tx_tss *)&(pr->throttling.
|
||||||
|
states_tss[i]);
|
||||||
if (tx->control == value)
|
if (tx->control == value)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -364,7 +374,9 @@ static int acpi_get_throttling_value(struct acpi_processor *pr,int state)
|
|||||||
{
|
{
|
||||||
int value = -1;
|
int value = -1;
|
||||||
if (state >= 0 && state <= pr->throttling.state_count) {
|
if (state >= 0 && state <= pr->throttling.state_count) {
|
||||||
struct acpi_processor_tx_tss *tx = (struct acpi_processor_tx_tss *) &(pr->throttling.states_tss[state]);
|
struct acpi_processor_tx_tss *tx =
|
||||||
|
(struct acpi_processor_tx_tss *)&(pr->throttling.
|
||||||
|
states_tss[state]);
|
||||||
value = tx->control;
|
value = tx->control;
|
||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
@ -375,7 +387,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
|
|||||||
int state = 0;
|
int state = 0;
|
||||||
u32 value = 0;
|
u32 value = 0;
|
||||||
|
|
||||||
|
|
||||||
if (!pr)
|
if (!pr)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -394,7 +405,6 @@ static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static int acpi_processor_get_throttling(struct acpi_processor *pr)
|
static int acpi_processor_get_throttling(struct acpi_processor *pr)
|
||||||
{
|
{
|
||||||
return pr->throttling.acpi_processor_get_throttling(pr);
|
return pr->throttling.acpi_processor_get_throttling(pr);
|
||||||
@ -406,7 +416,6 @@ int acpi_processor_set_throttling_fadt(struct acpi_processor *pr, int state)
|
|||||||
u32 duty_mask = 0;
|
u32 duty_mask = 0;
|
||||||
u32 duty_value = 0;
|
u32 duty_value = 0;
|
||||||
|
|
||||||
|
|
||||||
if (!pr)
|
if (!pr)
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
@ -518,7 +527,6 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
|
|||||||
int no_tss = 0;
|
int no_tss = 0;
|
||||||
int no_tsd = 0;
|
int no_tsd = 0;
|
||||||
|
|
||||||
|
|
||||||
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
|
||||||
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
|
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
|
||||||
pr->throttling.address,
|
pr->throttling.address,
|
||||||
@ -534,11 +542,15 @@ int acpi_processor_get_throttling_info(struct acpi_processor *pr)
|
|||||||
no_tsd = acpi_processor_get_tsd(pr);
|
no_tsd = acpi_processor_get_tsd(pr);
|
||||||
|
|
||||||
if (no_ptc || no_tss) {
|
if (no_ptc || no_tss) {
|
||||||
pr->throttling.acpi_processor_get_throttling = &acpi_processor_get_throttling_fadt;
|
pr->throttling.acpi_processor_get_throttling =
|
||||||
pr->throttling.acpi_processor_set_throttling = &acpi_processor_set_throttling_fadt;
|
&acpi_processor_get_throttling_fadt;
|
||||||
|
pr->throttling.acpi_processor_set_throttling =
|
||||||
|
&acpi_processor_set_throttling_fadt;
|
||||||
} else {
|
} else {
|
||||||
pr->throttling.acpi_processor_get_throttling = &acpi_processor_get_throttling_ptc;
|
pr->throttling.acpi_processor_get_throttling =
|
||||||
pr->throttling.acpi_processor_set_throttling = &acpi_processor_set_throttling_ptc;
|
&acpi_processor_get_throttling_ptc;
|
||||||
|
pr->throttling.acpi_processor_set_throttling =
|
||||||
|
&acpi_processor_set_throttling_ptc;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!pr->throttling.address) {
|
if (!pr->throttling.address) {
|
||||||
@ -620,7 +632,6 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
|
|
||||||
if (!pr)
|
if (!pr)
|
||||||
goto end;
|
goto end;
|
||||||
|
|
||||||
@ -655,8 +666,8 @@ static int acpi_processor_throttling_seq_show(struct seq_file *seq,
|
|||||||
for (i = 0; i < pr->throttling.state_count; i++)
|
for (i = 0; i < pr->throttling.state_count; i++)
|
||||||
seq_printf(seq, " %cT%d: %02d%%\n",
|
seq_printf(seq, " %cT%d: %02d%%\n",
|
||||||
(i == pr->throttling.state ? '*' : ' '), i,
|
(i == pr->throttling.state ? '*' : ' '), i,
|
||||||
(int)pr->throttling.states_tss[i].freqpercentage);
|
(int)pr->throttling.states_tss[i].
|
||||||
|
freqpercentage);
|
||||||
|
|
||||||
end:
|
end:
|
||||||
return 0;
|
return 0;
|
||||||
@ -678,7 +689,6 @@ static ssize_t acpi_processor_write_throttling(struct file * file,
|
|||||||
struct acpi_processor *pr = m->private;
|
struct acpi_processor *pr = m->private;
|
||||||
char state_string[12] = { '\0' };
|
char state_string[12] = { '\0' };
|
||||||
|
|
||||||
|
|
||||||
if (!pr || (count > sizeof(state_string) - 1))
|
if (!pr || (count > sizeof(state_string) - 1))
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
|
||||||
|
@ -168,7 +168,8 @@ struct acpi_processor_throttling {
|
|||||||
struct acpi_tsd_package domain_info;
|
struct acpi_tsd_package domain_info;
|
||||||
cpumask_t shared_cpu_map;
|
cpumask_t shared_cpu_map;
|
||||||
int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
|
int (*acpi_processor_get_throttling) (struct acpi_processor * pr);
|
||||||
int (*acpi_processor_set_throttling) (struct acpi_processor *pr, int state);
|
int (*acpi_processor_set_throttling) (struct acpi_processor * pr,
|
||||||
|
int state);
|
||||||
|
|
||||||
u32 address;
|
u32 address;
|
||||||
u8 duty_offset;
|
u8 duty_offset;
|
||||||
@ -207,7 +208,7 @@ struct acpi_processor {
|
|||||||
u32 pblk;
|
u32 pblk;
|
||||||
int performance_platform_limit;
|
int performance_platform_limit;
|
||||||
int throttling_platform_limit;
|
int throttling_platform_limit;
|
||||||
/*0 - states 0..n-th satte available*/
|
/* 0 - states 0..n-th state available */
|
||||||
|
|
||||||
struct acpi_processor_flags flags;
|
struct acpi_processor_flags flags;
|
||||||
struct acpi_processor_power power;
|
struct acpi_processor_power power;
|
||||||
|
Loading…
Reference in New Issue
Block a user