* [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD
@ 2015-02-25 12:34 Jani Nikula
2015-02-27 15:29 ` shuang.he
2015-03-12 4:00 ` Todd Previte
0 siblings, 2 replies; 3+ messages in thread
From: Jani Nikula @ 2015-02-25 12:34 UTC (permalink / raw)
To: intel-gfx; +Cc: jani.nikula
Occasionally it would be interesting to read some of the DPCD registers
for debug purposes, without having to resort to logging. Add an i915
specific i915_dpcd debugfs file for DP and eDP connectors to dump parts
of the DPCD. Currently the DPCD addresses to be dumped are statically
configured, and more can be added trivially.
The implementation also makes it relatively easy to add other i915 and
connector specific debugfs files in the future, as necessary.
This is currently i915 specific just because there's no generic way to
do AUX transactions given just a drm_connector. However it's all pretty
straightforward to port to other drivers.
Signed-off-by: Jani Nikula <jani.nikula@intel.com>
---
drivers/gpu/drm/i915/i915_debugfs.c | 93 +++++++++++++++++++++++++++++++++++++
drivers/gpu/drm/i915/i915_drv.h | 1 +
drivers/gpu/drm/i915/intel_dp.c | 2 +
3 files changed, 96 insertions(+)
diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
index 26e9c7b34113..451ef456c25f 100644
--- a/drivers/gpu/drm/i915/i915_debugfs.c
+++ b/drivers/gpu/drm/i915/i915_debugfs.c
@@ -4652,3 +4652,96 @@ void i915_debugfs_cleanup(struct drm_minor *minor)
drm_debugfs_remove_files(info_list, 1, minor);
}
}
+
+struct dpcd_block {
+ /* DPCD dump start address. */
+ unsigned int offset;
+ /* DPCD dump end address, inclusive. If unset, .size will be used. */
+ unsigned int end;
+ /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
+ size_t size;
+ /* Only valid for eDP. */
+ bool edp;
+};
+
+static const struct dpcd_block i915_dpcd_debug[] = {
+ { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
+ { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
+ { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
+ { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
+ { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
+ { .offset = DP_SET_POWER },
+ { .offset = DP_EDP_DPCD_REV },
+};
+
+static int i915_dpcd_show(struct seq_file *m, void *data)
+{
+ struct drm_connector *connector = m->private;
+ struct intel_dp *intel_dp =
+ enc_to_intel_dp(&intel_attached_encoder(connector)->base);
+ uint8_t buf[16];
+ ssize_t err;
+ int i;
+
+ for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
+ const struct dpcd_block *b = &i915_dpcd_debug[i];
+ size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
+
+ if (b->edp &&
+ connector->connector_type != DRM_MODE_CONNECTOR_eDP)
+ continue;
+
+ /* low tech for now */
+ if (WARN_ON(size > sizeof(buf)))
+ continue;
+
+ err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
+ if (err <= 0) {
+ DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
+ size, b->offset, err);
+ continue;
+ }
+
+ seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
+ };
+
+ return 0;
+}
+
+static int i915_dpcd_open(struct inode *inode, struct file *file)
+{
+ return single_open(file, i915_dpcd_show, inode->i_private);
+}
+
+static const struct file_operations i915_dpcd_fops = {
+ .owner = THIS_MODULE,
+ .open = i915_dpcd_open,
+ .read = seq_read,
+ .llseek = seq_lseek,
+ .release = single_release,
+};
+
+/**
+ * i915_debugfs_connector_add - add i915 specific connector debugfs files
+ * @connector: pointer to a registered drm_connector
+ *
+ * Cleanup will be done by drm_connector_unregister() through a call to
+ * drm_debugfs_connector_remove().
+ *
+ * Returns 0 on success, negative error codes on error.
+ */
+int i915_debugfs_connector_add(struct drm_connector *connector)
+{
+ struct dentry *root = connector->debugfs_entry;
+
+ /* The connector must have been registered beforehands. */
+ if (!root)
+ return -ENODEV;
+
+ if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
+ connector->connector_type == DRM_MODE_CONNECTOR_eDP)
+ debugfs_create_file("i915_dpcd", S_IRUGO, root, connector,
+ &i915_dpcd_fops);
+
+ return 0;
+}
diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
index d42040fbd3c4..f8d42c7afda4 100644
--- a/drivers/gpu/drm/i915/i915_drv.h
+++ b/drivers/gpu/drm/i915/i915_drv.h
@@ -3095,6 +3095,7 @@ int i915_verify_lists(struct drm_device *dev);
/* i915_debugfs.c */
int i915_debugfs_init(struct drm_minor *minor);
void i915_debugfs_cleanup(struct drm_minor *minor);
+int i915_debugfs_connector_add(struct drm_connector *connector);
#ifdef CONFIG_DEBUG_FS
void intel_display_crc_init(struct drm_device *dev);
#else
diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
index 8d674f400d9a..69af47ebf77b 100644
--- a/drivers/gpu/drm/i915/intel_dp.c
+++ b/drivers/gpu/drm/i915/intel_dp.c
@@ -5348,6 +5348,8 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
}
+ i915_debugfs_connector_add(connector);
+
return true;
}
--
2.1.4
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply related [flat|nested] 3+ messages in thread* Re: [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD
2015-02-25 12:34 [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD Jani Nikula
@ 2015-02-27 15:29 ` shuang.he
2015-03-12 4:00 ` Todd Previte
1 sibling, 0 replies; 3+ messages in thread
From: shuang.he @ 2015-02-27 15:29 UTC (permalink / raw)
To: shuang.he, ethan.gao, intel-gfx, jani.nikula
Tested-By: PRC QA PRTS (Patch Regression Test System Contact: shuang.he@intel.com)
Task id: 5824
-------------------------------------Summary-------------------------------------
Platform Delta drm-intel-nightly Series Applied
PNV 282/282 282/282
ILK -1 308/308 307/308
SNB 326/326 326/326
IVB 379/379 379/379
BYT 294/294 294/294
HSW -2 387/387 385/387
BDW -1 316/316 315/316
-------------------------------------Detailed-------------------------------------
Platform Test drm-intel-nightly Series Applied
*ILK igt_drv_suspend_debugfs-reader PASS(1) DMESG_WARN(2)
*HSW igt_gem_storedw_loop_blt PASS(1) DMESG_WARN(1)PASS(1)
*HSW igt_pm_rpm_debugfs-read PASS(1) DMESG_WARN(2)
*BDW igt_gem_gtt_hog PASS(1) DMESG_WARN(1)PASS(1)
Note: You need to pay more attention to line start with '*'
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD
2015-02-25 12:34 [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD Jani Nikula
2015-02-27 15:29 ` shuang.he
@ 2015-03-12 4:00 ` Todd Previte
1 sibling, 0 replies; 3+ messages in thread
From: Todd Previte @ 2015-03-12 4:00 UTC (permalink / raw)
To: intel-gfx
On 2/25/2015 5:34 AM, Jani Nikula wrote:
> Occasionally it would be interesting to read some of the DPCD registers
> for debug purposes, without having to resort to logging. Add an i915
> specific i915_dpcd debugfs file for DP and eDP connectors to dump parts
> of the DPCD. Currently the DPCD addresses to be dumped are statically
> configured, and more can be added trivially.
>
> The implementation also makes it relatively easy to add other i915 and
> connector specific debugfs files in the future, as necessary.
>
> This is currently i915 specific just because there's no generic way to
> do AUX transactions given just a drm_connector. However it's all pretty
> straightforward to port to other drivers.
>
> Signed-off-by: Jani Nikula <jani.nikula@intel.com>
> ---
> drivers/gpu/drm/i915/i915_debugfs.c | 93 +++++++++++++++++++++++++++++++++++++
> drivers/gpu/drm/i915/i915_drv.h | 1 +
> drivers/gpu/drm/i915/intel_dp.c | 2 +
> 3 files changed, 96 insertions(+)
>
> diff --git a/drivers/gpu/drm/i915/i915_debugfs.c b/drivers/gpu/drm/i915/i915_debugfs.c
> index 26e9c7b34113..451ef456c25f 100644
> --- a/drivers/gpu/drm/i915/i915_debugfs.c
> +++ b/drivers/gpu/drm/i915/i915_debugfs.c
> @@ -4652,3 +4652,96 @@ void i915_debugfs_cleanup(struct drm_minor *minor)
> drm_debugfs_remove_files(info_list, 1, minor);
> }
> }
> +
> +struct dpcd_block {
> + /* DPCD dump start address. */
> + unsigned int offset;
> + /* DPCD dump end address, inclusive. If unset, .size will be used. */
> + unsigned int end;
> + /* DPCD dump size. Used if .end is unset. If unset, defaults to 1. */
> + size_t size;
> + /* Only valid for eDP. */
> + bool edp;
> +};
> +
> +static const struct dpcd_block i915_dpcd_debug[] = {
> + { .offset = DP_DPCD_REV, .size = DP_RECEIVER_CAP_SIZE },
> + { .offset = DP_PSR_SUPPORT, .end = DP_PSR_CAPS },
> + { .offset = DP_DOWNSTREAM_PORT_0, .size = 16 },
> + { .offset = DP_LINK_BW_SET, .end = DP_EDP_CONFIGURATION_SET },
> + { .offset = DP_SINK_COUNT, .end = DP_ADJUST_REQUEST_LANE2_3 },
> + { .offset = DP_SET_POWER },
> + { .offset = DP_EDP_DPCD_REV },
> +};
> +
> +static int i915_dpcd_show(struct seq_file *m, void *data)
> +{
> + struct drm_connector *connector = m->private;
> + struct intel_dp *intel_dp =
> + enc_to_intel_dp(&intel_attached_encoder(connector)->base);
> + uint8_t buf[16];
> + ssize_t err;
> + int i;
> +
> + for (i = 0; i < ARRAY_SIZE(i915_dpcd_debug); i++) {
> + const struct dpcd_block *b = &i915_dpcd_debug[i];
> + size_t size = b->end ? b->end - b->offset + 1 : (b->size ?: 1);
> +
> + if (b->edp &&
> + connector->connector_type != DRM_MODE_CONNECTOR_eDP)
> + continue;
> +
> + /* low tech for now */
> + if (WARN_ON(size > sizeof(buf)))
> + continue;
> +
> + err = drm_dp_dpcd_read(&intel_dp->aux, b->offset, buf, size);
> + if (err <= 0) {
> + DRM_ERROR("dpcd read (%zu bytes at %u) failed (%zd)\n",
> + size, b->offset, err);
> + continue;
> + }
> +
> + seq_printf(m, "%04x: %*ph\n", b->offset, (int) size, buf);
> + };
> +
> + return 0;
> +}
> +
> +static int i915_dpcd_open(struct inode *inode, struct file *file)
> +{
> + return single_open(file, i915_dpcd_show, inode->i_private);
> +}
> +
> +static const struct file_operations i915_dpcd_fops = {
> + .owner = THIS_MODULE,
> + .open = i915_dpcd_open,
> + .read = seq_read,
> + .llseek = seq_lseek,
> + .release = single_release,
> +};
> +
> +/**
> + * i915_debugfs_connector_add - add i915 specific connector debugfs files
> + * @connector: pointer to a registered drm_connector
> + *
> + * Cleanup will be done by drm_connector_unregister() through a call to
> + * drm_debugfs_connector_remove().
> + *
> + * Returns 0 on success, negative error codes on error.
> + */
> +int i915_debugfs_connector_add(struct drm_connector *connector)
> +{
> + struct dentry *root = connector->debugfs_entry;
> +
> + /* The connector must have been registered beforehands. */
> + if (!root)
> + return -ENODEV;
> +
> + if (connector->connector_type == DRM_MODE_CONNECTOR_DisplayPort ||
> + connector->connector_type == DRM_MODE_CONNECTOR_eDP)
> + debugfs_create_file("i915_dpcd", S_IRUGO, root, connector,
> + &i915_dpcd_fops);
> +
> + return 0;
> +}
> diff --git a/drivers/gpu/drm/i915/i915_drv.h b/drivers/gpu/drm/i915/i915_drv.h
> index d42040fbd3c4..f8d42c7afda4 100644
> --- a/drivers/gpu/drm/i915/i915_drv.h
> +++ b/drivers/gpu/drm/i915/i915_drv.h
> @@ -3095,6 +3095,7 @@ int i915_verify_lists(struct drm_device *dev);
> /* i915_debugfs.c */
> int i915_debugfs_init(struct drm_minor *minor);
> void i915_debugfs_cleanup(struct drm_minor *minor);
> +int i915_debugfs_connector_add(struct drm_connector *connector);
> #ifdef CONFIG_DEBUG_FS
> void intel_display_crc_init(struct drm_device *dev);
> #else
> diff --git a/drivers/gpu/drm/i915/intel_dp.c b/drivers/gpu/drm/i915/intel_dp.c
> index 8d674f400d9a..69af47ebf77b 100644
> --- a/drivers/gpu/drm/i915/intel_dp.c
> +++ b/drivers/gpu/drm/i915/intel_dp.c
> @@ -5348,6 +5348,8 @@ intel_dp_init_connector(struct intel_digital_port *intel_dig_port,
> I915_WRITE(PEG_BAND_GAP_DATA, (temp & ~0xf) | 0xd);
> }
>
> + i915_debugfs_connector_add(connector);
> +
> return true;
> }
>
Looks good. I'm going to apply this patch and check it out.
Reviewed-by: Todd Previte <tprevite@gmail.com>
_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/intel-gfx
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-03-12 4:00 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-02-25 12:34 [PATCH] drm/i915: add i915 specific connector debugfs file for DPCD Jani Nikula
2015-02-27 15:29 ` shuang.he
2015-03-12 4:00 ` Todd Previte
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox