[PATCH v2 04/26] dm: core: Add a new sequence number for devices
Simon Glass
sjg at chromium.org
Fri Dec 11 02:31:29 CET 2020
At present each device has two sequence numbers, with 'req_seq' being
set up at bind time and 'seq' at probe time. The idea is that devices
can 'request' a sequence number and then the conflicts are resolved when
the device is probed.
This makes things complicated in a few cases, since we don't really know
what the sequence number will end up being. We want to honour the
bind-time requests if at all possible, but in fact the only source of
these at present is the devicetree aliases. Since we have the devicetree
available at bind time, we may as well just use it, in the hope that the
required processing will turn out to be useful later (i.e. the device
actually gets used).
Add a new 'sqq' member, the bind-time sequence number. It operates in
parallel to the old values for now. All devices get a valid sqq value,
i.e. it is never -1.
Drop an #ifdef while we are here.
Signed-off-by: Simon Glass <sjg at chromium.org>
---
Changes in v2:
- Give all devices a sequence number
- Drop uclass_alloc_all_seqs() and GD_FLG_DM_NO_SEQ flag
drivers/core/device.c | 22 ++++++++++++++++------
drivers/core/root.c | 8 +++++---
include/dm/device.h | 8 ++++++++
3 files changed, 29 insertions(+), 9 deletions(-)
diff --git a/drivers/core/device.c b/drivers/core/device.c
index 5febdb67503..a417bbc0964 100644
--- a/drivers/core/device.c
+++ b/drivers/core/device.c
@@ -41,6 +41,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
struct udevice *dev;
struct uclass *uc;
int size, ret = 0;
+ bool auto_seq = true;
if (devp)
*devp = NULL;
@@ -73,6 +74,7 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
dev->seq = -1;
dev->req_seq = -1;
+ dev->sqq = -1;
if (CONFIG_IS_ENABLED(DM_SEQ_ALIAS) &&
(uc->uc_drv->flags & DM_UC_FLAG_SEQ_ALIAS)) {
/*
@@ -84,17 +86,25 @@ static int device_bind_common(struct udevice *parent, const struct driver *drv,
*/
if (CONFIG_IS_ENABLED(OF_CONTROL) &&
!CONFIG_IS_ENABLED(OF_PLATDATA)) {
- if (uc->uc_drv->name && ofnode_valid(node))
+ if (uc->uc_drv->name && ofnode_valid(node)) {
+ dev_read_alias_seq(dev, &dev->sqq);
dev_read_alias_seq(dev, &dev->req_seq);
-#if CONFIG_IS_ENABLED(OF_PRIOR_STAGE)
- if (dev->req_seq == -1)
- dev->req_seq =
- uclass_find_next_free_req_seq(uc);
-#endif
+ auto_seq = false;
+ }
+ if (CONFIG_IS_ENABLED(OF_PRIOR_STAGE)) {
+ if (dev->req_seq == -1) {
+ auto_seq = true;
+ dev->req_seq =
+ uclass_find_next_free_req_seq(
+ uc);
+ }
+ }
} else {
dev->req_seq = uclass_find_next_free_req_seq(uc);
}
}
+ if (auto_seq)
+ dev->sqq = uclass_find_next_free_req_seq(uc);
if (drv->platdata_auto_alloc_size) {
bool alloc = !platdata;
diff --git a/drivers/core/root.c b/drivers/core/root.c
index 6f8168bb92d..8426b8e96b4 100644
--- a/drivers/core/root.c
+++ b/drivers/core/root.c
@@ -311,22 +311,24 @@ int dm_init_and_scan(bool pre_reloc_only)
ret = dm_scan_platdata(pre_reloc_only);
if (ret) {
debug("dm_scan_platdata() failed: %d\n", ret);
- return ret;
+ goto fail;
}
if (CONFIG_IS_ENABLED(OF_CONTROL) && !CONFIG_IS_ENABLED(OF_PLATDATA)) {
ret = dm_extended_scan(pre_reloc_only);
if (ret) {
debug("dm_extended_scan() failed: %d\n", ret);
- return ret;
+ goto fail;
}
}
ret = dm_scan_other(pre_reloc_only);
if (ret)
- return ret;
+ goto fail;
return 0;
+fail:
+ return ret;
}
#ifdef CONFIG_ACPIGEN
diff --git a/include/dm/device.h b/include/dm/device.h
index 9a171e523f3..80cd0955362 100644
--- a/include/dm/device.h
+++ b/include/dm/device.h
@@ -131,6 +131,13 @@ enum {
* @child_head: List of children of this device
* @sibling_node: Next device in list of all devices
* @flags: Flags for this device DM_FLAG_...
+ * @sqq: Allocated sequence number for this device (-1 = none). This is set up
+ * when the device is bound and is unique within the device's uclass. If the
+ * device has an alias in the devicetree then that is used to set the sequence
+ * number. Otherwise, the next available number is used. Sequence numbers are
+ * used by certain commands that need device to be numbered (e.g. 'mmc dev')
+ *
+ * The following two fields are deprecated:
* @req_seq: Requested sequence number for this device (-1 = any)
* @seq: Allocated sequence number for this device (-1 = none). This is set up
* when the device is probed and will be unique within the device's uclass.
@@ -156,6 +163,7 @@ struct udevice {
struct list_head child_head;
struct list_head sibling_node;
uint32_t flags;
+ int sqq;
int req_seq;
int seq;
#ifdef CONFIG_DEVRES
--
2.29.2.576.ga3fc446d84-goog
More information about the U-Boot
mailing list