From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-9.8 required=3.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI, SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27948C433DF for ; Fri, 5 Jun 2020 14:19:44 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 011BD2086A for ; Fri, 5 Jun 2020 14:19:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591366784; bh=sXJRCZe3wSoZKHyLoHmplsdTx1p8e9SXjjR3pDu+tIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:List-ID:From; b=irfquoDeNruvIp8nz/Iu4190RuAKkdd1QN28pG5AbrNKgbz3MhJYtL6QpSnJk3PNi uTrqtMO19keXi0B1CStgVTuggjM3ok9Cuv0xX/tfTXdHvjxbbuzGk6rVqu7E6mb6wh KPWS1sEP7th2BPEXjA4tq+MNMRPjVzFHEXlim/4s= Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728433AbgFEOTn (ORCPT ); Fri, 5 Jun 2020 10:19:43 -0400 Received: from mail.kernel.org ([198.145.29.99]:50602 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728860AbgFEOTl (ORCPT ); Fri, 5 Jun 2020 10:19:41 -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 83CE6208C3; Fri, 5 Jun 2020 14:19:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591366781; bh=sXJRCZe3wSoZKHyLoHmplsdTx1p8e9SXjjR3pDu+tIA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=iYl0DTRjUjZN3n97YBWqAF4BVczb/HzX9F3DV1snJyhuCniYi+EruJY8R8eEOSL1e JFEt1Df/T3Rb4E/KnMzIBuH7uAa0KZWGDACxGlqVFuZ7bqK/AUfuadZRc2nrzhexWa rtnL6olYpvCkJshOHQ6UgB6da7F7YhPCsisxhGdY= 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.19 15/28] spi: dw: use "smp_mb()" to avoid sending spi data error Date: Fri, 5 Jun 2020 16:15:17 +0200 Message-Id: <20200605140253.279609547@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200605140252.338635395@linuxfoundation.org> References: <20200605140252.338635395@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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(+) diff --git a/drivers/spi/spi-dw.c b/drivers/spi/spi-dw.c index 5a47e28e38c1..6f0f6b99953d 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -304,6 +304,9 @@ static int dw_spi_transfer_one(struct spi_controller *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 */ -- 2.25.1