summaryrefslogtreecommitdiff
path: root/drivers/gpu/drm/drm_managed.c
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2022-05-06 17:19:11 +1000
committerDave Airlie <airlied@redhat.com>2022-05-06 17:20:13 +1000
commitc67f84e97bafe73c47d5773105b114118ffb84df (patch)
treed8e01ee364dda98fe99426ab62b4dd9fbd89c980 /drivers/gpu/drm/drm_managed.c
parentaf3847a7472d2def8358b7ae94b14f1d20fd8661 (diff)
parent6071c4c2a319da360b0bf2bc397d4fefad10b2c8 (diff)
Merge tag 'drm-misc-next-2022-05-05' of git://anongit.freedesktop.org/drm/drm-misc into drm-next
drm-misc-next for 5.19: UAPI Changes: Cross-subsystem Changes: Core Changes: - Add DRM-managed mutex initialisation - edid: Doc improvements - fbdev: deferred io improvements - format-helper: consolidate format conversion helpers - gem: Rework fence handling in drm_gem_plane_helper_prepare_fb Driver Changes: - ast: DisplayPort support, locking improvements - exynos: Revert conversion to devm_drm_of_get_bridge for DSI - mgag200: locking improvements - mxsfb: LCDIF CRC support - nouveau: switch to drm_gem_plane_helper_prepare_fb - rockchip: Refactor IOMMU initialisation, make some structures static, replace drm_detect_hdmi_monitor with drm_display_info.is_hdmi, support swapped YUV formats, clock improvements, rk3568 support, VOP2 support - bridge: - adv7511: Enable CEC for ADV7535 - it6505: Send DPCD SET_POWER to monitor at disable - mcde_dsi: Revert conversion to devm_drm_of_get_bridge - tc358767: Fix for eDP and DP DT endpoint parsing - new bridge: i.MX8MP LDB - panel: - new panel: Startek KD070WVFPA043-C069A Signed-off-by: Dave Airlie <airlied@redhat.com> From: Maxime Ripard <maxime@cerno.tech> Link: https://patchwork.freedesktop.org/patch/msgid/20220505131127.lcqvsywo7qt3eywk@houat
Diffstat (limited to 'drivers/gpu/drm/drm_managed.c')
-rw-r--r--drivers/gpu/drm/drm_managed.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/drivers/gpu/drm/drm_managed.c b/drivers/gpu/drm/drm_managed.c
index 37d7db6223be..4cf214de50c4 100644
--- a/drivers/gpu/drm/drm_managed.c
+++ b/drivers/gpu/drm/drm_managed.c
@@ -8,6 +8,7 @@
#include <drm/drm_managed.h>
#include <linux/list.h>
+#include <linux/mutex.h>
#include <linux/slab.h>
#include <linux/spinlock.h>
@@ -262,3 +263,29 @@ void drmm_kfree(struct drm_device *dev, void *data)
free_dr(dr_match);
}
EXPORT_SYMBOL(drmm_kfree);
+
+static void drmm_mutex_release(struct drm_device *dev, void *res)
+{
+ struct mutex *lock = res;
+
+ mutex_destroy(lock);
+}
+
+/**
+ * drmm_mutex_init - &drm_device-managed mutex_init()
+ * @dev: DRM device
+ * @lock: lock to be initialized
+ *
+ * Returns:
+ * 0 on success, or a negative errno code otherwise.
+ *
+ * This is a &drm_device-managed version of mutex_init(). The initialized
+ * lock is automatically destroyed on the final drm_dev_put().
+ */
+int drmm_mutex_init(struct drm_device *dev, struct mutex *lock)
+{
+ mutex_init(lock);
+
+ return drmm_add_action_or_reset(dev, drmm_mutex_release, lock);
+}
+EXPORT_SYMBOL(drmm_mutex_init);