diff options
author | Tom Rini <trini@konsulko.com> | 2022-07-08 14:39:07 -0400 |
---|---|---|
committer | Tom Rini <trini@konsulko.com> | 2022-07-08 14:39:07 -0400 |
commit | 9ff4ce8abc627b8696c9bd6fd726dd1dbf4b9a5c (patch) | |
tree | d28c5d99d4996b080ec0c38f24a0232d611ea847 /drivers/core/root.c | |
parent | 7bc0be96f79344d7b103dd64c31be0574f7b39e9 (diff) | |
parent | e87da5704ffa6fc782d93d137fa30a37a5df3566 (diff) |
Merge tag 'dm-pull-28jun22' of https://source.denx.de/u-boot/custodians/u-boot-dm into next
nman external-symbol improvements
Driver model memory-usage reporting
patman test-reporting improvements
Add bloblist design goals
Diffstat (limited to 'drivers/core/root.c')
-rw-r--r-- | drivers/core/root.c | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/drivers/core/root.c b/drivers/core/root.c index 17dd1205a3..f24ddfa521 100644 --- a/drivers/core/root.c +++ b/drivers/core/root.c @@ -449,6 +449,59 @@ void dm_get_stats(int *device_countp, int *uclass_countp) *uclass_countp = uclass_get_count(); } +void dev_collect_stats(struct dm_stats *stats, const struct udevice *parent) +{ + const struct udevice *dev; + int i; + + stats->dev_count++; + stats->dev_size += sizeof(struct udevice); + stats->dev_name_size += strlen(parent->name) + 1; + for (i = 0; i < DM_TAG_ATTACH_COUNT; i++) { + int size = dev_get_attach_size(parent, i); + + if (size || + (i == DM_TAG_DRIVER_DATA && parent->driver_data)) { + stats->attach_count[i]++; + stats->attach_size[i] += size; + stats->attach_count_total++; + stats->attach_size_total += size; + } + } + + list_for_each_entry(dev, &parent->child_head, sibling_node) + dev_collect_stats(stats, dev); +} + +void uclass_collect_stats(struct dm_stats *stats) +{ + struct uclass *uc; + + list_for_each_entry(uc, gd->uclass_root, sibling_node) { + int size; + + stats->uc_count++; + stats->uc_size += sizeof(struct uclass); + size = uc->uc_drv->priv_auto; + if (size) { + stats->uc_attach_count++; + stats->uc_attach_size += size; + } + } +} + +void dm_get_mem(struct dm_stats *stats) +{ + memset(stats, '\0', sizeof(*stats)); + dev_collect_stats(stats, gd->dm_root); + uclass_collect_stats(stats); + dev_tag_collect_stats(stats); + + stats->total_size = stats->dev_size + stats->uc_size + + stats->attach_size_total + stats->uc_attach_size + + stats->tag_size; +} + #ifdef CONFIG_ACPIGEN static int root_acpi_get_name(const struct udevice *dev, char *out_name) { |