edtlib: indirect "include:"s break property filters #79948
Labels
area: Devicetree Tooling
PR modifies or adds a Device Tree tooling
area: Devicetree
bug
The issue is a bug, or the PR is fixing a bug
priority: low
Low impact/importance bug
Regression
Something, which was working, does not anymore
Filters set by an including binding to select the properties it chooses to inherit are not applied as expected when specifications are inherited indirectly (as in A includes B includes C):
Passing the simplest (former) test case is easy, but misleading, as fixing the general (later) case might be more involved.[Edit: Reverting #65221 seems to fix all use cases described in this issue.]Basics
The simplest test case is:
simple.yaml
: a base binding file, specifies some properties at the binding, child-binding and grandchild-binding levelssimple_inherit.yaml
: justinclude:s
the base binding file above (without modification nor filter)simple_filter.yaml
: top-level binding of the test case, which intends to simply filter the properties it inherits like bellowHere we'd expect to finally get only
child-prop-1
at the child-binding level andgrandchild-prop-1
at the grandchild-binding level: we instead inherit all properties specified insimple.yaml
at these levels.Although this test case could also be addressed on top of #65221, I'm going to fix it by doing a revert (I'll put the rationale for this in the PR). [Edit: see #80030]
Generalization
But there might be a more general issue
(independently of #65221).In my understanding, when
B
includesI
includesX
, the filters set byB
to select the properties it chooses to inherit should be deferred until they can be applied to the appropriate input:I
includesX
, with or without filtersB
includesI
, applying its own filters on top of the propertiesI
inherited fromX
Examples that seem natural:
B
only allows properties which are not in theallowlist
of the intermediary binding file (hereI
), we should end with no property at allB
blocks all properties which are in theallowlist
of the intermediary binding file, we should end with no property at allMore generally, still IIUC, child-binding filters should compose, not be merged:
B
allows[x1, x3]
andI
allows[x1, x2]
,B
should inherit onlyx1
, not[x1, x2, x3]
I
allows[x1, x2]
andB
blocksx2
, B should inheritx1
, not cause an error by merging theallowlist
andblocklist
fromB
andI
("should not specify both 'property-allowlist:' and 'property-blocklist:'")B
allows[x1, x2]
andY
blocksx2
,B
should inheritx1
, not cause an error by merging theallowlist
andblocklist
fromB
andI
B
blocksx2
andI
blocksx3
,B
should inheritx1
, not[x1, x3]
This is what I would intuitively expect, assuming it's permitted to set filters in an including binding and in an intermediary included file.
AFAICT, the Zephyr documentation doesn't specifically address the rules that apply to this scenario, but it seems that only filtering simultaneously with an
allowlist
and ablocklist
is explicitly prohibited (Devicetree bindings syntax, Include):If this reasoning is correct, implementing it properly seems not obvious to me, it's just not how bindings are initialized: without some design changes we can't compose the filters as we include bindings on top of each other, likeB=f1(f2(f3(X)))
, they're instead merged before use, like inB=(f1xf2xf3)(X)
.[Edit: all expectations above are actually honored when #65221 is reverted]
I will also open a PR for this general case, with the corresponding unit tests (doomed to fail), but for now without a fix: I don't see how we could get toB=f1(f2(f3(X)))
without rethinking the wholeBinding
initialization.[Edit: these unit tests, which are no longer supposed to fail, will be added to #79900 instead.]
Thanks.
The text was updated successfully, but these errors were encountered: