diff mbox

trouble with PCI: Call pci_read_bridge_bases() from core instead of arch code

Message ID CAE9FiQUsRHgqQ6F58yx5pyWeLJc1U72dWOf2p6OUO2PAbFwF=A@mail.gmail.com
State Not Applicable
Headers show

Commit Message

Yinghai Lu Sept. 9, 2015, 4:59 p.m. UTC
On Wed, Sep 9, 2015 at 4:32 AM, Lorenzo Pieralisi
<lorenzo.pieralisi@arm.com> wrote:
> Subject: [PATCH] PCI: remove dead code in pci_claim_bridge_resource()
>
> Commit 8505e729a2f6eb ("PCI: Add pci_claim_bridge_resource() to clip
> window if necessary") introduced a new API to claim bridge resources.
>
> pci_claim_bridge_resource() tries to claim a bridge resource, and if
> the claiming fails the function tries to clip the resource to make
> it fit within the parent resource window.
>
> If the clipping succeeds the bridge apertures are set-up accordingly
> and the pci_claim_bridge_resource() tries to claim the resource
> again.
>
> Commit c770cb4cb505 ("PCI: Mark invalid BARs as unassigned") added
> code that sets the IORESOURCE_UNSET flag on claiming failure.
>
> This means that the second resource claiming after window clipping will
> always fail, since the resource flags contain IORESOURCE_UNSET,
> previously set on failure by pci_claim_resource(), so the subsequent
> pci_claim_resource() call ends up spitting a log message and return
> failure with no chance whatsoever to succeed.
>
> This patch removes the second pci_claim_resource() call in
> pci_claim_bridge_resource() since it basically has no chance to
> succeed, leaving the current behaviour unchanged.
>
> Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Yinghai Lu <yinghai@kernel.org>
> ---
>  drivers/pci/setup-bus.c | 6 +-----
>  1 file changed, 1 insertion(+), 5 deletions(-)
>
> diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
> index 508cc56..2bf4ac1 100644
> --- a/drivers/pci/setup-bus.c
> +++ b/drivers/pci/setup-bus.c
> @@ -728,14 +728,10 @@ int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
>                 break;
>         case 2:
>                 pci_setup_bridge_mmio_pref(bridge);
> -               break;
>         default:
> -               return -EINVAL;
> +               break;
>         }
>
> -       if (pci_claim_resource(bridge, i) == 0)
> -               return 0;       /* claimed a smaller window */
> -
>         return -EINVAL;
>  }

That should be regression from c770cb4cb505 ("PCI: Mark invalid BARs
as unassigned")
so right fix should be:

the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/setup-bus.c b/drivers/pci/setup-bus.c
index 508cc56..76b3349 100644
--- a/drivers/pci/setup-bus.c
+++ b/drivers/pci/setup-bus.c
@@ -733,6 +733,7 @@  int pci_claim_bridge_resource(struct pci_dev *bridge, int i)
                return -EINVAL;
        }

+       bridge->resource[i].flags &= ~IORESOURCE_UNSET;
        if (pci_claim_resource(bridge, i) == 0)
                return 0;       /* claimed a smaller window */
--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in