Skip to contentSkip to conversation

Fix incorrect comments in linker_lists.h

PATCH New Bin Meng 2 participants 20 messages Jul 18, 2015 – Jul 21, 2015 1 message not in the archive

Subsystems (2)
lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Bin Meng

author
#1 lore raw

PATCH 1/6 Fix incorrect comments in linker_lists.h

This corrects several typos in the comment block as well as some indentions and nits in the linker_lists.h.

---

 include/linker_lists.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
include/linker_lists.h +10 -10
index b22d169..76898ab 100644
@@ -83,7 +83,7 @@
  * global list name ("outer"); iterators for only a sub-list should use
  * the full sub-list name ("outer_2_inner").
  *
- *  Here is an example of the sections generated from a global list
+ * Here is an example of the sections generated from a global list
  * named "drivers", two sub-lists named "i2c" and "pci", and iterators
  * defined for the whole list and each sub-list:
  *
@@ -103,7 +103,7 @@
  */
 
 /**
- * ll_sym() - Access a linker-generated array entry
+ * llsym() - Access a linker-generated array entry
  * @_type:	Data type of the entry
  * @_name:	Name of the entry
  * @_list:	name of the list. Should contain only characters allowed
@@ -142,7 +142,7 @@
  *    the inner sections are present in the array.
  *
  * Example:
- * ll_entry_declare(struct my_sub_cmd, my_sub_cmd, cmd_sub, cmd.sub) = {
+ * ll_entry_declare(struct my_sub_cmd, my_sub_cmd, cmd_sub) = {
  *         .x = 3,
  *         .y = 4,
  * };
@@ -162,7 +162,7 @@
  * This is like ll_entry_declare() but creates multiple entries. It should
  * be assigned to an array.
  *
- * ll_entry_declare_list(struct my_sub_cmd, my_sub_cmd, cmd_sub, cmd.sub) = {
+ * ll_entry_declare_list(struct my_sub_cmd, my_sub_cmd, cmd_sub) = {
  *	{ .x = 3, .y = 4 },
  *	{ .x = 8, .y = 2 },
  *	{ .x = 1, .y = 7 }
@@ -222,7 +222,7 @@
  */
 #define ll_entry_end(_type, _list)					\
 ({									\
-	static char end[0] __aligned(4) __attribute__((unused,	\
+	static char end[0] __aligned(4) __attribute__((unused,		\
 		section(".u_boot_list_2_"#_list"_3")));			\
 	(_type *)&end;							\
 })
@@ -256,8 +256,8 @@
  * @_name:	Name of the entry
  * @_list:	Name of the list in which this entry is placed
  *
- * This function returns a pointer to a particular entry in LG-array
- * identified by the subsection of u_boot_list where the entry resides
+ * This function returns a pointer to a particular entry in linker-generated
+ * array identified by the subsection of u_boot_list where the entry resides
  * and it's name.
  *
  * Example:
@@ -272,7 +272,7 @@
 	({								\
 		extern _type _u_boot_list_2_##_list##_2_##_name;	\
 		_type *_ll_result =					\
-			&_u_boot_list_2_##_list##_2_##_name;	\
+			&_u_boot_list_2_##_list##_2_##_name;		\
 		_ll_result;						\
 	})
 
@@ -297,7 +297,7 @@
 })
 
 /**
- * ll_entry_end() - Point after last entry of last linker-generated array
+ * ll_end() - Point after last entry of last linker-generated array
  * @_type:	Data type of the entry
  *
  * This function returns (_type *) pointer after the very last entry of
@@ -311,7 +311,7 @@
  */
 #define ll_end(_type)							\
 ({									\
-	static char end[0] __aligned(4) __attribute__((unused,	\
+	static char end[0] __aligned(4) __attribute__((unused,		\
 		section(".u_boot_list_3")));				\
 	(_type *)&end;							\
 })
Signature · 1 line
1.8.2.1
#2 lore raw

PATCH 1/6 Fix incorrect comments in linker_lists.h

Quoted 8 lines · Bin Meng

This corrects several typos in the comment block as well as some indentions and nits in the linker_lists.h.

---

 include/linker_lists.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
#3 lore raw

PATCH 1/6 Fix incorrect comments in linker_lists.h

Quoted 11 lines · Simon Glass
Quoted 8 lines · Bin Meng

This corrects several typos in the comment block as well as some indentions and nits in the linker_lists.h.

---

 include/linker_lists.h | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)

Applied to u-boot-x86, thanks!

author
#4 lore raw

PATCH 2/6 dm: pci: Correct primary/secondary/subordinate bus number assignment

In reply to a message not in the archive

In driver model, each pci bridge device has its own hose structure. hose->first_busno points to the bridge device's device number, so we should not substract hose->first_busno before programming the bridge device's primary/secondary/subordinate bus number registers.

---

 drivers/pci/pci_auto.c | 9 +++++++++
 1 file changed, 9 insertions(+)
drivers/pci/pci_auto.c +9 -0
index e034ed1..ef6dc4f 100644
@@ -224,10 +224,15 @@ void pciauto_prescan_setup_bridge(struct pci_controller *hose,
 	prefechable_64 &= PCI_PREF_RANGE_TYPE_MASK;
 
 	/* Configure bus number registers */
+#ifdef CONFIG_DM_PCI
+	pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS, PCI_BUS(dev));
+	pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS, sub_bus);
+#else
 	pci_hose_write_config_byte(hose, dev, PCI_PRIMARY_BUS,
 				   PCI_BUS(dev) - hose->first_busno);
 	pci_hose_write_config_byte(hose, dev, PCI_SECONDARY_BUS,
 				   sub_bus - hose->first_busno);
+#endif
 	pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, 0xff);
 
 	if (pci_mem) {
@@ -295,8 +300,12 @@ void pciauto_postscan_setup_bridge(struct pci_controller *hose,
 	struct pci_region *pci_io = hose->pci_io;
 
 	/* Configure bus number registers */
+#ifdef CONFIG_DM_PCI
+	pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS, sub_bus);
+#else
 	pci_hose_write_config_byte(hose, dev, PCI_SUBORDINATE_BUS,
 				   sub_bus - hose->first_busno);
+#endif
 
 	if (pci_mem) {
 		/* Round memory allocator to 1MB boundary */
Signature · 1 line
1.8.2.1
#5 lore raw

PATCH 2/6 dm: pci: Correct primary/secondary/subordinate bus number assignment

Hi Bin,

Quoted 10 lines · Bin Meng

In driver model, each pci bridge device has its own hose structure. hose->first_busno points to the bridge device's device number, so we should not substract hose->first_busno before programming the bridge device's primary/secondary/subordinate bus number registers.

---

 drivers/pci/pci_auto.c | 9 +++++++++
 1 file changed, 9 insertions(+)

I'm not happy with how each PCI bridge has its own hose structure. I think that was a mistake. It just creates problems.

I'm thinking we should instead have a UCLASS_PCI which is strictly for the PCI controller, and a new UCLASS_PCI_BRIDGE for bridges.

What do you think?

Regards,
Simon

author
#6 lore raw

PATCH 2/6 dm: pci: Correct primary/secondary/subordinate bus number assignment

Hi Simon,

Quoted 17 lines · Simon Glass

Hi Bin,

Quoted 10 lines · Bin Meng

In driver model, each pci bridge device has its own hose structure. hose->first_busno points to the bridge device's device number, so we should not substract hose->first_busno before programming the bridge device's primary/secondary/subordinate bus number registers.

---

 drivers/pci/pci_auto.c | 9 +++++++++
 1 file changed, 9 insertions(+)
Quoted 8 lines

I'm not happy with how each PCI bridge has its own hose structure. I think that was a mistake. It just creates problems.

I'm thinking we should instead have a UCLASS_PCI which is strictly for the PCI controller, and a new UCLASS_PCI_BRIDGE for bridges.

What do you think?

I guess that may help. During the debug, I feel the dm pci codes are really not that intuitive than the previous non-dm version. It took me sometime to figure out where is the problem.

Regards,
Bin

#7 lore raw

PATCH 2/6 dm: pci: Correct primary/secondary/subordinate bus number assignment

Hi Bin,

Quoted 26 lines · Bin Meng

Hi Simon,

Quoted 23 lines · Simon Glass

Hi Bin,

Quoted 10 lines · Bin Meng

In driver model, each pci bridge device has its own hose structure. hose->first_busno points to the bridge device's device number, so we should not substract hose->first_busno before programming the bridge device's primary/secondary/subordinate bus number registers.

---

 drivers/pci/pci_auto.c | 9 +++++++++
 1 file changed, 9 insertions(+)

I'm not happy with how each PCI bridge has its own hose structure. I think that was a mistake. It just creates problems.

I'm thinking we should instead have a UCLASS_PCI which is strictly for the PCI controller, and a new UCLASS_PCI_BRIDGE for bridges.

Quoted 6 lines
Quoted 2 lines

What do you think?

I guess that may help. During the debug, I feel the dm pci codes are really not that intuitive than the previous non-dm version. It took me sometime to figure out where is the problem.

Agreed. Part of the problem I think is that it is still compatible with the old code.

We should be able to do things like pci_read_config16(struct udevice *dev, ...)

I guess we could move to separate things more.

Regards,
Simon

#8 lore raw

PATCH 2/6 dm: pci: Correct primary/secondary/subordinate bus number assignment

In reply to Simon Glass
Quoted 8 lines · Simon Glass

Hi Bin,

Quoted 5 lines · Bin Meng

In driver model, each pci bridge device has its own hose structure. hose->first_busno points to the bridge device's device number, so we should not substract hose->first_busno before programming the bridge device's primary/secondary/subordinate bus number registers.

Quoted 9 lines
Quoted 5 lines

---

 drivers/pci/pci_auto.c | 9 +++++++++
 1 file changed, 9 insertions(+)

Applied to u-boot-x86, thanks!

[snip]

author
#9 lore raw

PATCH 3/6 dm: pci: Use complete bdf in all pci config read/write routines

In reply to a message not in the archive

Currently pci_bus_read_config() and pci_bus_write_config() are called with bus number masked off in the parameter bdf, and bus number is supposed to be added back in the bridge driver's pci config read/write ops if the device is behind a pci bridge. However this logic only works for a pci topology where there is only one bridge off the root controller. If there is addtional bridge in the system, the logic will create a non-existent bdf where its bus number gets accumulated across bridges.

To correct this, we change all pci config read/write routines to use complete bdf all the way up to the root controller.

---

 drivers/pci/pci-uclass.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
drivers/pci/pci-uclass.c +23 -23
index 5b91fe3..e92e4f3 100644
@@ -199,8 +199,7 @@ int pci_write_config(pci_dev_t bdf, int offset, unsigned long value,
 	if (ret)
 		return ret;
 
-	return pci_bus_write_config(bus, PCI_MASK_BUS(bdf), offset, value,
-				    size);
+	return pci_bus_write_config(bus, bdf, offset, value, size);
 }
 
 int pci_write_config32(pci_dev_t bdf, int offset, u32 value)
@@ -239,8 +238,7 @@ int pci_read_config(pci_dev_t bdf, int offset, unsigned long *valuep,
 	if (ret)
 		return ret;
 
-	return pci_bus_read_config(bus, PCI_MASK_BUS(bdf), offset, valuep,
-				   size);
+	return pci_bus_read_config(bus, bdf, offset, valuep, size);
 }
 
 int pci_read_config32(pci_dev_t bdf, int offset, u32 *valuep)
@@ -357,41 +355,43 @@ int pci_bind_bus_devices(struct udevice *bus)
 {
 	ulong vendor, device;
 	ulong header_type;
-	pci_dev_t devfn, end;
+	pci_dev_t bdf, end;
 	bool found_multi;
 	int ret;
 
 	found_multi = false;
-	end = PCI_DEVFN(PCI_MAX_PCI_DEVICES - 1, PCI_MAX_PCI_FUNCTIONS - 1);
-	for (devfn = PCI_DEVFN(0, 0); devfn < end; devfn += PCI_DEVFN(0, 1)) {
+	end = PCI_BDF(bus->seq, PCI_MAX_PCI_DEVICES - 1,
+		      PCI_MAX_PCI_FUNCTIONS - 1);
+	for (bdf = PCI_BDF(bus->seq, 0, 0); bdf < end;
+	     bdf += PCI_BDF(0, 0, 1)) {
 		struct pci_child_platdata *pplat;
 		struct udevice *dev;
 		ulong class;
 
-		if (PCI_FUNC(devfn) && !found_multi)
+		if (PCI_FUNC(bdf) && !found_multi)
 			continue;
 		/* Check only the first access, we don't expect problems */
-		ret = pci_bus_read_config(bus, devfn, PCI_HEADER_TYPE,
+		ret = pci_bus_read_config(bus, bdf, PCI_HEADER_TYPE,
 					  &header_type, PCI_SIZE_8);
 		if (ret)
 			goto error;
-		pci_bus_read_config(bus, devfn, PCI_VENDOR_ID, &vendor,
+		pci_bus_read_config(bus, bdf, PCI_VENDOR_ID, &vendor,
 				    PCI_SIZE_16);
 		if (vendor == 0xffff || vendor == 0x0000)
 			continue;
 
-		if (!PCI_FUNC(devfn))
+		if (!PCI_FUNC(bdf))
 			found_multi = header_type & 0x80;
 
 		debug("%s: bus %d/%s: found device %x, function %d\n", __func__,
-		      bus->seq, bus->name, PCI_DEV(devfn), PCI_FUNC(devfn));
-		pci_bus_read_config(bus, devfn, PCI_DEVICE_ID, &device,
+		      bus->seq, bus->name, PCI_DEV(bdf), PCI_FUNC(bdf));
+		pci_bus_read_config(bus, bdf, PCI_DEVICE_ID, &device,
 				    PCI_SIZE_16);
-		pci_bus_read_config(bus, devfn, PCI_CLASS_DEVICE, &class,
+		pci_bus_read_config(bus, bdf, PCI_CLASS_DEVICE, &class,
 				    PCI_SIZE_16);
 
 		/* Find this device in the device tree */
-		ret = pci_bus_find_devfn(bus, devfn, &dev);
+		ret = pci_bus_find_devfn(bus, PCI_MASK_BUS(bdf), &dev);
 
 		/* If nothing in the device tree, bind a generic device */
 		if (ret == -ENODEV) {
@@ -399,7 +399,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 			const char *drv;
 
 			sprintf(name, "pci_%x:%x.%x", bus->seq,
-				PCI_DEV(devfn), PCI_FUNC(devfn));
+				PCI_DEV(bdf), PCI_FUNC(bdf));
 			str = strdup(name);
 			if (!str)
 				return -ENOMEM;
@@ -412,7 +412,7 @@ int pci_bind_bus_devices(struct udevice *bus)
 
 		/* Update the platform data */
 		pplat = dev_get_parent_platdata(dev);
-		pplat->devfn = devfn;
+		pplat->devfn = PCI_MASK_BUS(bdf);
 		pplat->vendor = vendor;
 		pplat->device = device;
 		pplat->class = class;
@@ -583,20 +583,20 @@ static int pci_uclass_child_post_bind(struct udevice *dev)
 	return 0;
 }
 
-int pci_bridge_read_config(struct udevice *bus, pci_dev_t devfn, uint offset,
-			   ulong *valuep, enum pci_size_t size)
+static int pci_bridge_read_config(struct udevice *bus, pci_dev_t bdf,
+				  uint offset, ulong *valuep,
+				  enum pci_size_t size)
 {
 	struct pci_controller *hose = bus->uclass_priv;
-	pci_dev_t bdf = PCI_ADD_BUS(bus->seq, devfn);
 
 	return pci_bus_read_config(hose->ctlr, bdf, offset, valuep, size);
 }
 
-int pci_bridge_write_config(struct udevice *bus, pci_dev_t devfn, uint offset,
-			    ulong value, enum pci_size_t size)
+static int pci_bridge_write_config(struct udevice *bus, pci_dev_t bdf,
+				   uint offset, ulong value,
+				   enum pci_size_t size)
 {
 	struct pci_controller *hose = bus->uclass_priv;
-	pci_dev_t bdf = PCI_ADD_BUS(bus->seq, devfn);
 
 	return pci_bus_write_config(hose->ctlr, bdf, offset, value, size);
 }
Signature · 1 line
1.8.2.1
#10 lore raw

PATCH 3/6 dm: pci: Use complete bdf in all pci config read/write routines

Quoted 9 lines · Bin Meng

Currently pci_bus_read_config() and pci_bus_write_config() are called with bus number masked off in the parameter bdf, and bus number is supposed to be added back in the bridge driver's pci config read/write ops if the device is behind a pci bridge. However this logic only works for a pci topology where there is only one bridge off the root controller. If there is addtional bridge in the system, the logic will create a non-existent bdf where its bus number gets accumulated across bridges.

Quoted 8 lines

To correct this, we change all pci config read/write routines to use complete bdf all the way up to the root controller.

---

 drivers/pci/pci-uclass.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)
#11 lore raw

PATCH 3/6 dm: pci: Use complete bdf in all pci config read/write routines

Quoted 13 lines · Simon Glass
Quoted 12 lines · Bin Meng

Currently pci_bus_read_config() and pci_bus_write_config() are called with bus number masked off in the parameter bdf, and bus number is supposed to be added back in the bridge driver's pci config read/write ops if the device is behind a pci bridge. However this logic only works for a pci topology where there is only one bridge off the root controller. If there is addtional bridge in the system, the logic will create a non-existent bdf where its bus number gets accumulated across bridges.

To correct this, we change all pci config read/write routines to use complete bdf all the way up to the root controller.

Quoted 8 lines
Quoted 5 lines

---

 drivers/pci/pci-uclass.c | 46 +++++++++++++++++++++++-----------------------
 1 file changed, 23 insertions(+), 23 deletions(-)

Applied to u-boot-x86, thanks!

author
#12 lore raw

PATCH 4/6 dm: pci: Pass only device/function to pci_bus_find_devfn()

In reply to a message not in the archive

In dm_pci_hose_probe_bus(), pci_bus_find_devfn() is called with a bdf which includes a bus number, but it really should not as this routine only expects a device/function encoding.

---

 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/pci/pci-uclass.c +1 -1
index e92e4f3..164e3e9 100644
@@ -323,7 +323,7 @@ int dm_pci_hose_probe_bus(struct pci_controller *hose, pci_dev_t bdf)
 	parent = hose->bus;
 
 	/* Find the bus within the parent */
-	ret = pci_bus_find_devfn(parent, bdf, &bus);
+	ret = pci_bus_find_devfn(parent, PCI_MASK_BUS(bdf), &bus);
 	if (ret) {
 		debug("%s: Cannot find device %x on bus %s: %d\n", __func__,
 		      bdf, parent->name, ret);
Signature · 1 line
1.8.2.1
#13 lore raw

PATCH 4/6 dm: pci: Pass only device/function to pci_bus_find_devfn()

Quoted 9 lines · Bin Meng

In dm_pci_hose_probe_bus(), pci_bus_find_devfn() is called with a bdf which includes a bus number, but it really should not as this routine only expects a device/function encoding.

---

 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
#14 lore raw

PATCH 4/6 dm: pci: Pass only device/function to pci_bus_find_devfn()

Quoted 5 lines · Simon Glass
Quoted 4 lines · Bin Meng

In dm_pci_hose_probe_bus(), pci_bus_find_devfn() is called with a bdf which includes a bus number, but it really should not as this routine only expects a device/function encoding.

Quoted 8 lines
Quoted 5 lines

---

 drivers/pci/pci-uclass.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied to u-boot-x86, thanks!

author
#15 lore raw

PATCH 5/6 dm: pci: Support bridge device configuration correctly

In reply to a message not in the archive

Commit aec241d "dm: pci: Use the correct hose when configuring devices" was an attempt to fix pci bridge device configuration, but unfortunately that does not work 100%. In pciauto_config_devices(), the fix tried to call pciauto_config_device() with a ctlr_hose which is supposed to be the root controller hose, however when walking through a pci topology with 2 or more pci bridges this logic simply fails.

The call chain is: pciauto_config_devices()->pciauto_config_device() ->dm_pci_hose_probe_bus(). Here the call to dm_pci_hose_probe_bus() does not make any sense as the given hose is not the bridge device's hose, instead it is either the root controller's hose (case#1: if it is the 2nd pci bridge), or the bridge's parent bridge's hose (case#2:
if it is the 3rd pci bridge). In both cases the logic is wrong.

For example, for failing case#1 if the bridge device to config has the same devfn as one of the devices under the root controller, the call to pci_bus_find_devfn() will return the udevice of that pci device under the root controller as the bus, but this is wrong as the udevice is not a bus which does not contain all the necessary bits associated with the udevice which causes further failures.

To correctly support pci bridge device configuration, we should still call pciauto_config_device() with the pci bridge's hose directly. In order to access valid pci region information, we need to refer to the root controller simply by a call to pci_bus_to_hose(0) and get the region information there in the pciauto_prescan_setup_bridge(), pciauto_postscan_setup_bridge() and pciauto_config_device().

---

 drivers/pci/pci-uclass.c |  6 +----
 drivers/pci/pci_auto.c   | 66 +++++++++++++++++++++++++++++++++++++++---------
 drivers/pci/pci_common.c |  7 ++++-
 3 files changed, 61 insertions(+), 18 deletions(-)
drivers/pci/pci-uclass.c +1 -5
index 164e3e9..92dcc01 100644
@@ -294,7 +294,6 @@ int pci_auto_config_devices(struct udevice *bus)
 	     !ret && dev;
 	     ret = device_find_next_child(&dev)) {
 		struct pci_child_platdata *pplat;
-		struct pci_controller *ctlr_hose;
 
 		pplat = dev_get_parent_platdata(dev);
 		unsigned int max_bus;
@@ -302,10 +301,7 @@ int pci_auto_config_devices(struct udevice *bus)
 
 		bdf = PCI_ADD_BUS(bus->seq, pplat->devfn);
 		debug("%s: device %s\n", __func__, dev->name);
-
-		/* The root controller has the region information */
-		ctlr_hose = hose->ctlr->uclass_priv;
-		max_bus = pciauto_config_device(ctlr_hose, bdf);
+		max_bus = pciauto_config_device(hose, bdf);
 		sub_bus = max(sub_bus, max_bus);
 	}
 	debug("%s: done\n", __func__);
drivers/pci/pci_auto.c +54 -12

108 lines not on this page · raw message

drivers/pci/pci_common.c +6 -1
index f67c9c7..07f1726 100644
@@ -224,7 +224,7 @@ phys_addr_t pci_hose_bus_to_phys(struct pci_controller *hose,
 
 #ifdef CONFIG_DM_PCI
 	/* The root controller has the region information */
-	hose = hose->ctlr->uclass_priv;
+	hose = pci_bus_to_hose(0);
 #endif
 
 	/*
@@ -289,6 +289,11 @@ pci_addr_t pci_hose_phys_to_bus(struct pci_controller *hose,
 		return bus_addr;
 	}
 
+#ifdef CONFIG_DM_PCI
+	/* The root controller has the region information */
+	hose = pci_bus_to_hose(0);
+#endif
+
 	/*
 	 * if PCI_REGION_MEM is set we do a two pass search with preference
 	 * on matches that don't have PCI_REGION_SYS_MEMORY set
Signature · 1 line
1.8.2.1
#16 lore raw

PATCH 5/6 dm: pci: Support bridge device configuration correctly

Quoted 28 lines · Bin Meng

Commit aec241d "dm: pci: Use the correct hose when configuring devices" was an attempt to fix pci bridge device configuration, but unfortunately that does not work 100%. In pciauto_config_devices(), the fix tried to call pciauto_config_device() with a ctlr_hose which is supposed to be the root controller hose, however when walking through a pci topology with 2 or more pci bridges this logic simply fails.

The call chain is: pciauto_config_devices()->pciauto_config_device() ->dm_pci_hose_probe_bus(). Here the call to dm_pci_hose_probe_bus() does not make any sense as the given hose is not the bridge device's hose, instead it is either the root controller's hose (case#1: if it is the 2nd pci bridge), or the bridge's parent bridge's hose (case#2:
if it is the 3rd pci bridge). In both cases the logic is wrong.

For example, for failing case#1 if the bridge device to config has the same devfn as one of the devices under the root controller, the call to pci_bus_find_devfn() will return the udevice of that pci device under the root controller as the bus, but this is wrong as the udevice is not a bus which does not contain all the necessary bits associated with the udevice which causes further failures.

To correctly support pci bridge device configuration, we should still call pciauto_config_device() with the pci bridge's hose directly. In order to access valid pci region information, we need to refer to the root controller simply by a call to pci_bus_to_hose(0) and get the region information there in the pciauto_prescan_setup_bridge(), pciauto_postscan_setup_bridge() and pciauto_config_device().

Quoted 7 lines

---

 drivers/pci/pci-uclass.c |  6 +----
 drivers/pci/pci_auto.c   | 66 +++++++++++++++++++++++++++++++++++++++---------
 drivers/pci/pci_common.c |  7 ++++-
 3 files changed, 61 insertions(+), 18 deletions(-)
#17 lore raw

PATCH 5/6 dm: pci: Support bridge device configuration correctly

Quoted 32 lines · Simon Glass
Quoted 31 lines · Bin Meng

Commit aec241d "dm: pci: Use the correct hose when configuring devices" was an attempt to fix pci bridge device configuration, but unfortunately that does not work 100%. In pciauto_config_devices(), the fix tried to call pciauto_config_device() with a ctlr_hose which is supposed to be the root controller hose, however when walking through a pci topology with 2 or more pci bridges this logic simply fails.

The call chain is: pciauto_config_devices()->pciauto_config_device() ->dm_pci_hose_probe_bus(). Here the call to dm_pci_hose_probe_bus() does not make any sense as the given hose is not the bridge device's hose, instead it is either the root controller's hose (case#1: if it is the 2nd pci bridge), or the bridge's parent bridge's hose (case#2:
if it is the 3rd pci bridge). In both cases the logic is wrong.

For example, for failing case#1 if the bridge device to config has the same devfn as one of the devices under the root controller, the call to pci_bus_find_devfn() will return the udevice of that pci device under the root controller as the bus, but this is wrong as the udevice is not a bus which does not contain all the necessary bits associated with the udevice which causes further failures.

To correctly support pci bridge device configuration, we should still call pciauto_config_device() with the pci bridge's hose directly. In order to access valid pci region information, we need to refer to the root controller simply by a call to pci_bus_to_hose(0) and get the region information there in the pciauto_prescan_setup_bridge(), pciauto_postscan_setup_bridge() and pciauto_config_device().

---

Quoted 7 lines
Quoted 4 lines
 drivers/pci/pci-uclass.c |  6 +----
 drivers/pci/pci_auto.c   | 66 +++++++++++++++++++++++++++++++++++++++---------
 drivers/pci/pci_common.c |  7 ++++-
 3 files changed, 61 insertions(+), 18 deletions(-)

Applied to u-boot-x86, thanks!

author
#18 lore raw

PATCH 6/6 x86: Convert to use driver model pci on queensbay/crownbay

In reply to a message not in the archive

Move to driver model pci for Intel queensbay/crownbay.

---

 arch/x86/cpu/queensbay/Makefile  |  1 -
 arch/x86/cpu/queensbay/tnc.c     |  5 -----
 arch/x86/cpu/queensbay/tnc_pci.c | 46 ----------------------------------------
 arch/x86/dts/crownbay.dts        |  6 +++++-
 configs/crownbay_defconfig       |  1 +
 5 files changed, 6 insertions(+), 53 deletions(-)
 delete mode 100644 arch/x86/cpu/queensbay/tnc_pci.c
arch/x86/cpu/queensbay/Makefile +0 -1
index d8761fd..660f967 100644
@@ -6,4 +6,3 @@
 
 obj-y += fsp_configs.o
 obj-y += tnc.o topcliff.o
-obj-$(CONFIG_PCI) += tnc_pci.o
arch/x86/cpu/queensbay/tnc.c +0 -5
index d27b2d9..de50893 100644
@@ -25,7 +25,6 @@ static void unprotect_spi_flash(void)
 
 int arch_cpu_init(void)
 {
-	struct pci_controller *hose;
 	int ret;
 
 	post_code(POST_CPU_INIT);
@@ -37,10 +36,6 @@ int arch_cpu_init(void)
 	if (ret)
 		return ret;
 
-	ret = pci_early_init_hose(&hose);
-	if (ret)
-		return ret;
-
 	unprotect_spi_flash();
 
 	return 0;
arch/x86/cpu/queensbay/tnc_pci.c deleted +0 -46

46 lines not on this page · raw message

arch/x86/dts/crownbay.dts +5 -1
index 60da1f5..3af9cc3 100644
@@ -90,8 +90,12 @@
 	pci {
 		#address-cells = <3>;
 		#size-cells = <2>;
-		compatible = "intel,pci";
+		compatible = "pci-x86";
 		device_type = "pci";
+		u-boot,dm-pre-reloc;
+		ranges = <0x02000000 0x0 0x40000000 0x40000000 0 0x80000000
+			  0x42000000 0x0 0xc0000000 0xc0000000 0 0x20000000
+			  0x01000000 0x0 0x2000 0x2000 0 0xe000>;
 
 		pcie at 17,0 {
 			#address-cells = <3>;
configs/crownbay_defconfig +1 -0
index 17e6a72..aa1232d 100644
@@ -17,6 +17,7 @@ CONFIG_BOOTSTAGE_REPORT=y
 CONFIG_CMD_BOOTSTAGE=y
 CONFIG_OF_CONTROL=y
 CONFIG_CPU=y
+CONFIG_DM_PCI=y
 CONFIG_SPI_FLASH=y
 CONFIG_VIDEO_VESA=y
 CONFIG_FRAMEBUFFER_SET_VESA_MODE=y
Signature · 1 line
1.8.2.1
#19 lore raw

PATCH 6/6 x86: Convert to use driver model pci on queensbay/crownbay

Quoted 6 lines · Bin Meng

Move to driver model pci for Intel queensbay/crownbay.

---

Quoted 7 lines
 arch/x86/cpu/queensbay/Makefile  |  1 -
 arch/x86/cpu/queensbay/tnc.c     |  5 -----
 arch/x86/cpu/queensbay/tnc_pci.c | 46 ----------------------------------------
 arch/x86/dts/crownbay.dts        |  6 +++++-
 configs/crownbay_defconfig       |  1 +
 5 files changed, 6 insertions(+), 53 deletions(-)
 delete mode 100644 arch/x86/cpu/queensbay/tnc_pci.c
#20 lore raw

PATCH 6/6 x86: Convert to use driver model pci on queensbay/crownbay

Quoted 15 lines · Simon Glass
Quoted 6 lines · Bin Meng

Move to driver model pci for Intel queensbay/crownbay.

---

Quoted 7 lines
 arch/x86/cpu/queensbay/Makefile  |  1 -
 arch/x86/cpu/queensbay/tnc.c     |  5 -----
 arch/x86/cpu/queensbay/tnc_pci.c | 46 ----------------------------------------
 arch/x86/dts/crownbay.dts        |  6 +++++-
 configs/crownbay_defconfig       |  1 +
 5 files changed, 6 insertions(+), 53 deletions(-)
 delete mode 100644 arch/x86/cpu/queensbay/tnc_pci.c
Quoted 2 lines

Applied to u-boot-x86, thanks!