From nobody Mon Sep 15 05:51:49 2025 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 2F335C54EBD for ; Fri, 13 Jan 2023 18:30:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231154AbjAMSa4 (ORCPT ); Fri, 13 Jan 2023 13:30:56 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41718 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231222AbjAMSaP (ORCPT ); Fri, 13 Jan 2023 13:30:15 -0500 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D2C786C075 for ; Fri, 13 Jan 2023 10:26:37 -0800 (PST) Received: by mail-pg1-x530.google.com with SMTP id b12so15548477pgj.6 for ; Fri, 13 Jan 2023 10:26:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=v0IZMQ5s013CKLPMbvZH+OUmUx07zKwii/Tta4BO8NQ=; b=ochu6DRcIo08TOd/D8jh5Tf6fdQOlvs9XXYjw9VXWD1QJ6nUv0zY1YEEzocAoEf7eY KCIsfp9Pm0V31jq97KHsb3tRLRE3N47wfuTygppoSTRhrSQi5WYjrUvSGpCC4JieBiEG AbszzxRfLaJChuj8z9UUCZcoaCnKZx24qa+k0= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=v0IZMQ5s013CKLPMbvZH+OUmUx07zKwii/Tta4BO8NQ=; b=ofr+tU9Q4A4zjWllXKTRP2MBy9wYAC0byM40zVTu9Yq4UIwaswAvWSvM2YA1wI2b/x CUyCA8SyUXy1Np9hWqlrKO26AFzNlipHIAELogsn3gXOe//IKSTmNtVKYfTyOBNuqUhc AP+yhyTlRhAhCdf6v4FjC8laTFRXAGR4XhiY3mvmlprGqIEXEkdIPKELvtHozjpvpnFg ueL3cn/P7vuv2XuLN5R0zc2sbXjtSJm2CSTYp2IEPfJsFZ/h5rnACUEnrShLiEHee11H 8NLGuvMHdSgq6yGCw2ZSnk6ntFBpx/u+TZ///geBAlULUATI7ujVEnvi+o001MTwuNVo +kow== X-Gm-Message-State: AFqh2kpgzUVVHCXEeN/XSQbZ8ZM6IQiHnU+vkP7YoevpJhMElF5JAkF8 5dobfOdR+DoRFfmFqmd+lh0miSwETwnISwpx X-Google-Smtp-Source: AMrXdXvKc6B2+yqll8S678mrWE5J7iNXmXppKsc/lXs6VFCK7Gm1J1hzHJNPpJii6evUmrWWOnijuQ== X-Received: by 2002:a62:2903:0:b0:57f:f2cd:6180 with SMTP id p3-20020a622903000000b0057ff2cd6180mr74775013pfp.0.1673634397061; Fri, 13 Jan 2023 10:26:37 -0800 (PST) Received: from pmalani.c.googlers.com.com (33.5.83.34.bc.googleusercontent.com. [34.83.5.33]) by smtp.gmail.com with ESMTPSA id 124-20020a621882000000b0057709fce782sm9330183pfy.54.2023.01.13.10.26.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 13 Jan 2023 10:26:36 -0800 (PST) From: Prashant Malani To: linux-kernel@vger.kernel.org, chrome-platform@lists.linux.dev Cc: bleung@chromium.org, Prashant Malani Subject: [PATCH] platform/chrome: cros_typec_vdm: Fix VDO copy Date: Fri, 13 Jan 2023 18:26:26 +0000 Message-Id: <20230113182626.1149539-1-pmalani@chromium.org> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 Reviewed-by: Benson Leung --- 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/ch= rome/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_altmo= de *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