| .. | .. |
|---|
| 21 | 21 | * OTHER DEALINGS IN THE SOFTWARE. |
|---|
| 22 | 22 | */ |
|---|
| 23 | 23 | |
|---|
| 24 | | -#include <drm/drmP.h> |
|---|
| 24 | +#include <drm/drm_atomic.h> |
|---|
| 25 | 25 | #include <drm/drm_crtc.h> |
|---|
| 26 | +#include <drm/drm_device.h> |
|---|
| 26 | 27 | #include <drm/drm_modeset_lock.h> |
|---|
| 27 | 28 | |
|---|
| 28 | 29 | /** |
|---|
| .. | .. |
|---|
| 35 | 36 | * of extra utility/tracking out of our acquire-ctx. This is provided |
|---|
| 36 | 37 | * by &struct drm_modeset_lock and &struct drm_modeset_acquire_ctx. |
|---|
| 37 | 38 | * |
|---|
| 38 | | - * For basic principles of &ww_mutex, see: Documentation/locking/ww-mutex-design.txt |
|---|
| 39 | + * For basic principles of &ww_mutex, see: Documentation/locking/ww-mutex-design.rst |
|---|
| 39 | 40 | * |
|---|
| 40 | 41 | * The basic usage pattern is to:: |
|---|
| 41 | 42 | * |
|---|
| .. | .. |
|---|
| 55 | 56 | * out: |
|---|
| 56 | 57 | * drm_modeset_drop_locks(ctx); |
|---|
| 57 | 58 | * drm_modeset_acquire_fini(ctx); |
|---|
| 59 | + * |
|---|
| 60 | + * For convenience this control flow is implemented in |
|---|
| 61 | + * DRM_MODESET_LOCK_ALL_BEGIN() and DRM_MODESET_LOCK_ALL_END() for the case |
|---|
| 62 | + * where all modeset locks need to be taken through drm_modeset_lock_all_ctx(). |
|---|
| 58 | 63 | * |
|---|
| 59 | 64 | * If all that is needed is a single modeset lock, then the &struct |
|---|
| 60 | 65 | * drm_modeset_acquire_ctx is not needed and the locking can be simplified |
|---|
| .. | .. |
|---|
| 383 | 388 | * Locks acquired with this function should be released by calling the |
|---|
| 384 | 389 | * drm_modeset_drop_locks() function on @ctx. |
|---|
| 385 | 390 | * |
|---|
| 391 | + * See also: DRM_MODESET_LOCK_ALL_BEGIN() and DRM_MODESET_LOCK_ALL_END() |
|---|
| 392 | + * |
|---|
| 386 | 393 | * Returns: 0 on success or a negative error-code on failure. |
|---|
| 387 | 394 | */ |
|---|
| 388 | 395 | int drm_modeset_lock_all_ctx(struct drm_device *dev, |
|---|
| 389 | 396 | struct drm_modeset_acquire_ctx *ctx) |
|---|
| 390 | 397 | { |
|---|
| 398 | + struct drm_private_obj *privobj; |
|---|
| 391 | 399 | struct drm_crtc *crtc; |
|---|
| 392 | 400 | struct drm_plane *plane; |
|---|
| 393 | 401 | int ret; |
|---|
| .. | .. |
|---|
| 408 | 416 | return ret; |
|---|
| 409 | 417 | } |
|---|
| 410 | 418 | |
|---|
| 419 | + drm_for_each_privobj(privobj, dev) { |
|---|
| 420 | + ret = drm_modeset_lock(&privobj->lock, ctx); |
|---|
| 421 | + if (ret) |
|---|
| 422 | + return ret; |
|---|
| 423 | + } |
|---|
| 424 | + |
|---|
| 411 | 425 | return 0; |
|---|
| 412 | 426 | } |
|---|
| 413 | 427 | EXPORT_SYMBOL(drm_modeset_lock_all_ctx); |
|---|