* [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones
@ 2012-05-04 16:53 Marco Aurelio da Costa
2012-05-07 14:42 ` Marco Aurelio da Costa
2012-05-08 5:59 ` Len Brown
0 siblings, 2 replies; 5+ messages in thread
From: Marco Aurelio da Costa @ 2012-05-04 16:53 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk; +Cc: linux-acpi, Len Brown
From: Marco Aurelio da Costa <costa@gamic.com>
[v3: Fixes suggested by Konrad]
Signed-off-by: Marco Aurelio da Costa <costa@gamic.com>
The EliteBook 8560W has non-initialized entries in its _PSS ACPI
table. Instead of bailing out when the first non-initialized entry is
found, ignore it and use only the valid entries. Only bail out if there
is no valid entry at all.
---
--- linux-3.3.3/drivers/acpi/processor_perflib.c.orig 2012-04-24
22:18:23.288041268 +0200
+++ linux-3.3.3/drivers/acpi/processor_perflib.c 2012-05-04
18:23:02.640111246 +0200
@@ -311,6 +311,7 @@ static int acpi_processor_get_performanc
struct acpi_buffer state = { 0, NULL };
union acpi_object *pss = NULL;
int i;
+ int last_invalid = -1;
status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
@@ -372,14 +373,33 @@ static int acpi_processor_get_performanc
((u32)(px->core_frequency * 1000) !=
(px->core_frequency * 1000))) {
printk(KERN_ERR FW_BUG PREFIX
- "Invalid BIOS _PSS frequency: 0x%llx MHz\n",
- px->core_frequency);
- result = -EFAULT;
- kfree(pr->performance->states);
- goto end;
+ "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
+ pr->id, px->core_frequency);
+ if (last_invalid == -1)
+ last_invalid = i;
+ } else {
+ if (last_invalid != -1) {
+ /*
+ * Copy this valid entry over last_invalid entry
+ */
+ memcpy(&(pr->performance->states[last_invalid]),
+ px, sizeof(struct acpi_processor_px));
+ ++last_invalid;
+ }
}
}
+ if (last_invalid == 0) {
+ printk(KERN_ERR FW_BUG PREFIX
+ "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
+ result = -EFAULT;
+ kfree(pr->performance->states);
+ pr->performance->states = NULL;
+ }
+
+ if (last_invalid > 0)
+ pr->performance->state_count = last_invalid;
+
end:
kfree(buffer.pointer);
--
Marco Costa
Customer Support
--
GAMIC mbH
Roermonder Strasse, 151
52072 Aachen
Germany
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones
2012-05-04 16:53 [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones Marco Aurelio da Costa
@ 2012-05-07 14:42 ` Marco Aurelio da Costa
2012-05-07 17:27 ` Konrad Rzeszutek Wilk
2012-05-08 5:59 ` Len Brown
1 sibling, 1 reply; 5+ messages in thread
From: Marco Aurelio da Costa @ 2012-05-07 14:42 UTC (permalink / raw)
To: Konrad Rzeszutek Wilk; +Cc: linux-acpi, Len Brown
Hi, Konrad.
Should I change anything else?
I tested the changes in my notebook and it is working fine.
Cheers.
On Fri, May 4, 2012 at 1:53 PM, Marco Aurelio da Costa <costa@gamic.com> wrote:
> From: Marco Aurelio da Costa <costa@gamic.com>
> [v3: Fixes suggested by Konrad]
> Signed-off-by: Marco Aurelio da Costa <costa@gamic.com>
>
> The EliteBook 8560W has non-initialized entries in its _PSS ACPI
> table. Instead of bailing out when the first non-initialized entry is
> found, ignore it and use only the valid entries. Only bail out if there
> is no valid entry at all.
>
> ---
> --- linux-3.3.3/drivers/acpi/processor_perflib.c.orig 2012-04-24
> 22:18:23.288041268 +0200
> +++ linux-3.3.3/drivers/acpi/processor_perflib.c 2012-05-04
> 18:23:02.640111246 +0200
> @@ -311,6 +311,7 @@ static int acpi_processor_get_performanc
> struct acpi_buffer state = { 0, NULL };
> union acpi_object *pss = NULL;
> int i;
> + int last_invalid = -1;
>
>
> status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
> @@ -372,14 +373,33 @@ static int acpi_processor_get_performanc
> ((u32)(px->core_frequency * 1000) !=
> (px->core_frequency * 1000))) {
> printk(KERN_ERR FW_BUG PREFIX
> - "Invalid BIOS _PSS frequency: 0x%llx MHz\n",
> - px->core_frequency);
> - result = -EFAULT;
> - kfree(pr->performance->states);
> - goto end;
> + "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
> + pr->id, px->core_frequency);
> + if (last_invalid == -1)
> + last_invalid = i;
> + } else {
> + if (last_invalid != -1) {
> + /*
> + * Copy this valid entry over last_invalid entry
> + */
> + memcpy(&(pr->performance->states[last_invalid]),
> + px, sizeof(struct acpi_processor_px));
> + ++last_invalid;
> + }
> }
> }
>
> + if (last_invalid == 0) {
> + printk(KERN_ERR FW_BUG PREFIX
> + "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
> + result = -EFAULT;
> + kfree(pr->performance->states);
> + pr->performance->states = NULL;
> + }
> +
> + if (last_invalid > 0)
> + pr->performance->state_count = last_invalid;
> +
> end:
> kfree(buffer.pointer);
>
> --
> Marco Costa
> Customer Support
> --
> GAMIC mbH
> Roermonder Strasse, 151
> 52072 Aachen
> Germany
--
Marco Costa
Customer Support
--
GAMIC mbH
Roermonder Strasse, 151
52072 Aachen
Germany
^ permalink raw reply [flat|nested] 5+ messages in thread* Re: [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones
2012-05-07 14:42 ` Marco Aurelio da Costa
@ 2012-05-07 17:27 ` Konrad Rzeszutek Wilk
0 siblings, 0 replies; 5+ messages in thread
From: Konrad Rzeszutek Wilk @ 2012-05-07 17:27 UTC (permalink / raw)
To: Marco Aurelio da Costa; +Cc: linux-acpi, Len Brown
On Mon, May 07, 2012 at 11:42:13AM -0300, Marco Aurelio da Costa wrote:
> Hi, Konrad.
>
> Should I change anything else?
It looks fine to my eyes. Len has the final word.
> I tested the changes in my notebook and it is working fine.
Cool.
>
> Cheers.
>
> On Fri, May 4, 2012 at 1:53 PM, Marco Aurelio da Costa <costa@gamic.com> wrote:
> > From: Marco Aurelio da Costa <costa@gamic.com>
> > [v3: Fixes suggested by Konrad]
> > Signed-off-by: Marco Aurelio da Costa <costa@gamic.com>
> >
> > The EliteBook 8560W has non-initialized entries in its _PSS ACPI
> > table. Instead of bailing out when the first non-initialized entry is
> > found, ignore it and use only the valid entries. Only bail out if there
> > is no valid entry at all.
> >
> > ---
> > --- linux-3.3.3/drivers/acpi/processor_perflib.c.orig 2012-04-24
> > 22:18:23.288041268 +0200
> > +++ linux-3.3.3/drivers/acpi/processor_perflib.c 2012-05-04
> > 18:23:02.640111246 +0200
> > @@ -311,6 +311,7 @@ static int acpi_processor_get_performanc
> > struct acpi_buffer state = { 0, NULL };
> > union acpi_object *pss = NULL;
> > int i;
> > + int last_invalid = -1;
> >
> >
> > status = acpi_evaluate_object(pr->handle, "_PSS", NULL, &buffer);
> > @@ -372,14 +373,33 @@ static int acpi_processor_get_performanc
> > ((u32)(px->core_frequency * 1000) !=
> > (px->core_frequency * 1000))) {
> > printk(KERN_ERR FW_BUG PREFIX
> > - "Invalid BIOS _PSS frequency: 0x%llx MHz\n",
> > - px->core_frequency);
> > - result = -EFAULT;
> > - kfree(pr->performance->states);
> > - goto end;
> > + "Invalid BIOS _PSS frequency found for processor %d: 0x%llx MHz\n",
> > + pr->id, px->core_frequency);
> > + if (last_invalid == -1)
> > + last_invalid = i;
> > + } else {
> > + if (last_invalid != -1) {
> > + /*
> > + * Copy this valid entry over last_invalid entry
> > + */
> > + memcpy(&(pr->performance->states[last_invalid]),
> > + px, sizeof(struct acpi_processor_px));
> > + ++last_invalid;
> > + }
> > }
> > }
> >
> > + if (last_invalid == 0) {
> > + printk(KERN_ERR FW_BUG PREFIX
> > + "No valid BIOS _PSS frequency found for processor %d\n", pr->id);
> > + result = -EFAULT;
> > + kfree(pr->performance->states);
> > + pr->performance->states = NULL;
> > + }
> > +
> > + if (last_invalid > 0)
> > + pr->performance->state_count = last_invalid;
> > +
> > end:
> > kfree(buffer.pointer);
> >
> > --
> > Marco Costa
> > Customer Support
> > --
> > GAMIC mbH
> > Roermonder Strasse, 151
> > 52072 Aachen
> > Germany
>
>
>
> --
> Marco Costa
> Customer Support
> --
> GAMIC mbH
> Roermonder Strasse, 151
> 52072 Aachen
> Germany
--
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] 5+ messages in thread
* Re: [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones
2012-05-04 16:53 [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones Marco Aurelio da Costa
2012-05-07 14:42 ` Marco Aurelio da Costa
@ 2012-05-08 5:59 ` Len Brown
2012-05-08 11:13 ` Marco Aurelio da Costa
1 sibling, 1 reply; 5+ messages in thread
From: Len Brown @ 2012-05-08 5:59 UTC (permalink / raw)
To: Marco Aurelio da Costa; +Cc: Konrad Rzeszutek Wilk, linux-acpi
A BIOS bug workaround like this is sort of a guessing game...
What additional benefit do we get by making the workaround more complicated?
thanks,
-Len
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones
2012-05-08 5:59 ` Len Brown
@ 2012-05-08 11:13 ` Marco Aurelio da Costa
0 siblings, 0 replies; 5+ messages in thread
From: Marco Aurelio da Costa @ 2012-05-08 11:13 UTC (permalink / raw)
To: Len Brown; +Cc: Konrad Rzeszutek Wilk, linux-acpi
Hi, Len.
We are just using the data that is valid and ignoring the invalid
ones. The benefit is that we will have frequency control working on
Linux even if the table is not 100% correct.
We are not guessing anything, from what I see. This is not specific to
a brand or manufacturer. The test for the entry was there all along,
so the workaround is just improving on the simple case (bail out
completely and lose the capability).
With this patch, my battery lasts around 4h. Without it, less then 1h.
Cheers
On Tue, May 8, 2012 at 7:59 AM, Len Brown <lenb@kernel.org> wrote:
> A BIOS bug workaround like this is sort of a guessing game...
>
> What additional benefit do we get by making the workaround more complicated?
>
> thanks,
> -Len
>
--
Marco Costa
Customer Support
--
GAMIC mbH
Roermonder Strasse, 151
52072 Aachen
Germany
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2012-05-08 11:13 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-04 16:53 [RFC][PATCH v3]: ACPI: Ignore invalid _PSS entries, but use valid ones Marco Aurelio da Costa
2012-05-07 14:42 ` Marco Aurelio da Costa
2012-05-07 17:27 ` Konrad Rzeszutek Wilk
2012-05-08 5:59 ` Len Brown
2012-05-08 11:13 ` Marco Aurelio da Costa
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox