Skip to contentSkip to conversation

drm/amd/display: Use root connector's colorspace property for MST

PATCH In review Harry Wentland 3 participants 4 messages Jul 13, 2023 – Jul 28, 2023

Subsystems (3)
lore
Share & tools
lore

Harry Wentland

author maintainer
#0 lore raw

PATCH v2 1/1 drm/amd/display: Use root connector's colorspace property for MST

After driver init we shouldn't create new properties. Doing so will lead to a warning storm from __drm_mode_object_add.

We don't really need to create the property for MST connectors. Re-using the mst_root connector's property is fine.

v2: Add curly braces to avoid possibly 'else' confusion

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -2
index 28f8ac6007fb..f6dab6226b29 100644
@@ -7357,8 +7357,14 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 			drm_connector_attach_colorspace_property(&aconnector->base);
 	} else if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
 		   connector_type == DRM_MODE_CONNECTOR_eDP) {
-		if (!drm_mode_create_dp_colorspace_property(&aconnector->base, supported_colorspaces))
-			drm_connector_attach_colorspace_property(&aconnector->base);
+		if (!aconnector->mst_root) {
+			if (!drm_mode_create_dp_colorspace_property(&aconnector->base, supported_colorspaces))
+				drm_connector_attach_colorspace_property(&aconnector->base);
+		} else { /* use root connector's property */
+			if (aconnector->mst_root->base.colorspace_property)
+				drm_connector_attach_colorspace_property(&aconnector->mst_root->base);
+		}
+
 	}
 
 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||
Signature · 1 line
2.41.0
Reviewed-by on v2 1/1
#1 lore raw

[Public]

--

Regards,
Jay
________________________________
From: amd-gfx <[email protected]> on behalf of Harry Wentland <[email protected]>
Sent: Thursday, July 13, 2023 3:58 PM
To: [email protected] <[email protected]>
Cc: Wentland, Harry <[email protected]>
Subject: [PATCH v2] drm/amd/display: Use root connector's colorspace property for MST

After driver init we shouldn't create new properties. Doing so will lead to a warning storm from __drm_mode_object_add.

We don't really need to create the property for MST connectors. Re-using the mst_root connector's property is fine.

v2: Add curly braces to avoid possibly 'else' confusion

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -2
index 28f8ac6007fb..f6dab6226b29 100644
@@ -7357,8 +7357,14 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
                         drm_connector_attach_colorspace_property(&aconnector->base);
         } else if (connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
                    connector_type == DRM_MODE_CONNECTOR_eDP) {
-               if (!drm_mode_create_dp_colorspace_property(&aconnector->base, supported_colorspaces))
-                       drm_connector_attach_colorspace_property(&aconnector->base);
+               if (!aconnector->mst_root) {
+                       if (!drm_mode_create_dp_colorspace_property(&aconnector->base, supported_colorspaces))
+                               drm_connector_attach_colorspace_property(&aconnector->base);
+               } else { /* use root connector's property */
+                       if (aconnector->mst_root->base.colorspace_property)
+                               drm_connector_attach_colorspace_property(&aconnector->mst_root->base);
+               }
+
         }
 
         if (connector_type == DRM_MODE_CONNECTOR_HDMIA ||

--
2.41.0

#2 lore raw
In reply to Harry Wentland
Quoted 7 lines · Harry Wentland

After driver init we shouldn't create new properties. Doing so will lead to a warning storm from __drm_mode_object_add.

We don't really need to create the property for MST connectors. Re-using the mst_root connector's property is fine.

v2: Add curly braces to avoid possibly 'else' confusion

I'm still hitting WARNINGs with this, see attachment.

Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer
WARNING: CPU: 3 PID: 232 at drivers/gpu/drm/drm_mode_object.c:242 drm_object_attach_property+0x6d/0xb0 [drm]
Modules linked in: amdgpu(E+) crc32c_intel(E) i2c_algo_bit(E) drm_ttm_helper(E) ttm(E) drm_suballoc_helper(E) amdxcp(E) drm_buddy(E) gpu_sched(E) drm_display_helper(E) nvme(E) aesni_intel(E) xhci_pci(E) drm_kms_helper(E) nvme_core(E) crypto_simd(E) xhci_hcd(E) psmouse(E) evdev(E) t10_pi(E) cryptd(E) drm(E) serio_raw(E) cec(E) usbcore(E) rc_core(E) usb_common(E) crc64_rocksoft(E) crc64(E) crc_t10dif(E) crct10dif_generic(E) crct10dif_pclmul(E) crct10dif_common(E) video(E) wmi(E)
CPU: 3 PID: 232 Comm: kworker/3:2 Tainted: G            E      6.4.3+ #4
Hardware name: LENOVO 20NF0000GE/20NF0000GE, BIOS R11ET36W (1.16 ) 03/30/2020
Workqueue: events_long drm_dp_mst_link_probe_work [drm_display_helper]
RIP: 0010:drm_object_attach_property+0x6d/0xb0 [drm]
Code: 48 8b 47 08 83 00 01 31 c0 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 e9 2e 0e b8 f6 4d 85 d2 75 c6 83 7f 78 01 75 c0 <0f> 0b eb bc 41 80 78 68 00 74 b5 0f 0b eb b1 44 89 ce 48 c7 c7 00
RSP: 0018:ffffbfbc410bbb80 EFLAGS: 00010246
RAX: 0000000000000011 RBX: ffff9e679998a000 RCX: ffff9e67a1a041b8
RDX: 0000000000000000 RSI: ffff9e684a11a180 RDI: ffff9e67a1a04040
RBP: 000000000000000a R08: ffff9e67a2000010 R09: 00000000c0c0c0c0
R10: 0000000000000000 R11: 0000000000000000 R12: ffff9e679998a040
R13: ffff9e67a2045ca8 R14: ffff9e67a2000010 R15: 0000000000000003
FS:  0000000000000000(0000) GS:ffff9e6a30ac0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f31b4f4a055 CR3: 0000000120eb8000 CR4: 00000000003506e0
Call Trace:
 <TASK>
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? __warn+0x81/0x130
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? report_bug+0x1a2/0x1d0
 ? handle_bug+0x42/0x80
 ? exc_invalid_op+0x17/0x80
 ? asm_exc_invalid_op+0x1a/0x20
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 drm_connector_attach_colorspace_property+0x1b/0x30 [drm]
 amdgpu_dm_connector_init_helper+0x1ed/0x300 [amdgpu]
 dm_dp_add_mst_connector+0xbd/0x1b0 [amdgpu]
 drm_dp_mst_port_add_connector+0x13f/0x1e0 [drm_display_helper]
 drm_dp_send_link_address+0x542/0xaf0 [drm_display_helper]
 ? __slab_free+0xe0/0x330
 ? queue_work_on+0x63/0x70
 drm_dp_check_and_send_link_address+0x7e/0xa0 [drm_display_helper]
 drm_dp_mst_link_probe_work+0x12e/0x1b0 [drm_display_helper]
 process_one_work+0x1c8/0x3c0
 worker_thread+0x51/0x3a0
 ? __pfx_worker_thread+0x10/0x10
 kthread+0xfa/0x130
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x2c/0x50
 </TASK>
---[ end trace 0000000000000000 ]---
------------[ cut here ]------------
WARNING: CPU: 3 PID: 232 at drivers/gpu/drm/drm_mode_object.c:242 drm_object_attach_property+0x6d/0xb0 [drm]
Modules linked in: amdgpu(E+) crc32c_intel(E) i2c_algo_bit(E) drm_ttm_helper(E) ttm(E) drm_suballoc_helper(E) amdxcp(E) drm_buddy(E) gpu_sched(E) drm_display_helper(E) nvme(E) aesni_intel(E) xhci_pci(E) drm_kms_helper(E) nvme_core(E) crypto_simd(E) xhci_hcd(E) psmouse(E) evdev(E) t10_pi(E) cryptd(E) drm(E) serio_raw(E) cec(E) usbcore(E) rc_core(E) usb_common(E) crc64_rocksoft(E) crc64(E) crc_t10dif(E) crct10dif_generic(E) crct10dif_pclmul(E) crct10dif_common(E) video(E) wmi(E)
CPU: 3 PID: 232 Comm: kworker/3:2 Tainted: G        W   E      6.4.3+ #4
Hardware name: LENOVO 20NF0000GE/20NF0000GE, BIOS R11ET36W (1.16 ) 03/30/2020
Workqueue: events_long drm_dp_mst_link_probe_work [drm_display_helper]
RIP: 0010:drm_object_attach_property+0x6d/0xb0 [drm]
Code: 48 8b 47 08 83 00 01 31 c0 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 e9 2e 0e b8 f6 4d 85 d2 75 c6 83 7f 78 01 75 c0 <0f> 0b eb bc 41 80 78 68 00 74 b5 0f 0b eb b1 44 89 ce 48 c7 c7 00
RSP: 0018:ffffbfbc410bbb80 EFLAGS: 00010246
RAX: 0000000000000012 RBX: ffff9e679998e000 RCX: ffff9e67a1a041b8
RDX: 0000000000000000 RSI: ffff9e684a11a180 RDI: ffff9e67a1a04040
RBP: 000000000000000a R08: ffff9e67a2000010 R09: 00000000c0c0c0c0
R10: 0000000000000000 R11: 0000000000000000 R12: ffff9e679998e040
R13: ffff9e67a2045ca8 R14: ffff9e67a2000010 R15: 0000000000000003
FS:  0000000000000000(0000) GS:ffff9e6a30ac0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f31b4f4a055 CR3: 0000000120eb8000 CR4: 00000000003506e0
Call Trace:
 <TASK>
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? __warn+0x81/0x130
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? report_bug+0x1a2/0x1d0
 ? handle_bug+0x42/0x80
 ? exc_invalid_op+0x17/0x80
 ? asm_exc_invalid_op+0x1a/0x20
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 drm_connector_attach_colorspace_property+0x1b/0x30 [drm]
 amdgpu_dm_connector_init_helper+0x1ed/0x300 [amdgpu]
 dm_dp_add_mst_connector+0xbd/0x1b0 [amdgpu]
 drm_dp_mst_port_add_connector+0x13f/0x1e0 [drm_display_helper]
 drm_dp_send_link_address+0x542/0xaf0 [drm_display_helper]
 ? __slab_free+0xe0/0x330
 ? queue_work_on+0x63/0x70
 drm_dp_check_and_send_link_address+0x7e/0xa0 [drm_display_helper]
 drm_dp_mst_link_probe_work+0x12e/0x1b0 [drm_display_helper]
 process_one_work+0x1c8/0x3c0
 worker_thread+0x51/0x3a0
 ? __pfx_worker_thread+0x10/0x10
 kthread+0xfa/0x130
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x2c/0x50
 </TASK>
---[ end trace 0000000000000000 ]---
hid: raw HID events driver (C) Jiri Kosina
------------[ cut here ]------------
WARNING: CPU: 3 PID: 232 at drivers/gpu/drm/drm_mode_object.c:242 drm_object_attach_property+0x6d/0xb0 [drm]
Modules linked in: usbhid(E+) hid(E) amdgpu(E+) crc32c_intel(E) i2c_algo_bit(E) drm_ttm_helper(E) ttm(E) drm_suballoc_helper(E) amdxcp(E) drm_buddy(E) gpu_sched(E) drm_display_helper(E) nvme(E) aesni_intel(E) xhci_pci(E) drm_kms_helper(E) nvme_core(E) crypto_simd(E) xhci_hcd(E) psmouse(E) evdev(E) t10_pi(E) cryptd(E) drm(E) serio_raw(E) cec(E) usbcore(E) rc_core(E) usb_common(E) crc64_rocksoft(E) crc64(E) crc_t10dif(E) crct10dif_generic(E) crct10dif_pclmul(E) crct10dif_common(E) video(E) wmi(E)
CPU: 3 PID: 232 Comm: kworker/3:2 Tainted: G        W   E      6.4.3+ #4
Hardware name: LENOVO 20NF0000GE/20NF0000GE, BIOS R11ET36W (1.16 ) 03/30/2020
Workqueue: events_long drm_dp_mst_link_probe_work [drm_display_helper]
RIP: 0010:drm_object_attach_property+0x6d/0xb0 [drm]
Code: 48 8b 47 08 83 00 01 31 c0 31 d2 31 c9 31 f6 31 ff 45 31 c0 45 31 c9 45 31 d2 e9 2e 0e b8 f6 4d 85 d2 75 c6 83 7f 78 01 75 c0 <0f> 0b eb bc 41 80 78 68 00 74 b5 0f 0b eb b1 44 89 ce 48 c7 c7 00
RSP: 0018:ffffbfbc410bbb80 EFLAGS: 00010246
RAX: 0000000000000013 RBX: ffff9e6799988000 RCX: ffff9e67a1a041b8
RDX: 0000000000000000 RSI: ffff9e684a11a180 RDI: ffff9e67a1a04040
RBP: 000000000000000a R08: ffff9e67a2000010 R09: 00000000c0c0c0c0
R10: 0000000000000000 R11: 0000000000000000 R12: ffff9e6799988040
R13: ffff9e67a2045ca8 R14: ffff9e67a2000010 R15: 0000000000000003
FS:  0000000000000000(0000) GS:ffff9e6a30ac0000(0000) knlGS:0000000000000000
CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
CR2: 00007f31b4f4a055 CR3: 0000000120eb8000 CR4: 00000000003506e0
Call Trace:
 <TASK>
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? __warn+0x81/0x130
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 ? report_bug+0x1a2/0x1d0
 ? handle_bug+0x42/0x80
 ? exc_invalid_op+0x17/0x80
 ? asm_exc_invalid_op+0x1a/0x20
 ? drm_object_attach_property+0x6d/0xb0 [drm]
 drm_connector_attach_colorspace_property+0x1b/0x30 [drm]
 amdgpu_dm_connector_init_helper+0x1ed/0x300 [amdgpu]
 dm_dp_add_mst_connector+0xbd/0x1b0 [amdgpu]
 drm_dp_mst_port_add_connector+0x13f/0x1e0 [drm_display_helper]
 drm_dp_send_link_address+0x542/0xaf0 [drm_display_helper]
 ? __slab_free+0xe0/0x330
 ? queue_work_on+0x63/0x70
 drm_dp_check_and_send_link_address+0x7e/0xa0 [drm_display_helper]
 drm_dp_mst_link_probe_work+0x12e/0x1b0 [drm_display_helper]
 process_one_work+0x1c8/0x3c0
 worker_thread+0x51/0x3a0
 ? __pfx_worker_thread+0x10/0x10
 kthread+0xfa/0x130
 ? __pfx_kthread+0x10/0x10
 ret_from_fork+0x2c/0x50
 </TASK>
#3 lore raw
Quoted 10 lines · Michel Dänzer
Quoted 7 lines · Harry Wentland

After driver init we shouldn't create new properties. Doing so will lead to a warning storm from __drm_mode_object_add.

We don't really need to create the property for MST connectors. Re-using the mst_root connector's property is fine.

v2: Add curly braces to avoid possibly 'else' confusion

I'm still hitting WARNINGs with this, see attachment.

It's because drm_connector_attach_colorspace_property tries attaching the property to the MST root connector again, instead of to the newly created MST connector.

I tried the attached patch on top and didn't get any WARNINGs, but for some reason the MST connector for my external monitor never showed up to user space. Not sure what's going on there.

Signature · 2 lines
Earthling Michel Dänzer            |                  https://redhat.com
Libre software enthusiast          |         Mesa and Xwayland developer

From 18edb92dddb67e234fe7002ae7d0fb8bfd74642f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Michel=20D=C3=A4nzer?= <[email protected]>
Date: Fri, 28 Jul 2023 12:23:13 +0200
Subject: [PATCH] drm/amd/display: Fix attaching root colorspace property to
MST connector
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

drm_connector_attach_colorspace_property tried attaching the property to the mst_root connector again, which hit a WARNING in drm_object_attach_property.

Fix this by calling drm_object_attach_property directly with appropriate parameters.

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -2
index df30204a2a1a..447576fb7420 100644
@@ -7302,8 +7302,11 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 			if (!drm_mode_create_dp_colorspace_property(&aconnector->base, supported_colorspaces))
 				drm_connector_attach_colorspace_property(&aconnector->base);
 		} else { /* use root connector's property */
-			if (aconnector->mst_root->base.colorspace_property)
-				drm_connector_attach_colorspace_property(&aconnector->mst_root->base);
+			if (aconnector->mst_root->base.colorspace_property) {
+				drm_object_attach_property(&aconnector->base.base,
+							   aconnector->mst_root->base.colorspace_property,
+							   DRM_MODE_COLORIMETRY_DEFAULT);
+			}
 		}
 
 	}
Signature · 1 line
2.40.1