dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Jani Nikula <jani.nikula-VuQAYsv1563Yd54FQh9/CA@public.gmane.org>
To: dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org,
	amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
Cc: manasi.d.navare-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org,
	Jerry.Zuo-5C7GfCeVMHo@public.gmane.org
Subject: Re: [PATCH 1/2] drm: Add support for DP 1.4 Compliance edid corruption test 4.2.2.6
Date: Fri, 01 Nov 2019 16:07:29 +0200	[thread overview]
Message-ID: <87bltv8zby.fsf@intel.com> (raw)
In-Reply-To: <20191030210844.19803-2-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>

On Wed, 30 Oct 2019, "Jerry (Fangzhi) Zuo" <Jerry.Zuo@amd.com> wrote:
> DP 1.4 edid corruption test requires source DUT to write calculated
> CRC, not the corrupted CRC from reference sink.
>
> Return the calculated CRC back, and initiate the required sequence.
>
> Signed-off-by: Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_edid.c      | 15 ++++++++++++---
>  include/drm/drm_connector.h     |  7 +++++++
>  include/drm/drm_dp_helper.h     |  3 +++
>  4 files changed, 58 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index ffc68d305afe..75dbd30c62a7 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -336,6 +336,42 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
>  }
>  EXPORT_SYMBOL(drm_dp_dpcd_read_link_status);
>  
> +/**
> +  * drm_dp_send_bad_edid_checksum() - send back real edid checksum value
> +  * @aux: DisplayPort AUX channel
> +  * @bad_edid_checksum: real edid checksum for the last block
> +  *
> +  * Returns true on success
> +  */
> +bool drm_dp_send_bad_edid_checksum(struct drm_dp_aux *aux,
> +                                u8 bad_edid_checksum)
> +{
> +        u8 link_edid_read = 0, auto_test_req = 0;
> +        u8 test_resp = 0;
> +
> +        drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1);
> +        auto_test_req &= DP_AUTOMATED_TEST_REQUEST;
> +
> +        drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1);
> +        link_edid_read &= DP_TEST_LINK_EDID_READ;
> +
> +        if (!auto_test_req || !link_edid_read) {
> +                DRM_DEBUG_KMS("Source DUT does not support TEST_EDID_READ\n");
> +                return false;
> +        }
> +
> +        drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1);
> +
> +        /* send back checksum for the last edid extension block data */
> +        drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, &bad_edid_checksum, 1);
> +
> +        test_resp |= DP_TEST_EDID_CHECKSUM_WRITE;
> +        drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1);
> +
> +        return true;
> +}
> +EXPORT_SYMBOL(drm_dp_send_bad_edid_checksum);
> +
>  /**
>   * drm_dp_link_probe() - probe a DisplayPort link for capabilities
>   * @aux: DisplayPort AUX channel
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 82a4ceed3fcf..400064dcc010 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1344,13 +1344,19 @@ static void drm_get_displayid(struct drm_connector *connector,
>  			      struct edid *edid);
>  static int validate_displayid(u8 *displayid, int length, int idx);
>  
> -static int drm_edid_block_checksum(const u8 *raw_edid)
> +static int drm_edid_block_checksum(const u8 *raw_edid, bool c)
>  {
>  	int i;
>  	u8 csum = 0;
> -	for (i = 0; i < EDID_LENGTH; i++)
> +	u8 len;
> +
> +	len = c ? EDID_LENGTH : (EDID_LENGTH - 1);
> +
> +	for (i = 0; i < len; i++)
>  		csum += raw_edid[i];
>  
> +	csum = c ? csum : (0x100 - csum);
> +
>  	return csum;
>  }

I think a mysterious boolean 'c' argument just makes this more
confusing.

Please split the function to two, one that calculates the checksum (c ==
false case) and another that uses the function (c == true case). The
latter would return the same value as the above.

Please do this as a prep patch without any of the other modifications.

BR,
Jani.



>  
> @@ -1408,7 +1414,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
>  		}
>  	}
>  
> -	csum = drm_edid_block_checksum(raw_edid);
> +	csum = drm_edid_block_checksum(raw_edid, true);
>  	if (csum) {
>  		if (edid_corrupt)
>  			*edid_corrupt = true;
> @@ -1572,6 +1578,9 @@ static void connector_bad_edid(struct drm_connector *connector,
>  			       prefix, DUMP_PREFIX_NONE, 16, 1,
>  			       block, EDID_LENGTH, false);
>  	}
> +
> +	/* Calculate real checksum for the last edid extension block data */
> +	connector->bad_edid_checksum = drm_edid_block_checksum(edid + edid[0x7e] * EDID_LENGTH, false);
>  }
>  
>  /* Get override or firmware EDID */
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 681cb590f952..8442461542b9 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1345,6 +1345,13 @@ struct drm_connector {
>  	 * rev1.1 4.2.2.6
>  	 */
>  	bool edid_corrupt;
> +	/**
> +         * @bad_edid_checksum: real edid checksum value for corrupted edid block.
> +         * Required in Displayport 1.4 compliance testing
> +         * rev1.1 4.2.2.6
> +         */
> +        uint8_t bad_edid_checksum;
> +
>  
>  	/** @debugfs_entry: debugfs directory for this connector */
>  	struct dentry *debugfs_entry;
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 5a795075d5da..2a7e54bebb18 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -1383,6 +1383,9 @@ static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux,
>  int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
>  				 u8 status[DP_LINK_STATUS_SIZE]);
>  
> +bool drm_dp_send_bad_edid_checksum(struct drm_dp_aux *aux,
> +				u8 bad_edid_checksum);
> +
>  /*
>   * DisplayPort link
>   */

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

WARNING: multiple messages have this Message-ID (diff)
From: Jani Nikula <jani.nikula@linux.intel.com>
To: "Jerry \(Fangzhi\) Zuo" <Jerry.Zuo@amd.com>,
	dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org
Cc: manasi.d.navare@intel.com, Jerry.Zuo@amd.com
Subject: Re: [PATCH 1/2] drm: Add support for DP 1.4 Compliance edid corruption test 4.2.2.6
Date: Fri, 01 Nov 2019 16:07:29 +0200	[thread overview]
Message-ID: <87bltv8zby.fsf@intel.com> (raw)
Message-ID: <20191101140729.FNypUTNGryQToTE3tUwWkDTCKv6xt_Dj0m8duoBvZB8@z> (raw)
In-Reply-To: <20191030210844.19803-2-Jerry.Zuo@amd.com>

On Wed, 30 Oct 2019, "Jerry (Fangzhi) Zuo" <Jerry.Zuo@amd.com> wrote:
> DP 1.4 edid corruption test requires source DUT to write calculated
> CRC, not the corrupted CRC from reference sink.
>
> Return the calculated CRC back, and initiate the required sequence.
>
> Signed-off-by: Jerry (Fangzhi) Zuo <Jerry.Zuo@amd.com>
> ---
>  drivers/gpu/drm/drm_dp_helper.c | 36 ++++++++++++++++++++++++++++++++++++
>  drivers/gpu/drm/drm_edid.c      | 15 ++++++++++++---
>  include/drm/drm_connector.h     |  7 +++++++
>  include/drm/drm_dp_helper.h     |  3 +++
>  4 files changed, 58 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_dp_helper.c b/drivers/gpu/drm/drm_dp_helper.c
> index ffc68d305afe..75dbd30c62a7 100644
> --- a/drivers/gpu/drm/drm_dp_helper.c
> +++ b/drivers/gpu/drm/drm_dp_helper.c
> @@ -336,6 +336,42 @@ int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
>  }
>  EXPORT_SYMBOL(drm_dp_dpcd_read_link_status);
>  
> +/**
> +  * drm_dp_send_bad_edid_checksum() - send back real edid checksum value
> +  * @aux: DisplayPort AUX channel
> +  * @bad_edid_checksum: real edid checksum for the last block
> +  *
> +  * Returns true on success
> +  */
> +bool drm_dp_send_bad_edid_checksum(struct drm_dp_aux *aux,
> +                                u8 bad_edid_checksum)
> +{
> +        u8 link_edid_read = 0, auto_test_req = 0;
> +        u8 test_resp = 0;
> +
> +        drm_dp_dpcd_read(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1);
> +        auto_test_req &= DP_AUTOMATED_TEST_REQUEST;
> +
> +        drm_dp_dpcd_read(aux, DP_TEST_REQUEST, &link_edid_read, 1);
> +        link_edid_read &= DP_TEST_LINK_EDID_READ;
> +
> +        if (!auto_test_req || !link_edid_read) {
> +                DRM_DEBUG_KMS("Source DUT does not support TEST_EDID_READ\n");
> +                return false;
> +        }
> +
> +        drm_dp_dpcd_write(aux, DP_DEVICE_SERVICE_IRQ_VECTOR, &auto_test_req, 1);
> +
> +        /* send back checksum for the last edid extension block data */
> +        drm_dp_dpcd_write(aux, DP_TEST_EDID_CHECKSUM, &bad_edid_checksum, 1);
> +
> +        test_resp |= DP_TEST_EDID_CHECKSUM_WRITE;
> +        drm_dp_dpcd_write(aux, DP_TEST_RESPONSE, &test_resp, 1);
> +
> +        return true;
> +}
> +EXPORT_SYMBOL(drm_dp_send_bad_edid_checksum);
> +
>  /**
>   * drm_dp_link_probe() - probe a DisplayPort link for capabilities
>   * @aux: DisplayPort AUX channel
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 82a4ceed3fcf..400064dcc010 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -1344,13 +1344,19 @@ static void drm_get_displayid(struct drm_connector *connector,
>  			      struct edid *edid);
>  static int validate_displayid(u8 *displayid, int length, int idx);
>  
> -static int drm_edid_block_checksum(const u8 *raw_edid)
> +static int drm_edid_block_checksum(const u8 *raw_edid, bool c)
>  {
>  	int i;
>  	u8 csum = 0;
> -	for (i = 0; i < EDID_LENGTH; i++)
> +	u8 len;
> +
> +	len = c ? EDID_LENGTH : (EDID_LENGTH - 1);
> +
> +	for (i = 0; i < len; i++)
>  		csum += raw_edid[i];
>  
> +	csum = c ? csum : (0x100 - csum);
> +
>  	return csum;
>  }

I think a mysterious boolean 'c' argument just makes this more
confusing.

Please split the function to two, one that calculates the checksum (c ==
false case) and another that uses the function (c == true case). The
latter would return the same value as the above.

Please do this as a prep patch without any of the other modifications.

BR,
Jani.



>  
> @@ -1408,7 +1414,7 @@ bool drm_edid_block_valid(u8 *raw_edid, int block, bool print_bad_edid,
>  		}
>  	}
>  
> -	csum = drm_edid_block_checksum(raw_edid);
> +	csum = drm_edid_block_checksum(raw_edid, true);
>  	if (csum) {
>  		if (edid_corrupt)
>  			*edid_corrupt = true;
> @@ -1572,6 +1578,9 @@ static void connector_bad_edid(struct drm_connector *connector,
>  			       prefix, DUMP_PREFIX_NONE, 16, 1,
>  			       block, EDID_LENGTH, false);
>  	}
> +
> +	/* Calculate real checksum for the last edid extension block data */
> +	connector->bad_edid_checksum = drm_edid_block_checksum(edid + edid[0x7e] * EDID_LENGTH, false);
>  }
>  
>  /* Get override or firmware EDID */
> diff --git a/include/drm/drm_connector.h b/include/drm/drm_connector.h
> index 681cb590f952..8442461542b9 100644
> --- a/include/drm/drm_connector.h
> +++ b/include/drm/drm_connector.h
> @@ -1345,6 +1345,13 @@ struct drm_connector {
>  	 * rev1.1 4.2.2.6
>  	 */
>  	bool edid_corrupt;
> +	/**
> +         * @bad_edid_checksum: real edid checksum value for corrupted edid block.
> +         * Required in Displayport 1.4 compliance testing
> +         * rev1.1 4.2.2.6
> +         */
> +        uint8_t bad_edid_checksum;
> +
>  
>  	/** @debugfs_entry: debugfs directory for this connector */
>  	struct dentry *debugfs_entry;
> diff --git a/include/drm/drm_dp_helper.h b/include/drm/drm_dp_helper.h
> index 5a795075d5da..2a7e54bebb18 100644
> --- a/include/drm/drm_dp_helper.h
> +++ b/include/drm/drm_dp_helper.h
> @@ -1383,6 +1383,9 @@ static inline ssize_t drm_dp_dpcd_writeb(struct drm_dp_aux *aux,
>  int drm_dp_dpcd_read_link_status(struct drm_dp_aux *aux,
>  				 u8 status[DP_LINK_STATUS_SIZE]);
>  
> +bool drm_dp_send_bad_edid_checksum(struct drm_dp_aux *aux,
> +				u8 bad_edid_checksum);
> +
>  /*
>   * DisplayPort link
>   */

-- 
Jani Nikula, Intel Open Source Graphics Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

  parent reply	other threads:[~2019-11-01 14:07 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-10-30 21:08 [PATCH 0/2] Changes for DP 1.4 Compliance test 4.2.2.6 Jerry (Fangzhi) Zuo
2019-10-30 21:08 ` Jerry (Fangzhi) Zuo
     [not found] ` <20191030210844.19803-1-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-10-30 21:08   ` [PATCH 1/2] drm: Add support for DP 1.4 Compliance edid corruption " Jerry (Fangzhi) Zuo
2019-10-30 21:08     ` Jerry (Fangzhi) Zuo
     [not found]     ` <20191030210844.19803-2-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-11-01 14:07       ` Jani Nikula [this message]
2019-11-01 14:07         ` Jani Nikula
2019-11-01 19:38       ` [PATCH v2 " Jerry (Fangzhi) Zuo
2019-11-01 19:38         ` Jerry (Fangzhi) Zuo
     [not found]         ` <20191101193839.25582-1-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-11-01 20:57           ` Harry Wentland
2019-11-01 20:57             ` Harry Wentland
2019-11-04 14:00         ` Jani Nikula
2019-11-04 14:00           ` Jani Nikula
2019-11-04 21:11         ` [PATCH v3] " Jerry (Fangzhi) Zuo
2019-11-04 21:11           ` Jerry (Fangzhi) Zuo
     [not found]           ` <20191104211145.30553-1-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-11-05 16:37             ` [PATCH v4] " Jerry (Fangzhi) Zuo
2019-11-05 16:37               ` Jerry (Fangzhi) Zuo
     [not found]               ` <20191105163740.3093-1-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-11-25 21:36                 ` Zuo, Jerry
2019-11-25 21:36                   ` Zuo, Jerry
     [not found]                   ` <DM5PR12MB1705A4E4102731AF4BDB00CDE54A0-2J9CzHegvk9755J/8u8g5AdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-11-26 18:39                     ` Harry Wentland
2019-11-26 18:39                       ` Harry Wentland
2019-10-30 21:08   ` [PATCH 2/2] drm/amd/display: Hook up drm interface for DP 1.4 edid corruption test Jerry (Fangzhi) Zuo
2019-10-30 21:08     ` Jerry (Fangzhi) Zuo
     [not found]     ` <20191030210844.19803-3-Jerry.Zuo-5C7GfCeVMHo@public.gmane.org>
2019-11-04 21:13       ` [PATCH v2] " Jerry (Fangzhi) Zuo
2019-11-04 21:13         ` Jerry (Fangzhi) Zuo

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87bltv8zby.fsf@intel.com \
    --to=jani.nikula-vuqaysv1563yd54fqh9/ca@public.gmane.org \
    --cc=Jerry.Zuo-5C7GfCeVMHo@public.gmane.org \
    --cc=amd-gfx-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=dri-devel-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org \
    --cc=manasi.d.navare-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox