drm/vkms: Add writeback encoders as possible clones
PATCH 1/1 drm/vkms: Add writeback encoders as possible clones
Since commit 41b4b11da0215 ("drm: Add valid clones check") setting the possible_clones values is a hard requirement for cloning. vkms supports cloning for writeback connectors in order to capture CRTC content, however that broke with said commit.
Writeback connectors are created on a per-CRTC basis, thus mark every non-writeback connector that is compatible with a given CRTC as possible clone - and vice-versa.
Using a default configuration, the corresponding drm_info output changes from:
├───Encoders
│ ├───Encoder 0
│ │ ├───Object ID: 40
│ │ ├───Type: virtual
│ │ ├───CRTCS: {0}
│ │ └───Clones: {0}
│ └───Encoder 1
│ ├───Object ID: 41
│ ├───Type: virtual
│ ├───CRTCS: {0}
│ └───Clones: {1}to:
├───Encoders
│ ├───Encoder 0
│ │ ├───Object ID: 44
│ │ ├───Type: virtual
│ │ ├───CRTCS: {0}
│ │ └───Clones: {0, 1}
│ └───Encoder 1
│ ├───Object ID: 50
│ ├───Type: virtual
│ ├───CRTCS: {0}
│ └───Clones: {0, 1}--- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++++++++++ drivers/gpu/drm/vkms/vkms_writeback.c | 2 ++ 2 files changed, 14 insertions(+)
drivers/gpu/drm/vkms/vkms_output.c +12 -0
@@ -77,9 +77,21 @@ int vkms_output_init(struct vkms_device *vkmsdev)return ret; } + encoder_cfg->encoder->possible_clones |=BIT (drm_encoder_index (encoder_cfg->encoder)); +vkms_config_encoder_for_each_possible_crtc (encoder_cfg, idx, possible_crtc) { encoder_cfg->encoder->possible_crtcs |=drm_crtc_mask (&possible_crtc->crtc->crtc); + +if (vkms_config_crtc_get_writeback (possible_crtc)) { +struct drm_encoder *wb_encoder = + &possible_crtc->crtc->wb_encoder; + + encoder_cfg->encoder->possible_clones |= +BIT (drm_encoder_index (wb_encoder)); + wb_encoder->possible_clones |= +BIT (drm_encoder_index (encoder_cfg->encoder)); + } } }
drivers/gpu/drm/vkms/vkms_writeback.c +2 -0
@@ -174,6 +174,8 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,if (ret)return ret; vkms_output->wb_encoder.possible_crtcs |=drm_crtc_mask (&vkms_output->crtc); + vkms_output->wb_encoder.possible_clones |= +BIT (drm_encoder_index (&vkms_output->wb_encoder));drm_connector_helper_add (&wb->base, &vkms_wb_conn_helper_funcs);
Signature · 1 line
2.50.0
Quoted 11 lines · Robert Mader
Since commit
41b4b11da0215("drm: Add valid clones check") setting thepossible_clonesvalues is a hard requirement for cloning.vkmssupports cloning for writeback connectors in order to capture CRTC content, however that broke with said commit.Writeback connectors are created on a per-CRTC basis, thus mark every non-writeback connector that is compatible with a given CRTC as possible clone - and vice-versa.
Using a default configuration, the corresponding
drm_infooutput changes from:
It feels like the current possible_clones is incorrect according to the documentation. Should there be a Fixes tag?
Quoted 8 lines
Signed-off-by Robert Mader <[email protected]>--- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++++++++++ drivers/gpu/drm/vkms/vkms_writeback.c | 2 ++ 2 files changed, 14 insertions(+)
Signature · 2 lines
With best wishes Dmitry
Thanks for the feedback!
Quoted 6 lines · Dmitry Baryshkov
Quoted 5 lines · Robert Mader
Since commit
41b4b11da0215("drm: Add valid clones check") setting thepossible_clonesvalues is a hard requirement for cloning.vkmssupports cloning for writeback connectors in order to capture CRTC content, however that broke with said commit.
Quoted 8 lines
Quoted 6 lines
Writeback connectors are created on a per-CRTC basis, thus mark every non-writeback connector that is compatible with a given CRTC as possible clone - and vice-versa.
Using a default configuration, the corresponding
drm_infooutput changes from:It feels like the current
possible_clonesis incorrect according to the documentation. Should there be a Fixes tag?
The issue is that possible_clones was never explicitly set, making it fall back to the default value - every encoder only being compatible with itself. So candidates for a Fixes tag would be either the initial implementation of the writeback connector in vkms - or the commit that started enforcing correct values ("drm: Add valid clones check") as previously the values where simply ignored.
Unfortunately the patch is not easily backportable either way because of the changes in https://patchwork.freedesktop.org/series/144091/#rev4 that recently landed - i.e. 6.15 would need a completely rewritten fix, and previous kernels don't really need it.
Thus I'd rather leave it out if that's ok with you?
Quoted 7 lines
Quoted 7 lines
Signed-off-by Robert Mader<[email protected]>--- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++++++++++ drivers/gpu/drm/vkms/vkms_writeback.c | 2 ++ 2 files changed, 14 insertions(+)
Signature · 6 lines
Robert Mader Consultant Software Developer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718
Louis Chauvet
maintainerLe 03/07/2025 à 11:03, Robert Mader a écrit :
Quoted 38 lines
Since commit
41b4b11da0215("drm: Add valid clones check") setting thepossible_clonesvalues is a hard requirement for cloning.vkmssupports cloning for writeback connectors in order to capture CRTC content, however that broke with said commit.Writeback connectors are created on a per-CRTC basis, thus mark every non-writeback connector that is compatible with a given CRTC as possible clone - and vice-versa.
Using a default configuration, the corresponding
drm_infooutput changes from:├───Encoders │ ├───Encoder 0 │ │ ├───Object ID: 40 │ │ ├───Type: virtual │ │ ├───CRTCS: {0} │ │ └───Clones: {0} │ └───Encoder 1 │ ├───Object ID: 41 │ ├───Type: virtual │ ├───CRTCS: {0} │ └───Clones: {1}to:
├───Encoders │ ├───Encoder 0 │ │ ├───Object ID: 44 │ │ ├───Type: virtual │ │ ├───CRTCS: {0} │ │ └───Clones: {0, 1} │ └───Encoder 1 │ ├───Object ID: 50 │ ├───Type: virtual │ ├───CRTCS: {0} │ └───Clones: {0, 1}
Quoted 1 line
Signed-off-by Robert Mader <[email protected]>
Hi,
About the Fixes tag, I think you can add it anyway, if the patch is not applicable on previous kernel version, this is not an issue, it will just be ignored.
Quoted 17 lines
--- drivers/gpu/drm/vkms/vkms_output.c | 12 ++++++++++++ drivers/gpu/drm/vkms/vkms_writeback.c | 2 ++ 2 files changed, 14 insertions(+)drivers/gpu/drm/vkms/vkms_output.c +2
-0@@ -77,9 +77,21 @@ int vkms_output_init(struct vkms_device *vkmsdev)return ret; } + encoder_cfg->encoder->possible_clones |=BIT (drm_encoder_index (encoder_cfg->encoder)); +vkms_config_encoder_for_each_possible_crtc (encoder_cfg, idx, possible_crtc) { encoder_cfg->encoder->possible_crtcs |=
drivers/gpu/drm/vkms/vkms_output.c int vkms_output_init(struct vkms_device *vkmsdev) · line 93
Quoted 10 lines
drivers/gpu/drm/vkms/vkms_output.c +9
-0drm_crtc_mask (&possible_crtc->crtc->crtc); + +if (vkms_config_crtc_get_writeback (possible_crtc)) { +struct drm_encoder *wb_encoder = + &possible_crtc->crtc->wb_encoder; + + encoder_cfg->encoder->possible_clones |= +BIT (drm_encoder_index (wb_encoder)); + wb_encoder->possible_clones |= +BIT (drm_encoder_index (encoder_cfg->encoder));
Can you use drm_encoder_mask directly?
Thanks a lot for this patch,
Louis Chauvet
Quoted 17 lines
drivers/gpu/drm/vkms/vkms_output.c +1
-0+ } } }drivers/gpu/drm/vkms/vkms_writeback.c +2
-0@@ -174,6 +174,8 @@ int vkms_enable_writeback_connector(struct vkms_device *vkmsdev,if (ret)return ret; vkms_output->wb_encoder.possible_crtcs |=drm_crtc_mask (&vkms_output->crtc); + vkms_output->wb_encoder.possible_clones |= +BIT (drm_encoder_index (&vkms_output->wb_encoder));drm_connector_helper_add (&wb->base, &vkms_wb_conn_helper_funcs);
Signature · 3 lines
Louis Chauvet, Bootlin Embedded Linux and Kernel engineering https://bootlin.com
Quoted 41 lines · Louis Chauvet
Le 03/07/2025 à 11:03, Robert Mader a écrit :
Quoted 38 lines
Since commit
41b4b11da0215("drm: Add valid clones check") setting thepossible_clonesvalues is a hard requirement for cloning.vkmssupports cloning for writeback connectors in order to capture CRTC content, however that broke with said commit.Writeback connectors are created on a per-CRTC basis, thus mark every non-writeback connector that is compatible with a given CRTC as possible clone - and vice-versa.
Using a default configuration, the corresponding
drm_infooutput changes from:├───Encoders │ ├───Encoder 0 │ │ ├───Object ID: 40 │ │ ├───Type: virtual │ │ ├───CRTCS: {0} │ │ └───Clones: {0} │ └───Encoder 1 │ ├───Object ID: 41 │ ├───Type: virtual │ ├───CRTCS: {0} │ └───Clones: {1}to:
├───Encoders │ ├───Encoder 0 │ │ ├───Object ID: 44 │ │ ├───Type: virtual │ │ ├───CRTCS: {0} │ │ └───Clones: {0, 1} │ └───Encoder 1 │ ├───Object ID: 50 │ ├───Type: virtual │ ├───CRTCS: {0} │ └───Clones: {0, 1}
Quoted 5 lines
Quoted 1 line
Signed-off-by Robert Mader <[email protected]>Hi,
About the Fixes tag, I think you can add it anyway, if the patch is not applicable on previous kernel version, this is not an issue, it will just be ignored.
Alright, added
in v2.
Quoted 21 lines
Quoted 21 lines
---
drivers/gpu/drm/vkms/vkms_output.c | 12 ++++++++++++drivers/gpu/drm/vkms/vkms_writeback.c| 2 ++2 files changed, 14 insertions(+)drivers/gpu/drm/vkms/vkms_output.c +1
-0@@ -77,9 +77,21 @@ int vkms_output_init(struct vkms_device *vkmsdev) return ret; } + encoder_cfg->encoder->possible_clones |= BIT(drm_encoder_index(encoder_cfg->encoder)); + vkms_config_encoder_for_each_possible_crtc(encoder_cfg, idx, possible_crtc) {
encoder_cfg->encoder->possible_crtcs|=drm_crtc_mask(&possible_crtc->crtc->crtc);
+
+ if (vkms_config_crtc_get_writeback(possible_crtc)) { + structdrm_encoder*wb_encoder=
Quoted 8 lines
Quoted 6 lines
+
&possible_crtc->crtc->wb_encoder; +
+encoder_cfg->encoder->possible_clones|= + BIT(drm_encoder_index(wb_encoder)); +wb_encoder->possible_clones|=
+ BIT(drm_encoder_index(encoder_cfg->encoder));Can you use
drm_encoder_maskdirectly?
Much better, done for all places in v2.
Quoted 3 lines
Thanks a lot for this patch,
Louis Chauvet
Thanks for the feedback!
Quoted 17 lines
Quoted 16 lines
+ }
}
}
diff --gita/drivers/gpu/drm/vkms/vkms_writeback.cb/drivers/gpu/drm/vkms/vkms_writeback.cindexfe163271d5b5..12b60fb97c68100644drivers/gpu/drm/vkms/vkms_writeback.c +2
-0@@ -174,6 +174,8 @@ int vkms_enable_writeback_connector(structvkms_device *vkmsdev, if (ret) return ret; vkms_output->wb_encoder.possible_crtcs |= drm_crtc_mask(&vkms_output->crtc); + vkms_output->wb_encoder.possible_clones |= +BIT (drm_encoder_index (&vkms_output->wb_encoder)); drm_connector_helper_add(&wb->base, &vkms_wb_conn_helper_funcs);
Signature · 6 lines
Robert Mader Consultant Software Developer Collabora Ltd. Platinum Building, St John's Innovation Park, Cambridge CB4 0DS, UK Registered in England & Wales, no. 5513718