Received: by 2002:a05:6a10:2785:0:0:0:0 with SMTP id ia5csp21644pxb; Fri, 15 Jan 2021 04:55:48 -0800 (PST) X-Google-Smtp-Source: ABdhPJwtl8ko2LiU5Am3aLSz5lEpRMRcQIHXIYtyYr0GOZrWg9k5A1bdREA86cV+7mpTZU/Y/ArV X-Received: by 2002:a05:6402:ca2:: with SMTP id cn2mr9376760edb.137.1610715348460; Fri, 15 Jan 2021 04:55:48 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1610715348; cv=none; d=google.com; s=arc-20160816; b=lhIXmg45XU7hw48fy4yQqf1dAJyvCTRwmfG1vMcjY2dZQKUXE5w3pwOom6yAZ8XceD FIs/Yuhaqh3CIYVS7scnfffWSFTV3JNd5Vz6T+VpxAAgzt1vQ8NQzlyMsGkwcb0LFR7H Z+en51aqx2T0eEDb70/0fa57Qq5kxGw118W83rm82ptfHSx5aFS9XTJsrxfLje3dy3O1 JCcbbTlGVUro5fJhyMIg0CDyy3SLkeJ0axLxCApfG8k4fxeUXaNhP2jHopm+40USrk0t cyjKGsIBfuS4mgDdT7SVAh/pYyEBgEYghCbpean7GMJQWIC5qmxaPkOK7fyBSizDydJa ALyw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=kA0BqFqtOak6sWJdh5NuX53qa7MO40+4U5m9e1uwapM=; b=r6KLmDqizOw2yCFBhrffzkS2cIeS/8HlLo+6pK6nhklh0yaQfEBjJiFzclzBvl4rWs 280MUsR0Dw6XgC5L3nBRpsi7yBEz+gHEdLEMjX98qiz4BsquZAXmM5CUqyU3gQ/1AhPw OMm7Q5vT2uboeCP/XaNhMXAeB5y6udS3vRlC3a0imIW9qI8ls0dGbolQoSEpMdoAzu27 O1taoWlJW4T4GU9+gjpCzYNfe7+byjaIrNW0mkZaRk6Wyc0/QviJFSHiZiGTrn9TQ3UL AbgzDXW1Lifk8bjMt9FQO92o+vSZ4Ro93FbOlzIQBC0IYViNGKQ/OPtdvWbiZcOoSZ6d pldQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JQFeVstF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id hs17si3518705ejc.661.2021.01.15.04.55.08; Fri, 15 Jan 2021 04:55:48 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=JQFeVstF; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2387687AbhAOMyg (ORCPT + 99 others); Fri, 15 Jan 2021 07:54:36 -0500 Received: from mail.kernel.org ([198.145.29.99]:42602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2387696AbhAOMfc (ORCPT ); Fri, 15 Jan 2021 07:35:32 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id C96E6235F8; Fri, 15 Jan 2021 12:34:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1610714092; bh=gAuB4bxz3JyCVSL+w75fTiFRumZx+0gm9gjg+URFPoA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JQFeVstFotSFmuIeToTXThOyaQDD8qGpAs7hbJl5k9JuEMi2v14cFYr01wnbx/g6g 6MPgfztHEXoBFFrhbupkgr2hIBTjEuWnHrpoL3pcC9IVGpZR9eXIXCgSXzrTLp2foD bCpRz+bpkTBtJPcsi3Ga0NeVMEIAaR8iLCtpp6pI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Roman Guskov , Marek Vasut , Mark Brown Subject: [PATCH 5.4 41/62] spi: stm32: FIFO threshold level - fix align packet size Date: Fri, 15 Jan 2021 13:28:03 +0100 Message-Id: <20210115122000.381353872@linuxfoundation.org> X-Mailer: git-send-email 2.30.0 In-Reply-To: <20210115121958.391610178@linuxfoundation.org> References: <20210115121958.391610178@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Roman Guskov commit a590370d918fc66c62df6620445791fbe840344a upstream. if cur_bpw <= 8 and xfer_len < 4 then the value of fthlv will be 1 and SPI registers content may have been lost. * If SPI data register is accessed as a 16-bit register and DSIZE <= 8bit, better to select FTHLV = 2, 4, 6 etc * If SPI data register is accessed as a 32-bit register and DSIZE > 8bit, better to select FTHLV = 2, 4, 6 etc, while if DSIZE <= 8bit, better to select FTHLV = 4, 8, 12 etc Signed-off-by: Roman Guskov Fixes: dcbe0d84dfa5 ("spi: add driver for STM32 SPI controller") Reviewed-by: Marek Vasut Link: https://lore.kernel.org/r/20201221123532.27272-1-rguskov@dh-electronics.com Signed-off-by: Mark Brown Signed-off-by: Greg Kroah-Hartman --- drivers/spi/spi-stm32.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) --- a/drivers/spi/spi-stm32.c +++ b/drivers/spi/spi-stm32.c @@ -494,9 +494,9 @@ static u32 stm32h7_spi_prepare_fthlv(str /* align packet size with data registers access */ if (spi->cur_bpw > 8) - fthlv -= (fthlv % 2); /* multiple of 2 */ + fthlv += (fthlv % 2) ? 1 : 0; else - fthlv -= (fthlv % 4); /* multiple of 4 */ + fthlv += (fthlv % 4) ? (4 - (fthlv % 4)) : 0; if (!fthlv) fthlv = 1;