Documentation for drm/i915
So over the past few years the drm subsystem gained some very nice documentation. And recently we’ve started to follow suite with the Intel graphics driver. All the kernel documenation is integrated into one big DocBook and I regularly upload latest HTML builds of the Linux DRM Developer’s Guide. This is built from drm-intel-nightly so has slightly fresher documentation (hopefully) than the usual documentation builds from Linus’ main branch which can be found all over the place. If you want to build these yourself simply run
$ make htmldocs
For testing we now also have neat documentation for the infrastructure and helper libraries found in intel-gpu-tools. The README in the i-g-t repository has detailed build instructions - gtkdoc is a bit more of a fuzz to integrate.
Below the break some more details about documentation requirements relevant for developers.
So from now on I expect reasonable documentation for new, big kernel features and for new additions to the i-g-t library.
For i-g-t the process is simple: Add the gtk-doc comment blocks to all newly added functions, install and build with gtk-doc enabled. Done. If the new library is tricky (for example the pipe CRC support code) a short overview section that references some functions to get people started is useful, but not really required. And with the exception of the still in-flux kernel modesetting helper library i-g-t is fully documented, so there’s lots of examples to copy from.
For the kernel this is a bit more involved, mostly since kerneldoc sucks more. But we also only just started with documenting the drm/i915 driver itself.
- First extract all the code for your new feature into a new file. There’s unfortunately no other way to sensibly split up and group the reference documentation with kerneldoc. But at least that will also be a good excuse to review the related interfaces before extracting them.
- Create reference kerneldoc comments for the functions used as interfaces to
the rest of the driver. It’s always a bit a judgement call what to document and
what not, since compared to the DRM core where functions must be explicitly
exported to drivers there’s no clean separate between the core parts and
subsystems and more mundane platform enabling code. For big and complicated
features it’s also good practice to have an overview
DOC:
section somewhere at the beginning of the file. - Note that kerneldoc doesn’t have support for markdown syntax (or anything else like that) and doesn’t do automatic cross-referencing like gtk-doc. So if you documentation absolutely needs a table or a list you have to do it twice unfortunately: Once as a plain code comment and once as a DocBook marked-up table or list. Long-term we want to improve the kerneldoc markup support, but for now we have to deal with what we have.
- As with all documentation don’t document the details of the implementation - otherwise it will get stale fast because comments are often overlooked when updating code.
- Integrate the new kerneldoc section into the overall DRM DocBook template.
Note that you can’t go deeper than a
section2
nesting for otherwise the reference documentation won’t be lists, and due to the lack of any autogenerated cross-links inaccessible and useless. Build the html docs to check that your overview summary and reference sections have all been pulled in and that the kerneldoc parser is happy with your comments.
A really nice example for how to do this all is the documentation for the
gen7 cmd parser in i915_cmd_parser.c
.