linux-acpi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Mika Westerberg <mika.westerberg@linux.intel.com>
Cc: "open list:ULTRA-WIDEBAND (UWB) SUBSYSTEM:" 
	<linux-usb@vger.kernel.org>,
	Michael Jamet <michael.jamet@intel.com>,
	Yehezkel Bernat <YehezkelShB@gmail.com>,
	Andreas Noever <andreas.noever@gmail.com>,
	Lukas Wunner <lukas@wunner.de>,
	Mario Limonciello <mario.limonciello@dell.com>,
	"Rafael J. Wysocki" <rjw@rjwysocki.net>,
	Christian Kellner <christian@kellner.me>,
	Len Brown <lenb@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	ACPI Devel Maling List <linux-acpi@vger.kernel.org>
Subject: Re: [PATCH 4/6] ACPI: Execute platform _OSC also with query bit clear
Date: Tue, 26 Jan 2021 18:21:08 +0100	[thread overview]
Message-ID: <CAJZ5v0i+wCOFZOhyx6i=TUGMeWyQR4vXzDN06G6xheFwC66Tuw@mail.gmail.com> (raw)
In-Reply-To: <20210126155723.9388-5-mika.westerberg@linux.intel.com>

On Tue, Jan 26, 2021 at 5:01 PM Mika Westerberg
<mika.westerberg@linux.intel.com> wrote:
>
> From: Mario Limonciello <mario.limonciello@dell.com>
>
> The platform _OSC can change the hardware state when query bit is not
> set. According to ACPI spec it is recommended that the OS runs _OSC with
> query bit set until the platform does not mask any of the capabilities.
> Then it should run it with query bit clear in order to actually commit
> the changes. At the moment Linux only runs the _OSC with query bit set

And that's because there was nothing it could ask to control using the
_SB scope _OSC.

Today it is just reporting what features are supported by it.

However, with the upcoming USB4 CM support it needs to ask for the
control of that feature and that's why the _SB scope _OSC support
needs to be extended.  So it is not a fix for a bug or missing spec
coverage, which this part of the changelog kind of implies, it's just
enabling a new feature.

> and this is going to cause problems with the USB4 CM (Connection
> Manager) switch that is going to commit the switch only when the OS
> requests control over the feature.
>
> For this reason modify the _OSC support so that we first execute it with
> query bit set, then use the returned valu as base of the features we

s/valu/value/

> want to control and run the _OSC again with query bit clear.
>
> Also rename the function to better match what it does.
>
> Cc: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Mario Limonciello <mario.limonciello@dell.com>
> Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
>
> ---
>  drivers/acpi/bus.c | 43 +++++++++++++++++++++++++++++++------------
>  1 file changed, 31 insertions(+), 12 deletions(-)
>
> diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c
> index 1682f8b454a2..ca7c7b2bf56e 100644
> --- a/drivers/acpi/bus.c
> +++ b/drivers/acpi/bus.c
> @@ -282,9 +282,9 @@ bool osc_pc_lpi_support_confirmed;
>  EXPORT_SYMBOL_GPL(osc_pc_lpi_support_confirmed);
>
>  static u8 sb_uuid_str[] = "0811B06E-4A27-44F9-8D60-3CBBC22E7B48";
> -static void acpi_bus_osc_support(void)
> +static void acpi_bus_osc_negotiate_platform_control(void)
>  {
> -       u32 capbuf[2];
> +       u32 capbuf[2], *capbuf_ret;
>         struct acpi_osc_context context = {
>                 .uuid_str = sb_uuid_str,
>                 .rev = 1,
> @@ -321,17 +321,36 @@ static void acpi_bus_osc_support(void)
>                 capbuf[OSC_SUPPORT_DWORD] |= OSC_SB_APEI_SUPPORT;
>         if (ACPI_FAILURE(acpi_get_handle(NULL, "\\_SB", &handle)))
>                 return;
> -       if (ACPI_SUCCESS(acpi_run_osc(handle, &context))) {
> -               u32 *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;
> -               }
> +
> +       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;
>         }
> -       /* do we need to check other returned cap? Sounds no */
> +
> +       /*
> +        * Now run _OSC again with query flag clean and with the caps

s/clean/clear/

> +        * both platform and OS supports.

s/both platform and OS supports/supported by both the OS and the platform/

> +        */
> +       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;
> +       }
> +
> +       kfree(context.ret.pointer);
>  }
>
>  /* --------------------------------------------------------------------------
> @@ -1168,7 +1187,7 @@ static int __init acpi_bus_init(void)
>          * _OSC method may exist in module level code,
>          * so it must be run after ACPI_FULL_INITIALIZATION
>          */
> -       acpi_bus_osc_support();
> +       acpi_bus_osc_negotiate_platform_control();
>
>         /*
>          * _PDC control method may load dynamic SSDT tables,
> --
> 2.29.2
>

  parent reply	other threads:[~2021-01-27 13:02 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-01-26 15:57 [PATCH 0/6] thunderbolt / ACPI: Add support for USB4 _OSC Mika Westerberg
2021-01-26 15:57 ` [PATCH 1/6] thunderbolt: Fix possible NULL pointer dereference in tb_acpi_add_link() Mika Westerberg
2021-01-28 12:36   ` Mika Westerberg
2021-01-26 15:57 ` [PATCH 2/6] thunderbolt: Add support for PCIe tunneling disabled (SL5) Mika Westerberg
2021-01-26 16:18   ` Yehezkel Bernat
2021-01-26 16:26     ` Mika Westerberg
2021-01-26 16:29       ` Yehezkel Bernat
2021-01-26 15:57 ` [PATCH 3/6] thunderbolt: Allow disabling XDomain protocol Mika Westerberg
2021-01-26 15:57 ` [PATCH 4/6] ACPI: Execute platform _OSC also with query bit clear Mika Westerberg
2021-01-26 16:25   ` Yehezkel Bernat
2021-01-26 17:21   ` Rafael J. Wysocki [this message]
2021-01-26 17:37     ` Limonciello, Mario
2021-01-26 17:42       ` Rafael J. Wysocki
2021-01-26 22:43         ` Limonciello, Mario
2021-01-27 12:49           ` Mika Westerberg
2021-01-27 13:50             ` Rafael J. Wysocki
2021-01-26 15:57 ` [PATCH 5/6] ACPI: Add support for native USB4 control _OSC Mika Westerberg
2021-01-26 17:35   ` Rafael J. Wysocki
2021-01-26 17:46     ` Mika Westerberg
2021-01-26 18:25       ` Rafael J. Wysocki
2021-01-26 18:27   ` Rafael J. Wysocki
2021-01-26 15:57 ` [PATCH 6/6] thunderbolt: Add support for native USB4 _OSC Mika Westerberg
2021-01-26 16:37 ` [PATCH 0/6] thunderbolt / ACPI: Add support for " Yehezkel Bernat

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='CAJZ5v0i+wCOFZOhyx6i=TUGMeWyQR4vXzDN06G6xheFwC66Tuw@mail.gmail.com' \
    --to=rafael@kernel.org \
    --cc=YehezkelShB@gmail.com \
    --cc=andreas.noever@gmail.com \
    --cc=christian@kellner.me \
    --cc=gregkh@linuxfoundation.org \
    --cc=lenb@kernel.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=lukas@wunner.de \
    --cc=mario.limonciello@dell.com \
    --cc=michael.jamet@intel.com \
    --cc=mika.westerberg@linux.intel.com \
    --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).