From cb56aceabd36ef42bc7e081c43dc55ef57efba7a Mon Sep 17 00:00:00 2001 From: Dave Airlie Date: Tue, 3 Oct 2017 12:39:01 +1000 Subject: [PATCH] amdgpu/dc: convert dc_sink to kref. Refcounts use krefs. Signed-off-by: Dave Airlie Reviewed-by: Harry Wentland Signed-off-by: Alex Deucher --- drivers/gpu/drm/amd/display/dc/core/dc_sink.c | 20 +++++++++---------- drivers/gpu/drm/amd/display/dc/dc.h | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c index 3d620d3d0672..25fae38409ab 100644 --- a/drivers/gpu/drm/amd/display/dc/core/dc_sink.c +++ b/drivers/gpu/drm/amd/display/dc/core/dc_sink.c @@ -63,19 +63,19 @@ static bool construct(struct dc_sink *sink, const struct dc_sink_init_data *init void dc_sink_retain(struct dc_sink *sink) { - ASSERT(atomic_read(&sink->ref_count) > 0); - atomic_inc(&sink->ref_count); + kref_get(&sink->refcount); } -void dc_sink_release(struct dc_sink *sink) +static void dc_sink_free(struct kref *kref) { - ASSERT(atomic_read(&sink->ref_count) > 0); - atomic_dec(&sink->ref_count); + struct dc_sink *sink = container_of(kref, struct dc_sink, refcount); + destruct(sink); + kfree(sink); +} - if (atomic_read(&sink->ref_count) == 0) { - destruct(sink); - kfree(sink); - } +void dc_sink_release(struct dc_sink *sink) +{ + kref_put(&sink->refcount, dc_sink_free); } struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params) @@ -88,7 +88,7 @@ struct dc_sink *dc_sink_create(const struct dc_sink_init_data *init_params) if (false == construct(sink, init_params)) goto construct_fail; - atomic_inc(&sink->ref_count); + kref_init(&sink->refcount); return sink; diff --git a/drivers/gpu/drm/amd/display/dc/dc.h b/drivers/gpu/drm/amd/display/dc/dc.h index 97f6f34f3d22..4ff543826476 100644 --- a/drivers/gpu/drm/amd/display/dc/dc.h +++ b/drivers/gpu/drm/amd/display/dc/dc.h @@ -971,7 +971,7 @@ struct dc_sink { struct dc_context *ctx; /* private to dc_sink.c */ - atomic_t ref_count; + struct kref refcount; }; void dc_sink_retain(struct dc_sink *sink); -- 2.30.2