Skip to content

Commit

Permalink
drm: Uncomment checks on oops_in_progress
Browse files Browse the repository at this point in the history
[Why]
Usually, these correspond to functions which must be aborted when there
is a panic in progress.

`oops_in_progress` is supported by linuxkpi, thus we can rely on it.

This should fix nested panics I saw because the some code verifies that
some locks were acquires but they were not (because they were correctly
skipped inside a panic). These lock assertions would cause another panic
on top of the one being processed.

[How]
We simply remove all the `#ifdef __FreeBSD__`.
  • Loading branch information
dumbbell committed Mar 17, 2023
1 parent 9461782 commit 7b69765
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions drivers/gpu/drm/drm_modeset_lock.c
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,8 @@ void drm_modeset_lock_all(struct drm_device *dev)
struct drm_modeset_acquire_ctx *ctx;
int ret;

#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

ctx = kzalloc(sizeof(*ctx), GFP_KERNEL | __GFP_NOFAIL);
if (WARN_ON(!ctx))
Expand Down Expand Up @@ -196,10 +194,8 @@ void drm_modeset_unlock_all(struct drm_device *dev)
struct drm_mode_config *config = &dev->mode_config;
struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx;

#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

if (WARN_ON(!ctx))
return;
Expand All @@ -225,10 +221,8 @@ void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
struct drm_crtc *crtc;

/* Locking is currently fubar in the panic handler. */
#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

drm_for_each_crtc(crtc, dev)
WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
Expand All @@ -250,10 +244,8 @@ EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked);
void drm_modeset_acquire_init(struct drm_modeset_acquire_ctx *ctx,
uint32_t flags)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

memset(ctx, 0, sizeof(*ctx));
ww_acquire_init(&ctx->ww_ctx, &crtc_ww_class);
Expand All @@ -270,10 +262,8 @@ EXPORT_SYMBOL(drm_modeset_acquire_init);
*/
void drm_modeset_acquire_fini(struct drm_modeset_acquire_ctx *ctx)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

ww_acquire_fini(&ctx->ww_ctx);
}
Expand All @@ -287,10 +277,8 @@ EXPORT_SYMBOL(drm_modeset_acquire_fini);
*/
void drm_modeset_drop_locks(struct drm_modeset_acquire_ctx *ctx)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

if (WARN_ON(ctx->contended))
__drm_stack_depot_print(ctx->stack_depot);
Expand All @@ -312,10 +300,8 @@ static inline int modeset_lock(struct drm_modeset_lock *lock,
{
int ret;

#ifdef __FreeBSD__
if (oops_in_progress)
return 0;
#endif

if (WARN_ON(ctx->contended))
__drm_stack_depot_print(ctx->stack_depot);
Expand Down Expand Up @@ -371,10 +357,8 @@ int drm_modeset_backoff(struct drm_modeset_acquire_ctx *ctx)
{
struct drm_modeset_lock *contended = ctx->contended;

#ifdef __FreeBSD__
if (oops_in_progress)
return 0;
#endif

ctx->contended = NULL;
ctx->stack_depot = 0;
Expand Down Expand Up @@ -420,10 +404,8 @@ EXPORT_SYMBOL(drm_modeset_lock_init);
int drm_modeset_lock(struct drm_modeset_lock *lock,
struct drm_modeset_acquire_ctx *ctx)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return 0;
#endif

if (ctx)
return modeset_lock(lock, ctx, ctx->interruptible, false);
Expand All @@ -444,10 +426,8 @@ EXPORT_SYMBOL(drm_modeset_lock);
*/
int drm_modeset_lock_single_interruptible(struct drm_modeset_lock *lock)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return 0;
#endif
return ww_mutex_lock_interruptible(&lock->mutex, NULL);
}
EXPORT_SYMBOL(drm_modeset_lock_single_interruptible);
Expand All @@ -458,10 +438,8 @@ EXPORT_SYMBOL(drm_modeset_lock_single_interruptible);
*/
void drm_modeset_unlock(struct drm_modeset_lock *lock)
{
#ifdef __FreeBSD__
if (oops_in_progress)
return;
#endif

list_del_init(&lock->head);
ww_mutex_unlock(&lock->mutex);
Expand Down Expand Up @@ -496,10 +474,8 @@ int drm_modeset_lock_all_ctx(struct drm_device *dev,
struct drm_plane *plane;
int ret;

#ifdef __FreeBSD__
if (oops_in_progress)
return 0;
#endif

ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
if (ret)
Expand Down

0 comments on commit 7b69765

Please sign in to comment.