@@ -200,8 +200,7 @@ int amdgpu_dm_initialize_default_pipeline(struct drm_plane *plane, struct drm_pr
return 0;
cleanup:
- for (; i >= 0; i--)
- kfree(ops[i]);
+ drm_colorop_pipeline_destroy(plane);
return ret;
}
@@ -154,6 +154,47 @@ static int drm_colorop_init(struct drm_device *dev, struct drm_colorop *colorop,
return ret;
}
+/**
+ * drm_colorop_cleanup - Cleanup a drm_colorop object in color_pipeline
+ *
+ * @colorop: The drm_colorop object to be cleaned
+ */
+void drm_colorop_cleanup(struct drm_colorop *colorop)
+{
+ struct drm_device *dev = colorop->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+
+ list_del(&colorop->head);
+ config->num_colorop--;
+
+ if (colorop->state && colorop->state->data) {
+ drm_property_blob_put(colorop->state->data);
+ colorop->state->data = NULL;
+ }
+
+ kfree(colorop->state);
+ kfree(colorop);
+}
+
+/**
+ * drm_colorop_pipeline_destroy - Helper for color pipeline destruction
+ *
+ * @plane: - The drm_plane structure containing the color_pipeline
+ *
+ * Provides a default color pipeline destroy handler for a planes.
+ */
+void drm_colorop_pipeline_destroy(struct drm_plane *plane)
+{
+ struct drm_device *dev = plane->dev;
+ struct drm_mode_config *config = &dev->mode_config;
+ struct drm_colorop *colorop, *next;
+
+ list_for_each_entry_safe(colorop, next, &config->colorop_list, head) {
+ drm_colorop_cleanup(colorop);
+ }
+}
+EXPORT_SYMBOL(drm_colorop_pipeline_destroy);
+
/**
* drm_colorop_curve_1d_init - Initialize a DRM_COLOROP_1D_CURVE
*
@@ -89,8 +89,7 @@ static int vkms_initialize_color_pipeline(struct drm_plane *plane, struct drm_pr
return 0;
cleanup:
- for (; i >= 0; i--)
- kfree(ops[i]);
+ drm_colorop_pipeline_destroy(plane);
return ret;
}
@@ -367,6 +367,8 @@ static inline struct drm_colorop *drm_colorop_find(struct drm_device *dev,
return mo ? obj_to_colorop(mo) : NULL;
}
+void drm_colorop_pipeline_destroy(struct drm_plane *plane);
+
int drm_colorop_curve_1d_init(struct drm_device *dev, struct drm_colorop *colorop,
struct drm_plane *plane, u64 supported_tfs,
bool allow_bypass);
The functions are to clean up color pipeline when a device driver fails to create its color pipeline. Signed-off-by: Alex Hung <alex.hung@amd.com> --- .../amd/display/amdgpu_dm/amdgpu_dm_colorop.c | 3 +- drivers/gpu/drm/drm_colorop.c | 41 +++++++++++++++++++ drivers/gpu/drm/vkms/vkms_colorop.c | 3 +- include/drm/drm_colorop.h | 2 + 4 files changed, 45 insertions(+), 4 deletions(-)