Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[RFC][DNM]DTS service nodes #23394

Closed

Conversation

tbursztyka
Copy link
Collaborator

This is an attempt to expose "software services" as DTS nodes.

Software services are mostly all these code being initialized through SYS_INIT() (it currently creates a struct device, but most of them are just not devices per-se)

Exposing them is a primary requirement for fixing #22545
(Or then we will have a problem with all these hardcoded leve/prio used on SYS_INIT())

So I took a quick example with the UART console for qemu_x86, so you'll get an idea.

I put it into a services {} .dtsi root node, it has nothing to do in soc {}, as it is not a hardware device being exposed.

Tomasz Bursztyka added 2 commits March 11, 2020 13:06
Currently, DTS is used to generate device nodes only. However, there are
software services which are really close to devices (since they require
certain device to work) and thus could be exposed through DTS directly.

So adding the basic service node descriptor.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
It is a service providing a console access through a UART port.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
@tbursztyka tbursztyka added area: Devicetree area: Devicetree Binding PR modifies or adds a Device Tree binding labels Mar 11, 2020
@zephyrbot
Copy link
Collaborator

zephyrbot commented Mar 11, 2020

All checks are passing now.

Tip: The bot edits this comment instead of posting a new one, so you can check the comment's history to see earlier messages.

@galak
Copy link
Collaborator

galak commented Mar 11, 2020

@tbursztyka not sure I follow what info you are trying to encode and extract from the DTS for this purpose.

@carlescufi
Copy link
Member

If we go this way we might need to reconsider rewriting this section a bit:
https://docs.zephyrproject.org/latest/guides/dts/dt-vs-kconfig.html

Since it will no longer be true.
@mbolivar and @galak comments welcome.

@tbursztyka
Copy link
Collaborator Author

@galak check mbolivar's issue #22545 this won't be really reliable without exposing all build time init level/prio based objects (which are all struct device). There will be nothing to help the user setting the level/prio properly by hand if, depending on the device tree, the dependency devices (uart in case of uart console) have level/prio varying depending on the board/config/build/etc... Getting rid of pre_kernel_<1/2> will not be possible either.

@carlescufi DTS could help to set some options, like the uart dev name being used for the uart console. But I would not switch all the options to DTS. That said, I don't think the mentioned documentation needs to be updated: for instance if the user unset CONFIG_UART_CONSOLE via menuconfig, the uart console service won't be built anyway.

Note as well that some services are in fact a mix of hardware and software service, such as the rtt based console. The line is quite blurry sometime.

It provides a console through UART0.

Signed-off-by: Tomasz Bursztyka <tomasz.bursztyka@linux.intel.com>
@mbolivar
Copy link
Contributor

this won't be really reliable without exposing all build time init level/prio based objects (which are all struct device).

The fact that they are all struct device seems to be a historical artifact. I'm not sure I agree we should be putting software objects into DT. That doesn't seem to be what it's for.

@tbursztyka
Copy link
Collaborator Author

tbursztyka commented Mar 11, 2020

The fact that they are all struct device seems to be a historical artifact.

Indeed. However, because of dependency between devices and such software services (in this example: uart console needs the uart device to be initialized first), you must keep all of them in the same initialization ordered list anyway. Unless you start to bloat things up (having some slist or else), but this is exactly what I don't want to do.

@mbolivar
Copy link
Contributor

I think this deserves some measurement. Allocating an entire struct device for a single function is also a waste of space.

@tbursztyka
Copy link
Collaborator Author

tbursztyka commented Mar 11, 2020

I think this deserves some measurement. Allocating an entire struct device for a single function is also a waste of space.

On that we agree. I already started a few days ago to rework struct device and all to fix that issue.
I did mentioned it in #22941 issue number 9. (it does save a bit of ROM and RAM in the end)

@mbolivar-nordic
Copy link
Contributor

On that we agree. I already started a few days ago to rework struct device and all to fix that issue.

Do you have any code to share? Now that #23245 is basically ready to go in and I have some bandwidth back, I would like to start discussing devicetree.h vs. device.h issues more seriously.

@mbolivar-nordic mbolivar-nordic requested review from mbolivar-nordic and removed request for mbolivar March 23, 2020 16:57
@tbursztyka
Copy link
Collaborator Author

@mbolivar-nordic I have a draft still in wip state. Anyway, let me close this RFC as it's a wrong approach altogether.

@mbolivar-nordic
Copy link
Contributor

@mbolivar-nordic I have a draft still in wip state. Anyway, let me close this RFC as it's a wrong approach altogether.

If you have a branch you can post I would be very curious to see it with a full understanding that it's WIP. If not, any idea when you will have one?

@tbursztyka
Copy link
Collaborator Author

just look at my drafts, I updated #22941 with references there

@tbursztyka
Copy link
Collaborator Author

Let's close this one, as it won't go any further.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Devicetree Binding PR modifies or adds a Device Tree binding area: Devicetree
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants