Received: by 2002:a05:6358:a55:b0:ec:fcf4:3ecf with SMTP id 21csp3090423rwb; Fri, 20 Jan 2023 11:03:21 -0800 (PST) X-Google-Smtp-Source: AMrXdXu9pu7HB2NMZA1qa5n8Fym23aPdZknoyXYhA7F8KwIBAlq4VQTP8J7k5vyzyOnj4QFwvD9B X-Received: by 2002:a17:90a:d344:b0:229:4b4f:99e7 with SMTP id i4-20020a17090ad34400b002294b4f99e7mr16960031pjx.16.1674241401292; Fri, 20 Jan 2023 11:03:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1674241401; cv=none; d=google.com; s=arc-20160816; b=NNz5cpQnAw9QLWc0F+AkBfi4Z+bw78rWBFsv0c4OKDF0lDoS0/K9H3whAAugeWaObB OVcuZCG3HO/GB8HvCRqHQWALC2V7XZvufgqqdLeq3t9uzvqAcA0kpWARZpJADC5UtAqM +iJf2Or/xKiE2JIj9aGTLM4Hm74YzxjMbGflqIwNAlCDuaYJdMhODFwtQC6oWWqe15pS 3Y+l88aA5H/O9W2iShFEQw0l2vmlG9fO++9Gzr4pGcNZPdbwzSM03OpSQOqcclP/kPYu jXslUi84ltUv5+fiW6Y5c8HTkf7fy0pG4H8wTGXgcrjUQJIGSLnzj2VKawUJ1SMUqSf0 Sliw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=gM0RsfTuHckuor3p1wTydYsMS7aWIixLNSsGgZZKJcI=; b=R6pJrzCWFtusmFjJZoDr7Bk/yWsIi5Z6jCugLsyM9yubcrKw88I2HasMjZvsMRvsO3 Rlerc23HeiPC3lD0yFHrCutYWIfmWpefZbxs68zMJkvfl6//KswdmrnWQCBwxwUbK4Xi T7VjigDsY9fNgEHaD/BHGnIvJhzsPxttAUfXD6eguVoDg7jLRTA2bGXfU53pvM6qJmo8 j9uYzvAXhE4cJpmbREoRYQLczeo09DLlTEO7nulYfeUHq7YZ+msM9AvCXabChJvyPeIW Zzo55dEBClPhateuGuz/dru8Wh/h9vNTizbGJVFeW9kpn7dKUZZd5+iyJ+zzsdSPKZ1D xuXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RvC9LKPr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id l72-20020a63914b000000b004cc67cfc92bsi11360709pge.97.2023.01.20.11.03.15; Fri, 20 Jan 2023 11:03:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@google.com header.s=20210112 header.b=RvC9LKPr; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230017AbjATSvA (ORCPT + 50 others); Fri, 20 Jan 2023 13:51:00 -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-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> X-Spam-Status: No, score=-17.6 required=5.0 tests=BAYES_00,DKIMWL_WL_MED, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF, ENV_AND_HDR_SPF_MATCH,RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS, USER_IN_DEF_DKIM_WL,USER_IN_DEF_SPF_WL autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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--