From: "Rafael J. Wysocki" <rafael@kernel.org>
To: Joerg Roedel <joro@8bytes.org>
Cc: Bjorn Helgaas <bhelgaas@google.com>,
"Rafael J . Wysocki" <rjw@rjwysocki.net>,
Len Brown <lenb@kernel.org>,
Linux PCI <linux-pci@vger.kernel.org>,
ACPI Devel Maling List <linux-acpi@vger.kernel.org>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH v3 2/4] PCI/ACPI: Move supported and control calculations to separaten functions
Date: Wed, 1 Sep 2021 20:56:05 +0200 [thread overview]
Message-ID: <CAJZ5v0gHEY1FW7A-rytBkSrxidusd3jNPJOke6QWxwoE5VXeiA@mail.gmail.com> (raw)
In-Reply-To: <20210824122054.29481-3-joro@8bytes.org>
On Tue, Aug 24, 2021 at 2:21 PM Joerg Roedel <joro@8bytes.org> wrote:
>
> From: Joerg Roedel <jroedel@suse.de>
>
> Move the calculations of supported and controled _OSC features out of
> negotiate_os_control into separate functions.
>
> Signed-off-by: Joerg Roedel <jroedel@suse.de>
Reviewed-by: Rafael J. Wysocki <rafael@kernel.org>
> ---
> drivers/acpi/pci_root.c | 93 ++++++++++++++++++++++++-----------------
> 1 file changed, 55 insertions(+), 38 deletions(-)
>
> diff --git a/drivers/acpi/pci_root.c b/drivers/acpi/pci_root.c
> index 0c3030a58219..ed4e6b55e9bc 100644
> --- a/drivers/acpi/pci_root.c
> +++ b/drivers/acpi/pci_root.c
> @@ -396,6 +396,59 @@ static acpi_status acpi_pci_osc_control_set(acpi_handle handle, u32 *mask, u32 r
> return AE_OK;
> }
>
> +static u32 calculate_support(void)
> +{
> + u32 support;
> +
> + /*
> + * All supported architectures that use ACPI have support for
> + * PCI domains, so we indicate this in _OSC support capabilities.
> + */
> + support = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
> + support |= OSC_PCI_HPX_TYPE_3_SUPPORT;
> + if (pci_ext_cfg_avail())
> + support |= OSC_PCI_EXT_CONFIG_SUPPORT;
> + if (pcie_aspm_support_enabled())
> + support |= OSC_PCI_ASPM_SUPPORT | OSC_PCI_CLOCK_PM_SUPPORT;
> + if (pci_msi_enabled())
> + support |= OSC_PCI_MSI_SUPPORT;
> + if (IS_ENABLED(CONFIG_PCIE_EDR))
> + support |= OSC_PCI_EDR_SUPPORT;
> +
> + return support;
> +}
> +
> +static u32 calculate_control(void)
> +{
> + u32 control;
> +
> + control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
> + | OSC_PCI_EXPRESS_PME_CONTROL;
> +
> + if (IS_ENABLED(CONFIG_PCIEASPM))
> + control |= OSC_PCI_EXPRESS_LTR_CONTROL;
> +
> + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
> + control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL;
> +
> + if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC))
> + control |= OSC_PCI_SHPC_NATIVE_HP_CONTROL;
> +
> + if (pci_aer_available())
> + control |= OSC_PCI_EXPRESS_AER_CONTROL;
> +
> + /*
> + * Per the Downstream Port Containment Related Enhancements ECN to
> + * the PCI Firmware Spec, r3.2, sec 4.5.1, table 4-5,
> + * OSC_PCI_EXPRESS_DPC_CONTROL indicates the OS supports both DPC
> + * and EDR.
> + */
> + if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR))
> + control |= OSC_PCI_EXPRESS_DPC_CONTROL;
> +
> + return control;
> +}
> +
> static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
> bool is_pcie)
> {
> @@ -416,20 +469,7 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
> return;
> }
>
> - /*
> - * All supported architectures that use ACPI have support for
> - * PCI domains, so we indicate this in _OSC support capabilities.
> - */
> - support = OSC_PCI_SEGMENT_GROUPS_SUPPORT;
> - support |= OSC_PCI_HPX_TYPE_3_SUPPORT;
> - if (pci_ext_cfg_avail())
> - support |= OSC_PCI_EXT_CONFIG_SUPPORT;
> - if (pcie_aspm_support_enabled())
> - support |= OSC_PCI_ASPM_SUPPORT | OSC_PCI_CLOCK_PM_SUPPORT;
> - if (pci_msi_enabled())
> - support |= OSC_PCI_MSI_SUPPORT;
> - if (IS_ENABLED(CONFIG_PCIE_EDR))
> - support |= OSC_PCI_EDR_SUPPORT;
> + support = calculate_support();
>
> decode_osc_support(root, "OS supports", support);
> status = acpi_pci_osc_support(root, support);
> @@ -456,31 +496,8 @@ static void negotiate_os_control(struct acpi_pci_root *root, int *no_aspm,
> return;
> }
>
> - control = OSC_PCI_EXPRESS_CAPABILITY_CONTROL
> - | OSC_PCI_EXPRESS_PME_CONTROL;
> -
> - if (IS_ENABLED(CONFIG_PCIEASPM))
> - control |= OSC_PCI_EXPRESS_LTR_CONTROL;
> -
> - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_PCIE))
> - control |= OSC_PCI_EXPRESS_NATIVE_HP_CONTROL;
> -
> - if (IS_ENABLED(CONFIG_HOTPLUG_PCI_SHPC))
> - control |= OSC_PCI_SHPC_NATIVE_HP_CONTROL;
> -
> - if (pci_aer_available())
> - control |= OSC_PCI_EXPRESS_AER_CONTROL;
> -
> - /*
> - * Per the Downstream Port Containment Related Enhancements ECN to
> - * the PCI Firmware Spec, r3.2, sec 4.5.1, table 4-5,
> - * OSC_PCI_EXPRESS_DPC_CONTROL indicates the OS supports both DPC
> - * and EDR.
> - */
> - if (IS_ENABLED(CONFIG_PCIE_DPC) && IS_ENABLED(CONFIG_PCIE_EDR))
> - control |= OSC_PCI_EXPRESS_DPC_CONTROL;
> + requested = control = calculate_control();
>
> - requested = control;
> status = acpi_pci_osc_control_set(handle, &control,
> OSC_PCI_EXPRESS_CAPABILITY_CONTROL);
> if (ACPI_SUCCESS(status)) {
> --
> 2.32.0
>
next prev parent reply other threads:[~2021-09-01 18:56 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-08-24 12:20 [PATCH v3 0/4] PCI/ACPI: Simplify PCIe _OSC feature negotiation Joerg Roedel
2021-08-24 12:20 ` [PATCH v3 1/4] PCI/ACPI: Remove OSC_PCI_SUPPORT_MASKS and OSC_PCI_CONTROL_MASKS Joerg Roedel
2021-09-01 18:53 ` Rafael J. Wysocki
2021-08-24 12:20 ` [PATCH v3 2/4] PCI/ACPI: Move supported and control calculations to separaten functions Joerg Roedel
2021-09-01 18:56 ` Rafael J. Wysocki [this message]
2021-08-24 12:20 ` [PATCH v3 3/4] PCI/ACPI: Move _OSC query checks to separate function Joerg Roedel
2021-09-01 18:57 ` Rafael J. Wysocki
2021-08-24 12:20 ` [PATCH v3 4/4] PCI/ACPI: Check for _OSC support in acpi_pci_osc_control_set() Joerg Roedel
2021-09-01 19:31 ` Rafael J. Wysocki
2021-09-01 19:33 ` [PATCH v3 0/4] PCI/ACPI: Simplify PCIe _OSC feature negotiation Rafael J. Wysocki
2021-09-13 16:14 ` Rafael J. Wysocki
2021-09-14 13:49 ` Joerg Roedel
2021-09-14 13:52 ` Bjorn Helgaas
2021-09-28 21:21 ` Bjorn Helgaas
2021-09-29 8:09 ` Joerg Roedel
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=CAJZ5v0gHEY1FW7A-rytBkSrxidusd3jNPJOke6QWxwoE5VXeiA@mail.gmail.com \
--to=rafael@kernel.org \
--cc=bhelgaas@google.com \
--cc=joro@8bytes.org \
--cc=jroedel@suse.de \
--cc=lenb@kernel.org \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--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).