devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Rob Herring <robh@kernel.org>
To: Thierry Reding <thierry.reding@gmail.com>
Cc: Jon Hunter <jonathanh@nvidia.com>,
	devicetree@vger.kernel.org, linux-tegra@vger.kernel.org
Subject: Re: [PATCH v2 13/16] dt-bindings: i2c: tegra-bpmp: Convert to json-schema
Date: Thu, 2 Dec 2021 16:38:05 -0600	[thread overview]
Message-ID: <CAL_JsqJqCEr6JsTb_ZnadaDg_zxsdYxMyyyZT3JT=4uLLShGUQ@mail.gmail.com> (raw)
In-Reply-To: <CAL_JsqKb-azHGWkNzEJfCffiJ7FzscV4--8sKgq+uEONFmRD0w@mail.gmail.com>

On Thu, Dec 2, 2021 at 3:08 PM Rob Herring <robh@kernel.org> wrote:
>
> On Thu, Dec 2, 2021 at 11:55 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> >
> > On Wed, Dec 01, 2021 at 12:42:07PM -0600, Rob Herring wrote:
> > > On Wed, Dec 1, 2021 at 11:42 AM Thierry Reding <thierry.reding@gmail.com> wrote:
> > > >

[...]

> > > > However, a side-effect seems to be that now it also ignores any
> > > > properties that aren't defined anywhere. So for example if I touch
> > > > up the example in firmware/nvidia,tegra186-bpmp.yaml and add a bogus
> > > > "foo-bar = <0>;" property in the BPMP I2C node, then it'll blindly
> > > > accept that as valid.
> > >
> > > Do you have unevaluatedProperties within the i2c node? It only applies
> > > to 1 level, and you can't have a parent+child schema evaluated with
> > > another child (or parent+child) schema. This is why the graph schema
> > > is done the way it is and why we're splitting spi-controller.yaml
> > > child node schema out to spi-peripheral.yaml.
> >
> > Let me give an example based on a schema that's already upstream. So
> > looking at this:
> >
> >         Documentation/devicetree/bindings/spi/nvidia,tegra210-quad.yaml
> >
> > it does include spi-controller.yaml via an allOf: [ $ref: ... ], so it
> > uses unevaluatedProperties to validate against any generic SPI
> > controller properties. For example, #address-cells and #size-cells are
> > validated based on the schema from spi-controller.yaml.
> >
> > However, if I now apply the following patch to add an undocumented
> > property to the example, then validation doesn't fail as I would expect
> > it to.
>
> Indeed you are right. The problem is 'additionalProperties: true' in
> spi-controller.yaml makes everything evaluated. I thought
> 'additionalProperties: true' was equivalent to the default, but that's
> not how it's working. Now to figure out if this is correct operation
> or not. No wonder there were relatively few fixes when
> 'unevaluatedProperties' got implemented...

Based on the json-schema test cases[1], it looks like the tool is
doing the right thing and our schemas are wrong.

It's a quick fixup in the tools though to just delete any
'additionalProperties: true':

index 3cc5e428b0eb..a0f22aab935a 100644
--- a/dtschema/lib.py
+++ b/dtschema/lib.py
@@ -367,6 +367,9 @@ def fixup_sub_schema(schema, is_prop):
     if not isinstance(schema, dict):
         return

+    if 'additionalProperties' in schema and
schema['additionalProperties'] == True:
+        schema.pop('additionalProperties', None)
+
     schema.pop('description', None)
     fixup_interrupts(schema)
     if is_prop:

I'm leaning towards this route besides being easy because the whole
reason for the explicit 'additionalProperties: true' was so that
missing 'additionalProperties' is flagged as an error. The only other
way I've come up with handling this is making common schema use a
different meta-schema.

The result with the above is about 150 warnings. I quickly got this
down to 100 with only a couple of fixes, but the rest appear to be
individual schemas...

Rob

[1] https://github.com/json-schema-org/JSON-Schema-Test-Suite/blob/master/tests/draft2019-09/unevaluatedProperties.json#L230

  reply	other threads:[~2021-12-02 22:38 UTC|newest]

Thread overview: 42+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-19 14:38 [PATCH v2 00/16] dt-bindings: Convert Tegra DT bindings to json-schema Thierry Reding
2021-11-19 14:38 ` [PATCH v2 01/16] dt-bindings: misc: Convert Tegra MISC " Thierry Reding
2021-11-30  1:29   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 02/16] dt-bindings: mmc: tegra: Convert " Thierry Reding
2021-11-30  1:31   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 03/16] dt-bindings: mailbox: " Thierry Reding
2021-11-30  1:32   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 04/16] dt-bindings: mailbox: tegra: Document Tegra234 HSP Thierry Reding
2021-11-30  1:32   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 05/16] dt-bindings: rtc: tegra: Convert to json-schema Thierry Reding
2021-11-30  1:33   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 06/16] dt-bindings: rtc: tegra: Document Tegra234 RTC Thierry Reding
2021-11-30  1:33   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 07/16] dt-bindings: fuse: tegra: Convert to json-schema Thierry Reding
2021-11-30  1:35   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 08/16] dt-bindings: fuse: tegra: Document Tegra234 FUSE Thierry Reding
2021-11-30  1:35   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 09/16] dt-bindings: mmc: tegra: Document Tegra234 SDHCI Thierry Reding
2021-11-30  1:35   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 10/16] dt-bindings: serial: 8250: Document Tegra234 UART Thierry Reding
2021-11-30  1:36   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 11/16] dt-bindings: tegra: pmc: Convert to json-schema Thierry Reding
2021-11-30  1:41   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 12/16] dt-bindings: firmware: tegra: " Thierry Reding
2021-11-30  1:43   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 13/16] dt-bindings: i2c: tegra-bpmp: " Thierry Reding
2021-11-23 16:34   ` Rob Herring
2021-11-30  1:44   ` Rob Herring
2021-12-01 17:42     ` Thierry Reding
2021-12-01 18:42       ` Rob Herring
2021-12-02 17:55         ` Thierry Reding
2021-12-02 21:08           ` Rob Herring
2021-12-02 22:38             ` Rob Herring [this message]
2021-11-19 14:38 ` [PATCH v2 14/16] dt-bindings: thermal: tegra186-bpmp: " Thierry Reding
2021-11-30  1:44   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 15/16] dt-bindings: serial: tegra-tcu: " Thierry Reding
2021-11-23 16:34   ` Rob Herring
2021-11-30  1:45   ` Rob Herring
2021-11-19 14:38 ` [PATCH v2 16/16] dt-bindings: serial: Document Tegra234 TCU Thierry Reding
2021-11-23 16:34   ` Rob Herring
2021-11-30  1:45   ` Rob Herring
2021-12-09 17:05 ` [PATCH v2 00/16] dt-bindings: Convert Tegra DT bindings to json-schema Thierry Reding

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CAL_JsqJqCEr6JsTb_ZnadaDg_zxsdYxMyyyZT3JT=4uLLShGUQ@mail.gmail.com' \
    --to=robh@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).