todo.rst 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394
  1. .. _todo:
  2. =========
  3. TODO list
  4. =========
  5. This section contains a list of smaller janitorial tasks in the kernel DRM
  6. graphics subsystem useful as newbie projects. Or for slow rainy days.
  7. Subsystem-wide refactorings
  8. ===========================
  9. De-midlayer drivers
  10. -------------------
  11. With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
  12. to have a ``drm_bus`` structure set up. Drivers can directly set up the
  13. ``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
  14. and ``drm_pci.c``. The goal is to get rid of the driver's ``->load`` /
  15. ``->unload`` callbacks and open-code the load/unload sequence properly, using
  16. the new two-stage ``drm_device`` setup/teardown.
  17. Once all existing drivers are converted we can also remove those bus support
  18. files for USB and platform devices.
  19. All you need is a GPU for a non-converted driver (currently almost all of
  20. them, but also all the virtual ones used by KVM, so everyone qualifies).
  21. Contact: Daniel Vetter, Thierry Reding, respective driver maintainers
  22. Switch from reference/unreference to get/put
  23. --------------------------------------------
  24. For some reason DRM core uses ``reference``/``unreference`` suffixes for
  25. refcounting functions, but kernel uses ``get``/``put`` (e.g.
  26. ``kref_get``/``put()``). It would be good to switch over for consistency, and
  27. it's shorter. Needs to be done in 3 steps for each pair of functions:
  28. * Create new ``get``/``put`` functions, define the old names as compatibility
  29. wrappers
  30. * Switch over each file/driver using a cocci-generated spatch.
  31. * Once all users of the old names are gone, remove them.
  32. This way drivers/patches in the progress of getting merged won't break.
  33. Contact: Daniel Vetter
  34. Convert existing KMS drivers to atomic modesetting
  35. --------------------------------------------------
  36. 3.19 has the atomic modeset interfaces and helpers, so drivers can now be
  37. converted over. Modern compositors like Wayland or Surfaceflinger on Android
  38. really want an atomic modeset interface, so this is all about the bright
  39. future.
  40. There is a conversion guide for atomic and all you need is a GPU for a
  41. non-converted driver (again virtual HW drivers for KVM are still all
  42. suitable).
  43. As part of this drivers also need to convert to universal plane (which means
  44. exposing primary & cursor as proper plane objects). But that's much easier to
  45. do by directly using the new atomic helper driver callbacks.
  46. Contact: Daniel Vetter, respective driver maintainers
  47. Clean up the clipped coordination confusion around planes
  48. ---------------------------------------------------------
  49. We have a helper to get this right with drm_plane_helper_check_update(), but
  50. it's not consistently used. This should be fixed, preferrably in the atomic
  51. helpers (and drivers then moved over to clipped coordinates). Probably the
  52. helper should also be moved from drm_plane_helper.c to the atomic helpers, to
  53. avoid confusion - the other helpers in that file are all deprecated legacy
  54. helpers.
  55. Contact: Ville Syrjälä, Daniel Vetter, driver maintainers
  56. Implement deferred fbdev setup in the helper
  57. --------------------------------------------
  58. Many (especially embedded drivers) want to delay fbdev setup until there's a
  59. real screen plugged in. This is to avoid the dreaded fallback to the low-res
  60. fbdev default. Many drivers have a hacked-up (and often broken) version of this,
  61. better to do it once in the shared helpers. Thierry has a patch series, but that
  62. one needs to be rebased and final polish applied.
  63. Contact: Thierry Reding, Daniel Vetter, driver maintainers
  64. Convert early atomic drivers to async commit helpers
  65. ----------------------------------------------------
  66. For the first year the atomic modeset helpers didn't support asynchronous /
  67. nonblocking commits, and every driver had to hand-roll them. This is fixed
  68. now, but there's still a pile of existing drivers that easily could be
  69. converted over to the new infrastructure.
  70. One issue with the helpers is that they require that drivers handle completion
  71. events for atomic commits correctly. But fixing these bugs is good anyway.
  72. Contact: Daniel Vetter, respective driver maintainers
  73. Better manual-upload support for atomic
  74. ---------------------------------------
  75. This would be especially useful for tinydrm:
  76. - Add a struct drm_rect dirty_clip to drm_crtc_state. When duplicating the
  77. crtc state, clear that to the max values, x/y = 0 and w/h = MAX_INT, in
  78. __drm_atomic_helper_crtc_duplicate_state().
  79. - Move tinydrm_merge_clips into drm_framebuffer.c, dropping the tinydrm_
  80. prefix ofc and using drm_fb_. drm_framebuffer.c makes sense since this
  81. is a function useful to implement the fb->dirty function.
  82. - Create a new drm_fb_dirty function which does essentially what e.g.
  83. mipi_dbi_fb_dirty does. You can use e.g. drm_atomic_helper_update_plane as the
  84. template. But instead of doing a simple full-screen plane update, this new
  85. helper also sets crtc_state->dirty_clip to the right coordinates. And of
  86. course it needs to check whether the fb is actually active (and maybe where),
  87. so there's some book-keeping involved. There's also some good fun involved in
  88. scaling things appropriately. For that case we might simply give up and
  89. declare the entire area covered by the plane as dirty.
  90. Contact: Noralf Trønnes, Daniel Vetter
  91. Fallout from atomic KMS
  92. -----------------------
  93. ``drm_atomic_helper.c`` provides a batch of functions which implement legacy
  94. IOCTLs on top of the new atomic driver interface. Which is really nice for
  95. gradual conversion of drivers, but unfortunately the semantic mismatches are
  96. a bit too severe. So there's some follow-up work to adjust the function
  97. interfaces to fix these issues:
  98. * atomic needs the lock acquire context. At the moment that's passed around
  99. implicitly with some horrible hacks, and it's also allocate with
  100. ``GFP_NOFAIL`` behind the scenes. All legacy paths need to start allocating
  101. the acquire context explicitly on stack and then also pass it down into
  102. drivers explicitly so that the legacy-on-atomic functions can use them.
  103. * A bunch of the vtable hooks are now in the wrong place: DRM has a split
  104. between core vfunc tables (named ``drm_foo_funcs``), which are used to
  105. implement the userspace ABI. And then there's the optional hooks for the
  106. helper libraries (name ``drm_foo_helper_funcs``), which are purely for
  107. internal use. Some of these hooks should be move from ``_funcs`` to
  108. ``_helper_funcs`` since they are not part of the core ABI. There's a
  109. ``FIXME`` comment in the kerneldoc for each such case in ``drm_crtc.h``.
  110. * There's a new helper ``drm_atomic_helper_best_encoder()`` which could be
  111. used by all atomic drivers which don't select the encoder for a given
  112. connector at runtime. That's almost all of them, and would allow us to get
  113. rid of a lot of ``best_encoder`` boilerplate in drivers.
  114. Contact: Daniel Vetter
  115. Get rid of dev->struct_mutex from GEM drivers
  116. ---------------------------------------------
  117. ``dev->struct_mutex`` is the Big DRM Lock from legacy days and infested
  118. everything. Nowadays in modern drivers the only bit where it's mandatory is
  119. serializing GEM buffer object destruction. Which unfortunately means drivers
  120. have to keep track of that lock and either call ``unreference`` or
  121. ``unreference_locked`` depending upon context.
  122. Core GEM doesn't have a need for ``struct_mutex`` any more since kernel 4.8,
  123. and there's a ``gem_free_object_unlocked`` callback for any drivers which are
  124. entirely ``struct_mutex`` free.
  125. For drivers that need ``struct_mutex`` it should be replaced with a driver-
  126. private lock. The tricky part is the BO free functions, since those can't
  127. reliably take that lock any more. Instead state needs to be protected with
  128. suitable subordinate locks or some cleanup work pushed to a worker thread. For
  129. performance-critical drivers it might also be better to go with a more
  130. fine-grained per-buffer object and per-context lockings scheme. Currently the
  131. following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
  132. ``udl``.
  133. Contact: Daniel Vetter, respective driver maintainers
  134. Core refactorings
  135. =================
  136. Use new IDR deletion interface to clean up drm_gem_handle_delete()
  137. ------------------------------------------------------------------
  138. See the "This is gross" comment -- apparently the IDR system now can return an
  139. error code instead of oopsing.
  140. Clean up the DRM header mess
  141. ----------------------------
  142. Currently the DRM subsystem has only one global header, ``drmP.h``. This is
  143. used both for functions exported to helper libraries and drivers and functions
  144. only used internally in the ``drm.ko`` module. The goal would be to move all
  145. header declarations not needed outside of ``drm.ko`` into
  146. ``drivers/gpu/drm/drm_*_internal.h`` header files. ``EXPORT_SYMBOL`` also
  147. needs to be dropped for these functions.
  148. This would nicely tie in with the below task to create kerneldoc after the API
  149. is cleaned up. Or with the "hide legacy cruft better" task.
  150. Note that this is well in progress, but ``drmP.h`` is still huge. The updated
  151. plan is to switch to per-file driver API headers, which will also structure
  152. the kerneldoc better. This should also allow more fine-grained ``#include``
  153. directives.
  154. In the end no .c file should need to include ``drmP.h`` anymore.
  155. Contact: Daniel Vetter
  156. Add missing kerneldoc for exported functions
  157. --------------------------------------------
  158. The DRM reference documentation is still lacking kerneldoc in a few areas. The
  159. task would be to clean up interfaces like moving functions around between
  160. files to better group them and improving the interfaces like dropping return
  161. values for functions that never fail. Then write kerneldoc for all exported
  162. functions and an overview section and integrate it all into the drm book.
  163. See https://dri.freedesktop.org/docs/drm/ for what's there already.
  164. Contact: Daniel Vetter
  165. Hide legacy cruft better
  166. ------------------------
  167. Way back DRM supported only drivers which shadow-attached to PCI devices with
  168. userspace or fbdev drivers setting up outputs. Modern DRM drivers take charge
  169. of the entire device, you can spot them with the DRIVER_MODESET flag.
  170. Unfortunately there's still large piles of legacy code around which needs to
  171. be hidden so that driver writers don't accidentally end up using it. And to
  172. prevent security issues in those legacy IOCTLs from being exploited on modern
  173. drivers. This has multiple possible subtasks:
  174. * Extract support code for legacy features into a ``drm-legacy.ko`` kernel
  175. module and compile it only when one of the legacy drivers is enabled.
  176. This is mostly done, the only thing left is to split up ``drm_irq.c`` into
  177. legacy cruft and the parts needed by modern KMS drivers.
  178. Contact: Daniel Vetter
  179. Make panic handling work
  180. ------------------------
  181. This is a really varied tasks with lots of little bits and pieces:
  182. * The panic path can't be tested currently, leading to constant breaking. The
  183. main issue here is that panics can be triggered from hardirq contexts and
  184. hence all panic related callback can run in hardirq context. It would be
  185. awesome if we could test at least the fbdev helper code and driver code by
  186. e.g. trigger calls through drm debugfs files. hardirq context could be
  187. achieved by using an IPI to the local processor.
  188. * There's a massive confusion of different panic handlers. DRM fbdev emulation
  189. helpers have one, but on top of that the fbcon code itself also has one. We
  190. need to make sure that they stop fighting over each another.
  191. * ``drm_can_sleep()`` is a mess. It hides real bugs in normal operations and
  192. isn't a full solution for panic paths. We need to make sure that it only
  193. returns true if there's a panic going on for real, and fix up all the
  194. fallout.
  195. * The panic handler must never sleep, which also means it can't ever
  196. ``mutex_lock()``. Also it can't grab any other lock unconditionally, not
  197. even spinlocks (because NMI and hardirq can panic too). We need to either
  198. make sure to not call such paths, or trylock everything. Really tricky.
  199. * For the above locking troubles reasons it's pretty much impossible to
  200. attempt a synchronous modeset from panic handlers. The only thing we could
  201. try to achive is an atomic ``set_base`` of the primary plane, and hope that
  202. it shows up. Everything else probably needs to be delayed to some worker or
  203. something else which happens later on. Otherwise it just kills the box
  204. harder, prevent the panic from going out on e.g. netconsole.
  205. * There's also proposal for a simplied DRM console instead of the full-blown
  206. fbcon and DRM fbdev emulation. Any kind of panic handling tricks should
  207. obviously work for both console, in case we ever get kmslog merged.
  208. Contact: Daniel Vetter
  209. Clean up the debugfs support
  210. ----------------------------
  211. There's a bunch of issues with it:
  212. - The drm_info_list ->show() function doesn't even bother to cast to the drm
  213. structure for you. This is lazy.
  214. - We probably want to have some support for debugfs files on crtc/connectors and
  215. maybe other kms objects directly in core. There's even drm_print support in
  216. the funcs for these objects to dump kms state, so it's all there. And then the
  217. ->show() functions should obviously give you a pointer to the right object.
  218. - The drm_info_list stuff is centered on drm_minor instead of drm_device. For
  219. anything we want to print drm_device (or maybe drm_file) is the right thing.
  220. - The drm_driver->debugfs_init hooks we have is just an artifact of the old
  221. midlayered load sequence. DRM debugfs should work more like sysfs, where you
  222. can create properties/files for an object anytime you want, and the core
  223. takes care of publishing/unpuplishing all the files at register/unregister
  224. time. Drivers shouldn't need to worry about these technicalities, and fixing
  225. this (together with the drm_minor->drm_device move) would allow us to remove
  226. debugfs_init.
  227. Contact: Daniel Vetter
  228. Better Testing
  229. ==============
  230. Enable trinity for DRM
  231. ----------------------
  232. And fix up the fallout. Should be really interesting ...
  233. Make KMS tests in i-g-t generic
  234. -------------------------------
  235. The i915 driver team maintains an extensive testsuite for the i915 DRM driver,
  236. including tons of testcases for corner-cases in the modesetting API. It would
  237. be awesome if those tests (at least the ones not relying on Intel-specific GEM
  238. features) could be made to run on any KMS driver.
  239. Basic work to run i-g-t tests on non-i915 is done, what's now missing is mass-
  240. converting things over. For modeset tests we also first need a bit of
  241. infrastructure to use dumb buffers for untiled buffers, to be able to run all
  242. the non-i915 specific modeset tests.
  243. Contact: Daniel Vetter
  244. Create a virtual KMS driver for testing (vkms)
  245. ----------------------------------------------
  246. With all the latest helpers it should be fairly simple to create a virtual KMS
  247. driver useful for testing, or for running X or similar on headless machines
  248. (to be able to still use the GPU). This would be similar to vgem, but aimed at
  249. the modeset side.
  250. Once the basics are there there's tons of possibilities to extend it.
  251. Contact: Daniel Vetter
  252. Driver Specific
  253. ===============
  254. tinydrm
  255. -------
  256. Tinydrm is the helper driver for really simple fb drivers. The goal is to make
  257. those drivers as simple as possible, so lots of room for refactoring:
  258. - backlight helpers, probably best to put them into a new drm_backlight.c.
  259. This is because drivers/video is de-facto unmaintained. We could also
  260. move drivers/video/backlight to drivers/gpu/backlight and take it all
  261. over within drm-misc, but that's more work.
  262. - spi helpers, probably best put into spi core/helper code. Thierry said
  263. the spi maintainer is fast&reactive, so shouldn't be a big issue.
  264. - extract the mipi-dbi helper (well, the non-tinydrm specific parts at
  265. least) into a separate helper, like we have for mipi-dsi already. Or follow
  266. one of the ideas for having a shared dsi/dbi helper, abstracting away the
  267. transport details more.
  268. - tinydrm_lastclose could be drm_fb_helper_lastclose. Only thing we need
  269. for that is to store the drm_fb_helper pointer somewhere in
  270. drm_device->mode_config. And then we could roll that out to all the
  271. drivers.
  272. - tinydrm_gem_cma_prime_import_sg_table should probably go into the cma
  273. helpers, as a _vmapped variant (since not every driver needs the vmap).
  274. And tinydrm_gem_cma_free_object could the be merged into
  275. drm_gem_cma_free_object().
  276. - tinydrm_fb_create we could move into drm_simple_pipe, only need to add
  277. the fb_create hook to drm_simple_pipe_funcs, which would again simplify a
  278. bunch of things (since it gives you a one-stop vfunc for simple drivers).
  279. - Quick aside: The unregister devm stuff is kinda getting the lifetimes of
  280. a drm_device wrong. Doesn't matter, since everyone else gets it wrong
  281. too :-)
  282. - With the fbdev pointer in dev->mode_config we could also make
  283. suspend/resume helpers entirely generic, at least if we add a
  284. dev->mode_config.suspend_state. We could even provide a generic pm_ops
  285. structure with those.
  286. - also rework the drm_framebuffer_funcs->dirty hook wire-up, see above.
  287. Contact: Noralf Trønnes, Daniel Vetter
  288. Outside DRM
  289. ===========