Skip to content

Commit 77ef385

Browse files
danvet-intelalexdeucher
authored andcommitted
drm/modeset-lock: Take the modeset BKL for legacy drivers
This fell off in the conversion in commit 9bcaa3f Author: Michal Orzel <[email protected]> Date: Tue Apr 28 19:10:04 2020 +0200 drm: Replace drm_modeset_lock/unlock_all with DRM_MODESET_LOCK_ALL_* helpers but it's caught by the drm_warn_on_modeset_not_all_locked() that the legacy modeset code uses. Since this is the bkl and it's unclear what's all protected, play it safe and grab it again for legacy drivers. Unfortunately this means we need to sprinkle a few more #includes around. Also we need to add the drm_device as a parameter to the _END macro. Finally remove the mute_lock() from setcrtc, since that's now done by the macro. Cc: Alex Deucher <[email protected]> References: https://gitlab.freedesktop.org/drm/amd/-/issues/1224 Fixes: 9bcaa3f ("drm: Replace drm_modeset_lock/unlock_all with DRM_MODESET_LOCK_ALL_* helpers") Cc: Michal Orzel <[email protected]> Cc: Daniel Vetter <[email protected]> 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: [email protected] Cc: <[email protected]> # v5.8+ Signed-off-by: Daniel Vetter <[email protected]> Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: Alex Deucher <[email protected]> Link: https://patchwork.freedesktop.org/patch/msgid/[email protected]
1 parent 88fee1c commit 77ef385

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

drivers/gpu/drm/drm_atomic_helper.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include <drm/drm_bridge.h>
3535
#include <drm/drm_damage_helper.h>
3636
#include <drm/drm_device.h>
37+
#include <drm/drm_drv.h>
3738
#include <drm/drm_plane_helper.h>
3839
#include <drm/drm_print.h>
3940
#include <drm/drm_self_refresh_helper.h>
@@ -3105,7 +3106,7 @@ void drm_atomic_helper_shutdown(struct drm_device *dev)
31053106
if (ret)
31063107
DRM_ERROR("Disabling all crtc's during unload failed with %i\n", ret);
31073108

3108-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
3109+
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
31093110
}
31103111
EXPORT_SYMBOL(drm_atomic_helper_shutdown);
31113112

@@ -3245,7 +3246,7 @@ struct drm_atomic_state *drm_atomic_helper_suspend(struct drm_device *dev)
32453246
}
32463247

32473248
unlock:
3248-
DRM_MODESET_LOCK_ALL_END(ctx, err);
3249+
DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
32493250
if (err)
32503251
return ERR_PTR(err);
32513252

@@ -3326,7 +3327,7 @@ int drm_atomic_helper_resume(struct drm_device *dev,
33263327

33273328
err = drm_atomic_helper_commit_duplicated_state(state, &ctx);
33283329

3329-
DRM_MODESET_LOCK_ALL_END(ctx, err);
3330+
DRM_MODESET_LOCK_ALL_END(dev, ctx, err);
33303331
drm_atomic_state_put(state);
33313332

33323333
return err;

drivers/gpu/drm/drm_color_mgmt.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -294,7 +294,7 @@ int drm_mode_gamma_set_ioctl(struct drm_device *dev,
294294
crtc->gamma_size, &ctx);
295295

296296
out:
297-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
297+
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
298298
return ret;
299299

300300
}

drivers/gpu/drm/drm_crtc.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -561,7 +561,6 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
561561
if (crtc_req->mode_valid && !drm_lease_held(file_priv, plane->base.id))
562562
return -EACCES;
563563

564-
mutex_lock(&crtc->dev->mode_config.mutex);
565564
DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx,
566565
DRM_MODESET_ACQUIRE_INTERRUPTIBLE, ret);
567566

@@ -728,8 +727,7 @@ int drm_mode_setcrtc(struct drm_device *dev, void *data,
728727
fb = NULL;
729728
mode = NULL;
730729

731-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
732-
mutex_unlock(&crtc->dev->mode_config.mutex);
730+
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
733731

734732
return ret;
735733
}

drivers/gpu/drm/drm_mode_object.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -428,7 +428,7 @@ int drm_mode_obj_get_properties_ioctl(struct drm_device *dev, void *data,
428428
out_unref:
429429
drm_mode_object_put(obj);
430430
out:
431-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
431+
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
432432
return ret;
433433
}
434434

@@ -470,7 +470,7 @@ static int set_property_legacy(struct drm_mode_object *obj,
470470
break;
471471
}
472472
drm_property_change_valid_put(prop, ref);
473-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
473+
DRM_MODESET_LOCK_ALL_END(dev, ctx, ret);
474474

475475
return ret;
476476
}

drivers/gpu/drm/drm_plane.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ static int setplane_internal(struct drm_plane *plane,
791791
crtc_x, crtc_y, crtc_w, crtc_h,
792792
src_x, src_y, src_w, src_h, &ctx);
793793

794-
DRM_MODESET_LOCK_ALL_END(ctx, ret);
794+
DRM_MODESET_LOCK_ALL_END(plane->dev, ctx, ret);
795795

796796
return ret;
797797
}

include/drm/drm_modeset_lock.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,8 @@ int drm_modeset_lock_all_ctx(struct drm_device *dev,
164164
* is 0, so no error checking is necessary
165165
*/
166166
#define DRM_MODESET_LOCK_ALL_BEGIN(dev, ctx, flags, ret) \
167+
if (!drm_drv_uses_atomic_modeset(dev)) \
168+
mutex_lock(&dev->mode_config.mutex); \
167169
drm_modeset_acquire_init(&ctx, flags); \
168170
modeset_lock_retry: \
169171
ret = drm_modeset_lock_all_ctx(dev, &ctx); \
@@ -172,6 +174,7 @@ modeset_lock_retry: \
172174

173175
/**
174176
* DRM_MODESET_LOCK_ALL_END - Helper to release and cleanup modeset locks
177+
* @dev: drm device
175178
* @ctx: local modeset acquire context, will be dereferenced
176179
* @ret: local ret/err/etc variable to track error status
177180
*
@@ -188,14 +191,16 @@ modeset_lock_retry: \
188191
* to that failure. In both of these cases the code between BEGIN/END will not
189192
* be run, so the failure will reflect the inability to grab the locks.
190193
*/
191-
#define DRM_MODESET_LOCK_ALL_END(ctx, ret) \
194+
#define DRM_MODESET_LOCK_ALL_END(dev, ctx, ret) \
192195
modeset_lock_fail: \
193196
if (ret == -EDEADLK) { \
194197
ret = drm_modeset_backoff(&ctx); \
195198
if (!ret) \
196199
goto modeset_lock_retry; \
197200
} \
198201
drm_modeset_drop_locks(&ctx); \
199-
drm_modeset_acquire_fini(&ctx);
202+
drm_modeset_acquire_fini(&ctx); \
203+
if (!drm_drv_uses_atomic_modeset(dev)) \
204+
mutex_unlock(&dev->mode_config.mutex);
200205

201206
#endif /* DRM_MODESET_LOCK_H_ */

0 commit comments

Comments
 (0)