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 4889EC636D3 for ; Tue, 31 Jan 2023 03:49:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230028AbjAaDtm (ORCPT ); Mon, 30 Jan 2023 22:49:42 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:58588 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229542AbjAaDti (ORCPT ); Mon, 30 Jan 2023 22:49:38 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 65BEB4238 for ; Mon, 30 Jan 2023 19:49:38 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id F052361374 for ; Tue, 31 Jan 2023 03:49:37 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 930FDC433D2; Tue, 31 Jan 2023 03:49:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1675136977; bh=WZinc5g/K2KR61zeipZWfTaYVkSWEpLMMfI/qDV397g=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=UcY8xaq5D79gFEHzB78Hp9fkZY5cbkUYg0+HZNC+Oo6lE/oGR6MecfZueTBZxHVSe VPEItY6SwP/w5hKDopSlBJ3xLW0djU3eQWl+1LYT91UTmUY5bxAudKN/+UIt/MWMB1 HDMYFj9zSmK9gkGqavi3e/Sj8G4zhdSQ1rbqPD4JU7cuG2L8MveT0yZNBpDKOFiWDh 5hFMqwlXgoCqQ3aCRs34DZLkUrWHLdCt8YG450qS7bf3U7XEsJRAHABi3Xqe3eW0p/ DY8zchkxyoZhpEvj2Ai/TIIDzlT0ScG8jGo0qLjqW8JLsHYFInTcSt0nYZxkaRJled 1TGYAaLyL8eTw== Date: Tue, 31 Jan 2023 11:49:34 +0800 From: Tzung-Bi Shih 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: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230113182626.1149539-1-pmalani@chromium.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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). memcpy() is byte-oriented; however, `vdo` is a pointer to u32. > 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). Although the patch has applied, I am wondering if the following would be a better way to fix the issue: memcpy(&vdm_req.vdm_data[1], vdo, (cnt - 1) * sizeof(*vdo));