Skip to contentSkip to conversation

drm/amd/display: add panel_power_savings sysfs entry to eDP connectors

PATCH Superseded Hamza Mahfooz 3 participants 8 messages Jan 26, 2024 – Jan 28, 2024

Subsystems (3)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amd/display: add panel_power_savings sysfs entry to eDP connectors

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>
---
 .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++
 1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +59 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 	return &new_state->base;
 }
 
+static ssize_t panel_power_savings_show(struct device *device,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	ssize_t val;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	val = to_dm_connector_state(connector->state)->abm_level;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	long val;
+	int ret;
+
+	ret = kstrtol(buf, 0, &val);
+
+	if (ret)
+		return ret;
+
+	if (val < 0 || val > 4)
+		return -EINVAL;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	to_dm_connector_state(connector->state)->abm_level = val ?:
+		ABM_LEVEL_IMMEDIATE_DISABLE;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+	&dev_attr_panel_power_savings.attr,
+	NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+	.name = "amdgpu",
+	.attrs = amdgpu_attrs
+};
+
 static int
 amdgpu_dm_connector_late_register(struct drm_connector *connector)
 {
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector)
 		to_amdgpu_dm_connector(connector);
 	int r;
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+		r = sysfs_create_group(&connector->kdev->kobj,
+				       &amdgpu_group);
+		if (r)
+			return r;
+	}
+
 	amdgpu_dm_register_backlight_device(amdgpu_dm_connector);
 
 	if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
Signature · 1 line
2.43.0
#1 lore raw
Quoted 49 lines · Hamza Mahfooz

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>
---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++
  1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +30 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
  	return &new_state->base;
  }
 
+static ssize_t panel_power_savings_show(struct device *device,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	ssize_t val;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	val = to_dm_connector_state(connector->state)->abm_level;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	long val;
+	int ret;
+
+	ret = kstrtol(buf, 0, &val);
+
+	if (ret)
+		return ret;
+
+	if (val < 0 || val > 4)

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector) · line 6576

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +10 -0
+		return -EINVAL;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	to_dm_connector_state(connector->state)->abm_level = val ?:
+		ABM_LEVEL_IMMEDIATE_DISABLE;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return count;
+}
+

To make this more discoverable I think you want some kerneldoc.

Quoted 16 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +12 -0
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+	&dev_attr_panel_power_savings.attr,
+	NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+	.name = "amdgpu",
+	.attrs = amdgpu_attrs
+};
+
  static int
  amdgpu_dm_connector_late_register(struct drm_connector *connector)
  {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_late_register(struct drm_connector *connector) · line 6602

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector)
  		to_amdgpu_dm_connector(connector);
  	int r;
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+		r = sysfs_create_group(&connector->kdev->kobj,
+				       &amdgpu_group);
+		if (r)
+			return r;
+	}
+

I think there should be some matching code sysfs_remove_group(), maybe in early_unregister() callback.

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
  	amdgpu_dm_register_backlight_device(amdgpu_dm_connector);
 
  	if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
#2 lore raw
Quoted 25 lines · Mario Limonciello
Quoted 24 lines · Hamza Mahfooz

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>

---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++

  1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +5 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ 
 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
       return &new_state->base;
   }
+static ssize_t panel_power_savings_show(struct device *device,
+                    struct device_attribute *attr,
+                    char *buf)
+{
+    struct drm_connector *connector = dev_get_drvdata(device);
Quoted 8 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector) · line 6549

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+    struct drm_device *dev = connector->dev;
+    ssize_t val;
+
+    drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+    val = to_dm_connector_state(connector->state)->abm_level;
+    drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+    return sysfs_emit(buf, "%lu\n", val);

When the system is first booted up with nothing on the kernel command line, this emits the value for ABM_LEVEL_IMMEDIATE_DISABLE, which isn't something we normally should be showing to people.

I think you should be special casing it similar to how the store special case works.

Quoted 16 lines
Quoted 16 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +16 -0
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+                     struct device_attribute *attr,
+                     const char *buf, size_t count)
+{
+    struct drm_connector *connector = dev_get_drvdata(device);
+    struct drm_device *dev = connector->dev;
+    long val;
+    int ret;
+
+    ret = kstrtol(buf, 0, &val);
+
+    if (ret)
+        return ret;
+
Quoted 8 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector) · line 6573

Quoted 8 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +8 -0
+    if (val < 0 || val > 4)
+        return -EINVAL;
+
+    drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+    to_dm_connector_state(connector->state)->abm_level = val ?:
+        ABM_LEVEL_IMMEDIATE_DISABLE;
+    drm_modeset_unlock(&dev->mode_config.connection_mutex);
+

It appears that the ABM doesn't actually take effect by writing this value until the next modeset. This is also reported by Dominik Förderer. I suggested he try to change resolutions in his DE and that activated ABM.

So I think it's missing another call to flush out to the hardware.

Quoted 38 lines

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector) · line 6576

Quoted 3 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +3 -0
+    return count;
+}
+

To make this more discoverable I think you want some kerneldoc.

Quoted 16 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +12 -0
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+    &dev_attr_panel_power_savings.attr,
+    NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+    .name = "amdgpu",
+    .attrs = amdgpu_attrs
+};
+

  static int
  amdgpu_dm_connector_late_register(struct drm_connector *connector) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c amdgpu_dm_connector_late_register(struct · line 6602

Quoted 10 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct 
 drm_connector *connector)
           to_amdgpu_dm_connector(connector);
       int r;
+    if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+        r = sysfs_create_group(&connector->kdev->kobj,
+                       &amdgpu_group);
+        if (r)
+            return r;
+    }
+

I think there should be some matching code sysfs_remove_group(), maybe in early_unregister() callback.

Quoted 2 lines
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
       amdgpu_dm_register_backlight_device(amdgpu_dm_connector);

      if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||

#3 lore raw
In reply to Hamza Mahfooz

I've applied the patch to 6.7.2. The device then shows up under:

|/sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings|
|||(on Framework Laptop 13 amd 7840U with 780M).|
||

After a few tests i can say that at least in my system it’s not working. Setting a value between 0 and 4 in /sys/.../panel_power_savings changes nothing in the panel behavior. There are no errors in kernel log.

Setting an abmlevel via kernel option still works as intended.

||An other investigation is, that when setting abmlevel=0 via kernel option the value shown in /sys/.../panel_power_savings is 255 instead of 0. For abmleve values 1 to 4 set via kernel option the values shown in /sys/.../panel_power_savings are the same.

||

Am 26.01.24 um 23:22 schrieb Hamza Mahfooz:

Quoted 88 lines

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>
---
  .../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++
  1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +59 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
  	return &new_state->base;
  }
 
+static ssize_t panel_power_savings_show(struct device *device,
+					struct device_attribute *attr,
+					char *buf)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	ssize_t val;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	val = to_dm_connector_state(connector->state)->abm_level;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+					 struct device_attribute *attr,
+					 const char *buf, size_t count)
+{
+	struct drm_connector *connector = dev_get_drvdata(device);
+	struct drm_device *dev = connector->dev;
+	long val;
+	int ret;
+
+	ret = kstrtol(buf, 0, &val);
+
+	if (ret)
+		return ret;
+
+	if (val < 0 || val > 4)
+		return -EINVAL;
+
+	drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+	to_dm_connector_state(connector->state)->abm_level = val ?:
+		ABM_LEVEL_IMMEDIATE_DISABLE;
+	drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+	return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+	&dev_attr_panel_power_savings.attr,
+	NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+	.name = "amdgpu",
+	.attrs = amdgpu_attrs
+};
+
  static int
  amdgpu_dm_connector_late_register(struct drm_connector *connector)
  {
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct drm_connector *connector)
  		to_amdgpu_dm_connector(connector);
  	int r;
 
+	if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+		r = sysfs_create_group(&connector->kdev->kobj,
+				       &amdgpu_group);
+		if (r)
+			return r;
+	}
+
  	amdgpu_dm_register_backlight_device(amdgpu_dm_connector);
 
  	if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||
Signature · 4 lines
Dominik Förderer (Netzwerkadministrator)
Windeck-Gymnasium Bühl
Humboldtstr. 3
Tel. 07223/9409585
#4 lore raw
In reply to Hamza Mahfooz

I've applied the patch to 6.7.2. The device then shows up under:

/sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings (on Framework Laptop 13 amd 7840U with 780M).

After a few tests i can say that at least in my system it’s not working. Setting a value between 0 and 4 in /sys/.../panel_power_savings changes nothing in the panel behavior. There are no errors in kernel log.

Setting an abmlevel via kernel option still works as intended.

The issue can be resolved if one set the panel_power_savings value and after that change the display resolution to a lower value and than switch back. For example this script works:

xterm -e 'echo 0 | sudo tee /sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings' gnome-randr modify -m [email protected] eDP-1 && gnome-randr modify -m [email protected] eDP-1

Am 26.01.24 um 23:22 schrieb Hamza Mahfooz:

Quoted 87 lines

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>

---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++

1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +52 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ 
 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 return &new_state->base;
 }
+static ssize_t panel_power_savings_show(struct device *device,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ ssize_t val;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ val = to_dm_connector_state(connector->state)->abm_level;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ long val;
+ int ret;
+
+ ret = kstrtol(buf, 0, &val);
+
+ if (ret)
+ return ret;
+
+ if (val < 0 || val > 4)
+ return -EINVAL;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ to_dm_connector_state(connector->state)->abm_level = val ?:
+ ABM_LEVEL_IMMEDIATE_DISABLE;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+ &dev_attr_panel_power_savings.attr,
+ NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+ .name = "amdgpu",
+ .attrs = amdgpu_attrs
+};
+

static int
amdgpu_dm_connector_late_register(struct drm_connector *connector) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct 
 drm_connector *connector)
 to_amdgpu_dm_connector(connector);
 int r;
+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ r = sysfs_create_group(&connector->kdev->kobj,
+ &amdgpu_group);
+ if (r)
+ return r;
+ }
+
 amdgpu_dm_register_backlight_device(amdgpu_dm_connector);

if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||

Signature · 4 lines
Dominik Förderer (Netzwerkadministrator)
Windeck-Gymnasium Bühl
Humboldtstr. 3
Tel. 07223/9409585
#5 lore raw
In reply to Hamza Mahfooz

I've applied the patch to 6.7.2. The device then shows up under:

/sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings (on Framework Laptop 13 amd 7840U with 780M).

After a few tests i can say that at least in my system it’s not working. Setting a value between 0 and 4 in /sys/.../panel_power_savings changes nothing in the panel behavior. There are no errors in kernel log.

Setting an abmlevel via kernel option still works as intended.

The issue can be resolved if one set the panel_power_savings value and after that change the display resolution to a lower value and than switch back. For example this script works:

xterm -e 'echo 0 | sudo tee /sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings' gnome-randr modify -m [email protected] eDP-1 && gnome-randr modify -m [email protected] eDP-1

Am 26.01.24 um 23:22 schrieb Hamza Mahfooz:

Quoted 87 lines

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>

---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++

1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +52 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ 
 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 return &new_state->base;
 }
+static ssize_t panel_power_savings_show(struct device *device,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ ssize_t val;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ val = to_dm_connector_state(connector->state)->abm_level;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ long val;
+ int ret;
+
+ ret = kstrtol(buf, 0, &val);
+
+ if (ret)
+ return ret;
+
+ if (val < 0 || val > 4)
+ return -EINVAL;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ to_dm_connector_state(connector->state)->abm_level = val ?:
+ ABM_LEVEL_IMMEDIATE_DISABLE;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+ &dev_attr_panel_power_savings.attr,
+ NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+ .name = "amdgpu",
+ .attrs = amdgpu_attrs
+};
+

static int
amdgpu_dm_connector_late_register(struct drm_connector *connector) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct 
 drm_connector *connector)
 to_amdgpu_dm_connector(connector);
 int r;
+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ r = sysfs_create_group(&connector->kdev->kobj,
+ &amdgpu_group);
+ if (r)
+ return r;
+ }
+
 amdgpu_dm_register_backlight_device(amdgpu_dm_connector);

if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||

Signature · 4 lines
Dominik Förderer (Netzwerkadministrator)
Windeck-Gymnasium Bühl
Humboldtstr. 3
Tel. 07223/9409585
#6 lore raw
In reply to Hamza Mahfooz

I've applied the patch to 6.7.2. The device then shows up under:

/sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings (on Framework Laptop 13 amd 7840U with 780M).

After a few tests i can say that at least in my system it’s not working. Setting a value between 0 and 4 in /sys/.../panel_power_savings changes nothing in the panel behavior. There are no errors in kernel log.

Setting an abmlevel via kernel option still works as intended.

The issue can be resolved if one set the panel_power_savings value and after that change the display resolution to a lower value and than switch back. For example this script works:

xterm -e 'echo 0 | sudo tee /sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings' gnome-randr modify -m [email protected] eDP-1 && gnome-randr modify -m [email protected] eDP-1

Am 26.01.24 um 23:22 schrieb Hamza Mahfooz:

Quoted 87 lines

We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>

---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++

1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +52 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@ 
 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 return &new_state->base;
 }
+static ssize_t panel_power_savings_show(struct device *device,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ ssize_t val;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ val = to_dm_connector_state(connector->state)->abm_level;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ long val;
+ int ret;
+
+ ret = kstrtol(buf, 0, &val);
+
+ if (ret)
+ return ret;
+
+ if (val < 0 || val > 4)
+ return -EINVAL;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ to_dm_connector_state(connector->state)->abm_level = val ?:
+ ABM_LEVEL_IMMEDIATE_DISABLE;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+ &dev_attr_panel_power_savings.attr,
+ NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+ .name = "amdgpu",
+ .attrs = amdgpu_attrs
+};
+

static int
amdgpu_dm_connector_late_register(struct drm_connector *connector) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct 
 drm_connector *connector)
 to_amdgpu_dm_connector(connector);
 int r;
+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ r = sysfs_create_group(&connector->kdev->kobj,
+ &amdgpu_group);
+ if (r)
+ return r;
+ }
+
 amdgpu_dm_register_backlight_device(amdgpu_dm_connector);

if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||

Signature · 4 lines
Dominik Förderer (Netzwerkadministrator)
Windeck-Gymnasium Bühl
Humboldtstr. 3
Tel. 07223/9409585
#7 lore raw

I've applied the patch to 6.7.2. The device then shows up under:

/sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings (on Framework Laptop 13 amd 7840U with 780M).

After a few tests i can say that at least in my system it’s not working. Setting a value between 0 and 4 in /sys/.../panel_power_savings changes nothing in the panel behavior. There are no errors in kernel log.

Setting an abmlevel via kernel option still works as intended.

The issue can be resolved if one set the panel_power_savings value and after that change the display resolution to a lower value and than switch back. For example this script works:

xterm -e 'echo 0 | sudo tee /sys/devices/pci0000:00/0000:00:08.1/0000:c1:00.0/drm/card1/card1-eDP-1/amdgpu/panel_power_savings' gnome-randr modify -m [email protected] eDP-1 && gnome-randr modify -m [email protected] eDP-1

Quoted 88 lines

Am 26.01.24 um 23:22 schrieb Hamza Mahfooz:
We want programs besides the compositor to be able to enable or disable panel power saving features. However, since they are currently only configurable through DRM properties, that isn't possible. So, to remedy that issue introduce a new "panel_power_savings" sysfs attribute.

Cc Mario Limonciello <[email protected]>

---
.../gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 59 +++++++++++++++++++

1 file changed, 59 insertions(+)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +52 -0
index cd98b3565178..b3fcd833015d 100644
@@ -6534,6 +6534,58 @@  
 amdgpu_dm_connector_atomic_duplicate_state(struct drm_connector *connector)
 return &new_state->base;
 }
+static ssize_t panel_power_savings_show(struct device *device,
+ struct device_attribute *attr,
+ char *buf)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ ssize_t val;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ val = to_dm_connector_state(connector->state)->abm_level;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return sysfs_emit(buf, "%lu\n", val);
+}
+
+static ssize_t panel_power_savings_store(struct device *device,
+ struct device_attribute *attr,
+ const char *buf, size_t count)
+{
+ struct drm_connector *connector = dev_get_drvdata(device);
+ struct drm_device *dev = connector->dev;
+ long val;
+ int ret;
+
+ ret = kstrtol(buf, 0, &val);
+
+ if (ret)
+ return ret;
+
+ if (val < 0 || val > 4)
+ return -EINVAL;
+
+ drm_modeset_lock(&dev->mode_config.connection_mutex, NULL);
+ to_dm_connector_state(connector->state)->abm_level = val ?:
+ ABM_LEVEL_IMMEDIATE_DISABLE;
+ drm_modeset_unlock(&dev->mode_config.connection_mutex);
+
+ return count;
+}
+
+static DEVICE_ATTR_RW(panel_power_savings);
+
+static struct attribute *amdgpu_attrs[] = {
+ &dev_attr_panel_power_savings.attr,
+ NULL
+};
+
+static const struct attribute_group amdgpu_group = {
+ .name = "amdgpu",
+ .attrs = amdgpu_attrs
+};
+

static int
amdgpu_dm_connector_late_register(struct drm_connector *connector) {

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +7 -0
@@ -6541,6 +6593,13 @@ amdgpu_dm_connector_late_register(struct  
 drm_connector *connector)
 to_amdgpu_dm_connector(connector);
 int r;
+ if (connector->connector_type == DRM_MODE_CONNECTOR_eDP) {
+ r = sysfs_create_group(&connector->kdev->kobj,
+ &amdgpu_group);
+ if (r)
+ return r;
+ }
+
 amdgpu_dm_register_backlight_device(amdgpu_dm_connector);

if ((connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort) ||