Skip to content

Commit d9239fd

Browse files
committed
ACPI: bus: Rework the handling of \_SB._OSC USB4 features
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> Link: https://patch.msgid.link/3879947.MHq7AAxBmi@rafael.j.wysocki
1 parent 6485059 commit d9239fd

1 file changed

Lines changed: 8 additions & 50 deletions

File tree

drivers/acpi/bus.c

Lines changed: 8 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -528,19 +528,15 @@ static void acpi_bus_decode_usb_osc(const char *msg, u32 bits)
528528
(bits & OSC_USB_XDOMAIN) ? '+' : '-');
529529
}
530530

531-
static u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A";
532531
static void acpi_bus_osc_negotiate_usb_control(void)
533532
{
534-
u32 capbuf[3], *capbuf_ret;
535-
struct acpi_osc_context context = {
536-
.uuid_str = sb_usb_uuid_str,
537-
.rev = 1,
538-
.cap.length = sizeof(capbuf),
539-
.cap.pointer = capbuf,
533+
static const u8 sb_usb_uuid_str[] = "23A0D13A-26AB-486C-9C5F-0FFA525A575A";
534+
u32 capbuf[3], control;
535+
struct acpi_buffer cap = {
536+
.pointer = capbuf,
537+
.length = sizeof(capbuf),
540538
};
541539
acpi_handle handle;
542-
acpi_status status;
543-
u32 control;
544540

545541
if (!osc_sb_native_usb4_support_confirmed)
546542
return;
@@ -551,54 +547,16 @@ static void acpi_bus_osc_negotiate_usb_control(void)
551547
control = OSC_USB_USB3_TUNNELING | OSC_USB_DP_TUNNELING |
552548
OSC_USB_PCIE_TUNNELING | OSC_USB_XDOMAIN;
553549

554-
/*
555-
* Run _OSC first with query bit set, trying to get control over
556-
* all tunneling. The platform can then clear out bits in the
557-
* control dword that it does not want to grant to the OS.
558-
*/
559-
capbuf[OSC_QUERY_DWORD] = OSC_QUERY_ENABLE;
560550
capbuf[OSC_SUPPORT_DWORD] = 0;
561551
capbuf[OSC_CONTROL_DWORD] = control;
562552

563-
status = acpi_run_osc(handle, &context);
564-
if (ACPI_FAILURE(status))
565-
return;
566-
567-
if (context.ret.length != sizeof(capbuf)) {
568-
pr_info("USB4 _OSC: returned invalid length buffer\n");
569-
goto out_free;
570-
}
571-
572-
/*
573-
* Run _OSC again now with query bit clear and the control dword
574-
* matching what the platform granted (which may not have all
575-
* the control bits set).
576-
*/
577-
capbuf_ret = context.ret.pointer;
578-
579-
capbuf[OSC_QUERY_DWORD] = 0;
580-
capbuf[OSC_CONTROL_DWORD] = capbuf_ret[OSC_CONTROL_DWORD];
581-
582-
kfree(context.ret.pointer);
583-
584-
status = acpi_run_osc(handle, &context);
585-
if (ACPI_FAILURE(status))
553+
if (acpi_osc_handshake(handle, sb_usb_uuid_str, 1, &cap))
586554
return;
587555

588-
if (context.ret.length != sizeof(capbuf)) {
589-
pr_info("USB4 _OSC: returned invalid length buffer\n");
590-
goto out_free;
591-
}
592-
593-
osc_sb_native_usb4_control =
594-
control & acpi_osc_ctx_get_pci_control(&context);
556+
osc_sb_native_usb4_control = capbuf[OSC_CONTROL_DWORD];
595557

596558
acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control);
597-
acpi_bus_decode_usb_osc("USB4 _OSC: OS controls",
598-
osc_sb_native_usb4_control);
599-
600-
out_free:
601-
kfree(context.ret.pointer);
559+
acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", osc_sb_native_usb4_control);
602560
}
603561

604562
/* --------------------------------------------------------------------------

0 commit comments

Comments
 (0)