Subversion Repositories Kolibri OS

Rev

Rev 5271 | Rev 6937 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 5271 Rev 6084
Line 53... Line 53...
53
 *
53
 *
54
 *     drm_modeset_drop_locks(&ctx);
54
 *     drm_modeset_drop_locks(&ctx);
55
 *     drm_modeset_acquire_fini(&ctx);
55
 *     drm_modeset_acquire_fini(&ctx);
56
 */
56
 */
Line 57... Line -...
57
 
-
 
58
 
57
 
59
/**
58
/**
60
 * __drm_modeset_lock_all - internal helper to grab all modeset locks
59
 * drm_modeset_lock_all - take all modeset locks
61
 * @dev: DRM device
-
 
62
 * @trylock: trylock mode for atomic contexts
-
 
63
 *
-
 
64
 * This is a special version of drm_modeset_lock_all() which can also be used in
-
 
65
 * atomic contexts. Then @trylock must be set to true.
60
 * @dev: drm device
66
 *
61
 *
67
 * Returns:
62
 * This function takes all modeset locks, suitable where a more fine-grained
-
 
63
 * scheme isn't (yet) implemented. Locks must be dropped with
68
 * 0 on success or negative error code on failure.
64
 * drm_modeset_unlock_all.
69
 */
65
 */
70
int __drm_modeset_lock_all(struct drm_device *dev,
-
 
71
			   bool trylock)
66
void drm_modeset_lock_all(struct drm_device *dev)
72
{
67
{
73
	struct drm_mode_config *config = &dev->mode_config;
68
	struct drm_mode_config *config = &dev->mode_config;
74
	struct drm_modeset_acquire_ctx *ctx;
69
	struct drm_modeset_acquire_ctx *ctx;
Line 75... Line 70...
75
	int ret;
70
	int ret;
76
 
-
 
77
	ctx = kzalloc(sizeof(*ctx),
71
 
78
		      trylock ? GFP_ATOMIC : GFP_KERNEL);
72
	ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
Line 79... Line -...
79
	if (!ctx)
-
 
80
		return -ENOMEM;
-
 
81
 
-
 
82
	if (trylock) {
-
 
83
		if (!mutex_trylock(&config->mutex))
73
	if (WARN_ON(!ctx))
84
			return -EBUSY;
-
 
Line 85... Line 74...
85
	} else {
74
		return;
86
		mutex_lock(&config->mutex);
-
 
Line 87... Line 75...
87
	}
75
 
88
 
76
	mutex_lock(&config->mutex);
89
	drm_modeset_acquire_init(ctx, 0);
77
 
90
	ctx->trylock_only = trylock;
78
	drm_modeset_acquire_init(ctx, 0);
Line 104... Line 92...
104
	 */
92
	 */
105
	config->acquire_ctx = ctx;
93
	config->acquire_ctx = ctx;
Line 106... Line 94...
106
 
94
 
Line 107... Line 95...
107
	drm_warn_on_modeset_not_all_locked(dev);
95
	drm_warn_on_modeset_not_all_locked(dev);
Line 108... Line 96...
108
 
96
 
109
	return 0;
97
	return;
110
 
98
 
111
fail:
99
fail:
112
	if (ret == -EDEADLK) {
100
	if (ret == -EDEADLK) {
Line 113... Line 101...
113
		drm_modeset_backoff(ctx);
101
		drm_modeset_backoff(ctx);
114
		goto retry;
-
 
115
	}
-
 
116
 
-
 
117
	return ret;
-
 
118
}
-
 
119
EXPORT_SYMBOL(__drm_modeset_lock_all);
-
 
120
 
-
 
121
/**
-
 
122
 * drm_modeset_lock_all - take all modeset locks
-
 
123
 * @dev: drm device
-
 
124
 *
-
 
125
 * This function takes all modeset locks, suitable where a more fine-grained
-
 
126
 * scheme isn't (yet) implemented. Locks must be dropped with
-
 
127
 * drm_modeset_unlock_all.
-
 
128
 */
102
		goto retry;
129
void drm_modeset_lock_all(struct drm_device *dev)
103
	}
Line 130... Line 104...
130
{
104
 
131
	WARN_ON(__drm_modeset_lock_all(dev, false) != 0);
105
	kfree(ctx);
Line 267... Line 241...
267
void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
241
void drm_warn_on_modeset_not_all_locked(struct drm_device *dev)
268
{
242
{
269
	struct drm_crtc *crtc;
243
	struct drm_crtc *crtc;
Line 270... Line 244...
270
 
244
 
271
	/* Locking is currently fubar in the panic handler. */
245
	/* Locking is currently fubar in the panic handler. */
272
//   if (oops_in_progress)
246
	if (oops_in_progress)
Line 273... Line 247...
273
//       return;
247
		return;
274
 
248
 
Line 275... Line 249...
275
	list_for_each_entry(crtc, &dev->mode_config.crtc_list, head)
249
	drm_for_each_crtc(crtc, dev)
276
		WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
250
		WARN_ON(!drm_modeset_is_locked(&crtc->mutex));
277
 
251
 
Line 331... Line 305...
331
	int ret;
305
	int ret;
Line 332... Line 306...
332
 
306
 
Line 333... Line 307...
333
	WARN_ON(ctx->contended);
307
	WARN_ON(ctx->contended);
-
 
308
 
-
 
309
	if (ctx->trylock_only) {
334
 
310
		lockdep_assert_held(&ctx->ww_ctx);
335
	if (ctx->trylock_only) {
311
 
336
		if (!ww_mutex_trylock(&lock->mutex))
312
		if (!ww_mutex_trylock(&lock->mutex))
337
			return -EBUSY;
313
			return -EBUSY;
338
		else
314
		else
Line 458... Line 434...
458
/* In some legacy codepaths it's convenient to just grab all the crtc and plane
434
/* In some legacy codepaths it's convenient to just grab all the crtc and plane
459
 * related locks. */
435
 * related locks. */
460
int drm_modeset_lock_all_crtcs(struct drm_device *dev,
436
int drm_modeset_lock_all_crtcs(struct drm_device *dev,
461
		struct drm_modeset_acquire_ctx *ctx)
437
		struct drm_modeset_acquire_ctx *ctx)
462
{
438
{
463
	struct drm_mode_config *config = &dev->mode_config;
-
 
464
	struct drm_crtc *crtc;
439
	struct drm_crtc *crtc;
465
	struct drm_plane *plane;
440
	struct drm_plane *plane;
466
	int ret = 0;
441
	int ret = 0;
Line 467... Line 442...
467
 
442
 
468
	list_for_each_entry(crtc, &config->crtc_list, head) {
443
	drm_for_each_crtc(crtc, dev) {
469
		ret = drm_modeset_lock(&crtc->mutex, ctx);
444
		ret = drm_modeset_lock(&crtc->mutex, ctx);
470
		if (ret)
445
		if (ret)
471
			return ret;
446
			return ret;
Line 472... Line 447...
472
	}
447
	}
473
 
448
 
474
	list_for_each_entry(plane, &config->plane_list, head) {
449
	drm_for_each_plane(plane, dev) {
475
		ret = drm_modeset_lock(&plane->mutex, ctx);
450
		ret = drm_modeset_lock(&plane->mutex, ctx);
476
		if (ret)
451
		if (ret)