aboutsummaryrefslogtreecommitdiffstats
path: root/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch')
-rw-r--r--meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch117
1 files changed, 117 insertions, 0 deletions
diff --git a/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch
new file mode 100644
index 00000000..0036dd49
--- /dev/null
+++ b/meta-amd-bsp/recipes-kernel/linux/linux-yocto-4.14.71/2464-amdgpu-dc-use-kref-for-dc_state.patch
@@ -0,0 +1,117 @@
+From 355c6ea39905bb70dbdaa2ef614ada365ecf627a Mon Sep 17 00:00:00 2001
+From: Dave Airlie <airlied@redhat.com>
+Date: Tue, 3 Oct 2017 12:39:02 +1000
+Subject: [PATCH 2464/4131] amdgpu/dc: use kref for dc_state.
+
+I'm not a huge fan of those copying around refcounts bits, might
+want to consider alternates, but this should work for now.
+
+Signed-off-by: Dave Airlie <airlied@redhat.com>
+---
+ drivers/gpu/drm/amd/display/dc/core/dc.c | 26 +++++++++++------------
+ drivers/gpu/drm/amd/display/dc/core/dc_resource.c | 4 ++--
+ drivers/gpu/drm/amd/display/dc/inc/core_types.h | 2 +-
+ 3 files changed, 16 insertions(+), 16 deletions(-)
+
+diff --git a/drivers/gpu/drm/amd/display/dc/core/dc.c b/drivers/gpu/drm/amd/display/dc/core/dc.c
+index 6223358..c513225 100644
+--- a/drivers/gpu/drm/amd/display/dc/core/dc.c
++++ b/drivers/gpu/drm/amd/display/dc/core/dc.c
+@@ -940,25 +940,25 @@ struct dc_state *dc_create_state(void)
+ if (!context)
+ return NULL;
+
+- atomic_inc(&context->ref_count);
++ kref_init(&context->refcount);
+ return context;
+ }
+
+ void dc_retain_state(struct dc_state *context)
+ {
+- ASSERT(atomic_read(&context->ref_count) > 0);
+- atomic_inc(&context->ref_count);
++ kref_get(&context->refcount);
+ }
+
+-void dc_release_state(struct dc_state *context)
++static void dc_state_free(struct kref *kref)
+ {
+- ASSERT(atomic_read(&context->ref_count) > 0);
+- atomic_dec(&context->ref_count);
++ struct dc_state *context = container_of(kref, struct dc_state, refcount);
++ dc_resource_state_destruct(context);
++ kfree(context);
++}
+
+- if (atomic_read(&context->ref_count) == 0) {
+- dc_resource_state_destruct(context);
+- kfree(context);
+- }
++void dc_release_state(struct dc_state *context)
++{
++ kref_put(&context->refcount, dc_state_free);
+ }
+
+ static bool is_surface_in_context(
+@@ -1545,7 +1545,7 @@ void dc_set_power_state(
+ struct dc *dc,
+ enum dc_acpi_cm_power_state power_state)
+ {
+- atomic_t ref_count;
++ struct kref refcount;
+
+ switch (power_state) {
+ case DC_ACPI_CM_POWER_STATE_D0:
+@@ -1563,12 +1563,12 @@ void dc_set_power_state(
+ */
+
+ /* Preserve refcount */
+- ref_count = dc->current_state->ref_count;
++ refcount = dc->current_state->refcount;
+ dc_resource_state_destruct(dc->current_state);
+ memset(dc->current_state, 0,
+ sizeof(*dc->current_state));
+
+- dc->current_state->ref_count = ref_count;
++ dc->current_state->refcount = refcount;
+
+ break;
+ }
+diff --git a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+index 99a4d19..77b3474 100644
+--- a/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
++++ b/drivers/gpu/drm/amd/display/dc/core/dc_resource.c
+@@ -2432,7 +2432,7 @@ void dc_resource_state_copy_construct(
+ struct dc_state *dst_ctx)
+ {
+ int i, j;
+- atomic_t ref_count = dst_ctx->ref_count;
++ struct kref refcount = dst_ctx->refcount;
+
+ *dst_ctx = *src_ctx;
+
+@@ -2455,7 +2455,7 @@ void dc_resource_state_copy_construct(
+ }
+
+ /* context refcount should not be overridden */
+- dst_ctx->ref_count = ref_count;
++ dst_ctx->refcount = refcount;
+
+ }
+
+diff --git a/drivers/gpu/drm/amd/display/dc/inc/core_types.h b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+index c47ce6b..ff23f26 100644
+--- a/drivers/gpu/drm/amd/display/dc/inc/core_types.h
++++ b/drivers/gpu/drm/amd/display/dc/inc/core_types.h
+@@ -267,7 +267,7 @@ struct dc_state {
+
+ struct display_clock *dis_clk;
+
+- atomic_t ref_count;
++ struct kref refcount;
+ };
+
+ #endif /* _CORE_TYPES_H_ */
+--
+2.7.4
+