-
Notifications
You must be signed in to change notification settings - Fork 7.4k
RFC: Parse Kconfig to get driver API/feature info #50724
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
Conversation
Add a Kconfig symbol that reflects the devicetree compatible string so we can map from dts compatible to Kconfig fully. Signed-off-by: Kumar Gala <[email protected]>
pull edt into kconfig so we can look at devicetree stuff Signed-off-by: Kumar Gala <[email protected]>
Kumar, could you define 'feature' here? And clarifying the end goal of this update would help. |
Feature here is meant to be defined as what capabilities a driver implements. For something like serial drivers, this goes to what APIs are or not implemented. So if you look at something like
The end goal would be to provide a means that we can "query" this information for whatever needs we might have, for example we can generate docs for a board to describe what features are supported, based on its devicetree and this information. In addition to the features, we also have the API information. Today we don't have an easy way of associating a device with what API its supporting. The "type" information of the api pointer isn't kept anywhere we can determine in an easy way. There are some things we do for user space and parsing the ELF file to extract this info. But we can easily associate a In what format the data we extract is exposed is a TBD based on the needs at hand. The first goal of this PR is to show the capability and discuss the idea of standardizing on conventions for use of Kconfig symbol naming for conveying API and features. |
Walk devicetree compatibles that are enabled and dump out API and feature info based on the Kconfig symbols we have enabled. Signed-off-by: Kumar Gala <[email protected]>
38ead4a
to
c400511
Compare
Please provide an example Kconfig file for some driver. I can't work out how the compatible property is defined in the Kconfig file. |
The compatible Kconfig properties are auto-generated (look at Kconfig/Kconfig.dts in the build dir). All this does right now is output when you do the cmake config what API and features we can detect. So for something like FRDM-K64F, we get:
For something like qemu_x86 we get:
|
How would something like this look with the changes?
It would require no changes right? |
So for something like
(No change to any Kconfig, boards, etc). |
|
Some notes:
|
Also, We should add a config like DEVICE_DRIVER
We could use this to validate the individual kconfig files which describe a device driver, make sure it has a compatible, an API etc. this could help maintain standardization. |
One alternative to this solution is, as proposed previously, adding a device_type or api property to the bindings files. This doesn't require strict Kconfig symbols, names and patterns, and changes are isolated to the devicetree. The only feature which I find essential in this PR is associating a compatible with an API. Not sure if the extracted "feature" property is really that useful, especially if we can split up the APIs like UART for which it could be useful, into different bespoke APIs. Validating that a bindings file contains a property like device_type is also trivial, compared to kconfigs where some of them must be validated as device drivers, while some must not be validated at all, like files which just source other files. Unless this solution can bring way more useful features than the bindings file solution, I don't think the complexity is worth it. |
I agree on api type in the bindings (in the yaml file so even if that's software feature being exposed, it's not strictly part of the DT which should only be about the hw, or are the yaml also under such rule?), it would be easier and more reliable to relate a compatible to an actual API. That said, @galak, could you expose exactly a few major use cases for such metadata extractions? Any which way this is solved, it will require a very strict normalization of Kconfig options name in order to differentiate what is a feature and what is not (i.e. just a simple config thing such as an obscure internal timeout) |
-1 on adding this info to bindings. Bindings are the schema of Devicetree, nothing else. And why should a binding be tied to a particular API? I can create my own sensor API out of tree and still use the same DT file. Btw, we are still missing why we need all this information. Can we come up with a problem that needs to be solved using it first? |
Adding api to bindings files is entirely appropriate according to ePAPR and Linux In summary:
The problems that need the API information In summary:
With the simplicity of the already supported feature on Linux, and the gain we will immediately get for the shells, and may get for future uses, I see no good argument against adding the feature. Having the feature added will retrospectively reduce complexity as we will not need to touch the kconfig system. |
An additional note to the "alternative solution" comment i made earlier, we can do both if there is enough other information we can get from kconfig files, just get the API from the node as is done with the compatible. |
Ok, thus my question in parenthesis. I was not sure the yaml files are that tight to the dtsi ones.
👍 |
While I am not as skeptical towards the DTS |
This property is deprecated (as mentioned in the paper). From DT-spec: https://github.com/devicetree-org/devicetree-specification/releases/download/v0.3/devicetree-specification-v0.3.pdf
Also, we should not mix device type with API type, these are different things. I could add to a sensor |
Devicetree is NOT the right place for this information. I repeat that devicetree is meant to describe hardware and should be agnostic to the software it is running on. One should be able to take a devicetree and use it with a different OS. So encoding Zephyr specific API choices is devicetree does not make sense. |
@tbursztyka @gmarull I think the main in zephyr use case is around multi-api device support. The shell as @henrikbrixandersen mention works, but we can make it better with this information. There is some need for sensors that having this information seems like it might be useful, but I don't quite understand the use / need there (@yperess @MaureenHelm can you chime on the sensor need). There is some possible use with I3C and knowing the set of client devices. Also possibly simplifying some of the userspace/syscall logic that is extracting API type information out of the ELF file. And than there is all the information cases - docs, testing, etc. |
The point is that it and "model" exist, showing precedent for having other metadata than compatible in the bindings files, not whether or not that specific property is deprecated which i even noted in the comment... It not only exists, it is in use in Linux. |
I understand the point some of those things are hold overs from true IEEE 1275 and aren't utilized anymore. My point about encoding zephyr software choices in devicetree does not make sense and I don't support it for this purpose. |
How would this PR help to solve the multi-api issue that #49374 tried to (and could, if all instances were DTS based) do? I know there are different approach to an issue. But so far, on things related to device model, it seems to me we are piling up more code and workarounds to the existing model than actually fixing its core issues.
Informational use cases are far from being critical, not sure it's worth piling up more hacks on devices just for it. At least before fixing the core issuse. |
This doesn't solve the multi-api issue by itself. Its meant to demonstrate how to get the API type information associated with a devicetree compatible and driver (and thus can connect to a 'struct device'). Regardless of what solution we utilize we will have to have some means of associated and lookup the different API pointers for a "device".
I'm not sure what hack this is doing. It's utilizing the existing Kconfig information we already have, and suggesting we standardize on some aspects of it. |
While researching into yet another solution to the issue of device driver capabilities, I stumbled upon the following problems that we should be able to account for with these solutions. The new solution looks like this.
It describes what kconfig symbol selects the driver, which compatibles it works with, and of course, the API. How does this PR handle one driver supporting multiple compatibles? can it? |
Looking at the code it seems like the Kconfig
|
The example is not related to the currently existing device drivers/bindings. Can this solution solve the problem shown in the example? The modem drivers/bindings are bit messy currently, and will be updated to the example that i showed in the future. It should be possible to change which driver you use without changing the compatible, just by including MODEM_GSM_PPP instead of MODEM_QUECTEL_BG9X or reverse. |
I appreciate all the efforts on this topic, I'm sure it will be useful one way or the other. But remember, we still have no use for it. We have potential uses, so we don't really know if any of these proposals will fit. I'd go back to the original discussions and open RFCs if not in place:
|
I'm not familiar with how we do other doc generation for things like Kconfig or dts bindings, but in boards we tend to have a section/table like: https://docs.zephyrproject.org/latest/boards/arm/lpcxpresso55s06/doc/index.html#supported-features We could autogenerate that based on this information being extracted from devicetree and Kconfig. (Thus it would always be correct and in sync). The following commit shows how the table got updated recently to expose features on a driver level: 569ef4c |
If we can describe the relationship in Kconfig than we can extract that information. So its easy enough to have something like:
|
We have a multi-API proposal from @bjarki-trackunit that requires meta-info (#48817). This PR shows an alternate to using a yet another YAML file to describe devicetree compatible to driver API type association. |
@galak as discussed at dev-review it'd be good to get a view of the use cases and problems to solve here, with links to the relevant issues that should have good descriptions of those. There are already 30 comments on this issue. I'd really not have to read all of them to find the ones that have answers to basic questions like "why" and "for what" -- i.e. it'd be better for all the reviewers if you can update the PR description instead of answering inline. |
I'm going to close this PR for now since I agree, this is more about how to implement a solution to a specific problem, and not about the problems themselves. |
The intent of this PR is to show how we can parse Kconfig data to extract driver API and feature information. We map from devicetree compatible to Kconfig.
If we standardize on the Kconfig symbols names and pattern, we can utilize this as a means to extract info we need for things like multi-api, shell, userspace, docs, testing, etc.