[PATCH v2 0/3] Update aliases when added or removed

Ayush Singh posted 3 patches 2 weeks ago
drivers/of/base.c | 132 +++++++++++++++++++++++++++++++++++++++---------------
1 file changed, 95 insertions(+), 37 deletions(-)
[PATCH v2 0/3] Update aliases when added or removed
Posted by Ayush Singh 2 weeks ago
Currently the list of aliases is not updated when a DT overlay that adds
an alias is loaded or unloaded. This break drivers (e.g. serial) that
rely on of_alias_get_id().

This picks up the original patch series from Geert Uytterhoeven.

I have not added unittests in this version since I am not sure if kunit
tests should be added, or if the runtime unittests (CONFIG_OF_UNITTEST)
need to be added. Additionally, it would be great if someone can inform
me how to run the runtime unittests since the unittests seem to fail in
my current setup (tried running on qemu x86_64 and beagleplay).

Changes in v2:
- Use `of_reconfig_notifier_register`
- Leak memory when freeing alias entry
- Link to v1: https://lore.kernel.org/all/1435675876-2159-1-git-send-email-geert+renesas@glider.be/

---
Ayush Singh (3):
      of: Extract of_alias_create()
      of: Add of_alias_destroy()
      of: Add notifier in of_reconfig_notifier_register()

 drivers/of/base.c | 132 +++++++++++++++++++++++++++++++++++++++---------------
 1 file changed, 95 insertions(+), 37 deletions(-)
---
base-commit: 929beafbe7acce3267c06115e13e03ff6e50548a
change-id: 20241016-of-alias-bc4f333dc773

Best regards,
-- 
Ayush Singh <ayush@beagleboard.org>
Re: [PATCH v2 0/3] Update aliases when added or removed
Posted by Rob Herring 1 week, 4 days ago
On Sat, Nov 9, 2024 at 1:52 PM Ayush Singh <ayush@beagleboard.org> wrote:
>
> Currently the list of aliases is not updated when a DT overlay that adds
> an alias is loaded or unloaded. This break drivers (e.g. serial) that
> rely on of_alias_get_id().

Drivers use the non-existent alias numbers for instances without an
alias. So what happens if an index is already in use and then an
overlay uses the same index.

I don't see how this can work reliably unless the alias name doesn't
exist in the base DT.

> This picks up the original patch series from Geert Uytterhoeven.
>
> I have not added unittests in this version since I am not sure if kunit
> tests should be added, or if the runtime unittests (CONFIG_OF_UNITTEST)
> need to be added. Additionally, it would be great if someone can inform
> me how to run the runtime unittests since the unittests seem to fail in
> my current setup (tried running on qemu x86_64 and beagleplay).

You enable the config and boot.

Rob