public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Benson Leung <bleung@google.com>
To: Prashant Malani <pmalani@chromium.org>
Cc: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev,
	bleung@chromium.org
Subject: Re: [PATCH] platform/chrome: cros_typec_vdm: Fix VDO copy
Date: Fri, 20 Jan 2023 10:50:51 -0800	[thread overview]
Message-ID: <Y8rii5gRTsi5jEP9@google.com> (raw)
In-Reply-To: <20230113182626.1149539-1-pmalani@chromium.org>

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

Hi Prashant,


On Fri, Jan 13, 2023 at 06:26:26PM +0000, Prashant Malani wrote:
> The usage of memcpy() affects the representation of the VDOs as they are
> copied to the EC Host Command buffer. Specifically, all higher order
> bits get dropped (for example: a VDO of 0x406 just gets copied as 0x6).
> 
> Avoid this by explicitly copying each VDO in the array. The number of
> VDOs generated by alternate mode drivers in their VDMs is almost always
> just 1 (apart from the header) so this doesn't affect performance in a
> meaningful way).
> 
> Fixes: 40a9b13a09ef ("platform/chrome: cros_typec_vdm: Add VDM send support")
> Signed-off-by: Prashant Malani <pmalani@chromium.org>

Reviewed-by: Benson Leung <bleung@chromium.org>


> ---
>  drivers/platform/chrome/cros_typec_vdm.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/platform/chrome/cros_typec_vdm.c b/drivers/platform/chrome/cros_typec_vdm.c
> index aca9d337118e..06f4a55999c5 100644
> --- a/drivers/platform/chrome/cros_typec_vdm.c
> +++ b/drivers/platform/chrome/cros_typec_vdm.c
> @@ -86,10 +86,12 @@ static int cros_typec_port_amode_vdm(struct typec_altmode *amode, const u32 hdr,
>  		.command = TYPEC_CONTROL_COMMAND_SEND_VDM_REQ,
>  	};
>  	struct typec_vdm_req vdm_req = {};
> +	int i;
>  
>  	vdm_req.vdm_data[0] = hdr;
>  	vdm_req.vdm_data_objects = cnt;
> -	memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1);
> +	for (i = 1; i < cnt; i++)
> +		vdm_req.vdm_data[i] = vdo[i-1];
>  	vdm_req.partner_type = TYPEC_PARTNER_SOP;
>  	req.vdm_req_params = vdm_req;
>  
> -- 
> 2.39.0.314.g84b9a713c41-goog
> 
> 

-- 
Benson Leung
Staff Software Engineer
Chrome OS Kernel
Google Inc.
bleung@google.com
Chromium OS Project
bleung@chromium.org

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

  reply	other threads:[~2023-01-20 18:51 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-01-13 18:26 [PATCH] platform/chrome: cros_typec_vdm: Fix VDO copy Prashant Malani
2023-01-20 18:50 ` Benson Leung [this message]
2023-01-24 19:10 ` patchwork-bot+chrome-platform
2023-01-26 19:50 ` patchwork-bot+chrome-platform
2023-01-31  3:49 ` Tzung-Bi Shih
2023-01-31 18:17   ` Prashant Malani

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=Y8rii5gRTsi5jEP9@google.com \
    --to=bleung@google.com \
    --cc=bleung@chromium.org \
    --cc=chrome-platform@lists.linux.dev \
    --cc=linux-kernel@vger.kernel.org \
    --cc=pmalani@chromium.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