From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A9EA5629 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> Precedence: bulk X-Mailing-List: chrome-platform@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230113182626.1149539-1-pmalani@chromium.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));