linux-arm-kernel.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [RFC/RFT PATCH 1/2] ARM: kernel: bios32: implement PCI device resources claiming
@ 2015-05-14 14:42 Lorenzo Pieralisi
  2015-05-14 14:42 ` [RFC/RFT PATCH 2/2] ARM64: kernel: pci: " Lorenzo Pieralisi
  0 siblings, 1 reply; 10+ messages in thread
From: Lorenzo Pieralisi @ 2015-05-14 14:42 UTC (permalink / raw)
  To: linux-arm-kernel

The current ARM pcibios layer prevents PCI devices resources enablement
if the PCI_PROBE_ONLY global flag is set, since on systems that require
immutable PCI BARs set-up (ie probe only) the arm PCI bios layer does
not assign resources, hence resources are not really checked (ie claimed)
and they do not get assigned a parent, which causes pci_enable_resources
to fail in turn.

If the kernel tries to enable the resources for a PCI device through
pci_enable_resources, it would fail on PCI_PROBE_ONLY systems since the
device resources are not claimed (ie they are not assigned) on those
systems and the resource parent is left uninitialized (ie they have a
dangling parent pointer).

This behaviour does not conform with the expected kernel behaviour.

When a PCI device and its resources are scanned, the detected PCI
resources should be claimed in order to validate their values read
from the BARs set-up and should be assigned a parent resource so that the
resource hierarchy is initialized.

Resource claiming must be carried out on PCI_PROBE_ONLY systems
too, since it is a method for validating resources and it has nothing
to do with PCI_PROBE_ONLY flag.

This patch removes the pcibios_enable_device call from the arm bios32
implementation (which means that arm falls back to the generic weak
version for its implementation, that correctly enables a device resources)
and replaces it with an arm pcibios_add_device implementation, that claims
resources for a device, so that the behaviour becomes compliant with the
expected PCI device kernel initialization flow.

This way, resources are claimed and enabled on PCI_PROBE_ONLY systems
too improving the BAR set-up validation and making the arm kernel PCI
behaviour closer to other architectures.

Signed-off-by: Lorenzo Pieralisi <lorenzo.pieralisi@arm.com>
Cc: Arnd Bergmann <arnd@arndb.de>
Cc: Will Deacon <will.deacon@arm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Russell King <linux@arm.linux.org.uk>
---
 arch/arm/kernel/bios32.c | 22 ++++++++++++++++------
 1 file changed, 16 insertions(+), 6 deletions(-)

diff --git a/arch/arm/kernel/bios32.c b/arch/arm/kernel/bios32.c
index fcbbbb1..aace9ca 100644
--- a/arch/arm/kernel/bios32.c
+++ b/arch/arm/kernel/bios32.c
@@ -604,15 +604,25 @@ resource_size_t pcibios_align_resource(void *data, const struct resource *res,
 }
 
 /**
- * pcibios_enable_device - Enable I/O and memory.
- * @dev: PCI device to be enabled
+ * pcibios_add_device - Initialize device before adding it to PCI bus
+ * @dev: PCI device to be added
  */
-int pcibios_enable_device(struct pci_dev *dev, int mask)
+int pcibios_add_device(struct pci_dev *dev)
 {
-	if (pci_has_flag(PCI_PROBE_ONLY))
-		return 0;
+	struct resource *res;
+	int i;
+	/*
+	 * Device resources are claimed to validate
+	 * them and initialize their hierarchy structure
+	 */
+	for (i = 0; i < PCI_NUM_RESOURCES; i++) {
+		res = &dev->resource[i];
+		if (res->parent || !res->flags)
+			continue;
+		pci_claim_resource(dev, i);
+	}
 
-	return pci_enable_resources(dev, mask);
+	return 0;
 }
 
 int pci_mmap_page_range(struct pci_dev *dev, struct vm_area_struct *vma,
-- 
2.2.1

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2015-05-20 17:48 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-05-14 14:42 [RFC/RFT PATCH 1/2] ARM: kernel: bios32: implement PCI device resources claiming Lorenzo Pieralisi
2015-05-14 14:42 ` [RFC/RFT PATCH 2/2] ARM64: kernel: pci: " Lorenzo Pieralisi
2015-05-15  2:09   ` Suravee Suthikulanit
2015-05-18 17:38     ` Lorenzo Pieralisi
2015-05-18 19:44       ` Suravee Suthikulanit
2015-05-20  8:56     ` Lorenzo Pieralisi
2015-05-20 13:02       ` Bjorn Helgaas
2015-05-20 17:48         ` Lorenzo Pieralisi
2015-05-19 23:25   ` Bjorn Helgaas
2015-05-20  9:16     ` Lorenzo Pieralisi

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).