All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Glass <sjg@chromium.org>
To: u-boot@lists.denx.de
Subject: [PATCH v3 13/28] pci: Update to use new sequence numbers
Date: Wed, 16 Dec 2020 21:20:18 -0700	[thread overview]
Message-ID: <20201216212001.v3.13.Ic2ef484e2ee4861057d1d4bb1bb9e5ffe51c7c76@changeid> (raw)
In-Reply-To: <20201217042034.411902-1-sjg@chromium.org>

Now that we know the sequence number at bind time, there is no need for
special-case code in dm_pci_hose_probe_bus().

Note: the PCI_CAP_ID_EA code may need a look, but there are no test
failures so I have left it as is.

Signed-off-by: Simon Glass <sjg@chromium.org>
---

Changes in v3:
- Update PCI to use manual sequence numbering

Changes in v2:
- Use the sequence number directly instead of max bus

 drivers/pci/pci-uclass.c | 45 ++++++++++++++++++++++++----------------
 drivers/pci/pci_auto.c   | 10 ++++-----
 2 files changed, 32 insertions(+), 23 deletions(-)

diff --git a/drivers/pci/pci-uclass.c b/drivers/pci/pci-uclass.c
index ebe7fb7cd2d..bff183eea23 100644
--- a/drivers/pci/pci-uclass.c
+++ b/drivers/pci/pci-uclass.c
@@ -14,6 +14,7 @@
 #include <asm/io.h>
 #include <dm/device-internal.h>
 #include <dm/lists.h>
+#include <dm/uclass-internal.h>
 #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
 #include <asm/fsp/fsp_support.h>
 #endif
@@ -544,7 +545,7 @@ int pci_auto_config_devices(struct udevice *bus)
 			continue;
 		ret = dm_pciauto_config_device(dev);
 		if (ret < 0)
-			return ret;
+			return log_msg_ret("auto", ret);
 		max_bus = ret;
 		sub_bus = max(sub_bus, max_bus);
 
@@ -554,7 +555,7 @@ int pci_auto_config_devices(struct udevice *bus)
 	}
 	debug("%s: done\n", __func__);
 
-	return sub_bus;
+	return log_msg_ret("sub", sub_bus);
 }
 
 int pci_generic_mmap_write_config(
@@ -641,17 +642,9 @@ int dm_pci_hose_probe_bus(struct udevice *bus)
 	if (ret) {
 		debug("%s: Cannot probe bus %s: %d\n", __func__, bus->name,
 		      ret);
-		return ret;
+		return log_msg_ret("probe", ret);
 	}
 
-	if (!ea_pos) {
-		if (sub_bus != dev_seq(bus)) {
-			debug("%s: Internal error, bus '%s' got seq %d, expected %d\n",
-			      __func__, bus->name, dev_seq(bus), sub_bus);
-			return -EPIPE;
-		}
-		sub_bus = pci_get_bus_max();
-	}
 	dm_pciauto_postscan_setup_bridge(bus, sub_bus);
 
 	return sub_bus;
@@ -714,7 +707,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
 
 	if (ofnode_valid(node) && !ofnode_is_available(node)) {
 		debug("%s: Ignoring disabled device\n", __func__);
-		return -EPERM;
+		return log_msg_ret("dis", -EPERM);
 	}
 
 	start = ll_entry_start(struct pci_driver_entry, pci_driver_entry);
@@ -740,7 +733,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
 			 */
 			if (!(gd->flags & GD_FLG_RELOC) &&
 			    !(drv->flags & DM_FLAG_PRE_RELOC))
-				return -EPERM;
+				return log_msg_ret("pre", -EPERM);
 
 			/*
 			 * We could pass the descriptor to the driver as
@@ -768,7 +761,7 @@ static int pci_find_and_bind_driver(struct udevice *parent,
 	 * limited (ie: using Cache As RAM).
 	 */
 	if (!(gd->flags & GD_FLG_RELOC) && !bridge)
-		return -EPERM;
+		return log_msg_ret("notbr", -EPERM);
 
 	/* Bind a generic driver so that the device can be used */
 	sprintf(name, "pci_%x:%x.%x", dev_seq(parent), PCI_DEV(bdf),
@@ -1009,11 +1002,26 @@ static void decode_regions(struct pci_controller *hose, ofnode parent_node,
 static int pci_uclass_pre_probe(struct udevice *bus)
 {
 	struct pci_controller *hose;
+	struct uclass *uc;
+	int ret;
 
 	debug("%s, bus=%d/%s, parent=%s\n", __func__, dev_seq(bus), bus->name,
 	      bus->parent->name);
 	hose = bus->uclass_priv;
 
+	/*
+	 * Set the sequence number, if device_bind() doesn't. We want control
+	 * of this so that numbers are allocated as devices are probed. That
+	 * ensures that sub-bus numbered is correct (sub-buses must get numbers
+	 * higher than their parents)
+	 */
+	if (dev_seq(bus) == -1) {
+		ret = uclass_get(UCLASS_PCI, &uc);
+		if (ret)
+			return ret;
+		bus->sqq = uclass_find_next_free_req_seq(uc);
+	}
+
 	/* For bridges, use the top-level PCI controller */
 	if (!device_is_on_pci_bus(bus)) {
 		hose->ctlr = bus;
@@ -1024,6 +1032,7 @@ static int pci_uclass_pre_probe(struct udevice *bus)
 		parent_hose = dev_get_uclass_priv(bus->parent);
 		hose->ctlr = parent_hose->bus;
 	}
+
 	hose->bus = bus;
 	hose->first_busno = dev_seq(bus);
 	hose->last_busno = dev_seq(bus);
@@ -1044,14 +1053,14 @@ static int pci_uclass_post_probe(struct udevice *bus)
 	debug("%s: probing bus %d\n", __func__, dev_seq(bus));
 	ret = pci_bind_bus_devices(bus);
 	if (ret)
-		return ret;
+		return log_msg_ret("bind", ret);
 
 	if (CONFIG_IS_ENABLED(PCI_PNP) && ll_boot_init() &&
 	    (!hose->skip_auto_config_until_reloc ||
 	     (gd->flags & GD_FLG_RELOC))) {
 		ret = pci_auto_config_devices(bus);
 		if (ret < 0)
-			return log_msg_ret("pci auto-config", ret);
+			return log_msg_ret("cfg", ret);
 	}
 
 #if defined(CONFIG_X86) && defined(CONFIG_HAVE_FSP)
@@ -1071,7 +1080,7 @@ static int pci_uclass_post_probe(struct udevice *bus)
 	if ((gd->flags & GD_FLG_RELOC) && dev_seq(bus) == 0 && ll_boot_init()) {
 		ret = fsp_init_phase_pci();
 		if (ret)
-			return ret;
+			return log_msg_ret("fsp", ret);
 	}
 #endif
 
@@ -1791,7 +1800,7 @@ int pci_sriov_get_totalvfs(struct udevice *pdev)
 UCLASS_DRIVER(pci) = {
 	.id		= UCLASS_PCI,
 	.name		= "pci",
-	.flags		= DM_UC_FLAG_SEQ_ALIAS,
+	.flags		= DM_UC_FLAG_SEQ_ALIAS | DM_UC_FLAG_NO_AUTO_SEQ,
 	.post_bind	= dm_scan_fdt_dev,
 	.pre_probe	= pci_uclass_pre_probe,
 	.post_probe	= pci_uclass_post_probe,
diff --git a/drivers/pci/pci_auto.c b/drivers/pci/pci_auto.c
index 4d797ec034b..68ef4e8092a 100644
--- a/drivers/pci/pci_auto.c
+++ b/drivers/pci/pci_auto.c
@@ -321,7 +321,7 @@ int dm_pciauto_config_device(struct udevice *dev)
 	bool enum_only = false;
 	struct udevice *ctlr = pci_get_controller(dev);
 	struct pci_controller *ctlr_hose = dev_get_uclass_priv(ctlr);
-	int n;
+	int ret;
 
 #ifdef CONFIG_PCI_ENUM_ONLY
 	enum_only = true;
@@ -341,10 +341,10 @@ int dm_pciauto_config_device(struct udevice *dev)
 		dm_pciauto_setup_device(dev, 2, pci_mem, pci_prefetch, pci_io,
 					enum_only);
 
-		n = dm_pci_hose_probe_bus(dev);
-		if (n < 0)
-			return n;
-		sub_bus = (unsigned int)n;
+		ret = dm_pci_hose_probe_bus(dev);
+		if (ret < 0)
+			return log_msg_ret("probe", ret);
+		sub_bus = ret;
 		break;
 
 	case PCI_CLASS_BRIDGE_CARDBUS:
-- 
2.29.2.684.gfbc64c5ab5-goog

  parent reply	other threads:[~2020-12-17  4:20 UTC|newest]

Thread overview: 67+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-12-17  4:20 [PATCH v3 00/28] dm: Change the way sequence numbers are implemented Simon Glass
2020-12-17  4:20 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass
2021-04-15  7:39   ` Heinrich Schuchardt
2021-04-21  7:14     ` Simon Glass
2020-12-17  4:20 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-17  4:20 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-17  4:20 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-17  4:20 ` [PATCH v3 05/28] dm: test: Check all devices have a sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 06/28] dm: core: Switch binding to use new " Simon Glass
2020-12-17  4:20 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 10/28] i2c: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 11/28] net: Update to use " Simon Glass
2020-12-17  4:20 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-17  4:20 ` Simon Glass [this message]
2020-12-17  4:20 ` [PATCH v3 14/28] spi: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2020-12-17  4:20 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-17  4:20 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-17  4:20 ` [PATCH v3 19/28] gpio: Update for new sequence numbers Simon Glass
2020-12-17  4:20 ` [PATCH v3 20/28] pinctrl: " Simon Glass
2020-12-17  4:20 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-17  4:20 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-17  4:20 ` [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-17  4:20 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-17  4:20 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-17  4:20 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-18 11:09 ` [PATCH v3 00/28] dm: Change the way sequence numbers are implemented Michael Walle
2020-12-19 16:40 ` [PATCH v3 28/28] dm: Update documentation for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 27/28] dm: core: Drop seq and req_seq Simon Glass
2020-12-19 16:40 ` [PATCH v3 25/28] dm: core: Update uclass_find_next_free_req_seq() for new scheme Simon Glass
2020-12-19 16:40 ` [PATCH v3 26/28] cmd: Drop use of old sequence numbers in commands Simon Glass
2020-12-19 16:40 ` [PATCH v3 24/28] dm: Drop the unused arg in uclass_find_device_by_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 23/28] dm: Drop uclass_resolve_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 22/28] dm: test: Add a test for DM_UC_FLAG_NO_AUTO_SEQ Simon Glass
2020-12-19 16:40 ` [PATCH v3 21/28] dm: Switch over to use new sequence number for dev_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 20/28] pinctrl: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 19/28] gpio: " Simon Glass
2020-12-19 16:40 ` [PATCH v3 18/28] x86: Simplify acpi_device_infer_name() Simon Glass
2020-12-19 16:40 ` [PATCH v3 17/28] x86: Drop unnecessary mp_init logic Simon Glass
2020-12-19 16:40 ` [PATCH v3 16/28] usb: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 15/28] usb: ehci-mx6: Drop assignment of sequence number Simon Glass
2021-03-31 19:14   ` Marek Vasut
2021-03-31 19:27     ` Tom Rini
2021-03-31 22:20       ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 14/28] spi: Update for new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 13/28] pci: Update to use " Simon Glass
2021-04-13 18:32   ` Tim Harvey
2021-04-14 19:37     ` Simon Glass
2021-04-15  0:28       ` Tim Harvey
2021-04-15  0:44         ` Simon Glass
2020-12-19 16:40 ` [PATCH v3 12/28] dm: core: Allow manual sequence numbering Simon Glass
2020-12-19 16:40 ` [PATCH v3 11/28] net: Update to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 10/28] i2c: Update for " Simon Glass
2020-12-19 16:40 ` [PATCH v3 09/28] octeon: Don't attempt to set the sequence number Simon Glass
2020-12-19 16:40 ` [PATCH v3 08/28] dm: test: Drop assumptions of no sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 07/28] dm: Fix return value in dev_read_alias_seq() Simon Glass
2020-12-19 16:40 ` [PATCH v3 06/28] dm: core: Switch binding to use new sequence numbers Simon Glass
2020-12-19 16:40 ` [PATCH v3 05/28] dm: test: Check all devices have a " Simon Glass
2020-12-19 16:40 ` [PATCH v3 04/28] dm: core: Add a new sequence number for devices Simon Glass
2020-12-19 16:40 ` [PATCH v3 03/28] dm: core: Update uclass_find_next_free_req_seq() args Simon Glass
2020-12-19 16:40 ` [PATCH v3 02/28] dm: Avoid accessing seq directly Simon Glass
2020-12-19 16:40 ` [PATCH v3 01/28] linker_lists: Fix alignment issue Simon Glass

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20201216212001.v3.13.Ic2ef484e2ee4861057d1d4bb1bb9e5ffe51c7c76@changeid \
    --to=sjg@chromium.org \
    --cc=u-boot@lists.denx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.