Re: [RFC][PATCH] ACPI: Ignore invalid _PSS entries, but use valid ones

From: Marco Aurelio da Costa
Date: Fri May 04 2012 - 10:13:21 EST


Hi, Konrad.

On Fri, May 4, 2012 at 10:52 AM, Konrad Rzeszutek Wilk
<konrad.wilk@xxxxxxxxxx> wrote:
> On Fri, May 04, 2012 at 10:46:01AM -0300, Marco Aurelio da Costa wrote:
>> From: Marco Aurelio da Costa <costa@xxxxxxxxx>
>> Signed-off-by: Marco Aurelio da Costa <costa@xxxxxxxxx>
>>
>> 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.
>
> Is that safe? Meaning re-use the other CPU's _PSS states? Perhaps the
> warning at the end should say: "Trying to compensate by using the
> other CPU's PSS state).

This case in question was created by HP removing the overclock options
and leaving the entries in a invalid/empty situation. In this specific
case, it is safe.
I am not changing the table in any way, I just ignore the
non-initialized entries. The code only use listed states. If they are
CPU bound, the code doesn't assume anything.

>
>>
>> ---
>> --- 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-04-24
>> 22:19:25.912042603 +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);
>> @@ -374,12 +375,30 @@ static int acpi_processor_get_performanc
>> Â Â Â Â Â Â Â Â Â Â Â Â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;
>> + Â Â Â Â Â Â Â Â Â Â Â if (-1 == last_invalid)
>
> Swap it around or just do it this way:

Ok.

>
> if (last_invalid < 0)
>
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â last_invalid = i;
>> + Â Â Â Â Â Â Â } else {
>> + Â Â Â Â Â Â Â Â Â Â Â if (last_invalid != -1) {
>
> if (last_invalid >= 0)
>
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â /*
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â* Copy this valid entry over last_invalid entry
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â*/
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â memcpy(&(pr->performance->states[last_invalid]),
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â Âpx, sizeof(struct acpi_processor_px));
>> + Â Â Â Â Â Â Â Â Â Â Â Â Â Â Â ++last_invalid;
>> + Â Â Â Â Â Â Â Â Â Â Â }
>> Â Â Â Â Â Â Â Â}
>> Â Â Â Â}
>>
>> + Â Â Â if (0 == last_invalid) {
>
> So if _PSS that is missing is at CPU2, this own't print it.

I don't get what do you mean by CPU. last_invalid is just the last
invalid _PSS entry item. Nothing to do with the CPU.

>
> I think you want 'if (last_invalid >= 0)'

No, it is correct. If the last invalid found item is the item 0, than
it means that no valid item was found.

>
>> + Â Â Â Â Â Â Â printk(KERN_ERR FW_BUG PREFIX
>> + Â Â Â Â Â Â Â Â Â Â Â"No valid BIOS _PSS frequency found\n");
>
> And you should mention which CPU has it busted - as there are
> some that are working.

No CPU here, just the _PSS item.

>
>
>> + Â Â Â Â Â Â Â result = -EFAULT;
>> + Â Â Â Â Â Â Â kfree(pr->performance->states);
>> + Â Â Â }
>> +
>> + Â Â Â if (last_invalid > 0)
>
> Don't you want 'last_invalid >= 0' ?

No. It is correct. If the last invalid item is greater than 0, then
there was at least 1 valid _PSS entry. And the count of valid entries
is the same as the last_invalid variable.

>
>> + Â Â Â Â Â Â Â pr->performance->state_count = last_invalid;
>> +
>> Â Â Â end:
>> Â Â Â Âkfree(buffer.pointer);
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
>> the body of a message to majordomo@xxxxxxxxxxxxxxx
>> More majordomo info at Âhttp://vger.kernel.org/majordomo-info.html

I will send the corrected patch next.


--
Marco Costa
Customer Support
--
GAMIC mbH
Roermonder Strasse, 151
52072 Aachen
Germany
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/