Skip to contentSkip to conversation

drm/atomic: clarify the rules around drm_atomic_state->allow_modeset

PATCH New Daniel Vetter 7 participants 11 messages Oct 10, 2023 – Jan 10, 2025

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/atomic: clarify the rules around drm_atomic_state->allow_modeset

msm is automagically upgrading normal commits to full modesets, and that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
---
 include/drm/drm_atomic.h | 18 ++++++++++++++++--
 1 file changed, 16 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +16 -2
index cf8e1220a4ac..09bef1b6c170 100644
@@ -372,8 +372,22 @@ struct drm_atomic_state {
 	 *
 	 * Allow full modeset. This is used by the ATOMIC IOCTL handler to
 	 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-	 * never consult this flag, instead looking at the output of
-	 * drm_atomic_crtc_needs_modeset().
+	 * not consult this flag, instead looking at the output of
+	 * drm_atomic_crtc_needs_modeset(). The detailed rules are:
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,
+	 *   and instead use drm_atomic_crtc_needs_modeset().
+	 *
+	 * - Drivers may consult @allow_modeset in the atomic check path, if
+	 *   they have the choice between an optimal hardware configuration
+	 *   which requires a modeset, and a less optimal configuration which
+	 *   can be committed without a modeset. An example would be suboptimal
+	 *   scanout FIFO allocation resulting in increased idle power
+	 *   consumption. This allows userspace to avoid flickering and delays
+	 *   for the normal composition loop at reasonable cost.
+	 *
+	 * - Drivers must never change this flag, it is only under the control
+	 *   of userspace.
 	 */
 	bool allow_modeset : 1;
 	/**
Signature · 1 line
2.40.1
#1 lore raw

PATCH 1/1 drm/atomic: clarify the rules around drm_atomic_state->allow_modeset

msm is automagically upgrading normal commits to full modesets, and that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
 include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +21 -2
index cf8e1220a4ac..545c48545402 100644
@@ -372,8 +372,27 @@ struct drm_atomic_state {
 	 *
 	 * Allow full modeset. This is used by the ATOMIC IOCTL handler to
 	 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-	 * never consult this flag, instead looking at the output of
-	 * drm_atomic_crtc_needs_modeset().
+	 * not consult this flag, instead looking at the output of
+	 * drm_atomic_crtc_needs_modeset(). The detailed rules are:
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,
+	 *   and instead use drm_atomic_crtc_needs_modeset().
+	 *
+	 * - Drivers may consult @allow_modeset in the atomic check path, if
+	 *   they have the choice between an optimal hardware configuration
+	 *   which requires a modeset, and a less optimal configuration which
+	 *   can be committed without a modeset. An example would be suboptimal
+	 *   scanout FIFO allocation resulting in increased idle power
+	 *   consumption. This allows userspace to avoid flickering and delays
+	 *   for the normal composition loop at reasonable cost.
+	 *
+	 * - Drivers must consult @allow_modeset before adding unrelated struct
+	 *   drm_crtc_state to this commit by calling
+	 *   drm_atomic_get_crtc_state(). See also the warning in the
+	 *   documentation for that function.
+	 *
+	 * - Drivers must never change this flag, it is only under the control
+	 *   of userspace.
 	 */
 	bool allow_modeset : 1;
 	/**
Signature · 1 line
2.40.1
#2 lore raw

Hi

Am 11.10.23 um 11:20 schrieb Daniel Vetter:

Quoted 1 line

msm is automagically upgrading normal commits to full modesets, and

Can you give context or pointers here?

Quoted 39 lines

that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
  include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
  1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +0 -0
index cf8e1220a4ac..545c48545402 100644

include/drm/drm_atomic.h struct drm_atomic_state { · line 376

Quoted 7 lines
include/drm/drm_atomic.h +2 -2
@@ -372,8 +372,27 @@ struct drm_atomic_state {
  	 *
  	 * Allow full modeset. This is used by the ATOMIC IOCTL handler to
  	 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-	 * never consult this flag, instead looking at the output of
-	 * drm_atomic_crtc_needs_modeset().
+	 * not consult this flag, instead looking at the output of
+	 * drm_atomic_crtc_needs_modeset(). The detailed rules are:

Comments on the text from a non-native speaker:

I assume that you follow RFC 2119. I'd leave out the new sentence ('should not'), as it is weaker than the actual rules. Maybe list the rules directly. Something along the lines of "Drivers consulting this flag must follow the following rules".

include/drm/drm_atomic.h struct drm_atomic_state { · line 378

Quoted 2 lines
include/drm/drm_atomic.h +2 -0
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,

'atomic-commit' because it's the code path for atomic commits.

include/drm/drm_atomic.h struct drm_atomic_state { · line 381

Quoted 3 lines
include/drm/drm_atomic.h +3 -0
+	 *   and instead use drm_atomic_crtc_needs_modeset().
+	 *
+	 * - Drivers may consult @allow_modeset in the atomic check path, if

'atomic-check'

include/drm/drm_atomic.h struct drm_atomic_state { · line 382

Quoted 1 line
include/drm/drm_atomic.h +1 -0
+	 *   they have the choice between an optimal hardware configuration

comma after configuration

include/drm/drm_atomic.h struct drm_atomic_state { · line 383

Quoted 1 line
include/drm/drm_atomic.h +1 -0
+	 *   which requires a modeset, and a less optimal configuration which

'less-optimal'

include/drm/drm_atomic.h struct drm_atomic_state { · line 385

Quoted 2 lines
include/drm/drm_atomic.h +2 -0
+	 *   can be committed without a modeset. An example would be suboptimal
+	 *   scanout FIFO allocation resulting in increased idle power

This sentence is hard to understand for me. Is it 'scanout FIFO allocation' or 'scanout-FIFO allocation'? Maybe also try putting a comma after 'allocation'.

include/drm/drm_atomic.h struct drm_atomic_state { · line 394

Quoted 9 lines
include/drm/drm_atomic.h +9 -0
+	 *   consumption. This allows userspace to avoid flickering and delays
+	 *   for the normal composition loop at reasonable cost.
+	 *
+	 * - Drivers must consult @allow_modeset before adding unrelated struct
+	 *   drm_crtc_state to this commit by calling
+	 *   drm_atomic_get_crtc_state(). See also the warning in the
+	 *   documentation for that function.
+	 *
+	 * - Drivers must never change this flag, it is only under the control

Maybe try 'it is under exclusive control of user space' ?

include/drm/drm_atomic.h struct drm_atomic_state { · line 395

Quoted 1 line
include/drm/drm_atomic.h +1 -0
+	 *   of userspace.

I'd also order these points like that

- must not change
- must not use it in atomic_commit
- must
- may

so that the 'don't dos' are first.

Best regards
Thomas

Quoted 3 lines
include/drm/drm_atomic.h +0 -0
  	 */
  	bool allow_modeset : 1;
  	/**
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#3 lore raw
Quoted 6 lines · Thomas Zimmermann

Hi

Am 11.10.23 um 11:20 schrieb Daniel Vetter:

Quoted 1 line

msm is automagically upgrading normal commits to full modesets, and

Can you give context or pointers here?

See Dmitry's enforcement patch set he just sent out. Also finally got around to picking this up again.

Quoted 55 lines
Quoted 39 lines

that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
  include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
  1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +0 -0
index cf8e1220a4ac..545c48545402 100644

include/drm/drm_atomic.h struct drm_atomic_state { · line 376

Quoted 7 lines
include/drm/drm_atomic.h +2 -2
@@ -372,8 +372,27 @@ struct drm_atomic_state {
  	 *
  	 * Allow full modeset. This is used by the ATOMIC IOCTL handler to
  	 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-	 * never consult this flag, instead looking at the output of
-	 * drm_atomic_crtc_needs_modeset().
+	 * not consult this flag, instead looking at the output of
+	 * drm_atomic_crtc_needs_modeset(). The detailed rules are:

Comments on the text from a non-native speaker:

I assume that you follow RFC 2119. I'd leave out the new sentence ('should not'), as it is weaker than the actual rules. Maybe list the rules directly. Something along the lines of "Drivers consulting this flag must follow the following rules".

Quoted 4 lines

include/drm/drm_atomic.h struct drm_atomic_state { · line 378

Quoted 2 lines
include/drm/drm_atomic.h +2 -0
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,

'atomic-commit' because it's the code path for atomic commits.

Maybe I'm wrong, but my understanding is that English generally doesn't do compound words connected with dashes, you just line them up with spaces. Which can be confusing sometimes, especially since German very much makes a distinction here.

Quoted 10 lines

include/drm/drm_atomic.h struct drm_atomic_state { · line 381

Quoted 4 lines
include/drm/drm_atomic.h +3 -0
+	 *   and instead use drm_atomic_crtc_needs_modeset().
+	 *
+	 * - Drivers may consult @allow_modeset in the atomic check path, if

'atomic-check'

include/drm/drm_atomic.h struct drm_atomic_state { · line 382

Quoted 1 line
include/drm/drm_atomic.h +1 -0
+	 *   they have the choice between an optimal hardware configuration

comma after configuration

Nope, because English doesn't have unconditional comma before relative subclauses. Instead the lack of comma signifies that the subclause specifies essential information which cannot be ommitted without changing the meaning of the sentence. Which is the case here for all the commas you want to add.

See https://prowritingaid.com/grammar/1008112/comma-before-which-where-who

Quoted 10 lines

include/drm/drm_atomic.h struct drm_atomic_state { · line 383

Quoted 2 lines
include/drm/drm_atomic.h +1 -0
+	 *   which requires a modeset, and a less optimal configuration which

'less-optimal'

include/drm/drm_atomic.h struct drm_atomic_state { · line 385

Quoted 2 lines
include/drm/drm_atomic.h +2 -0
+	 *   can be committed without a modeset. An example would be suboptimal
+	 *   scanout FIFO allocation resulting in increased idle power

This sentence is hard to understand for me. Is it 'scanout FIFO allocation' or 'scanout-FIFO allocation'? Maybe also try putting a comma after 'allocation'.

See above, I think this is just English being English.

Quoted 16 lines

include/drm/drm_atomic.h struct drm_atomic_state { · line 394

Quoted 9 lines
include/drm/drm_atomic.h +9 -0
+	 *   consumption. This allows userspace to avoid flickering and delays
+	 *   for the normal composition loop at reasonable cost.
+	 *
+	 * - Drivers must consult @allow_modeset before adding unrelated struct
+	 *   drm_crtc_state to this commit by calling
+	 *   drm_atomic_get_crtc_state(). See also the warning in the
+	 *   documentation for that function.
+	 *
+	 * - Drivers must never change this flag, it is only under the control

Maybe try 'it is under exclusive control of user space' ?

include/drm/drm_atomic.h struct drm_atomic_state { · line 395

Quoted 1 line
include/drm/drm_atomic.h +1 -0
+	 *   of userspace.

I'd also order these points like that

Quoted 6 lines

- must not change
- must not use it in atomic_commit
- must
- may

so that the 'don't dos' are first.

I've done your other changes as suggested.

Thanks, Sima

Quoted 15 lines

Best regards
Thomas

Quoted 3 lines
include/drm/drm_atomic.h +0 -0
  	 */
  	bool allow_modeset : 1;
  	/**
Signature · 6 lines
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
Signature · 3 lines
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
#4 lore raw
Quoted 11 lines · Simona Vetter
Quoted 6 lines · Thomas Zimmermann

Comments on the text from a non-native speaker:

include/drm/drm_atomic.h struct drm_atomic_state { · line 378

Quoted 2 lines
include/drm/drm_atomic.h +2 -0
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,

'atomic-commit' because it's the code path for atomic commits.

Maybe I'm wrong, but my understanding is that English generally doesn't do compound words connected with dashes, you just line them up with spaces.

I hope you don't mind me jumping in, three native German speakers discussing English grammar is merrier than just two. :)

FWIW, LWN writes compound words with spaces when used as nouns ("code in user space"), with dashes when used as adjectives ("user-space code"). I don't know if this is an official / general rule, I'm using it as a guideline though.

Signature · 2 lines
Earthling Michel Dänzer       \        GNOME / Xwayland / Mesa developer
https://redhat.com             \               Libre software enthusiast
#5 lore raw

Hi,

Quoted 7 lines · Michel Dänzer
Quoted 2 lines · Simona Vetter

Maybe I'm wrong, but my understanding is that English generally doesn't do compound words connected with dashes, you just line them up with spaces.

I hope you don't mind me jumping in, three native German speakers discussing English grammar is merrier than just two. :)

FWIW, LWN writes compound words with spaces when used as nouns ("code in user space"), with dashes when used as adjectives ("user-space code"). I don't know if this is an official / general rule, I'm using it as a guideline though.

To the extent that Australian counts as native English: yes, that's exactly the rule.

Cheers,
Daniel

#6 lore raw

Hi

Am 09.01.25 um 16:45 schrieb Daniel Stone:

Quoted 11 lines

Hi,

Quoted 6 lines · Michel Dänzer
Quoted 2 lines · Simona Vetter

Maybe I'm wrong, but my understanding is that English generally doesn't do compound words connected with dashes, you just line them up with spaces.

I hope you don't mind me jumping in, three native German speakers discussing English grammar is merrier than just two. :)

FWIW, LWN writes compound words with spaces when used as nouns ("code in user space"), with dashes when used as adjectives ("user-space code"). I don't know if this is an official / general rule, I'm using it as a guideline though.

To the extent that Australian counts as native English: yes, that's exactly the rule.

Thanks! My understanding is that words are right associative by default. So "user space code" means 'user (space code)'. The dash makes it left associative, hence "user-space code".

Best regards
Thomas

Quoted 3 lines

Cheers,
Daniel

Signature · 7 lines
--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Frankenstrasse 146, 90461 Nuernberg, Germany
GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman
HRB 36809 (AG Nuernberg)
#7 lore raw
In reply to Daniel Stone
Quoted 10 lines · Daniel Stone

Hi,

Quoted 7 lines · Michel Dänzer
Quoted 2 lines · Simona Vetter

Maybe I'm wrong, but my understanding is that English generally doesn't do compound words connected with dashes, you just line them up with spaces.

I hope you don't mind me jumping in, three native German speakers discussing English grammar is merrier than just two. :)

Quoted 7 lines
Quoted 4 lines

FWIW, LWN writes compound words with spaces when used as nouns ("code in user space"), with dashes when used as adjectives ("user-space code"). I don't know if this is an official / general rule, I'm using it as a guideline though.

To the extent that Australian counts as native English: yes, that's exactly the rule.

TIL, thanks a lot.

Pretty sure we never got around to this rule, and I had close to a decade of English lessons. The one about commas I do remember from school though. -Sima

Signature · 3 lines
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
Acked-by on v1 1/1
#8 lore raw
In reply to Daniel Vetter
Quoted 40 lines · On Wed, 11 Oct 2023 11:20:51 +0200 Daniel Vetter <[email protected]> wrote:

msm is automagically upgrading normal commits to full modesets, and that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
 include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +0 -0
index cf8e1220a4ac..545c48545402 100644

include/drm/drm_atomic.h struct drm_atomic_state { · line 379

Quoted 10 lines
include/drm/drm_atomic.h +5 -2
@@ -372,8 +372,27 @@ struct drm_atomic_state {
 	 *
 	 * Allow full modeset. This is used by the ATOMIC IOCTL handler to
 	 * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-	 * never consult this flag, instead looking at the output of
-	 * drm_atomic_crtc_needs_modeset().
+	 * not consult this flag, instead looking at the output of
+	 * drm_atomic_crtc_needs_modeset(). The detailed rules are:
+	 *
+	 * - Drivers must not consult @allow_modeset in the atomic commit path,
+	 *   and instead use drm_atomic_crtc_needs_modeset().

Change to

Drivers must not consult @allow_modeset in the atomic commit path. Use drm_atomic_crtc_needs_modeset() instead.

maybe?

It's hard for me to see the difference between "instead use X" and "instead of X". "Use Y instead (of X)." helps me at least.

Quoted 6 lines
include/drm/drm_atomic.h +6 -0
+	 *
+	 * - Drivers may consult @allow_modeset in the atomic check path, if
+	 *   they have the choice between an optimal hardware configuration
+	 *   which requires a modeset, and a less optimal configuration which
+	 *   can be committed without a modeset. An example would be suboptimal
+	 *   scanout FIFO allocation resulting in increased idle power

include/drm/drm_atomic.h struct drm_atomic_state { · line 395

Quoted 10 lines
include/drm/drm_atomic.h +10 -0
+	 *   consumption. This allows userspace to avoid flickering and delays
+	 *   for the normal composition loop at reasonable cost.
+	 *
+	 * - Drivers must consult @allow_modeset before adding unrelated struct
+	 *   drm_crtc_state to this commit by calling
+	 *   drm_atomic_get_crtc_state(). See also the warning in the
+	 *   documentation for that function.
+	 *
+	 * - Drivers must never change this flag, it is only under the control
+	 *   of userspace.

*only userspace may set it. ?

include/drm/drm_atomic.h struct drm_atomic_state { · line 398

Quoted 3 lines
include/drm/drm_atomic.h +0 -0
 	 */
 	bool allow_modeset : 1;
 	/**

Wording bikeshed aside,

Thanks,
pq

#9 lore raw
In reply to Daniel Vetter

Hello,

Quoted 12 lines · Daniel Vetter

msm is automagically upgrading normal commits to full modesets, and that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

Quoted 5 lines

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

I have been looking at the drm_atomic_helper_check_modeset() issue, I couldn't help but notice that this hasn't been committed. Maybe it's time for v3?

Quoted 55 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
 include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +21 -3
index cf8e1220a4ac..545c48545402 100644
@@ -372,8 +372,27 @@ struct drm_atomic_state {
         *
         * Allow full modeset. This is used by the ATOMIC IOCTL handler to
         * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-        * never consult this flag, instead looking at the output of
-        * drm_atomic_crtc_needs_modeset().
+        * not consult this flag, instead looking at the output of
+        * drm_atomic_crtc_needs_modeset(). The detailed rules are:
+        *
+        * - Drivers must not consult @allow_modeset in the atomic commit path,
+        *   and instead use drm_atomic_crtc_needs_modeset().
+        *
+        * - Drivers may consult @allow_modeset in the atomic check path, if
+        *   they have the choice between an optimal hardware configuration
+        *   which requires a modeset, and a less optimal configuration which
+        *   can be committed without a modeset. An example would be suboptimal
+        *   scanout FIFO allocation resulting in increased idle power
+        *   consumption. This allows userspace to avoid flickering and delays
+        *   for the normal composition loop at reasonable cost.
+        *
+        * - Drivers must consult @allow_modeset before adding unrelated struct
+        *   drm_crtc_state to this commit by calling
+        *   drm_atomic_get_crtc_state(). See also the warning in the
+        *   documentation for that function.
+        *
+        * - Drivers must never change this flag, it is only under the control
+        *   of userspace.
         */
        bool allow_modeset : 1;
        /**
--

2.40.1

Signature · 2 lines
With best wishes
Dmitry
#10 lore raw
Quoted 21 lines · Dmitry Baryshkov

Hello,

Quoted 12 lines · Daniel Vetter

msm is automagically upgrading normal commits to full modesets, and that's a big no-no:

- for one this results in full on->off->on transitions on all these crtc, at least if you're using the usual helpers. Which seems to be the case, and is breaking uapi

- further even if the ctm change itself would not result in flicker, this can hide modesets for other reasons. Which again breaks the uapi

Quoted 5 lines

v2: I forgot the case of adding unrelated crtc state. Add that case and link to the existing kerneldoc explainers. This has come up in an irc discussion with Manasi and Ville about intel's bigjoiner mode. Also cc everyone involved in the msm irc discussion, more people joined after I sent out v1.

Quoted 3 lines

I have been looking at the drm_atomic_helper_check_modeset() issue, I couldn't help but notice that this hasn't been committed. Maybe it's time for v3?

Oops. Working on it now.
-Sima

Quoted 61 lines
Quoted 56 lines
Cc Maarten Lankhorst <[email protected]>
Cc Maxime Ripard <[email protected]>
Cc Thomas Zimmermann <[email protected]>
Cc David Airlie <[email protected]>
Cc Daniel Vetter <[email protected]>
Cc Pekka Paalanen <[email protected]>
Cc Rob Clark <[email protected]>
Cc Simon Ser <[email protected]>
Cc Manasi Navare <[email protected]>
Cc Ville Syrjälä <[email protected]>
Cc Abhinav Kumar <[email protected]>
Cc Dmitry Baryshkov <[email protected]>
---
 include/drm/drm_atomic.h | 23 +++++++++++++++++++++--
 1 file changed, 21 insertions(+), 2 deletions(-)
include/drm/drm_atomic.h +21 -3
index cf8e1220a4ac..545c48545402 100644
@@ -372,8 +372,27 @@ struct drm_atomic_state {
         *
         * Allow full modeset. This is used by the ATOMIC IOCTL handler to
         * implement the DRM_MODE_ATOMIC_ALLOW_MODESET flag. Drivers should
-        * never consult this flag, instead looking at the output of
-        * drm_atomic_crtc_needs_modeset().
+        * not consult this flag, instead looking at the output of
+        * drm_atomic_crtc_needs_modeset(). The detailed rules are:
+        *
+        * - Drivers must not consult @allow_modeset in the atomic commit path,
+        *   and instead use drm_atomic_crtc_needs_modeset().
+        *
+        * - Drivers may consult @allow_modeset in the atomic check path, if
+        *   they have the choice between an optimal hardware configuration
+        *   which requires a modeset, and a less optimal configuration which
+        *   can be committed without a modeset. An example would be suboptimal
+        *   scanout FIFO allocation resulting in increased idle power
+        *   consumption. This allows userspace to avoid flickering and delays
+        *   for the normal composition loop at reasonable cost.
+        *
+        * - Drivers must consult @allow_modeset before adding unrelated struct
+        *   drm_crtc_state to this commit by calling
+        *   drm_atomic_get_crtc_state(). See also the warning in the
+        *   documentation for that function.
+        *
+        * - Drivers must never change this flag, it is only under the control
+        *   of userspace.
         */
        bool allow_modeset : 1;
        /**
--

2.40.1

Signature · 2 lines
With best wishes
Dmitry
Signature · 3 lines
Simona Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch