1*4882a593Smuzhiyun.. _todo: 2*4882a593Smuzhiyun 3*4882a593Smuzhiyun========= 4*4882a593SmuzhiyunTODO list 5*4882a593Smuzhiyun========= 6*4882a593Smuzhiyun 7*4882a593SmuzhiyunThis section contains a list of smaller janitorial tasks in the kernel DRM 8*4882a593Smuzhiyungraphics subsystem useful as newbie projects. Or for slow rainy days. 9*4882a593Smuzhiyun 10*4882a593SmuzhiyunDifficulty 11*4882a593Smuzhiyun---------- 12*4882a593Smuzhiyun 13*4882a593SmuzhiyunTo make it easier task are categorized into different levels: 14*4882a593Smuzhiyun 15*4882a593SmuzhiyunStarter: Good tasks to get started with the DRM subsystem. 16*4882a593Smuzhiyun 17*4882a593SmuzhiyunIntermediate: Tasks which need some experience with working in the DRM 18*4882a593Smuzhiyunsubsystem, or some specific GPU/display graphics knowledge. For debugging issue 19*4882a593Smuzhiyunit's good to have the relevant hardware (or a virtual driver set up) available 20*4882a593Smuzhiyunfor testing. 21*4882a593Smuzhiyun 22*4882a593SmuzhiyunAdvanced: Tricky tasks that need fairly good understanding of the DRM subsystem 23*4882a593Smuzhiyunand graphics topics. Generally need the relevant hardware for development and 24*4882a593Smuzhiyuntesting. 25*4882a593Smuzhiyun 26*4882a593SmuzhiyunSubsystem-wide refactorings 27*4882a593Smuzhiyun=========================== 28*4882a593Smuzhiyun 29*4882a593SmuzhiyunRemove custom dumb_map_offset implementations 30*4882a593Smuzhiyun--------------------------------------------- 31*4882a593Smuzhiyun 32*4882a593SmuzhiyunAll GEM based drivers should be using drm_gem_create_mmap_offset() instead. 33*4882a593SmuzhiyunAudit each individual driver, make sure it'll work with the generic 34*4882a593Smuzhiyunimplementation (there's lots of outdated locking leftovers in various 35*4882a593Smuzhiyunimplementations), and then remove it. 36*4882a593Smuzhiyun 37*4882a593SmuzhiyunContact: Daniel Vetter, respective driver maintainers 38*4882a593Smuzhiyun 39*4882a593SmuzhiyunLevel: Intermediate 40*4882a593Smuzhiyun 41*4882a593SmuzhiyunConvert existing KMS drivers to atomic modesetting 42*4882a593Smuzhiyun-------------------------------------------------- 43*4882a593Smuzhiyun 44*4882a593Smuzhiyun3.19 has the atomic modeset interfaces and helpers, so drivers can now be 45*4882a593Smuzhiyunconverted over. Modern compositors like Wayland or Surfaceflinger on Android 46*4882a593Smuzhiyunreally want an atomic modeset interface, so this is all about the bright 47*4882a593Smuzhiyunfuture. 48*4882a593Smuzhiyun 49*4882a593SmuzhiyunThere is a conversion guide for atomic and all you need is a GPU for a 50*4882a593Smuzhiyunnon-converted driver (again virtual HW drivers for KVM are still all 51*4882a593Smuzhiyunsuitable). 52*4882a593Smuzhiyun 53*4882a593SmuzhiyunAs part of this drivers also need to convert to universal plane (which means 54*4882a593Smuzhiyunexposing primary & cursor as proper plane objects). But that's much easier to 55*4882a593Smuzhiyundo by directly using the new atomic helper driver callbacks. 56*4882a593Smuzhiyun 57*4882a593SmuzhiyunContact: Daniel Vetter, respective driver maintainers 58*4882a593Smuzhiyun 59*4882a593SmuzhiyunLevel: Advanced 60*4882a593Smuzhiyun 61*4882a593SmuzhiyunClean up the clipped coordination confusion around planes 62*4882a593Smuzhiyun--------------------------------------------------------- 63*4882a593Smuzhiyun 64*4882a593SmuzhiyunWe have a helper to get this right with drm_plane_helper_check_update(), but 65*4882a593Smuzhiyunit's not consistently used. This should be fixed, preferrably in the atomic 66*4882a593Smuzhiyunhelpers (and drivers then moved over to clipped coordinates). Probably the 67*4882a593Smuzhiyunhelper should also be moved from drm_plane_helper.c to the atomic helpers, to 68*4882a593Smuzhiyunavoid confusion - the other helpers in that file are all deprecated legacy 69*4882a593Smuzhiyunhelpers. 70*4882a593Smuzhiyun 71*4882a593SmuzhiyunContact: Ville Syrjälä, Daniel Vetter, driver maintainers 72*4882a593Smuzhiyun 73*4882a593SmuzhiyunLevel: Advanced 74*4882a593Smuzhiyun 75*4882a593SmuzhiyunImprove plane atomic_check helpers 76*4882a593Smuzhiyun---------------------------------- 77*4882a593Smuzhiyun 78*4882a593SmuzhiyunAside from the clipped coordinates right above there's a few suboptimal things 79*4882a593Smuzhiyunwith the current helpers: 80*4882a593Smuzhiyun 81*4882a593Smuzhiyun- drm_plane_helper_funcs->atomic_check gets called for enabled or disabled 82*4882a593Smuzhiyun planes. At best this seems to confuse drivers, worst it means they blow up 83*4882a593Smuzhiyun when the plane is disabled without the CRTC. The only special handling is 84*4882a593Smuzhiyun resetting values in the plane state structures, which instead should be moved 85*4882a593Smuzhiyun into the drm_plane_funcs->atomic_duplicate_state functions. 86*4882a593Smuzhiyun 87*4882a593Smuzhiyun- Once that's done, helpers could stop calling ->atomic_check for disabled 88*4882a593Smuzhiyun planes. 89*4882a593Smuzhiyun 90*4882a593Smuzhiyun- Then we could go through all the drivers and remove the more-or-less confused 91*4882a593Smuzhiyun checks for plane_state->fb and plane_state->crtc. 92*4882a593Smuzhiyun 93*4882a593SmuzhiyunContact: Daniel Vetter 94*4882a593Smuzhiyun 95*4882a593SmuzhiyunLevel: Advanced 96*4882a593Smuzhiyun 97*4882a593SmuzhiyunConvert early atomic drivers to async commit helpers 98*4882a593Smuzhiyun---------------------------------------------------- 99*4882a593Smuzhiyun 100*4882a593SmuzhiyunFor the first year the atomic modeset helpers didn't support asynchronous / 101*4882a593Smuzhiyunnonblocking commits, and every driver had to hand-roll them. This is fixed 102*4882a593Smuzhiyunnow, but there's still a pile of existing drivers that easily could be 103*4882a593Smuzhiyunconverted over to the new infrastructure. 104*4882a593Smuzhiyun 105*4882a593SmuzhiyunOne issue with the helpers is that they require that drivers handle completion 106*4882a593Smuzhiyunevents for atomic commits correctly. But fixing these bugs is good anyway. 107*4882a593Smuzhiyun 108*4882a593SmuzhiyunContact: Daniel Vetter, respective driver maintainers 109*4882a593Smuzhiyun 110*4882a593SmuzhiyunLevel: Advanced 111*4882a593Smuzhiyun 112*4882a593SmuzhiyunFallout from atomic KMS 113*4882a593Smuzhiyun----------------------- 114*4882a593Smuzhiyun 115*4882a593Smuzhiyun``drm_atomic_helper.c`` provides a batch of functions which implement legacy 116*4882a593SmuzhiyunIOCTLs on top of the new atomic driver interface. Which is really nice for 117*4882a593Smuzhiyungradual conversion of drivers, but unfortunately the semantic mismatches are 118*4882a593Smuzhiyuna bit too severe. So there's some follow-up work to adjust the function 119*4882a593Smuzhiyuninterfaces to fix these issues: 120*4882a593Smuzhiyun 121*4882a593Smuzhiyun* atomic needs the lock acquire context. At the moment that's passed around 122*4882a593Smuzhiyun implicitly with some horrible hacks, and it's also allocate with 123*4882a593Smuzhiyun ``GFP_NOFAIL`` behind the scenes. All legacy paths need to start allocating 124*4882a593Smuzhiyun the acquire context explicitly on stack and then also pass it down into 125*4882a593Smuzhiyun drivers explicitly so that the legacy-on-atomic functions can use them. 126*4882a593Smuzhiyun 127*4882a593Smuzhiyun Except for some driver code this is done. This task should be finished by 128*4882a593Smuzhiyun adding WARN_ON(!drm_drv_uses_atomic_modeset) in drm_modeset_lock_all(). 129*4882a593Smuzhiyun 130*4882a593Smuzhiyun* A bunch of the vtable hooks are now in the wrong place: DRM has a split 131*4882a593Smuzhiyun between core vfunc tables (named ``drm_foo_funcs``), which are used to 132*4882a593Smuzhiyun implement the userspace ABI. And then there's the optional hooks for the 133*4882a593Smuzhiyun helper libraries (name ``drm_foo_helper_funcs``), which are purely for 134*4882a593Smuzhiyun internal use. Some of these hooks should be move from ``_funcs`` to 135*4882a593Smuzhiyun ``_helper_funcs`` since they are not part of the core ABI. There's a 136*4882a593Smuzhiyun ``FIXME`` comment in the kerneldoc for each such case in ``drm_crtc.h``. 137*4882a593Smuzhiyun 138*4882a593SmuzhiyunContact: Daniel Vetter 139*4882a593Smuzhiyun 140*4882a593SmuzhiyunLevel: Intermediate 141*4882a593Smuzhiyun 142*4882a593SmuzhiyunGet rid of dev->struct_mutex from GEM drivers 143*4882a593Smuzhiyun--------------------------------------------- 144*4882a593Smuzhiyun 145*4882a593Smuzhiyun``dev->struct_mutex`` is the Big DRM Lock from legacy days and infested 146*4882a593Smuzhiyuneverything. Nowadays in modern drivers the only bit where it's mandatory is 147*4882a593Smuzhiyunserializing GEM buffer object destruction. Which unfortunately means drivers 148*4882a593Smuzhiyunhave to keep track of that lock and either call ``unreference`` or 149*4882a593Smuzhiyun``unreference_locked`` depending upon context. 150*4882a593Smuzhiyun 151*4882a593SmuzhiyunCore GEM doesn't have a need for ``struct_mutex`` any more since kernel 4.8, 152*4882a593Smuzhiyunand there's a ``gem_free_object_unlocked`` callback for any drivers which are 153*4882a593Smuzhiyunentirely ``struct_mutex`` free. 154*4882a593Smuzhiyun 155*4882a593SmuzhiyunFor drivers that need ``struct_mutex`` it should be replaced with a driver- 156*4882a593Smuzhiyunprivate lock. The tricky part is the BO free functions, since those can't 157*4882a593Smuzhiyunreliably take that lock any more. Instead state needs to be protected with 158*4882a593Smuzhiyunsuitable subordinate locks or some cleanup work pushed to a worker thread. For 159*4882a593Smuzhiyunperformance-critical drivers it might also be better to go with a more 160*4882a593Smuzhiyunfine-grained per-buffer object and per-context lockings scheme. Currently only 161*4882a593Smuzhiyunthe ``msm`` and `i915` drivers use ``struct_mutex``. 162*4882a593Smuzhiyun 163*4882a593SmuzhiyunContact: Daniel Vetter, respective driver maintainers 164*4882a593Smuzhiyun 165*4882a593SmuzhiyunLevel: Advanced 166*4882a593Smuzhiyun 167*4882a593SmuzhiyunConvert logging to drm_* functions with drm_device paramater 168*4882a593Smuzhiyun------------------------------------------------------------ 169*4882a593Smuzhiyun 170*4882a593SmuzhiyunFor drivers which could have multiple instances, it is necessary to 171*4882a593Smuzhiyundifferentiate between which is which in the logs. Since DRM_INFO/WARN/ERROR 172*4882a593Smuzhiyundon't do this, drivers used dev_info/warn/err to make this differentiation. We 173*4882a593Smuzhiyunnow have drm_* variants of the drm print functions, so we can start to convert 174*4882a593Smuzhiyunthose drivers back to using drm-formatted specific log messages. 175*4882a593Smuzhiyun 176*4882a593SmuzhiyunBefore you start this conversion please contact the relevant maintainers to make 177*4882a593Smuzhiyunsure your work will be merged - not everyone agrees that the DRM dmesg macros 178*4882a593Smuzhiyunare better. 179*4882a593Smuzhiyun 180*4882a593SmuzhiyunContact: Sean Paul, Maintainer of the driver you plan to convert 181*4882a593Smuzhiyun 182*4882a593SmuzhiyunLevel: Starter 183*4882a593Smuzhiyun 184*4882a593SmuzhiyunConvert drivers to use simple modeset suspend/resume 185*4882a593Smuzhiyun---------------------------------------------------- 186*4882a593Smuzhiyun 187*4882a593SmuzhiyunMost drivers (except i915 and nouveau) that use 188*4882a593Smuzhiyundrm_atomic_helper_suspend/resume() can probably be converted to use 189*4882a593Smuzhiyundrm_mode_config_helper_suspend/resume(). Also there's still open-coded version 190*4882a593Smuzhiyunof the atomic suspend/resume code in older atomic modeset drivers. 191*4882a593Smuzhiyun 192*4882a593SmuzhiyunContact: Maintainer of the driver you plan to convert 193*4882a593Smuzhiyun 194*4882a593SmuzhiyunLevel: Intermediate 195*4882a593Smuzhiyun 196*4882a593SmuzhiyunConvert drivers to use drm_fbdev_generic_setup() 197*4882a593Smuzhiyun------------------------------------------------ 198*4882a593Smuzhiyun 199*4882a593SmuzhiyunMost drivers can use drm_fbdev_generic_setup(). Driver have to implement 200*4882a593Smuzhiyunatomic modesetting and GEM vmap support. Current generic fbdev emulation 201*4882a593Smuzhiyunexpects the framebuffer in system memory (or system-like memory). 202*4882a593Smuzhiyun 203*4882a593SmuzhiyunContact: Maintainer of the driver you plan to convert 204*4882a593Smuzhiyun 205*4882a593SmuzhiyunLevel: Intermediate 206*4882a593Smuzhiyun 207*4882a593Smuzhiyundrm_framebuffer_funcs and drm_mode_config_funcs.fb_create cleanup 208*4882a593Smuzhiyun----------------------------------------------------------------- 209*4882a593Smuzhiyun 210*4882a593SmuzhiyunA lot more drivers could be switched over to the drm_gem_framebuffer helpers. 211*4882a593SmuzhiyunVarious hold-ups: 212*4882a593Smuzhiyun 213*4882a593Smuzhiyun- Need to switch over to the generic dirty tracking code using 214*4882a593Smuzhiyun drm_atomic_helper_dirtyfb first (e.g. qxl). 215*4882a593Smuzhiyun 216*4882a593Smuzhiyun- Need to switch to drm_fbdev_generic_setup(), otherwise a lot of the custom fb 217*4882a593Smuzhiyun setup code can't be deleted. 218*4882a593Smuzhiyun 219*4882a593Smuzhiyun- Many drivers wrap drm_gem_fb_create() only to check for valid formats. For 220*4882a593Smuzhiyun atomic drivers we could check for valid formats by calling 221*4882a593Smuzhiyun drm_plane_check_pixel_format() against all planes, and pass if any plane 222*4882a593Smuzhiyun supports the format. For non-atomic that's not possible since like the format 223*4882a593Smuzhiyun list for the primary plane is fake and we'd therefor reject valid formats. 224*4882a593Smuzhiyun 225*4882a593Smuzhiyun- Many drivers subclass drm_framebuffer, we'd need a embedding compatible 226*4882a593Smuzhiyun version of the varios drm_gem_fb_create functions. Maybe called 227*4882a593Smuzhiyun drm_gem_fb_create/_with_dirty/_with_funcs as needed. 228*4882a593Smuzhiyun 229*4882a593SmuzhiyunContact: Daniel Vetter 230*4882a593Smuzhiyun 231*4882a593SmuzhiyunLevel: Intermediate 232*4882a593Smuzhiyun 233*4882a593SmuzhiyunClean up mmap forwarding 234*4882a593Smuzhiyun------------------------ 235*4882a593Smuzhiyun 236*4882a593SmuzhiyunA lot of drivers forward gem mmap calls to dma-buf mmap for imported buffers. 237*4882a593SmuzhiyunAnd also a lot of them forward dma-buf mmap to the gem mmap implementations. 238*4882a593SmuzhiyunThere's drm_gem_prime_mmap() for this now, but still needs to be rolled out. 239*4882a593Smuzhiyun 240*4882a593SmuzhiyunContact: Daniel Vetter 241*4882a593Smuzhiyun 242*4882a593SmuzhiyunLevel: Intermediate 243*4882a593Smuzhiyun 244*4882a593SmuzhiyunGeneric fbdev defio support 245*4882a593Smuzhiyun--------------------------- 246*4882a593Smuzhiyun 247*4882a593SmuzhiyunThe defio support code in the fbdev core has some very specific requirements, 248*4882a593Smuzhiyunwhich means drivers need to have a special framebuffer for fbdev. The main 249*4882a593Smuzhiyunissue is that it uses some fields in struct page itself, which breaks shmem 250*4882a593Smuzhiyungem objects (and other things). To support defio, affected drivers require 251*4882a593Smuzhiyunthe use of a shadow buffer, which may add CPU and memory overhead. 252*4882a593Smuzhiyun 253*4882a593SmuzhiyunPossible solution would be to write our own defio mmap code in the drm fbdev 254*4882a593Smuzhiyunemulation. It would need to fully wrap the existing mmap ops, forwarding 255*4882a593Smuzhiyuneverything after it has done the write-protect/mkwrite trickery: 256*4882a593Smuzhiyun 257*4882a593Smuzhiyun- In the drm_fbdev_fb_mmap helper, if we need defio, change the 258*4882a593Smuzhiyun default page prots to write-protected with something like this:: 259*4882a593Smuzhiyun 260*4882a593Smuzhiyun vma->vm_page_prot = pgprot_wrprotect(vma->vm_page_prot); 261*4882a593Smuzhiyun 262*4882a593Smuzhiyun- Set the mkwrite and fsync callbacks with similar implementions to the core 263*4882a593Smuzhiyun fbdev defio stuff. These should all work on plain ptes, they don't actually 264*4882a593Smuzhiyun require a struct page. uff. These should all work on plain ptes, they don't 265*4882a593Smuzhiyun actually require a struct page. 266*4882a593Smuzhiyun 267*4882a593Smuzhiyun- Track the dirty pages in a separate structure (bitfield with one bit per page 268*4882a593Smuzhiyun should work) to avoid clobbering struct page. 269*4882a593Smuzhiyun 270*4882a593SmuzhiyunMight be good to also have some igt testcases for this. 271*4882a593Smuzhiyun 272*4882a593SmuzhiyunContact: Daniel Vetter, Noralf Tronnes 273*4882a593Smuzhiyun 274*4882a593SmuzhiyunLevel: Advanced 275*4882a593Smuzhiyun 276*4882a593Smuzhiyunidr_init_base() 277*4882a593Smuzhiyun--------------- 278*4882a593Smuzhiyun 279*4882a593SmuzhiyunDRM core&drivers uses a lot of idr (integer lookup directories) for mapping 280*4882a593Smuzhiyunuserspace IDs to internal objects, and in most places ID=0 means NULL and hence 281*4882a593Smuzhiyunis never used. Switching to idr_init_base() for these would make the idr more 282*4882a593Smuzhiyunefficient. 283*4882a593Smuzhiyun 284*4882a593SmuzhiyunContact: Daniel Vetter 285*4882a593Smuzhiyun 286*4882a593SmuzhiyunLevel: Starter 287*4882a593Smuzhiyun 288*4882a593Smuzhiyunstruct drm_gem_object_funcs 289*4882a593Smuzhiyun--------------------------- 290*4882a593Smuzhiyun 291*4882a593SmuzhiyunGEM objects can now have a function table instead of having the callbacks on the 292*4882a593SmuzhiyunDRM driver struct. This is now the preferred way and drivers can be moved over. 293*4882a593Smuzhiyun 294*4882a593SmuzhiyunWe also need a 2nd version of the CMA define that doesn't require the 295*4882a593Smuzhiyunvmapping to be present (different hook for prime importing). Plus this needs to 296*4882a593Smuzhiyunbe rolled out to all drivers using their own implementations, too. 297*4882a593Smuzhiyun 298*4882a593SmuzhiyunLevel: Intermediate 299*4882a593Smuzhiyun 300*4882a593SmuzhiyunUse DRM_MODESET_LOCK_ALL_* helpers instead of boilerplate 301*4882a593Smuzhiyun--------------------------------------------------------- 302*4882a593Smuzhiyun 303*4882a593SmuzhiyunFor cases where drivers are attempting to grab the modeset locks with a local 304*4882a593Smuzhiyunacquire context. Replace the boilerplate code surrounding 305*4882a593Smuzhiyundrm_modeset_lock_all_ctx() with DRM_MODESET_LOCK_ALL_BEGIN() and 306*4882a593SmuzhiyunDRM_MODESET_LOCK_ALL_END() instead. 307*4882a593Smuzhiyun 308*4882a593SmuzhiyunThis should also be done for all places where drm_modeset_lock_all() is still 309*4882a593Smuzhiyunused. 310*4882a593Smuzhiyun 311*4882a593SmuzhiyunAs a reference, take a look at the conversions already completed in drm core. 312*4882a593Smuzhiyun 313*4882a593SmuzhiyunContact: Sean Paul, respective driver maintainers 314*4882a593Smuzhiyun 315*4882a593SmuzhiyunLevel: Starter 316*4882a593Smuzhiyun 317*4882a593SmuzhiyunRename CMA helpers to DMA helpers 318*4882a593Smuzhiyun--------------------------------- 319*4882a593Smuzhiyun 320*4882a593SmuzhiyunCMA (standing for contiguous memory allocator) is really a bit an accident of 321*4882a593Smuzhiyunwhat these were used for first, a much better name would be DMA helpers. In the 322*4882a593Smuzhiyuntext these should even be called coherent DMA memory helpers (so maybe CDM, but 323*4882a593Smuzhiyunno one knows what that means) since underneath they just use dma_alloc_coherent. 324*4882a593Smuzhiyun 325*4882a593SmuzhiyunContact: Laurent Pinchart, Daniel Vetter 326*4882a593Smuzhiyun 327*4882a593SmuzhiyunLevel: Intermediate (mostly because it is a huge tasks without good partial 328*4882a593Smuzhiyunmilestones, not technically itself that challenging) 329*4882a593Smuzhiyun 330*4882a593Smuzhiyunconnector register/unregister fixes 331*4882a593Smuzhiyun----------------------------------- 332*4882a593Smuzhiyun 333*4882a593Smuzhiyun- For most connectors it's a no-op to call drm_connector_register/unregister 334*4882a593Smuzhiyun directly from driver code, drm_dev_register/unregister take care of this 335*4882a593Smuzhiyun already. We can remove all of them. 336*4882a593Smuzhiyun 337*4882a593Smuzhiyun- For dp drivers it's a bit more a mess, since we need the connector to be 338*4882a593Smuzhiyun registered when calling drm_dp_aux_register. Fix this by instead calling 339*4882a593Smuzhiyun drm_dp_aux_init, and moving the actual registering into a late_register 340*4882a593Smuzhiyun callback as recommended in the kerneldoc. 341*4882a593Smuzhiyun 342*4882a593SmuzhiyunLevel: Intermediate 343*4882a593Smuzhiyun 344*4882a593SmuzhiyunRemove load/unload callbacks from all non-DRIVER_LEGACY drivers 345*4882a593Smuzhiyun--------------------------------------------------------------- 346*4882a593Smuzhiyun 347*4882a593SmuzhiyunThe load/unload callbacks in struct &drm_driver are very much midlayers, plus 348*4882a593Smuzhiyunfor historical reasons they get the ordering wrong (and we can't fix that) 349*4882a593Smuzhiyunbetween setting up the &drm_driver structure and calling drm_dev_register(). 350*4882a593Smuzhiyun 351*4882a593Smuzhiyun- Rework drivers to no longer use the load/unload callbacks, directly coding the 352*4882a593Smuzhiyun load/unload sequence into the driver's probe function. 353*4882a593Smuzhiyun 354*4882a593Smuzhiyun- Once all non-DRIVER_LEGACY drivers are converted, disallow the load/unload 355*4882a593Smuzhiyun callbacks for all modern drivers. 356*4882a593Smuzhiyun 357*4882a593SmuzhiyunContact: Daniel Vetter 358*4882a593Smuzhiyun 359*4882a593SmuzhiyunLevel: Intermediate 360*4882a593Smuzhiyun 361*4882a593SmuzhiyunReplace drm_detect_hdmi_monitor() with drm_display_info.is_hdmi 362*4882a593Smuzhiyun--------------------------------------------------------------- 363*4882a593Smuzhiyun 364*4882a593SmuzhiyunOnce EDID is parsed, the monitor HDMI support information is available through 365*4882a593Smuzhiyundrm_display_info.is_hdmi. Many drivers still call drm_detect_hdmi_monitor() to 366*4882a593Smuzhiyunretrieve the same information, which is less efficient. 367*4882a593Smuzhiyun 368*4882a593SmuzhiyunAudit each individual driver calling drm_detect_hdmi_monitor() and switch to 369*4882a593Smuzhiyundrm_display_info.is_hdmi if applicable. 370*4882a593Smuzhiyun 371*4882a593SmuzhiyunContact: Laurent Pinchart, respective driver maintainers 372*4882a593Smuzhiyun 373*4882a593SmuzhiyunLevel: Intermediate 374*4882a593Smuzhiyun 375*4882a593SmuzhiyunConsolidate custom driver modeset properties 376*4882a593Smuzhiyun-------------------------------------------- 377*4882a593Smuzhiyun 378*4882a593SmuzhiyunBefore atomic modeset took place, many drivers where creating their own 379*4882a593Smuzhiyunproperties. Among other things, atomic brought the requirement that custom, 380*4882a593Smuzhiyundriver specific properties should not be used. 381*4882a593Smuzhiyun 382*4882a593SmuzhiyunFor this task, we aim to introduce core helpers or reuse the existing ones 383*4882a593Smuzhiyunif available: 384*4882a593Smuzhiyun 385*4882a593SmuzhiyunA quick, unconfirmed, examples list. 386*4882a593Smuzhiyun 387*4882a593SmuzhiyunIntroduce core helpers: 388*4882a593Smuzhiyun- audio (amdgpu, intel, gma500, radeon) 389*4882a593Smuzhiyun- brightness, contrast, etc (armada, nouveau) - overlay only (?) 390*4882a593Smuzhiyun- broadcast rgb (gma500, intel) 391*4882a593Smuzhiyun- colorkey (armada, nouveau, rcar) - overlay only (?) 392*4882a593Smuzhiyun- dither (amdgpu, nouveau, radeon) - varies across drivers 393*4882a593Smuzhiyun- underscan family (amdgpu, radeon, nouveau) 394*4882a593Smuzhiyun 395*4882a593SmuzhiyunAlready in core: 396*4882a593Smuzhiyun- colorspace (sti) 397*4882a593Smuzhiyun- tv format names, enhancements (gma500, intel) 398*4882a593Smuzhiyun- tv overscan, margins, etc. (gma500, intel) 399*4882a593Smuzhiyun- zorder (omapdrm) - same as zpos (?) 400*4882a593Smuzhiyun 401*4882a593Smuzhiyun 402*4882a593SmuzhiyunContact: Emil Velikov, respective driver maintainers 403*4882a593Smuzhiyun 404*4882a593SmuzhiyunLevel: Intermediate 405*4882a593Smuzhiyun 406*4882a593SmuzhiyunPlumb drm_atomic_state all over 407*4882a593Smuzhiyun------------------------------- 408*4882a593Smuzhiyun 409*4882a593SmuzhiyunCurrently various atomic functions take just a single or a handful of 410*4882a593Smuzhiyunobject states (eg. plane state). While that single object state can 411*4882a593Smuzhiyunsuffice for some simple cases, we often have to dig out additional 412*4882a593Smuzhiyunobject states for dealing with various dependencies between the individual 413*4882a593Smuzhiyunobjects or the hardware they represent. The process of digging out the 414*4882a593Smuzhiyunadditional states is rather non-intuitive and error prone. 415*4882a593Smuzhiyun 416*4882a593SmuzhiyunTo fix that most functions should rather take the overall 417*4882a593Smuzhiyundrm_atomic_state as one of their parameters. The other parameters 418*4882a593Smuzhiyunwould generally be the object(s) we mainly want to interact with. 419*4882a593Smuzhiyun 420*4882a593SmuzhiyunFor example, instead of 421*4882a593Smuzhiyun 422*4882a593Smuzhiyun.. code-block:: c 423*4882a593Smuzhiyun 424*4882a593Smuzhiyun int (*atomic_check)(struct drm_plane *plane, struct drm_plane_state *state); 425*4882a593Smuzhiyun 426*4882a593Smuzhiyunwe would have something like 427*4882a593Smuzhiyun 428*4882a593Smuzhiyun.. code-block:: c 429*4882a593Smuzhiyun 430*4882a593Smuzhiyun int (*atomic_check)(struct drm_plane *plane, struct drm_atomic_state *state); 431*4882a593Smuzhiyun 432*4882a593SmuzhiyunThe implementation can then trivially gain access to any required object 433*4882a593Smuzhiyunstate(s) via drm_atomic_get_plane_state(), drm_atomic_get_new_plane_state(), 434*4882a593Smuzhiyundrm_atomic_get_old_plane_state(), and their equivalents for 435*4882a593Smuzhiyunother object types. 436*4882a593Smuzhiyun 437*4882a593SmuzhiyunAdditionally many drivers currently access the object->state pointer 438*4882a593Smuzhiyundirectly in their commit functions. That is not going to work if we 439*4882a593Smuzhiyuneg. want to allow deeper commit pipelines as those pointers could 440*4882a593Smuzhiyunthen point to the states corresponding to a future commit instead of 441*4882a593Smuzhiyunthe current commit we're trying to process. Also non-blocking commits 442*4882a593Smuzhiyunexecute locklessly so there are serious concerns with dereferencing 443*4882a593Smuzhiyunthe object->state pointers without holding the locks that protect them. 444*4882a593SmuzhiyunUse of drm_atomic_get_new_plane_state(), drm_atomic_get_old_plane_state(), 445*4882a593Smuzhiyunetc. avoids these problems as well since they relate to a specific 446*4882a593Smuzhiyuncommit via the passed in drm_atomic_state. 447*4882a593Smuzhiyun 448*4882a593SmuzhiyunContact: Ville Syrjälä, Daniel Vetter 449*4882a593Smuzhiyun 450*4882a593SmuzhiyunLevel: Intermediate 451*4882a593Smuzhiyun 452*4882a593Smuzhiyun 453*4882a593SmuzhiyunCore refactorings 454*4882a593Smuzhiyun================= 455*4882a593Smuzhiyun 456*4882a593SmuzhiyunMake panic handling work 457*4882a593Smuzhiyun------------------------ 458*4882a593Smuzhiyun 459*4882a593SmuzhiyunThis is a really varied tasks with lots of little bits and pieces: 460*4882a593Smuzhiyun 461*4882a593Smuzhiyun* The panic path can't be tested currently, leading to constant breaking. The 462*4882a593Smuzhiyun main issue here is that panics can be triggered from hardirq contexts and 463*4882a593Smuzhiyun hence all panic related callback can run in hardirq context. It would be 464*4882a593Smuzhiyun awesome if we could test at least the fbdev helper code and driver code by 465*4882a593Smuzhiyun e.g. trigger calls through drm debugfs files. hardirq context could be 466*4882a593Smuzhiyun achieved by using an IPI to the local processor. 467*4882a593Smuzhiyun 468*4882a593Smuzhiyun* There's a massive confusion of different panic handlers. DRM fbdev emulation 469*4882a593Smuzhiyun helpers have one, but on top of that the fbcon code itself also has one. We 470*4882a593Smuzhiyun need to make sure that they stop fighting over each another. 471*4882a593Smuzhiyun 472*4882a593Smuzhiyun* ``drm_can_sleep()`` is a mess. It hides real bugs in normal operations and 473*4882a593Smuzhiyun isn't a full solution for panic paths. We need to make sure that it only 474*4882a593Smuzhiyun returns true if there's a panic going on for real, and fix up all the 475*4882a593Smuzhiyun fallout. 476*4882a593Smuzhiyun 477*4882a593Smuzhiyun* The panic handler must never sleep, which also means it can't ever 478*4882a593Smuzhiyun ``mutex_lock()``. Also it can't grab any other lock unconditionally, not 479*4882a593Smuzhiyun even spinlocks (because NMI and hardirq can panic too). We need to either 480*4882a593Smuzhiyun make sure to not call such paths, or trylock everything. Really tricky. 481*4882a593Smuzhiyun 482*4882a593Smuzhiyun* For the above locking troubles reasons it's pretty much impossible to 483*4882a593Smuzhiyun attempt a synchronous modeset from panic handlers. The only thing we could 484*4882a593Smuzhiyun try to achive is an atomic ``set_base`` of the primary plane, and hope that 485*4882a593Smuzhiyun it shows up. Everything else probably needs to be delayed to some worker or 486*4882a593Smuzhiyun something else which happens later on. Otherwise it just kills the box 487*4882a593Smuzhiyun harder, prevent the panic from going out on e.g. netconsole. 488*4882a593Smuzhiyun 489*4882a593Smuzhiyun* There's also proposal for a simplied DRM console instead of the full-blown 490*4882a593Smuzhiyun fbcon and DRM fbdev emulation. Any kind of panic handling tricks should 491*4882a593Smuzhiyun obviously work for both console, in case we ever get kmslog merged. 492*4882a593Smuzhiyun 493*4882a593SmuzhiyunContact: Daniel Vetter 494*4882a593Smuzhiyun 495*4882a593SmuzhiyunLevel: Advanced 496*4882a593Smuzhiyun 497*4882a593SmuzhiyunClean up the debugfs support 498*4882a593Smuzhiyun---------------------------- 499*4882a593Smuzhiyun 500*4882a593SmuzhiyunThere's a bunch of issues with it: 501*4882a593Smuzhiyun 502*4882a593Smuzhiyun- The drm_info_list ->show() function doesn't even bother to cast to the drm 503*4882a593Smuzhiyun structure for you. This is lazy. 504*4882a593Smuzhiyun 505*4882a593Smuzhiyun- We probably want to have some support for debugfs files on crtc/connectors and 506*4882a593Smuzhiyun maybe other kms objects directly in core. There's even drm_print support in 507*4882a593Smuzhiyun the funcs for these objects to dump kms state, so it's all there. And then the 508*4882a593Smuzhiyun ->show() functions should obviously give you a pointer to the right object. 509*4882a593Smuzhiyun 510*4882a593Smuzhiyun- The drm_info_list stuff is centered on drm_minor instead of drm_device. For 511*4882a593Smuzhiyun anything we want to print drm_device (or maybe drm_file) is the right thing. 512*4882a593Smuzhiyun 513*4882a593Smuzhiyun- The drm_driver->debugfs_init hooks we have is just an artifact of the old 514*4882a593Smuzhiyun midlayered load sequence. DRM debugfs should work more like sysfs, where you 515*4882a593Smuzhiyun can create properties/files for an object anytime you want, and the core 516*4882a593Smuzhiyun takes care of publishing/unpuplishing all the files at register/unregister 517*4882a593Smuzhiyun time. Drivers shouldn't need to worry about these technicalities, and fixing 518*4882a593Smuzhiyun this (together with the drm_minor->drm_device move) would allow us to remove 519*4882a593Smuzhiyun debugfs_init. 520*4882a593Smuzhiyun 521*4882a593Smuzhiyun- Drop the return code and error checking from all debugfs functions. Greg KH is 522*4882a593Smuzhiyun working on this already. 523*4882a593Smuzhiyun 524*4882a593SmuzhiyunContact: Daniel Vetter 525*4882a593Smuzhiyun 526*4882a593SmuzhiyunLevel: Intermediate 527*4882a593Smuzhiyun 528*4882a593SmuzhiyunKMS cleanups 529*4882a593Smuzhiyun------------ 530*4882a593Smuzhiyun 531*4882a593SmuzhiyunSome of these date from the very introduction of KMS in 2008 ... 532*4882a593Smuzhiyun 533*4882a593Smuzhiyun- Make ->funcs and ->helper_private vtables optional. There's a bunch of empty 534*4882a593Smuzhiyun function tables in drivers, but before we can remove them we need to make sure 535*4882a593Smuzhiyun that all the users in helpers and drivers do correctly check for a NULL 536*4882a593Smuzhiyun vtable. 537*4882a593Smuzhiyun 538*4882a593Smuzhiyun- Cleanup up the various ->destroy callbacks. A lot of them just wrapt the 539*4882a593Smuzhiyun drm_*_cleanup implementations and can be removed. Some tack a kfree() at the 540*4882a593Smuzhiyun end, for which we could add drm_*_cleanup_kfree(). And then there's the (for 541*4882a593Smuzhiyun historical reasons) misnamed drm_primary_helper_destroy() function. 542*4882a593Smuzhiyun 543*4882a593SmuzhiyunLevel: Intermediate 544*4882a593Smuzhiyun 545*4882a593SmuzhiyunRemove automatic page mapping from dma-buf importing 546*4882a593Smuzhiyun---------------------------------------------------- 547*4882a593Smuzhiyun 548*4882a593SmuzhiyunWhen importing dma-bufs, the dma-buf and PRIME frameworks automatically map 549*4882a593Smuzhiyunimported pages into the importer's DMA area. drm_gem_prime_fd_to_handle() and 550*4882a593Smuzhiyundrm_gem_prime_handle_to_fd() require that importers call dma_buf_attach() 551*4882a593Smuzhiyuneven if they never do actual device DMA, but only CPU access through 552*4882a593Smuzhiyundma_buf_vmap(). This is a problem for USB devices, which do not support DMA 553*4882a593Smuzhiyunoperations. 554*4882a593Smuzhiyun 555*4882a593SmuzhiyunTo fix the issue, automatic page mappings should be removed from the 556*4882a593Smuzhiyunbuffer-sharing code. Fixing this is a bit more involved, since the import/export 557*4882a593Smuzhiyuncache is also tied to &drm_gem_object.import_attach. Meanwhile we paper over 558*4882a593Smuzhiyunthis problem for USB devices by fishing out the USB host controller device, as 559*4882a593Smuzhiyunlong as that supports DMA. Otherwise importing can still needlessly fail. 560*4882a593Smuzhiyun 561*4882a593SmuzhiyunContact: Thomas Zimmermann <tzimmermann@suse.de>, Daniel Vetter 562*4882a593Smuzhiyun 563*4882a593SmuzhiyunLevel: Advanced 564*4882a593Smuzhiyun 565*4882a593Smuzhiyun 566*4882a593SmuzhiyunBetter Testing 567*4882a593Smuzhiyun============== 568*4882a593Smuzhiyun 569*4882a593SmuzhiyunEnable trinity for DRM 570*4882a593Smuzhiyun---------------------- 571*4882a593Smuzhiyun 572*4882a593SmuzhiyunAnd fix up the fallout. Should be really interesting ... 573*4882a593Smuzhiyun 574*4882a593SmuzhiyunLevel: Advanced 575*4882a593Smuzhiyun 576*4882a593SmuzhiyunMake KMS tests in i-g-t generic 577*4882a593Smuzhiyun------------------------------- 578*4882a593Smuzhiyun 579*4882a593SmuzhiyunThe i915 driver team maintains an extensive testsuite for the i915 DRM driver, 580*4882a593Smuzhiyunincluding tons of testcases for corner-cases in the modesetting API. It would 581*4882a593Smuzhiyunbe awesome if those tests (at least the ones not relying on Intel-specific GEM 582*4882a593Smuzhiyunfeatures) could be made to run on any KMS driver. 583*4882a593Smuzhiyun 584*4882a593SmuzhiyunBasic work to run i-g-t tests on non-i915 is done, what's now missing is mass- 585*4882a593Smuzhiyunconverting things over. For modeset tests we also first need a bit of 586*4882a593Smuzhiyuninfrastructure to use dumb buffers for untiled buffers, to be able to run all 587*4882a593Smuzhiyunthe non-i915 specific modeset tests. 588*4882a593Smuzhiyun 589*4882a593SmuzhiyunLevel: Advanced 590*4882a593Smuzhiyun 591*4882a593SmuzhiyunExtend virtual test driver (VKMS) 592*4882a593Smuzhiyun--------------------------------- 593*4882a593Smuzhiyun 594*4882a593SmuzhiyunSee the documentation of :ref:`VKMS <vkms>` for more details. This is an ideal 595*4882a593Smuzhiyuninternship task, since it only requires a virtual machine and can be sized to 596*4882a593Smuzhiyunfit the available time. 597*4882a593Smuzhiyun 598*4882a593SmuzhiyunContact: Daniel Vetter 599*4882a593Smuzhiyun 600*4882a593SmuzhiyunLevel: See details 601*4882a593Smuzhiyun 602*4882a593SmuzhiyunBacklight Refactoring 603*4882a593Smuzhiyun--------------------- 604*4882a593Smuzhiyun 605*4882a593SmuzhiyunBacklight drivers have a triple enable/disable state, which is a bit overkill. 606*4882a593SmuzhiyunPlan to fix this: 607*4882a593Smuzhiyun 608*4882a593Smuzhiyun1. Roll out backlight_enable() and backlight_disable() helpers everywhere. This 609*4882a593Smuzhiyun has started already. 610*4882a593Smuzhiyun2. In all, only look at one of the three status bits set by the above helpers. 611*4882a593Smuzhiyun3. Remove the other two status bits. 612*4882a593Smuzhiyun 613*4882a593SmuzhiyunContact: Daniel Vetter 614*4882a593Smuzhiyun 615*4882a593SmuzhiyunLevel: Intermediate 616*4882a593Smuzhiyun 617*4882a593SmuzhiyunDriver Specific 618*4882a593Smuzhiyun=============== 619*4882a593Smuzhiyun 620*4882a593SmuzhiyunAMD DC Display Driver 621*4882a593Smuzhiyun--------------------- 622*4882a593Smuzhiyun 623*4882a593SmuzhiyunAMD DC is the display driver for AMD devices starting with Vega. There has been 624*4882a593Smuzhiyuna bunch of progress cleaning it up but there's still plenty of work to be done. 625*4882a593Smuzhiyun 626*4882a593SmuzhiyunSee drivers/gpu/drm/amd/display/TODO for tasks. 627*4882a593Smuzhiyun 628*4882a593SmuzhiyunContact: Harry Wentland, Alex Deucher 629*4882a593Smuzhiyun 630*4882a593SmuzhiyunBootsplash 631*4882a593Smuzhiyun========== 632*4882a593Smuzhiyun 633*4882a593SmuzhiyunThere is support in place now for writing internal DRM clients making it 634*4882a593Smuzhiyunpossible to pick up the bootsplash work that was rejected because it was written 635*4882a593Smuzhiyunfor fbdev. 636*4882a593Smuzhiyun 637*4882a593Smuzhiyun- [v6,8/8] drm/client: Hack: Add bootsplash example 638*4882a593Smuzhiyun https://patchwork.freedesktop.org/patch/306579/ 639*4882a593Smuzhiyun 640*4882a593Smuzhiyun- [RFC PATCH v2 00/13] Kernel based bootsplash 641*4882a593Smuzhiyun https://lkml.org/lkml/2017/12/13/764 642*4882a593Smuzhiyun 643*4882a593SmuzhiyunContact: Sam Ravnborg 644*4882a593Smuzhiyun 645*4882a593SmuzhiyunLevel: Advanced 646*4882a593Smuzhiyun 647*4882a593SmuzhiyunOutside DRM 648*4882a593Smuzhiyun=========== 649*4882a593Smuzhiyun 650*4882a593SmuzhiyunConvert fbdev drivers to DRM 651*4882a593Smuzhiyun---------------------------- 652*4882a593Smuzhiyun 653*4882a593SmuzhiyunThere are plenty of fbdev drivers for older hardware. Some hwardware has 654*4882a593Smuzhiyunbecome obsolete, but some still provides good(-enough) framebuffers. The 655*4882a593Smuzhiyundrivers that are still useful should be converted to DRM and afterwards 656*4882a593Smuzhiyunremoved from fbdev. 657*4882a593Smuzhiyun 658*4882a593SmuzhiyunVery simple fbdev drivers can best be converted by starting with a new 659*4882a593SmuzhiyunDRM driver. Simple KMS helpers and SHMEM should be able to handle any 660*4882a593Smuzhiyunexisting hardware. The new driver's call-back functions are filled from 661*4882a593Smuzhiyunexisting fbdev code. 662*4882a593Smuzhiyun 663*4882a593SmuzhiyunMore complex fbdev drivers can be refactored step-by-step into a DRM 664*4882a593Smuzhiyundriver with the help of the DRM fbconv helpers. [1] These helpers provide 665*4882a593Smuzhiyunthe transition layer between the DRM core infrastructure and the fbdev 666*4882a593Smuzhiyundriver interface. Create a new DRM driver on top of the fbconv helpers, 667*4882a593Smuzhiyuncopy over the fbdev driver, and hook it up to the DRM code. Examples for 668*4882a593Smuzhiyunseveral fbdev drivers are available at [1] and a tutorial of this process 669*4882a593Smuzhiyunavailable at [2]. The result is a primitive DRM driver that can run X11 670*4882a593Smuzhiyunand Weston. 671*4882a593Smuzhiyun 672*4882a593Smuzhiyun - [1] https://gitlab.freedesktop.org/tzimmermann/linux/tree/fbconv 673*4882a593Smuzhiyun - [2] https://gitlab.freedesktop.org/tzimmermann/linux/blob/fbconv/drivers/gpu/drm/drm_fbconv_helper.c 674*4882a593Smuzhiyun 675*4882a593SmuzhiyunContact: Thomas Zimmermann <tzimmermann@suse.de> 676*4882a593Smuzhiyun 677*4882a593SmuzhiyunLevel: Advanced 678