* [PATCH] ACPI:avoid printing the error message that processor device is not present
@ 2007-10-08 3:35 Zhao Yakui
2007-10-10 3:43 ` Len Brown
0 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2007-10-08 3:35 UTC (permalink / raw)
To: lenb; +Cc: Linux-acpi
Subject: ACPI: avoid printing the info that processor device is not present
From: Zhao Yakui <yakui.zhao@intel.com>
Four processors are defined in the DSDT table, which means that quad-core cpu
is supported. But dual-core cpu is installed on the system. In the
initialization OS will check whether the defined processor exists. If it
doesn't exist, it will print the info that processor device is not present.
The above error message has no effect on the system but it will mislead us.
So it is unnecessary to print the error message when disabling acpi debug.
http://bugzilla.kernel.org/show_bug.cgi?id=8630
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/acpi/processor_core.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
Index: linux-2.6.23-rc7/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.23-rc7.orig/drivers/acpi/processor_core.c
+++ linux-2.6.23-rc7/drivers/acpi/processor_core.c
@@ -813,7 +813,9 @@ static int is_processor_present(acpi_han
status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) {
- ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "%s :Processor Device is not present",
+ acpi_format_exception(status)));
return 0;
}
return 1;
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] ACPI:avoid printing the error message that processor device is not present
2007-10-08 3:35 [PATCH] ACPI:avoid printing the error message that processor device is not present Zhao Yakui
@ 2007-10-10 3:43 ` Len Brown
2007-10-15 1:19 ` Zhao Yakui
` (23 more replies)
0 siblings, 24 replies; 33+ messages in thread
From: Len Brown @ 2007-10-10 3:43 UTC (permalink / raw)
To: Zhao Yakui; +Cc: Linux-acpi
On Sunday 07 October 2007 23:35, Zhao Yakui wrote:
> Subject: ACPI: avoid printing the info that processor device is not present
> From: Zhao Yakui <yakui.zhao@intel.com>
>
> Four processors are defined in the DSDT table, which means that quad-core cpu
> is supported. But dual-core cpu is installed on the system. In the
> initialization OS will check whether the defined processor exists. If it
> doesn't exist, it will print the info that processor device is not present.
> The above error message has no effect on the system but it will mislead us.
> So it is unnecessary to print the error message when disabling acpi debug.
SuSE ships with ACPI_DEBUG enabled by default.
Can we get smarter about this -- say by checking against
the processors that we expect to be present?
thanks,
-Len
> http://bugzilla.kernel.org/show_bug.cgi?id=8630
>
> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> ---
> drivers/acpi/processor_core.c | 4 +++-
> 1 file changed, 3 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.23-rc7/drivers/acpi/processor_core.c
> ===================================================================
> --- linux-2.6.23-rc7.orig/drivers/acpi/processor_core.c
> +++ linux-2.6.23-rc7/drivers/acpi/processor_core.c
> @@ -813,7 +813,9 @@ static int is_processor_present(acpi_han
>
> status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
> if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) {
> - ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
> + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> + "%s :Processor Device is not present",
> + acpi_format_exception(status)));
> return 0;
> }
> return 1;
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH] ACPI:avoid printing the error message that processor device is not present
2007-10-10 3:43 ` Len Brown
@ 2007-10-15 1:19 ` Zhao Yakui
2007-11-07 12:34 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
` (22 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-10-15 1:19 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
On Tue, 2007-10-09 at 23:43 -0400, Len Brown wrote:
> On Sunday 07 October 2007 23:35, Zhao Yakui wrote:
> > Subject: ACPI: avoid printing the info that processor device is not present
> > From: Zhao Yakui <yakui.zhao@intel.com>
> >
> > Four processors are defined in the DSDT table, which means that quad-core cpu
> > is supported. But dual-core cpu is installed on the system. In the
> > initialization OS will check whether the defined processor exists. If it
> > doesn't exist, it will print the info that processor device is not present.
> > The above error message has no effect on the system but it will mislead us.
> > So it is unnecessary to print the error message when disabling acpi debug.
>
> SuSE ships with ACPI_DEBUG enabled by default.
> Can we get smarter about this -- say by checking against
> the processors that we expect to be present?
The error info depends on the two following conditions :
1. ACPI_DEBUG is enabled
2. boot option of acpi.debug_level=0x10
If Only ACPI_DEBUG is enabled, the dmesg won't print the error info.
> thanks,
> -Len
>
> > http://bugzilla.kernel.org/show_bug.cgi?id=8630
> >
> > Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> > ---
> > drivers/acpi/processor_core.c | 4 +++-
> > 1 file changed, 3 insertions(+), 1 deletion(-)
> >
> > Index: linux-2.6.23-rc7/drivers/acpi/processor_core.c
> > ===================================================================
> > --- linux-2.6.23-rc7.orig/drivers/acpi/processor_core.c
> > +++ linux-2.6.23-rc7/drivers/acpi/processor_core.c
> > @@ -813,7 +813,9 @@ static int is_processor_present(acpi_han
> >
> > status = acpi_evaluate_integer(handle, "_STA", NULL, &sta);
> > if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT)) {
> > - ACPI_EXCEPTION((AE_INFO, status, "Processor Device is not present"));
> > + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> > + "%s :Processor Device is not present",
> > + acpi_format_exception(status)));
> > return 0;
> > }
> > return 1;
> >
> -
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_1/4] :Add the _TPC throttling limit for TSS
2007-10-10 3:43 ` Len Brown
2007-10-15 1:19 ` Zhao Yakui
@ 2007-11-07 12:34 ` Zhao Yakui
2007-11-07 12:34 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
` (21 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-07 12:34 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
Subject: ACPI :Add the _TPC throttling limit for TSS
>From : Zhao Yakui <yakui.zhao@intel.com>
When T-state limit change notification is received, OSPM should
evaluate the _TPC object and change the current T-State according to the new
limit.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 49 +++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -70,7 +70,54 @@ static int acpi_processor_get_platform_l
int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
{
- return acpi_processor_get_platform_limit(pr);
+ int result = 0;
+ int throttling_limit;
+ int current_state;
+ struct acpi_processor_limit *limit;
+ int target_state;
+
+ result = acpi_processor_get_platform_limit(pr);
+ if (result) {
+ /* Throttling Limit is unsupported */
+ return result;
+ }
+
+ throttling_limit = pr->throttling_platform_limit;
+ if (throttling_limit >= pr->throttling.state_count) {
+ /* Uncorrect Throttling Limit */
+ return -EINVAL;
+ }
+
+ current_state = pr->throttling.state;
+ if (current_state >= throttling_limit) {
+ /*
+ * The current state can meet with the requirement of
+ * _TPC limit. But it is reasonable that OSPM changes
+ * t-states from high to low for better performance.
+ * Of course the limit condition of thermal
+ * and user should be considered.
+ */
+ limit = &pr->limit;
+ target_state = throttling_limit;
+ if (limit->thermal.tx > target_state)
+ target_state = limit->thermal.tx;
+ if (limit->user.tx > target_state)
+ target_state = limit->user.tx;
+ if (target_state == current_state) {
+ /* unnecessary to change T-state */
+ return 0;
+ }
+ } else {
+ /*
+ * If the current state is lower than the limit of _TPC, it
+ * will be forced to switch to the throttling state defined
+ * by throttling_platfor_limit.
+ * Because the previous state meets with the limit condition
+ * of thermal and user, it is unnecessary to check it again.
+ */
+ target_state = throttling_limit;
+ }
+ return acpi_processor_set_throttling(pr, target_state);
}
/*
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_2/4] : Modify the ACPI I/O Access width
2007-10-10 3:43 ` Len Brown
2007-10-15 1:19 ` Zhao Yakui
2007-11-07 12:34 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
@ 2007-11-07 12:34 ` Zhao Yakui
2007-11-07 12:35 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
` (20 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-07 12:34 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
Subject: ACPI : Modify the ACPI I/O Access width
>From : Zhao Yakui <yakui.zhao@intel.com>
When the argument width is not the multiple of eight, the acpi I/O access
will fail. Modify the acpi I/O access width to the multiple of eight.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/osl.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/osl.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/osl.c
+++ linux-2.6.24-rc1/drivers/acpi/osl.c
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_ad
if (!value)
value = &dummy;
- switch (width) {
- case 8:
+ *value = 0;
+ if (width <= 8) {
*(u8 *) value = inb(port);
- break;
- case 16:
+ } else if (width <= 16) {
*(u16 *) value = inw(port);
- break;
- case 32:
+ } else if (width <= 32) {
*(u32 *) value = inl(port);
- break;
- default:
+ } else {
BUG();
}
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port);
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
- switch (width) {
- case 8:
+ if (width <= 8) {
outb(value, port);
- break;
- case 16:
+ } else if (width <= 16) {
outw(value, port);
- break;
- case 32:
+ } else if (width <= 32) {
outl(value, port);
- break;
- default:
+ } else {
BUG();
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists
2007-10-10 3:43 ` Len Brown
` (2 preceding siblings ...)
2007-11-07 12:34 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
@ 2007-11-07 12:35 ` Zhao Yakui
2007-11-07 12:35 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
` (19 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-07 12:35 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
Subject: ACPI : Throttling control uses T-states returned by _TSS when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, throttling control will use the T-states returned by _TSS.
Otherwise the calculated T-states from FADT.duty_width are used.
When TSS is used , the access width is included in the throttling.
So it is unnecessary that the access bit width is multiplied by 8.
At the same time the bit_offset should be considered for system I/O Access.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 157 +++++++++++++++++++++++-------------
1 file changed, 103 insertions(+), 54 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -130,6 +130,7 @@ static int acpi_processor_get_throttling
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *ptc = NULL;
union acpi_object obj = { 0 };
+ struct acpi_processor_throttling *throttling;
status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
if (ACPI_FAILURE(status)) {
@@ -181,6 +182,22 @@ static int acpi_processor_get_throttling
memcpy(&pr->throttling.status_register, obj.buffer.pointer,
sizeof(struct acpi_ptc_register));
+ throttling = &pr->throttling;
+
+ if ((throttling->control_register.bit_width +
+ throttling->control_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
+ if ((throttling->status_register.bit_width +
+ throttling->status_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
end:
kfree(buffer.pointer);
@@ -375,16 +392,27 @@ static int acpi_processor_get_throttling
return 0;
}
-static int acpi_read_throttling_status(struct acpi_processor_throttling
- *throttling)
+static int acpi_read_throttling_status(struct acpi_processor *pr,
+ acpi_integer *value)
{
- int value = -1;
+ u32 bit_width, bit_offset;
+ u64 ptc_mask;
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
+ int ret = -1;
+
+ throttling = &pr->throttling;
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ bit_width = throttling->status_register.bit_width;
+ bit_offset = throttling->status_register.bit_offset;
+
acpi_os_read_port((acpi_io_address) throttling->status_register.
- address, &value,
- (u32) throttling->status_register.bit_width *
- 8);
+ address, (u32 *)&ptc_value,
+ (u32) (bit_width + bit_offset));
+ ptc_mask = (1 << bit_width ) - 1;
+ *value =(acpi_integer)((ptc_value >> bit_offset) & ptc_mask);
+ ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX
@@ -394,20 +422,30 @@ static int acpi_read_throttling_status(s
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
(u32) (throttling->status_register.space_id));
}
- return value;
+ return ret;
}
-static int acpi_write_throttling_state(struct acpi_processor_throttling
- *throttling, int value)
+static int acpi_write_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
+ u32 bit_width, bit_offset;
+ u64 ptc_value;
+ u64 ptc_mask;
+ struct acpi_processor_throttling *throttling;
int ret = -1;
+ throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ bit_width = throttling->control_register.bit_width;
+ bit_offset = throttling->control_register.bit_offset;
+ ptc_mask = (1 << bit_width) - 1;
+ ptc_value = value & ptc_mask;
+
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, value,
- (u32) throttling->control_register.
- bit_width * 8);
+ control_register.address,
+ (u32) (ptc_value << bit_offset),
+ (u32) (bit_width + bit_offset));
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -421,7 +459,8 @@ static int acpi_write_throttling_state(s
return ret;
}
-static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
+static int acpi_get_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
int i;
@@ -437,22 +476,25 @@ static int acpi_get_throttling_state(str
return i;
}
-static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
+static int acpi_get_throttling_value(struct acpi_processor *pr,
+ int state, acpi_integer *value)
{
- int value = -1;
+ int ret = -1;
if (state >= 0 && state <= pr->throttling.state_count) {
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[state]);
- value = tx->control;
+ *value = tx->control;
+ ret = 0;
}
- return value;
+ return ret;
}
static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
{
int state = 0;
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -462,8 +504,8 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
- value = acpi_read_throttling_status(&pr->throttling);
- if (value >= 0) {
+ ret = acpi_read_throttling_status(pr, &value);
+ if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
pr->throttling.state = state;
}
@@ -477,6 +519,40 @@ static int acpi_processor_get_throttling
return pr->throttling.acpi_processor_get_throttling(pr);
}
+static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
+{
+ int i, step;
+
+ if (!pr->throttling.address) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
+ return -EINVAL;
+ } else if (!pr->throttling.duty_width) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
+ return -EINVAL;
+ }
+ /* TBD: Support duty_cycle values that span bit 4. */
+ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
+ printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+ return -EINVAL;
+ }
+
+ pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
+
+ /*
+ * Compute state values. Note that throttling displays a linear power/
+ * performance relationship (at 50% performance the CPU will consume
+ * 50% power). Values are in 1/10th of a percent to preserve accuracy.
+ */
+
+ step = (1000 / pr->throttling.state_count);
+
+ for (i = 0; i < pr->throttling.state_count; i++) {
+ pr->throttling.states[i].performance = 1000 - step * i;
+ pr->throttling.states[i].power = 1000 - step * i;
+ }
+ return 0;
+}
+
static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
int state)
{
@@ -553,7 +629,8 @@ static int acpi_processor_set_throttling
static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
int state)
{
- u32 value = 0;
+ int ret ;
+ acpi_integer value = 0;
if (!pr)
return -EINVAL;
@@ -572,9 +649,9 @@ static int acpi_processor_set_throttling
local_irq_disable();
- value = acpi_get_throttling_value(pr, state);
- if (value >= 0) {
- acpi_write_throttling_state(&pr->throttling, value);
+ ret = acpi_get_throttling_value(pr, state, &value);
+ if (ret >= 0) {
+ acpi_write_throttling_state(pr, value);
pr->throttling.state = state;
}
local_irq_enable();
@@ -590,8 +667,6 @@ int acpi_processor_set_throttling(struct
int acpi_processor_get_throttling_info(struct acpi_processor *pr)
{
int result = 0;
- int step = 0;
- int i = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -610,6 +685,8 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_throttling_states(pr) ||
acpi_processor_get_platform_limit(pr))
{
+ if (acpi_processor_get_fadt_info(pr))
+ return 0;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling =
@@ -623,19 +700,6 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_tsd(pr);
- if (!pr->throttling.address) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
- return 0;
- } else if (!pr->throttling.duty_width) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
- return 0;
- }
- /* TBD: Support duty_cycle values that span bit 4. */
- else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
- printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
- return 0;
- }
-
/*
* PIIX4 Errata: We don't support throttling on the original PIIX4.
* This shouldn't be an issue as few (if any) mobile systems ever
@@ -647,21 +711,6 @@ int acpi_processor_get_throttling_info(s
return 0;
}
- pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
-
- /*
- * Compute state values. Note that throttling displays a linear power/
- * performance relationship (at 50% performance the CPU will consume
- * 50% power). Values are in 1/10th of a percent to preserve accuracy.
- */
-
- step = (1000 / pr->throttling.state_count);
-
- for (i = 0; i < pr->throttling.state_count; i++) {
- pr->throttling.states[i].performance = step * i;
- pr->throttling.states[i].power = step * i;
- }
-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
pr->throttling.state_count));
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_4/4] :Add MSR support for T-States
2007-10-10 3:43 ` Len Brown
` (3 preceding siblings ...)
2007-11-07 12:35 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
@ 2007-11-07 12:35 ` Zhao Yakui
2007-11-08 0:56 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
` (18 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-07 12:35 UTC (permalink / raw)
To: Len Brown; +Cc: Linux-acpi
Subject: ACPI : Add MSR support for T-States
>From : Zhao Yakui <yakui.zhao@intel.com>
Add throttling control via MSR when T-states uses the FixHW Control/
Status registers.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
arch/x86/kernel/acpi/processor.c | 3 +
drivers/acpi/processor_throttling.c | 72 ++++++++++++++++++++++++++++++++++--
2 files changed, 71 insertions(+), 4 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -391,6 +391,71 @@ static int acpi_processor_get_throttling
return 0;
}
+#ifdef CONFIG_X86
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ struct cpuinfo_x86 *c;
+ u64 msr_high, msr_low;
+ unsigned int cpu;
+ u64 msr = 0;
+ int ret = -1;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr_low = 0;
+ msr_high = 0;
+ rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ (u32 *)&msr_low , (u32 *) &msr_high);
+ msr = (msr_high << 32) | msr_low;
+ *value = (acpi_integer) msr;
+ ret = 0;
+ }
+ return ret;
+}
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ struct cpuinfo_x86 *c;
+ unsigned int cpu;
+ int ret = -1;
+ u64 msr;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr = value;
+ wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ msr & 0xffffffff, msr >> 32);
+ ret = 0;
+ }
+ return ret;
+}
+#else
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+#endif
static int acpi_read_throttling_status(struct acpi_processor *pr,
acpi_integer *value)
@@ -415,8 +480,7 @@ static int acpi_read_throttling_status(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_rdmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -449,8 +513,7 @@ static int acpi_write_throttling_state(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_wrmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -504,6 +567,7 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
+ value = 0;
ret = acpi_read_throttling_status(pr, &value);
if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
Index: linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
===================================================================
--- linux-2.6.24-rc1.orig/arch/x86/kernel/acpi/processor.c
+++ linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
@@ -49,6 +49,9 @@ static void init_intel_pdc(struct acpi_p
if (cpu_has(c, X86_FEATURE_EST))
buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+ if (cpu_has(c, X86_FEATURE_ACPI))
+ buf[2] |= ACPI_PDC_T_FFH;
+
obj->type = ACPI_TYPE_BUFFER;
obj->buffer.length = 12;
obj->buffer.pointer = (u8 *) buf;
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_1/4] :Add the _TPC throttling limit for TSS
2007-10-10 3:43 ` Len Brown
` (4 preceding siblings ...)
2007-11-07 12:35 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
@ 2007-11-08 0:56 ` Zhao Yakui
2007-11-15 2:52 ` Len Brown
2007-11-08 0:56 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
` (17 subsequent siblings)
23 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2007-11-08 0:56 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI :Add the _TPC throttling limit for TSS
>From : Zhao Yakui <yakui.zhao@intel.com>
When T-state limit change notification is received, OSPM should
evaluate the _TPC object and change the current T-State according to the new
limit.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 49 +++++++++++++++++++++++++++++++++++-
1 file changed, 48 insertions(+), 1 deletion(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -70,7 +70,54 @@ static int acpi_processor_get_platform_l
int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
{
- return acpi_processor_get_platform_limit(pr);
+ int result = 0;
+ int throttling_limit;
+ int current_state;
+ struct acpi_processor_limit *limit;
+ int target_state;
+
+ result = acpi_processor_get_platform_limit(pr);
+ if (result) {
+ /* Throttling Limit is unsupported */
+ return result;
+ }
+
+ throttling_limit = pr->throttling_platform_limit;
+ if (throttling_limit >= pr->throttling.state_count) {
+ /* Uncorrect Throttling Limit */
+ return -EINVAL;
+ }
+
+ current_state = pr->throttling.state;
+ if (current_state >= throttling_limit) {
+ /*
+ * The current state can meet with the requirement of
+ * _TPC limit. But it is reasonable that OSPM changes
+ * t-states from high to low for better performance.
+ * Of course the limit condition of thermal
+ * and user should be considered.
+ */
+ limit = &pr->limit;
+ target_state = throttling_limit;
+ if (limit->thermal.tx > target_state)
+ target_state = limit->thermal.tx;
+ if (limit->user.tx > target_state)
+ target_state = limit->user.tx;
+ if (target_state == current_state) {
+ /* unnecessary to change T-state */
+ return 0;
+ }
+ } else {
+ /*
+ * If the current state is lower than the limit of _TPC, it
+ * will be forced to switch to the throttling state defined
+ * by throttling_platfor_limit.
+ * Because the previous state meets with the limit condition
+ * of thermal and user, it is unnecessary to check it again.
+ */
+ target_state = throttling_limit;
+ }
+ return acpi_processor_set_throttling(pr, target_state);
}
/*
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_2/4] : Modify the ACPI I/O Access width
2007-10-10 3:43 ` Len Brown
` (5 preceding siblings ...)
2007-11-08 0:56 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
@ 2007-11-08 0:56 ` Zhao Yakui
2007-11-08 0:57 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
` (16 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-08 0:56 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Modify the ACPI I/O Access width
>From : Zhao Yakui <yakui.zhao@intel.com>
When the argument width is not the multiple of eight, the acpi I/O access
will fail. Modify the acpi I/O access width to the multiple of eight.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/osl.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/osl.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/osl.c
+++ linux-2.6.24-rc1/drivers/acpi/osl.c
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_ad
if (!value)
value = &dummy;
- switch (width) {
- case 8:
+ *value = 0;
+ if (width <= 8) {
*(u8 *) value = inb(port);
- break;
- case 16:
+ } else if (width <= 16) {
*(u16 *) value = inw(port);
- break;
- case 32:
+ } else if (width <= 32) {
*(u32 *) value = inl(port);
- break;
- default:
+ } else {
BUG();
}
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port);
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
- switch (width) {
- case 8:
+ if (width <= 8) {
outb(value, port);
- break;
- case 16:
+ } else if (width <= 16) {
outw(value, port);
- break;
- case 32:
+ } else if (width <= 32) {
outl(value, port);
- break;
- default:
+ } else {
BUG();
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists
2007-10-10 3:43 ` Len Brown
` (6 preceding siblings ...)
2007-11-08 0:56 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
@ 2007-11-08 0:57 ` Zhao Yakui
2007-11-08 0:57 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
` (15 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-08 0:57 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Throttling control uses T-states returned by _TSS when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, throttling control will use the T-states returned by _TSS.
Otherwise the calculated T-states from FADT.duty_width are used.
When TSS is used , the access width is included in the throttling.
So it is unnecessary that the access bit width is multiplied by 8.
At the same time the bit_offset should be considered for system I/O Access.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 157 +++++++++++++++++++++++-------------
1 file changed, 103 insertions(+), 54 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -130,6 +130,7 @@ static int acpi_processor_get_throttling
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *ptc = NULL;
union acpi_object obj = { 0 };
+ struct acpi_processor_throttling *throttling;
status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
if (ACPI_FAILURE(status)) {
@@ -181,6 +182,22 @@ static int acpi_processor_get_throttling
memcpy(&pr->throttling.status_register, obj.buffer.pointer,
sizeof(struct acpi_ptc_register));
+ throttling = &pr->throttling;
+
+ if ((throttling->control_register.bit_width +
+ throttling->control_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
+ if ((throttling->status_register.bit_width +
+ throttling->status_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
end:
kfree(buffer.pointer);
@@ -375,16 +392,27 @@ static int acpi_processor_get_throttling
return 0;
}
-static int acpi_read_throttling_status(struct acpi_processor_throttling
- *throttling)
+static int acpi_read_throttling_status(struct acpi_processor *pr,
+ acpi_integer *value)
{
- int value = -1;
+ u32 bit_width, bit_offset;
+ u64 ptc_mask;
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
+ int ret = -1;
+
+ throttling = &pr->throttling;
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ bit_width = throttling->status_register.bit_width;
+ bit_offset = throttling->status_register.bit_offset;
+
acpi_os_read_port((acpi_io_address) throttling->status_register.
- address, &value,
- (u32) throttling->status_register.bit_width *
- 8);
+ address, (u32 *)&ptc_value,
+ (u32) (bit_width + bit_offset));
+ ptc_mask = (1 << bit_width ) - 1;
+ *value =(acpi_integer)((ptc_value >> bit_offset) & ptc_mask);
+ ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX
@@ -394,20 +422,30 @@ static int acpi_read_throttling_status(s
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
(u32) (throttling->status_register.space_id));
}
- return value;
+ return ret;
}
-static int acpi_write_throttling_state(struct acpi_processor_throttling
- *throttling, int value)
+static int acpi_write_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
+ u32 bit_width, bit_offset;
+ u64 ptc_value;
+ u64 ptc_mask;
+ struct acpi_processor_throttling *throttling;
int ret = -1;
+ throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ bit_width = throttling->control_register.bit_width;
+ bit_offset = throttling->control_register.bit_offset;
+ ptc_mask = (1 << bit_width) - 1;
+ ptc_value = value & ptc_mask;
+
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, value,
- (u32) throttling->control_register.
- bit_width * 8);
+ control_register.address,
+ (u32) (ptc_value << bit_offset),
+ (u32) (bit_width + bit_offset));
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -421,7 +459,8 @@ static int acpi_write_throttling_state(s
return ret;
}
-static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
+static int acpi_get_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
int i;
@@ -437,22 +476,25 @@ static int acpi_get_throttling_state(str
return i;
}
-static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
+static int acpi_get_throttling_value(struct acpi_processor *pr,
+ int state, acpi_integer *value)
{
- int value = -1;
+ int ret = -1;
if (state >= 0 && state <= pr->throttling.state_count) {
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[state]);
- value = tx->control;
+ *value = tx->control;
+ ret = 0;
}
- return value;
+ return ret;
}
static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
{
int state = 0;
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -462,8 +504,8 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
- value = acpi_read_throttling_status(&pr->throttling);
- if (value >= 0) {
+ ret = acpi_read_throttling_status(pr, &value);
+ if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
pr->throttling.state = state;
}
@@ -477,6 +519,40 @@ static int acpi_processor_get_throttling
return pr->throttling.acpi_processor_get_throttling(pr);
}
+static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
+{
+ int i, step;
+
+ if (!pr->throttling.address) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
+ return -EINVAL;
+ } else if (!pr->throttling.duty_width) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
+ return -EINVAL;
+ }
+ /* TBD: Support duty_cycle values that span bit 4. */
+ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
+ printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+ return -EINVAL;
+ }
+
+ pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
+
+ /*
+ * Compute state values. Note that throttling displays a linear power/
+ * performance relationship (at 50% performance the CPU will consume
+ * 50% power). Values are in 1/10th of a percent to preserve accuracy.
+ */
+
+ step = (1000 / pr->throttling.state_count);
+
+ for (i = 0; i < pr->throttling.state_count; i++) {
+ pr->throttling.states[i].performance = 1000 - step * i;
+ pr->throttling.states[i].power = 1000 - step * i;
+ }
+ return 0;
+}
+
static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
int state)
{
@@ -553,7 +629,8 @@ static int acpi_processor_set_throttling
static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
int state)
{
- u32 value = 0;
+ int ret ;
+ acpi_integer value = 0;
if (!pr)
return -EINVAL;
@@ -572,9 +649,9 @@ static int acpi_processor_set_throttling
local_irq_disable();
- value = acpi_get_throttling_value(pr, state);
- if (value >= 0) {
- acpi_write_throttling_state(&pr->throttling, value);
+ ret = acpi_get_throttling_value(pr, state, &value);
+ if (ret >= 0) {
+ acpi_write_throttling_state(pr, value);
pr->throttling.state = state;
}
local_irq_enable();
@@ -590,8 +667,6 @@ int acpi_processor_set_throttling(struct
int acpi_processor_get_throttling_info(struct acpi_processor *pr)
{
int result = 0;
- int step = 0;
- int i = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -610,6 +685,8 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_throttling_states(pr) ||
acpi_processor_get_platform_limit(pr))
{
+ if (acpi_processor_get_fadt_info(pr))
+ return 0;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling =
@@ -623,19 +700,6 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_tsd(pr);
- if (!pr->throttling.address) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
- return 0;
- } else if (!pr->throttling.duty_width) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
- return 0;
- }
- /* TBD: Support duty_cycle values that span bit 4. */
- else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
- printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
- return 0;
- }
-
/*
* PIIX4 Errata: We don't support throttling on the original PIIX4.
* This shouldn't be an issue as few (if any) mobile systems ever
@@ -647,21 +711,6 @@ int acpi_processor_get_throttling_info(s
return 0;
}
- pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
-
- /*
- * Compute state values. Note that throttling displays a linear power/
- * performance relationship (at 50% performance the CPU will consume
- * 50% power). Values are in 1/10th of a percent to preserve accuracy.
- */
-
- step = (1000 / pr->throttling.state_count);
-
- for (i = 0; i < pr->throttling.state_count; i++) {
- pr->throttling.states[i].performance = step * i;
- pr->throttling.states[i].power = step * i;
- }
-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
pr->throttling.state_count));
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_4/4] :Add MSR support for T-States
2007-10-10 3:43 ` Len Brown
` (7 preceding siblings ...)
2007-11-08 0:57 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
@ 2007-11-08 0:57 ` Zhao Yakui
2007-11-15 3:22 ` Len Brown
2007-11-08 1:25 ` [PATCH] [ACPI ]: Init PDC before getting throttling info Zhao Yakui
` (14 subsequent siblings)
23 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2007-11-08 0:57 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Add MSR support for T-States
>From : Zhao Yakui <yakui.zhao@intel.com>
Add throttling control via MSR when T-states uses the FixHW Control/
Status registers.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
arch/x86/kernel/acpi/processor.c | 3 +
drivers/acpi/processor_throttling.c | 72 ++++++++++++++++++++++++++++++++++--
2 files changed, 71 insertions(+), 4 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -391,6 +391,71 @@ static int acpi_processor_get_throttling
return 0;
}
+#ifdef CONFIG_X86
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ struct cpuinfo_x86 *c;
+ u64 msr_high, msr_low;
+ unsigned int cpu;
+ u64 msr = 0;
+ int ret = -1;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr_low = 0;
+ msr_high = 0;
+ rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ (u32 *)&msr_low , (u32 *) &msr_high);
+ msr = (msr_high << 32) | msr_low;
+ *value = (acpi_integer) msr;
+ ret = 0;
+ }
+ return ret;
+}
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ struct cpuinfo_x86 *c;
+ unsigned int cpu;
+ int ret = -1;
+ u64 msr;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr = value;
+ wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ msr & 0xffffffff, msr >> 32);
+ ret = 0;
+ }
+ return ret;
+}
+#else
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+#endif
static int acpi_read_throttling_status(struct acpi_processor *pr,
acpi_integer *value)
@@ -415,8 +480,7 @@ static int acpi_read_throttling_status(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_rdmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -449,8 +513,7 @@ static int acpi_write_throttling_state(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_wrmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -504,6 +567,7 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
+ value = 0;
ret = acpi_read_throttling_status(pr, &value);
if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
Index: linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
===================================================================
--- linux-2.6.24-rc1.orig/arch/x86/kernel/acpi/processor.c
+++ linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
@@ -49,6 +49,9 @@ static void init_intel_pdc(struct acpi_p
if (cpu_has(c, X86_FEATURE_EST))
buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+ if (cpu_has(c, X86_FEATURE_ACPI))
+ buf[2] |= ACPI_PDC_T_FFH;
+
obj->type = ACPI_TYPE_BUFFER;
obj->buffer.length = 12;
obj->buffer.pointer = (u8 *) buf;
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH] [ACPI ]: Init PDC before getting throttling info
2007-10-10 3:43 ` Len Brown
` (8 preceding siblings ...)
2007-11-08 0:57 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
@ 2007-11-08 1:25 ` Zhao Yakui
2007-11-15 8:41 ` [PATCH_2/7] : Modify the ACPI I/O Access width Zhao Yakui
` (13 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-08 1:25 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Init PDC before getting throttling info
>From : Zhao Yakui <yakui.zhao@intel.com>
The throttling info should be obtained after PDC is initialized.
Otherwise the cpus maybe use the different PTC control/status register
when the system supports the TSS throttling via ACPI MSR.
One uses the System I/O mode and the other uses the Fixed HW access mode.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_core.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_core.c
@@ -612,12 +612,6 @@ static int acpi_processor_get_info(struc
request_region(pr->throttling.address, 6, "ACPI CPU throttle");
}
-#ifdef CONFIG_CPU_FREQ
- acpi_processor_ppc_has_changed(pr);
-#endif
- acpi_processor_get_throttling_info(pr);
- acpi_processor_get_limit_info(pr);
-
return 0;
}
@@ -665,6 +659,12 @@ static int __cpuinit acpi_processor_star
/* _PDC call should be done before doing anything else (if reqd.). */
arch_acpi_processor_init_pdc(pr);
acpi_processor_set_pdc(pr);
+#ifdef CONFIG_CPU_FREQ
+ acpi_processor_ppc_has_changed(pr);
+#endif
+ acpi_processor_get_throttling_info(pr);
+ acpi_processor_get_limit_info(pr);
+
acpi_processor_power_init(pr, device);
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH_1/4] :Add the _TPC throttling limit for TSS
2007-11-08 0:56 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
@ 2007-11-15 2:52 ` Len Brown
0 siblings, 0 replies; 33+ messages in thread
From: Len Brown @ 2007-11-15 2:52 UTC (permalink / raw)
To: Zhao Yakui; +Cc: linux-acpi
On Wednesday 07 November 2007 19:56, Zhao Yakui wrote:
> Subject: ACPI :Add the _TPC throttling limit for TSS
> >From : Zhao Yakui <yakui.zhao@intel.com>
>
> When T-state limit change notification is received, OSPM should
> evaluate the _TPC object and change the current T-State according to the new
> limit.
>
> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> Signed-off-by: Li Shaohua <shaohua.li@intel.com>
>
> ---
> drivers/acpi/processor_throttling.c | 49 +++++++++++++++++++++++++++++++++++-
> 1 file changed, 48 insertions(+), 1 deletion(-)
>
> Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
> ===================================================================
> --- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
> +++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
> @@ -70,7 +70,54 @@ static int acpi_processor_get_platform_l
>
> int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
> {
> - return acpi_processor_get_platform_limit(pr);
> + int result = 0;
> + int throttling_limit;
> + int current_state;
> + struct acpi_processor_limit *limit;
> + int target_state;
> +
> + result = acpi_processor_get_platform_limit(pr);
> + if (result) {
> + /* Throttling Limit is unsupported */
> + return result;
> + }
> +
> + throttling_limit = pr->throttling_platform_limit;
> + if (throttling_limit >= pr->throttling.state_count) {
> + /* Uncorrect Throttling Limit */
> + return -EINVAL;
> + }
> +
> + current_state = pr->throttling.state;
> + if (current_state >= throttling_limit) {
probably don't need to check for == here
> + /*
> + * The current state can meet with the requirement of
> + * _TPC limit. But it is reasonable that OSPM changes
> + * t-states from high to low for better performance.
> + * Of course the limit condition of thermal
> + * and user should be considered.
> + */
> + limit = &pr->limit;
> + target_state = throttling_limit;
> + if (limit->thermal.tx > target_state)
> + target_state = limit->thermal.tx;
> + if (limit->user.tx > target_state)
> + target_state = limit->user.tx;
> + if (target_state == current_state) {
and don't need the corresponding == case here.
> + /* unnecessary to change T-state */
> + return 0;
> + }
> + } else {
> + /*
> + * If the current state is lower than the limit of _TPC, it
> + * will be forced to switch to the throttling state defined
> + * by throttling_platfor_limit.
> + * Because the previous state meets with the limit condition
> + * of thermal and user, it is unnecessary to check it again.
> + */
> + target_state = throttling_limit;
> + }
> + return acpi_processor_set_throttling(pr, target_state);
> }
>
> /*
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [Patch_4/4] :Add MSR support for T-States
2007-11-08 0:57 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
@ 2007-11-15 3:22 ` Len Brown
0 siblings, 0 replies; 33+ messages in thread
From: Len Brown @ 2007-11-15 3:22 UTC (permalink / raw)
To: Zhao Yakui; +Cc: linux-acpi
On Wednesday 07 November 2007 19:57, Zhao Yakui wrote:
> Subject: ACPI : Add MSR support for T-States
> >From : Zhao Yakui <yakui.zhao@intel.com>
>
> Add throttling control via MSR when T-states uses the FixHW Control/
> Status registers.
>
>
> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> Signed-off-by: Li Shaohua <shaohua.li@intel.com>
>
> ---
> arch/x86/kernel/acpi/processor.c | 3 +
> drivers/acpi/processor_throttling.c | 72 ++++++++++++++++++++++++++++++++++--
> 2 files changed, 71 insertions(+), 4 deletions(-)
>
> Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
> ===================================================================
> --- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
> +++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
> @@ -391,6 +391,71 @@ static int acpi_processor_get_throttling
>
> return 0;
> }
> +#ifdef CONFIG_X86
> +static int acpi_throttling_rdmsr(struct acpi_processor *pr,
> + acpi_integer * value)
> +{
> + struct cpuinfo_x86 *c;
> + u64 msr_high, msr_low;
> + unsigned int cpu;
> + u64 msr = 0;
> + int ret = -1;
> +
> + cpu = pr->id;
> + c = &cpu_data(cpu);
> +
> + if ((c->x86_vendor != X86_VENDOR_INTEL) ||
> + !cpu_has(c, X86_FEATURE_ACPI)) {
> + printk(KERN_ERR PREFIX
> + "HARDWARE addr space,NOT supported yet\n");
> + } else {
> + msr_low = 0;
> + msr_high = 0;
> + rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
> + (u32 *)&msr_low , (u32 *) &msr_high);
> + msr = (msr_high << 32) | msr_low;
> + *value = (acpi_integer) msr;
> + ret = 0;
> + }
> + return ret;
> +}
> +static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
> +{
> + struct cpuinfo_x86 *c;
> + unsigned int cpu;
> + int ret = -1;
> + u64 msr;
> +
> + cpu = pr->id;
> + c = &cpu_data(cpu);
> +
> + if ((c->x86_vendor != X86_VENDOR_INTEL) ||
> + !cpu_has(c, X86_FEATURE_ACPI)) {
> + printk(KERN_ERR PREFIX
> + "HARDWARE addr space,NOT supported yet\n");
> + } else {
> + msr = value;
> + wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
> + msr & 0xffffffff, msr >> 32);
> + ret = 0;
> + }
> + return ret;
> +}
> +#else
> +static int acpi_throttling_rdmsr(struct acpi_processor *pr,
> + acpi_integer * value)
> +{
> + printk(KERN_ERR PREFIX
> + "HARDWARE addr space,NOT supported yet\n");
> + return -1;
> +}
> +static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
> +{
> + printk(KERN_ERR PREFIX
> + "HARDWARE addr space,NOT supported yet\n");
> + return -1;
> +}
> +#endif
>
> static int acpi_read_throttling_status(struct acpi_processor *pr,
> acpi_integer *value)
> @@ -415,8 +480,7 @@ static int acpi_read_throttling_status(s
> ret = 0;
> break;
> case ACPI_ADR_SPACE_FIXED_HARDWARE:
> - printk(KERN_ERR PREFIX
> - "HARDWARE addr space,NOT supported yet\n");
> + ret = acpi_throttling_rdmsr(pr, value);
> break;
> default:
> printk(KERN_ERR PREFIX "Unknown addr space %d\n",
> @@ -449,8 +513,7 @@ static int acpi_write_throttling_state(s
> ret = 0;
> break;
> case ACPI_ADR_SPACE_FIXED_HARDWARE:
> - printk(KERN_ERR PREFIX
> - "HARDWARE addr space,NOT supported yet\n");
> + ret = acpi_throttling_wrmsr(pr, value);
> break;
> default:
> printk(KERN_ERR PREFIX "Unknown addr space %d\n",
> @@ -504,6 +567,7 @@ static int acpi_processor_get_throttling
>
> pr->throttling.state = 0;
> local_irq_disable();
> + value = 0;
but this patch doesn't _use_ value -- should it have been initialized
in a previous patch?
> ret = acpi_read_throttling_status(pr, &value);
> if (ret >= 0) {
> state = acpi_get_throttling_state(pr, value);
> Index: linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
> ===================================================================
> --- linux-2.6.24-rc1.orig/arch/x86/kernel/acpi/processor.c
> +++ linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
> @@ -49,6 +49,9 @@ static void init_intel_pdc(struct acpi_p
> if (cpu_has(c, X86_FEATURE_EST))
> buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
>
> + if (cpu_has(c, X86_FEATURE_ACPI))
> + buf[2] |= ACPI_PDC_T_FFH;
> +
> obj->type = ACPI_TYPE_BUFFER;
> obj->buffer.length = 12;
> obj->buffer.pointer = (u8 *) buf;
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_2/7] : Modify the ACPI I/O Access width
2007-10-10 3:43 ` Len Brown
` (9 preceding siblings ...)
2007-11-08 1:25 ` [PATCH] [ACPI ]: Init PDC before getting throttling info Zhao Yakui
@ 2007-11-15 8:41 ` Zhao Yakui
2007-11-15 8:41 ` [Patch_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
` (12 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 8:41 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Modify the ACPI I/O Access width
>From : Zhao Yakui <yakui.zhao@intel.com>
When the argument width is not the multiple of eight, the acpi I/O access
will fail. Modify the acpi I/O access width to the multiple of eight.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/osl.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/osl.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/osl.c
+++ linux-2.6.24-rc1/drivers/acpi/osl.c
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_ad
if (!value)
value = &dummy;
- switch (width) {
- case 8:
+ *value = 0;
+ if (width <= 8) {
*(u8 *) value = inb(port);
- break;
- case 16:
+ } else if (width <= 16) {
*(u16 *) value = inw(port);
- break;
- case 32:
+ } else if (width <= 32) {
*(u32 *) value = inl(port);
- break;
- default:
+ } else {
BUG();
}
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port);
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
- switch (width) {
- case 8:
+ if (width <= 8) {
outb(value, port);
- break;
- case 16:
+ } else if (width <= 16) {
outw(value, port);
- break;
- case 32:
+ } else if (width <= 32) {
outl(value, port);
- break;
- default:
+ } else {
BUG();
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists
2007-10-10 3:43 ` Len Brown
` (10 preceding siblings ...)
2007-11-15 8:41 ` [PATCH_2/7] : Modify the ACPI I/O Access width Zhao Yakui
@ 2007-11-15 8:41 ` Zhao Yakui
2007-11-15 8:41 ` [Patch_4/7] :Change the function interface for throttling control via PTC Zhao Yakui
` (11 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 8:41 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Not use calculated T-states from FADT.duty_width when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, it will return supported T-states.
It doesn't make sense to use calculated T-states from FADT.duty_width.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 66 +++++++++++++++++++-----------------
1 file changed, 36 insertions(+), 30 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -478,6 +478,40 @@ static int acpi_processor_get_throttling
return pr->throttling.acpi_processor_get_throttling(pr);
}
+static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
+{
+ int i, step;
+
+ if (!pr->throttling.address) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
+ return -EINVAL;
+ } else if (!pr->throttling.duty_width) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
+ return -EINVAL;
+ }
+ /* TBD: Support duty_cycle values that span bit 4. */
+ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
+ printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+ return -EINVAL;
+ }
+
+ pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
+
+ /*
+ * Compute state values. Note that throttling displays a linear power
+ * performance relationship (at 50% performance the CPU will consume
+ * 50% power). Values are in 1/10th of a percent to preserve accuracy.
+ */
+
+ step = (1000 / pr->throttling.state_count);
+
+ for (i = 0; i < pr->throttling.state_count; i++) {
+ pr->throttling.states[i].performance = 1000 - step * i;
+ pr->throttling.states[i].power = 1000 - step * i;
+ }
+ return 0;
+}
+
static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
int state)
{
@@ -591,8 +625,6 @@ int acpi_processor_set_throttling(struct
int acpi_processor_get_throttling_info(struct acpi_processor *pr)
{
int result = 0;
- int step = 0;
- int i = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -611,6 +643,8 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_throttling_states(pr) ||
acpi_processor_get_platform_limit(pr))
{
+ if (acpi_processor_get_fadt_info(pr))
+ return 0;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling =
@@ -624,19 +658,6 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_tsd(pr);
- if (!pr->throttling.address) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
- return 0;
- } else if (!pr->throttling.duty_width) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
- return 0;
- }
- /* TBD: Support duty_cycle values that span bit 4. */
- else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
- printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
- return 0;
- }
-
/*
* PIIX4 Errata: We don't support throttling on the original PIIX4.
* This shouldn't be an issue as few (if any) mobile systems ever
@@ -648,21 +669,6 @@ int acpi_processor_get_throttling_info(s
return 0;
}
- pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
-
- /*
- * Compute state values. Note that throttling displays a linear power/
- * performance relationship (at 50% performance the CPU will consume
- * 50% power). Values are in 1/10th of a percent to preserve accuracy.
- */
-
- step = (1000 / pr->throttling.state_count);
-
- for (i = 0; i < pr->throttling.state_count; i++) {
- pr->throttling.states[i].performance = step * i;
- pr->throttling.states[i].power = step * i;
- }
-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
pr->throttling.state_count));
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_4/7] :Change the function interface for throttling control via PTC
2007-10-10 3:43 ` Len Brown
` (11 preceding siblings ...)
2007-11-15 8:41 ` [Patch_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
@ 2007-11-15 8:41 ` Zhao Yakui
2007-11-15 8:42 ` [Patch_5/7 ] :Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
` (10 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 8:41 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Change the function interface for throttling control via PTC
>From : Zhao Yakui <yakui.zhao@intel.com>
Change the function interface for throttling control via PTC.
The following functions are concerned:
acpi_read_throttling_status()
acpi_write_throttling_state()
acpi_get_throttling_value()
acpi_get_throttling_state()
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 60 +++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 21 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -376,16 +376,23 @@ static int acpi_processor_get_throttling
return 0;
}
-static int acpi_read_throttling_status(struct acpi_processor_throttling
- *throttling)
+static int acpi_read_throttling_status(struct acpi_processor *pr,
+ acpi_integer *value)
{
- int value = -1;
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
+ int ret = -1;
+
+ throttling = &pr->throttling;
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ ptc_value = 0;
acpi_os_read_port((acpi_io_address) throttling->status_register.
- address, &value,
+ address, (u32 *) &ptc_value,
(u32) throttling->status_register.bit_width *
8);
+ *value = (acpi_integer) ptc_value;
+ ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX
@@ -395,18 +402,22 @@ static int acpi_read_throttling_status(s
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
(u32) (throttling->status_register.space_id));
}
- return value;
+ return ret;
}
-static int acpi_write_throttling_state(struct acpi_processor_throttling
- *throttling, int value)
+static int acpi_write_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
int ret = -1;
+ throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ ptc_value = value;
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, value,
+ control_register.address, (u32) ptc_value,
(u32) throttling->control_register.
bit_width * 8);
ret = 0;
@@ -422,7 +433,8 @@ static int acpi_write_throttling_state(s
return ret;
}
-static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
+static int acpi_get_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
int i;
@@ -438,22 +450,26 @@ static int acpi_get_throttling_state(str
return i;
}
-static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
+static int acpi_get_throttling_value(struct acpi_processor *pr,
+ int state, acpi_integer *value)
{
- int value = -1;
+ int ret = -1;
+
if (state >= 0 && state <= pr->throttling.state_count) {
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[state]);
- value = tx->control;
+ *value = tx->control;
+ ret = 0;
}
- return value;
+ return ret;
}
static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
{
int state = 0;
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -463,8 +479,9 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
- value = acpi_read_throttling_status(&pr->throttling);
- if (value >= 0) {
+ value = 0;
+ ret = acpi_read_throttling_status(pr, &value);
+ if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
pr->throttling.state = state;
}
@@ -588,7 +605,8 @@ static int acpi_processor_set_throttling
static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
int state)
{
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -606,10 +624,10 @@ static int acpi_processor_set_throttling
return -EPERM;
local_irq_disable();
-
- value = acpi_get_throttling_value(pr, state);
- if (value >= 0) {
- acpi_write_throttling_state(&pr->throttling, value);
+ value = 0;
+ ret = acpi_get_throttling_value(pr, state, &value);
+ if (ret >= 0) {
+ acpi_write_throttling_state(pr, value);
pr->throttling.state = state;
}
local_irq_enable();
^ permalink raw reply [flat|nested] 33+ messages in thread
* [Patch_5/7 ] :Throttling control uses T-states returned by _TSS when _TSS exists
2007-10-10 3:43 ` Len Brown
` (12 preceding siblings ...)
2007-11-15 8:41 ` [Patch_4/7] :Change the function interface for throttling control via PTC Zhao Yakui
@ 2007-11-15 8:42 ` Zhao Yakui
2007-11-15 8:59 ` [PATCH_1/7] ACPI: Add the _TPC throttling limit for TSS Zhao Yakui
` (9 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 8:42 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Throttling control uses T-states returned by _TSS when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, throttling control will use the T-states returned by _TSS.
Otherwise the calculated T-states from FADT.duty_width are used.
When TSS is used , the access width is included in the PTC control/status
register.So it is unnecessary that the access bit width is multiplied by 8.
At the same time the bit_offset should be considered for system I/O Access.
It should be checked the bit_width and bit_offset of PTC regsiter in order to
avoid the failure of system I/O access. It means that bit_width plus
bit_offset can't be greater than 32.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 42 ++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 7 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -131,6 +131,7 @@ static int acpi_processor_get_throttling
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *ptc = NULL;
union acpi_object obj = { 0 };
+ struct acpi_processor_throttling *throttling;
status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
if (ACPI_FAILURE(status)) {
@@ -182,6 +183,22 @@ static int acpi_processor_get_throttling
memcpy(&pr->throttling.status_register, obj.buffer.pointer,
sizeof(struct acpi_ptc_register));
+ throttling = &pr->throttling;
+
+ if ((throttling->control_register.bit_width +
+ throttling->control_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
+ if ((throttling->status_register.bit_width +
+ throttling->status_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
end:
kfree(buffer.pointer);
@@ -379,7 +396,9 @@ static int acpi_processor_get_throttling
static int acpi_read_throttling_status(struct acpi_processor *pr,
acpi_integer *value)
{
+ u32 bit_width, bit_offset;
u64 ptc_value;
+ u64 ptc_mask;
struct acpi_processor_throttling *throttling;
int ret = -1;
@@ -387,11 +406,14 @@ static int acpi_read_throttling_status(s
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
ptc_value = 0;
+ bit_width = throttling->status_register.bit_width;
+ bit_offset = throttling->status_register.bit_offset;
+
acpi_os_read_port((acpi_io_address) throttling->status_register.
address, (u32 *) &ptc_value,
- (u32) throttling->status_register.bit_width *
- 8);
- *value = (acpi_integer) ptc_value;
+ (u32) (bit_width + bit_offset));
+ ptc_mask = (1 << bit_width) - 1;
+ *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask);
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -408,18 +430,24 @@ static int acpi_read_throttling_status(s
static int acpi_write_throttling_state(struct acpi_processor *pr,
acpi_integer value)
{
+ u32 bit_width, bit_offset;
u64 ptc_value;
+ u64 ptc_mask;
struct acpi_processor_throttling *throttling;
int ret = -1;
throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
- ptc_value = value;
+ bit_width = throttling->control_register.bit_width;
+ bit_offset = throttling->control_register.bit_offset;
+ ptc_mask = (1 << bit_width) - 1;
+ ptc_value = value & ptc_mask;
+
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, (u32) ptc_value,
- (u32) throttling->control_register.
- bit_width * 8);
+ control_register.address,
+ (u32) (ptc_value << bit_offset),
+ (u32) (bit_width + bit_offset));
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_1/7] ACPI: Add the _TPC throttling limit for TSS
2007-10-10 3:43 ` Len Brown
` (13 preceding siblings ...)
2007-11-15 8:42 ` [Patch_5/7 ] :Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
@ 2007-11-15 8:59 ` Zhao Yakui
2007-11-15 9:01 ` [PATCH_2/7] ACPI: Modify the ACPI I/O Access width Zhao Yakui
` (8 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 8:59 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI :Add the _TPC throttling limit for TSS
>From : Zhao Yakui <yakui.zhao@intel.com>
When Tstate limit change notification is received, OSPM should
evaluate the _TPC object and change the current TState according to the new
limit.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 50 +++++++++++++++++++++++++++++++++++-
1 file changed, 49 insertions(+), 1 deletion(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -70,7 +70,55 @@ static int acpi_processor_get_platform_l
int acpi_processor_tstate_has_changed(struct acpi_processor *pr)
{
- return acpi_processor_get_platform_limit(pr);
+ int result = 0;
+ int throttling_limit;
+ int current_state;
+ struct acpi_processor_limit *limit;
+ int target_state;
+
+ result = acpi_processor_get_platform_limit(pr);
+ if (result) {
+ /* Throttling Limit is unsupported */
+ return result;
+ }
+
+ throttling_limit = pr->throttling_platform_limit;
+ if (throttling_limit >= pr->throttling.state_count) {
+ /* Uncorrect Throttling Limit */
+ return -EINVAL;
+ }
+
+ current_state = pr->throttling.state;
+ if (current_state > throttling_limit) {
+ /*
+ * The current state can meet the requirement of
+ * _TPC limit. But it is reasonable that OSPM changes
+ * t-states from high to low for better performance.
+ * Of course the limit condition of thermal
+ * and user should be considered.
+ */
+ limit = &pr->limit;
+ target_state = throttling_limit;
+ if (limit->thermal.tx > target_state)
+ target_state = limit->thermal.tx;
+ if (limit->user.tx > target_state)
+ target_state = limit->user.tx;
+ } else if (current_state == throttling_limit) {
+ /*
+ * Unnecessary to change the throttling state
+ */
+ return 0;
+ } else {
+ /*
+ * If the current state is lower than the limit of _TPC, it
+ * will be forced to switch to the throttling state defined
+ * by throttling_platfor_limit.
+ * Because the previous state meets with the limit condition
+ * of thermal and user, it is unnecessary to check it again.
+ */
+ target_state = throttling_limit;
+ }
+ return acpi_processor_set_throttling(pr, target_state);
}
/*
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_2/7] ACPI: Modify the ACPI I/O Access width
2007-10-10 3:43 ` Len Brown
` (14 preceding siblings ...)
2007-11-15 8:59 ` [PATCH_1/7] ACPI: Add the _TPC throttling limit for TSS Zhao Yakui
@ 2007-11-15 9:01 ` Zhao Yakui
2007-11-15 9:02 ` [PATCH_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
` (7 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:01 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Modify the ACPI I/O Access width
>From : Zhao Yakui <yakui.zhao@intel.com>
When the argument width is not the multiple of eight, the acpi I/O access
will fail. Modify the acpi I/O access width to the multiple of eight.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/osl.c | 25 +++++++++----------------
1 file changed, 9 insertions(+), 16 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/osl.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/osl.c
+++ linux-2.6.24-rc1/drivers/acpi/osl.c
@@ -387,17 +387,14 @@ acpi_status acpi_os_read_port(acpi_io_ad
if (!value)
value = &dummy;
- switch (width) {
- case 8:
+ *value = 0;
+ if (width <= 8) {
*(u8 *) value = inb(port);
- break;
- case 16:
+ } else if (width <= 16) {
*(u16 *) value = inw(port);
- break;
- case 32:
+ } else if (width <= 32) {
*(u32 *) value = inl(port);
- break;
- default:
+ } else {
BUG();
}
@@ -408,17 +405,13 @@ EXPORT_SYMBOL(acpi_os_read_port);
acpi_status acpi_os_write_port(acpi_io_address port, u32 value, u32 width)
{
- switch (width) {
- case 8:
+ if (width <= 8) {
outb(value, port);
- break;
- case 16:
+ } else if (width <= 16) {
outw(value, port);
- break;
- case 32:
+ } else if (width <= 32) {
outl(value, port);
- break;
- default:
+ } else {
BUG();
}
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists
2007-10-10 3:43 ` Len Brown
` (15 preceding siblings ...)
2007-11-15 9:01 ` [PATCH_2/7] ACPI: Modify the ACPI I/O Access width Zhao Yakui
@ 2007-11-15 9:02 ` Zhao Yakui
2007-11-15 9:03 ` [PATCH_4/7] ACPI: Change the function interface for throttling control via PTC Zhao Yakui
` (6 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:02 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Not use calculated T-states from FADT.duty_width when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, it will return supported T-states.
It doesn't make sense to use calculated T-states from FADT.duty_width.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 66 +++++++++++++++++++-----------------
1 file changed, 36 insertions(+), 30 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -478,6 +478,40 @@ static int acpi_processor_get_throttling
return pr->throttling.acpi_processor_get_throttling(pr);
}
+static int acpi_processor_get_fadt_info(struct acpi_processor *pr)
+{
+ int i, step;
+
+ if (!pr->throttling.address) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
+ return -EINVAL;
+ } else if (!pr->throttling.duty_width) {
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
+ return -EINVAL;
+ }
+ /* TBD: Support duty_cycle values that span bit 4. */
+ else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
+ printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
+ return -EINVAL;
+ }
+
+ pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
+
+ /*
+ * Compute state values. Note that throttling displays a linear power
+ * performance relationship (at 50% performance the CPU will consume
+ * 50% power). Values are in 1/10th of a percent to preserve accuracy.
+ */
+
+ step = (1000 / pr->throttling.state_count);
+
+ for (i = 0; i < pr->throttling.state_count; i++) {
+ pr->throttling.states[i].performance = 1000 - step * i;
+ pr->throttling.states[i].power = 1000 - step * i;
+ }
+ return 0;
+}
+
static int acpi_processor_set_throttling_fadt(struct acpi_processor *pr,
int state)
{
@@ -591,8 +625,6 @@ int acpi_processor_set_throttling(struct
int acpi_processor_get_throttling_info(struct acpi_processor *pr)
{
int result = 0;
- int step = 0;
- int i = 0;
ACPI_DEBUG_PRINT((ACPI_DB_INFO,
"pblk_address[0x%08x] duty_offset[%d] duty_width[%d]\n",
@@ -611,6 +643,8 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_throttling_states(pr) ||
acpi_processor_get_platform_limit(pr))
{
+ if (acpi_processor_get_fadt_info(pr))
+ return 0;
pr->throttling.acpi_processor_get_throttling =
&acpi_processor_get_throttling_fadt;
pr->throttling.acpi_processor_set_throttling =
@@ -624,19 +658,6 @@ int acpi_processor_get_throttling_info(s
acpi_processor_get_tsd(pr);
- if (!pr->throttling.address) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling register\n"));
- return 0;
- } else if (!pr->throttling.duty_width) {
- ACPI_DEBUG_PRINT((ACPI_DB_INFO, "No throttling states\n"));
- return 0;
- }
- /* TBD: Support duty_cycle values that span bit 4. */
- else if ((pr->throttling.duty_offset + pr->throttling.duty_width) > 4) {
- printk(KERN_WARNING PREFIX "duty_cycle spans bit 4\n");
- return 0;
- }
-
/*
* PIIX4 Errata: We don't support throttling on the original PIIX4.
* This shouldn't be an issue as few (if any) mobile systems ever
@@ -648,21 +669,6 @@ int acpi_processor_get_throttling_info(s
return 0;
}
- pr->throttling.state_count = 1 << acpi_gbl_FADT.duty_width;
-
- /*
- * Compute state values. Note that throttling displays a linear power/
- * performance relationship (at 50% performance the CPU will consume
- * 50% power). Values are in 1/10th of a percent to preserve accuracy.
- */
-
- step = (1000 / pr->throttling.state_count);
-
- for (i = 0; i < pr->throttling.state_count; i++) {
- pr->throttling.states[i].performance = step * i;
- pr->throttling.states[i].power = step * i;
- }
-
ACPI_DEBUG_PRINT((ACPI_DB_INFO, "Found %d throttling states\n",
pr->throttling.state_count));
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_4/7] ACPI: Change the function interface for throttling control via PTC
2007-10-10 3:43 ` Len Brown
` (16 preceding siblings ...)
2007-11-15 9:02 ` [PATCH_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
@ 2007-11-15 9:03 ` Zhao Yakui
2007-11-15 9:05 ` [PATCH_5/7] ACPI: Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
` (5 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:03 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Change the function interface for throttling control via PTC
>From : Zhao Yakui <yakui.zhao@intel.com>
Change the function interface for throttling control via PTC.
The following functions are concerned:
acpi_read_throttling_status()
acpi_write_throttling_state()
acpi_get_throttling_value()
acpi_get_throttling_state()
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 60 +++++++++++++++++++++++-------------
1 file changed, 39 insertions(+), 21 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -376,16 +376,23 @@ static int acpi_processor_get_throttling
return 0;
}
-static int acpi_read_throttling_status(struct acpi_processor_throttling
- *throttling)
+static int acpi_read_throttling_status(struct acpi_processor *pr,
+ acpi_integer *value)
{
- int value = -1;
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
+ int ret = -1;
+
+ throttling = &pr->throttling;
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ ptc_value = 0;
acpi_os_read_port((acpi_io_address) throttling->status_register.
- address, &value,
+ address, (u32 *) &ptc_value,
(u32) throttling->status_register.bit_width *
8);
+ *value = (acpi_integer) ptc_value;
+ ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
printk(KERN_ERR PREFIX
@@ -395,18 +402,22 @@ static int acpi_read_throttling_status(s
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
(u32) (throttling->status_register.space_id));
}
- return value;
+ return ret;
}
-static int acpi_write_throttling_state(struct acpi_processor_throttling
- *throttling, int value)
+static int acpi_write_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
+ u64 ptc_value;
+ struct acpi_processor_throttling *throttling;
int ret = -1;
+ throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
+ ptc_value = value;
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, value,
+ control_register.address, (u32) ptc_value,
(u32) throttling->control_register.
bit_width * 8);
ret = 0;
@@ -422,7 +433,8 @@ static int acpi_write_throttling_state(s
return ret;
}
-static int acpi_get_throttling_state(struct acpi_processor *pr, int value)
+static int acpi_get_throttling_state(struct acpi_processor *pr,
+ acpi_integer value)
{
int i;
@@ -438,22 +450,26 @@ static int acpi_get_throttling_state(str
return i;
}
-static int acpi_get_throttling_value(struct acpi_processor *pr, int state)
+static int acpi_get_throttling_value(struct acpi_processor *pr,
+ int state, acpi_integer *value)
{
- int value = -1;
+ int ret = -1;
+
if (state >= 0 && state <= pr->throttling.state_count) {
struct acpi_processor_tx_tss *tx =
(struct acpi_processor_tx_tss *)&(pr->throttling.
states_tss[state]);
- value = tx->control;
+ *value = tx->control;
+ ret = 0;
}
- return value;
+ return ret;
}
static int acpi_processor_get_throttling_ptc(struct acpi_processor *pr)
{
int state = 0;
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -463,8 +479,9 @@ static int acpi_processor_get_throttling
pr->throttling.state = 0;
local_irq_disable();
- value = acpi_read_throttling_status(&pr->throttling);
- if (value >= 0) {
+ value = 0;
+ ret = acpi_read_throttling_status(pr, &value);
+ if (ret >= 0) {
state = acpi_get_throttling_state(pr, value);
pr->throttling.state = state;
}
@@ -588,7 +605,8 @@ static int acpi_processor_set_throttling
static int acpi_processor_set_throttling_ptc(struct acpi_processor *pr,
int state)
{
- u32 value = 0;
+ int ret;
+ acpi_integer value;
if (!pr)
return -EINVAL;
@@ -606,10 +624,10 @@ static int acpi_processor_set_throttling
return -EPERM;
local_irq_disable();
-
- value = acpi_get_throttling_value(pr, state);
- if (value >= 0) {
- acpi_write_throttling_state(&pr->throttling, value);
+ value = 0;
+ ret = acpi_get_throttling_value(pr, state, &value);
+ if (ret >= 0) {
+ acpi_write_throttling_state(pr, value);
pr->throttling.state = state;
}
local_irq_enable();
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_5/7] ACPI: Throttling control uses T-states returned by _TSS when _TSS exists
2007-10-10 3:43 ` Len Brown
` (17 preceding siblings ...)
2007-11-15 9:03 ` [PATCH_4/7] ACPI: Change the function interface for throttling control via PTC Zhao Yakui
@ 2007-11-15 9:05 ` Zhao Yakui
2007-11-15 9:05 ` [PATCH_6/7] ACPI: Init PDC before getting throttling info Zhao Yakui
` (4 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:05 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Throttling control uses T-states returned by _TSS when _TSS exists
>From : Zhao Yakui <yakui.zhao@intel.com>
If _TSS exists, throttling control will use the T-states returned by _TSS.
Otherwise the calculated T-states from FADT.duty_width are used.
When TSS is used , the access width is included in the PTC control/status
register.So it is unnecessary that the access bit width is multiplied by 8.
At the same time the bit_offset should be considered for system I/O Access.
It should be checked the bit_width and bit_offset of PTC regsiter in order to
avoid the failure of system I/O access. It means that bit_width plus
bit_offset can't be greater than 32.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_throttling.c | 42 ++++++++++++++++++++++++++++++------
1 file changed, 35 insertions(+), 7 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -131,6 +131,7 @@ static int acpi_processor_get_throttling
struct acpi_buffer buffer = { ACPI_ALLOCATE_BUFFER, NULL };
union acpi_object *ptc = NULL;
union acpi_object obj = { 0 };
+ struct acpi_processor_throttling *throttling;
status = acpi_evaluate_object(pr->handle, "_PTC", NULL, &buffer);
if (ACPI_FAILURE(status)) {
@@ -182,6 +183,22 @@ static int acpi_processor_get_throttling
memcpy(&pr->throttling.status_register, obj.buffer.pointer,
sizeof(struct acpi_ptc_register));
+ throttling = &pr->throttling;
+
+ if ((throttling->control_register.bit_width +
+ throttling->control_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC control register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
+ if ((throttling->status_register.bit_width +
+ throttling->status_register.bit_offset) > 32) {
+ printk(KERN_ERR PREFIX "Invalid _PTC status register\n");
+ result = -EFAULT;
+ goto end;
+ }
+
end:
kfree(buffer.pointer);
@@ -379,7 +396,9 @@ static int acpi_processor_get_throttling
static int acpi_read_throttling_status(struct acpi_processor *pr,
acpi_integer *value)
{
+ u32 bit_width, bit_offset;
u64 ptc_value;
+ u64 ptc_mask;
struct acpi_processor_throttling *throttling;
int ret = -1;
@@ -387,11 +406,14 @@ static int acpi_read_throttling_status(s
switch (throttling->status_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
ptc_value = 0;
+ bit_width = throttling->status_register.bit_width;
+ bit_offset = throttling->status_register.bit_offset;
+
acpi_os_read_port((acpi_io_address) throttling->status_register.
address, (u32 *) &ptc_value,
- (u32) throttling->status_register.bit_width *
- 8);
- *value = (acpi_integer) ptc_value;
+ (u32) (bit_width + bit_offset));
+ ptc_mask = (1 << bit_width) - 1;
+ *value = (acpi_integer) ((ptc_value >> bit_offset) & ptc_mask);
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
@@ -408,18 +430,24 @@ static int acpi_read_throttling_status(s
static int acpi_write_throttling_state(struct acpi_processor *pr,
acpi_integer value)
{
+ u32 bit_width, bit_offset;
u64 ptc_value;
+ u64 ptc_mask;
struct acpi_processor_throttling *throttling;
int ret = -1;
throttling = &pr->throttling;
switch (throttling->control_register.space_id) {
case ACPI_ADR_SPACE_SYSTEM_IO:
- ptc_value = value;
+ bit_width = throttling->control_register.bit_width;
+ bit_offset = throttling->control_register.bit_offset;
+ ptc_mask = (1 << bit_width) - 1;
+ ptc_value = value & ptc_mask;
+
acpi_os_write_port((acpi_io_address) throttling->
- control_register.address, (u32) ptc_value,
- (u32) throttling->control_register.
- bit_width * 8);
+ control_register.address,
+ (u32) (ptc_value << bit_offset),
+ (u32) (bit_width + bit_offset));
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_6/7] ACPI: Init PDC before getting throttling info
2007-10-10 3:43 ` Len Brown
` (18 preceding siblings ...)
2007-11-15 9:05 ` [PATCH_5/7] ACPI: Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
@ 2007-11-15 9:05 ` Zhao Yakui
2007-11-15 9:06 ` [PATCH_7/7] ACPI: Add MSR support for T-States Zhao Yakui
` (3 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:05 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Init PDC before getting throttling info
>From : Zhao Yakui <yakui.zhao@intel.com>
The throttling info should be obtained after PDC is initialized.
Otherwise the cpus maybe use the different PTC control/status register
when the system supports the TSS throttling via ACPI MSR.
One uses the System I/O mode and the other uses the Fixed HW access mode.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
drivers/acpi/processor_core.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
Index: linux-2.6.24-rc1/drivers/acpi/processor_core.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_core.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_core.c
@@ -612,12 +612,6 @@ static int acpi_processor_get_info(struc
request_region(pr->throttling.address, 6, "ACPI CPU throttle");
}
-#ifdef CONFIG_CPU_FREQ
- acpi_processor_ppc_has_changed(pr);
-#endif
- acpi_processor_get_throttling_info(pr);
- acpi_processor_get_limit_info(pr);
-
return 0;
}
@@ -665,6 +659,12 @@ static int __cpuinit acpi_processor_star
/* _PDC call should be done before doing anything else (if reqd.). */
arch_acpi_processor_init_pdc(pr);
acpi_processor_set_pdc(pr);
+#ifdef CONFIG_CPU_FREQ
+ acpi_processor_ppc_has_changed(pr);
+#endif
+ acpi_processor_get_throttling_info(pr);
+ acpi_processor_get_limit_info(pr);
+
acpi_processor_power_init(pr, device);
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH_7/7] ACPI: Add MSR support for T-States
2007-10-10 3:43 ` Len Brown
` (19 preceding siblings ...)
2007-11-15 9:05 ` [PATCH_6/7] ACPI: Init PDC before getting throttling info Zhao Yakui
@ 2007-11-15 9:06 ` Zhao Yakui
2007-11-15 9:18 ` [PATCH] ACPI: Disable all GPEs before re-enable interrupts Zhao Yakui
` (2 subsequent siblings)
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:06 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI : Add MSR support for T-States
>From : Zhao Yakui <yakui.zhao@intel.com>
Add throttling control via MSR when T-states uses the FixHW Control/
Status registers.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
---
arch/x86/kernel/acpi/processor.c | 3 +
drivers/acpi/processor_throttling.c | 74 ++++++++++++++++++++++++++++++++++--
2 files changed, 73 insertions(+), 4 deletions(-)
Index: linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
===================================================================
--- linux-2.6.24-rc1.orig/arch/x86/kernel/acpi/processor.c
+++ linux-2.6.24-rc1/arch/x86/kernel/acpi/processor.c
@@ -49,6 +49,9 @@ static void init_intel_pdc(struct acpi_p
if (cpu_has(c, X86_FEATURE_EST))
buf[2] |= ACPI_PDC_EST_CAPABILITY_SWSMP;
+ if (cpu_has(c, X86_FEATURE_ACPI))
+ buf[2] |= ACPI_PDC_T_FFH;
+
obj->type = ACPI_TYPE_BUFFER;
obj->buffer.length = 12;
obj->buffer.pointer = (u8 *) buf;
Index: linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
===================================================================
--- linux-2.6.24-rc1.orig/drivers/acpi/processor_throttling.c
+++ linux-2.6.24-rc1/drivers/acpi/processor_throttling.c
@@ -393,6 +393,74 @@ static int acpi_processor_get_throttling
return 0;
}
+#ifdef CONFIG_X86
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ struct cpuinfo_x86 *c;
+ u64 msr_high, msr_low;
+ unsigned int cpu;
+ u64 msr = 0;
+ int ret = -1;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr_low = 0;
+ msr_high = 0;
+ rdmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ (u32 *)&msr_low , (u32 *) &msr_high);
+ msr = (msr_high << 32) | msr_low;
+ *value = (acpi_integer) msr;
+ ret = 0;
+ }
+ return ret;
+}
+
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ struct cpuinfo_x86 *c;
+ unsigned int cpu;
+ int ret = -1;
+ u64 msr;
+
+ cpu = pr->id;
+ c = &cpu_data(cpu);
+
+ if ((c->x86_vendor != X86_VENDOR_INTEL) ||
+ !cpu_has(c, X86_FEATURE_ACPI)) {
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ } else {
+ msr = value;
+ wrmsr_on_cpu(cpu, MSR_IA32_THERM_CONTROL,
+ msr & 0xffffffff, msr >> 32);
+ ret = 0;
+ }
+ return ret;
+}
+#else
+static int acpi_throttling_rdmsr(struct acpi_processor *pr,
+ acpi_integer * value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+
+static int acpi_throttling_wrmsr(struct acpi_processor *pr, acpi_integer value)
+{
+ printk(KERN_ERR PREFIX
+ "HARDWARE addr space,NOT supported yet\n");
+ return -1;
+}
+#endif
+
static int acpi_read_throttling_status(struct acpi_processor *pr,
acpi_integer *value)
{
@@ -417,8 +485,7 @@ static int acpi_read_throttling_status(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_rdmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
@@ -451,8 +518,7 @@ static int acpi_write_throttling_state(s
ret = 0;
break;
case ACPI_ADR_SPACE_FIXED_HARDWARE:
- printk(KERN_ERR PREFIX
- "HARDWARE addr space,NOT supported yet\n");
+ ret = acpi_throttling_wrmsr(pr, value);
break;
default:
printk(KERN_ERR PREFIX "Unknown addr space %d\n",
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH] ACPI: Disable all GPEs before re-enable interrupts
2007-10-10 3:43 ` Len Brown
` (20 preceding siblings ...)
2007-11-15 9:06 ` [PATCH_7/7] ACPI: Add MSR support for T-States Zhao Yakui
@ 2007-11-15 9:18 ` Zhao Yakui
2008-05-09 9:22 ` Subject:ACPI: Send the reserved AC notification event to user space Zhao Yakui
2008-05-14 3:32 ` [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler Zhao Yakui
23 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2007-11-15 9:18 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject: ACPI: Disable all GPEs before re-enable interrupts.
From: Zhao Yakui <yakui.zhao@intel.com>
Some wakeup gpes have no handler. If system is waked up by such GPE like
a USB hotplug, sometimes it will cause a lot of errors reporting that
the GPE has no handler .
Of course acpi_leave_sleep_state will disable and clear the GPE but it's
too late. It should be done before interrupt is re-enabled.
Signed-off-by: Li Shaohua <shaohua.li@intel.com>
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/acpi/sleep/main.c | 7 +++++++
1 file changed, 7 insertions(+)
Index: linux-2.6.24-rc2/drivers/acpi/sleep/main.c
===================================================================
--- linux-2.6.24-rc2.orig/drivers/acpi/sleep/main.c
+++ linux-2.6.24-rc2/drivers/acpi/sleep/main.c
@@ -146,6 +146,13 @@ static int acpi_pm_enter(suspend_state_t
if (ACPI_SUCCESS(status) && (acpi_state == ACPI_STATE_S3))
acpi_clear_event(ACPI_EVENT_POWER_BUTTON);
+ /*
+ * Disable and clear GPE status before interrupt is enabled.Some GPEs
+ * (like wakeup GPE) haven't handler, this can avoid such GPE misfire.
+ * acpi_leave_sleep_state will reenable specific GPEs later.
+ */
+ acpi_hw_disable_all_gpes();
+
local_irq_restore(flags);
printk(KERN_DEBUG "Back to C!\n");
^ permalink raw reply [flat|nested] 33+ messages in thread
* Subject:ACPI: Send the reserved AC notification event to user space
2007-10-10 3:43 ` Len Brown
` (21 preceding siblings ...)
2007-11-15 9:18 ` [PATCH] ACPI: Disable all GPEs before re-enable interrupts Zhao Yakui
@ 2008-05-09 9:22 ` Zhao Yakui
2008-05-14 0:55 ` Len Brown
2008-05-14 3:32 ` [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler Zhao Yakui
23 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2008-05-09 9:22 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject:ACPI: Send the reserved AC notification event to user space
>From : Zhao Yakui <yakui.zhao@intel.com>
On some laptops the bogus bios sends the reserved AC notification event(0x81)
when the AC adapter is plugged/unplugged .It can't be sent to
user space, which causes that user space application can't
receive the AC adapter event.
So the reserved AC adapter event(0x81) is still sent to the user space
so that user space can receive the notification event.
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
---
drivers/acpi/ac.c | 4 ++++
1 file changed, 4 insertions(+)
Index: linux-2.6/drivers/acpi/ac.c
===================================================================
--- linux-2.6.orig/drivers/acpi/ac.c
+++ linux-2.6/drivers/acpi/ac.c
@@ -42,6 +42,7 @@
#define ACPI_AC_DEVICE_NAME "AC Adapter"
#define ACPI_AC_FILE_STATE "state"
#define ACPI_AC_NOTIFY_STATUS 0x80
+#define ACPI_AC_NOTIFY_RESERVED 0x81
#define ACPI_AC_STATUS_OFFLINE 0x00
#define ACPI_AC_STATUS_ONLINE 0x01
#define ACPI_AC_STATUS_UNKNOWN 0xFF
@@ -233,6 +234,9 @@ static void acpi_ac_notify(acpi_handle h
device = ac->device;
switch (event) {
+ case ACPI_AC_NOTIFY_RESERVED:
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "Unsupported event [0x%x]\n", event));
case ACPI_AC_NOTIFY_STATUS:
case ACPI_NOTIFY_BUS_CHECK:
case ACPI_NOTIFY_DEVICE_CHECK:
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Subject:ACPI: Send the reserved AC notification event to user space
2008-05-09 9:22 ` Subject:ACPI: Send the reserved AC notification event to user space Zhao Yakui
@ 2008-05-14 0:55 ` Len Brown
2008-05-14 2:47 ` Zhao Yakui
0 siblings, 1 reply; 33+ messages in thread
From: Len Brown @ 2008-05-14 0:55 UTC (permalink / raw)
To: Zhao Yakui; +Cc: linux-acpi
On Friday 09 May 2008, Zhao Yakui wrote:
> Subject:ACPI: Send the reserved AC notification event to user space
> >From : Zhao Yakui <yakui.zhao@intel.com>
>
> On some laptops the bogus bios sends the reserved AC notification event(0x81)
> when the AC adapter is plugged/unplugged .It can't be sent to
> user space, which causes that user space application can't
> receive the AC adapter event.
> So the reserved AC adapter event(0x81) is still sent to the user space
> so that user space can receive the notification event.
>
> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> ---
> drivers/acpi/ac.c | 4 ++++
> 1 file changed, 4 insertions(+)
>
> Index: linux-2.6/drivers/acpi/ac.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/ac.c
> +++ linux-2.6/drivers/acpi/ac.c
> @@ -42,6 +42,7 @@
> #define ACPI_AC_DEVICE_NAME "AC Adapter"
> #define ACPI_AC_FILE_STATE "state"
> #define ACPI_AC_NOTIFY_STATUS 0x80
> +#define ACPI_AC_NOTIFY_RESERVED 0x81
> #define ACPI_AC_STATUS_OFFLINE 0x00
> #define ACPI_AC_STATUS_ONLINE 0x01
> #define ACPI_AC_STATUS_UNKNOWN 0xFF
> @@ -233,6 +234,9 @@ static void acpi_ac_notify(acpi_handle h
>
> device = ac->device;
> switch (event) {
> + case ACPI_AC_NOTIFY_RESERVED:
shouldn't this line above be "default:"
and the default: below this patch be removed?
-Len
> + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> + "Unsupported event [0x%x]\n", event));
> case ACPI_AC_NOTIFY_STATUS:
> case ACPI_NOTIFY_BUS_CHECK:
> case ACPI_NOTIFY_DEVICE_CHECK:
>
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at http://vger.kernel.org/majordomo-info.html
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Subject:ACPI: Send the reserved AC notification event to user space
2008-05-14 0:55 ` Len Brown
@ 2008-05-14 2:47 ` Zhao Yakui
2008-05-14 23:04 ` Len Brown
0 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2008-05-14 2:47 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
On Tue, 2008-05-13 at 20:55 -0400, Len Brown wrote:
> On Friday 09 May 2008, Zhao Yakui wrote:
> > Subject:ACPI: Send the reserved AC notification event to user space
> > >From : Zhao Yakui <yakui.zhao@intel.com>
> >
> > On some laptops the bogus bios sends the reserved AC notification event(0x81)
> > when the AC adapter is plugged/unplugged .It can't be sent to
> > user space, which causes that user space application can't
> > receive the AC adapter event.
> > So the reserved AC adapter event(0x81) is still sent to the user space
> > so that user space can receive the notification event.
> >
> > Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> > ---
> > drivers/acpi/ac.c | 4 ++++
> > 1 file changed, 4 insertions(+)
> >
> > Index: linux-2.6/drivers/acpi/ac.c
> > ===================================================================
> > --- linux-2.6.orig/drivers/acpi/ac.c
> > +++ linux-2.6/drivers/acpi/ac.c
> > @@ -42,6 +42,7 @@
> > #define ACPI_AC_DEVICE_NAME "AC Adapter"
> > #define ACPI_AC_FILE_STATE "state"
> > #define ACPI_AC_NOTIFY_STATUS 0x80
> > +#define ACPI_AC_NOTIFY_RESERVED 0x81
> > #define ACPI_AC_STATUS_OFFLINE 0x00
> > #define ACPI_AC_STATUS_ONLINE 0x01
> > #define ACPI_AC_STATUS_UNKNOWN 0xFF
> > @@ -233,6 +234,9 @@ static void acpi_ac_notify(acpi_handle h
> >
> > device = ac->device;
> > switch (event) {
> > + case ACPI_AC_NOTIFY_RESERVED:
>
> shouldn't this line above be "default:"
If the follwing debug info is not needed, it will be OK to put it above
the "default" branch.
> "Unsupported event [0x%x]\n", event.
When this line is put above the "AC_NOTIFY_STATUS" branch, it can send
the notification event to user space while printing the debug info.
> and the default: below this patch be removed?
Had better not remove the default branch. If other type of notification
event is sent to AC device, the debug info can be printed. It will be
helpful to find the root cause.
> -Len
>
> > + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> > + "Unsupported event [0x%x]\n", event));
> > case ACPI_AC_NOTIFY_STATUS:
> > case ACPI_NOTIFY_BUS_CHECK:
> > case ACPI_NOTIFY_DEVICE_CHECK:
> >
> >
> > --
> > To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> > the body of a message to majordomo@vger.kernel.org
> > More majordomo info at http://vger.kernel.org/majordomo-info.html
> >
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler
2007-10-10 3:43 ` Len Brown
` (22 preceding siblings ...)
2008-05-09 9:22 ` Subject:ACPI: Send the reserved AC notification event to user space Zhao Yakui
@ 2008-05-14 3:32 ` Zhao Yakui
2008-05-14 4:33 ` Len Brown
23 siblings, 1 reply; 33+ messages in thread
From: Zhao Yakui @ 2008-05-14 3:32 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
Subject:ACPI: Disable Fixed_RTC event when installing RTC handler
>From : Zhao Yakui <yakui.zhao@intel.com>
The Fixed_RTC event should be disabled when installing RTC handler.
Only when RTC alarm is set will it be enabled again. If it is not
disabled, maybe some machines will be powered on automatically after
the system is shutdown even when the RTC alarm is not set.
http://bugzilla.kernel.org/show_bug.cgi?id=10010
Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
Signed-off-by: Zhang Rui <rui.zhang@intel.com>
---
drivers/acpi/glue.c | 6 ++++++
drivers/acpi/sleep/proc.c | 6 ++++++
2 files changed, 12 insertions(+)
Index: linux-2.6/drivers/acpi/glue.c
===================================================================
--- linux-2.6.orig/drivers/acpi/glue.c
+++ linux-2.6/drivers/acpi/glue.c
@@ -272,6 +272,12 @@ static u32 rtc_handler(void *context)
static inline void rtc_wake_setup(void)
{
acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
+ /*
+ * After the RTC handler is installed, the Fixed_RTC event should
+ * be disabled. Only when the RTC alarm is set will it be enabled.
+ */
+ acpi_clear_event(ACPI_EVENT_RTC);
+ acpi_disable_event(ACPI_EVENT_RTC, 0);
}
static void rtc_wake_on(struct device *dev)
Index: linux-2.6/drivers/acpi/sleep/proc.c
===================================================================
--- linux-2.6.orig/drivers/acpi/sleep/proc.c
+++ linux-2.6/drivers/acpi/sleep/proc.c
@@ -495,6 +495,12 @@ static int __init acpi_sleep_proc_init(v
acpi_root_dir, &acpi_system_alarm_fops);
acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
+ /*
+ * Disable the RTC event after installing RTC handler.
+ * Only when RTC alarm is set will it be enabled.
+ */
+ acpi_clear_event(ACPI_EVENT_RTC);
+ acpi_disable_event(ACPI_EVENT_RTC, 0);
#endif /* HAVE_ACPI_LEGACY_ALARM */
/* 'wakeup device' [R/W] */
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler
2008-05-14 3:32 ` [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler Zhao Yakui
@ 2008-05-14 4:33 ` Len Brown
0 siblings, 0 replies; 33+ messages in thread
From: Len Brown @ 2008-05-14 4:33 UTC (permalink / raw)
To: Zhao Yakui; +Cc: linux-acpi
Applied.
thanks,
-Len
On Tuesday 13 May 2008, Zhao Yakui wrote:
> Subject:ACPI: Disable Fixed_RTC event when installing RTC handler
> >From : Zhao Yakui <yakui.zhao@intel.com>
>
> The Fixed_RTC event should be disabled when installing RTC handler.
> Only when RTC alarm is set will it be enabled again. If it is not
> disabled, maybe some machines will be powered on automatically after
> the system is shutdown even when the RTC alarm is not set.
>
> http://bugzilla.kernel.org/show_bug.cgi?id=10010
>
> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> Signed-off-by: Zhang Rui <rui.zhang@intel.com>
>
> ---
> drivers/acpi/glue.c | 6 ++++++
> drivers/acpi/sleep/proc.c | 6 ++++++
> 2 files changed, 12 insertions(+)
>
> Index: linux-2.6/drivers/acpi/glue.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/glue.c
> +++ linux-2.6/drivers/acpi/glue.c
> @@ -272,6 +272,12 @@ static u32 rtc_handler(void *context)
> static inline void rtc_wake_setup(void)
> {
> acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
> + /*
> + * After the RTC handler is installed, the Fixed_RTC event should
> + * be disabled. Only when the RTC alarm is set will it be enabled.
> + */
> + acpi_clear_event(ACPI_EVENT_RTC);
> + acpi_disable_event(ACPI_EVENT_RTC, 0);
> }
>
> static void rtc_wake_on(struct device *dev)
> Index: linux-2.6/drivers/acpi/sleep/proc.c
> ===================================================================
> --- linux-2.6.orig/drivers/acpi/sleep/proc.c
> +++ linux-2.6/drivers/acpi/sleep/proc.c
> @@ -495,6 +495,12 @@ static int __init acpi_sleep_proc_init(v
> acpi_root_dir, &acpi_system_alarm_fops);
>
> acpi_install_fixed_event_handler(ACPI_EVENT_RTC, rtc_handler, NULL);
> + /*
> + * Disable the RTC event after installing RTC handler.
> + * Only when RTC alarm is set will it be enabled.
> + */
> + acpi_clear_event(ACPI_EVENT_RTC);
> + acpi_disable_event(ACPI_EVENT_RTC, 0);
> #endif /* HAVE_ACPI_LEGACY_ALARM */
>
> /* 'wakeup device' [R/W] */
>
>
^ permalink raw reply [flat|nested] 33+ messages in thread
* Re: Subject:ACPI: Send the reserved AC notification event to user space
2008-05-14 2:47 ` Zhao Yakui
@ 2008-05-14 23:04 ` Len Brown
2008-05-15 13:55 ` Zhao Yakui
0 siblings, 1 reply; 33+ messages in thread
From: Len Brown @ 2008-05-14 23:04 UTC (permalink / raw)
To: Zhao Yakui; +Cc: linux-acpi
On Tuesday 13 May 2008, Zhao Yakui wrote:
> On Tue, 2008-05-13 at 20:55 -0400, Len Brown wrote:
> > On Friday 09 May 2008, Zhao Yakui wrote:
> > > Subject:ACPI: Send the reserved AC notification event to user space
> > > >From : Zhao Yakui <yakui.zhao@intel.com>
> > >
> > > On some laptops the bogus bios sends the reserved AC notification event(0x81)
> > > when the AC adapter is plugged/unplugged .It can't be sent to
> > > user space, which causes that user space application can't
> > > receive the AC adapter event.
> > > So the reserved AC adapter event(0x81) is still sent to the user space
> > > so that user space can receive the notification event.
> > >
> > > Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
> > > ---
> > > drivers/acpi/ac.c | 4 ++++
> > > 1 file changed, 4 insertions(+)
> > >
> > > Index: linux-2.6/drivers/acpi/ac.c
> > > ===================================================================
> > > --- linux-2.6.orig/drivers/acpi/ac.c
> > > +++ linux-2.6/drivers/acpi/ac.c
> > > @@ -42,6 +42,7 @@
> > > #define ACPI_AC_DEVICE_NAME "AC Adapter"
> > > #define ACPI_AC_FILE_STATE "state"
> > > #define ACPI_AC_NOTIFY_STATUS 0x80
> > > +#define ACPI_AC_NOTIFY_RESERVED 0x81
> > > #define ACPI_AC_STATUS_OFFLINE 0x00
> > > #define ACPI_AC_STATUS_ONLINE 0x01
> > > #define ACPI_AC_STATUS_UNKNOWN 0xFF
> > > @@ -233,6 +234,9 @@ static void acpi_ac_notify(acpi_handle h
> > >
> > > device = ac->device;
> > > switch (event) {
> > > + case ACPI_AC_NOTIFY_RESERVED:
> >
> > shouldn't this line above be "default:"
> If the follwing debug info is not needed, it will be OK to put it above
> the "default" branch.
> > "Unsupported event [0x%x]\n", event.
> When this line is put above the "AC_NOTIFY_STATUS" branch, it can send
> the notification event to user space while printing the debug info.
> > and the default: below this patch be removed?
> Had better not remove the default branch. If other type of notification
> event is sent to AC device, the debug info can be printed. It will be
> helpful to find the root cause.
> > -Len
> >
> > > + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> > > + "Unsupported event [0x%x]\n", event));
> > > case ACPI_AC_NOTIFY_STATUS:
> > > case ACPI_NOTIFY_BUS_CHECK:
> > > case ACPI_NOTIFY_DEVICE_CHECK:
> > >
> > >
Maybe I'm too tired to parse what you're saying.
What is the matter with doing it this way:
(this is now bugzilla 10695, btw.
diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
index 5b73f6a..831883b 100644
--- a/drivers/acpi/ac.c
+++ b/drivers/acpi/ac.c
@@ -233,6 +233,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
device = ac->device;
switch (event) {
+ default:
+ ACPI_DEBUG_PRINT((ACPI_DB_INFO,
+ "Unsupported event [0x%x]\n", event));
case ACPI_AC_NOTIFY_STATUS:
case ACPI_NOTIFY_BUS_CHECK:
case ACPI_NOTIFY_DEVICE_CHECK:
@@ -244,11 +247,6 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
#ifdef CONFIG_ACPI_SYSFS_POWER
kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
#endif
- break;
- default:
- ACPI_DEBUG_PRINT((ACPI_DB_INFO,
- "Unsupported event [0x%x]\n", event));
- break;
}
return;
^ permalink raw reply related [flat|nested] 33+ messages in thread
* Re: Subject:ACPI: Send the reserved AC notification event to user space
2008-05-14 23:04 ` Len Brown
@ 2008-05-15 13:55 ` Zhao Yakui
0 siblings, 0 replies; 33+ messages in thread
From: Zhao Yakui @ 2008-05-15 13:55 UTC (permalink / raw)
To: Len Brown; +Cc: linux-acpi
On Wed, 2008-05-14 at 19:04 -0400, Len Brown wrote:
> Maybe I'm too tired to parse what you're saying.
> What is the matter with doing it this way:
> (this is now bugzilla 10695, btw.
>
The following patch is OK. Of course the matter is that all the reserved
events will be sent to the user space. For example: 0x82, 0x83. Even the
invalid event will also be sent.
In my patch only the 0x81 reserved event is sent to the user space. For
the invalid events and other reserved events(For example : 0x82, 0x83),
only warning message is printed but they won't be sent to the user
space.
>
> diff --git a/drivers/acpi/ac.c b/drivers/acpi/ac.c
> index 5b73f6a..831883b 100644
> --- a/drivers/acpi/ac.c
> +++ b/drivers/acpi/ac.c
> @@ -233,6 +233,9 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
>
> device = ac->device;
> switch (event) {
> + default:
> + ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> + "Unsupported event [0x%x]\n", event));
> case ACPI_AC_NOTIFY_STATUS:
> case ACPI_NOTIFY_BUS_CHECK:
> case ACPI_NOTIFY_DEVICE_CHECK:
> @@ -244,11 +247,6 @@ static void acpi_ac_notify(acpi_handle handle, u32 event, void *data)
> #ifdef CONFIG_ACPI_SYSFS_POWER
> kobject_uevent(&ac->charger.dev->kobj, KOBJ_CHANGE);
> #endif
> - break;
> - default:
> - ACPI_DEBUG_PRINT((ACPI_DB_INFO,
> - "Unsupported event [0x%x]\n", event));
> - break;
> }
>
> return;
>
^ permalink raw reply [flat|nested] 33+ messages in thread
end of thread, other threads:[~2008-05-15 13:46 UTC | newest]
Thread overview: 33+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-10-08 3:35 [PATCH] ACPI:avoid printing the error message that processor device is not present Zhao Yakui
2007-10-10 3:43 ` Len Brown
2007-10-15 1:19 ` Zhao Yakui
2007-11-07 12:34 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
2007-11-07 12:34 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
2007-11-07 12:35 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
2007-11-07 12:35 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
2007-11-08 0:56 ` [PATCH_1/4] :Add the _TPC throttling limit for TSS Zhao Yakui
2007-11-15 2:52 ` Len Brown
2007-11-08 0:56 ` [PATCH_2/4] : Modify the ACPI I/O Access width Zhao Yakui
2007-11-08 0:57 ` [Patch_3/4]:Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
2007-11-08 0:57 ` [Patch_4/4] :Add MSR support for T-States Zhao Yakui
2007-11-15 3:22 ` Len Brown
2007-11-08 1:25 ` [PATCH] [ACPI ]: Init PDC before getting throttling info Zhao Yakui
2007-11-15 8:41 ` [PATCH_2/7] : Modify the ACPI I/O Access width Zhao Yakui
2007-11-15 8:41 ` [Patch_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
2007-11-15 8:41 ` [Patch_4/7] :Change the function interface for throttling control via PTC Zhao Yakui
2007-11-15 8:42 ` [Patch_5/7 ] :Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
2007-11-15 8:59 ` [PATCH_1/7] ACPI: Add the _TPC throttling limit for TSS Zhao Yakui
2007-11-15 9:01 ` [PATCH_2/7] ACPI: Modify the ACPI I/O Access width Zhao Yakui
2007-11-15 9:02 ` [PATCH_3/7] ACPI: Not use calculated T-states from FADT.duty_width when _TSS exists Zhao Yakui
2007-11-15 9:03 ` [PATCH_4/7] ACPI: Change the function interface for throttling control via PTC Zhao Yakui
2007-11-15 9:05 ` [PATCH_5/7] ACPI: Throttling control uses T-states returned by _TSS when _TSS exists Zhao Yakui
2007-11-15 9:05 ` [PATCH_6/7] ACPI: Init PDC before getting throttling info Zhao Yakui
2007-11-15 9:06 ` [PATCH_7/7] ACPI: Add MSR support for T-States Zhao Yakui
2007-11-15 9:18 ` [PATCH] ACPI: Disable all GPEs before re-enable interrupts Zhao Yakui
2008-05-09 9:22 ` Subject:ACPI: Send the reserved AC notification event to user space Zhao Yakui
2008-05-14 0:55 ` Len Brown
2008-05-14 2:47 ` Zhao Yakui
2008-05-14 23:04 ` Len Brown
2008-05-15 13:55 ` Zhao Yakui
2008-05-14 3:32 ` [PATCH]: ACPI: Disable Fixed_RTC event when installing RTC handler Zhao Yakui
2008-05-14 4:33 ` Len Brown
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).