From patchwork Tue Jun 9 17:44:10 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: 187700 Delivered-To: patch@linaro.org Received: by 2002:a54:30ca:0:0:0:0:0 with SMTP id e10csp641631ecs; Tue, 9 Jun 2020 11:22:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFHqrFRKa2gOrK0U9PBX5yb3ijHB5twQi1/6X4BxNevd+iWx5ajUfECg8RSS4HubKk3ghp X-Received: by 2002:aa7:c148:: with SMTP id r8mr28442713edp.108.1591726944771; Tue, 09 Jun 2020 11:22:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591726944; cv=none; d=google.com; s=arc-20160816; b=CXpEK0Oy/pldG6RrzWV1gqNvdlaGMpPsIsBalg4bq6n3H1cigTXp4+4ev9Fpm1La1u uZ+m4pCEI7176oGn8sNw4rxmc/gIYpLHndKYwoNs4Fgjj19JT2vDEkGMggSZB1X3c032 HIgIpIlIYaRFlrqJ4LVU47NWaC3iZ2wdi5fIvMJ6ehS/27rSa2CJbb6O4Z8LBAXWEq/z yvk3afXVkR+zIv+EfKBXijfYfxPzmIhI0M00wukDAgdz7LC7fFJtrBZ5QRPF4dHaVbo3 iR1oerOsE4pFIDI9/61Js5PmkxsZufGOCEAXQ3M/8hWMxYUxvrugbPd0V4TTUVb42kzu IPJA== 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=q4PantsPl6xmOYF2U58QKH49f6GLiHCSxwnIkmt2VgA=; b=GlnWXS1xud+wSldWKg6XyVPp6bhlNa+PnpLNAOonX+FHQ5Tn5BhIV2u9Kcoe1CGFs9 uHpk5PsgXwaaf3VGPGmkYje0Fwqy0WJ2iA/7hVQ4uuEZ0yV1CmtoojskN19hO0P3H4H1 9a2M+ycYOf3fx59gvLXVEREdgqhscr5853TjxgKW55zlT3Z9sqNHqL7j1DBUyDXM3wOK DKaYPpJ/mfACu1ufdHDQEtLCRlhEslFfW/qg77htgmNOYGuEscNbu/qyg3KF1n0Mt7jT 1fAvtFq6EQaSegRIKD7i5Yd8EbQnDswtMXpkufKYeLqBlLhC/qyjtxfXla75wYA3fH95 cMwg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=fXZ8Psdq; 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 gl21si10493719ejb.739.2020.06.09.11.22.24; Tue, 09 Jun 2020 11:22:24 -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=fXZ8Psdq; 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 S1732278AbgFIRsZ (ORCPT + 15 others); Tue, 9 Jun 2020 13:48:25 -0400 Received: from mail.kernel.org ([198.145.29.99]:60736 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1732272AbgFIRsY (ORCPT ); Tue, 9 Jun 2020 13:48:24 -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 8B3E6207F9; Tue, 9 Jun 2020 17:48:23 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1591724904; bh=UGCaFbEuunkpiMPLhMo9e/ZU2NqYD3MHVp2tizz5GwA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=fXZ8PsdqT0PZeB7tPKlamm4lyFXMkV5p4mjNedtDd9r3x4hHREMk00/VU5nlxIdN7 QjNusCxNx8SZyoy6gePxJE0pNlBAAwpi1chKdWEvAj08oya3jN1vrvjV3vKnMQtw2X knKqRuRe312nNS2mhCIrCx9/AT+ccOa150wShky0= 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.9 04/42] spi: dw: use "smp_mb()" to avoid sending spi data error Date: Tue, 9 Jun 2020 19:44:10 +0200 Message-Id: <20200609174015.905169211@linuxfoundation.org> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20200609174015.379493548@linuxfoundation.org> References: <20200609174015.379493548@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 16f0def9df82..babf0a337e96 100644 --- a/drivers/spi/spi-dw.c +++ b/drivers/spi/spi-dw.c @@ -305,6 +305,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 */