Skip to contentSkip to conversation

drm/amd: Drop abm_level property

PATCH In review Mario Limonciello 4 participants 9 messages Feb 16, 2024 – Mar 6, 2024

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd: Drop abm_level property

This vendor specific property has never been used by userspace software and conflicts with the panel_power_savings sysfs file. That is a compositor and user could fight over the same data.

Fixes f97e4303da16 ("drm/amd/display: add panel_power_savings sysfs entry to eDP connectors")

--
Cc: Hamza Mahfooz <[email protected]>
Cc: Sun peng (Leo) Li <[email protected]>

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       |  8 --------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h          |  2 --
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 --------------
 3 files changed, 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -8
index b8fbe97efe1d..3ecc7ef95172 100644
@@ -1350,14 +1350,6 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
 					 "dither",
 					 amdgpu_dither_enum_list, sz);
 
-	if (adev->dc_enabled) {
-		adev->mode_info.abm_level_property =
-			drm_property_create_range(adev_to_drm(adev), 0,
-						  "abm level", 0, 4);
-		if (!adev->mode_info.abm_level_property)
-			return -ENOMEM;
-	}
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -2
index 2e4911050cc5..1fe21a70ddd0 100644
@@ -324,8 +324,6 @@ struct amdgpu_mode_info {
 	struct drm_property *audio_property;
 	/* FMT dithering */
 	struct drm_property *dither_property;
-	/* Adaptive Backlight Modulation (power feature) */
-	struct drm_property *abm_level_property;
 	/* hardcoded DFP edid from BIOS */
 	struct edid *bios_hardcoded_edid;
 	int bios_hardcoded_edid_size;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -14
index b9ac3d2f8029..e3b32ffba85a 100644
@@ -6388,9 +6388,6 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		dm_new_state->underscan_enable = val;
 		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		dm_new_state->abm_level = val ?: ABM_LEVEL_IMMEDIATE_DISABLE;
-		ret = 0;
 	}
 
 	return ret;
@@ -6433,10 +6430,6 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		*val = dm_state->underscan_enable;
 		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		*val = (dm_state->abm_level != ABM_LEVEL_IMMEDIATE_DISABLE) ?
-			dm_state->abm_level : 0;
-		ret = 0;
 	}
 
 	return ret;
@@ -7652,13 +7645,6 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 	aconnector->base.state->max_bpc = 16;
 	aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc;
 
-	if (connector_type == DRM_MODE_CONNECTOR_eDP &&
-	    (dc_is_dmcu_initialized(adev->dm.dc) ||
-	     adev->dm.dc->ctx->dmub_srv) && amdgpu_dm_abm_level < 0) {
-		drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.abm_level_property, 0);
-	}
-
 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
 		/* Content Type is currently only implemented for HDMI. */
 		drm_connector_attach_content_type_property(&aconnector->base);
Signature · 1 line
2.34.1
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Mario Limonciello

This vendor specific property has never been used by userspace software and conflicts with the panel_power_savings sysfs file. That is a compositor and user could fight over the same data.

Fixes f97e4303da16 ("drm/amd/display: add panel_power_savings sysfs entry to eDP connectors")

--
Cc: Hamza Mahfooz <[email protected]>
Cc: Sun peng (Leo) Li <[email protected]>

Harry

Quoted 77 lines
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       |  8 --------
 drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h          |  2 --
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 --------------
 3 files changed, 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -8
index b8fbe97efe1d..3ecc7ef95172 100644
@@ -1350,14 +1350,6 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
 					 "dither",
 					 amdgpu_dither_enum_list, sz);
 
-	if (adev->dc_enabled) {
-		adev->mode_info.abm_level_property =
-			drm_property_create_range(adev_to_drm(adev), 0,
-						  "abm level", 0, 4);
-		if (!adev->mode_info.abm_level_property)
-			return -ENOMEM;
-	}
-
 	return 0;
 }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -2
index 2e4911050cc5..1fe21a70ddd0 100644
@@ -324,8 +324,6 @@ struct amdgpu_mode_info {
 	struct drm_property *audio_property;
 	/* FMT dithering */
 	struct drm_property *dither_property;
-	/* Adaptive Backlight Modulation (power feature) */
-	struct drm_property *abm_level_property;
 	/* hardcoded DFP edid from BIOS */
 	struct edid *bios_hardcoded_edid;
 	int bios_hardcoded_edid_size;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -14
index b9ac3d2f8029..e3b32ffba85a 100644
@@ -6388,9 +6388,6 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		dm_new_state->underscan_enable = val;
 		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		dm_new_state->abm_level = val ?: ABM_LEVEL_IMMEDIATE_DISABLE;
-		ret = 0;
 	}
 
 	return ret;
@@ -6433,10 +6430,6 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
 	} else if (property == adev->mode_info.underscan_property) {
 		*val = dm_state->underscan_enable;
 		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		*val = (dm_state->abm_level != ABM_LEVEL_IMMEDIATE_DISABLE) ?
-			dm_state->abm_level : 0;
-		ret = 0;
 	}
 
 	return ret;
@@ -7652,13 +7645,6 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
 	aconnector->base.state->max_bpc = 16;
 	aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc;
 
-	if (connector_type == DRM_MODE_CONNECTOR_eDP &&
-	    (dc_is_dmcu_initialized(adev->dm.dc) ||
-	     adev->dm.dc->ctx->dmub_srv) && amdgpu_dm_abm_level < 0) {
-		drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.abm_level_property, 0);
-	}
-
 	if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
 		/* Content Type is currently only implemented for HDMI. */
 		drm_connector_attach_content_type_property(&aconnector->base);
Acked-by on v1 1/1
#2 lore raw
In reply to Mario Limonciello

Am 16.02.24 um 16:33 schrieb Mario Limonciello:

Quoted 7 lines

This vendor specific property has never been used by userspace software and conflicts with the panel_power_savings sysfs file. That is a compositor and user could fight over the same data.

Fixes f97e4303da16 ("drm/amd/display: add panel_power_savings sysfs entry to eDP connectors")
Quoted 80 lines

--
Cc: Hamza Mahfooz <[email protected]>
Cc: Sun peng (Leo) Li <[email protected]>

---
  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c       |  8 --------
  drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h          |  2 --
  drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 14 --------------
  3 files changed, 24 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +0 -8
index b8fbe97efe1d..3ecc7ef95172 100644
@@ -1350,14 +1350,6 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)
  					 "dither",
  					 amdgpu_dither_enum_list, sz);
 
-	if (adev->dc_enabled) {
-		adev->mode_info.abm_level_property =
-			drm_property_create_range(adev_to_drm(adev), 0,
-						  "abm level", 0, 4);
-		if (!adev->mode_info.abm_level_property)
-			return -ENOMEM;
-	}
-
  	return 0;
  }
 
drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h +0 -2
index 2e4911050cc5..1fe21a70ddd0 100644
@@ -324,8 +324,6 @@ struct amdgpu_mode_info {
  	struct drm_property *audio_property;
  	/* FMT dithering */
  	struct drm_property *dither_property;
-	/* Adaptive Backlight Modulation (power feature) */
-	struct drm_property *abm_level_property;
  	/* hardcoded DFP edid from BIOS */
  	struct edid *bios_hardcoded_edid;
  	int bios_hardcoded_edid_size;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -14
index b9ac3d2f8029..e3b32ffba85a 100644
@@ -6388,9 +6388,6 @@ int amdgpu_dm_connector_atomic_set_property(struct drm_connector *connector,
  	} else if (property == adev->mode_info.underscan_property) {
  		dm_new_state->underscan_enable = val;
  		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		dm_new_state->abm_level = val ?: ABM_LEVEL_IMMEDIATE_DISABLE;
-		ret = 0;
  	}
 
  	return ret;
@@ -6433,10 +6430,6 @@ int amdgpu_dm_connector_atomic_get_property(struct drm_connector *connector,
  	} else if (property == adev->mode_info.underscan_property) {
  		*val = dm_state->underscan_enable;
  		ret = 0;
-	} else if (property == adev->mode_info.abm_level_property) {
-		*val = (dm_state->abm_level != ABM_LEVEL_IMMEDIATE_DISABLE) ?
-			dm_state->abm_level : 0;
-		ret = 0;
  	}
 
  	return ret;
@@ -7652,13 +7645,6 @@ void amdgpu_dm_connector_init_helper(struct amdgpu_display_manager *dm,
  	aconnector->base.state->max_bpc = 16;
  	aconnector->base.state->max_requested_bpc = aconnector->base.state->max_bpc;
 
-	if (connector_type == DRM_MODE_CONNECTOR_eDP &&
-	    (dc_is_dmcu_initialized(adev->dm.dc) ||
-	     adev->dm.dc->ctx->dmub_srv) && amdgpu_dm_abm_level < 0) {
-		drm_object_attach_property(&aconnector->base.base,
-				adev->mode_info.abm_level_property, 0);
-	}
-
  	if (connector_type == DRM_MODE_CONNECTOR_HDMIA) {
  		/* Content Type is currently only implemented for HDMI. */
  		drm_connector_attach_content_type_property(&aconnector->base);
#3 lore raw
In reply to Mario Limonciello

Like already mentioned in the power profiles daemon repository, I don't think this makes sense. This is a display setting, which compositors have interest in controlling, for example to:
- disable it in a bright environment, because afaiu it reduces the maximum screen brightness
- disable it when it shows color critical content
- disable it while profiling the display
- enable it when it shows content that's definitely not color critical (based on the content-type property of Wayland surfaces)
- enable it as a first step before properly dimming the screen on idle

If the primary concern here is that this hasn't been used by compositors and potential power savings aren't being realized, that could be solved by providing documentation about what the feature does in the kernel, and by sending a mail to wayland-devel describing why it should be used.

If the goal is to implement it in power profiles daemon and not get conflicts, I think disabling the property by default and instead enable it + disable the sysfs file when a CAP for it is set would make more sense than making the listed features impossible.

#4 lore raw
Quoted 11 lines · Xaver Hugl

Like already mentioned in the power profiles daemon repository, I don't think this makes sense. This is a display setting, which compositors have interest in controlling, for example to:
- disable it in a bright environment, because afaiu it reduces the maximum screen brightness
- disable it when it shows color critical content
- disable it while profiling the display
- enable it when it shows content that's definitely not color critical (based on the content-type property of Wayland surfaces)
- enable it as a first step before properly dimming the screen on idle

This specific topic is on the agenda to discuss at 2024 Display Next Hackfest.

Quoted 11 lines

If the primary concern here is that this hasn't been used by compositors and potential power savings aren't being realized, that could be solved by providing documentation about what the feature does in the kernel, and by sending a mail to wayland-devel describing why it should be used.

If the goal is to implement it in power profiles daemon and not get conflicts, I think disabling the property by default and instead enable it + disable the sysfs file when a CAP for it is set would make more sense than making the listed features impossible.

So the idea being if the compositor isn't using it we let power-profiles-daemon (or any other software) take control via sysfs and if the compositor does want to control it then it then it writes a DRM cap and we destroy the sysfs file?

#5 lore raw

Am Mi., 6. März 2024 um 18:19 Uhr schrieb Mario Limonciello <[email protected]>:

Quoted 4 lines

So the idea being if the compositor isn't using it we let power-profiles-daemon (or any other software) take control via sysfs and if the compositor does want to control it then it then it writes a DRM cap and we destroy the sysfs file?

Yes. That way still only one party controls it at a given time, and we can get both good default behavior for display servers that don't care (like Xorg or compositors without color management support), and compositors that want to put in the effort can do more specific things with it.

#6 lore raw
Quoted 7 lines · Xaver Hugl

Am Mi., 6. März 2024 um 18:19 Uhr schrieb Mario Limonciello <[email protected]>:

Quoted 4 lines

So the idea being if the compositor isn't using it we let power-profiles-daemon (or any other software) take control via sysfs and if the compositor does want to control it then it then it writes a DRM cap and we destroy the sysfs file?

Quoted 5 lines

Yes. That way still only one party controls it at a given time, and we can get both good default behavior for display servers that don't care (like Xorg or compositors without color management support), and compositors that want to put in the effort can do more specific things with it.

I think that's a very good solution.

Harry, Hamza, what do you guys think?

maintainer
#7 lore raw
Quoted 14 lines · Mario Limonciello
Quoted 7 lines · Xaver Hugl

Am Mi., 6. März 2024 um 18:19 Uhr schrieb Mario Limonciello <[email protected]>:

Quoted 4 lines

So the idea being if the compositor isn't using it we let power-profiles-daemon (or any other software) take control via sysfs and if the compositor does want to control it then it then it writes a DRM cap and we destroy the sysfs file?

Quoted 5 lines

Yes. That way still only one party controls it at a given time, and we can get both good default behavior for display servers that don't care (like Xorg or compositors without color management support), and compositors that want to put in the effort can do more specific things with it.

Quoted 3 lines

I think that's a very good solution.

Harry, Hamza, what do you guys think?

In theory I like it. But how will this look in practice? Is PPD or compositor on the scene first? Would it be possible to yank the sysfs away from PPD?

DRM client caps are set by the client when the client interacts with DRM. At driver creation there is no client. How will the driver set things up?

A user might switch between DRM clients (login manager, to desktop compositor, maybe to another VT with a different compositor). I know everything but the login manager to desktop compositor hand-off is today considered exotic, but what if someone starts building a use-case for it? I've done a bunch of gamescope or IGT work in a different VT while I've had Plasma running on its default VT.

If someone can sketch this out, with answers to all the questions above and any other questions you can come up (be creative), I'd be happy to review. Alternatively we can discuss this at the hackfest and maybe arrive at a solution.

Harry

#8 lore raw
Quoted 17 lines · Harry Wentland
Quoted 14 lines · Mario Limonciello
Quoted 12 lines · Xaver Hugl

Am Mi., 6. März 2024 um 18:19 Uhr schrieb Mario Limonciello <[email protected]>:

Quoted 4 lines

So the idea being if the compositor isn't using it we let power-profiles-daemon (or any other software) take control via sysfs and if the compositor does want to control it then it then it writes a DRM cap and we destroy the sysfs file?

Yes. That way still only one party controls it at a given time, and we can get both good default behavior for display servers that don't care (like Xorg or compositors without color management support), and compositors that want to put in the effort can do more specific things with it.

Quoted 7 lines
Quoted 3 lines

I think that's a very good solution.

Harry, Hamza, what do you guys think?

In theory I like it. But how will this look in practice? Is PPD or compositor on the scene first? Would it be possible to yank the sysfs away from PPD?

I double checked the existing PPD code to see how well this case maps out.

* If the compositor shows up first then PPD just wouldn't find amdgpu support when it probed.
* If PPD goes first and then the compositor I expect right now that PPD wouldn't explode. All the cases that would update it check that the file exists before trying to write it.

I think the only risk is TOCTOU for that check relative to when it would write the file, but the worst case is you have an error in the journal log that it tried to write the file but it's not present (there is already error handling everywhere for this).

What we can do to smooth it out even more is export a CHANGE uevent from amdgpu when this happens. PPD can react to the change event and totally stop the amdgpu plugin.

Quoted 3 lines

DRM client caps are set by the client when the client interacts with DRM. At driver creation there is no client. How will the driver set things up?

You jog my mind for another idea.

1) We could reintroduce abm_level property.
2) If client connects with the cap set, we make any reads or writes to the sysfs return -EBUSY and we make amdgpu issue a CHANGE uevent.

* Unchanged PPD will likely log a message to the journal that writes fail, but won't explode.
* A changed PPD could react to the uevent and look for -EBUSY to not bother even logging a message to the journal.

Quoted 7 lines

A user might switch between DRM clients (login manager, to desktop compositor, maybe to another VT with a different compositor). I know everything but the login manager to desktop compositor hand-off is today considered exotic, but what if someone starts building a use-case for it? I've done a bunch of gamescope or IGT work in a different VT while I've had Plasma running on its default VT.

If going off the cap of the client to decide whether or not to report -EBUSY to sysfs I think it handles the handoff cleanly.

Quoted 5 lines

If someone can sketch this out, with answers to all the questions above and any other questions you can come up (be creative), I'd be happy to review. Alternatively we can discuss this at the hackfest and maybe arrive at a solution.

Yes; I think we should use this thread as a basis for that discussion.