linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* RFC: build config via DT names
@ 2018-02-10 15:52 Enrico Weigelt, metux IT consult
  2018-02-12 23:13 ` Frank Rowand
  0 siblings, 1 reply; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2018-02-10 15:52 UTC (permalink / raw)
  To: linux-kernel

Hi folks,

I've regularily have the task of configuring a kernel for a given DT.
To make this a little bit easier, I'd like to do this automatically.

The tuff task here is getting a mapping between dt compatible strings
and corresponding CONFIG_* flags. Automatically extracting it from the
source code seems pretty tricky, especially w/ corner cases (eg. some
drivers support groups of devices, depending on config options) - IMHO
it will need some code changes anyways.

Therefore I propose a simple approach using the existing Kconfig system:

Add an extra (toplevel) menu and config flag naming scheme which
directly map DT compatible strings to config flags. For example:

 > fsl,mpc5200-gpio <=> CONFIG_DTDEV_FSL_MPC5200_GPIO

 > config CONFIG_DTDEV_FSL_MPC5200_GPIO
 >    tristate "fsl,mpc5200-gpio"
 >    select GPIO_MPC5200

Note that these flags are separate from the actual drivers - they just
enable them automatically. Of course they'll have to be maintained by
the driver maintainers.


What do you think about this idea ?


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

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

* Re: RFC: build config via DT names
  2018-02-10 15:52 RFC: build config via DT names Enrico Weigelt, metux IT consult
@ 2018-02-12 23:13 ` Frank Rowand
  2018-02-12 23:24   ` Frank Rowand
  2018-02-13 15:19   ` Rob Herring
  0 siblings, 2 replies; 6+ messages in thread
From: Frank Rowand @ 2018-02-12 23:13 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult; +Cc: linux-kernel, devicetree

+ devicetree mail list

On 02/10/18 07:52, Enrico Weigelt, metux IT consult wrote:
> Hi folks,
> 
> I've regularily have the task of configuring a kernel for a given DT.
> To make this a little bit easier, I'd like to do this automatically.
> 
> The tuff task here is getting a mapping between dt compatible strings
> and corresponding CONFIG_* flags. Automatically extracting it from the
> source code seems pretty tricky, especially w/ corner cases (eg. some
> drivers support groups of devices, depending on config options) - IMHO
> it will need some code changes anyways.
> 
> Therefore I propose a simple approach using the existing Kconfig system:
> 
> Add an extra (toplevel) menu and config flag naming scheme which
> directly map DT compatible strings to config flags. For example:
> 
>> fsl,mpc5200-gpio <=> CONFIG_DTDEV_FSL_MPC5200_GPIO
> 
>> config CONFIG_DTDEV_FSL_MPC5200_GPIO
>>    tristate "fsl,mpc5200-gpio"
>>    select GPIO_MPC5200
> 
> Note that these flags are separate from the actual drivers - they just
> enable them automatically. Of course they'll have to be maintained by
> the driver maintainers.
> 
> 
> What do you think about this idea ?
> 
> 
> --mtx
> 

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

* Re: RFC: build config via DT names
  2018-02-12 23:13 ` Frank Rowand
@ 2018-02-12 23:24   ` Frank Rowand
  2018-02-13 13:16     ` Enrico Weigelt, metux IT consult
  2018-02-13 15:19   ` Rob Herring
  1 sibling, 1 reply; 6+ messages in thread
From: Frank Rowand @ 2018-02-12 23:24 UTC (permalink / raw)
  To: Enrico Weigelt, metux IT consult; +Cc: linux-kernel, devicetree

Hi Enrico,

On 02/12/18 15:13, Frank Rowand wrote:
> + devicetree mail list
> 
> On 02/10/18 07:52, Enrico Weigelt, metux IT consult wrote:
>> Hi folks,
>>
>> I've regularily have the task of configuring a kernel for a given DT.
>> To make this a little bit easier, I'd like to do this automatically.
>>
>> The tuff task here is getting a mapping between dt compatible strings
>> and corresponding CONFIG_* flags. Automatically extracting it from the
>> source code seems pretty tricky, especially w/ corner cases (eg. some
>> drivers support groups of devices, depending on config options) - IMHO
>> it will need some code changes anyways.
>>
>> Therefore I propose a simple approach using the existing Kconfig system:
>>
>> Add an extra (toplevel) menu and config flag naming scheme which
>> directly map DT compatible strings to config flags. For example:
>>
>>> fsl,mpc5200-gpio <=> CONFIG_DTDEV_FSL_MPC5200_GPIO
>>
>>> config CONFIG_DTDEV_FSL_MPC5200_GPIO
>>>     tristate "fsl,mpc5200-gpio"
>>>     select GPIO_MPC5200
>>
>> Note that these flags are separate from the actual drivers - they just
>> enable them automatically. Of course they'll have to be maintained by
>> the driver maintainers.
>>
>>
>> What do you think about this idea ?
>>
>>
>> --mtx

As you note, it can be quite tricky getting the correct kernel configuration
for a given devicetree.

There is a tool to aid this process: scripts/dtc/dt_to_config.  It is not
a 100% solution, but it is very helpful.

The problem is difficult enough that this tool led to a conference talk.
The slides are at https://elinux.org/images/5/50/Dt_debugging_part_2.pdf
which is linked to from
https://elinux.org/Device_Tree_presentations_papers_articles#linux_kernel_configuration

dt_to_config and configuration issues are discussed in slides 33 - 80.

-Frank

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

* Re: RFC: build config via DT names
  2018-02-12 23:24   ` Frank Rowand
@ 2018-02-13 13:16     ` Enrico Weigelt, metux IT consult
  0 siblings, 0 replies; 6+ messages in thread
From: Enrico Weigelt, metux IT consult @ 2018-02-13 13:16 UTC (permalink / raw)
  To: Frank Rowand; +Cc: linux-kernel, devicetree

On 12.02.2018 23:24, Frank Rowand wrote:

> There is a tool to aid this process: scripts/dtc/dt_to_config.  It is not
> a 100% solution, but it is very helpful.
> 
> The problem is difficult enough that this tool led to a conference talk.
> The slides are at https://elinux.org/images/5/50/Dt_debugging_part_2.pdf
> which is linked to from
> https://elinux.org/Device_Tree_presentations_papers_articles#linux_kernel_configuration

I believe my approach can make this much simpler, at least for most
drivers: the maintainers would explicitly add proper config flags,
instead of letting the tool guess it.

Of course, it would take some amount of work to do that for all drivers,
but we could do that step by step.


--mtx

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

* Re: RFC: build config via DT names
  2018-02-12 23:13 ` Frank Rowand
  2018-02-12 23:24   ` Frank Rowand
@ 2018-02-13 15:19   ` Rob Herring
  2018-02-13 16:21     ` Enrico Weigelt
  1 sibling, 1 reply; 6+ messages in thread
From: Rob Herring @ 2018-02-13 15:19 UTC (permalink / raw)
  To: Frank Rowand; +Cc: Enrico Weigelt, metux IT consult, linux-kernel, devicetree

On Mon, Feb 12, 2018 at 5:13 PM, Frank Rowand <frowand.list@gmail.com> wrote:
> + devicetree mail list
>
> On 02/10/18 07:52, Enrico Weigelt, metux IT consult wrote:
>> Hi folks,
>>
>> I've regularily have the task of configuring a kernel for a given DT.
>> To make this a little bit easier, I'd like to do this automatically.
>>
>> The tuff task here is getting a mapping between dt compatible strings
>> and corresponding CONFIG_* flags. Automatically extracting it from the
>> source code seems pretty tricky, especially w/ corner cases (eg. some
>> drivers support groups of devices, depending on config options) - IMHO
>> it will need some code changes anyways.
>>
>> Therefore I propose a simple approach using the existing Kconfig system:
>>
>> Add an extra (toplevel) menu and config flag naming scheme which
>> directly map DT compatible strings to config flags. For example:
>>
>>> fsl,mpc5200-gpio <=> CONFIG_DTDEV_FSL_MPC5200_GPIO
>>
>>> config CONFIG_DTDEV_FSL_MPC5200_GPIO
>>>    tristate "fsl,mpc5200-gpio"
>>>    select GPIO_MPC5200
>>
>> Note that these flags are separate from the actual drivers - they just
>> enable them automatically. Of course they'll have to be maintained by
>> the driver maintainers.
>>
>>
>> What do you think about this idea ?

Doubling the number of driver config options is not going to fly. How
would you handle multiple compatible strings per driver? We want fewer
config options, not more.

We have all the data, so we should be able to generate this which
dt_to_config tries to do. I think part of the problem is dt_to_config
works at the source level for everything. Really we need a more robust
way to map source files to config options and extracting match tables
from drivers. Perhaps doing the latter with coccinelle which can match
struct types, using the object files instead, or using module aliases
(though that doesn't work for built-in drivers).

Rob

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

* Re: RFC: build config via DT names
  2018-02-13 15:19   ` Rob Herring
@ 2018-02-13 16:21     ` Enrico Weigelt
  0 siblings, 0 replies; 6+ messages in thread
From: Enrico Weigelt @ 2018-02-13 16:21 UTC (permalink / raw)
  To: Rob Herring, Frank Rowand
  Cc: Enrico Weigelt, metux IT consult, linux-kernel, devicetree

On 13.02.2018 15:19, Rob Herring wrote:

> Doubling the number of driver config options is not going to fly. 

These options would be in their own submenu (which could be disabled
completely) and use their own prefix. IMHO, even if they grow into big
numbers, the impact should be minimal.

> How would you handle multiple compatible strings per driver? 

Multiple entries in the submenu, each selecting the same driver.

> We have all the data, so we should be able to generate this which
> dt_to_config tries to do. 

I guess there're lots of corner cases that would need special magic.

> I think part of the problem is dt_to_config
> works at the source level for everything. Really we need a more robust
> way to map source files to config options and extracting match tables
> from drivers. Perhaps doing the latter with coccinelle which can match
> struct types, using the object files instead, or using module aliases
> (though that doesn't work for built-in drivers).

Configure by already compiled binaries ?


--mtx

-- 
Enrico Weigelt, metux IT consult
Free software and Linux embedded engineering
info@metux.net -- +49-151-27565287

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

end of thread, other threads:[~2018-02-13 16:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-02-10 15:52 RFC: build config via DT names Enrico Weigelt, metux IT consult
2018-02-12 23:13 ` Frank Rowand
2018-02-12 23:24   ` Frank Rowand
2018-02-13 13:16     ` Enrico Weigelt, metux IT consult
2018-02-13 15:19   ` Rob Herring
2018-02-13 16:21     ` Enrico Weigelt

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