diff options
Diffstat (limited to 'drivers/gpu/drm/drm_connector.c')
-rw-r--r-- | drivers/gpu/drm/drm_connector.c | 28 |
1 files changed, 26 insertions, 2 deletions
diff --git a/drivers/gpu/drm/drm_connector.c b/drivers/gpu/drm/drm_connector.c index 25f4b2e9a44f..482014137953 100644 --- a/drivers/gpu/drm/drm_connector.c +++ b/drivers/gpu/drm/drm_connector.c | |||
@@ -152,6 +152,16 @@ static void drm_connector_free(struct kref *kref) | |||
152 | connector->funcs->destroy(connector); | 152 | connector->funcs->destroy(connector); |
153 | } | 153 | } |
154 | 154 | ||
155 | static void drm_connector_free_work_fn(struct work_struct *work) | ||
156 | { | ||
157 | struct drm_connector *connector = | ||
158 | container_of(work, struct drm_connector, free_work); | ||
159 | struct drm_device *dev = connector->dev; | ||
160 | |||
161 | drm_mode_object_unregister(dev, &connector->base); | ||
162 | connector->funcs->destroy(connector); | ||
163 | } | ||
164 | |||
155 | /** | 165 | /** |
156 | * drm_connector_init - Init a preallocated connector | 166 | * drm_connector_init - Init a preallocated connector |
157 | * @dev: DRM device | 167 | * @dev: DRM device |
@@ -181,6 +191,8 @@ int drm_connector_init(struct drm_device *dev, | |||
181 | if (ret) | 191 | if (ret) |
182 | return ret; | 192 | return ret; |
183 | 193 | ||
194 | INIT_WORK(&connector->free_work, drm_connector_free_work_fn); | ||
195 | |||
184 | connector->base.properties = &connector->properties; | 196 | connector->base.properties = &connector->properties; |
185 | connector->dev = dev; | 197 | connector->dev = dev; |
186 | connector->funcs = funcs; | 198 | connector->funcs = funcs; |
@@ -529,6 +541,18 @@ void drm_connector_list_iter_begin(struct drm_device *dev, | |||
529 | } | 541 | } |
530 | EXPORT_SYMBOL(drm_connector_list_iter_begin); | 542 | EXPORT_SYMBOL(drm_connector_list_iter_begin); |
531 | 543 | ||
544 | /* | ||
545 | * Extra-safe connector put function that works in any context. Should only be | ||
546 | * used from the connector_iter functions, where we never really expect to | ||
547 | * actually release the connector when dropping our final reference. | ||
548 | */ | ||
549 | static void | ||
550 | drm_connector_put_safe(struct drm_connector *conn) | ||
551 | { | ||
552 | if (refcount_dec_and_test(&conn->base.refcount.refcount)) | ||
553 | schedule_work(&conn->free_work); | ||
554 | } | ||
555 | |||
532 | /** | 556 | /** |
533 | * drm_connector_list_iter_next - return next connector | 557 | * drm_connector_list_iter_next - return next connector |
534 | * @iter: connectr_list iterator | 558 | * @iter: connectr_list iterator |
@@ -561,7 +585,7 @@ drm_connector_list_iter_next(struct drm_connector_list_iter *iter) | |||
561 | spin_unlock_irqrestore(&config->connector_list_lock, flags); | 585 | spin_unlock_irqrestore(&config->connector_list_lock, flags); |
562 | 586 | ||
563 | if (old_conn) | 587 | if (old_conn) |
564 | drm_connector_put(old_conn); | 588 | drm_connector_put_safe(old_conn); |
565 | 589 | ||
566 | return iter->conn; | 590 | return iter->conn; |
567 | } | 591 | } |
@@ -580,7 +604,7 @@ void drm_connector_list_iter_end(struct drm_connector_list_iter *iter) | |||
580 | { | 604 | { |
581 | iter->dev = NULL; | 605 | iter->dev = NULL; |
582 | if (iter->conn) | 606 | if (iter->conn) |
583 | drm_connector_put(iter->conn); | 607 | drm_connector_put_safe(iter->conn); |
584 | lock_release(&connector_list_iter_dep_map, 0, _RET_IP_); | 608 | lock_release(&connector_list_iter_dep_map, 0, _RET_IP_); |
585 | } | 609 | } |
586 | EXPORT_SYMBOL(drm_connector_list_iter_end); | 610 | EXPORT_SYMBOL(drm_connector_list_iter_end); |