All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show()
@ 2023-02-03 15:43 ` Hamza Mahfooz
  0 siblings, 0 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2023-02-03 15:43 UTC (permalink / raw)
  To: amd-gfx
  Cc: Hamza Mahfooz, Harry Wentland, Leo Li, Rodrigo Siqueira,
	Alex Deucher, Christian König, Pan, Xinhui, David Airlie,
	Daniel Vetter, Wayne Lin, Alan Liu, hersen wu, Wenjing Liu,
	Greg Kroah-Hartman, Jiapeng Chong, Alexey Kodanev,
	Bhanuprakash Modem, dri-devel, linux-kernel

Currently, it is likely that we will read the relevant LTTPR caps after
link training has completed (which can cause garbage data to be read),
however according to the DP 2.0 spec that should be done before link
training has commenced. So, instead of reading the registers on demand,
use the values provided to us by DC.

Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++-------------
 1 file changed, 22 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index e783082a4eef..cbc241596c1f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -36,6 +36,7 @@
 #include "dsc.h"
 #include "link_hwss.h"
 #include "dc/dc_dmub_srv.h"
+#include "link/protocols/link_dp_capability.h"
 
 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
 #include "amdgpu_dm_psr.h"
@@ -418,67 +419,38 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
 	return result;
 }
 
-static int dp_lttpr_status_show(struct seq_file *m, void *d)
+static int dp_lttpr_status_show(struct seq_file *m, void *unused)
 {
-	char *data;
-	struct amdgpu_dm_connector *connector = file_inode(m->file)->i_private;
-	struct dc_link *link = connector->dc_link;
-	uint32_t read_size = 1;
-	uint8_t repeater_count = 0;
+	struct drm_connector *connector = m->private;
+	struct amdgpu_dm_connector *aconnector =
+		to_amdgpu_dm_connector(connector);
+	struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
 
-	data = kzalloc(read_size, GFP_KERNEL);
-	if (!data)
-		return 0;
+	if (connector->status != connector_status_connected)
+		return -ENODEV;
 
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0002, data, read_size);
+	seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
+		   dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
+		   caps.phy_repeater_cnt);
 
-	switch ((uint8_t)*data) {
-	case 0x80:
-		repeater_count = 1;
-		break;
-	case 0x40:
-		repeater_count = 2;
-		break;
-	case 0x20:
-		repeater_count = 3;
-		break;
-	case 0x10:
-		repeater_count = 4;
-		break;
-	case 0x8:
-		repeater_count = 5;
-		break;
-	case 0x4:
-		repeater_count = 6;
-		break;
-	case 0x2:
-		repeater_count = 7;
+	seq_puts(m, "phy repeater mode: ");
+
+	switch (caps.mode) {
+	case DP_PHY_REPEATER_MODE_TRANSPARENT:
+		seq_puts(m, "transparent");
 		break;
-	case 0x1:
-		repeater_count = 8;
+	case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
+		seq_puts(m, "non-transparent");
 		break;
-	case 0x0:
-		repeater_count = 0;
+	case 0x00:
+		seq_puts(m, "non lttpr");
 		break;
 	default:
-		repeater_count = (uint8_t)*data;
+		seq_printf(m, "read error (raw: 0x%x)", caps.mode);
 		break;
 	}
 
-	seq_printf(m, "phy repeater count: %d\n", repeater_count);
-
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0003, data, read_size);
-
-	if ((uint8_t)*data == 0x55)
-		seq_printf(m, "phy repeater mode: transparent\n");
-	else if ((uint8_t)*data == 0xAA)
-		seq_printf(m, "phy repeater mode: non-transparent\n");
-	else if ((uint8_t)*data == 0x00)
-		seq_printf(m, "phy repeater mode: non lttpr\n");
-	else
-		seq_printf(m, "phy repeater mode: read error\n");
-
-	kfree(data);
+	seq_puts(m, "\n");
 	return 0;
 }
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show()
@ 2023-02-03 15:43 ` Hamza Mahfooz
  0 siblings, 0 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2023-02-03 15:43 UTC (permalink / raw)
  To: amd-gfx
  Cc: Alan Liu, Jiapeng Chong, Greg Kroah-Hartman, Leo Li, Pan, Xinhui,
	Rodrigo Siqueira, linux-kernel, dri-devel, Wenjing Liu,
	hersen wu, Hamza Mahfooz, Wayne Lin, Alex Deucher,
	Bhanuprakash Modem, Christian König, Alexey Kodanev

Currently, it is likely that we will read the relevant LTTPR caps after
link training has completed (which can cause garbage data to be read),
however according to the DP 2.0 spec that should be done before link
training has commenced. So, instead of reading the registers on demand,
use the values provided to us by DC.

Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++-------------
 1 file changed, 22 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index e783082a4eef..cbc241596c1f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -36,6 +36,7 @@
 #include "dsc.h"
 #include "link_hwss.h"
 #include "dc/dc_dmub_srv.h"
+#include "link/protocols/link_dp_capability.h"
 
 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
 #include "amdgpu_dm_psr.h"
@@ -418,67 +419,38 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
 	return result;
 }
 
-static int dp_lttpr_status_show(struct seq_file *m, void *d)
+static int dp_lttpr_status_show(struct seq_file *m, void *unused)
 {
-	char *data;
-	struct amdgpu_dm_connector *connector = file_inode(m->file)->i_private;
-	struct dc_link *link = connector->dc_link;
-	uint32_t read_size = 1;
-	uint8_t repeater_count = 0;
+	struct drm_connector *connector = m->private;
+	struct amdgpu_dm_connector *aconnector =
+		to_amdgpu_dm_connector(connector);
+	struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
 
-	data = kzalloc(read_size, GFP_KERNEL);
-	if (!data)
-		return 0;
+	if (connector->status != connector_status_connected)
+		return -ENODEV;
 
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0002, data, read_size);
+	seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
+		   dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
+		   caps.phy_repeater_cnt);
 
-	switch ((uint8_t)*data) {
-	case 0x80:
-		repeater_count = 1;
-		break;
-	case 0x40:
-		repeater_count = 2;
-		break;
-	case 0x20:
-		repeater_count = 3;
-		break;
-	case 0x10:
-		repeater_count = 4;
-		break;
-	case 0x8:
-		repeater_count = 5;
-		break;
-	case 0x4:
-		repeater_count = 6;
-		break;
-	case 0x2:
-		repeater_count = 7;
+	seq_puts(m, "phy repeater mode: ");
+
+	switch (caps.mode) {
+	case DP_PHY_REPEATER_MODE_TRANSPARENT:
+		seq_puts(m, "transparent");
 		break;
-	case 0x1:
-		repeater_count = 8;
+	case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
+		seq_puts(m, "non-transparent");
 		break;
-	case 0x0:
-		repeater_count = 0;
+	case 0x00:
+		seq_puts(m, "non lttpr");
 		break;
 	default:
-		repeater_count = (uint8_t)*data;
+		seq_printf(m, "read error (raw: 0x%x)", caps.mode);
 		break;
 	}
 
-	seq_printf(m, "phy repeater count: %d\n", repeater_count);
-
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0003, data, read_size);
-
-	if ((uint8_t)*data == 0x55)
-		seq_printf(m, "phy repeater mode: transparent\n");
-	else if ((uint8_t)*data == 0xAA)
-		seq_printf(m, "phy repeater mode: non-transparent\n");
-	else if ((uint8_t)*data == 0x00)
-		seq_printf(m, "phy repeater mode: non lttpr\n");
-	else
-		seq_printf(m, "phy repeater mode: read error\n");
-
-	kfree(data);
+	seq_puts(m, "\n");
 	return 0;
 }
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show()
@ 2023-02-03 15:43 ` Hamza Mahfooz
  0 siblings, 0 replies; 5+ messages in thread
From: Hamza Mahfooz @ 2023-02-03 15:43 UTC (permalink / raw)
  To: amd-gfx
  Cc: Alan Liu, Jiapeng Chong, Greg Kroah-Hartman, Leo Li,
	David Airlie, Pan, Xinhui, Rodrigo Siqueira, linux-kernel,
	dri-devel, Wenjing Liu, hersen wu, Hamza Mahfooz, Daniel Vetter,
	Wayne Lin, Alex Deucher, Bhanuprakash Modem, Harry Wentland,
	Christian König, Alexey Kodanev

Currently, it is likely that we will read the relevant LTTPR caps after
link training has completed (which can cause garbage data to be read),
however according to the DP 2.0 spec that should be done before link
training has commenced. So, instead of reading the registers on demand,
use the values provided to us by DC.

Signed-off-by: Hamza Mahfooz <hamza.mahfooz@amd.com>
---
 .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++-------------
 1 file changed, 22 insertions(+), 50 deletions(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
index e783082a4eef..cbc241596c1f 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
@@ -36,6 +36,7 @@
 #include "dsc.h"
 #include "link_hwss.h"
 #include "dc/dc_dmub_srv.h"
+#include "link/protocols/link_dp_capability.h"
 
 #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
 #include "amdgpu_dm_psr.h"
@@ -418,67 +419,38 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
 	return result;
 }
 
-static int dp_lttpr_status_show(struct seq_file *m, void *d)
+static int dp_lttpr_status_show(struct seq_file *m, void *unused)
 {
-	char *data;
-	struct amdgpu_dm_connector *connector = file_inode(m->file)->i_private;
-	struct dc_link *link = connector->dc_link;
-	uint32_t read_size = 1;
-	uint8_t repeater_count = 0;
+	struct drm_connector *connector = m->private;
+	struct amdgpu_dm_connector *aconnector =
+		to_amdgpu_dm_connector(connector);
+	struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
 
-	data = kzalloc(read_size, GFP_KERNEL);
-	if (!data)
-		return 0;
+	if (connector->status != connector_status_connected)
+		return -ENODEV;
 
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0002, data, read_size);
+	seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
+		   dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
+		   caps.phy_repeater_cnt);
 
-	switch ((uint8_t)*data) {
-	case 0x80:
-		repeater_count = 1;
-		break;
-	case 0x40:
-		repeater_count = 2;
-		break;
-	case 0x20:
-		repeater_count = 3;
-		break;
-	case 0x10:
-		repeater_count = 4;
-		break;
-	case 0x8:
-		repeater_count = 5;
-		break;
-	case 0x4:
-		repeater_count = 6;
-		break;
-	case 0x2:
-		repeater_count = 7;
+	seq_puts(m, "phy repeater mode: ");
+
+	switch (caps.mode) {
+	case DP_PHY_REPEATER_MODE_TRANSPARENT:
+		seq_puts(m, "transparent");
 		break;
-	case 0x1:
-		repeater_count = 8;
+	case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
+		seq_puts(m, "non-transparent");
 		break;
-	case 0x0:
-		repeater_count = 0;
+	case 0x00:
+		seq_puts(m, "non lttpr");
 		break;
 	default:
-		repeater_count = (uint8_t)*data;
+		seq_printf(m, "read error (raw: 0x%x)", caps.mode);
 		break;
 	}
 
-	seq_printf(m, "phy repeater count: %d\n", repeater_count);
-
-	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0003, data, read_size);
-
-	if ((uint8_t)*data == 0x55)
-		seq_printf(m, "phy repeater mode: transparent\n");
-	else if ((uint8_t)*data == 0xAA)
-		seq_printf(m, "phy repeater mode: non-transparent\n");
-	else if ((uint8_t)*data == 0x00)
-		seq_printf(m, "phy repeater mode: non lttpr\n");
-	else
-		seq_printf(m, "phy repeater mode: read error\n");
-
-	kfree(data);
+	seq_puts(m, "\n");
 	return 0;
 }
 
-- 
2.39.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show()
  2023-02-03 15:43 ` Hamza Mahfooz
@ 2023-02-03 16:26   ` Aurabindo Pillai
  -1 siblings, 0 replies; 5+ messages in thread
From: Aurabindo Pillai @ 2023-02-03 16:26 UTC (permalink / raw)
  To: Hamza Mahfooz, amd-gfx
  Cc: Alan Liu, Jiapeng Chong, Leo Li, Greg Kroah-Hartman, Pan, Xinhui,
	Rodrigo Siqueira, linux-kernel, dri-devel, Wenjing Liu,
	hersen wu, Wayne Lin, Alex Deucher, Bhanuprakash Modem,
	Christian König, Alexey Kodanev

[-- Attachment #1: Type: text/plain, Size: 3677 bytes --]


On 2/3/23 10:43, Hamza Mahfooz wrote:
> Currently, it is likely that we will read the relevant LTTPR caps after
> link training has completed (which can cause garbage data to be read),
> however according to the DP 2.0 spec that should be done before link
> training has commenced. So, instead of reading the registers on demand,
> use the values provided to us by DC.
>
> Signed-off-by: Hamza Mahfooz<hamza.mahfooz@amd.com>
> ---
>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++-------------
>   1 file changed, 22 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index e783082a4eef..cbc241596c1f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -36,6 +36,7 @@
>   #include "dsc.h"
>   #include "link_hwss.h"
>   #include "dc/dc_dmub_srv.h"
> +#include "link/protocols/link_dp_capability.h"
>   
>   #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>   #include "amdgpu_dm_psr.h"
> @@ -418,67 +419,38 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
>   	return result;
>   }
>   
> -static int dp_lttpr_status_show(struct seq_file *m, void *d)
> +static int dp_lttpr_status_show(struct seq_file *m, void *unused)
>   {
> -	char *data;
> -	struct amdgpu_dm_connector *connector = file_inode(m->file)->i_private;
> -	struct dc_link *link = connector->dc_link;
> -	uint32_t read_size = 1;
> -	uint8_t repeater_count = 0;
> +	struct drm_connector *connector = m->private;
> +	struct amdgpu_dm_connector *aconnector =
> +		to_amdgpu_dm_connector(connector);
> +	struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
>   
> -	data = kzalloc(read_size, GFP_KERNEL);
> -	if (!data)
> -		return 0;
> +	if (connector->status != connector_status_connected)
> +		return -ENODEV;
>   
> -	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0002, data, read_size);
> +	seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
> +		   dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
> +		   caps.phy_repeater_cnt);
>   
> -	switch ((uint8_t)*data) {
> -	case 0x80:
> -		repeater_count = 1;
> -		break;
> -	case 0x40:
> -		repeater_count = 2;
> -		break;
> -	case 0x20:
> -		repeater_count = 3;
> -		break;
> -	case 0x10:
> -		repeater_count = 4;
> -		break;
> -	case 0x8:
> -		repeater_count = 5;
> -		break;
> -	case 0x4:
> -		repeater_count = 6;
> -		break;
> -	case 0x2:
> -		repeater_count = 7;
> +	seq_puts(m, "phy repeater mode: ");
> +
> +	switch (caps.mode) {
> +	case DP_PHY_REPEATER_MODE_TRANSPARENT:
> +		seq_puts(m, "transparent");
>   		break;
> -	case 0x1:
> -		repeater_count = 8;
> +	case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
> +		seq_puts(m, "non-transparent");
>   		break;
> -	case 0x0:
> -		repeater_count = 0;
> +	case 0x00:
> +		seq_puts(m, "non lttpr");
>   		break;
>   	default:
> -		repeater_count = (uint8_t)*data;
> +		seq_printf(m, "read error (raw: 0x%x)", caps.mode);
>   		break;
>   	}
>   
> -	seq_printf(m, "phy repeater count: %d\n", repeater_count);
> -
> -	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0003, data, read_size);
> -
> -	if ((uint8_t)*data == 0x55)
> -		seq_printf(m, "phy repeater mode: transparent\n");
> -	else if ((uint8_t)*data == 0xAA)
> -		seq_printf(m, "phy repeater mode: non-transparent\n");
> -	else if ((uint8_t)*data == 0x00)
> -		seq_printf(m, "phy repeater mode: non lttpr\n");
> -	else
> -		seq_printf(m, "phy repeater mode: read error\n");
> -
> -	kfree(data);
> +	seq_puts(m, "\n");
>   	return 0;
>   }
>   


Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>

[-- Attachment #2: Type: text/html, Size: 4251 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show()
@ 2023-02-03 16:26   ` Aurabindo Pillai
  0 siblings, 0 replies; 5+ messages in thread
From: Aurabindo Pillai @ 2023-02-03 16:26 UTC (permalink / raw)
  To: Hamza Mahfooz, amd-gfx
  Cc: Alan Liu, Jiapeng Chong, Harry Wentland, Leo Li,
	Greg Kroah-Hartman, Pan, Xinhui, Rodrigo Siqueira, linux-kernel,
	dri-devel, Wenjing Liu, hersen wu, Daniel Vetter, Wayne Lin,
	Alex Deucher, Bhanuprakash Modem, David Airlie,
	Christian König, Alexey Kodanev

[-- Attachment #1: Type: text/plain, Size: 3677 bytes --]


On 2/3/23 10:43, Hamza Mahfooz wrote:
> Currently, it is likely that we will read the relevant LTTPR caps after
> link training has completed (which can cause garbage data to be read),
> however according to the DP 2.0 spec that should be done before link
> training has commenced. So, instead of reading the registers on demand,
> use the values provided to us by DC.
>
> Signed-off-by: Hamza Mahfooz<hamza.mahfooz@amd.com>
> ---
>   .../amd/display/amdgpu_dm/amdgpu_dm_debugfs.c | 72 ++++++-------------
>   1 file changed, 22 insertions(+), 50 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> index e783082a4eef..cbc241596c1f 100644
> --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_debugfs.c
> @@ -36,6 +36,7 @@
>   #include "dsc.h"
>   #include "link_hwss.h"
>   #include "dc/dc_dmub_srv.h"
> +#include "link/protocols/link_dp_capability.h"
>   
>   #ifdef CONFIG_DRM_AMD_SECURE_DISPLAY
>   #include "amdgpu_dm_psr.h"
> @@ -418,67 +419,38 @@ static ssize_t dp_phy_settings_read(struct file *f, char __user *buf,
>   	return result;
>   }
>   
> -static int dp_lttpr_status_show(struct seq_file *m, void *d)
> +static int dp_lttpr_status_show(struct seq_file *m, void *unused)
>   {
> -	char *data;
> -	struct amdgpu_dm_connector *connector = file_inode(m->file)->i_private;
> -	struct dc_link *link = connector->dc_link;
> -	uint32_t read_size = 1;
> -	uint8_t repeater_count = 0;
> +	struct drm_connector *connector = m->private;
> +	struct amdgpu_dm_connector *aconnector =
> +		to_amdgpu_dm_connector(connector);
> +	struct dc_lttpr_caps caps = aconnector->dc_link->dpcd_caps.lttpr_caps;
>   
> -	data = kzalloc(read_size, GFP_KERNEL);
> -	if (!data)
> -		return 0;
> +	if (connector->status != connector_status_connected)
> +		return -ENODEV;
>   
> -	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0002, data, read_size);
> +	seq_printf(m, "phy repeater count: %u (raw: 0x%x)\n",
> +		   dp_parse_lttpr_repeater_count(caps.phy_repeater_cnt),
> +		   caps.phy_repeater_cnt);
>   
> -	switch ((uint8_t)*data) {
> -	case 0x80:
> -		repeater_count = 1;
> -		break;
> -	case 0x40:
> -		repeater_count = 2;
> -		break;
> -	case 0x20:
> -		repeater_count = 3;
> -		break;
> -	case 0x10:
> -		repeater_count = 4;
> -		break;
> -	case 0x8:
> -		repeater_count = 5;
> -		break;
> -	case 0x4:
> -		repeater_count = 6;
> -		break;
> -	case 0x2:
> -		repeater_count = 7;
> +	seq_puts(m, "phy repeater mode: ");
> +
> +	switch (caps.mode) {
> +	case DP_PHY_REPEATER_MODE_TRANSPARENT:
> +		seq_puts(m, "transparent");
>   		break;
> -	case 0x1:
> -		repeater_count = 8;
> +	case DP_PHY_REPEATER_MODE_NON_TRANSPARENT:
> +		seq_puts(m, "non-transparent");
>   		break;
> -	case 0x0:
> -		repeater_count = 0;
> +	case 0x00:
> +		seq_puts(m, "non lttpr");
>   		break;
>   	default:
> -		repeater_count = (uint8_t)*data;
> +		seq_printf(m, "read error (raw: 0x%x)", caps.mode);
>   		break;
>   	}
>   
> -	seq_printf(m, "phy repeater count: %d\n", repeater_count);
> -
> -	dm_helpers_dp_read_dpcd(link->ctx, link, 0xF0003, data, read_size);
> -
> -	if ((uint8_t)*data == 0x55)
> -		seq_printf(m, "phy repeater mode: transparent\n");
> -	else if ((uint8_t)*data == 0xAA)
> -		seq_printf(m, "phy repeater mode: non-transparent\n");
> -	else if ((uint8_t)*data == 0x00)
> -		seq_printf(m, "phy repeater mode: non lttpr\n");
> -	else
> -		seq_printf(m, "phy repeater mode: read error\n");
> -
> -	kfree(data);
> +	seq_puts(m, "\n");
>   	return 0;
>   }
>   


Reviewed-by: Aurabindo Pillai <aurabindo.pillai@amd.com>

[-- Attachment #2: Type: text/html, Size: 4251 bytes --]

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-03 16:26 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-03 15:43 [PATCH] drm/amd/display: fix read errors pertaining to dp_lttpr_status_show() Hamza Mahfooz
2023-02-03 15:43 ` Hamza Mahfooz
2023-02-03 15:43 ` Hamza Mahfooz
2023-02-03 16:26 ` Aurabindo Pillai
2023-02-03 16:26   ` Aurabindo Pillai

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.