Re: [PATCH 0/2] Add support for phandle in symbols

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



On 9/2/24 7:17 AM, Ayush Singh wrote:
Add ability to resolve symbols pointing to phandles instead of strings.

Combining this with existing fixups infrastructure allows creating
symbols in overlays that refer to undefined phandles. This is planned to
be used for addon board chaining [1].

Patch 2 containing tests demonstrates how this looks in practice.

Open Items:

1. Phandle vs String identification:
    I am not sure how to distinguish between symbols that are paths and
    phandles. Currently I am checking the proplen and if the first byte
    is '/'. However, this can cause problems if the number of phandles in
    dt exceed 0x2f000000 or 788,529,152.


Ha, that is clever, never thought about the count ending up in the
ascii space :)

Does the blob format being big-endian affect this? Would mean the
slightly more realistic phandle count of 47 would run into this..

Probably not an issue, the below length check would save us.

    Alternatively, if we can be sure that there will be no node whose
    path is of length = 4, i.e. a node name of 2 characters ('\' and NULL
    already take up 2 characters), we can avoid the '/' check.


I also ran into the issue of the fdt not having type info. My solution
was the same as yours, quick and simple len==4 check.

We can disassemble fdt back into source, I thought about how that
works without type info, scanning the code it seems dtc also just
guesses the same way we do here (see guess_value_type()).

Might have been better if all properties in __symbols__ were simply
phandles from the start. Having full paths string for every symbol
adds most of the bloat when enabling symbols (adds ~10% to each fdt
file on average in kernel last time I ran an audit), phandle-only
would solve that.

Andrew

[1]: https://lore.kernel.org/linux-arm-kernel/20240702164403.29067-1-afd@xxxxxx/

Signed-off-by: Ayush Singh <ayush@xxxxxxxxxxxxxxx>

---
Ayush Singh (2):
       libfdt: overlay: Allow resolving phandle symbols
       tests: Add test for symbol resolution

  libfdt/fdt_overlay.c                   | 16 ++++++++++------
  tests/overlay_overlay_symbols1.dts     | 12 ++++++++++++
  tests/overlay_overlay_symbols2.dts     |  9 +++++++++
  tests/overlay_overlay_symbols_user.dts | 26 ++++++++++++++++++++++++++
  tests/run_tests.sh                     | 19 +++++++++++++++++++
  5 files changed, 76 insertions(+), 6 deletions(-)
---
base-commit: 99031e3a4a6e479466ae795790b44727434ca27d
change-id: 20240829-symbol-phandle-9d1e0489c32a

Best regards,




[Index of Archives]     [Device Tree]     [Device Tree Spec]     [Linux Driver Backports]     [Video for Linux]     [Linux USB Devel]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Yosemite Backpacking]

  Powered by Linux