Skip to content

Commit 10021ef

Browse files
committed
drm/ast: Automatically clean up poll helper
Automatically clean up the conncetor-poll thread as part of the DRM device release. The new helper drmm_kms_helper_poll_init() provides a shared implementation for all drivers. v6: - fix kernel doc comment (Sui, kernel test robot) Signed-off-by: Thomas Zimmermann <tzimmermann@suse.de> Reviewed-by: Jocelyn Falempe <jfalempe@redhat.com> Acked-by: Sui Jingfeng <sui.jingfeng@linux.dev> Link: https://patchwork.freedesktop.org/patch/msgid/20240325200855.21150-14-tzimmermann@suse.de
1 parent 225a8d0 commit 10021ef

3 files changed

Lines changed: 32 additions & 1 deletion

File tree

drivers/gpu/drm/ast/ast_mode.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1905,7 +1905,9 @@ int ast_mode_config_init(struct ast_device *ast)
19051905

19061906
drm_mode_config_reset(dev);
19071907

1908-
drm_kms_helper_poll_init(dev);
1908+
ret = drmm_kms_helper_poll_init(dev);
1909+
if (ret)
1910+
return ret;
19091911

19101912
return 0;
19111913
}

drivers/gpu/drm/drm_probe_helper.c

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
#include <drm/drm_crtc.h>
3838
#include <drm/drm_edid.h>
3939
#include <drm/drm_fourcc.h>
40+
#include <drm/drm_managed.h>
4041
#include <drm/drm_modeset_helper_vtables.h>
4142
#include <drm/drm_print.h>
4243
#include <drm/drm_probe_helper.h>
@@ -951,6 +952,32 @@ void drm_kms_helper_poll_fini(struct drm_device *dev)
951952
}
952953
EXPORT_SYMBOL(drm_kms_helper_poll_fini);
953954

955+
static void drm_kms_helper_poll_init_release(struct drm_device *dev, void *res)
956+
{
957+
drm_kms_helper_poll_fini(dev);
958+
}
959+
960+
/**
961+
* drmm_kms_helper_poll_init - initialize and enable output polling
962+
* @dev: drm_device
963+
*
964+
* This function initializes and then also enables output polling support for
965+
* @dev similar to drm_kms_helper_poll_init(). Polling will automatically be
966+
* cleaned up when the DRM device goes away.
967+
*
968+
* See drm_kms_helper_poll_init() for more information.
969+
*
970+
* Returns:
971+
* 0 on success, or a negative errno code otherwise.
972+
*/
973+
int drmm_kms_helper_poll_init(struct drm_device *dev)
974+
{
975+
drm_kms_helper_poll_init(dev);
976+
977+
return drmm_add_action_or_reset(dev, drm_kms_helper_poll_init_release, dev);
978+
}
979+
EXPORT_SYMBOL(drmm_kms_helper_poll_init);
980+
954981
static bool check_connector_changed(struct drm_connector *connector)
955982
{
956983
struct drm_device *dev = connector->dev;

include/drm/drm_probe_helper.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ int drm_helper_probe_single_connector_modes(struct drm_connector
1616
int drm_helper_probe_detect(struct drm_connector *connector,
1717
struct drm_modeset_acquire_ctx *ctx,
1818
bool force);
19+
20+
int drmm_kms_helper_poll_init(struct drm_device *dev);
1921
void drm_kms_helper_poll_init(struct drm_device *dev);
2022
void drm_kms_helper_poll_fini(struct drm_device *dev);
2123
bool drm_helper_hpd_irq_event(struct drm_device *dev);

0 commit comments

Comments
 (0)