devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Queries: Using ifdef CONFIG condition in dts files
       [not found] <CAOuPNLjGWp4+Ub_Ccaw+tx1NQrNcqyjUG5K30uPH3uYTF_wxfw@mail.gmail.com>
@ 2022-05-26  8:46 ` Pintu Agarwal
       [not found]   ` <65f1b675-84ac-b5da-6075-2a9f0353ab37@quicinc.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Pintu Agarwal @ 2022-05-26  8:46 UTC (permalink / raw)
  To: open list, robh+dt, devicetree, frowand.list, linux-mm

Hi,

I have a generic question regarding conditional compilation options in
dts/dtsi files.
Our Kernel version is: 4.14
Let's say I have a Kernel config such as CONFIG_XYZ.
This driver uses a CMA reserved memory and its node is defined in a
mysoc.dtsi file.
Like:
#if defined(CONFIG_XYZ)
&reserved_mem {
        xyz_region: xyz_region {
                compatible = "shared-dma-pool";
                reusable;
                size = <0x600000>;
        };
};
#endif

The problem is as follows:
a) The same kernel/dts source is shared across 2 product versions.
b) In one product we need to enable this CONFIG_XYZ but in another
product we need to disable it.
c) When we disable the CONFIG we wanted this dts node also to be
disabled together.
d) When we add "#if defined(CONFIG_XYZ)" check in the dtsi file, it
works if the CONFIG is disabled, but it does not work if CONFIG is
enabled (node is not getting created).
e) This mysoc.dtsi file is getting included in many other dts files,
so we cannot add a compilation check in Makefile. We will end up
renaming many files just to protect this one change.

Is there any other better way to handle this situation ?

I see that in latest kernel we have a conditional compilation added like this:
#ifdef SOC_HAS_USB2_CH2
https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/renesas/salvator-common.dtsi#L1028

But the same is not recognized by the device tree compiler when using
kernel CONFIG_ check.

Is it the device-tree compiler issue which got fixed in the latest version ?
Or, is it because Kernel config cannot be shared with device-tree ?

Please let us know if there is any other opinion.


Thank you.

Regards,
Pintu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Queries: Using ifdef CONFIG condition in dts files
       [not found]   ` <65f1b675-84ac-b5da-6075-2a9f0353ab37@quicinc.com>
@ 2022-05-27 10:04     ` Pintu Agarwal
  2022-05-27 11:36       ` Pintu Agarwal
  0 siblings, 1 reply; 4+ messages in thread
From: Pintu Agarwal @ 2022-05-27 10:04 UTC (permalink / raw)
  To: T.Michael Turney; +Cc: open list, robh+dt, devicetree, frowand.list, linux-mm

Hi,

On Thu, 26 May 2022 at 19:53, T.Michael Turney <quic_mturney@quicinc.com> wrote:
>
> Kernel developers correct me where I go astray, but this seems like the
> CONFIG_XYZ value is not available in this file.  This would explain why
> the disable case works.
>
> At top of dtsi file are you #include <config.h> or whatever the correct
> syntax is to see the CONFIG values?

Thanks for your comments.
No, I could not find any specific config,h to be included to make the
CONFIG values visible to dts.

Thanks,
Pintu

>
> On 5/26/2022 1:46 AM, Pintu Agarwal wrote:
> > Hi,
> >
> > I have a generic question regarding conditional compilation options in
> > dts/dtsi files.
> > Our Kernel version is: 4.14
> > Let's say I have a Kernel config such as CONFIG_XYZ.
> > This driver uses a CMA reserved memory and its node is defined in a
> > mysoc.dtsi file.
> > Like:
> > #if defined(CONFIG_XYZ)
> > &reserved_mem {
> >          xyz_region: xyz_region {
> >                  compatible = "shared-dma-pool";
> >                  reusable;
> >                  size = <0x600000>;
> >          };
> > };
> > #endif
> >
> > The problem is as follows:
> > a) The same kernel/dts source is shared across 2 product versions.
> > b) In one product we need to enable this CONFIG_XYZ but in another
> > product we need to disable it.
> > c) When we disable the CONFIG we wanted this dts node also to be
> > disabled together.
> > d) When we add "#if defined(CONFIG_XYZ)" check in the dtsi file, it
> > works if the CONFIG is disabled, but it does not work if CONFIG is
> > enabled (node is not getting created).
> > e) This mysoc.dtsi file is getting included in many other dts files,
> > so we cannot add a compilation check in Makefile. We will end up
> > renaming many files just to protect this one change.
> >
> > Is there any other better way to handle this situation ?
> >
> > I see that in latest kernel we have a conditional compilation added like this:
> > #ifdef SOC_HAS_USB2_CH2
> > https://elixir.bootlin.com/linux/latest/source/arch/arm64/boot/dts/renesas/salvator-common.dtsi#L1028
> >
> > But the same is not recognized by the device tree compiler when using
> > kernel CONFIG_ check.
> >
> > Is it the device-tree compiler issue which got fixed in the latest version ?
> > Or, is it because Kernel config cannot be shared with device-tree ?
> >
> > Please let us know if there is any other opinion.
> >
> >
> > Thank you.
> >
> > Regards,
> > Pintu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Queries: Using ifdef CONFIG condition in dts files
  2022-05-27 10:04     ` Pintu Agarwal
@ 2022-05-27 11:36       ` Pintu Agarwal
  2022-05-28  3:51         ` Pintu Agarwal
  0 siblings, 1 reply; 4+ messages in thread
From: Pintu Agarwal @ 2022-05-27 11:36 UTC (permalink / raw)
  To: T.Michael Turney; +Cc: open list, robh+dt, devicetree, frowand.list, linux-mm

On Fri, 27 May 2022 at 15:34, Pintu Agarwal <pintu.ping@gmail.com> wrote:
>
> Hi,
>
> On Thu, 26 May 2022 at 19:53, T.Michael Turney <quic_mturney@quicinc.com> wrote:
> >
> > Kernel developers correct me where I go astray, but this seems like the
> > CONFIG_XYZ value is not available in this file.  This would explain why
> > the disable case works.
> >
> > At top of dtsi file are you #include <config.h> or whatever the correct
> > syntax is to see the CONFIG values?
>
> Thanks for your comments.
> No, I could not find any specific config,h to be included to make the
> CONFIG values visible to dts.
>

BTW, I tried another approach but this also doesn't work when CONFIG is enabled.
a) I have created a new header file such as myxyz.h and defined a new
macro with config check.
=> myxyz.h
+#ifdef CONFIG_XYZ
+#define XYZ_CMA
+#endif

b) Then I included the header file in my dtsi file and used ifdef with
the new macro.

#include "myxyz.h"

#ifdef CONFIG_XYZ
&reserved_mem {
        xyz_region: xyz_region {
                compatible = "shared-dma-pool";
                reusable;
                size = <0x600000>;
        };
};
#endif

But unfortunately this approach also did not work when CONFIG is
enabled. So, when config enable/disable its same behavior.
However, if I put the #define in the dtsi file itself then it works as expected.


Thanks,
Pintu

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: Queries: Using ifdef CONFIG condition in dts files
  2022-05-27 11:36       ` Pintu Agarwal
@ 2022-05-28  3:51         ` Pintu Agarwal
  0 siblings, 0 replies; 4+ messages in thread
From: Pintu Agarwal @ 2022-05-28  3:51 UTC (permalink / raw)
  To: T.Michael Turney; +Cc: open list, robh+dt, devicetree, frowand.list, linux-mm

Sorry, a small correction.

On Fri, 27 May 2022 at 17:06, Pintu Agarwal <pintu.ping@gmail.com> wrote:
>
> On Fri, 27 May 2022 at 15:34, Pintu Agarwal <pintu.ping@gmail.com> wrote:
> >
> > Hi,
> >
> > On Thu, 26 May 2022 at 19:53, T.Michael Turney <quic_mturney@quicinc.com> wrote:
> > >
> > > Kernel developers correct me where I go astray, but this seems like the
> > > CONFIG_XYZ value is not available in this file.  This would explain why
> > > the disable case works.
> > >
> > > At top of dtsi file are you #include <config.h> or whatever the correct
> > > syntax is to see the CONFIG values?
> >
> > Thanks for your comments.
> > No, I could not find any specific config,h to be included to make the
> > CONFIG values visible to dts.
> >
>
> BTW, I tried another approach but this also doesn't work when CONFIG is enabled.
> a) I have created a new header file such as myxyz.h and defined a new
> macro with config check.
> => myxyz.h
> +#ifdef CONFIG_XYZ
> +#define XYZ_CMA
> +#endif
>
> b) Then I included the header file in my dtsi file and used ifdef with
> the new macro.
>
> #include "myxyz.h"
>
> #ifdef CONFIG_XYZ

#ifdef XYZ_CMA

> &reserved_mem {
>         xyz_region: xyz_region {
>                 compatible = "shared-dma-pool";
>                 reusable;
>                 size = <0x600000>;
>         };
> };
> #endif
>
> But unfortunately this approach also did not work when CONFIG is
> enabled. So, when config enable/disable its same behavior.
> However, if I put the #define in the dtsi file itself then it works as expected.
>
>
> Thanks,
> Pintu

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2022-05-28  3:51 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <CAOuPNLjGWp4+Ub_Ccaw+tx1NQrNcqyjUG5K30uPH3uYTF_wxfw@mail.gmail.com>
2022-05-26  8:46 ` Queries: Using ifdef CONFIG condition in dts files Pintu Agarwal
     [not found]   ` <65f1b675-84ac-b5da-6075-2a9f0353ab37@quicinc.com>
2022-05-27 10:04     ` Pintu Agarwal
2022-05-27 11:36       ` Pintu Agarwal
2022-05-28  3:51         ` Pintu Agarwal

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).