diff mbox series

[4/4] arm64: pci: acpi: Preserve PCI resources configuration when asked by ACPI

Message ID 20190615002359.29577-4-benh@kernel.crashing.org (mailing list archive)
State New, archived
Headers show
Series [1/4] arm64: pci: acpi: Use pci_assign_unassigned_root_bus_resources() | expand

Commit Message

Benjamin Herrenschmidt June 15, 2019, 12:23 a.m. UTC
When _DSM #5 returns 0 for a host bridge, we need to claim the existing
resources rather than reassign everything.

Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 arch/arm64/kernel/pci.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

Comments

Lorenzo Pieralisi June 21, 2019, 2:57 p.m. UTC | #1
On Sat, Jun 15, 2019 at 10:23:59AM +1000, Benjamin Herrenschmidt wrote:
> When _DSM #5 returns 0 for a host bridge, we need to claim the existing

Nit: technically we do not know whether it is a _DSM #5 setting
hb->preserve_config or not, it is just a matter of rewording the log.

> resources rather than reassign everything.
> 
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  arch/arm64/kernel/pci.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 1419b1b4e9b9..a2c608a3fc41 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -168,6 +168,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	struct acpi_pci_generic_root_info *ri;
>  	struct pci_bus *bus, *child;
>  	struct acpi_pci_root_ops *root_ops;
> +	struct pci_host_bridge *hb;
>  
>  	ri = kzalloc(sizeof(*ri), GFP_KERNEL);
>  	if (!ri)
> @@ -193,6 +194,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	if (!bus)
>  		return NULL;
>  
> +	hb = pci_find_host_bridge(bus);

to_pci_host_bridge(bus->bridge) would do but it is probably better to
leave it as-is.

> +
> +	/* If ACPI tells us to preserve the resource configuration, claim now */
> +	if (hb->preserve_config)
> +		pci_bus_claim_resources(bus);
> +
> +	/*
> +	 * Assign whatever was left unassigned. If we didn't claim above, this will
> +	 * reassign everything.
> +	 */
>  	pci_assign_unassigned_root_bus_resources(bus);
>  
>  	list_for_each_entry(child, &bus->children, node)

This is fine as far as we acknowledge that claiming resources
on a bus is what should be done to make them immutable.

Acked-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Ard Biesheuvel June 21, 2019, 3:44 p.m. UTC | #2
On Sat, 15 Jun 2019 at 02:30, Benjamin Herrenschmidt
<benh@kernel.crashing.org> wrote:
>
> When _DSM #5 returns 0 for a host bridge, we need to claim the existing
> resources rather than reassign everything.
>
> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>

Acked-by: Ard Biesheuvel <ard.biesheuvel@linaro.org>

> ---
>  arch/arm64/kernel/pci.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
>
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 1419b1b4e9b9..a2c608a3fc41 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -168,6 +168,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>         struct acpi_pci_generic_root_info *ri;
>         struct pci_bus *bus, *child;
>         struct acpi_pci_root_ops *root_ops;
> +       struct pci_host_bridge *hb;
>
>         ri = kzalloc(sizeof(*ri), GFP_KERNEL);
>         if (!ri)
> @@ -193,6 +194,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>         if (!bus)
>                 return NULL;
>
> +       hb = pci_find_host_bridge(bus);
> +
> +       /* If ACPI tells us to preserve the resource configuration, claim now */
> +       if (hb->preserve_config)
> +               pci_bus_claim_resources(bus);
> +
> +       /*
> +        * Assign whatever was left unassigned. If we didn't claim above, this will
> +        * reassign everything.
> +        */
>         pci_assign_unassigned_root_bus_resources(bus);
>
>         list_for_each_entry(child, &bus->children, node)
> --
> 2.17.1
>
Bjorn Helgaas June 21, 2019, 8:08 p.m. UTC | #3
arm64: PCI: Preserve firmware configuration when necessary

On Sat, Jun 15, 2019 at 10:23:59AM +1000, Benjamin Herrenschmidt wrote:
> When _DSM #5 returns 0 for a host bridge, we need to claim the existing
> resources rather than reassign everything.

Use imperative mood.  I'd remove the reference to _DSM #5.  This patch
does not directly reference _DSM, and it's conceivable a kernel
command line parameter or other mechanism could set
host->preserve_config.

> Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> ---
>  arch/arm64/kernel/pci.c | 11 +++++++++++
>  1 file changed, 11 insertions(+)
> 
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index 1419b1b4e9b9..a2c608a3fc41 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -168,6 +168,7 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	struct acpi_pci_generic_root_info *ri;
>  	struct pci_bus *bus, *child;
>  	struct acpi_pci_root_ops *root_ops;
> +	struct pci_host_bridge *hb;
>  
>  	ri = kzalloc(sizeof(*ri), GFP_KERNEL);
>  	if (!ri)
> @@ -193,6 +194,16 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
>  	if (!bus)
>  		return NULL;
>  
> +	hb = pci_find_host_bridge(bus);
> +
> +	/* If ACPI tells us to preserve the resource configuration, claim now */
> +	if (hb->preserve_config)
> +		pci_bus_claim_resources(bus);
> +
> +	/*
> +	 * Assign whatever was left unassigned. If we didn't claim above, this will
> +	 * reassign everything.

Wrap the comment so it fits in 80 columns (unless local arch/arm64 style
allows wider lines, but I don't see any other wide lines in the file).

This series generally looks good to me.

> +	 */
>  	pci_assign_unassigned_root_bus_resources(bus);
>  
>  	list_for_each_entry(child, &bus->children, node)
> -- 
> 2.17.1
>
Benjamin Herrenschmidt June 21, 2019, 11:07 p.m. UTC | #4
On Fri, 2019-06-21 at 15:57 +0100, Lorenzo Pieralisi wrote:
> >        pci_assign_unassigned_root_bus_resources(bus);
> >   
> >        list_for_each_entry(child, &bus->children, node)
> 
> This is fine as far as we acknowledge that claiming resources
> on a bus is what should be done to make them immutable.

Well, as immuatable as it gets today. It's not perfect but it's a step
in the right direction. With the previous change in the series that
prevents auto-realloc when preserve_config is set, it will be
equivalent, in the current state of the code.

As part of my ongoing rework, I plan to look at making
IORESOURCE_PCI_FIXED more generally useful/robust, in which case we
could add that on top as well. That said, if we go down that path, I'm
keen on also adding a cmdline arg to ignore _DSM #5, if anything as a
test/diag tool when chasing problems caused by buggy BIOSes.

Cheers,
Ben.
diff mbox series

Patch

diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index 1419b1b4e9b9..a2c608a3fc41 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -168,6 +168,7 @@  struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	struct acpi_pci_generic_root_info *ri;
 	struct pci_bus *bus, *child;
 	struct acpi_pci_root_ops *root_ops;
+	struct pci_host_bridge *hb;
 
 	ri = kzalloc(sizeof(*ri), GFP_KERNEL);
 	if (!ri)
@@ -193,6 +194,16 @@  struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
 	if (!bus)
 		return NULL;
 
+	hb = pci_find_host_bridge(bus);
+
+	/* If ACPI tells us to preserve the resource configuration, claim now */
+	if (hb->preserve_config)
+		pci_bus_claim_resources(bus);
+
+	/*
+	 * Assign whatever was left unassigned. If we didn't claim above, this will
+	 * reassign everything.
+	 */
 	pci_assign_unassigned_root_bus_resources(bus);
 
 	list_for_each_entry(child, &bus->children, node)