Skip to contentSkip to conversation

drm/vkms: Add writeback encoders as possible clones

PATCH Superseded Robert Mader 3 participants 5 messages Jul 3, 2025 – Jul 18, 2025

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

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
index 8d7ca0cdd79f..21935eb88198 100644
@@ -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
index fe163271d5b5..12b60fb97c68 100644
@@ -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
#1 lore raw
Quoted 11 lines · Robert Mader

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:

It feels like the current possible_clones is incorrect according to the documentation. Should there be a Fixes tag?

Quoted 8 lines
---
 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
#2 lore raw

Thanks for the feedback!

Quoted 6 lines · Dmitry Baryshkov
Quoted 5 lines · Robert Mader

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.

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_info output changes from:

It feels like the current possible_clones is 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
---
  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
maintainer
#3 lore raw
In reply to Robert Mader

Le 03/07/2025 à 11:03, Robert Mader a écrit :

Quoted 38 lines

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}
Quoted 1 line

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
index 8d7ca0cdd79f..21935eb88198 100644
@@ -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 -0
  				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));

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
index fe163271d5b5..12b60fb97c68 100644
@@ -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
#4 lore raw
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 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}
Quoted 5 lines
Quoted 1 line

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

Fixes dbd9d80c1b2e (drm/vkms: Add support for writeback)

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
index 8d7ca0cdd79f..21935eb88198 100644
@@ -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 =

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_mask directly?

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 --git a/drivers/gpu/drm/vkms/vkms_writeback.c b/drivers/gpu/drm/vkms/vkms_writeback.c index fe163271d5b5..12b60fb97c68 100644

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 · 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