From nobody Tue Jun 23 14:06:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EE2CCC433F5 for ; Thu, 3 Mar 2022 22:43:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237059AbiCCWoU (ORCPT ); Thu, 3 Mar 2022 17:44:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57752 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236956AbiCCWoS (ORCPT ); Thu, 3 Mar 2022 17:44:18 -0500 Received: from mail-ot1-f54.google.com (mail-ot1-f54.google.com [209.85.210.54]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A76D555200; Thu, 3 Mar 2022 14:43:31 -0800 (PST) Received: by mail-ot1-f54.google.com with SMTP id u17-20020a056830231100b005ad13358af9so5872624ote.11; Thu, 03 Mar 2022 14:43:31 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=4DiSaVj/l0jro1TNXi9BXnk16wdcQX2uMpMANh6u6M0=; b=vxJCgz/U17Bz3m8uIso8+rvyR4QZ95Z5lK2FEjpKNE66NTnnbTZtLFPIWv66RDK/jn WymPM4+q+WJBOoF9w33wsWQI3zsk9WX/pIiFebSqR1kLx8LJYtoLLJa4sRINAp9uwiST jQ23tlXV7tWOsbm0oBkTKZfZVzl2K+ubK5CKZ6w0DKk6L4Ggii92NJjlvz320nENQlmy X50gmyYDEvGcrsE0lrujUHhu3Tds+ypu3sH5t0/hOtwTF23Yz/ww4DAvUaD8NaNR2yWE sfRKnhJ9bxSsOeWqki76G8i2+sN5cbpNy4k7mWtKx9Qc5zfgNErnYtXbX1mACJIpUZKx ILpA== X-Gm-Message-State: AOAM530222HZpL2a9+w8ZZyL0EYvcu0KvxG6GX4vDN0c2cgHCq5sCuQI 6aPD/4UY6hMWcnIIBhLRHHJV/RdO6Q== X-Google-Smtp-Source: ABdhPJxpftXABxUIMiQYUkxEDIhTL6OgtlC0i6/ctwm+SyKuYt9QqOo6odNRQiGv1YYVcZVqxm6kXA== X-Received: by 2002:a9d:7987:0:b0:5af:ac0:379d with SMTP id h7-20020a9d7987000000b005af0ac0379dmr20843526otm.97.1646347410951; Thu, 03 Mar 2022 14:43:30 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id x10-20020a4a2a4a000000b0031bf0818df1sm1608480oox.4.2022.03.03.14.43.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 14:43:30 -0800 (PST) From: Rob Herring To: Masahiro Yamada , Krzysztof Kozlowski , Michal Marek , Nick Desaulniers Cc: Geert Uytterhoeven , Laurent Pinchart , Maxime Ripard , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH 1/2] dt-bindings: kbuild: Pass DT_SCHEMA_FILES to dt-validate Date: Thu, 3 Mar 2022 16:42:36 -0600 Message-Id: <20220303224237.2497570-2-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220303224237.2497570-1-robh@kernel.org> References: <20220303224237.2497570-1-robh@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" In preparation for supporting validation of DTB files, the full processed schema will always be needed in order to extract type information from it. Therefore, the processed schema containing only what DT_SCHEMA_FILES specifies won't work. Instead, dt-validate has gained an option, -l or --limit, to specify which schema(s) to use for validation. As the command line option is new, we the minimum dtschema version must be updated. Cc: Masahiro Yamada Signed-off-by: Rob Herring --- Documentation/devicetree/bindings/Makefile | 28 +++------------------- scripts/Makefile.lib | 3 +-- 2 files changed, 4 insertions(+), 27 deletions(-) diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/dev= icetree/bindings/Makefile index 61ec18ecc931..246ba0ecab64 100644 --- a/Documentation/devicetree/bindings/Makefile +++ b/Documentation/devicetree/bindings/Makefile @@ -6,7 +6,7 @@ DT_MK_SCHEMA ?=3D dt-mk-schema DT_SCHEMA_LINT :=3D $(shell which yamllint || \ echo "warning: yamllint not installed, skipping. To install, run 'pip in= stall yamllint'" >&2) =20 -DT_SCHEMA_MIN_VERSION =3D 2021.2.1 +DT_SCHEMA_MIN_VERSION =3D 2022.3 =20 PHONY +=3D check_dtschema_version check_dtschema_version: @@ -25,9 +25,6 @@ quiet_cmd_extract_ex =3D DTEX $@ $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_version FORCE $(call if_changed,extract_ex) =20 -# Use full schemas when checking %.example.dts -DT_TMP_SCHEMA :=3D $(obj)/processed-schema-examples.json - find_all_cmd =3D find $(srctree)/$(src) \( -name '*.yaml' ! \ -name 'processed-schema*' ! \ -name '*.example.dt.yaml' \) @@ -70,29 +67,10 @@ override DTC_FLAGS :=3D \ # Disable undocumented compatible checks until warning free override DT_CHECKER_FLAGS ?=3D =20 -$(obj)/processed-schema-examples.json: $(DT_DOCS) $(src)/.yamllint check_d= tschema_version FORCE +$(obj)/processed-schema.json: $(DT_DOCS) $(src)/.yamllint check_dtschema_v= ersion FORCE $(call if_changed_rule,chkdt) =20 -ifeq ($(DT_SCHEMA_FILES),) - -# Unless DT_SCHEMA_FILES is specified, use the full schema for dtbs_check = too. -# Just copy processed-schema-examples.json - -$(obj)/processed-schema.json: $(obj)/processed-schema-examples.json FORCE - $(call if_changed,copy) - -else - -# If DT_SCHEMA_FILES is specified, use it for processed-schema.json - -$(obj)/processed-schema.json: DT_MK_SCHEMA_FLAGS :=3D -u -$(obj)/processed-schema.json: $(CHK_DT_DOCS) check_dtschema_version FORCE - $(call if_changed,mk_schema) - -endif - -always-$(CHECK_DT_BINDING) +=3D processed-schema-examples.json -always-$(CHECK_DTBS) +=3D processed-schema.json +always-y +=3D processed-schema.json always-$(CHECK_DT_BINDING) +=3D $(patsubst $(srctree)/$(src)/%.yaml,%.exam= ple.dts, $(CHK_DT_DOCS)) always-$(CHECK_DT_BINDING) +=3D $(patsubst $(srctree)/$(src)/%.yaml,%.exam= ple.dt.yaml, $(CHK_DT_DOCS)) =20 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 79be57fdd32a..9f1e8442564e 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -361,9 +361,8 @@ $(multi-dtb-y): FORCE $(call multi_depend, $(multi-dtb-y), .dtb, -dtbs) =20 DT_CHECKER ?=3D dt-validate -DT_CHECKER_FLAGS ?=3D $(if $(DT_SCHEMA_FILES),,-m) +DT_CHECKER_FLAGS ?=3D $(if $(DT_SCHEMA_FILES),-l $(DT_SCHEMA_FILES),-m) DT_BINDING_DIR :=3D Documentation/devicetree/bindings -# DT_TMP_SCHEMA may be overridden from Documentation/devicetree/bindings/M= akefile DT_TMP_SCHEMA ?=3D $(objtree)/$(DT_BINDING_DIR)/processed-schema.json =20 quiet_cmd_dtb_check =3D CHECK $@ --=20 2.32.0 From nobody Tue Jun 23 14:06:00 2026 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8FCA4C433FE for ; Thu, 3 Mar 2022 22:43:49 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237071AbiCCWoe (ORCPT ); Thu, 3 Mar 2022 17:44:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58680 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232763AbiCCWoc (ORCPT ); Thu, 3 Mar 2022 17:44:32 -0500 Received: from mail-oi1-f181.google.com (mail-oi1-f181.google.com [209.85.167.181]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 284E855200; Thu, 3 Mar 2022 14:43:46 -0800 (PST) Received: by mail-oi1-f181.google.com with SMTP id j2so6220602oie.7; Thu, 03 Mar 2022 14:43:46 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=uIHCa+KnIPtYqD5TBPEYYO/aR7DF5N4jQFH/0XzJtyw=; b=5ETj/QB30HWXwVoaeIb7MnOpa/jajECVKaUVq7WA+/LIsP5fKuV07sV9dYzYy1tcw/ r0U4V9hkfM3DvQJbRXtzAWKCAH+IkxjkmUMR1fCfIcwsNyXA7tIWlQq6o0OkhhwKHlBT Ke7NrmB0ZmpcPC+seprFAAAHRhRtduBejXPgR1FKG6ekQOkgatUdhNi6rQK9mSZgFEBt RexfhjTV09Pb02NqZdEICSlYJh3e1L6r1MOVQLAselAitJrRJKiz4LTUGXWUenaj+F0h KpdgOgIOcVRAlRvKkACQ/eRWDx7g8gjEnKB2PXcoX3J+pMnewV0HF2d7KHABrC++xzrw lovQ== X-Gm-Message-State: AOAM531RIDkvKD55ER8F2fO6Kq27DlG3oUzw+sdC64aL8EsXWaXmQqrI N//r1y0n1EDFKCnWkLqBwg== X-Google-Smtp-Source: ABdhPJzh1T2VePI6949NYqkhNMnV7xpV4aGqLc1QB3TTOTncSMcDTPqTJxOlGz0OTTnwdn3LnsaQ9w== X-Received: by 2002:a05:6808:1b27:b0:2d5:38fc:26f with SMTP id bx39-20020a0568081b2700b002d538fc026fmr6542030oib.42.1646347425366; Thu, 03 Mar 2022 14:43:45 -0800 (PST) Received: from xps15.herring.priv (66-90-148-213.dyn.grandenetworks.net. [66.90.148.213]) by smtp.googlemail.com with ESMTPSA id x10-20020a4a2a4a000000b0031bf0818df1sm1608480oox.4.2022.03.03.14.43.44 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 03 Mar 2022 14:43:44 -0800 (PST) From: Rob Herring To: Masahiro Yamada , Krzysztof Kozlowski , Michal Marek , Nick Desaulniers , Frank Rowand Cc: Geert Uytterhoeven , Laurent Pinchart , Maxime Ripard , linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, linux-kbuild@vger.kernel.org Subject: [PATCH 2/2] dt-bindings: kbuild: Use DTB files for validation Date: Thu, 3 Mar 2022 16:42:37 -0600 Message-Id: <20220303224237.2497570-3-robh@kernel.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20220303224237.2497570-1-robh@kernel.org> References: <20220303224237.2497570-1-robh@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" Switch the DT validation to use DTB files directly instead of a DTS to YAML conversion. The original motivation for supporting validation on DTB files was to enable running validation on a running system (e.g. 'dt-validate /sys/firmware/fdt') or other cases where the original source DTS is not available. The YAML format was not without issues. Using DTBs with the schema type information solves some of those problems. The YAML format relies on the DTS source level information including bracketing of properties, size directives, and phandle tags all of which are lost in a DTB file. While standardizing the bracketing is a good thing, it does cause a lot of extra warnings and churn to fix them. Another issue has been signed types are not validated correctly as sign information is not propagated to YAML. Using the schema type information allows for proper handling of signed types. YAML also can't represent the full range of 64-bit integers as numbers are stored as floats by most/all parsers. The DTB validation works by decoding property values using the type information in the schemas themselves. The main corner case this does not work for is matrix types where neither dimension is fixed. For now, checking the dimensions in these cases are skipped. Signed-off-by: Rob Herring Tested-by: Geert Uytterhoeven --- Documentation/devicetree/bindings/Makefile | 7 +++---- .../devicetree/bindings/writing-schema.rst | 12 ----------- scripts/Makefile.lib | 20 +++++++------------ scripts/dtc/Makefile | 13 ------------ scripts/dtc/update-dtc-source.sh | 2 +- 5 files changed, 11 insertions(+), 43 deletions(-) diff --git a/Documentation/devicetree/bindings/Makefile b/Documentation/dev= icetree/bindings/Makefile index 246ba0ecab64..b8bd6a8ec43a 100644 --- a/Documentation/devicetree/bindings/Makefile +++ b/Documentation/devicetree/bindings/Makefile @@ -26,8 +26,7 @@ $(obj)/%.example.dts: $(src)/%.yaml check_dtschema_versio= n FORCE $(call if_changed,extract_ex) =20 find_all_cmd =3D find $(srctree)/$(src) \( -name '*.yaml' ! \ - -name 'processed-schema*' ! \ - -name '*.example.dt.yaml' \) + -name 'processed-schema*' \) =20 find_cmd =3D $(find_all_cmd) | grep -F "$(DT_SCHEMA_FILES)" CHK_DT_DOCS :=3D $(shell $(find_cmd)) @@ -72,9 +71,9 @@ $(obj)/processed-schema.json: $(DT_DOCS) $(src)/.yamllint= check_dtschema_version =20 always-y +=3D processed-schema.json always-$(CHECK_DT_BINDING) +=3D $(patsubst $(srctree)/$(src)/%.yaml,%.exam= ple.dts, $(CHK_DT_DOCS)) -always-$(CHECK_DT_BINDING) +=3D $(patsubst $(srctree)/$(src)/%.yaml,%.exam= ple.dt.yaml, $(CHK_DT_DOCS)) +always-$(CHECK_DT_BINDING) +=3D $(patsubst $(srctree)/$(src)/%.yaml,%.exam= ple.dtb, $(CHK_DT_DOCS)) =20 # Hack: avoid 'Argument list too long' error for 'make clean'. Remove most= of # build artifacts here before they are processed by scripts/Makefile.clean clean-files =3D $(shell find $(obj) \( -name '*.example.dts' -o \ - -name '*.example.dt.yaml' \) -delete 2>/dev/null) + -name '*.example.dtb' \) -delete 2>/dev/null) diff --git a/Documentation/devicetree/bindings/writing-schema.rst b/Documen= tation/devicetree/bindings/writing-schema.rst index 3b00fe981494..b4258bf81be5 100644 --- a/Documentation/devicetree/bindings/writing-schema.rst +++ b/Documentation/devicetree/bindings/writing-schema.rst @@ -123,18 +123,6 @@ project can be installed with pip:: Several executables (dt-doc-validate, dt-mk-schema, dt-validate) will be installed. Ensure they are in your PATH (~/.local/bin by default). =20 -dtc must also be built with YAML output support enabled. This requires that -libyaml and its headers be installed on the host system. For some distribu= tions -that involves installing the development package, such as: - -Debian:: - - apt-get install libyaml-dev - -Fedora:: - - dnf -y install libyaml-devel - Running checks ~~~~~~~~~~~~~~ =20 diff --git a/scripts/Makefile.lib b/scripts/Makefile.lib index 9f1e8442564e..4629af60160b 100644 --- a/scripts/Makefile.lib +++ b/scripts/Makefile.lib @@ -87,11 +87,6 @@ base-dtb-y :=3D $(foreach m, $(multi-dtb-y), $(firstword= $(call suffix-search, $m, =20 always-y +=3D $(dtb-y) =20 -ifneq ($(CHECK_DTBS),) -always-y +=3D $(patsubst %.dtb,%.dt.yaml, $(real-dtb-y)) -always-y +=3D $(patsubst %.dtbo,%.dt.yaml, $(real-dtb-y)) -endif - # Add subdir path =20 extra-y :=3D $(addprefix $(obj)/,$(extra-y)) @@ -347,12 +342,6 @@ cmd_dtc =3D $(HOSTCC) -E $(dtc_cpp_flags) -x assembler= -with-cpp -o $(dtc-tmp) $< ; -d $(depfile).dtc.tmp $(dtc-tmp) ; \ cat $(depfile).pre.tmp $(depfile).dtc.tmp > $(depfile) =20 -$(obj)/%.dtb: $(src)/%.dts $(DTC) FORCE - $(call if_changed_dep,dtc) - -$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE - $(call if_changed_dep,dtc) - quiet_cmd_fdtoverlay =3D DTOVL $@ cmd_fdtoverlay =3D $(objtree)/scripts/dtc/fdtoverlay -o $@ -i $(real= -prereqs) =20 @@ -365,17 +354,22 @@ DT_CHECKER_FLAGS ?=3D $(if $(DT_SCHEMA_FILES),-l $(DT= _SCHEMA_FILES),-m) DT_BINDING_DIR :=3D Documentation/devicetree/bindings DT_TMP_SCHEMA ?=3D $(objtree)/$(DT_BINDING_DIR)/processed-schema.json =20 +ifneq ($(CHECK_DTBS)$(CHECK_DT_BINDING),) quiet_cmd_dtb_check =3D CHECK $@ - cmd_dtb_check =3D $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(= DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ + cmd_dtb_check =3D $(DT_CHECKER) $(DT_CHECKER_FLAGS) -u $(srctree)/$(= DT_BINDING_DIR) -p $(DT_TMP_SCHEMA) $@ || true +endif =20 define rule_dtc $(call cmd_and_fixdep,dtc) $(call cmd,dtb_check) endef =20 -$(obj)/%.dt.yaml: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE +$(obj)/%.dtb: $(src)/%.dts $(DTC) $(DT_TMP_SCHEMA) FORCE $(call if_changed_rule,dtc) =20 +$(obj)/%.dtbo: $(src)/%.dts $(DTC) FORCE + $(call if_changed_dep,dtc) + dtc-tmp =3D $(subst $(comma),_,$(dot-target).dts.tmp) =20 # Bzip2 diff --git a/scripts/dtc/Makefile b/scripts/dtc/Makefile index 1cba78e1dce6..4d32b9497da9 100644 --- a/scripts/dtc/Makefile +++ b/scripts/dtc/Makefile @@ -17,20 +17,7 @@ fdtoverlay-objs :=3D $(libfdt) fdtoverlay.o util.o =20 # Source files need to get at the userspace version of libfdt_env.h to com= pile HOST_EXTRACFLAGS +=3D -I $(srctree)/$(src)/libfdt - -ifeq ($(shell pkg-config --exists yaml-0.1 2>/dev/null && echo yes),) -ifneq ($(CHECK_DT_BINDING)$(CHECK_DTBS),) -$(error dtc needs libyaml for DT schema validation support. \ - Install the necessary libyaml development package.) -endif HOST_EXTRACFLAGS +=3D -DNO_YAML -else -dtc-objs +=3D yamltree.o -# To include installed in a non-default path -HOSTCFLAGS_yamltree.o :=3D $(shell pkg-config --cflags yaml-0.1) -# To link libyaml installed in a non-default path -HOSTLDLIBS_dtc :=3D $(shell pkg-config --libs yaml-0.1) -endif =20 # Generated files need one more search path to include headers in source t= ree HOSTCFLAGS_dtc-lexer.lex.o :=3D -I $(srctree)/$(src) diff --git a/scripts/dtc/update-dtc-source.sh b/scripts/dtc/update-dtc-sour= ce.sh index 32ff17ffd089..94627541533e 100755 --- a/scripts/dtc/update-dtc-source.sh +++ b/scripts/dtc/update-dtc-source.sh @@ -32,7 +32,7 @@ DTC_UPSTREAM_PATH=3D`pwd`/../dtc DTC_LINUX_PATH=3D`pwd`/scripts/dtc =20 DTC_SOURCE=3D"checks.c data.c dtc.c dtc.h flattree.c fstree.c livetree.c s= rcpos.c \ - srcpos.h treesource.c util.c util.h version_gen.h yamltree.c \ + srcpos.h treesource.c util.c util.h version_gen.h \ dtc-lexer.l dtc-parser.y" LIBFDT_SOURCE=3D"fdt.c fdt.h fdt_addresses.c fdt_empty_tree.c \ fdt_overlay.c fdt_ro.c fdt_rw.c fdt_strerror.c fdt_sw.c \ --=20 2.32.0