]> git.proxmox.com Git - mirror_ubuntu-bionic-kernel.git/blame - Documentation/gpu/todo.rst
drm/docs: Record TODO about plane clipping
[mirror_ubuntu-bionic-kernel.git] / Documentation / gpu / todo.rst
CommitLineData
0e70dad0
TR
1.. _todo:
2
3=========
4TODO list
5=========
6
7This section contains a list of smaller janitorial tasks in the kernel DRM
8graphics subsystem useful as newbie projects. Or for slow rainy days.
9
10Subsystem-wide refactorings
11===========================
12
13De-midlayer drivers
14-------------------
15
16With the recent ``drm_bus`` cleanup patches for 3.17 it is no longer required
17to have a ``drm_bus`` structure set up. Drivers can directly set up the
18``drm_device`` structure instead of relying on bus methods in ``drm_usb.c``
19and ``drm_platform.c``. The goal is to get rid of the driver's ``->load`` /
20``->unload`` callbacks and open-code the load/unload sequence properly, using
21the new two-stage ``drm_device`` setup/teardown.
22
23Once all existing drivers are converted we can also remove those bus support
24files for USB and platform devices.
25
26All you need is a GPU for a non-converted driver (currently almost all of
27them, but also all the virtual ones used by KVM, so everyone qualifies).
28
29Contact: Daniel Vetter, Thierry Reding, respective driver maintainers
30
31Switch from reference/unreference to get/put
32--------------------------------------------
33
34For some reason DRM core uses ``reference``/``unreference`` suffixes for
35refcounting functions, but kernel uses ``get``/``put`` (e.g.
36``kref_get``/``put()``). It would be good to switch over for consistency, and
37it's shorter. Needs to be done in 3 steps for each pair of functions:
38
39* Create new ``get``/``put`` functions, define the old names as compatibility
40 wrappers
41* Switch over each file/driver using a cocci-generated spatch.
42* Once all users of the old names are gone, remove them.
43
44This way drivers/patches in the progress of getting merged won't break.
45
46Contact: Daniel Vetter
47
48Convert existing KMS drivers to atomic modesetting
49--------------------------------------------------
50
513.19 has the atomic modeset interfaces and helpers, so drivers can now be
52converted over. Modern compositors like Wayland or Surfaceflinger on Android
53really want an atomic modeset interface, so this is all about the bright
54future.
55
56There is a conversion guide for atomic and all you need is a GPU for a
57non-converted driver (again virtual HW drivers for KVM are still all
58suitable).
59
60As part of this drivers also need to convert to universal plane (which means
61exposing primary & cursor as proper plane objects). But that's much easier to
62do by directly using the new atomic helper driver callbacks.
63
64Contact: Daniel Vetter, respective driver maintainers
1a80cc1c
DV
65
66Clean up the clipped coordination confusion around planes
67---------------------------------------------------------
68
69We have a helper to get this right with drm_plane_helper_check_update(), but
70it's not consistently used. This should be fixed, preferrably in the atomic
71helpers (and drivers then moved over to clipped coordinates). Probably the
72helper should also be moved from drm_plane_helper.c to the atomic helpers, to
73avoid confusion - the other helpers in that file are all deprecated legacy
74helpers.
75
76Contact: Ville Syrjälä, Daniel Vetter, driver maintainers
0e70dad0
TR
77
78Convert early atomic drivers to async commit helpers
79----------------------------------------------------
80
81For the first year the atomic modeset helpers didn't support asynchronous /
82nonblocking commits, and every driver had to hand-roll them. This is fixed
83now, but there's still a pile of existing drivers that easily could be
84converted over to the new infrastructure.
85
86One issue with the helpers is that they require that drivers handle completion
87events for atomic commits correctly. But fixing these bugs is good anyway.
88
89Contact: Daniel Vetter, respective driver maintainers
90
91Fallout from atomic KMS
92-----------------------
93
94``drm_atomic_helper.c`` provides a batch of functions which implement legacy
95IOCTLs on top of the new atomic driver interface. Which is really nice for
96gradual conversion of drivers, but unfortunately the semantic mismatches are
97a bit too severe. So there's some follow-up work to adjust the function
98interfaces to fix these issues:
99
100* atomic needs the lock acquire context. At the moment that's passed around
101 implicitly with some horrible hacks, and it's also allocate with
102 ``GFP_NOFAIL`` behind the scenes. All legacy paths need to start allocating
103 the acquire context explicitly on stack and then also pass it down into
104 drivers explicitly so that the legacy-on-atomic functions can use them.
105
106* A bunch of the vtable hooks are now in the wrong place: DRM has a split
107 between core vfunc tables (named ``drm_foo_funcs``), which are used to
108 implement the userspace ABI. And then there's the optional hooks for the
109 helper libraries (name ``drm_foo_helper_funcs``), which are purely for
110 internal use. Some of these hooks should be move from ``_funcs`` to
111 ``_helper_funcs`` since they are not part of the core ABI. There's a
112 ``FIXME`` comment in the kerneldoc for each such case in ``drm_crtc.h``.
113
114* There's a new helper ``drm_atomic_helper_best_encoder()`` which could be
115 used by all atomic drivers which don't select the encoder for a given
116 connector at runtime. That's almost all of them, and would allow us to get
117 rid of a lot of ``best_encoder`` boilerplate in drivers.
118
119Contact: Daniel Vetter
120
121Get rid of dev->struct_mutex from GEM drivers
122---------------------------------------------
123
124``dev->struct_mutex`` is the Big DRM Lock from legacy days and infested
125everything. Nowadays in modern drivers the only bit where it's mandatory is
126serializing GEM buffer object destruction. Which unfortunately means drivers
127have to keep track of that lock and either call ``unreference`` or
128``unreference_locked`` depending upon context.
129
130Core GEM doesn't have a need for ``struct_mutex`` any more since kernel 4.8,
131and there's a ``gem_free_object_unlocked`` callback for any drivers which are
132entirely ``struct_mutex`` free.
133
134For drivers that need ``struct_mutex`` it should be replaced with a driver-
135private lock. The tricky part is the BO free functions, since those can't
136reliably take that lock any more. Instead state needs to be protected with
137suitable subordinate locks or some cleanup work pushed to a worker thread. For
138performance-critical drivers it might also be better to go with a more
139fine-grained per-buffer object and per-context lockings scheme. Currently the
140following drivers still use ``struct_mutex``: ``msm``, ``omapdrm`` and
141``udl``.
142
143Contact: Daniel Vetter
144
145Core refactorings
146=================
147
148Use new IDR deletion interface to clean up drm_gem_handle_delete()
149------------------------------------------------------------------
150
151See the "This is gross" comment -- apparently the IDR system now can return an
152error code instead of oopsing.
153
154Clean up the DRM header mess
155----------------------------
156
157Currently the DRM subsystem has only one global header, ``drmP.h``. This is
158used both for functions exported to helper libraries and drivers and functions
159only used internally in the ``drm.ko`` module. The goal would be to move all
160header declarations not needed outside of ``drm.ko`` into
161``drivers/gpu/drm/drm_*_internal.h`` header files. ``EXPORT_SYMBOL`` also
162needs to be dropped for these functions.
163
164This would nicely tie in with the below task to create kerneldoc after the API
165is cleaned up. Or with the "hide legacy cruft better" task.
166
167Note that this is well in progress, but ``drmP.h`` is still huge. The updated
168plan is to switch to per-file driver API headers, which will also structure
169the kerneldoc better. This should also allow more fine-grained ``#include``
170directives.
171
172Contact: Daniel Vetter
173
174Add missing kerneldoc for exported functions
175--------------------------------------------
176
177The DRM reference documentation is still lacking kerneldoc in a few areas. The
178task would be to clean up interfaces like moving functions around between
179files to better group them and improving the interfaces like dropping return
180values for functions that never fail. Then write kerneldoc for all exported
181functions and an overview section and integrate it all into the drm DocBook.
182
183See https://dri.freedesktop.org/docs/drm/ for what's there already.
184
185Contact: Daniel Vetter
186
187Hide legacy cruft better
188------------------------
189
190Way back DRM supported only drivers which shadow-attached to PCI devices with
191userspace or fbdev drivers setting up outputs. Modern DRM drivers take charge
192of the entire device, you can spot them with the DRIVER_MODESET flag.
193
194Unfortunately there's still large piles of legacy code around which needs to
195be hidden so that driver writers don't accidentally end up using it. And to
196prevent security issues in those legacy IOCTLs from being exploited on modern
197drivers. This has multiple possible subtasks:
198
199* Make sure legacy IOCTLs can't be used on modern drivers.
200* Extract support code for legacy features into a ``drm-legacy.ko`` kernel
201 module and compile it only when one of the legacy drivers is enabled.
202* Extract legacy functions into their own headers and remove it that from the
203 monolithic ``drmP.h`` header.
204* Remove any lingering cruft from the OS abstraction layer from modern
205 drivers.
206
207This is mostly done, the only thing left is to split up ``drm_irq.c`` into
208legacy cruft and the parts needed by modern KMS drivers.
209
210Contact: Daniel Vetter
211
212Make panic handling work
213------------------------
214
215This is a really varied tasks with lots of little bits and pieces:
216
217* The panic path can't be tested currently, leading to constant breaking. The
218 main issue here is that panics can be triggered from hardirq contexts and
219 hence all panic related callback can run in hardirq context. It would be
220 awesome if we could test at least the fbdev helper code and driver code by
221 e.g. trigger calls through drm debugfs files. hardirq context could be
222 achieved by using an IPI to the local processor.
223
224* There's a massive confusion of different panic handlers. DRM fbdev emulation
225 helpers have one, but on top of that the fbcon code itself also has one. We
226 need to make sure that they stop fighting over each another.
227
228* ``drm_can_sleep()`` is a mess. It hides real bugs in normal operations and
229 isn't a full solution for panic paths. We need to make sure that it only
230 returns true if there's a panic going on for real, and fix up all the
231 fallout.
232
233* The panic handler must never sleep, which also means it can't ever
234 ``mutex_lock()``. Also it can't grab any other lock unconditionally, not
235 even spinlocks (because NMI and hardirq can panic too). We need to either
236 make sure to not call such paths, or trylock everything. Really tricky.
237
238* For the above locking troubles reasons it's pretty much impossible to
239 attempt a synchronous modeset from panic handlers. The only thing we could
240 try to achive is an atomic ``set_base`` of the primary plane, and hope that
241 it shows up. Everything else probably needs to be delayed to some worker or
242 something else which happens later on. Otherwise it just kills the box
243 harder, prevent the panic from going out on e.g. netconsole.
244
245* There's also proposal for a simplied DRM console instead of the full-blown
246 fbcon and DRM fbdev emulation. Any kind of panic handling tricks should
247 obviously work for both console, in case we ever get kmslog merged.
248
249Contact: Daniel Vetter
250
251Better Testing
252==============
253
254Enable trinity for DRM
255----------------------
256
257And fix up the fallout. Should be really interesting ...
258
259Make KMS tests in i-g-t generic
260-------------------------------
261
262The i915 driver team maintains an extensive testsuite for the i915 DRM driver,
263including tons of testcases for corner-cases in the modesetting API. It would
264be awesome if those tests (at least the ones not relying on Intel-specific GEM
265features) could be made to run on any KMS driver.
266
267Basic work to run i-g-t tests on non-i915 is done, what's now missing is mass-
268converting things over. For modeset tests we also first need a bit of
269infrastructure to use dumb buffers for untiled buffers, to be able to run all
270the non-i915 specific modeset tests.
271
272Contact: Daniel Vetter
273
274Create a virtual KMS driver for testing (vkms)
275----------------------------------------------
276
277With all the latest helpers it should be fairly simple to create a virtual KMS
278driver useful for testing, or for running X or similar on headless machines
279(to be able to still use the GPU). This would be similar to vgem, but aimed at
280the modeset side.
281
282Once the basics are there there's tons of possibilities to extend it.
283
284Contact: Daniel Vetter
285
286Driver Specific
287===============
288
289Outside DRM
290===========
291
292Better kerneldoc
293----------------
294
295This is pretty much done, but there's some advanced topics:
296
297Come up with a way to hyperlink to struct members. Currently you can hyperlink
298to the struct using ``#struct_name``, but not to a member within. Would need
299buy-in from kerneldoc maintainers, and the big question is how to make it work
300without totally unsightly
301``drm_foo_bar_really_long_structure->even_longer_memeber`` all over the text
302which breaks text flow.
303
304Figure out how to integrate the asciidoc support for ascii-diagrams. We have a
305few of those (e.g. to describe mode timings), and asciidoc supports converting
306some ascii-art dialect into pngs. Would be really pretty to make that work.
307
308Contact: Daniel Vetter, Jani Nikula
309
310Jani is working on this already, hopefully lands in 4.8.