diff mbox

[RFC,3/4] arm64: Do not call enable PCI resources when specify PCI_PROBE_ONLY

Message ID 1411937610-22125-4-git-send-email-suravee.suthikulpanit@amd.com (mailing list archive)
State New, archived
Headers show

Commit Message

Suravee Suthikulpanit Sept. 28, 2014, 8:53 p.m. UTC
From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>

When specify PCI_PROBE_ONLY, the resource parent does not get assigned.
Therefore, pci_enable_resources() return error saying that
"BAR x not claimed".

Note: This same logic is also used in the arch/arm/kernel/bios32.c

Cc: Liviu Dudau <Liviu.Dudau@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Catalin Marinas <catalin.marinas@arm.com>
Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
---
 arch/arm64/kernel/pci.c | 8 ++++++++
 1 file changed, 8 insertions(+)

Comments

Arnd Bergmann Sept. 29, 2014, 2:38 p.m. UTC | #1
On Sunday 28 September 2014 15:53:29 suravee.suthikulpanit@amd.com wrote:
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index ce5836c..7fd4d2b 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -68,3 +68,11 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>         bus->domain_nr = domain;
>  }
>  #endif
> +
> +int pcibios_enable_device(struct pci_dev *dev, int mask)
> +{
> +       if (pci_has_flag(PCI_PROBE_ONLY))
> +               return 0;
> +
> +       return pci_enable_resources(dev, mask);
> +}

This doesn't look arm64 specific to me, and there is already a generic
pcibios_enable_device() function in drivers/pci/pci.c. Would it
be possible to move the check for PCI_PROBE_ONLY there without breaking
other architectures?

If that works, please do so.

	Arnd
Bjorn Helgaas Sept. 29, 2014, 6:17 p.m. UTC | #2
On Sun, Sep 28, 2014 at 2:53 PM,  <suravee.suthikulpanit@amd.com> wrote:
> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
>
> When specify PCI_PROBE_ONLY, the resource parent does not get assigned.
> Therefore, pci_enable_resources() return error saying that
> "BAR x not claimed".
>
> Note: This same logic is also used in the arch/arm/kernel/bios32.c
>
> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> ---
>  arch/arm64/kernel/pci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
>
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index ce5836c..7fd4d2b 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -68,3 +68,11 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>         bus->domain_nr = domain;
>  }
>  #endif
> +
> +int pcibios_enable_device(struct pci_dev *dev, int mask)
> +{
> +       if (pci_has_flag(PCI_PROBE_ONLY))
> +               return 0;
> +
> +       return pci_enable_resources(dev, mask);

I had thought of "PCI_PROBE_ONLY" as the "look but don't touch" flag,
i.e., never change any BAR or bridge window assignments.  But I guess
the current usage is more general than that: we also use it to

  - avoid pci_enable_resources(), which only turns on IO/MEM bits in
the command register
  - avoid pcie_bus_configure_settings(), which programs MPS and MRRS
  - avoid pci_read_bridge_bases(), which really just *reads* bridge windows
  - avoid pcibios_reserve_legacy_regions(), which doesn't touch any
PCI registers
  - enables pci_claim_resource()

This seems like more than necessary, but I don't know all the history.
In particular, I don't know why PCI_PROBE_ONLY should make a
difference to things like claiming resources.

> +}
> --
> 1.9.3
>b
Benjamin Herrenschmidt June 23, 2015, 10:32 p.m. UTC | #3
On Sun, 2014-09-28 at 15:53 -0500, suravee.suthikulpanit@amd.com wrote:
> From: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> 
> When specify PCI_PROBE_ONLY, the resource parent does not get assigned.
> Therefore, pci_enable_resources() return error saying that
> "BAR x not claimed".
> 
> Note: This same logic is also used in the arch/arm/kernel/bios32.c

This looks broken. Why don't you assign the resource parent ?

> Cc: Liviu Dudau <Liviu.Dudau@arm.com>
> Cc: Bjorn Helgaas <bhelgaas@google.com>
> Cc: Will Deacon <will.deacon@arm.com>
> Cc: Catalin Marinas <catalin.marinas@arm.com>
> Signed-off-by: Suravee Suthikulpanit <Suravee.Suthikulpanit@amd.com>
> ---
>  arch/arm64/kernel/pci.c | 8 ++++++++
>  1 file changed, 8 insertions(+)
> 
> diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
> index ce5836c..7fd4d2b 100644
> --- a/arch/arm64/kernel/pci.c
> +++ b/arch/arm64/kernel/pci.c
> @@ -68,3 +68,11 @@ void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
>  	bus->domain_nr = domain;
>  }
>  #endif
> +
> +int pcibios_enable_device(struct pci_dev *dev, int mask)
> +{
> +	if (pci_has_flag(PCI_PROBE_ONLY))
> +		return 0;
> +
> +	return pci_enable_resources(dev, mask);
> +}
Benjamin Herrenschmidt June 23, 2015, 10:34 p.m. UTC | #4
On Mon, 2014-09-29 at 12:17 -0600, Bjorn Helgaas wrote:
> This seems like more than necessary, but I don't know all the history.
> In particular, I don't know why PCI_PROBE_ONLY should make a
> difference to things like claiming resources.

It shouldn't ... we created that option on ppc originally to avoid
allocation/reallocation of resources. If they are bad, leave them bad,
but it was never a question of disabling all these other things.

(Ok, the MRSS/MPS is debatable, but why not plumb the parent pointers
and why not claim ? That doesn't make sense to me).

Cheers,
Ben.
Russell King - ARM Linux June 23, 2015, 11:05 p.m. UTC | #5
On Wed, Jun 24, 2015 at 08:34:28AM +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2014-09-29 at 12:17 -0600, Bjorn Helgaas wrote:
> > This seems like more than necessary, but I don't know all the history.
> > In particular, I don't know why PCI_PROBE_ONLY should make a
> > difference to things like claiming resources.
> 
> It shouldn't ... we created that option on ppc originally to avoid
> allocation/reallocation of resources. If they are bad, leave them bad,
> but it was never a question of disabling all these other things.
> 
> (Ok, the MRSS/MPS is debatable, but why not plumb the parent pointers
> and why not claim ? That doesn't make sense to me).

You could look back over the history of arch/arm/kernel/bios32.c and
see that it was introduced by Will Deacon when he stripped out the
ARM version in favour of the generic version, and was found to be
necessary then.

I think the question has to be asked (based upon what Ben's saying)
and what's identified in these commits as a failure case
(pci_enable_resource failing when PCI_PROBE_ONLY is enabled) -
why is the PCI core creating per-device resources which do not have
parents.

I've no idea on that; the only ARM boxes I have use the kernel's PCI
allocation, I don't have these boxes which want to use PCI_PROBE_ONLY
so it's something I have zero knowledge of.
diff mbox

Patch

diff --git a/arch/arm64/kernel/pci.c b/arch/arm64/kernel/pci.c
index ce5836c..7fd4d2b 100644
--- a/arch/arm64/kernel/pci.c
+++ b/arch/arm64/kernel/pci.c
@@ -68,3 +68,11 @@  void pci_bus_assign_domain_nr(struct pci_bus *bus, struct device *parent)
 	bus->domain_nr = domain;
 }
 #endif
+
+int pcibios_enable_device(struct pci_dev *dev, int mask)
+{
+	if (pci_has_flag(PCI_PROBE_ONLY))
+		return 0;
+
+	return pci_enable_resources(dev, mask);
+}