Message ID | 20220330181434.1515791-2-vishal.l.verma@intel.com |
---|---|
State | New, archived |
Headers | show |
Series | acpi: add support for CXL _OSC | expand |
Look at previous subject lines and copy the style instead of making up something new. On Wed, Mar 30, 2022 at 12:14:32PM -0600, Vishal Verma wrote: > During _OSC negotiation, when the 'Control' DWORD is needed from the > result buffer after running _OSC, a couple of places performed manual > pointer arithmetic to offset into the right spot in the raw buffer. > Add a acpi_osc_ctx_get_pci_control() helper to use the #define'd > DWORD offsets to fetch the DWORDs needed from @acpi_osc_context, and > replace the above instances of the open-coded arithmetic. Bjorn
On Wed, 2022-03-30 at 14:04 -0500, Bjorn Helgaas wrote: > Look at previous subject lines and copy the style instead of making up > something new. Yep will fix. > > On Wed, Mar 30, 2022 at 12:14:32PM -0600, Vishal Verma wrote: > > During _OSC negotiation, when the 'Control' DWORD is needed from the > > result buffer after running _OSC, a couple of places performed manual > > pointer arithmetic to offset into the right spot in the raw buffer. > > Add a acpi_osc_ctx_get_pci_control() helper to use the #define'd > > DWORD offsets to fetch the DWORDs needed from @acpi_osc_context, and > > replace the above instances of the open-coded arithmetic. > > Bjorn
diff --git a/include/linux/acpi.h b/include/linux/acpi.h index 6274758648e3..5c5bac255d35 100644 --- a/include/linux/acpi.h +++ b/include/linux/acpi.h @@ -607,6 +607,13 @@ extern u32 osc_sb_native_usb4_control; #define OSC_PCI_EXPRESS_LTR_CONTROL 0x00000020 #define OSC_PCI_EXPRESS_DPC_CONTROL 0x00000080 +static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) +{ + u32 *ret = context->ret.pointer; + + return ret[OSC_CONTROL_DWORD]; +} + #define ACPI_GSB_ACCESS_ATTRIB_QUICK 0x00000002 #define ACPI_GSB_ACCESS_ATTRIB_SEND_RCV 0x00000004 #define ACPI_GSB_ACCESS_ATTRIB_BYTE 0x00000006 @@ -1003,6 +1010,11 @@ static inline int acpi_register_wakeup_handler(int wake_irq, static inline void acpi_unregister_wakeup_handler( bool (*wakeup)(void *context), void *context) { } +static inline u32 acpi_osc_ctx_get_pci_control(struct acpi_osc_context *context) +{ + return 0; +} + #endif /* !CONFIG_ACPI */ #ifdef CONFIG_ACPI_HOTPLUG_IOAPIC diff --git a/drivers/acpi/bus.c b/drivers/acpi/bus.c index 07f604832fd6..4992e05cf429 100644 --- a/drivers/acpi/bus.c +++ b/drivers/acpi/bus.c @@ -405,7 +405,7 @@ static void acpi_bus_osc_negotiate_usb_control(void) } osc_sb_native_usb4_control = - control & ((u32 *)context.ret.pointer)[OSC_CONTROL_DWORD]; + control & acpi_osc_ctx_get_pci_control(&context); acpi_bus_decode_usb_osc("USB4 _OSC: OS supports", control); acpi_bus_decode_usb_osc("USB4 _OSC: OS controls", diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c index b76db99cced3..40a74ff3fa02 100644 --- a/drivers/acpi/pci_root.c +++ b/drivers/acpi/pci_root.c @@ -185,7 +185,7 @@ static acpi_status acpi_pci_run_osc(acpi_handle handle, status = acpi_run_osc(handle, &context); if (ACPI_SUCCESS(status)) { - *retval = *((u32 *)(context.ret.pointer + 8)); + *retval = acpi_osc_ctx_get_pci_control(&context); kfree(context.ret.pointer); } return status;
During _OSC negotiation, when the 'Control' DWORD is needed from the result buffer after running _OSC, a couple of places performed manual pointer arithmetic to offset into the right spot in the raw buffer. Add a acpi_osc_ctx_get_pci_control() helper to use the #define'd DWORD offsets to fetch the DWORDs needed from @acpi_osc_context, and replace the above instances of the open-coded arithmetic. Cc: "Rafael J. Wysocki" <rafael@kernel.org> Suggested-by: Davidlohr Bueso <dave@stgolabs.net> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com> --- include/linux/acpi.h | 12 ++++++++++++ drivers/acpi/bus.c | 2 +- drivers/acpi/pci_root.c | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-)