2 * Copyright (C) 2014 Red Hat
3 * Copyright (C) 2014 Intel Corp.
4 * Copyright (C) 2018 Intel Corp.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE COPYRIGHT HOLDER(S) OR AUTHOR(S) BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * OTHER DEALINGS IN THE SOFTWARE.
25 * Rob Clark <robdclark@gmail.com>
26 * Daniel Vetter <daniel.vetter@ffwll.ch>
29 #include <drm/drm_atomic_uapi.h>
30 #include <drm/drm_atomic.h>
31 #include <drm/drm_print.h>
32 #include <drm/drm_drv.h>
33 #include <drm/drm_writeback.h>
34 #include <drm/drm_vblank.h>
36 #include <linux/dma-fence.h>
37 #include <linux/uaccess.h>
38 #include <linux/sync_file.h>
39 #include <linux/file.h>
41 #include "drm_crtc_internal.h"
46 * This file contains the marshalling and demarshalling glue for the atomic UAPI
47 * in all its forms: The monster ATOMIC IOCTL itself, code for GET_PROPERTY and
48 * SET_PROPERTY IOCTLs. Plus interface functions for compatibility helpers and
49 * drivers which have special needs to construct their own atomic updates, e.g.
50 * for load detect or similiar.
54 * drm_atomic_set_mode_for_crtc - set mode for CRTC
55 * @state: the CRTC whose incoming state to update
56 * @mode: kernel-internal mode to use for the CRTC, or NULL to disable
58 * Set a mode (originating from the kernel) on the desired CRTC state and update
59 * the enable property.
62 * Zero on success, error code on failure. Cannot return -EDEADLK.
64 int drm_atomic_set_mode_for_crtc(struct drm_crtc_state
*state
,
65 const struct drm_display_mode
*mode
)
67 struct drm_crtc
*crtc
= state
->crtc
;
68 struct drm_mode_modeinfo umode
;
70 /* Early return for no change. */
71 if (mode
&& memcmp(&state
->mode
, mode
, sizeof(*mode
)) == 0)
74 drm_property_blob_put(state
->mode_blob
);
75 state
->mode_blob
= NULL
;
78 drm_mode_convert_to_umode(&umode
, mode
);
80 drm_property_create_blob(state
->crtc
->dev
,
83 if (IS_ERR(state
->mode_blob
))
84 return PTR_ERR(state
->mode_blob
);
86 drm_mode_copy(&state
->mode
, mode
);
88 drm_dbg_atomic(crtc
->dev
,
89 "Set [MODE:%s] for [CRTC:%d:%s] state %p\n",
90 mode
->name
, crtc
->base
.id
, crtc
->name
, state
);
92 memset(&state
->mode
, 0, sizeof(state
->mode
));
93 state
->enable
= false;
94 drm_dbg_atomic(crtc
->dev
,
95 "Set [NOMODE] for [CRTC:%d:%s] state %p\n",
96 crtc
->base
.id
, crtc
->name
, state
);
101 EXPORT_SYMBOL(drm_atomic_set_mode_for_crtc
);
104 * drm_atomic_set_mode_prop_for_crtc - set mode for CRTC
105 * @state: the CRTC whose incoming state to update
106 * @blob: pointer to blob property to use for mode
108 * Set a mode (originating from a blob property) on the desired CRTC state.
109 * This function will take a reference on the blob property for the CRTC state,
110 * and release the reference held on the state's existing mode property, if any
114 * Zero on success, error code on failure. Cannot return -EDEADLK.
116 int drm_atomic_set_mode_prop_for_crtc(struct drm_crtc_state
*state
,
117 struct drm_property_blob
*blob
)
119 struct drm_crtc
*crtc
= state
->crtc
;
121 if (blob
== state
->mode_blob
)
124 drm_property_blob_put(state
->mode_blob
);
125 state
->mode_blob
= NULL
;
127 memset(&state
->mode
, 0, sizeof(state
->mode
));
132 if (blob
->length
!= sizeof(struct drm_mode_modeinfo
)) {
133 drm_dbg_atomic(crtc
->dev
,
134 "[CRTC:%d:%s] bad mode blob length: %zu\n",
135 crtc
->base
.id
, crtc
->name
,
140 ret
= drm_mode_convert_umode(crtc
->dev
,
141 &state
->mode
, blob
->data
);
143 drm_dbg_atomic(crtc
->dev
,
144 "[CRTC:%d:%s] invalid mode (ret=%d, status=%s):\n",
145 crtc
->base
.id
, crtc
->name
,
146 ret
, drm_get_mode_status_name(state
->mode
.status
));
147 drm_mode_debug_printmodeline(&state
->mode
);
151 state
->mode_blob
= drm_property_blob_get(blob
);
152 state
->enable
= true;
153 drm_dbg_atomic(crtc
->dev
,
154 "Set [MODE:%s] for [CRTC:%d:%s] state %p\n",
155 state
->mode
.name
, crtc
->base
.id
, crtc
->name
,
158 state
->enable
= false;
159 drm_dbg_atomic(crtc
->dev
,
160 "Set [NOMODE] for [CRTC:%d:%s] state %p\n",
161 crtc
->base
.id
, crtc
->name
, state
);
166 EXPORT_SYMBOL(drm_atomic_set_mode_prop_for_crtc
);
169 * drm_atomic_set_crtc_for_plane - set CRTC for plane
170 * @plane_state: the plane whose incoming state to update
171 * @crtc: CRTC to use for the plane
173 * Changing the assigned CRTC for a plane requires us to grab the lock and state
174 * for the new CRTC, as needed. This function takes care of all these details
175 * besides updating the pointer in the state object itself.
178 * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
179 * then the w/w mutex code has detected a deadlock and the entire atomic
180 * sequence must be restarted. All other errors are fatal.
183 drm_atomic_set_crtc_for_plane(struct drm_plane_state
*plane_state
,
184 struct drm_crtc
*crtc
)
186 struct drm_plane
*plane
= plane_state
->plane
;
187 struct drm_crtc_state
*crtc_state
;
188 /* Nothing to do for same crtc*/
189 if (plane_state
->crtc
== crtc
)
191 if (plane_state
->crtc
) {
192 crtc_state
= drm_atomic_get_crtc_state(plane_state
->state
,
194 if (WARN_ON(IS_ERR(crtc_state
)))
195 return PTR_ERR(crtc_state
);
197 crtc_state
->plane_mask
&= ~drm_plane_mask(plane
);
200 plane_state
->crtc
= crtc
;
203 crtc_state
= drm_atomic_get_crtc_state(plane_state
->state
,
205 if (IS_ERR(crtc_state
))
206 return PTR_ERR(crtc_state
);
207 crtc_state
->plane_mask
|= drm_plane_mask(plane
);
211 drm_dbg_atomic(plane
->dev
,
212 "Link [PLANE:%d:%s] state %p to [CRTC:%d:%s]\n",
213 plane
->base
.id
, plane
->name
, plane_state
,
214 crtc
->base
.id
, crtc
->name
);
216 drm_dbg_atomic(plane
->dev
,
217 "Link [PLANE:%d:%s] state %p to [NOCRTC]\n",
218 plane
->base
.id
, plane
->name
, plane_state
);
222 EXPORT_SYMBOL(drm_atomic_set_crtc_for_plane
);
225 * drm_atomic_set_fb_for_plane - set framebuffer for plane
226 * @plane_state: atomic state object for the plane
227 * @fb: fb to use for the plane
229 * Changing the assigned framebuffer for a plane requires us to grab a reference
230 * to the new fb and drop the reference to the old fb, if there is one. This
231 * function takes care of all these details besides updating the pointer in the
232 * state object itself.
235 drm_atomic_set_fb_for_plane(struct drm_plane_state
*plane_state
,
236 struct drm_framebuffer
*fb
)
238 struct drm_plane
*plane
= plane_state
->plane
;
241 drm_dbg_atomic(plane
->dev
,
242 "Set [FB:%d] for [PLANE:%d:%s] state %p\n",
243 fb
->base
.id
, plane
->base
.id
, plane
->name
,
246 drm_dbg_atomic(plane
->dev
,
247 "Set [NOFB] for [PLANE:%d:%s] state %p\n",
248 plane
->base
.id
, plane
->name
, plane_state
);
250 drm_framebuffer_assign(&plane_state
->fb
, fb
);
252 EXPORT_SYMBOL(drm_atomic_set_fb_for_plane
);
255 * drm_atomic_set_fence_for_plane - set fence for plane
256 * @plane_state: atomic state object for the plane
257 * @fence: dma_fence to use for the plane
259 * Helper to setup the plane_state fence in case it is not set yet.
260 * By using this drivers doesn't need to worry if the user choose
261 * implicit or explicit fencing.
263 * This function will not set the fence to the state if it was set
264 * via explicit fencing interfaces on the atomic ioctl. In that case it will
265 * drop the reference to the fence as we are not storing it anywhere.
266 * Otherwise, if &drm_plane_state.fence is not set this function we just set it
267 * with the received implicit fence. In both cases this function consumes a
268 * reference for @fence.
270 * This way explicit fencing can be used to overrule implicit fencing, which is
271 * important to make explicit fencing use-cases work: One example is using one
272 * buffer for 2 screens with different refresh rates. Implicit fencing will
273 * clamp rendering to the refresh rate of the slower screen, whereas explicit
274 * fence allows 2 independent render and display loops on a single buffer. If a
275 * driver allows obeys both implicit and explicit fences for plane updates, then
276 * it will break all the benefits of explicit fencing.
279 drm_atomic_set_fence_for_plane(struct drm_plane_state
*plane_state
,
280 struct dma_fence
*fence
)
282 if (plane_state
->fence
) {
283 dma_fence_put(fence
);
287 plane_state
->fence
= fence
;
289 EXPORT_SYMBOL(drm_atomic_set_fence_for_plane
);
292 * drm_atomic_set_crtc_for_connector - set CRTC for connector
293 * @conn_state: atomic state object for the connector
294 * @crtc: CRTC to use for the connector
296 * Changing the assigned CRTC for a connector requires us to grab the lock and
297 * state for the new CRTC, as needed. This function takes care of all these
298 * details besides updating the pointer in the state object itself.
301 * 0 on success or can fail with -EDEADLK or -ENOMEM. When the error is EDEADLK
302 * then the w/w mutex code has detected a deadlock and the entire atomic
303 * sequence must be restarted. All other errors are fatal.
306 drm_atomic_set_crtc_for_connector(struct drm_connector_state
*conn_state
,
307 struct drm_crtc
*crtc
)
309 struct drm_connector
*connector
= conn_state
->connector
;
310 struct drm_crtc_state
*crtc_state
;
312 if (conn_state
->crtc
== crtc
)
315 if (conn_state
->crtc
) {
316 crtc_state
= drm_atomic_get_new_crtc_state(conn_state
->state
,
319 crtc_state
->connector_mask
&=
320 ~drm_connector_mask(conn_state
->connector
);
322 drm_connector_put(conn_state
->connector
);
323 conn_state
->crtc
= NULL
;
327 crtc_state
= drm_atomic_get_crtc_state(conn_state
->state
, crtc
);
328 if (IS_ERR(crtc_state
))
329 return PTR_ERR(crtc_state
);
331 crtc_state
->connector_mask
|=
332 drm_connector_mask(conn_state
->connector
);
334 drm_connector_get(conn_state
->connector
);
335 conn_state
->crtc
= crtc
;
337 drm_dbg_atomic(connector
->dev
,
338 "Link [CONNECTOR:%d:%s] state %p to [CRTC:%d:%s]\n",
339 connector
->base
.id
, connector
->name
,
340 conn_state
, crtc
->base
.id
, crtc
->name
);
342 drm_dbg_atomic(connector
->dev
,
343 "Link [CONNECTOR:%d:%s] state %p to [NOCRTC]\n",
344 connector
->base
.id
, connector
->name
,
350 EXPORT_SYMBOL(drm_atomic_set_crtc_for_connector
);
352 static void set_out_fence_for_crtc(struct drm_atomic_state
*state
,
353 struct drm_crtc
*crtc
, s32 __user
*fence_ptr
)
355 state
->crtcs
[drm_crtc_index(crtc
)].out_fence_ptr
= fence_ptr
;
358 static s32 __user
*get_out_fence_for_crtc(struct drm_atomic_state
*state
,
359 struct drm_crtc
*crtc
)
361 s32 __user
*fence_ptr
;
363 fence_ptr
= state
->crtcs
[drm_crtc_index(crtc
)].out_fence_ptr
;
364 state
->crtcs
[drm_crtc_index(crtc
)].out_fence_ptr
= NULL
;
369 static int set_out_fence_for_connector(struct drm_atomic_state
*state
,
370 struct drm_connector
*connector
,
371 s32 __user
*fence_ptr
)
373 unsigned int index
= drm_connector_index(connector
);
378 if (put_user(-1, fence_ptr
))
381 state
->connectors
[index
].out_fence_ptr
= fence_ptr
;
386 static s32 __user
*get_out_fence_for_connector(struct drm_atomic_state
*state
,
387 struct drm_connector
*connector
)
389 unsigned int index
= drm_connector_index(connector
);
390 s32 __user
*fence_ptr
;
392 fence_ptr
= state
->connectors
[index
].out_fence_ptr
;
393 state
->connectors
[index
].out_fence_ptr
= NULL
;
399 drm_atomic_replace_property_blob_from_id(struct drm_device
*dev
,
400 struct drm_property_blob
**blob
,
402 ssize_t expected_size
,
403 ssize_t expected_elem_size
,
406 struct drm_property_blob
*new_blob
= NULL
;
409 new_blob
= drm_property_lookup_blob(dev
, blob_id
);
410 if (new_blob
== NULL
)
413 if (expected_size
> 0 &&
414 new_blob
->length
!= expected_size
) {
415 drm_property_blob_put(new_blob
);
418 if (expected_elem_size
> 0 &&
419 new_blob
->length
% expected_elem_size
!= 0) {
420 drm_property_blob_put(new_blob
);
425 *replaced
|= drm_property_replace_blob(blob
, new_blob
);
426 drm_property_blob_put(new_blob
);
431 static int drm_atomic_crtc_set_property(struct drm_crtc
*crtc
,
432 struct drm_crtc_state
*state
, struct drm_property
*property
,
435 struct drm_device
*dev
= crtc
->dev
;
436 struct drm_mode_config
*config
= &dev
->mode_config
;
437 bool replaced
= false;
440 if (property
== config
->prop_active
)
442 else if (property
== config
->prop_mode_id
) {
443 struct drm_property_blob
*mode
=
444 drm_property_lookup_blob(dev
, val
);
445 ret
= drm_atomic_set_mode_prop_for_crtc(state
, mode
);
446 drm_property_blob_put(mode
);
448 } else if (property
== config
->prop_vrr_enabled
) {
449 state
->vrr_enabled
= val
;
450 } else if (property
== config
->degamma_lut_property
) {
451 ret
= drm_atomic_replace_property_blob_from_id(dev
,
454 -1, sizeof(struct drm_color_lut
),
456 state
->color_mgmt_changed
|= replaced
;
458 } else if (property
== config
->ctm_property
) {
459 ret
= drm_atomic_replace_property_blob_from_id(dev
,
462 sizeof(struct drm_color_ctm
), -1,
464 state
->color_mgmt_changed
|= replaced
;
466 } else if (property
== config
->gamma_lut_property
) {
467 ret
= drm_atomic_replace_property_blob_from_id(dev
,
470 -1, sizeof(struct drm_color_lut
),
472 state
->color_mgmt_changed
|= replaced
;
474 } else if (property
== config
->prop_out_fence_ptr
) {
475 s32 __user
*fence_ptr
= u64_to_user_ptr(val
);
480 if (put_user(-1, fence_ptr
))
483 set_out_fence_for_crtc(state
->state
, crtc
, fence_ptr
);
484 } else if (property
== crtc
->scaling_filter_property
) {
485 state
->scaling_filter
= val
;
486 } else if (crtc
->funcs
->atomic_set_property
) {
487 return crtc
->funcs
->atomic_set_property(crtc
, state
, property
, val
);
489 drm_dbg_atomic(crtc
->dev
,
490 "[CRTC:%d:%s] unknown property [PROP:%d:%s]]\n",
491 crtc
->base
.id
, crtc
->name
,
492 property
->base
.id
, property
->name
);
500 drm_atomic_crtc_get_property(struct drm_crtc
*crtc
,
501 const struct drm_crtc_state
*state
,
502 struct drm_property
*property
, uint64_t *val
)
504 struct drm_device
*dev
= crtc
->dev
;
505 struct drm_mode_config
*config
= &dev
->mode_config
;
507 if (property
== config
->prop_active
)
508 *val
= drm_atomic_crtc_effectively_active(state
);
509 else if (property
== config
->prop_mode_id
)
510 *val
= (state
->mode_blob
) ? state
->mode_blob
->base
.id
: 0;
511 else if (property
== config
->prop_vrr_enabled
)
512 *val
= state
->vrr_enabled
;
513 else if (property
== config
->degamma_lut_property
)
514 *val
= (state
->degamma_lut
) ? state
->degamma_lut
->base
.id
: 0;
515 else if (property
== config
->ctm_property
)
516 *val
= (state
->ctm
) ? state
->ctm
->base
.id
: 0;
517 else if (property
== config
->gamma_lut_property
)
518 *val
= (state
->gamma_lut
) ? state
->gamma_lut
->base
.id
: 0;
519 else if (property
== config
->prop_out_fence_ptr
)
521 else if (property
== crtc
->scaling_filter_property
)
522 *val
= state
->scaling_filter
;
523 else if (crtc
->funcs
->atomic_get_property
)
524 return crtc
->funcs
->atomic_get_property(crtc
, state
, property
, val
);
531 static int drm_atomic_plane_set_property(struct drm_plane
*plane
,
532 struct drm_plane_state
*state
, struct drm_file
*file_priv
,
533 struct drm_property
*property
, uint64_t val
)
535 struct drm_device
*dev
= plane
->dev
;
536 struct drm_mode_config
*config
= &dev
->mode_config
;
537 bool replaced
= false;
540 if (property
== config
->prop_fb_id
) {
541 struct drm_framebuffer
*fb
;
543 fb
= drm_framebuffer_lookup(dev
, file_priv
, val
);
544 drm_atomic_set_fb_for_plane(state
, fb
);
546 drm_framebuffer_put(fb
);
547 } else if (property
== config
->prop_in_fence_fd
) {
551 if (U642I64(val
) == -1)
554 state
->fence
= sync_file_get_fence(val
);
558 } else if (property
== config
->prop_crtc_id
) {
559 struct drm_crtc
*crtc
= drm_crtc_find(dev
, file_priv
, val
);
563 return drm_atomic_set_crtc_for_plane(state
, crtc
);
564 } else if (property
== config
->prop_crtc_x
) {
565 state
->crtc_x
= U642I64(val
);
566 } else if (property
== config
->prop_crtc_y
) {
567 state
->crtc_y
= U642I64(val
);
568 } else if (property
== config
->prop_crtc_w
) {
570 } else if (property
== config
->prop_crtc_h
) {
572 } else if (property
== config
->prop_src_x
) {
574 } else if (property
== config
->prop_src_y
) {
576 } else if (property
== config
->prop_src_w
) {
578 } else if (property
== config
->prop_src_h
) {
580 } else if (property
== plane
->alpha_property
) {
582 } else if (property
== plane
->blend_mode_property
) {
583 state
->pixel_blend_mode
= val
;
584 } else if (property
== plane
->rotation_property
) {
585 if (!is_power_of_2(val
& DRM_MODE_ROTATE_MASK
)) {
586 drm_dbg_atomic(plane
->dev
,
587 "[PLANE:%d:%s] bad rotation bitmask: 0x%llx\n",
588 plane
->base
.id
, plane
->name
, val
);
591 state
->rotation
= val
;
592 } else if (property
== plane
->zpos_property
) {
594 } else if (property
== plane
->color_encoding_property
) {
595 state
->color_encoding
= val
;
596 } else if (property
== plane
->color_range_property
) {
597 state
->color_range
= val
;
598 } else if (property
== config
->prop_fb_damage_clips
) {
599 ret
= drm_atomic_replace_property_blob_from_id(dev
,
600 &state
->fb_damage_clips
,
603 sizeof(struct drm_rect
),
606 } else if (property
== plane
->scaling_filter_property
) {
607 state
->scaling_filter
= val
;
608 } else if (plane
->funcs
->atomic_set_property
) {
609 return plane
->funcs
->atomic_set_property(plane
, state
,
612 drm_dbg_atomic(plane
->dev
,
613 "[PLANE:%d:%s] unknown property [PROP:%d:%s]]\n",
614 plane
->base
.id
, plane
->name
,
615 property
->base
.id
, property
->name
);
623 drm_atomic_plane_get_property(struct drm_plane
*plane
,
624 const struct drm_plane_state
*state
,
625 struct drm_property
*property
, uint64_t *val
)
627 struct drm_device
*dev
= plane
->dev
;
628 struct drm_mode_config
*config
= &dev
->mode_config
;
630 if (property
== config
->prop_fb_id
) {
631 *val
= (state
->fb
) ? state
->fb
->base
.id
: 0;
632 } else if (property
== config
->prop_in_fence_fd
) {
634 } else if (property
== config
->prop_crtc_id
) {
635 *val
= (state
->crtc
) ? state
->crtc
->base
.id
: 0;
636 } else if (property
== config
->prop_crtc_x
) {
637 *val
= I642U64(state
->crtc_x
);
638 } else if (property
== config
->prop_crtc_y
) {
639 *val
= I642U64(state
->crtc_y
);
640 } else if (property
== config
->prop_crtc_w
) {
641 *val
= state
->crtc_w
;
642 } else if (property
== config
->prop_crtc_h
) {
643 *val
= state
->crtc_h
;
644 } else if (property
== config
->prop_src_x
) {
646 } else if (property
== config
->prop_src_y
) {
648 } else if (property
== config
->prop_src_w
) {
650 } else if (property
== config
->prop_src_h
) {
652 } else if (property
== plane
->alpha_property
) {
654 } else if (property
== plane
->blend_mode_property
) {
655 *val
= state
->pixel_blend_mode
;
656 } else if (property
== plane
->rotation_property
) {
657 *val
= state
->rotation
;
658 } else if (property
== plane
->zpos_property
) {
660 } else if (property
== plane
->color_encoding_property
) {
661 *val
= state
->color_encoding
;
662 } else if (property
== plane
->color_range_property
) {
663 *val
= state
->color_range
;
664 } else if (property
== config
->prop_fb_damage_clips
) {
665 *val
= (state
->fb_damage_clips
) ?
666 state
->fb_damage_clips
->base
.id
: 0;
667 } else if (property
== plane
->scaling_filter_property
) {
668 *val
= state
->scaling_filter
;
669 } else if (plane
->funcs
->atomic_get_property
) {
670 return plane
->funcs
->atomic_get_property(plane
, state
, property
, val
);
678 static int drm_atomic_set_writeback_fb_for_connector(
679 struct drm_connector_state
*conn_state
,
680 struct drm_framebuffer
*fb
)
683 struct drm_connector
*conn
= conn_state
->connector
;
685 ret
= drm_writeback_set_fb(conn_state
, fb
);
690 drm_dbg_atomic(conn
->dev
,
691 "Set [FB:%d] for connector state %p\n",
692 fb
->base
.id
, conn_state
);
694 drm_dbg_atomic(conn
->dev
,
695 "Set [NOFB] for connector state %p\n",
701 static int drm_atomic_connector_set_property(struct drm_connector
*connector
,
702 struct drm_connector_state
*state
, struct drm_file
*file_priv
,
703 struct drm_property
*property
, uint64_t val
)
705 struct drm_device
*dev
= connector
->dev
;
706 struct drm_mode_config
*config
= &dev
->mode_config
;
707 bool replaced
= false;
710 if (property
== config
->prop_crtc_id
) {
711 struct drm_crtc
*crtc
= drm_crtc_find(dev
, file_priv
, val
);
715 return drm_atomic_set_crtc_for_connector(state
, crtc
);
716 } else if (property
== config
->dpms_property
) {
717 /* setting DPMS property requires special handling, which
718 * is done in legacy setprop path for us. Disallow (for
719 * now?) atomic writes to DPMS property:
722 } else if (property
== config
->tv_select_subconnector_property
) {
723 state
->tv
.subconnector
= val
;
724 } else if (property
== config
->tv_left_margin_property
) {
725 state
->tv
.margins
.left
= val
;
726 } else if (property
== config
->tv_right_margin_property
) {
727 state
->tv
.margins
.right
= val
;
728 } else if (property
== config
->tv_top_margin_property
) {
729 state
->tv
.margins
.top
= val
;
730 } else if (property
== config
->tv_bottom_margin_property
) {
731 state
->tv
.margins
.bottom
= val
;
732 } else if (property
== config
->tv_mode_property
) {
733 state
->tv
.mode
= val
;
734 } else if (property
== config
->tv_brightness_property
) {
735 state
->tv
.brightness
= val
;
736 } else if (property
== config
->tv_contrast_property
) {
737 state
->tv
.contrast
= val
;
738 } else if (property
== config
->tv_flicker_reduction_property
) {
739 state
->tv
.flicker_reduction
= val
;
740 } else if (property
== config
->tv_overscan_property
) {
741 state
->tv
.overscan
= val
;
742 } else if (property
== config
->tv_saturation_property
) {
743 state
->tv
.saturation
= val
;
744 } else if (property
== config
->tv_hue_property
) {
746 } else if (property
== config
->link_status_property
) {
747 /* Never downgrade from GOOD to BAD on userspace's request here,
748 * only hw issues can do that.
750 * For an atomic property the userspace doesn't need to be able
751 * to understand all the properties, but needs to be able to
752 * restore the state it wants on VT switch. So if the userspace
753 * tries to change the link_status from GOOD to BAD, driver
754 * silently rejects it and returns a 0. This prevents userspace
755 * from accidently breaking the display when it restores the
758 if (state
->link_status
!= DRM_LINK_STATUS_GOOD
)
759 state
->link_status
= val
;
760 } else if (property
== config
->hdr_output_metadata_property
) {
761 ret
= drm_atomic_replace_property_blob_from_id(dev
,
762 &state
->hdr_output_metadata
,
764 sizeof(struct hdr_output_metadata
), -1,
767 } else if (property
== config
->aspect_ratio_property
) {
768 state
->picture_aspect_ratio
= val
;
769 } else if (property
== config
->content_type_property
) {
770 state
->content_type
= val
;
771 } else if (property
== connector
->scaling_mode_property
) {
772 state
->scaling_mode
= val
;
773 } else if (property
== config
->content_protection_property
) {
774 if (val
== DRM_MODE_CONTENT_PROTECTION_ENABLED
) {
775 DRM_DEBUG_KMS("only drivers can set CP Enabled\n");
778 state
->content_protection
= val
;
779 } else if (property
== config
->hdcp_content_type_property
) {
780 state
->hdcp_content_type
= val
;
781 } else if (property
== connector
->colorspace_property
) {
782 state
->colorspace
= val
;
783 } else if (property
== config
->writeback_fb_id_property
) {
784 struct drm_framebuffer
*fb
;
787 fb
= drm_framebuffer_lookup(dev
, file_priv
, val
);
788 ret
= drm_atomic_set_writeback_fb_for_connector(state
, fb
);
790 drm_framebuffer_put(fb
);
792 } else if (property
== config
->writeback_out_fence_ptr_property
) {
793 s32 __user
*fence_ptr
= u64_to_user_ptr(val
);
795 return set_out_fence_for_connector(state
->state
, connector
,
797 } else if (property
== connector
->max_bpc_property
) {
798 state
->max_requested_bpc
= val
;
799 } else if (connector
->funcs
->atomic_set_property
) {
800 return connector
->funcs
->atomic_set_property(connector
,
801 state
, property
, val
);
803 drm_dbg_atomic(connector
->dev
,
804 "[CONNECTOR:%d:%s] unknown property [PROP:%d:%s]]\n",
805 connector
->base
.id
, connector
->name
,
806 property
->base
.id
, property
->name
);
814 drm_atomic_connector_get_property(struct drm_connector
*connector
,
815 const struct drm_connector_state
*state
,
816 struct drm_property
*property
, uint64_t *val
)
818 struct drm_device
*dev
= connector
->dev
;
819 struct drm_mode_config
*config
= &dev
->mode_config
;
821 if (property
== config
->prop_crtc_id
) {
822 *val
= (state
->crtc
) ? state
->crtc
->base
.id
: 0;
823 } else if (property
== config
->dpms_property
) {
824 if (state
->crtc
&& state
->crtc
->state
->self_refresh_active
)
825 *val
= DRM_MODE_DPMS_ON
;
827 *val
= connector
->dpms
;
828 } else if (property
== config
->tv_select_subconnector_property
) {
829 *val
= state
->tv
.subconnector
;
830 } else if (property
== config
->tv_left_margin_property
) {
831 *val
= state
->tv
.margins
.left
;
832 } else if (property
== config
->tv_right_margin_property
) {
833 *val
= state
->tv
.margins
.right
;
834 } else if (property
== config
->tv_top_margin_property
) {
835 *val
= state
->tv
.margins
.top
;
836 } else if (property
== config
->tv_bottom_margin_property
) {
837 *val
= state
->tv
.margins
.bottom
;
838 } else if (property
== config
->tv_mode_property
) {
839 *val
= state
->tv
.mode
;
840 } else if (property
== config
->tv_brightness_property
) {
841 *val
= state
->tv
.brightness
;
842 } else if (property
== config
->tv_contrast_property
) {
843 *val
= state
->tv
.contrast
;
844 } else if (property
== config
->tv_flicker_reduction_property
) {
845 *val
= state
->tv
.flicker_reduction
;
846 } else if (property
== config
->tv_overscan_property
) {
847 *val
= state
->tv
.overscan
;
848 } else if (property
== config
->tv_saturation_property
) {
849 *val
= state
->tv
.saturation
;
850 } else if (property
== config
->tv_hue_property
) {
851 *val
= state
->tv
.hue
;
852 } else if (property
== config
->link_status_property
) {
853 *val
= state
->link_status
;
854 } else if (property
== config
->aspect_ratio_property
) {
855 *val
= state
->picture_aspect_ratio
;
856 } else if (property
== config
->content_type_property
) {
857 *val
= state
->content_type
;
858 } else if (property
== connector
->colorspace_property
) {
859 *val
= state
->colorspace
;
860 } else if (property
== connector
->scaling_mode_property
) {
861 *val
= state
->scaling_mode
;
862 } else if (property
== config
->hdr_output_metadata_property
) {
863 *val
= state
->hdr_output_metadata
?
864 state
->hdr_output_metadata
->base
.id
: 0;
865 } else if (property
== config
->content_protection_property
) {
866 *val
= state
->content_protection
;
867 } else if (property
== config
->hdcp_content_type_property
) {
868 *val
= state
->hdcp_content_type
;
869 } else if (property
== config
->writeback_fb_id_property
) {
870 /* Writeback framebuffer is one-shot, write and forget */
872 } else if (property
== config
->writeback_out_fence_ptr_property
) {
874 } else if (property
== connector
->max_bpc_property
) {
875 *val
= state
->max_requested_bpc
;
876 } else if (connector
->funcs
->atomic_get_property
) {
877 return connector
->funcs
->atomic_get_property(connector
,
878 state
, property
, val
);
886 int drm_atomic_get_property(struct drm_mode_object
*obj
,
887 struct drm_property
*property
, uint64_t *val
)
889 struct drm_device
*dev
= property
->dev
;
893 case DRM_MODE_OBJECT_CONNECTOR
: {
894 struct drm_connector
*connector
= obj_to_connector(obj
);
896 WARN_ON(!drm_modeset_is_locked(&dev
->mode_config
.connection_mutex
));
897 ret
= drm_atomic_connector_get_property(connector
,
898 connector
->state
, property
, val
);
901 case DRM_MODE_OBJECT_CRTC
: {
902 struct drm_crtc
*crtc
= obj_to_crtc(obj
);
904 WARN_ON(!drm_modeset_is_locked(&crtc
->mutex
));
905 ret
= drm_atomic_crtc_get_property(crtc
,
906 crtc
->state
, property
, val
);
909 case DRM_MODE_OBJECT_PLANE
: {
910 struct drm_plane
*plane
= obj_to_plane(obj
);
912 WARN_ON(!drm_modeset_is_locked(&plane
->mutex
));
913 ret
= drm_atomic_plane_get_property(plane
,
914 plane
->state
, property
, val
);
926 * The big monster ioctl
929 static struct drm_pending_vblank_event
*create_vblank_event(
930 struct drm_crtc
*crtc
, uint64_t user_data
)
932 struct drm_pending_vblank_event
*e
= NULL
;
934 e
= kzalloc(sizeof *e
, GFP_KERNEL
);
938 e
->event
.base
.type
= DRM_EVENT_FLIP_COMPLETE
;
939 e
->event
.base
.length
= sizeof(e
->event
);
940 e
->event
.vbl
.crtc_id
= crtc
->base
.id
;
941 e
->event
.vbl
.user_data
= user_data
;
946 int drm_atomic_connector_commit_dpms(struct drm_atomic_state
*state
,
947 struct drm_connector
*connector
,
950 struct drm_connector
*tmp_connector
;
951 struct drm_connector_state
*new_conn_state
;
952 struct drm_crtc
*crtc
;
953 struct drm_crtc_state
*crtc_state
;
954 int i
, ret
, old_mode
= connector
->dpms
;
957 ret
= drm_modeset_lock(&state
->dev
->mode_config
.connection_mutex
,
962 if (mode
!= DRM_MODE_DPMS_ON
)
963 mode
= DRM_MODE_DPMS_OFF
;
964 connector
->dpms
= mode
;
966 crtc
= connector
->state
->crtc
;
969 ret
= drm_atomic_add_affected_connectors(state
, crtc
);
973 crtc_state
= drm_atomic_get_crtc_state(state
, crtc
);
974 if (IS_ERR(crtc_state
)) {
975 ret
= PTR_ERR(crtc_state
);
979 for_each_new_connector_in_state(state
, tmp_connector
, new_conn_state
, i
) {
980 if (new_conn_state
->crtc
!= crtc
)
982 if (tmp_connector
->dpms
== DRM_MODE_DPMS_ON
) {
988 crtc_state
->active
= active
;
989 ret
= drm_atomic_commit(state
);
992 connector
->dpms
= old_mode
;
996 int drm_atomic_set_property(struct drm_atomic_state
*state
,
997 struct drm_file
*file_priv
,
998 struct drm_mode_object
*obj
,
999 struct drm_property
*prop
,
1000 uint64_t prop_value
)
1002 struct drm_mode_object
*ref
;
1005 if (!drm_property_change_valid_get(prop
, prop_value
, &ref
))
1008 switch (obj
->type
) {
1009 case DRM_MODE_OBJECT_CONNECTOR
: {
1010 struct drm_connector
*connector
= obj_to_connector(obj
);
1011 struct drm_connector_state
*connector_state
;
1013 connector_state
= drm_atomic_get_connector_state(state
, connector
);
1014 if (IS_ERR(connector_state
)) {
1015 ret
= PTR_ERR(connector_state
);
1019 ret
= drm_atomic_connector_set_property(connector
,
1020 connector_state
, file_priv
,
1024 case DRM_MODE_OBJECT_CRTC
: {
1025 struct drm_crtc
*crtc
= obj_to_crtc(obj
);
1026 struct drm_crtc_state
*crtc_state
;
1028 crtc_state
= drm_atomic_get_crtc_state(state
, crtc
);
1029 if (IS_ERR(crtc_state
)) {
1030 ret
= PTR_ERR(crtc_state
);
1034 ret
= drm_atomic_crtc_set_property(crtc
,
1035 crtc_state
, prop
, prop_value
);
1038 case DRM_MODE_OBJECT_PLANE
: {
1039 struct drm_plane
*plane
= obj_to_plane(obj
);
1040 struct drm_plane_state
*plane_state
;
1042 plane_state
= drm_atomic_get_plane_state(state
, plane
);
1043 if (IS_ERR(plane_state
)) {
1044 ret
= PTR_ERR(plane_state
);
1048 ret
= drm_atomic_plane_set_property(plane
,
1049 plane_state
, file_priv
,
1058 drm_property_change_valid_put(prop
, ref
);
1063 * DOC: explicit fencing properties
1065 * Explicit fencing allows userspace to control the buffer synchronization
1066 * between devices. A Fence or a group of fences are transfered to/from
1067 * userspace using Sync File fds and there are two DRM properties for that.
1068 * IN_FENCE_FD on each DRM Plane to send fences to the kernel and
1069 * OUT_FENCE_PTR on each DRM CRTC to receive fences from the kernel.
1071 * As a contrast, with implicit fencing the kernel keeps track of any
1072 * ongoing rendering, and automatically ensures that the atomic update waits
1073 * for any pending rendering to complete. For shared buffers represented with
1074 * a &struct dma_buf this is tracked in &struct dma_resv.
1075 * Implicit syncing is how Linux traditionally worked (e.g. DRI2/3 on X.org),
1076 * whereas explicit fencing is what Android wants.
1079 * Use this property to pass a fence that DRM should wait on before
1080 * proceeding with the Atomic Commit request and show the framebuffer for
1081 * the plane on the screen. The fence can be either a normal fence or a
1082 * merged one, the sync_file framework will handle both cases and use a
1083 * fence_array if a merged fence is received. Passing -1 here means no
1084 * fences to wait on.
1086 * If the Atomic Commit request has the DRM_MODE_ATOMIC_TEST_ONLY flag
1087 * it will only check if the Sync File is a valid one.
1089 * On the driver side the fence is stored on the @fence parameter of
1090 * &struct drm_plane_state. Drivers which also support implicit fencing
1091 * should set the implicit fence using drm_atomic_set_fence_for_plane(),
1092 * to make sure there's consistent behaviour between drivers in precedence
1093 * of implicit vs. explicit fencing.
1096 * Use this property to pass a file descriptor pointer to DRM. Once the
1097 * Atomic Commit request call returns OUT_FENCE_PTR will be filled with
1098 * the file descriptor number of a Sync File. This Sync File contains the
1099 * CRTC fence that will be signaled when all framebuffers present on the
1100 * Atomic Commit * request for that given CRTC are scanned out on the
1103 * The Atomic Commit request fails if a invalid pointer is passed. If the
1104 * Atomic Commit request fails for any other reason the out fence fd
1105 * returned will be -1. On a Atomic Commit with the
1106 * DRM_MODE_ATOMIC_TEST_ONLY flag the out fence will also be set to -1.
1108 * Note that out-fences don't have a special interface to drivers and are
1109 * internally represented by a &struct drm_pending_vblank_event in struct
1110 * &drm_crtc_state, which is also used by the nonblocking atomic commit
1111 * helpers and for the DRM event handling for existing userspace.
1114 struct drm_out_fence_state
{
1115 s32 __user
*out_fence_ptr
;
1116 struct sync_file
*sync_file
;
1120 static int setup_out_fence(struct drm_out_fence_state
*fence_state
,
1121 struct dma_fence
*fence
)
1123 fence_state
->fd
= get_unused_fd_flags(O_CLOEXEC
);
1124 if (fence_state
->fd
< 0)
1125 return fence_state
->fd
;
1127 if (put_user(fence_state
->fd
, fence_state
->out_fence_ptr
))
1130 fence_state
->sync_file
= sync_file_create(fence
);
1131 if (!fence_state
->sync_file
)
1137 static int prepare_signaling(struct drm_device
*dev
,
1138 struct drm_atomic_state
*state
,
1139 struct drm_mode_atomic
*arg
,
1140 struct drm_file
*file_priv
,
1141 struct drm_out_fence_state
**fence_state
,
1142 unsigned int *num_fences
)
1144 struct drm_crtc
*crtc
;
1145 struct drm_crtc_state
*crtc_state
;
1146 struct drm_connector
*conn
;
1147 struct drm_connector_state
*conn_state
;
1150 if (arg
->flags
& DRM_MODE_ATOMIC_TEST_ONLY
)
1153 for_each_new_crtc_in_state(state
, crtc
, crtc_state
, i
) {
1154 s32 __user
*fence_ptr
;
1156 fence_ptr
= get_out_fence_for_crtc(crtc_state
->state
, crtc
);
1158 if (arg
->flags
& DRM_MODE_PAGE_FLIP_EVENT
|| fence_ptr
) {
1159 struct drm_pending_vblank_event
*e
;
1161 e
= create_vblank_event(crtc
, arg
->user_data
);
1165 crtc_state
->event
= e
;
1168 if (arg
->flags
& DRM_MODE_PAGE_FLIP_EVENT
) {
1169 struct drm_pending_vblank_event
*e
= crtc_state
->event
;
1174 ret
= drm_event_reserve_init(dev
, file_priv
, &e
->base
,
1178 crtc_state
->event
= NULL
;
1184 struct dma_fence
*fence
;
1185 struct drm_out_fence_state
*f
;
1187 f
= krealloc(*fence_state
, sizeof(**fence_state
) *
1188 (*num_fences
+ 1), GFP_KERNEL
);
1192 memset(&f
[*num_fences
], 0, sizeof(*f
));
1194 f
[*num_fences
].out_fence_ptr
= fence_ptr
;
1197 fence
= drm_crtc_create_fence(crtc
);
1201 ret
= setup_out_fence(&f
[(*num_fences
)++], fence
);
1203 dma_fence_put(fence
);
1207 crtc_state
->event
->base
.fence
= fence
;
1213 for_each_new_connector_in_state(state
, conn
, conn_state
, i
) {
1214 struct drm_writeback_connector
*wb_conn
;
1215 struct drm_out_fence_state
*f
;
1216 struct dma_fence
*fence
;
1217 s32 __user
*fence_ptr
;
1219 if (!conn_state
->writeback_job
)
1222 fence_ptr
= get_out_fence_for_connector(state
, conn
);
1226 f
= krealloc(*fence_state
, sizeof(**fence_state
) *
1227 (*num_fences
+ 1), GFP_KERNEL
);
1231 memset(&f
[*num_fences
], 0, sizeof(*f
));
1233 f
[*num_fences
].out_fence_ptr
= fence_ptr
;
1236 wb_conn
= drm_connector_to_writeback(conn
);
1237 fence
= drm_writeback_get_out_fence(wb_conn
);
1241 ret
= setup_out_fence(&f
[(*num_fences
)++], fence
);
1243 dma_fence_put(fence
);
1247 conn_state
->writeback_job
->out_fence
= fence
;
1251 * Having this flag means user mode pends on event which will never
1252 * reach due to lack of at least one CRTC for signaling
1254 if (c
== 0 && (arg
->flags
& DRM_MODE_PAGE_FLIP_EVENT
))
1260 static void complete_signaling(struct drm_device
*dev
,
1261 struct drm_atomic_state
*state
,
1262 struct drm_out_fence_state
*fence_state
,
1263 unsigned int num_fences
,
1266 struct drm_crtc
*crtc
;
1267 struct drm_crtc_state
*crtc_state
;
1271 for (i
= 0; i
< num_fences
; i
++)
1272 fd_install(fence_state
[i
].fd
,
1273 fence_state
[i
].sync_file
->file
);
1279 for_each_new_crtc_in_state(state
, crtc
, crtc_state
, i
) {
1280 struct drm_pending_vblank_event
*event
= crtc_state
->event
;
1282 * Free the allocated event. drm_atomic_helper_setup_commit
1283 * can allocate an event too, so only free it if it's ours
1284 * to prevent a double free in drm_atomic_state_clear.
1286 if (event
&& (event
->base
.fence
|| event
->base
.file_priv
)) {
1287 drm_event_cancel_free(dev
, &event
->base
);
1288 crtc_state
->event
= NULL
;
1295 for (i
= 0; i
< num_fences
; i
++) {
1296 if (fence_state
[i
].sync_file
)
1297 fput(fence_state
[i
].sync_file
->file
);
1298 if (fence_state
[i
].fd
>= 0)
1299 put_unused_fd(fence_state
[i
].fd
);
1301 /* If this fails log error to the user */
1302 if (fence_state
[i
].out_fence_ptr
&&
1303 put_user(-1, fence_state
[i
].out_fence_ptr
))
1304 drm_dbg_atomic(dev
, "Couldn't clear out_fence_ptr\n");
1310 int drm_mode_atomic_ioctl(struct drm_device
*dev
,
1311 void *data
, struct drm_file
*file_priv
)
1313 struct drm_mode_atomic
*arg
= data
;
1314 uint32_t __user
*objs_ptr
= (uint32_t __user
*)(unsigned long)(arg
->objs_ptr
);
1315 uint32_t __user
*count_props_ptr
= (uint32_t __user
*)(unsigned long)(arg
->count_props_ptr
);
1316 uint32_t __user
*props_ptr
= (uint32_t __user
*)(unsigned long)(arg
->props_ptr
);
1317 uint64_t __user
*prop_values_ptr
= (uint64_t __user
*)(unsigned long)(arg
->prop_values_ptr
);
1318 unsigned int copied_objs
, copied_props
;
1319 struct drm_atomic_state
*state
;
1320 struct drm_modeset_acquire_ctx ctx
;
1321 struct drm_out_fence_state
*fence_state
;
1323 unsigned int i
, j
, num_fences
;
1325 /* disallow for drivers not supporting atomic: */
1326 if (!drm_core_check_feature(dev
, DRIVER_ATOMIC
))
1329 /* disallow for userspace that has not enabled atomic cap (even
1330 * though this may be a bit overkill, since legacy userspace
1331 * wouldn't know how to call this ioctl)
1333 if (!file_priv
->atomic
) {
1335 "commit failed: atomic cap not enabled\n");
1339 if (arg
->flags
& ~DRM_MODE_ATOMIC_FLAGS
) {
1340 drm_dbg_atomic(dev
, "commit failed: invalid flag\n");
1344 if (arg
->reserved
) {
1345 drm_dbg_atomic(dev
, "commit failed: reserved field set\n");
1349 if (arg
->flags
& DRM_MODE_PAGE_FLIP_ASYNC
) {
1351 "commit failed: invalid flag DRM_MODE_PAGE_FLIP_ASYNC\n");
1355 /* can't test and expect an event at the same time. */
1356 if ((arg
->flags
& DRM_MODE_ATOMIC_TEST_ONLY
) &&
1357 (arg
->flags
& DRM_MODE_PAGE_FLIP_EVENT
)) {
1359 "commit failed: page-flip event requested with test-only commit\n");
1363 state
= drm_atomic_state_alloc(dev
);
1367 drm_modeset_acquire_init(&ctx
, DRM_MODESET_ACQUIRE_INTERRUPTIBLE
);
1368 state
->acquire_ctx
= &ctx
;
1369 state
->allow_modeset
= !!(arg
->flags
& DRM_MODE_ATOMIC_ALLOW_MODESET
);
1377 for (i
= 0; i
< arg
->count_objs
; i
++) {
1378 uint32_t obj_id
, count_props
;
1379 struct drm_mode_object
*obj
;
1381 if (get_user(obj_id
, objs_ptr
+ copied_objs
)) {
1386 obj
= drm_mode_object_find(dev
, file_priv
, obj_id
, DRM_MODE_OBJECT_ANY
);
1392 if (!obj
->properties
) {
1393 drm_mode_object_put(obj
);
1398 if (get_user(count_props
, count_props_ptr
+ copied_objs
)) {
1399 drm_mode_object_put(obj
);
1406 for (j
= 0; j
< count_props
; j
++) {
1408 uint64_t prop_value
;
1409 struct drm_property
*prop
;
1411 if (get_user(prop_id
, props_ptr
+ copied_props
)) {
1412 drm_mode_object_put(obj
);
1417 prop
= drm_mode_obj_find_prop_id(obj
, prop_id
);
1419 drm_mode_object_put(obj
);
1424 if (copy_from_user(&prop_value
,
1425 prop_values_ptr
+ copied_props
,
1426 sizeof(prop_value
))) {
1427 drm_mode_object_put(obj
);
1432 ret
= drm_atomic_set_property(state
, file_priv
,
1433 obj
, prop
, prop_value
);
1435 drm_mode_object_put(obj
);
1442 drm_mode_object_put(obj
);
1445 ret
= prepare_signaling(dev
, state
, arg
, file_priv
, &fence_state
,
1450 if (arg
->flags
& DRM_MODE_ATOMIC_TEST_ONLY
) {
1451 ret
= drm_atomic_check_only(state
);
1452 } else if (arg
->flags
& DRM_MODE_ATOMIC_NONBLOCK
) {
1453 ret
= drm_atomic_nonblocking_commit(state
);
1455 if (drm_debug_enabled(DRM_UT_STATE
))
1456 drm_atomic_print_state(state
);
1458 ret
= drm_atomic_commit(state
);
1462 complete_signaling(dev
, state
, fence_state
, num_fences
, !ret
);
1464 if (ret
== -EDEADLK
) {
1465 drm_atomic_state_clear(state
);
1466 ret
= drm_modeset_backoff(&ctx
);
1471 drm_atomic_state_put(state
);
1473 drm_modeset_drop_locks(&ctx
);
1474 drm_modeset_acquire_fini(&ctx
);