Skip to contentSkip to conversation

drm/i915: add psr toggle to debugfs

PATCH In review Eric Caruso 4 participants 10 messages Mar 13, 2015 – Apr 20, 2015

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

PATCH 1/1 drm/i915: add psr toggle to debugfs

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 67 ++++++++++++++++++++++++++++++++++---
 1 file changed, 63 insertions(+), 4 deletions(-)
drivers/gpu/drm/i915/i915_debugfs.c +63 -4
index 74bc89b..c3d9c89 100644
@@ -2224,10 +2224,9 @@ static int i915_llc(struct seq_file *m, void *data)
 	return 0;
 }
 
-static int i915_edp_psr_status(struct seq_file *m, void *data)
+static int i915_edp_psr_status_show(struct seq_file *m, void *data)
 {
-	struct drm_info_node *node = m->private;
-	struct drm_device *dev = node->minor->dev;
+	struct drm_device *dev = m->private;
 	struct drm_i915_private *dev_priv = dev->dev_private;
 	u32 psrperf = 0;
 	u32 stat[3];
@@ -2288,6 +2287,66 @@ static int i915_edp_psr_status(struct seq_file *m, void *data)
 	return 0;
 }
 
+static int i915_edp_psr_status_open(struct inode *inode, struct file *file)
+{
+	struct drm_device *dev = inode->i_private;
+
+	return single_open(file, i915_edp_psr_status_show, dev);
+}
+
+static ssize_t i915_edp_psr_status_write(struct file *file,
+					 const char __user *ubuf,
+					 size_t len, loff_t *offp)
+{
+	struct seq_file *m = file->private_data;
+	struct drm_device *dev = m->private;
+	struct intel_encoder *encoder;
+	struct intel_dp *intel_dp = NULL;
+	int ret;
+	int enable;
+	char tmp[32];
+
+	if (len >= sizeof(tmp))
+		return -EINVAL;
+
+	if (copy_from_user(tmp, ubuf, len))
+		return -EFAULT;
+
+	tmp[len] = '\0';
+
+	ret = kstrtoint(tmp, 0, &enable);
+	if (ret || (enable != 0 && enable != 1))
+		return -EINVAL;
+
+	i915.enable_psr = enable;
+	ret = -ENODEV;
+
+	drm_modeset_lock_all(dev);
+	for_each_intel_encoder(dev, encoder) {
+		if (encoder->type != INTEL_OUTPUT_EDP)
+			continue;
+
+		ret = len;
+		intel_dp = enc_to_intel_dp(&encoder->base);
+
+		if (enable)
+			intel_psr_enable(intel_dp);
+		else
+			intel_psr_disable(intel_dp);
+	}
+	drm_modeset_unlock_all(dev);
+	return ret;
+}
+
+static const struct file_operations i915_edp_psr_status_fops = {
+	.owner = THIS_MODULE,
+	.open = i915_edp_psr_status_open,
+	.read = seq_read,
+	.llseek = seq_lseek,
+	.release = single_release,
+	.write = i915_edp_psr_status_write
+};
+
 static int i915_sink_crc(struct seq_file *m, void *data)
 {
 	struct drm_info_node *node = m->private;
@@ -4663,7 +4722,6 @@ static const struct drm_info_list i915_debugfs_list[] = {
 	{"i915_swizzle_info", i915_swizzle_info, 0},
 	{"i915_ppgtt_info", i915_ppgtt_info, 0},
 	{"i915_llc", i915_llc, 0},
-	{"i915_edp_psr_status", i915_edp_psr_status, 0},
 	{"i915_sink_crc_eDP1", i915_sink_crc, 0},
 	{"i915_energy_uJ", i915_energy_uJ, 0},
 	{"i915_pc8_status", i915_pc8_status, 0},
@@ -4698,6 +4756,7 @@ static const struct i915_debugfs_files {
 	{"i915_spr_wm_latency", &i915_spr_wm_latency_fops},
 	{"i915_cur_wm_latency", &i915_cur_wm_latency_fops},
 	{"i915_fbc_false_color", &i915_fbc_fc_fops},
+	{"i915_edp_psr_status", &i915_edp_psr_status_fops},
 };
 
 void intel_display_crc_init(struct drm_device *dev)
Signature · 6 lines
2.1.2

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#1 lore raw
Quoted 10 lines · Eric Caruso

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#2 lore raw

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 5 lines
Paulo Zanoni
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#3 lore raw
Quoted 31 lines · Paulo Zanoni

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 2 lines

--
Paulo Zanoni

Forgive me if this is wrong, but updating the module parameter doesn't change whether or not PSR is enabled immediately. You need to go through intel_enable_ddi for this to take effect.

We were using something like this for testing on Chromium OS, because PSR would sometimes cause issues. This allows us to change the module parameter and enable/disable PSR in one step.

The upstream feedback I mentioned was done about a year ago:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041896.html
It seemed to favor a debugfs knob for this.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#4 lore raw
Quoted 32 lines · Eric Caruso
Quoted 31 lines · Paulo Zanoni

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 6 lines
Quoted 2 lines

--
Paulo Zanoni

Forgive me if this is wrong, but updating the module parameter doesn't change whether or not PSR is enabled immediately. You need to go through intel_enable_ddi for this to take effect.

indeed.

Quoted 4 lines

We were using something like this for testing on Chromium OS, because PSR would sometimes cause issues. This allows us to change the module parameter and enable/disable PSR in one step.

I like the idea. But I'd prefer a sysfs toggle interface though...

Quoted 8 lines

The upstream feedback I mentioned was done about a year ago:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041896.html
It seemed to favor a debugfs knob for this.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#5 lore raw
Quoted 40 lines · Rodrigo Vivi
Quoted 32 lines · Eric Caruso
Quoted 31 lines · Paulo Zanoni

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 6 lines
Quoted 2 lines

--
Paulo Zanoni

Forgive me if this is wrong, but updating the module parameter doesn't change whether or not PSR is enabled immediately. You need to go through intel_enable_ddi for this to take effect.

Quoted 8 lines

indeed.

Quoted 4 lines

We were using something like this for testing on Chromium OS, because PSR would sometimes cause issues. This allows us to change the module parameter and enable/disable PSR in one step.

I like the idea. But I'd prefer a sysfs toggle interface though...

Aren't you adding a connector property at this point? If so, it seems like both this debugfs knob and a hypothetical sysfs interface would both be unnecessary. (see: http://lists.freedesktop.org/archives/intel-gfx/2015-March/063074.html)

Quoted 12 lines
Quoted 9 lines

The upstream feedback I mentioned was done about a year ago:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041896.html
It seemed to favor a debugfs knob for this.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 3 lines

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#6 lore raw

I'm not sure that that property will be accepted...
if so it can be changed to toggle, but for now it is informative only (DRM_MODE_PROP_IMMUTABLE).

Quoted 69 lines · Eric Caruso
Quoted 40 lines · Rodrigo Vivi
Quoted 32 lines · Eric Caruso
Quoted 31 lines · Paulo Zanoni

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 6 lines
Quoted 2 lines

--
Paulo Zanoni

Forgive me if this is wrong, but updating the module parameter doesn't change whether or not PSR is enabled immediately. You need to go through intel_enable_ddi for this to take effect.

Quoted 8 lines

indeed.

Quoted 4 lines

We were using something like this for testing on Chromium OS, because PSR would sometimes cause issues. This allows us to change the module parameter and enable/disable PSR in one step.

I like the idea. But I'd prefer a sysfs toggle interface though...

Aren't you adding a connector property at this point? If so, it seems like both this debugfs knob and a hypothetical sysfs interface would both be unnecessary. (see: http://lists.freedesktop.org/archives/intel-gfx/2015-March/063074.html)

Quoted 15 lines
Quoted 9 lines

The upstream feedback I mentioned was done about a year ago:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041896.html
It seemed to favor a debugfs knob for this.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
#7 lore raw
Quoted 4 lines · Rodrigo Vivi

I'm not sure that that property will be accepted...
if so it can be changed to toggle, but for now it is informative only (DRM_MODE_PROP_IMMUTABLE).

Okay, that changes things somewhat. There'll have to be some discussion over what the sysfs interface would be, then. It's supposed to be stable, if I understand correctly.

Quoted 74 lines · Eric Caruso
Quoted 48 lines · Rodrigo Vivi
Quoted 47 lines · Eric Caruso
Quoted 32 lines · Paulo Zanoni
Quoted 31 lines

2015-03-13 16:01 GMT-03:00 Daniel Vetter <[email protected]>:

Quoted 10 lines · Eric Caruso
Quoted 9 lines

This patch allows userspace to toggle PSR through a debugfs interface. It adds functionality to write 0 or 1 to the existing i915_edp_psr_status file in order to change the relevant module parameter and enable/disable PSR.

Previous upstream feedback did not like making it a connector property or putting it in sysfs because that would require API stability going forward. debugfs interfaces do not have this restriction.

Quoted 5 lines
Quoted 1 line

What do we need this for? debugfs is generally for debugging (where the module option should be enough) and for testcases (which doesn't seem to be the case here).

What is wrong with "echo 1 > /sys/module/i915/parameters/enable_psr"?

Quoted 9 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
+41 (0) 79 365 57 48 - http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

Quoted 6 lines
Quoted 2 lines

--
Paulo Zanoni

Forgive me if this is wrong, but updating the module parameter doesn't change whether or not PSR is enabled immediately. You need to go through intel_enable_ddi for this to take effect.

indeed.

Quoted 4 lines

We were using something like this for testing on Chromium OS, because PSR would sometimes cause issues. This allows us to change the module parameter and enable/disable PSR in one step.

Quoted 21 lines
Quoted 1 line

I like the idea. But I'd prefer a sysfs toggle interface though...

Aren't you adding a connector property at this point? If so, it seems like both this debugfs knob and a hypothetical sysfs interface would both be unnecessary. (see: http://lists.freedesktop.org/archives/intel-gfx/2015-March/063074.html)

Quoted 15 lines
Quoted 9 lines

The upstream feedback I mentioned was done about a year ago:
http://lists.freedesktop.org/archives/intel-gfx/2014-March/041896.html
It seemed to favor a debugfs knob for this.
_______________________________________________
Intel-gfx mailing list [email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

Quoted 3 lines

--
Rodrigo Vivi
Blog: http://blog.vivi.eng.br

_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx

#8 lore raw
Quoted 9 lines · Eric Caruso
Quoted 4 lines · Rodrigo Vivi

I'm not sure that that property will be accepted...
if so it can be changed to toggle, but for now it is informative only (DRM_MODE_PROP_IMMUTABLE).

Okay, that changes things somewhat. There'll have to be some discussion over what the sysfs interface would be, then. It's supposed to be stable, if I understand correctly.

Imo if it's just for debugging, then debugfs is the correct place. Sysfs means ABI with all the requirements (igt tests, open-source userspace, ...) that entails.
-Daniel

Signature · 7 lines
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
Acked-by
#9 lore raw
Quoted 7 lines · Daniel Vetter
Quoted 6 lines · Eric Caruso
Quoted 4 lines · Rodrigo Vivi

I'm not sure that that property will be accepted...
if so it can be changed to toggle, but for now it is informative only (DRM_MODE_PROP_IMMUTABLE).

Quoted 7 lines
Quoted 3 lines

Okay, that changes things somewhat. There'll have to be some discussion over what the sysfs interface would be, then. It's supposed to be stable, if I understand correctly.

Imo if it's just for debugging, then debugfs is the correct place. Sysfs means ABI with all the requirements (igt tests, open-source userspace, ...) that entails.

Good points, so:

Although "i915.enable_psr = enable;" is useless and change the meaning of this parameter.
I'd remove this...

And probably check for pipe_config psr ready if/when merged...

Quoted 5 lines

-Daniel
--
Daniel Vetter
Software Engineer, Intel Corporation
http://blog.ffwll.ch

Signature · 6 lines
Rodrigo Vivi
Blog: http://blog.vivi.eng.br
_______________________________________________
Intel-gfx mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/intel-gfx