linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Hans de Goede <hdegoede@redhat.com>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: Mario Limonciello <mario.limonciello@outlook.com>,
	"Rafael J. Wysocki" <rafael@kernel.org>,
	"Rafael J . Wysocki" <rjw@rjwysocki.net>,
	linux-acpi <linux-acpi@vger.kernel.org>
Subject: Re: Some SSDT tables are not loading with kernel >= 5.12
Date: Tue, 8 Jun 2021 15:24:28 +0200	[thread overview]
Message-ID: <edeba86c-1db7-e547-09a0-27da405155b3@redhat.com> (raw)
In-Reply-To: <YL9YOlLosVeYfuuu@lahna.fi.intel.com>

Hi,

On 6/8/21 1:44 PM, Mika Westerberg wrote:
> Hi,
> 
> On Tue, Jun 08, 2021 at 11:50:15AM +0200, Hans de Goede wrote:
>> Hi,
>>
>> On 6/7/21 9:18 PM, Hans de Goede wrote:
>>> Hi,
>>>
>>> On 6/7/21 6:08 PM, Mika Westerberg wrote:
>>>> Hi,
>>>>
>>>> Tried now on ADL-P and TGL systems and the _OSC still works properly.
>>>>
>>>> Thanks Hans for fixing!
>>>>
>>>> Feel free to add my Tested-by.
>>>
>>> Thank you for testing, unfortunately so far from the comments here:
>>>
>>> https://bugzilla.kernel.org/show_bug.cgi?id=213023
>>>
>>> it seems that my patch does not help resolve the issues caused
>>> by commit 719e1f561afb ("ACPI: Execute platform _OSC also with query
>>> bit clear"), where as reverting that commit does resolve them :|
>>>
>>> Does anyone have any other ideas how to fix this ?
>>
>> The reporter who has done the bisect has commented out the new/second
>> _OSC call and that fixes things for them. So I've written a new fix
>> (attached), note just as before this is untested ATM.
>>
>> Mika, if you can test this one (it replaces the previous one)
>> on machines with native USB4 support to check those don't regress then
>> that would be great.
> 
> I can test it sure, but first let's try to understand what the problem is :)
> 
>> I've asked the various reporters from the 2 bugzilla's for this to also
>> test this new patch. I'll let you know how that goes.
> 
> The _OSC on at least one of the affected platforms look like this:
> 
>     If ((Arg0 == ToUUID ("0811b06e-4a27-44f9-8d60-3cbbc22e7b48") /* Platform-wide Capabilities */))
>     {
> 	If ((Arg1 == One))
> 	{
> 	    OSCP = CAP0 /* \_SB_._OSC.CAP0 */
> 	    If ((CAP0 & 0x04))
> 	    {
> 		OSCO = 0x04
> 		If (((SGMD & 0x0F) != 0x02))
> 		{
> 		    If ((RTD3 == Zero))
> 		    {
> 			CAP0 &= 0x3B
> 			STS0 |= 0x10
> 		    }
> 		}
> 	    }
> 	}
> 	Else
> 	{
> 	    STS0 &= 0xFFFFFF00
> 	    STS0 |= 0x0A
> 	}
>     }
>     Else
>     {
> 	STS0 &= 0xFFFFFF00
> 	STS0 |= 0x06
>     }
> 
> Probably it is fine to call it several times but the issue is with the mask
> that it does:
> 
>     CAP0 &= 0x3B
> 
> This clears out the upper bits. I think this is actually a BIOS bug as it ends
> up clearing OSC_SB_PCLPI_SUPPORT which is probably not intented, and that seems
> to cause skipping of the LPI tables or something like that.
> 
> The alternative is to pass the original caps to the second _OSC call. I think
> this is safe too. While looking at the code, I found a couple of other issues
> that should be fixed with the below hack patch.
> 
> What do you think about this approach?

I think you might be on to something, quoting from the spec:

"""
6.2.11.1.3 Sequence of _OSC calls
The following rules govern sequences of calls to _OSC that are issued to the same host bridge and
occur within the same boot.
• The OS is permitted to evaluate _OSC an arbitrary number of times.
• If the OS declares support of a feature in the Status Field in one call to _OSC, then it must
preserve the set state of that bit (declaring support for that feature) in all subsequent calls.
• If the OS is granted control of a feature in the Control Field in one call to _OSC, then it must
preserve the set state of that bit (requesting that feature) in all subsequent calls.
"""

So the spec is saying that we should indeed keep all the flags which set during
the first call also set during subsequent calls.

If you can turn this into a proper patch then I can ask the reporters of
the 2 bugs to test that patch.

Regards,

Hans






> 
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index be7da23fad76..80ff81bb668b 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -290,7 +290,7 @@ static void acpi_bus_osc_negotiate_platform_control(void)
>  	struct acpi_osc_context context = {
>  		.uuid_str = sb_uuid_str,
>  		.rev = 1,
> -		.cap.length = 8,
> +		.cap.length = sizeof(capbuf),
>  		.cap.pointer = capbuf,
>  	};
>  	acpi_handle handle;
> @@ -330,32 +330,21 @@ static void acpi_bus_osc_negotiate_platform_control(void)
>  	if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
>  		return;
>  
> -	capbuf_ret = context.ret.pointer;
> -	if (context.ret.length <= OSC_SUPPORT_DWORD) {
> -		kfree(context.ret.pointer);
> -		return;
> -	}
> +	kfree(context.ret.pointer);
>  
> -	/*
> -	 * Now run _OSC again with query flag clear and with the caps
> -	 * supported by both the OS and the platform.
> -	 */
> +	/* Now run _OSC again with query flag clear */
>  	capbuf[OSC_QUERY_DWORD] = 0;
> -	capbuf[OSC_SUPPORT_DWORD] = capbuf_ret[OSC_SUPPORT_DWORD];
> -	kfree(context.ret.pointer);
>  
>  	if (ACPI_FAILURE(acpi_run_osc(handle, &context)))
>  		return;
>  
>  	capbuf_ret = context.ret.pointer;
> -	if (context.ret.length > OSC_SUPPORT_DWORD) {
> -		osc_sb_apei_support_acked =
> -			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
> -		osc_pc_lpi_support_confirmed =
> -			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
> -		osc_sb_native_usb4_support_confirmed =
> -			capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
> -	}
> +	osc_sb_apei_support_acked =
> +		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_APEI_SUPPORT;
> +	osc_pc_lpi_support_confirmed =
> +		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_PCLPI_SUPPORT;
> +	osc_sb_native_usb4_support_confirmed =
> +		capbuf_ret[OSC_SUPPORT_DWORD] & OSC_SB_NATIVE_USB4_SUPPORT;
>  
>  	kfree(context.ret.pointer);
>  }
> 


  parent reply	other threads:[~2021-06-08 13:24 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-03 17:26 Some SSDT tables are not loading with kernel >= 5.12 Hans de Goede
2021-06-07  9:43 ` Hans de Goede
2021-06-07 10:05   ` Hans de Goede
2021-06-07 11:13     ` Rafael J. Wysocki
     [not found]       ` <FR1PR80MB5051E91269FD36681BB357A7E1389@FR1PR80MB5051.lamprd80.prod.outlook.com>
2021-06-07 16:08         ` Mika Westerberg
2021-06-07 19:18           ` Hans de Goede
2021-06-08  9:50             ` Hans de Goede
2021-06-08 11:44               ` Mika Westerberg
2021-06-08 13:01                 ` Mika Westerberg
2021-06-08 13:24                 ` Hans de Goede [this message]
2021-06-08 15:03                   ` Mika Westerberg
2021-06-08 16:38                     ` [PATCH] ACPI: Pass the same capabilities to the _OSC regardless of the query flag Mika Westerberg
2021-06-08 17:10                       ` Hans de Goede
2021-06-09  7:58                         ` Hans de Goede
2021-06-09  9:24                           ` Mika Westerberg

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=edeba86c-1db7-e547-09a0-27da405155b3@redhat.com \
    --to=hdegoede@redhat.com \
    --cc=linux-acpi@vger.kernel.org \
    --cc=mario.limonciello@outlook.com \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael@kernel.org \
    --cc=rjw@rjwysocki.net \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).