Atomic Modesetting for Drivers Daniel Vetter, Intel OTC 1 Anatomy - - PowerPoint PPT Presentation

atomic modesetting for drivers
SMART_READER_LITE
LIVE PREVIEW

Atomic Modesetting for Drivers Daniel Vetter, Intel OTC 1 Anatomy - - PowerPoint PPT Presentation

Atomic Modesetting for Drivers Daniel Vetter, Intel OTC 1 Anatomy of an Atomic Modeset 1. Build up new state 2. Compute derived state and check the update 3. Commit the new state to the hardware, possibly asynchronously 2 State Building


slide-1
SLIDE 1

1

Atomic Modesetting for Drivers

Daniel Vetter, Intel OTC

slide-2
SLIDE 2

2

Anatomy of an Atomic Modeset

  • 1. Build up new state
  • 2. Compute derived state and check the update
  • 3. Commit the new state to the hardware, possibly

asynchronously

slide-3
SLIDE 3

3

State Building

  • per-object states structures tracked in struct

drm_atomic_state

  • ->atomic_duplicate/destroy_* per-object
  • ->atomic_set/get_property only for private

properties

  • start with pure helpers, subclass as needed
slide-4
SLIDE 4

4

State Checking

  • global ->atomic_check entry point
  • plus big modular helper library
  • helper supports legacy ->mode_fixup and new
  • >atomic_check hooks
  • read the kerneldoc!
slide-5
SLIDE 5

5

State Precomputing&Checking

  • often check and commit need to compute the same values,

e.g. DP link settings

➔ subclass state structures and store derived state for reuse

in the commit phase

  • almosts everything ends up being subclassed, tons of

examples

slide-6
SLIDE 6

6

Cross-State Structures Checking

  • ->atomic_check hooks can look at any other state
  • always use provided functions and check errors to avoid

wait/wound mutex headaches and unecessary serialization

  • CONFIG_DEBUG_WW_MUTEX_SLOWPATH
  • overwrite global ->atomic_check if needed
  • tons of examples already
slide-7
SLIDE 7

7

Handling Global State

  • for shared resources across CRTCs
  • use driver-private w/w mutex or dev->mode_config-

>connection_mutex

  • ->atomic_state_alloc/clear/free to subclass

global struct drm_atomic_state

  • currently only i915: display core clock, shared PLLs, ...
slide-8
SLIDE 8

8

State Committing

  • global ->atomic_commit entry point
  • commit not allowed to fail due to invalid state
  • core guarantees to call ->atomic_check first
  • helpers by default optimized for backwards compat
  • modular helpers to accomodate more drivers, read docs!
slide-9
SLIDE 9

9

Helper Design

  • plane updates orthogonal to modeset changes
  • no parital enables/disable, reducing complexity
  • DPMS implemented entirely in helpers
  • lots of old hooks depracated, most others optional
  • legacy state updated by default, but can be ignored

➔ much fewer boilerplate required

slide-10
SLIDE 10

10

Atomic Commit Flow

  • ->prepare_fb for memory alloc, pinning
  • swap new state into objects (must be done synchronously)
  • wait for fences and buffers
  • actual hardware commit, built from helpers and driver code
  • wait for vblank
  • ->cleanup_fb to for memory release, unpin
slide-11
SLIDE 11

11

Hardware Commit Helpers

  • CRTC, encoders and bridges for modesets with just

enable/disable hooks

  • 3-phase plane updates:
  • 1. CRTC ->atomic_begin for vblank evade, blocking

updates

  • 2. per-plane ->atomic_update/disable

3.CRTC ->atomic_flush to set GO bit, unblock updates

slide-12
SLIDE 12

12

Bootstrapping Atomic State

  • atomic updates always incremental
  • assume that software state perfectly matches hardware
  • driver load and resume need to ensure matching state, use
  • >reset hooks
  • need not actually reset, hardware state readout for fastboot

also possible

slide-13
SLIDE 13

13

Legacy Entry Points

  • helpers to implement them with atomic for all of them
  • allows drivers to keep old features that don't make sense to

port to atomic around

slide-14
SLIDE 14

14

Ongoing for 4.4

  • suspend/resume helpers
  • atomic fbdev
  • active_only plane update helpers
  • better support for runtime PM in general
slide-15
SLIDE 15

15

Future Work

  • generic async commit
  • state readout for fastboot à la i915
  • more helpers as use-cases crop up …
  • generic validation tests in i-g-t perhaps
slide-16
SLIDE 16

16

KMS Extensions

  • easy to do with properties
  • color manager, plane blending, ...
  • should put them into core drm state structures to avoid

property proliferation

  • same rules as any other kernel ABI
slide-17
SLIDE 17

17

Android Support?

  • just fences missing, but:
  • hardware composer wants per-buffer relase fence, even

before the next flip is scheduled

➔ trivial fencing deadlock

  • … and no one has an open-source atomic hwc
slide-18
SLIDE 18

18

Documentation

  • conversion HOWTO for legacy drivers:

http://blog.ffwll.ch/2014/11/atomic-modeset-support-for-kms-drivers.html

  • LWN design overview: https://lwn.net/Articles/653071/

https://lwn.net/Articles/653466/

  • DRM DocBook: https://01.org/linuxgraphics/gfx-docs/drm/
slide-19
SLIDE 19

19

Q & A