From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 2E7AEC05027 for ; Fri, 20 Jan 2023 18:51:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230072AbjATSvB (ORCPT ); Fri, 20 Jan 2023 13:51:01 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56136 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229379AbjATSu7 (ORCPT ); Fri, 20 Jan 2023 13:50:59 -0500 Received: from mail-pf1-x433.google.com (mail-pf1-x433.google.com [IPv6:2607:f8b0:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DC0A75421A for ; Fri, 20 Jan 2023 10:50:58 -0800 (PST) Received: by mail-pf1-x433.google.com with SMTP id i65so4697065pfc.0 for ; Fri, 20 Jan 2023 10:50:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=gM0RsfTuHckuor3p1wTydYsMS7aWIixLNSsGgZZKJcI=; b=RvC9LKPrewaHEB4mXhWw5HrT0pd9A85zqjbzTTDS2FlcDk5UBhjFjfWTKzyI6c7WC9 GdHzuStMSR7RJM3rV/X8/C3hqA7EflZWdB08ngv1tN39gXPfPRrjZmSiQhorlAWbm/oO DHi1fLdZuCQDbrQjJwSBf4y5D/LvFfd3aGeu2kVudVYXL8uH7UoyUt0yFIxgsMe2oq7M rg/bYnbqJx26UjtHURTVXj5Zv1yCnPKH2XCYVCBb5msCX2RvCj5rFYoQmhIvLcv/5qRf xeTG5m5SwI51IuLRNZnUvYrJ+qRRjxxGY+AtzDBKB2oTAFo3UOzvAr95zhzQqASl3pa0 OcgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=gM0RsfTuHckuor3p1wTydYsMS7aWIixLNSsGgZZKJcI=; b=Q//GU75Z2cr6Lb9nfrDH6IwhhV9BzCnMU5Jni+i11hQ791Qs2jh24GbsB1RASRFDV1 b4rrJxhWNv8+nTiTKS2I6hThQQ8zxIzlC79l31687pz2YUXV1sr+gwNJEERatDWP8BLl UKHSE+sUmX+ND/QLyT7s65Sr4U5bOoFqdw4RQloQ0TI2bOLK0/Agtnfh+WoFVYi817cY 7MesRjeRMaU9SwTmR0GnRn7pJTLqsVCooZyBjODt4WM1xxU/ndvgmEXePLGwJg+uuL2h IQtWepGAMD9jmw4PHU+k3UnW1+w+dwGUv6Q6/W0+fFulXs/0DNCwfIRTHk7n4tHHBTPM 6vaQ== X-Gm-Message-State: AFqh2kpbAMpUztgDI0AI0DkASNztCumX00RreCTQrgzxXPJGMR0yXV6z aQ8MbJNnFkTrKrTUpbwXpSOU1g== X-Google-Smtp-Source: AMrXdXuci1ryQcAp1fGQy5qxEJbH7tBxHv5qkbFfxY7kSWv2Okz0AC9wEQnvzJvLW0/xnnmEJ2t3IQ== X-Received: by 2002:aa7:8692:0:b0:582:13b5:d735 with SMTP id d18-20020aa78692000000b0058213b5d735mr287483pfo.0.1674240657900; Fri, 20 Jan 2023 10:50:57 -0800 (PST) Received: from google.com ([2620:15c:9d:2:67ba:96c6:d11f:daaa]) by smtp.gmail.com with ESMTPSA id a7-20020aa795a7000000b0058da56f8b95sm10043637pfk.115.2023.01.20.10.50.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 20 Jan 2023 10:50:56 -0800 (PST) Date: Fri, 20 Jan 2023 10:50:51 -0800 From: Benson Leung To: Prashant Malani 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 Message-ID: References: <20230113182626.1149539-1-pmalani@chromium.org> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha512; protocol="application/pgp-signature"; boundary="OAoGfFgmeh+HrIz6" Content-Disposition: inline In-Reply-To: <20230113182626.1149539-1-pmalani@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --OAoGfFgmeh+HrIz6 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable 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). >=20 > 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). >=20 > Fixes: 40a9b13a09ef ("platform/chrome: cros_typec_vdm: Add VDM send suppo= rt") > Signed-off-by: Prashant Malani Reviewed-by: Benson Leung > --- > drivers/platform/chrome/cros_typec_vdm.c | 4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) >=20 > 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_alt= mode *amode, const u32 hdr, > .command =3D TYPEC_CONTROL_COMMAND_SEND_VDM_REQ, > }; > struct typec_vdm_req vdm_req =3D {}; > + int i; > =20 > vdm_req.vdm_data[0] =3D hdr; > vdm_req.vdm_data_objects =3D cnt; > - memcpy(&vdm_req.vdm_data[1], vdo, cnt - 1); > + for (i =3D 1; i < cnt; i++) > + vdm_req.vdm_data[i] =3D vdo[i-1]; > vdm_req.partner_type =3D TYPEC_PARTNER_SOP; > req.vdm_req_params =3D vdm_req; > =20 > --=20 > 2.39.0.314.g84b9a713c41-goog >=20 >=20 --=20 Benson Leung Staff Software Engineer Chrome OS Kernel Google Inc. bleung@google.com Chromium OS Project bleung@chromium.org --OAoGfFgmeh+HrIz6 Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iHUEABYKAB0WIQQCtZK6p/AktxXfkOlzbaomhzOwwgUCY8riiwAKCRBzbaomhzOw wuSDAQDrAanTBr12LLmQByxqlHex86Ytxgmmh88UxOsHHk7ErQD+N+tIc7j/HkyR SOclTL6OB8jx/nYJB82XlIY21rPARgo= =AmzF -----END PGP SIGNATURE----- --OAoGfFgmeh+HrIz6--