XenevaOS
Loading...
Searching...
No Matches
Classes | Macros | Functions
drm_modeset_lock.h File Reference
#include <linux/types.h>
#include <linux/stackdepot.h>
#include <linux/ww_mutex.h>
Include dependency graph for drm_modeset_lock.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  drm_modeset_acquire_ctx
 
struct  drm_modeset_lock
 

Macros

#define DRM_MODESET_ACQUIRE_INTERRUPTIBLE   BIT(0)
 
#define DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, flags, ret)
 
#define DRM_MODESET_LOCK_ALL_END(dev, ctx, ret)
 

Functions

void drm_modeset_acquire_init (struct drm_modeset_acquire_ctx *ctx, uint32_t flags)
 
void drm_modeset_acquire_fini (struct drm_modeset_acquire_ctx *ctx)
 
void drm_modeset_drop_locks (struct drm_modeset_acquire_ctx *ctx)
 
int drm_modeset_backoff (struct drm_modeset_acquire_ctx *ctx)
 
void drm_modeset_lock_init (struct drm_modeset_lock *lock)
 
int drm_modeset_lock (struct drm_modeset_lock *lock, struct drm_modeset_acquire_ctx *ctx)
 
int __must_check drm_modeset_lock_single_interruptible (struct drm_modeset_lock *lock)
 
void drm_modeset_unlock (struct drm_modeset_lock *lock)
 
void drm_modeset_lock_all (struct drm_device *dev)
 
void drm_modeset_unlock_all (struct drm_device *dev)
 
void drm_warn_on_modeset_not_all_locked (struct drm_device *dev)
 
int drm_modeset_lock_all_ctx (struct drm_device *dev, struct drm_modeset_acquire_ctx *ctx)
 

Macro Definition Documentation

◆ DRM_MODESET_ACQUIRE_INTERRUPTIBLE

#define DRM_MODESET_ACQUIRE_INTERRUPTIBLE   BIT(0)

◆ DRM_MODESET_LOCK_ALL_BEGIN

#define DRM_MODESET_LOCK_ALL_BEGIN (   dev,
  ctx,
  flags,
  ret 
)
Value:
if (!drm_drv_uses_atomic_modeset(dev)) \
mutex_lock(&dev->mode_config.mutex); \
drm_modeset_acquire_init(&ctx, flags); \
modeset_lock_retry: \
ret = drm_modeset_lock_all_ctx(dev, &ctx); \
if (ret) \
goto modeset_lock_fail;
uint8_t flags
Definition virtio.h:0
int drm_modeset_lock_all_ctx(struct drm_device *dev, struct drm_modeset_acquire_ctx *ctx)
const struct device * dev
Definition drm_print.h:519

DRM_MODESET_LOCK_ALL_BEGIN - Helper to acquire modeset locks @dev: drm device @ctx: local modeset acquire context, will be dereferenced @flags: DRM_MODESET_ACQUIRE_* flags to pass to drm_modeset_acquire_init() @ret: local ret/err/etc variable to track error status

Use these macros to simplify grabbing all modeset locks using a local context. This has the advantage of reducing boilerplate, but also properly checking return values where appropriate.

Any code run between BEGIN and END will be holding the modeset locks.

This must be paired with DRM_MODESET_LOCK_ALL_END(). We will jump back and forth between the labels on deadlock and error conditions.

Drivers can acquire additional modeset locks. If any lock acquisition fails, the control flow needs to jump to DRM_MODESET_LOCK_ALL_END() with the @ret parameter containing the return value of drm_modeset_lock().

Returns: The only possible value of ret immediately after DRM_MODESET_LOCK_ALL_BEGIN() is 0, so no error checking is necessary

◆ DRM_MODESET_LOCK_ALL_END

#define DRM_MODESET_LOCK_ALL_END (   dev,
  ctx,
  ret 
)
Value:
modeset_lock_fail: \
if (ret == -EDEADLK) { \
ret = drm_modeset_backoff(&ctx); \
if (!ret) \
goto modeset_lock_retry; \
} \
drm_modeset_drop_locks(&ctx); \
drm_modeset_acquire_fini(&ctx); \
if (!drm_drv_uses_atomic_modeset(dev)) \
mutex_unlock(&dev->mode_config.mutex);
int drm_modeset_backoff(struct drm_modeset_acquire_ctx *ctx)
#define EDEADLK
Definition kernel.h:307

DRM_MODESET_LOCK_ALL_END - Helper to release and cleanup modeset locks @dev: drm device @ctx: local modeset acquire context, will be dereferenced @ret: local ret/err/etc variable to track error status

The other side of DRM_MODESET_LOCK_ALL_BEGIN(). It will bounce back to BEGIN if ret is -EDEADLK.

It's important that you use the same ret variable for begin and end so deadlock conditions are properly handled.

Returns: ret will be untouched unless it is -EDEADLK on entry. That means that if you successfully acquire the locks, ret will be whatever your code sets it to. If there is a deadlock or other failure with acquire or backoff, ret will be set to that failure. In both of these cases the code between BEGIN/END will not be run, so the failure will reflect the inability to grab the locks.

Function Documentation

◆ drm_modeset_acquire_fini()

void drm_modeset_acquire_fini ( struct drm_modeset_acquire_ctx *  ctx)

◆ drm_modeset_acquire_init()

void drm_modeset_acquire_init ( struct drm_modeset_acquire_ctx *  ctx,
uint32_t  flags 
)

◆ drm_modeset_backoff()

int drm_modeset_backoff ( struct drm_modeset_acquire_ctx *  ctx)

◆ drm_modeset_drop_locks()

void drm_modeset_drop_locks ( struct drm_modeset_acquire_ctx *  ctx)

◆ drm_modeset_lock()

int drm_modeset_lock ( struct drm_modeset_lock *  lock,
struct drm_modeset_acquire_ctx *  ctx 
)

◆ drm_modeset_lock_all()

void drm_modeset_lock_all ( struct drm_device *  dev)

◆ drm_modeset_lock_all_ctx()

int drm_modeset_lock_all_ctx ( struct drm_device *  dev,
struct drm_modeset_acquire_ctx *  ctx 
)

◆ drm_modeset_lock_init()

void drm_modeset_lock_init ( struct drm_modeset_lock *  lock)

◆ drm_modeset_lock_single_interruptible()

int __must_check drm_modeset_lock_single_interruptible ( struct drm_modeset_lock *  lock)

◆ drm_modeset_unlock()

void drm_modeset_unlock ( struct drm_modeset_lock *  lock)

◆ drm_modeset_unlock_all()

void drm_modeset_unlock_all ( struct drm_device *  dev)

◆ drm_warn_on_modeset_not_all_locked()

void drm_warn_on_modeset_not_all_locked ( struct drm_device *  dev)