Skip to contentSkip to conversation

Makefile: Fix include directory for OF_UPSTREAM

PATCH Superseded Patrick Barsanti 3 participants 7 messages May 28, 2024 – May 31, 2024 Kbuild

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Makefile: Fix include directory for OF_UPSTREAM

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have not been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +14 -0
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+	-I$(srctree)/dts/upstream/include \
+	-Iinclude \
+	$(if $(KBUILD_SRC), -I$(srctree)/include) \
+	$(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+		$(if $(CONFIG_HAS_THUMB2), \
+			$(if $(CONFIG_CPU_V7M), \
+				-I$(srctree)/arch/arm/thumb1/include), \
+			-I$(srctree)/arch/arm/thumb1/include)) \
+	-I$(srctree)/arch/$(ARCH)/include \
+	-include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
 	-Iinclude \
 	$(if $(KBUILD_SRC), -I$(srctree)/include) \
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
 	-I$(srctree)/arch/$(ARCH)/include \
 	-include $(srctree)/include/linux/kconfig.h \
 	-I$(srctree)/dts/upstream/include
+endif
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
Signature · 1 line
2.43.0
#1 lore raw

Hi Patrick,

Quoted 10 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Quoted 50 lines

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have not been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +14 -1
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+       -I$(srctree)/dts/upstream/include \
+       -Iinclude \
+       $(if $(KBUILD_SRC), -I$(srctree)/include) \
+       $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+               $(if $(CONFIG_HAS_THUMB2), \
+                       $(if $(CONFIG_CPU_V7M), \
+                               -I$(srctree)/arch/arm/thumb1/include), \
+                       -I$(srctree)/arch/arm/thumb1/include)) \
+       -I$(srctree)/arch/$(ARCH)/include \
+       -include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
        -Iinclude \
        $(if $(KBUILD_SRC), -I$(srctree)/include) \
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
        -I$(srctree)/arch/$(ARCH)/include \
        -include $(srctree)/include/linux/kconfig.h \
        -I$(srctree)/dts/upstream/include
+endif
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
--

2.43.0

#2 lore raw

Hi Sumit,

Quoted 15 lines · Sumit Garg

Hi Patrick,

Quoted 10 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

Quoted 6 lines

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Sorry, I think I have worded my commit message wrong. I should have used differ instead of diverge, which is slightly misleading.

The specific case I am talking about can be found in:
include/dt-bindings/clock/imx6ul-clock.h dts/upstream/include/dt-bindings/clock/imx6ul-clock.h

The local header is missing the last commit from the kernel, which is 4e197ee880c2 ("clk: imx6ul: add ethernet refclock mux support"). This added some new defines, which are not present in the u-boot header.
Following this commit, the imx6ul.dtsi was patched in the kernel to use one of the new defines.

Because of this, at the current state, migrating a board which is somehow based on imx6ul.dtsi will give a dtc error given by a value being used in the upstream dtsi which is not defined in the local header, because local includes always have priority with respect to upstream ones even when setting OF_UPSTREAM.

Regards,
Patrick

Quoted 52 lines
Quoted 40 lines

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have not been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +13 -0
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+       -I$(srctree)/dts/upstream/include \
+       -Iinclude \
+       $(if $(KBUILD_SRC), -I$(srctree)/include) \
+       $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+               $(if $(CONFIG_HAS_THUMB2), \
+                       $(if $(CONFIG_CPU_V7M), \
+                               -I$(srctree)/arch/arm/thumb1/include), \
+                       -I$(srctree)/arch/arm/thumb1/include)) \
+       -I$(srctree)/arch/$(ARCH)/include \
+       -include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
        -Iinclude \
        $(if $(KBUILD_SRC), -I$(srctree)/include) \

Makefile UBOOTINCLUDE := \ · line 855

Quoted 6 lines
Makefile +1 -0
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
        -I$(srctree)/arch/$(ARCH)/include \
        -include $(srctree)/include/linux/kconfig.h \
        -I$(srctree)/dts/upstream/include
+endif
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC)

-print-file-name=include)

Quoted 4 lines
Makefile +0 -1
--

2.43.0

#3 lore raw
Quoted 41 lines · Patrick Barsanti

Hi Sumit,

Quoted 16 lines · Sumit Garg

Hi Patrick,

Quoted 10 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

Quoted 5 lines

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Sorry, I think I have worded my commit message wrong. I should have used differ instead of diverge, which is slightly misleading.

The specific case I am talking about can be found in:
include/dt-bindings/clock/imx6ul-clock.h dts/upstream/include/dt-bindings/clock/imx6ul-clock.h

The local header is missing the last commit from the kernel, which is 4e197ee880c2 ("clk: imx6ul: add ethernet refclock mux support"). This added some new defines, which are not present in the u-boot header.
Following this commit, the imx6ul.dtsi was patched in the kernel to use one of the new defines.

Quoted 5 lines

Because of this, at the current state, migrating a board which is somehow based on imx6ul.dtsi will give a dtc error given by a value being used in the upstream dtsi which is not defined in the local header, because local includes always have priority with respect to upstream ones even when setting OF_UPSTREAM.

So you should just drop the local DT bindings header:
include/dt-bindings/clock/imx6ul-clock.h and that should resolve the problem for you, right?

-Sumit

Quoted 55 lines

Regards,
Patrick

Quoted 51 lines
Quoted 51 lines

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have not been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +14 -1
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+       -I$(srctree)/dts/upstream/include \
+       -Iinclude \
+       $(if $(KBUILD_SRC), -I$(srctree)/include) \
+       $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+               $(if $(CONFIG_HAS_THUMB2), \
+                       $(if $(CONFIG_CPU_V7M), \
+                               -I$(srctree)/arch/arm/thumb1/include), \
+                       -I$(srctree)/arch/arm/thumb1/include)) \
+       -I$(srctree)/arch/$(ARCH)/include \
+       -include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
        -Iinclude \
        $(if $(KBUILD_SRC), -I$(srctree)/include) \
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
        -I$(srctree)/arch/$(ARCH)/include \
        -include $(srctree)/include/linux/kconfig.h \
        -I$(srctree)/dts/upstream/include
+endif
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
--

2.43.0

#4 lore raw

Hi Sumit,

Quoted 52 lines · Sumit Garg
Quoted 12 lines · Patrick Barsanti

Hi Sumit,

Quoted 8 lines · Sumit Garg

Hi Patrick,

Quoted 3 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files

with

Quoted 5 lines
Quoted 5 lines
Quoted 5 lines

respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose

of

Quoted 1 line
Quoted 1 line
Quoted 1 line

OF_UPSTREAM, or delete it entirely. This last option would then break

all

Quoted 23 lines
Quoted 7 lines
Quoted 1 line

the other boards which have not yet been migrated to OF_UPSTREAM.

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Sorry, I think I have worded my commit message wrong. I should have used differ instead of diverge, which is slightly misleading.

The specific case I am talking about can be found in:
include/dt-bindings/clock/imx6ul-clock.h dts/upstream/include/dt-bindings/clock/imx6ul-clock.h

The local header is missing the last commit from the kernel, which is 4e197ee880c2 ("clk: imx6ul: add ethernet refclock mux support"). This added some new defines, which are not present in the u-boot header.
Following this commit, the imx6ul.dtsi was patched in the kernel to use one of the new defines.

Quoted 5 lines

Because of this, at the current state, migrating a board which is somehow based on imx6ul.dtsi will give a dtc error given by a value being used in the upstream dtsi which is not defined in the local header, because local includes always have priority with respect to upstream ones even when setting OF_UPSTREAM.

Quoted 3 lines

So you should just drop the local DT bindings header:
include/dt-bindings/clock/imx6ul-clock.h and that should resolve the problem for you, right?

Yes, that indeed solves my problem.
But if I drop it, I will force all other boards which are not yet migrated to OF_UPSTREAM and include imx6ul.dtsi to
use the upstream header instead of the local one.
I did not feel comfortable in doing so, because if any change is made to the upstream header in the future which is somehow not backwards compatible, then all boards which are still not using OF_UPSTREAM would not compile.

I also thought this would not be limited to the single header file which caused my problem. I imagine there would be other cases of local headers which are missing one or more commits from mainline kernel and cause the same type of problem when moving to OF_UPSTREAM.

The opposite problem also exists.
For example:
675575880f ("phycore-am64x: Migrate to OF_UPSTREAM")
does not drop include/dt-bindings/net/ti-dp83867.h, and I think the migration worked properly only because at the moment there is no difference between local and upstream headers.
If and when the upstream headers and devicetrees will be patched, this will cause problems, because the local include will be used even if it's out-of-date.
I have tested this: by simulating a kernel patch to the upstream files, which adds an extra define in ti-dp83867.h and updates k3-am64-phycore-som.dtsi to use this new define, current state u-boot will fail to build because that define is not present in the local include header.
By including my patch, the build is successful.

This is the reason why I proposed this Makefile patch, but of course I am completely open to suggestions and ideas better than mine, which I suspect are fairly easy to come by :)

Thank you,
Regards,
Patrick

Quoted 65 lines

-Sumit

Quoted 9 lines

Regards,
Patrick

Quoted 5 lines
Quoted 5 lines

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have

not

Quoted 7 lines
Quoted 7 lines
Quoted 7 lines

been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

Signed-off-by Patrick Barsanti <

[email protected]>

Quoted 9 lines
Quoted 9 lines

Makefile KBUILD_HOSTCFLAGS += $(if

Quoted 9 lines
---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +0 -0
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if

$(CONFIG_TOOLS_DEBUG),-g)

Quoted 12 lines
Quoted 12 lines

Makefile KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)

Quoted 12 lines
Makefile +9 -0
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+       -I$(srctree)/dts/upstream/include \
+       -Iinclude \
+       $(if $(KBUILD_SRC), -I$(srctree)/include) \
+       $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+               $(if $(CONFIG_HAS_THUMB2), \
+                       $(if $(CONFIG_CPU_V7M), \
+

-I$(srctree)/arch/arm/thumb1/include), \

Quoted 13 lines
Quoted 13 lines
Quoted 13 lines
Makefile +5 -0
+                       -I$(srctree)/arch/arm/thumb1/include)) \
+       -I$(srctree)/arch/$(ARCH)/include \
+       -include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
        -Iinclude \
        $(if $(KBUILD_SRC), -I$(srctree)/include) \
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
        -I$(srctree)/arch/$(ARCH)/include \
        -include $(srctree)/include/linux/kconfig.h \
        -I$(srctree)/dts/upstream/include
+endif
 
Quoted 1 line
Quoted 1 line

Makefile UBOOTINCLUDE := \ · line 855

Quoted 1 line
Makefile +0 -0
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC)

-print-file-name=include)

Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
Makefile +0 -1
--

2.43.0

#5 lore raw
Quoted 59 lines · Patrick Barsanti

Hi Sumit,

Quoted 50 lines · Sumit Garg
Quoted 41 lines · Patrick Barsanti

Hi Sumit,

Quoted 16 lines · Sumit Garg

Hi Patrick,

Quoted 10 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

Quoted 5 lines

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Sorry, I think I have worded my commit message wrong. I should have used differ instead of diverge, which is slightly misleading.

The specific case I am talking about can be found in:
include/dt-bindings/clock/imx6ul-clock.h dts/upstream/include/dt-bindings/clock/imx6ul-clock.h

The local header is missing the last commit from the kernel, which is 4e197ee880c2 ("clk: imx6ul: add ethernet refclock mux support"). This added some new defines, which are not present in the u-boot header.
Following this commit, the imx6ul.dtsi was patched in the kernel to use one of the new defines.

Quoted 5 lines

Because of this, at the current state, migrating a board which is somehow based on imx6ul.dtsi will give a dtc error given by a value being used in the upstream dtsi which is not defined in the local header, because local includes always have priority with respect to upstream ones even when setting OF_UPSTREAM.

Quoted 3 lines

So you should just drop the local DT bindings header:
include/dt-bindings/clock/imx6ul-clock.h and that should resolve the problem for you, right?

Quoted 8 lines

Yes, that indeed solves my problem.
But if I drop it, I will force all other boards which are not yet migrated to OF_UPSTREAM and include imx6ul.dtsi to
use the upstream header instead of the local one.
I did not feel comfortable in doing so, because if any change is made to the upstream header in the future which is somehow not backwards compatible, then all boards which are still not using OF_UPSTREAM would not compile.

DT headers backwards compatibility is something that upstream DT maintainers assure us about. And we try to closely monitor any DT ABI breakage while syncing upstream DT. Till now after we added OF_UPSTREAM support, fortunately there hasn't been any DT ABI breakage reports. So we should switch to upstream DT headers wherever we can and drop any redundant local DT headers. Migration to OF_UPSTREAM can surely be the next step but we want to encourage more and more code reuse from upstream DT sources.

Quoted 5 lines

I also thought this would not be limited to the single header file which caused my problem. I imagine there would be other cases of local headers which are missing one or more commits from mainline kernel and cause the same type of problem when moving to OF_UPSTREAM.

The redundant local DT headers should be dropped wherever we can. Adding further defines or new clocks in your case isn't going to break backwards compatibility but rather dropping any existing clock defines would be a DT ABI breakage.

Quoted 7 lines

The opposite problem also exists.
For example:
675575880f ("phycore-am64x: Migrate to OF_UPSTREAM") does not drop include/dt-bindings/net/ti-dp83867.h, and I think the migration worked properly only because at the moment there is no difference between local and upstream headers.

That's a leftover from migration, feel free to propose a patch to drop it.

Quoted 10 lines

If and when the upstream headers and devicetrees will be patched, this will cause problems, because the local include will be used even if it's out-of-date.
I have tested this: by simulating a kernel patch to the upstream files, which adds an extra define in ti-dp83867.h and updates k3-am64-phycore-som.dtsi to use this new define, current state u-boot will fail to build because that define is not present in the local include header.
By including my patch, the build is successful.

Quoted 3 lines

This is the reason why I proposed this Makefile patch, but of course I am completely open to suggestions and ideas better than mine, which I suspect are fairly easy to come by :)

The additional complexity added by your patch is just needed to keep local DT headers but that goes against using upstream DT as much as we can and thereby reducing maintenance burden.

-Sumit

#6 lore raw
In reply to Patrick Barsanti

Hi Patrick

Quoted 89 lines · Patrick Barsanti

Hi Sumit,

Quoted 50 lines · Sumit Garg
Quoted 41 lines · Patrick Barsanti

Hi Sumit,

Quoted 16 lines · Sumit Garg

Hi Patrick,

Quoted 10 lines · Patrick Barsanti

Always prioritizing u-boot includes causes problems when trying to migrate boards to OF_UPSTREAM that have divergent devicetree files with respect to the upstream ones.

For example, migrating a board based on imx6ul.dtsi to OF_UPSTREAM breaks it, as there are some missing defines in the local dtsi file; the solutions would be to either patch it, which defeats the purpose of OF_UPSTREAM, or delete it entirely. This last option would then break all the other boards which have not yet been migrated to OF_UPSTREAM.

Quoted 5 lines

Can you elaborate more here regarding which dt-bindings headers conflict? Also, is it only the DTS files consumer for those headers or there are U-Boot drivers depending on them too?

-Sumit

Sorry, I think I have worded my commit message wrong. I should have used differ instead of diverge, which is slightly misleading.

The specific case I am talking about can be found in:
include/dt-bindings/clock/imx6ul-clock.h dts/upstream/include/dt-bindings/clock/imx6ul-clock.h

The local header is missing the last commit from the kernel, which is 4e197ee880c2 ("clk: imx6ul: add ethernet refclock mux support"). This added some new defines, which are not present in the u-boot header.
Following this commit, the imx6ul.dtsi was patched in the kernel to use one of the new defines.

Quoted 5 lines

Because of this, at the current state, migrating a board which is somehow based on imx6ul.dtsi will give a dtc error given by a value being used in the upstream dtsi which is not defined in the local header, because local includes always have priority with respect to upstream ones even when setting OF_UPSTREAM.

Quoted 3 lines

So you should just drop the local DT bindings header:
include/dt-bindings/clock/imx6ul-clock.h and that should resolve the problem for you, right?

Yes, that indeed solves my problem.
But if I drop it, I will force all other boards which are not yet migrated to OF_UPSTREAM and include imx6ul.dtsi to
use the upstream header instead of the local one.
I did not feel comfortable in doing so, because if any change is made to the upstream header in the future which is somehow not backwards compatible, then all boards which are still not using OF_UPSTREAM would not compile.

I also thought this would not be limited to the single header file which caused my problem. I imagine there would be other cases of local headers which are missing one or more commits from mainline kernel and cause the same type of problem when moving to OF_UPSTREAM.

The opposite problem also exists.
For example:
675575880f ("phycore-am64x: Migrate to OF_UPSTREAM")
does not drop include/dt-bindings/net/ti-dp83867.h, and I think the migration worked properly only because at the moment there is no difference between local and upstream headers.
If and when the upstream headers and devicetrees will be patched, this will cause problems, because the local include will be used even if it's out-of-date.
I have tested this: by simulating a kernel patch to the upstream files, which adds an extra define in ti-dp83867.h and updates k3-am64-phycore-som.dtsi to use this new define, current state u-boot will fail to build because that define is not present in the local include header.
By including my patch, the build is successful.

Quoted 4 lines

This is the reason why I proposed this Makefile patch, but of course I am completely open to suggestions and ideas better than mine, which I suspect are fairly easy to come by :)

Based on the discussion so far, you can extend the commit message so other people can comment on it

Michael

Quoted 64 lines

Thank you,
Regards,
Patrick

Quoted 60 lines

-Sumit

Quoted 55 lines

Regards,
Patrick

Quoted 51 lines
Quoted 51 lines

The opposite problem also exists: by always prioritizing upstream includes, if changes are made in the kernel headers and devicetree files that are not backwards compatible, again all boards which have not been migrated to OF_UPSTREAM will break.

This patch fixes this problem by prioritizing upstream includes when CONFIG_OF_UPSTREAM=y, while keeping current prioritization when it is not.

---
 Makefile | 14 ++++++++++++++
 1 file changed, 14 insertions(+)
Makefile +14 -1
index 79b28c2d81..899ae664ca 100644
@@ -826,6 +826,19 @@ KBUILD_HOSTCFLAGS += $(if $(CONFIG_TOOLS_DEBUG),-g)
 
 # Use UBOOTINCLUDE when you must reference the include/ directory.
 # Needed to be compatible with the O= option
+ifeq ($(CONFIG_OF_UPSTREAM),y)
+UBOOTINCLUDE    := \
+       -I$(srctree)/dts/upstream/include \
+       -Iinclude \
+       $(if $(KBUILD_SRC), -I$(srctree)/include) \
+       $(if $(CONFIG_$(SPL_)SYS_THUMB_BUILD), \
+               $(if $(CONFIG_HAS_THUMB2), \
+                       $(if $(CONFIG_CPU_V7M), \
+                               -I$(srctree)/arch/arm/thumb1/include), \
+                       -I$(srctree)/arch/arm/thumb1/include)) \
+       -I$(srctree)/arch/$(ARCH)/include \
+       -include $(srctree)/include/linux/kconfig.h
+else
 UBOOTINCLUDE    := \
        -Iinclude \
        $(if $(KBUILD_SRC), -I$(srctree)/include) \
@@ -837,6 +850,7 @@ UBOOTINCLUDE    := \
        -I$(srctree)/arch/$(ARCH)/include \
        -include $(srctree)/include/linux/kconfig.h \
        -I$(srctree)/dts/upstream/include
+endif
 
 NOSTDINC_FLAGS += -nostdinc -isystem $(shell $(CC) -print-file-name=include)
 
--

2.43.0

Signature · 11 lines
Michael Nazzareno Trimarchi
Co-Founder & Chief Executive Officer
M. +39 347 913 2170
[email protected]
__________________________________

Amarula Solutions BV
Joop Geesinkweg 125, 1114 AB, Amsterdam, NL
T. +31 (0)85 111 9172
[email protected]
www.amarulasolutions.com