From patchwork Tue Jun 9 17:44:07 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kroah-Hartman X-Patchwork-Id: 187686 Delivered-To: patch@linaro.org Received: by 2002:a92:cf06:0:0:0:0:0 with SMTP id c6csp757648ilo; Tue, 9 Jun 2020 10:46:37 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzpPpU+GcpZugX5ojxwXw6ao3Aadivv37iUQtjr4OwS75P5zXymB1C5IlXg7oDxWspMQXGX X-Received: by 2002:a17:906:ce31:: with SMTP id sd17mr26492526ejb.255.1591724797099; Tue, 09 Jun 2020 10:46:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591724797; cv=none; d=google.com; s=arc-20160816; b=VSU1tjxI/sR6IXVscJk0+dweEUoqDFmJ0GY9hh3BSSGJk66v0axfOLdq29MgrsinrW a07AgMYcx6xgkRb85bHkZwr1pE123X4v+ClkgWo2QBAfK8F9oxg3RBtil3w+gbk4eVf+ C+ONGc2D4jlj7JYQtJSrSPjq/Fxl1Nu3K/1SHqLOjv0cnFW5G7nWvyg9LWlhCeR8MSNw YU1rGoeWnwkurtTMgiAjVmpwCyIUNAQe27Pq8RU43wXCdlW+lvcI6rx9uLsJY+Jf9ftZ LhyFnUbP/Zlt8c1XtGNWFweDTYe9KnF0iaJ2zIRv7gtfgROJdJBkQsbYlSqf33IztJUk ZxrA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=LANlOOjFtX9cgQaMwG1pZVKqKc8kZKon2X+RB3sEx5Y=; b=vH94i0i6vRqjMn5myk5NU3o8jvx38DBF/E9sFnd2jBYd0U+DDRSc1JKmMkFSLJdXjH 0+qm1ALf8K0RPOvunOpNtXuwfSn1kb315wRoD4dkRlsVEitkXHQRINpd7bOvWBXkPkFF cGQ4Gm3bnmv8ew8Togz7gQxHqgSKSIs2TyQ4xSKndPz2YaWURm2xYY8cuc771RojuqNF wgQbNr+U5/gI374DKb3zvgkhRfDScL3Xyg7Vohr4vChJf2/NRzfMnYVUnBQAwFRT4KQU BNJamJA2DehY1Z7PG12ho6k6Bl2bbIu9fNxD7cmqesoABYhJeJP/Vr78KZ24fw132Eq1 dJdA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=rclGf4Y3; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id md12si10300459ejb.431.2020.06.09.10.46.36; Tue, 09 Jun 2020 10:46:37 -0700 (PDT) Received-SPF: pass (google.com: domain of stable-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=@kernel.org header.s=default header.b=rclGf4Y3; spf=pass (google.com: domain of stable-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=stable-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731950AbgFIRqb (ORCPT + 15 others); Tue, 9 Jun 2020 13:46:31 -0400 Received: from mail.kernel.org ([198.145.29.99]:56408 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731928AbgFIRq0 (ORCPT ); Tue, 9 Jun 2020 13:46:26 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 59A972081A; Tue, 9 Jun 2020 17:46:24 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591724784; bh=HtOKJ+6AhzRcJp42rN8vMCosQZR/IW/NBwTb7UtPEfQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rclGf4Y3iN4zmI1W7O73mS+Rzjzby9epkvo98b0keK2AR+dzeHRJ9I0hsufxswY0j OuuPFl6Xo/eKHiRFdR3a5x0i0ic9CkvLlShc0yDhC2ZZ68Uf2BspiS1MCv9njNROEv cOCXDZ9n15rdULmdQ7lHk0xieLRjNqVi4ude1Usg= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, fengsheng , Xinwei Kong , Mark Brown , Sasha Levin Subject: [PATCH 4.4 07/36] spi: dw: use "smp_mb()" to avoid sending spi data error Date: Tue, 9 Jun 2020 19:44:07 +0200 Message-Id: <20200609173933.708823642@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609173933.288044334@linuxfoundation.org> References: <20200609173933.288044334@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Sender: stable-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: stable@vger.kernel.org From: Xinwei Kong [ Upstream commit bfda044533b213985bc62bd7ca96f2b984d21b80 ] Because of out-of-order execution about some CPU architecture, In this debug stage we find Completing spi interrupt enable -> prodrucing TXEI interrupt -> running "interrupt_transfer" function will prior to set "dw->rx and dws->rx_end" data, so this patch add memory barrier to enable dw->rx and dw->rx_end to be visible and solve to send SPI data error. eg: it will fix to this following low possibility error in testing environment which using SPI control to connect TPM Modules kernel: tpm tpm0: Operation Timed out kernel: tpm tpm0: tpm_relinquish_locality: : error -1 Signed-off-by: fengsheng Signed-off-by: Xinwei Kong Link: https://lore.kernel.org/r/1578019930-55858-1-git-send-email-kong.kongxinwei@hisilicon.com Signed-off-by: Mark Brown Signed-off-by: Sasha Levin --- drivers/spi/spi-dw.c | 3 +++ 1 file changed, 3 insertions(+) -- 2.25.1 diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 4edd38d03b93..5688591e9cd3 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -306,6 +306,9 @@ static int dw_spi_transfer_one(struct spi_master *master, dws->len = transfer->len; spin_unlock_irqrestore(&dws->buf_lock, flags); + /* Ensure dw->rx and dw->rx_end are visible */ + smp_mb(); + spi_enable_chip(dws, 0); /* Handle per transfer options for bpw and speed */