Le 22/09/24 - 18:31, Dmitry Baryshkov a écrit : > On Fri, Sep 06, 2024 at 07:28:17PM GMT, Louis Chauvet wrote: > > Currently drm_writeback_connector are created by > > drm_writeback_connector_init or drm_writeback_connector_init_with_encoder. > > Both of the function uses drm_connector_init and drm_encoder_init, but > > there is no way to properly clean those structure from outside. By using > > drm managed variants, we can ensure that the writeback connector is > > properly cleaned. > > > > This patch introduce drmm_writeback_connector_init, an helper to initialize > > a writeback connector using drm managed helpers. This function allows the > > caller to use its own encoder. > > Also it introduces drm_writeback_connector_cleanup(). Ideally that > should be a separate commit with a proper description. Will do for the v2. > You should also > document that existing users should call that function (and maybe add a > WARN_ON that can check if the function wasn't called). It was my initial implementation [2] (usage in [3]), but Maxime suggested switching to drmm. If I make it non-static, this will be a new API with no user. I don't know how to add a warning if this function is not called. Do you have an example somewhere where a warning is emitted after everything has been cleaned up? > Last, but not least, please don't add API without a user. Please switch > at least one driver into using this API. The user will be VKMS, see [1]. [1]:https://lore.kernel.org/all/20240912-google-vkms-managed-v3-4-7708d6ad262d@xxxxxxxxxxx/ [2]:https://lore.kernel.org/all/20240814-google-remove-crtc-index-from-parameter-v1-11-6e179abf9fd4@xxxxxxxxxxx/ [3]:https://lore.kernel.org/all/20240814-google-remove-crtc-index-from-parameter-v1-12-6e179abf9fd4@xxxxxxxxxxx/ Thanks, Louis Chauvet > > > > Signed-off-by: Louis Chauvet <louis.chauvet@xxxxxxxxxxx> > > --- > > Hi Maxime, Jani, > > > > I tried with this commit to implement the drm-managed version of writeback > > connector initialization. I tested with the current vkms driver, and it > > seems to works (at least no crash/warns). > > > > As suggested by Jani, I only created one function, which takes a > > NULL-able pointer for encoder/encoder functions/possible_crtc. What do you > > think about it? > > > > Regarding the documentation, I think I repeated too much, can I simply add > > comments like "see documentation of @... for the details / requirements"? > > > > Good weekend, > > Louis Chauvet > > --- > > drivers/gpu/drm/drm_writeback.c | 224 ++++++++++++++++++++++++++++++++++------ > > include/drm/drm_writeback.h | 7 ++ > > 2 files changed, 201 insertions(+), 30 deletions(-) > > > > -- > With best wishes > Dmitry