drm: Manage drm_mode_config_init with drmm_
drm_mode_config_cleanup is idempotent, so no harm in calling this twice. This allows us to gradually switch drivers over by removing explicit drm_mode_config_cleanup calls. With this step it's now also possible that (at least for simple drivers) automatic resource cleanup can be done correctly without a drm_driver->release hook. Therefore allow this now in devm_drm_dev_init(). Also with drmm_ explicit drm_driver->release hooks are kinda not the best option: Drivers can always just register their current release hook with drmm_add_action, but even better they could split them up to simplify the unwinding for the driver load failure case. So deprecate that hook to discourage future users. v2: Fixup the example in the kerneldoc too. v3: - For paranoia, double check that minor->dev == dev in the release hook, because I botched the pointer math in the drmm library. - Call drm_mode_config_cleanup when drmm_add_action fails, we'd be missing some mutex_destroy and ida_cleanup otherwise (Laurent) v4: Add a drmm_add_action_or_reset (like devm_ has) to encapsulate this pattern (Noralf). v5: Fix oversight in the new drmm_add_action_or_reset macro (Noralf) v4: Review from Sam: - drmm_mode_config_init wrapper (also suggested by Thomas) - improve commit message, explain better why ->relase is deprecated v5: - Make drmm_ the main function, with the old one as compat wrapper (Sam) - Add FIXME comments to drm_mode_config_cleanup/init() that drivers shouldn't use these anymore. - Move drmm_add_action_or_reset helper to an earlier patch. Reviewed-by: Sam Ravnborg <sam@ravnborg.org> Cc: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Cc: "Noralf Trønnes" <noralf@tronnes.org> Cc: Sam Ravnborg <sam@ravnborg.org> Cc: Thomas Zimmermann <tzimmermann@suse.de> Acked-by: Noralf Trønnes <noralf@tronnes.org> Signed-off-by: Daniel Vetter <daniel.vetter@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20200323144950.3018436-27-daniel.vetter@ffwll.ch
Šī revīzija ir iekļauta:
@@ -929,7 +929,23 @@ struct drm_mode_config {
|
||||
const struct drm_mode_config_helper_funcs *helper_private;
|
||||
};
|
||||
|
||||
void drm_mode_config_init(struct drm_device *dev);
|
||||
int __must_check drmm_mode_config_init(struct drm_device *dev);
|
||||
|
||||
/**
|
||||
* drm_mode_config_init - DRM mode_configuration structure initialization
|
||||
* @dev: DRM device
|
||||
*
|
||||
* This is the unmanaged version of drmm_mode_config_init() for drivers which
|
||||
* still explicitly call drm_mode_config_cleanup().
|
||||
*
|
||||
* FIXME: This function is deprecated and drivers should be converted over to
|
||||
* drmm_mode_config_init().
|
||||
*/
|
||||
static inline int drm_mode_config_init(struct drm_device *dev)
|
||||
{
|
||||
return drmm_mode_config_init(dev);
|
||||
}
|
||||
|
||||
void drm_mode_config_reset(struct drm_device *dev);
|
||||
void drm_mode_config_cleanup(struct drm_device *dev);
|
||||
|
||||
|
Atsaukties uz šo jaunā problēmā
Block a user