Subversion Repositories Kolibri OS

Rev

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

Rev 6084 Rev 6937
Line 46... Line 46...
46
 *       if (ret == -EDEADLK) {
46
 *       if (ret == -EDEADLK) {
47
 *          drm_modeset_backoff(&ctx);
47
 *          drm_modeset_backoff(&ctx);
48
 *          goto retry;
48
 *          goto retry;
49
 *       }
49
 *       }
50
 *     }
50
 *     }
51
 *
-
 
52
 *     ... do stuff ...
51
 *     ... do stuff ...
53
 *
-
 
54
 *     drm_modeset_drop_locks(&ctx);
52
 *     drm_modeset_drop_locks(&ctx);
55
 *     drm_modeset_acquire_fini(&ctx);
53
 *     drm_modeset_acquire_fini(&ctx);
56
 */
54
 */
Line 57... Line 55...
57
 
55
 
58
/**
56
/**
59
 * drm_modeset_lock_all - take all modeset locks
57
 * drm_modeset_lock_all - take all modeset locks
60
 * @dev: drm device
58
 * @dev: DRM device
61
 *
59
 *
62
 * This function takes all modeset locks, suitable where a more fine-grained
60
 * This function takes all modeset locks, suitable where a more fine-grained
63
 * scheme isn't (yet) implemented. Locks must be dropped with
61
 * scheme isn't (yet) implemented. Locks must be dropped by calling the
-
 
62
 * drm_modeset_unlock_all() function.
-
 
63
 *
-
 
64
 * This function is deprecated. It allocates a lock acquisition context and
-
 
65
 * stores it in the DRM device's ->mode_config. This facilitate conversion of
-
 
66
 * existing code because it removes the need to manually deal with the
-
 
67
 * acquisition context, but it is also brittle because the context is global
-
 
68
 * and care must be taken not to nest calls. New code should use the
64
 * drm_modeset_unlock_all.
69
 * drm_modeset_lock_all_ctx() function and pass in the context explicitly.
65
 */
70
 */
66
void drm_modeset_lock_all(struct drm_device *dev)
71
void drm_modeset_lock_all(struct drm_device *dev)
67
{
72
{
68
	struct drm_mode_config *config = &dev->mode_config;
73
	struct drm_mode_config *config = &dev->mode_config;
Line 76... Line 81...
76
	mutex_lock(&config->mutex);
81
	mutex_lock(&config->mutex);
Line 77... Line 82...
77
 
82
 
Line 78... Line 83...
78
	drm_modeset_acquire_init(ctx, 0);
83
	drm_modeset_acquire_init(ctx, 0);
79
 
84
 
80
retry:
85
retry:
-
 
86
	ret = drm_modeset_lock_all_ctx(dev, ctx);
-
 
87
	if (ret < 0) {
81
	ret = drm_modeset_lock(&config->connection_mutex, ctx);
88
		if (ret == -EDEADLK) {
-
 
89
			drm_modeset_backoff(ctx);
-
 
90
			goto retry;
82
	if (ret)
91
		}
83
		goto fail;
92
 
84
	ret = drm_modeset_lock_all_crtcs(dev, ctx);
93
		drm_modeset_acquire_fini(ctx);
-
 
94
		kfree(ctx);
Line 85... Line 95...
85
	if (ret)
95
		return;
Line -... Line 96...
-
 
96
	}
86
		goto fail;
97
 
87
 
98
	WARN_ON(config->acquire_ctx);
88
	WARN_ON(config->acquire_ctx);
99
 
89
 
100
	/*
Line 90... Line 101...
90
	/* now we hold the locks, so now that it is safe, stash the
101
	 * We hold the locks now, so it is safe to stash the acquisition
91
	 * ctx for drm_modeset_unlock_all():
-
 
92
	 */
-
 
93
	config->acquire_ctx = ctx;
-
 
94
 
-
 
95
	drm_warn_on_modeset_not_all_locked(dev);
-
 
96
 
-
 
97
	return;
-
 
98
 
-
 
99
fail:
-
 
100
	if (ret == -EDEADLK) {
-
 
101
		drm_modeset_backoff(ctx);
102
	 * context for drm_modeset_unlock_all().
102
		goto retry;
103
	 */
Line 103... Line 104...
103
	}
104
	config->acquire_ctx = ctx;
104
 
105
 
105
	kfree(ctx);
106
	drm_warn_on_modeset_not_all_locked(dev);
106
}
107
}
107
EXPORT_SYMBOL(drm_modeset_lock_all);
108
EXPORT_SYMBOL(drm_modeset_lock_all);
-
 
109
 
-
 
110
/**
-
 
111
 * drm_modeset_unlock_all - drop all modeset locks
-
 
112
 * @dev: DRM device
-
 
113
 *
-
 
114
 * This function drops all modeset locks taken by a previous call to the
-
 
115
 * drm_modeset_lock_all() function.
-
 
116
 *
108
 
117
 * This function is deprecated. It uses the lock acquisition context stored
109
/**
118
 * in the DRM device's ->mode_config. This facilitates conversion of existing
110
 * drm_modeset_unlock_all - drop all modeset locks
119
 * code because it removes the need to manually deal with the acquisition
111
 * @dev: device
120
 * context, but it is also brittle because the context is global and care must
112
 *
121
 * be taken not to nest calls. New code should pass the acquisition context
Line 429... Line 438...
429
	list_del_init(&lock->head);
438
	list_del_init(&lock->head);
430
	ww_mutex_unlock(&lock->mutex);
439
	ww_mutex_unlock(&lock->mutex);
431
}
440
}
432
EXPORT_SYMBOL(drm_modeset_unlock);
441
EXPORT_SYMBOL(drm_modeset_unlock);
Line -... Line 442...
-
 
442
 
-
 
443
/**
-
 
444
 * drm_modeset_lock_all_ctx - take all modeset locks
-
 
445
 * @dev: DRM device
-
 
446
 * @ctx: lock acquisition context
433
 
447
 *
434
/* In some legacy codepaths it's convenient to just grab all the crtc and plane
448
 * This function takes all modeset locks, suitable where a more fine-grained
-
 
449
 * scheme isn't (yet) implemented.
-
 
450
 *
-
 
451
 * Unlike drm_modeset_lock_all(), it doesn't take the dev->mode_config.mutex
-
 
452
 * since that lock isn't required for modeset state changes. Callers which
-
 
453
 * need to grab that lock too need to do so outside of the acquire context
-
 
454
 * @ctx.
-
 
455
 *
-
 
456
 * Locks acquired with this function should be released by calling the
-
 
457
 * drm_modeset_drop_locks() function on @ctx.
-
 
458
 *
-
 
459
 * Returns: 0 on success or a negative error-code on failure.
435
 * related locks. */
460
 */
436
int drm_modeset_lock_all_crtcs(struct drm_device *dev,
461
int drm_modeset_lock_all_ctx(struct drm_device *dev,
437
		struct drm_modeset_acquire_ctx *ctx)
462
		struct drm_modeset_acquire_ctx *ctx)
438
{
463
{
439
	struct drm_crtc *crtc;
464
	struct drm_crtc *crtc;
440
	struct drm_plane *plane;
465
	struct drm_plane *plane;
-
 
466
	int ret;
-
 
467
 
-
 
468
	ret = drm_modeset_lock(&dev->mode_config.connection_mutex, ctx);
-
 
469
	if (ret)
Line 441... Line 470...
441
	int ret = 0;
470
		return ret;
442
 
471
 
443
	drm_for_each_crtc(crtc, dev) {
472
	drm_for_each_crtc(crtc, dev) {
444
		ret = drm_modeset_lock(&crtc->mutex, ctx);
473
		ret = drm_modeset_lock(&crtc->mutex, ctx);
Line 452... Line 481...
452
			return ret;
481
			return ret;
453
	}
482
	}
Line 454... Line 483...
454
 
483
 
455
	return 0;
484
	return 0;
456
}
485
}