Add support for 'power saving policy' property
Subsystems (4)
v5 cover Add support for 'power saving policy' property
From: Mario Limonciello <[email protected]>
During the Display Next hackfest 2024 one of the topics discussed was the need for compositor to be able to relay intention to drivers that color fidelity is preferred over power savings.
To accomplish this a new optional DRM property is being introduced called "power saving policy". This property is a bit mask that can be configured with requests of "Require color accuracy" or "Require low latency" that can be configured by the compositor.
When a driver advertises support for this property and the compositor sets it to "Require color accuracy" then the driver will disable any power saving features that can compromise color fidelity.
In practice the main feature this currently applies to is the "Adaptive Backlight Modulation" feature within AMD DCN on eDP panels.
When the compositor has marked the property "Require color accuracy" then this feature will be disabled and any userspace that tries to turn it on will get an -EBUSY return code.
Compositors can also request that low latency is critical which in practice should cause PSR and PSR2 to be disabled.
When the compositor has restored the value back to no requirements then the previous value that would have been programmed will be restored.
This was previously accepted at version 4 but reverted because userspace didn't have a matching implementation.
One was now created for KDE:
* https://invent.kde.org/plasma/kwin/-/merge_requests/6028
There was also a bug reported that Xorg crashed with this change. It's fixed by this PR:
* https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/merge_requests/102
Mario Limonciello (2):
drm: Introduce 'power saving policy' drm property drm/amd: Add power_saving_policy drm property to eDP connectors
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 52 +++++++++++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++ include/drm/drm_connector.h | 2 + include/drm/drm_mode_config.h | 5 ++ include/uapi/drm/drm_mode.h | 9 ++++ 7 files changed, 118 insertions(+), 5 deletions(-)
Signature · 1 line
2.43.0
PATCH v5 1/2 drm: Introduce 'power saving policy' drm property
From: Mario Limonciello <[email protected]>
The power saving policy DRM property is an optional property that can be added to a connector by a driver.
This property is for compositors to indicate intent of policy of whether a driver can use power saving features that may compromise the experience intended by the compositor.
---
v5:
* Add None to the bitmask
--- drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++++++++++++++++++ include/drm/drm_connector.h | 2 ++ include/drm/drm_mode_config.h | 5 ++++ include/uapi/drm/drm_mode.h | 9 ++++++ 4 files changed, 65 insertions(+)
drivers/gpu/drm/drm_connector.c +49 -0
@@ -1170,6 +1170,12 @@ static const struct drm_prop_enum_list drm_scaling_mode_enum_list[] = { { DRM_MODE_SCALE_ASPECT, "Full aspect" }, }; +static const struct drm_prop_enum_list drm_power_saving_policy_enum_list[] = { + {__builtin_ffs (DRM_MODE_REQUIRE_NONE ) -1 ,"None" }, + {__builtin_ffs (DRM_MODE_REQUIRE_COLOR_ACCURACY ) -1 ,"Require color accuracy" }, + {__builtin_ffs (DRM_MODE_REQUIRE_LOW_LATENCY ) -1 ,"Require low latency" }, +}; +static const struct drm_prop_enum_list drm_aspect_ratio_enum_list[] = { {DRM_MODE_PICTURE_ASPECT_NONE ,"Automatic" }, { DRM_MODE_PICTURE_ASPECT_4_3, "4:3" },
@@ -1760,6 +1766,16 @@ EXPORT_SYMBOL(drm_hdmi_connector_get_output_format_name);* * Drivers can set up these properties by calling * drm_mode_create_tv_margin_properties(). +* power saving policy: +* This property is used to set the power saving policy for the connector. +* This property is populated with a bitmask of optional requirements set +* by the drm master for the drm driver to respect: +* - "Require color accuracy": Disable power saving features that will +* affect color fidelity. +* For example: Hardware assisted backlight modulation. +* - "Require low latency": Disable power saving features that will +* affect latency. +* For example: Panel self refresh (PSR) */ int drm_connector_create_standard_properties (struct drm_device *dev)
@@ -2262,6 +2278,39 @@ int drm_mode_create_scaling_mode_property(struct drm_device *dev) }EXPORT_SYMBOL (drm_mode_create_scaling_mode_property); +/** +* drm_mode_create_power_saving_policy_property - create power saving policy property +* @dev: DRM device +* @supported_policies: bitmask of supported power saving policies +* +* Called by a driver the first time it's needed, must be attached to desired +* connectors. +* +* Returns: %0 +*/ +int drm_mode_create_power_saving_policy_property (struct drm_device *dev, +uint64_t supported_policies) +{ +struct drm_property *power_saving; + +if (dev->mode_config.power_saving_policy) +return 0 ; +WARN_ON ((supported_policies &DRM_MODE_POWER_SAVING_POLICY_ALL ) ==0 ); + + power_saving = +drm_property_create_bitmask (dev,0 ,"power saving policy" , + drm_power_saving_policy_enum_list, +ARRAY_SIZE (drm_power_saving_policy_enum_list), + supported_policies); +if (!power_saving) +return -ENOMEM ; + + dev->mode_config.power_saving_policy = power_saving; + +return 0 ; +} +EXPORT_SYMBOL (drm_mode_create_power_saving_policy_property); +/** * DOC: Variable refresh properties *
include/drm/drm_connector.h +2 -0
@@ -2408,6 +2408,8 @@ int drm_mode_create_dp_colorspace_property(struct drm_connector *connector, u32 supported_colorspaces);int drm_mode_create_content_type_property (struct drm_device *dev);int drm_mode_create_suggested_offset_properties (struct drm_device *dev); +int drm_mode_create_power_saving_policy_property (struct drm_device *dev, +uint64_t supported_policies);int drm_connector_set_path_property (struct drm_connector *connector,const char *path);
include/drm/drm_mode_config.h +5 -0
@@ -959,6 +959,11 @@ struct drm_mode_config {*/ struct drm_atomic_state *suspend_state; +/** +* @power_saving_policy: bitmask for power saving policy requests. +*/ +struct drm_property *power_saving_policy; +const struct drm_mode_config_helper_funcs *helper_private; };
include/uapi/drm/drm_mode.h +9 -0
@@ -152,6 +152,15 @@ extern "C" {#define DRM_MODE_SCALE_CENTER 2/* Centered, no scaling */ #define DRM_MODE_SCALE_ASPECT 3/* Full screen, preserve aspect */ +/* power saving policy options */ +#define DRM_MODE_REQUIRE_NONE BIT(0)/* Compositor doesn't require power saving */ +#define DRM_MODE_REQUIRE_COLOR_ACCURACY BIT(1)/* Compositor requires color accuracy */ +#define DRM_MODE_REQUIRE_LOW_LATENCY BIT(2)/* Compositor requires low latency */ + +#define DRM_MODE_POWER_SAVING_POLICY_ALL (DRM_MODE_REQUIRE_NONE |\ + DRM_MODE_REQUIRE_COLOR_ACCURACY |\ + DRM_MODE_REQUIRE_LOW_LATENCY) +/* Dithering mode options */ #define DRM_MODE_DITHERING_OFF 0#define DRM_MODE_DITHERING_ON 1
Signature · 1 line
2.43.0
PATCH v5 2/2 drm/amd: Add power_saving_policy drm property to eDP connectors
In reply to Mario LimoncielloFrom: Mario Limonciello <[email protected]>
When the power_saving_policy property is set to bit mask "Require color accuracy" ABM should be disabled immediately and any requests by sysfs to update will return an -EBUSY error.
When the power_saving_policy property is set to bit mask "Require low latency" PSR should be disabled.
When the property is restored to an empty bit mask ABM and PSR can be enabled again.
---
v5:
* Adjust for new signature of amdgpu_dm_psr_disable()
* Default to none
--- drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 52 +++++++++++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + 3 files changed, 53 insertions(+), 5 deletions(-)
drivers/gpu/drm/amd/amdgpu/amdgpu_display.c +4 -0
@@ -1409,6 +1409,10 @@ int amdgpu_display_modeset_create_props(struct amdgpu_device *adev)"dither" , amdgpu_dither_enum_list, sz); +if (adev->dc_enabled) +drm_mode_create_power_saving_policy_property (adev_to_drm (adev), +DRM_MODE_POWER_SAVING_POLICY_ALL ); +return 0 ; }
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +47 -5
96 lines not on this page · raw message
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h +2 -0
@@ -968,6 +968,8 @@ struct dm_connector_state {bool underscan_enable;bool freesync_capable;bool update_hdcp; +bool abm_forbidden; +bool psr_forbidden;uint8_t abm_level;int vcpi_slots;uint64_t pbn;
Signature · 1 line
2.43.0
I have some more concerns / different direction I'd like to go with this stuff, let's please hold on it for now and talk about it at the display next hackfest again.
- Xaver
Am Sa., 21. Juni 2025 um 17:27 Uhr schrieb Mario Limonciello <[email protected]>:
Quoted 54 lines
From: Mario Limonciello <[email protected]>
During the Display Next hackfest 2024 one of the topics discussed was the need for compositor to be able to relay intention to drivers that color fidelity is preferred over power savings.
To accomplish this a new optional DRM property is being introduced called "power saving policy". This property is a bit mask that can be configured with requests of "Require color accuracy" or "Require low latency" that can be configured by the compositor.
When a driver advertises support for this property and the compositor sets it to "Require color accuracy" then the driver will disable any power saving features that can compromise color fidelity.
In practice the main feature this currently applies to is the "Adaptive Backlight Modulation" feature within AMD DCN on eDP panels.
When the compositor has marked the property "Require color accuracy" then this feature will be disabled and any userspace that tries to turn it on will get an
-EBUSYreturn code.Compositors can also request that low latency is critical which in practice should cause PSR and PSR2 to be disabled.
When the compositor has restored the value back to no requirements then the previous value that would have been programmed will be restored.
This was previously accepted at version 4 but reverted because userspace didn't have a matching implementation.
One was now created for KDE:
* https://invent.kde.org/plasma/kwin/-/merge_requests/6028There was also a bug reported that Xorg crashed with this change. It's fixed by this PR:
* https://gitlab.freedesktop.org/xorg/driver/xf86-video-amdgpu/-/merge_requests/102Mario Limonciello (2):
drm: Introduce 'power saving policy' drm property drm/amd: Addpower_saving_policydrm property to eDP connectorsdrivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 4 ++ .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 52 +++++++++++++++++-- .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.h | 2 + drivers/gpu/drm/drm_connector.c | 49 +++++++++++++++++ include/drm/drm_connector.h | 2 + include/drm/drm_mode_config.h | 5 ++ include/uapi/drm/drm_mode.h | 9 ++++ 7 files changed, 118 insertions(+), 5 deletions(-)--
2.43.0