All of lore.kernel.org
 help / color / mirror / Atom feed
From: Adam Manzanares <a.manzanares@samsung.com>
To: Vishal Verma <vishal.l.verma@intel.com>
Cc: "linux-cxl@vger.kernel.org" <linux-cxl@vger.kernel.org>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	Jonathan Cameron <Jonathan.Cameron@Huawei.com>,
	Dan Williams <dan.j.williams@intel.com>,
	"Rafael J. Wysocki" <rafael.j.wysocki@intel.com>,
	Robert Moore <robert.moore@intel.com>,
	Bjorn Helgaas <bhelgaas@google.com>,
	"Davidlohr Bueso" <dave@stgolabs.net>,
	"Rafael J. Wysocki" <rafael@kernel.org>
Subject: Re: [PATCH v5 1/3] PCI/ACPI: add a helper for retrieving _OSC Control DWORDs
Date: Fri, 8 Apr 2022 20:14:49 +0000	[thread overview]
Message-ID: <20220408201443.GA17996@bgt-140510-bm01> (raw)
In-Reply-To: <20220406023746.2807328-2-vishal.l.verma@intel.com>

On Tue, Apr 05, 2022 at 08:37:44PM -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.
> 
> Cc: "Rafael J. Wysocki" <rafael@kernel.org>
> Suggested-by: Davidlohr Bueso <dave@stgolabs.net>
> Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
> Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
> ---
>  include/linux/acpi.h    | 13 +++++++++++++
>  drivers/acpi/bus.c      |  2 +-
>  drivers/acpi/pci_root.c |  2 +-
>  3 files changed, 15 insertions(+), 2 deletions(-)
> 
> diff --git a/include/linux/acpi.h b/include/linux/acpi.h
> index 6274758648e3..ff4d1fdd9009 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,12 @@ static inline int acpi_register_wakeup_handler(int wake_irq,
>  static inline void acpi_unregister_wakeup_handler(
>  	bool (*wakeup)(void *context), void *context) { }
>  
> +struct acpi_osc_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;
> -- 
> 2.35.1
> 

Looks good.

Reviewed by: Adam Manzanares <a.manzanares@samsung.com>

  reply	other threads:[~2022-04-08 20:14 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-06  2:37 [PATCH v5 0/3] PCI/ACPI: add support for CXL _OSC Vishal Verma
2022-04-06  2:37 ` [PATCH v5 1/3] PCI/ACPI: add a helper for retrieving _OSC Control DWORDs Vishal Verma
2022-04-08 20:14   ` Adam Manzanares [this message]
2022-04-12 19:23   ` Rafael J. Wysocki
2022-04-06  2:37 ` [PATCH v5 2/3] PCI/ACPI: Prefer CXL _OSC instead of PCIe _OSC for CXL host bridges Vishal Verma
2022-04-12 19:21   ` Rafael J. Wysocki
2022-04-06  2:37 ` [PATCH v5 3/3] PCI/ACPI: negotiate CXL _OSC Vishal Verma
2022-04-12 19:20   ` Rafael J. Wysocki
2022-04-08 15:22 ` [PATCH v5 0/3] PCI/ACPI: add support for " Davidlohr Bueso

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=20220408201443.GA17996@bgt-140510-bm01 \
    --to=a.manzanares@samsung.com \
    --cc=Jonathan.Cameron@Huawei.com \
    --cc=bhelgaas@google.com \
    --cc=dan.j.williams@intel.com \
    --cc=dave@stgolabs.net \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-cxl@vger.kernel.org \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rafael@kernel.org \
    --cc=robert.moore@intel.com \
    --cc=vishal.l.verma@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.