diff options
author | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-07-25 11:47:18 -0400 |
---|---|---|
committer | Daniel Vetter <daniel.vetter@ffwll.ch> | 2014-08-08 11:46:40 -0400 |
commit | a6a8bb848d5ca40bc0eb708ddeb23df2b0eca1fb (patch) | |
tree | 6d746abb0ea078eab69b3595215fa8c96ff36b99 | |
parent | 10f637bf292ba501f9b9e9df6dfe21d8fa521fbd (diff) |
drm: Move modeset_lock_all helpers to drm_modeset_lock.[hc]
Somehow we've forgotten about this little bit of OCD.
Reviewed-by: Dave Airlie <airlied@redhat.com>
Reviewed-by: Matt Roper <matthew.d.roper@intel.com>
Signed-off-by: Daniel Vetter <daniel.vetter@ffwll.ch>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 95 | ||||
-rw-r--r-- | drivers/gpu/drm/drm_modeset_lock.c | 95 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 4 | ||||
-rw-r--r-- | include/drm/drm_modeset_lock.h | 5 |
4 files changed, 100 insertions, 99 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index f3ef461deeb8..caaa01f3b353 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -45,101 +45,6 @@ static struct drm_framebuffer *add_framebuffer_internal(struct drm_device *dev, | |||
45 | struct drm_mode_fb_cmd2 *r, | 45 | struct drm_mode_fb_cmd2 *r, |
46 | struct drm_file *file_priv); | 46 | struct drm_file *file_priv); |
47 | 47 | ||
48 | /** | ||
49 | * drm_modeset_lock_all - take all modeset locks | ||
50 | * @dev: drm device | ||
51 | * | ||
52 | * This function takes all modeset locks, suitable where a more fine-grained | ||
53 | * scheme isn't (yet) implemented. Locks must be dropped with | ||
54 | * drm_modeset_unlock_all. | ||
55 | */ | ||
56 | void drm_modeset_lock_all(struct drm_device *dev) | ||
57 | { | ||
58 | struct drm_mode_config *config = &dev->mode_config; | ||
59 | struct drm_modeset_acquire_ctx *ctx; | ||
60 | int ret; | ||
61 | |||
62 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | ||
63 | if (WARN_ON(!ctx)) | ||
64 | return; | ||
65 | |||
66 | mutex_lock(&config->mutex); | ||
67 | |||
68 | drm_modeset_acquire_init(ctx, 0); | ||
69 | |||
70 | retry: | ||
71 | ret = drm_modeset_lock(&config->connection_mutex, ctx); | ||
72 | if (ret) | ||
73 | goto fail; | ||
74 | ret = drm_modeset_lock_all_crtcs(dev, ctx); | ||
75 | if (ret) | ||
76 | goto fail; | ||
77 | |||
78 | WARN_ON(config->acquire_ctx); | ||
79 | |||
80 | /* now we hold the locks, so now that it is safe, stash the | ||
81 | * ctx for drm_modeset_unlock_all(): | ||
82 | */ | ||
83 | config->acquire_ctx = ctx; | ||
84 | |||
85 | drm_warn_on_modeset_not_all_locked(dev); | ||
86 | |||
87 | return; | ||
88 | |||
89 | fail: | ||
90 | if (ret == -EDEADLK) { | ||
91 | drm_modeset_backoff(ctx); | ||
92 | goto retry; | ||
93 | } | ||
94 | } | ||
95 | EXPORT_SYMBOL(drm_modeset_lock_all); | ||
96 | |||
97 | /** | ||
98 | * drm_modeset_unlock_all - drop all modeset locks | ||
99 | * @dev: device | ||
100 | * | ||
101 | * This function drop all modeset locks taken by drm_modeset_lock_all. | ||
102 | */ | ||
103 | void drm_modeset_unlock_all(struct drm_device *dev) | ||
104 | { | ||
105 | struct drm_mode_config *config = &dev->mode_config; | ||
106 | struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx; | ||
107 | |||
108 | if (WARN_ON(!ctx)) | ||
109 | return; | ||
110 | |||
111 | config->acquire_ctx = NULL; | ||
112 | drm_modeset_drop_locks(ctx); | ||
113 | drm_modeset_acquire_fini(ctx); | ||
114 | |||
115 | kfree(ctx); | ||
116 | |||
117 | mutex_unlock(&dev->mode_config.mutex); | ||
118 | } | ||
119 | EXPORT_SYMBOL(drm_modeset_unlock_all); | ||
120 | |||
121 | /** | ||
122 | * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked | ||
123 | * @dev: device | ||
124 | * | ||
125 | * Useful as a debug assert. | ||
126 | */ | ||
127 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev) | ||
128 | { | ||
129 | struct drm_crtc *crtc; | ||
130 | |||
131 | /* Locking is currently fubar in the panic handler. */ | ||
132 | if (oops_in_progress) | ||
133 | return; | ||
134 | |||
135 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | ||
136 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); | ||
137 | |||
138 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); | ||
139 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); | ||
140 | } | ||
141 | EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked); | ||
142 | |||
143 | /* Avoid boilerplate. I'm tired of typing. */ | 48 | /* Avoid boilerplate. I'm tired of typing. */ |
144 | #define DRM_ENUM_NAME_FN(fnname, list) \ | 49 | #define DRM_ENUM_NAME_FN(fnname, list) \ |
145 | const char *fnname(int val) \ | 50 | const char *fnname(int val) \ |
diff --git a/drivers/gpu/drm/drm_modeset_lock.c b/drivers/gpu/drm/drm_modeset_lock.c index 0dc57d5ecd10..73e6534fd0aa 100644 --- a/drivers/gpu/drm/drm_modeset_lock.c +++ b/drivers/gpu/drm/drm_modeset_lock.c | |||
@@ -57,6 +57,101 @@ | |||
57 | 57 | ||
58 | 58 | ||
59 | /** | 59 | /** |
60 | * drm_modeset_lock_all - take all modeset locks | ||
61 | * @dev: drm device | ||
62 | * | ||
63 | * This function takes all modeset locks, suitable where a more fine-grained | ||
64 | * scheme isn't (yet) implemented. Locks must be dropped with | ||
65 | * drm_modeset_unlock_all. | ||
66 | */ | ||
67 | void drm_modeset_lock_all(struct drm_device *dev) | ||
68 | { | ||
69 | struct drm_mode_config *config = &dev->mode_config; | ||
70 | struct drm_modeset_acquire_ctx *ctx; | ||
71 | int ret; | ||
72 | |||
73 | ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); | ||
74 | if (WARN_ON(!ctx)) | ||
75 | return; | ||
76 | |||
77 | mutex_lock(&config->mutex); | ||
78 | |||
79 | drm_modeset_acquire_init(ctx, 0); | ||
80 | |||
81 | retry: | ||
82 | ret = drm_modeset_lock(&config->connection_mutex, ctx); | ||
83 | if (ret) | ||
84 | goto fail; | ||
85 | ret = drm_modeset_lock_all_crtcs(dev, ctx); | ||
86 | if (ret) | ||
87 | goto fail; | ||
88 | |||
89 | WARN_ON(config->acquire_ctx); | ||
90 | |||
91 | /* now we hold the locks, so now that it is safe, stash the | ||
92 | * ctx for drm_modeset_unlock_all(): | ||
93 | */ | ||
94 | config->acquire_ctx = ctx; | ||
95 | |||
96 | drm_warn_on_modeset_not_all_locked(dev); | ||
97 | |||
98 | return; | ||
99 | |||
100 | fail: | ||
101 | if (ret == -EDEADLK) { | ||
102 | drm_modeset_backoff(ctx); | ||
103 | goto retry; | ||
104 | } | ||
105 | } | ||
106 | EXPORT_SYMBOL(drm_modeset_lock_all); | ||
107 | |||
108 | /** | ||
109 | * drm_modeset_unlock_all - drop all modeset locks | ||
110 | * @dev: device | ||
111 | * | ||
112 | * This function drop all modeset locks taken by drm_modeset_lock_all. | ||
113 | */ | ||
114 | void drm_modeset_unlock_all(struct drm_device *dev) | ||
115 | { | ||
116 | struct drm_mode_config *config = &dev->mode_config; | ||
117 | struct drm_modeset_acquire_ctx *ctx = config->acquire_ctx; | ||
118 | |||
119 | if (WARN_ON(!ctx)) | ||
120 | return; | ||
121 | |||
122 | config->acquire_ctx = NULL; | ||
123 | drm_modeset_drop_locks(ctx); | ||
124 | drm_modeset_acquire_fini(ctx); | ||
125 | |||
126 | kfree(ctx); | ||
127 | |||
128 | mutex_unlock(&dev->mode_config.mutex); | ||
129 | } | ||
130 | EXPORT_SYMBOL(drm_modeset_unlock_all); | ||
131 | |||
132 | /** | ||
133 | * drm_warn_on_modeset_not_all_locked - check that all modeset locks are locked | ||
134 | * @dev: device | ||
135 | * | ||
136 | * Useful as a debug assert. | ||
137 | */ | ||
138 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev) | ||
139 | { | ||
140 | struct drm_crtc *crtc; | ||
141 | |||
142 | /* Locking is currently fubar in the panic handler. */ | ||
143 | if (oops_in_progress) | ||
144 | return; | ||
145 | |||
146 | list_for_each_entry(crtc, &dev->mode_config.crtc_list, head) | ||
147 | WARN_ON(!drm_modeset_is_locked(&crtc->mutex)); | ||
148 | |||
149 | WARN_ON(!drm_modeset_is_locked(&dev->mode_config.connection_mutex)); | ||
150 | WARN_ON(!mutex_is_locked(&dev->mode_config.mutex)); | ||
151 | } | ||
152 | EXPORT_SYMBOL(drm_warn_on_modeset_not_all_locked); | ||
153 | |||
154 | /** | ||
60 | * drm_modeset_acquire_init - initialize acquire context | 155 | * drm_modeset_acquire_init - initialize acquire context |
61 | * @ctx: the acquire context | 156 | * @ctx: the acquire context |
62 | * @flags: for future | 157 | * @flags: for future |
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 9f18e7022ab3..a11d73422e7f 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -218,10 +218,6 @@ struct drm_property { | |||
218 | struct list_head enum_blob_list; | 218 | struct list_head enum_blob_list; |
219 | }; | 219 | }; |
220 | 220 | ||
221 | void drm_modeset_lock_all(struct drm_device *dev); | ||
222 | void drm_modeset_unlock_all(struct drm_device *dev); | ||
223 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); | ||
224 | |||
225 | struct drm_crtc; | 221 | struct drm_crtc; |
226 | struct drm_connector; | 222 | struct drm_connector; |
227 | struct drm_encoder; | 223 | struct drm_encoder; |
diff --git a/include/drm/drm_modeset_lock.h b/include/drm/drm_modeset_lock.h index 402aa7a6a058..cf61e857bc06 100644 --- a/include/drm/drm_modeset_lock.h +++ b/include/drm/drm_modeset_lock.h | |||
@@ -120,6 +120,11 @@ int drm_modeset_lock_interruptible(struct drm_modeset_lock *lock, | |||
120 | void drm_modeset_unlock(struct drm_modeset_lock *lock); | 120 | void drm_modeset_unlock(struct drm_modeset_lock *lock); |
121 | 121 | ||
122 | struct drm_device; | 122 | struct drm_device; |
123 | |||
124 | void drm_modeset_lock_all(struct drm_device *dev); | ||
125 | void drm_modeset_unlock_all(struct drm_device *dev); | ||
126 | void drm_warn_on_modeset_not_all_locked(struct drm_device *dev); | ||
127 | |||
123 | int drm_modeset_lock_all_crtcs(struct drm_device *dev, | 128 | int drm_modeset_lock_all_crtcs(struct drm_device *dev, |
124 | struct drm_modeset_acquire_ctx *ctx); | 129 | struct drm_modeset_acquire_ctx *ctx); |
125 | 130 | ||