drm/ast: Inline drm_simple_encoder_init()
Subsystems (3)
Thomas Zimmermann
maintainerPATCH 1/1 drm/ast: Inline drm_simple_encoder_init()
The function drm_simple_encoder_init() is a trivial helper and deprecated. Replace it with the regular call to drm_encoder_init(). Resolves the dependency on drm_simple_kms_helper.h. No functional changes.
--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)
drivers/gpu/drm/ast/ast_mode.c +40 -5
@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h"
@@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */
@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
@@ -1427,6 +1435,14 @@ static int ast_vga_output_init(struct ast_device *ast)return 0 ; } +/* +* SIL164 Encoder +*/ + +static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * SIL164 Connector */
@@ -1480,7 +1496,8 @@ static int ast_sil164_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.sil164.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_sil164_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
@@ -1496,6 +1513,14 @@ static int ast_sil164_output_init(struct ast_device *ast)return 0 ; } +/* +* DP501 Encoder +*/ + +static const struct drm_encoder_funcs ast_dp501_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * DP501 Connector */
@@ -1578,7 +1603,8 @@ static int ast_dp501_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.dp501.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_dp501_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
@@ -1594,6 +1620,14 @@ static int ast_dp501_output_init(struct ast_device *ast)return 0 ; } +/* +* ASPEED Display-Port Encoder +*/ + +static const struct drm_encoder_funcs ast_astdp_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * ASPEED Display-Port Connector */
@@ -1688,7 +1722,8 @@ static int ast_astdp_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.astdp.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_astdp_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
Signature · 1 line
2.45.2
Jocelyn Falempe
reviewerQuoted 4 lines · Thomas Zimmermann
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.
Do you think it's possible to add a default to drm_encoder_init() to avoid having to declare the same struct for each encoder ?
something like:
drm_encoder_init(...)
{
if (!funcs)
funcs = &drm_encoder_default_funcs;
So you can call it like this to get the default funcs:
drm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL);
I don't see this pattern in other drm functions, so it might not fit the current coding style.
Best regards,
Signature · 1 line
Jocelyn
Quoted 118 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +40
-5@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ @@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1427,6 +1435,14 @@ static int ast_vga_output_init(struct ast_device *ast)return 0 ; } +/* +* SIL164 Encoder +*/ + +static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * SIL164 Connector */ @@ -1480,7 +1496,8 @@ static int ast_sil164_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.sil164.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_sil164_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1496,6 +1513,14 @@ static int ast_sil164_output_init(struct ast_device *ast)return 0 ; } +/* +* DP501 Encoder +*/ + +static const struct drm_encoder_funcs ast_dp501_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * DP501 Connector */ @@ -1578,7 +1603,8 @@ static int ast_dp501_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.dp501.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_dp501_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1594,6 +1620,14 @@ static int ast_dp501_output_init(struct ast_device *ast)return 0 ; } +/* +* ASPEED Display-Port Encoder +*/ + +static const struct drm_encoder_funcs ast_astdp_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * ASPEED Display-Port Connector */ @@ -1688,7 +1722,8 @@ static int ast_astdp_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.astdp.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_astdp_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
Thomas Zimmermann
maintainerHi
Am 25.06.24 um 15:55 schrieb Jocelyn Falempe:
Quoted 18 lines · Thomas Zimmermann
Quoted 4 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Do you think it's possible to add a default to
drm_encoder_init()to avoid having to declare the same struct for each encoder ?something like:
drm_encoder_init(...)
{if (!funcs)
funcs =&drm_encoder_default_funcs;
Quoted 6 lines
So you can call it like this to get the default funcs:
drm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL);I don't see this pattern in other drm functions, so it might not fit the current coding style.
Yeah, we don't do this in other places. And it's not guaranteed that drm_encoder_cleanup() is the correct helper in all cases; even the common ones. I would prefer to not add such tweaks. As for drm_simple_encoder_init(), it was an attempt to solve exactly this problem, but the function is so trivial that it's not actually worth the dependency.
Best regards
Thomas
Quoted 3 lines
Best regards,
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 27 lines · Thomas Zimmermann
Hi
Am 25.06.24 um 15:55 schrieb Jocelyn Falempe:
Quoted 24 lines · Thomas Zimmermann
Quoted 4 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Do you think it's possible to add a default to
drm_encoder_init()to avoid having to declare the same struct for each encoder ?something like:
drm_encoder_init(...)
{if (!funcs)
funcs =&drm_encoder_default_funcs;So you can call it like this to get the default funcs:
drm_encoder_init(dev, encoder, NULL, DRM_MODE_ENCODER_DAC, NULL);
Quoted 8 lines
Quoted 2 lines
I don't see this pattern in other drm functions, so it might not fit the current coding style.
Yeah, we don't do this in other places. And it's not guaranteed that
drm_encoder_cleanup()is the correct helper in all cases; even the common ones. I would prefer to not add such tweaks. As fordrm_simple_encoder_init(), it was an attempt to solve exactly this problem, but the function is so trivial that it's not actually worth the dependency.
For drmm_encoder_init/alloc this is doable, because it makes sure that there really is only one correct encoder cleanup hook for simple encoders. Without drmm_ there's the entire "who calls kfree() and how buggy is it" mess :-/
So I'd very much welcome this kind of handling in drmm_encoder_alloc/init, but in the unmanaged drm_encoder_init I agree it sounds like a mistake.
Cheers,
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 4 lines · Thomas Zimmermann
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.
Thanks for your patch, it looks good to me.
Quoted 118 lines
Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +40
-5@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ @@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1427,6 +1435,14 @@ static int ast_vga_output_init(struct ast_device *ast)return 0 ; } +/* +* SIL164 Encoder +*/ + +static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * SIL164 Connector */ @@ -1480,7 +1496,8 @@ static int ast_sil164_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.sil164.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_sil164_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1496,6 +1513,14 @@ static int ast_sil164_output_init(struct ast_device *ast)return 0 ; } +/* +* DP501 Encoder +*/ + +static const struct drm_encoder_funcs ast_dp501_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * DP501 Connector */ @@ -1578,7 +1603,8 @@ static int ast_dp501_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.dp501.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_dp501_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);@@ -1594,6 +1620,14 @@ static int ast_dp501_output_init(struct ast_device *ast)return 0 ; } +/* +* ASPEED Display-Port Encoder +*/ + +static const struct drm_encoder_funcs ast_astdp_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * ASPEED Display-Port Connector */ @@ -1688,7 +1722,8 @@ static int ast_astdp_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.astdp.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_TMDS ); + ret =drm_encoder_init (dev, encoder, &ast_astdp_encoder_funcs, +DRM_MODE_ENCODER_TMDS ,NULL );if (ret)return ret; encoder->possible_crtcs =drm_crtc_mask (crtc);
Thomas Zimmermann
maintainerHi
Am 25.06.24 um 16:18 schrieb Jocelyn Falempe:
Quoted 10 lines · Thomas Zimmermann
Quoted 4 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Thanks for your patch, it looks good to me.
Reviewed-by Jocelyn Falempe <[email protected]>
Thanks. I've merged the patch for now. Let's see where the discussion on managed interfaces goes.
Best regards
Thomas
Quoted 117 lines
Quoted 116 lines
Signed-off-by Thomas Zimmermann <[email protected]>---
drivers/gpu/drm/ast/ast_mode.c| 45 ++++++++++++++++++++++++++++++----1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +0
-1@@ -45,7 +45,6 @@ #include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h"@@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev) return 0; }+/*
+ * VGA Encoder
+ */drivers/gpu/drm/ast/ast_mode.c +5
-0+ +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/*
* VGA Connector
*/drivers/gpu/drm/ast/ast_mode.c +2
-0@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast) struct drm_connector *connector = &ast->output.vga.connector; int ret; - ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_DAC); + ret = drm_encoder_init(dev, encoder, &ast_vga_encoder_funcs, + DRM_MODE_ENCODER_DAC, NULL); if (ret) return ret;
encoder->possible_crtcs=drm_crtc_mask(crtc);drivers/gpu/drm/ast/ast_mode.c +0
-0@@ -1427,6 +1435,14 @@ static int ast_vga_output_init(struct ast_device *ast) return 0; }+/*
+ * SIL164 Encoder
+ */drivers/gpu/drm/ast/ast_mode.c +5
-0+ +static const struct drm_encoder_funcs ast_sil164_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/*
* SIL164 Connector
*/drivers/gpu/drm/ast/ast_mode.c +2
-0@@ -1480,7 +1496,8 @@ static int ast_sil164_output_init(struct ast_device *ast) struct drm_connector *connector = &ast->output.sil164.connector; int ret; - ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS); + ret = drm_encoder_init(dev, encoder, &ast_sil164_encoder_funcs, + DRM_MODE_ENCODER_TMDS, NULL); if (ret) return ret;
encoder->possible_crtcs=drm_crtc_mask(crtc);drivers/gpu/drm/ast/ast_mode.c +0
-0@@ -1496,6 +1513,14 @@ static int ast_sil164_output_init(struct ast_device *ast) return 0; }+/*
+ * DP501 Encoder
+ */drivers/gpu/drm/ast/ast_mode.c +5
-0+ +static const struct drm_encoder_funcs ast_dp501_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/*
* DP501 Connector
*/drivers/gpu/drm/ast/ast_mode.c +2
-0@@ -1578,7 +1603,8 @@ static int ast_dp501_output_init(struct ast_device *ast) struct drm_connector *connector = &ast->output.dp501.connector; int ret; - ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS); + ret = drm_encoder_init(dev, encoder, &ast_dp501_encoder_funcs, + DRM_MODE_ENCODER_TMDS, NULL); if (ret) return ret;
encoder->possible_crtcs=drm_crtc_mask(crtc);drivers/gpu/drm/ast/ast_mode.c +0
-0@@ -1594,6 +1620,14 @@ static int ast_dp501_output_init(struct ast_device *ast) return 0; }+/*
+ * ASPEED Display-Port Encoder
+ */drivers/gpu/drm/ast/ast_mode.c +5
-0+ +static const struct drm_encoder_funcs ast_astdp_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/*
* ASPEED Display-Port Connector
*/drivers/gpu/drm/ast/ast_mode.c +2
-0@@ -1688,7 +1722,8 @@ static int ast_astdp_output_init(struct ast_device *ast) struct drm_connector *connector = &ast->output.astdp.connector; int ret; - ret = drm_simple_encoder_init(dev, encoder, DRM_MODE_ENCODER_TMDS); + ret = drm_encoder_init(dev, encoder, &ast_astdp_encoder_funcs, + DRM_MODE_ENCODER_TMDS, NULL); if (ret) return ret;
encoder->possible_crtcs=drm_crtc_mask(crtc);
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 38 lines · Thomas Zimmermann
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1422
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );
What about using drmm_encoder_init() instead? It will call drm_encoder_cleanup automatically.
Signature · 2 lines
With best wishes Dmitry
Thomas Zimmermann
maintainerHi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 42 lines · Thomas Zimmermann
Quoted 41 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ @@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret;
Quoted 5 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1422
Quoted 3 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1- ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses drmm_mode_config_init() for auto-cleaning up the modesetting pipeline. Using drmm_encoder_init() seems like a bit of wasted resources for no gain.
Best regards
Thomas
Quoted 1 line
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 48 lines · Thomas Zimmermann
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.
Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
I'd say it's qui pro quo. We are wasting resources on drmm handling, but then keep it by dropping all drm_encoder_funcs instances.
Signature · 2 lines
With best wishes Dmitry
Thomas Zimmermann
maintainerHi
Am 26.06.24 um 11:10 schrieb Dmitry Baryshkov:
Quoted 48 lines · Thomas Zimmermann
Quoted 47 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 44 lines · Thomas Zimmermann
Quoted 36 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 5 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.
Quoted 7 lines
Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.I'd say it's qui pro quo. We are wasting resources on drmm handling, but then keep it by dropping all
drm_encoder_funcsinstances.
With drm_encoder_init() there's a static-const declared struct in RO memory. With drmm_encoder_init(), there's a kalloc for the managed callback data. It's RW memory and the alloc can fail. Therefore I prefer drm_encoder_init() in this case.
Best regards
Thomas
Quoted 1 line
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 57 lines · Thomas Zimmermann
Hi
Am 26.06.24 um 11:10 schrieb Dmitry Baryshkov:
Quoted 53 lines · Thomas Zimmermann
Quoted 52 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
Quoted 7 lines
Quoted 2 lines
I'd say it's qui pro quo. We are wasting resources on drmm handling, but then keep it by dropping all
drm_encoder_funcsinstances.With
drm_encoder_init()there's a static-const declared struct in RO memory. Withdrmm_encoder_init(), there's a kalloc for the managed callback data. It's RW memory and the alloc can fail. Therefore I preferdrm_encoder_init()in this case.
Ack.
Signature · 2 lines
With best wishes Dmitry
Thomas Zimmermann
maintainerHi
Am 26.06.24 um 11:19 schrieb Dmitry Baryshkov:
Quoted 57 lines · Thomas Zimmermann
Quoted 56 lines
Hi
Am 26.06.24 um 11:10 schrieb Dmitry Baryshkov:
Quoted 53 lines · Thomas Zimmermann
Quoted 52 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
Quoted 7 lines
Quoted 6 lines
Quoted 2 lines
I'd say it's qui pro quo. We are wasting resources on drmm handling, but then keep it by dropping all
drm_encoder_funcsinstances.With
drm_encoder_init()there's a static-const declared struct in RO memory. Withdrmm_encoder_init(), there's a kalloc for the managed callback data. It's RW memory and the alloc can fail. Therefore I preferdrm_encoder_init()in this case.Ack.
One more though on this: we could discuss if we want some default cleanup. Such as if no cleanup pointer has been set, we always call drm_encoder_cleanup(). But IMHO that needs to be consistent among all elements of the pipeline (planes, CRTCs, etc), and we need to document clearly which and why the default has been chosen.
Best regards
Thomas
Quoted 1 line
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 48 lines · Thomas Zimmermann
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.
Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
The idea of drmm_ is that you use them all. That the managed version of drm_mode_config_init also happens to still work with the unmanaged encoder/connector/crtc/plane cleanup is just to facilitate gradual conversions.
And see my other reply, for drmm_encoder_init supporting the NULL funcs case actually makes full sense.
Also, any driver can be hotunbound through sysfs, no hotunplug of the hw needed at all.
-Sima
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Thomas Zimmermann
maintainerHi
Am 26.06.24 um 19:59 schrieb Daniel Vetter:
Quoted 53 lines · Thomas Zimmermann
Quoted 47 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
Quoted 4 lines
The idea of
drmm_is that you use them all. That the managed version ofdrm_mode_config_initalso happens to still work with the unmanaged encoder/connector/crtc/plane cleanup is just to facilitate gradual conversions.
Sure, I welcome using drmm_ everywhere. I just don't like the fine-grained release if that's unnecessary. What most DRM drivers need is in drmm_mode_config_init().
Best regards
Thomas
Quoted 7 lines
And see my other reply, for
drmm_encoder_initsupporting the NULL funcs case actually makes full sense.Also, any driver can be hotunbound through sysfs, no hotunplug of the hw needed at all.
-Sima
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
Quoted 56 lines · Thomas Zimmermann
Hi
Am 26.06.24 um 19:59 schrieb Daniel Vetter:
Quoted 53 lines · Thomas Zimmermann
Quoted 52 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.
Quoted 8 lines
Quoted 4 lines
The idea of
drmm_is that you use them all. That the managed version ofdrm_mode_config_initalso happens to still work with the unmanaged encoder/connector/crtc/plane cleanup is just to facilitate gradual conversions.Sure, I welcome using
drmm_everywhere. I just don't like the fine-grained release if that's unnecessary. What most DRM drivers need is indrmm_mode_config_init().
Why do you think drmm_mode_config_init is better?
My take is that the point of drmm and devres is that you have really fine-grained release hooks, so that you never have to write hand-rolled error handling code anymore. The issue is that when you then try to combine that with bigger hammer methods like the cleanup callbacks in drm_mode_config_cleanup, it won't work, because it will interleave wrongly. And then you're back to hand-rolling all the cleanup code again. It's a bit an all-or-nothing approach unfortunately, at least for a given area.
At least my idea was to have drmm_mode_config_init as a transational helper only, not as the endpoint. At least for anything the driver allocates/initializes itself, there's still a bunch of things that need to be cleaned up separately.
Or the other counterpoint: If the global release really is best, then drm_driver->release is all that's ever needed, and the entire drmm_ infrastructure is kinda pointless. Which yes, strictly speaking it is, at the cost of typing a lot of error paths.
-Sima
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Quoted 60 lines · Daniel Vetter
Quoted 48 lines · Thomas Zimmermann
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.The idea of
drmm_is that you use them all. That the managed version ofdrm_mode_config_initalso happens to still work with the unmanaged encoder/connector/crtc/plane cleanup is just to facilitate gradual conversions.
Quoted 5 lines
And see my other reply, for
drmm_encoder_initsupporting the NULL funcs case actually makes full sense.Also, any driver can be hotunbound through sysfs, no hotunplug of the hw needed at all.
I pondered this some more, I think we could embed the drmm tracking structure into struct drm_encoder (and anywhere else we need one), which
- would mean a lot of the drmm_ versions again get a void return value, like their non-managed counterparts.
- we could truly roll out drmm_ versions everywhere and deprecate the unmanaged ones in a lot more cases, since drivers like ast could then also use it.
I'm not sure this is a bright idea at scale, since devm_ doesn't do it afaik. But maybe we should just try.
Thoughts?
Cheers, Sima
Signature · 3 lines
Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch
Thomas Zimmermann
maintainerHi
Am 27.06.24 um 09:47 schrieb Daniel Vetter:
Quoted 70 lines · Daniel Vetter
Quoted 58 lines · Thomas Zimmermann
Quoted 47 lines
Hi
Am 26.06.24 um 06:34 schrieb Dmitry Baryshkov:
Quoted 36 lines · Thomas Zimmermann
Quoted 35 lines
The function
drm_simple_encoder_init()is a trivial helper and deprecated. Replace it with the regular call todrm_encoder_init(). Resolves the dependency ondrm_simple_kms_helper.h. No functional changes.Signed-off-by Thomas Zimmermann <[email protected]>--- drivers/gpu/drm/ast/ast_mode.c | 45 ++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-)drivers/gpu/drm/ast/ast_mode.c +8
-1@@ -45,7 +45,6 @@#include <drm/drm_managed.h> #include <drm/drm_panic.h> #include <drm/drm_probe_helper.h> -#include <drm/drm_simple_kms_helper.h> #include "ast_ddc.h" #include "ast_drv.h" @@ -1358,6 +1357,14 @@ static int ast_crtc_init(struct drm_device *dev)return 0 ; } +/* +* VGA Encoder +*/ + +static const struct drm_encoder_funcs ast_vga_encoder_funcs = { + .destroy = drm_encoder_cleanup, +}; +/* * VGA Connector */ Quoted 8 lines
drivers/gpu/drm/ast/ast_mode.c static int ast_vga_output_init(struct ast_device *ast) · line 1421
Quoted 6 lines
drivers/gpu/drm/ast/ast_mode.c +2
-1@@ -1411,7 +1418,8 @@ static int ast_vga_output_init(struct ast_device *ast)struct drm_connector *connector = &ast->output.vga.connector;int ret; - ret =drm_simple_encoder_init (dev, encoder,DRM_MODE_ENCODER_DAC ); + ret =drm_encoder_init (dev, encoder, &ast_vga_encoder_funcs, +DRM_MODE_ENCODER_DAC ,NULL );What about using
drmm_encoder_init()instead? It will calldrm_encoder_cleanupautomatically.Quoted 5 lines
IIRC the original use case for the drmm_encoder_*() funcs was to solve problems with the clean-up order if the encoder was added dynamically. The hardware for ast is entirely static and ast uses
drmm_mode_config_init()for auto-cleaning up the modesetting pipeline. Usingdrmm_encoder_init()seems like a bit of wasted resources for no gain.The idea of
drmm_is that you use them all. That the managed version ofdrm_mode_config_initalso happens to still work with the unmanaged encoder/connector/crtc/plane cleanup is just to facilitate gradual conversions.Quoted 5 lines
And see my other reply, for
drmm_encoder_initsupporting the NULL funcs case actually makes full sense.Also, any driver can be hotunbound through sysfs, no hotunplug of the hw needed at all.
I pondered this some more, I think we could embed the drmm tracking structure into struct
drm_encoder(and anywhere else we need one), which- would mean a lot of the
drmm_versions again get a void return value, like their non-managed counterparts.
Quoted 8 lines
- we could truly roll out
drmm_versions everywhere and deprecate the unmanaged ones in a lot more cases, since drivers like ast could then also use it.I'm not sure this is a bright idea at scale, since
devm_doesn't do it afaik. But maybe we should just try.Thoughts?
I cannot say whether it's a good idea. At least it's sounds better then kcalloc-ing drm_res for each object. The drm_res instance could directly into struct drm_mode_object, so it's available for all the relevant stages of the modesetting pipeline.
Best regards
Thomas
Quoted 2 lines
Cheers, Sima
Signature · 7 lines
-- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)