diff options
author | Jesse Barnes <jbarnes@virtuousgeek.org> | 2009-01-19 02:21:45 -0500 |
---|---|---|
committer | Dave Airlie <airlied@redhat.com> | 2009-01-22 02:53:05 -0500 |
commit | ad2563c2e42fc67b0976aeb70e9f3faf1c1196e8 (patch) | |
tree | 5e4dc7f4d882143166d9aa5525f5f526d79056e7 | |
parent | c1ff85d97708550e634fb6fa099c463db90fc40d (diff) |
drm: create mode_config idr lock
Create a separate mode_config IDR lock for simplicity. The core DRM
config structures (connector, mode, etc. lists) are still protected by
the mode_config mutex, but the CRTC IDR (used for the various identifier
IDs) is now protected by the mode_config idr_mutex. Simplifies the
locking a bit and removes a warning.
All objects are protected by the config mutex, we may in the future,
split the object further to have reference counts.
Signed-off-by: Jesse Barnes <jbarnes@virtuousgeek.org>
Signed-off-by: Dave Airlie <airlied@redhat.com>
-rw-r--r-- | drivers/gpu/drm/drm_crtc.c | 14 | ||||
-rw-r--r-- | include/drm/drm_crtc.h | 3 |
2 files changed, 11 insertions, 6 deletions
diff --git a/drivers/gpu/drm/drm_crtc.c b/drivers/gpu/drm/drm_crtc.c index 5b2cbb778162..bfce0992fefb 100644 --- a/drivers/gpu/drm/drm_crtc.c +++ b/drivers/gpu/drm/drm_crtc.c | |||
@@ -194,7 +194,6 @@ char *drm_get_connector_status_name(enum drm_connector_status status) | |||
194 | * @type: object type | 194 | * @type: object type |
195 | * | 195 | * |
196 | * LOCKING: | 196 | * LOCKING: |
197 | * Caller must hold DRM mode_config lock. | ||
198 | * | 197 | * |
199 | * Create a unique identifier based on @ptr in @dev's identifier space. Used | 198 | * Create a unique identifier based on @ptr in @dev's identifier space. Used |
200 | * for tracking modes, CRTCs and connectors. | 199 | * for tracking modes, CRTCs and connectors. |
@@ -209,15 +208,15 @@ static int drm_mode_object_get(struct drm_device *dev, | |||
209 | int new_id = 0; | 208 | int new_id = 0; |
210 | int ret; | 209 | int ret; |
211 | 210 | ||
212 | WARN(!mutex_is_locked(&dev->mode_config.mutex), | ||
213 | "%s called w/o mode_config lock\n", __func__); | ||
214 | again: | 211 | again: |
215 | if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) { | 212 | if (idr_pre_get(&dev->mode_config.crtc_idr, GFP_KERNEL) == 0) { |
216 | DRM_ERROR("Ran out memory getting a mode number\n"); | 213 | DRM_ERROR("Ran out memory getting a mode number\n"); |
217 | return -EINVAL; | 214 | return -EINVAL; |
218 | } | 215 | } |
219 | 216 | ||
217 | mutex_lock(&dev->mode_config.idr_mutex); | ||
220 | ret = idr_get_new_above(&dev->mode_config.crtc_idr, obj, 1, &new_id); | 218 | ret = idr_get_new_above(&dev->mode_config.crtc_idr, obj, 1, &new_id); |
219 | mutex_unlock(&dev->mode_config.idr_mutex); | ||
221 | if (ret == -EAGAIN) | 220 | if (ret == -EAGAIN) |
222 | goto again; | 221 | goto again; |
223 | 222 | ||
@@ -239,16 +238,20 @@ again: | |||
239 | static void drm_mode_object_put(struct drm_device *dev, | 238 | static void drm_mode_object_put(struct drm_device *dev, |
240 | struct drm_mode_object *object) | 239 | struct drm_mode_object *object) |
241 | { | 240 | { |
241 | mutex_lock(&dev->mode_config.idr_mutex); | ||
242 | idr_remove(&dev->mode_config.crtc_idr, object->id); | 242 | idr_remove(&dev->mode_config.crtc_idr, object->id); |
243 | mutex_unlock(&dev->mode_config.idr_mutex); | ||
243 | } | 244 | } |
244 | 245 | ||
245 | void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type) | 246 | void *drm_mode_object_find(struct drm_device *dev, uint32_t id, uint32_t type) |
246 | { | 247 | { |
247 | struct drm_mode_object *obj; | 248 | struct drm_mode_object *obj = NULL; |
248 | 249 | ||
250 | mutex_lock(&dev->mode_config.idr_mutex); | ||
249 | obj = idr_find(&dev->mode_config.crtc_idr, id); | 251 | obj = idr_find(&dev->mode_config.crtc_idr, id); |
250 | if (!obj || (obj->type != type) || (obj->id != id)) | 252 | if (!obj || (obj->type != type) || (obj->id != id)) |
251 | return NULL; | 253 | obj = NULL; |
254 | mutex_unlock(&dev->mode_config.idr_mutex); | ||
252 | 255 | ||
253 | return obj; | 256 | return obj; |
254 | } | 257 | } |
@@ -786,6 +789,7 @@ EXPORT_SYMBOL(drm_mode_create_dithering_property); | |||
786 | void drm_mode_config_init(struct drm_device *dev) | 789 | void drm_mode_config_init(struct drm_device *dev) |
787 | { | 790 | { |
788 | mutex_init(&dev->mode_config.mutex); | 791 | mutex_init(&dev->mode_config.mutex); |
792 | mutex_init(&dev->mode_config.idr_mutex); | ||
789 | INIT_LIST_HEAD(&dev->mode_config.fb_list); | 793 | INIT_LIST_HEAD(&dev->mode_config.fb_list); |
790 | INIT_LIST_HEAD(&dev->mode_config.fb_kernel_list); | 794 | INIT_LIST_HEAD(&dev->mode_config.fb_kernel_list); |
791 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); | 795 | INIT_LIST_HEAD(&dev->mode_config.crtc_list); |
diff --git a/include/drm/drm_crtc.h b/include/drm/drm_crtc.h index 47809ac94bc3..d54de24bf371 100644 --- a/include/drm/drm_crtc.h +++ b/include/drm/drm_crtc.h | |||
@@ -528,7 +528,8 @@ struct drm_mode_group { | |||
528 | * | 528 | * |
529 | */ | 529 | */ |
530 | struct drm_mode_config { | 530 | struct drm_mode_config { |
531 | struct mutex mutex; /* protects configuration and IDR */ | 531 | struct mutex mutex; /* protects configuration (mode lists etc.) */ |
532 | struct mutex idr_mutex; /* for IDR management */ | ||
532 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ | 533 | struct idr crtc_idr; /* use this idr for all IDs, fb, crtc, connector, modes - just makes life easier */ |
533 | /* this is limited to one for now */ | 534 | /* this is limited to one for now */ |
534 | int num_fb; | 535 | int num_fb; |