From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Linux ACPI <linux-acpi@vger.kernel.org>,
Jonathan Cameron <jonathan.cameron@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
Bjorn Helgaas <helgaas@kernel.org>,
Srinivas Pandruvada <srinivas.pandruvada@linux.intel.com>,
Hans de Goede <hansg@kernel.org>,
Mario Limonciello <mario.limonciello@amd.com>
Subject: [PATCH v2.1 8/8] ACPI: bus: Rework the handling of \_SB._OSC USB4 features
Date: Mon, 22 Dec 2025 20:26:36 +0100 [thread overview]
Message-ID: <3879947.MHq7AAxBmi@rafael.j.wysocki> (raw)
In-Reply-To: <2413407.ElGaqSPkdT@rafael.j.wysocki>
From: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Use acpi_osc_handshake() introduced previously for implementing the
\_SB._OSC USB4 features control negotiation.
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Reviewed-by: Jonathan Cameron <jonathan.cameron@huawei.com>
---
v1 -> v2.1:
* Drop a redundant local variable.
* Add R-by from Jonathan (assuming it still applies).
---
drivers/acpi/bus.c | 58 +++++++----------------------------------------------
1 file changed, 8 insertions(+), 50 deletions(-)
--- a/drivers/acpi/bus.c
+++ b/drivers/acpi/bus.c
@@ -528,19 +528,15 @@ static void acpi_bus_decode_usb_osc(cons
(bits & OSC_USB_XDOMAIN) ? '+' : '-');
}
-static u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A";
static void acpi_bus_osc_negotiate_usb_control(void)
{
- u32 capbuf[3], *capbuf_ret;
- struct acpi_osc_context context = {
- .uuid_str = sb_usb_uuid_str,
- .rev = 1,
- .cap.length = sizeof(capbuf),
- .cap.pointer = capbuf,
+ static const u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A";
+ u32 capbuf[3], control;
+ struct acpi_buffer cap = {
+ .pointer = capbuf,
+ .length = sizeof(capbuf),
};
acpi_handle handle;
- acpi_status status;
- u32 control;
if (!osc_sb_native_usb4_support_confirmed)
return;
@@ -551,54 +547,16 @@ static void acpi_bus_osc_negotiate_usb_c
control = OSC_USB_USB3_TUNNELING | OSC_USB_DP_TUNNELING |
OSC_USB_PCIE_TUNNELING | OSC_USB_XDOMAIN;
- /*
- * Run _OSC first with query bit set, trying to get control over
- * all tunneling. The platform can then clear out bits in the
- * control dword that it does not want to grant to the OS.
- */
- capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
capbuf[OSC_SUPPORT_DWORD] = 0;
capbuf[OSC_CONTROL_DWORD] = control;
- status = acpi_run_osc(handle, &context);
- if (ACPI_FAILURE(status))
+ if (acpi_osc_handshake(handle, sb_usb_uuid_str, 1, &cap))
return;
- if (context.ret.length != sizeof(capbuf)) {
- pr_info("USB4 _OSC: returned invalid length buffer\n");
- goto out_free;
- }
-
- /*
- * Run _OSC again now with query bit clear and the control dword
- * matching what the platform granted (which may not have all
- * the control bits set).
- */
- capbuf_ret = context.ret.pointer;
-
- capbuf[OSC_QUERY_DWORD] = 0;
- capbuf[OSC_CONTROL_DWORD] = capbuf_ret[OSC_CONTROL_DWORD];
-
- kfree(context.ret.pointer);
-
- status = acpi_run_osc(handle, &context);
- if (ACPI_FAILURE(status))
- return;
-
- if (context.ret.length != sizeof(capbuf)) {
- pr_info("USB4 _OSC: returned invalid length buffer\n");
- goto out_free;
- }
-
- osc_sb_native_usb4_control =
- control & acpi_osc_ctx_get_pci_control(&context);
+ osc_sb_native_usb4_control = capbuf[OSC_CONTROL_DWORD];
acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control);
- acpi_bus_decode_usb_osc("USB4 _OSC: OS controls",
- osc_sb_native_usb4_control);
-
-out_free:
- kfree(context.ret.pointer);
+ acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", osc_sb_native_usb4_control);
}
/* --------------------------------------------------------------------------
prev parent reply other threads:[~2025-12-22 19:26 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-22 18:58 [PATCH v2.1 0/8] ACPI: bus: Rework of the \_SB._OSC handling Rafael J. Wysocki
2025-12-22 19:05 ` [PATCH v2.1 1/8] ACPI: bus: Fix handling of _OSC errors in acpi_run_osc() Rafael J. Wysocki
2025-12-23 11:12 ` Jonathan Cameron
2025-12-23 16:13 ` Rafael J. Wysocki
2025-12-22 19:11 ` [PATCH v2.1 2/8] ACPI: bus: Rework printing debug messages on _OSC errors Rafael J. Wysocki
2025-12-23 11:13 ` Jonathan Cameron
2025-12-22 19:14 ` [PATCH v2.1 3/8] ACPI: bus: Split _OSC evaluation out of acpi_run_osc() Rafael J. Wysocki
2025-12-23 11:18 ` Jonathan Cameron
2025-12-22 19:17 ` [PATCH v2.1 4/8] ACPI: bus: Split _OSC error processing " Rafael J. Wysocki
2025-12-22 19:18 ` [PATCH v2.1 5/8] ACPI: bus: Rename label and use ACPI_FREE() in acpi_run_osc() Rafael J. Wysocki
2025-12-22 19:21 ` [PATCH v2.1 6/8] ACPI: bus: Rework the handling of \_SB._OSC platform features Rafael J. Wysocki
2025-12-23 11:25 ` Jonathan Cameron
2025-12-22 19:23 ` [PATCH v2.1 7/8] ACPI: bus: Adjust feature mask creation for \_SB._OSC Rafael J. Wysocki
2025-12-23 11:26 ` Jonathan Cameron
2025-12-22 19:26 ` Rafael J. Wysocki [this message]
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=3879947.MHq7AAxBmi@rafael.j.wysocki \
--to=rafael@kernel.org \
--cc=hansg@kernel.org \
--cc=helgaas@kernel.org \
--cc=jonathan.cameron@huawei.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mario.limonciello@amd.com \
--cc=srinivas.pandruvada@linux.intel.com \
/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