From: kongxinwei <kong.kongxinwei@hisilicon.com>
To: Mark Brown <broonie@kernel.org>
Cc: <linux-spi@vger.kernel.org>, <linux-kernel@vger.kernel.org>,
<linuxarm@huawei.com>, fengsheng <fengsheng5@huawei.com>,
Xinwei Kong <kong.kongxinwei@hisilicon.com>
Subject: Re: [PATCH] spi: dw: use "smp_mb()" to avoid sending spi data error
Date: Sat, 28 Dec 2019 16:31:53 +0800 [thread overview]
Message-ID: <afad8a97-6159-bf7e-466a-fdbaf0a07d4a@hisilicon.com> (raw)
In-Reply-To: <20191227002239.GH27497@sirena.org.uk>
On 2019/12/27 8:22, Mark Brown wrote:
> On Thu, Dec 26, 2019 at 05:21:28PM +0800, Xinwei Kong wrote:
>> this patch will add memory barrier to ensure this "struct dw_spi *dws"
>> to complete data setting before enabling this SPI hardware interrupt.
>> eg:
>> it will fix to this following low possibility error in testing environment
>> which using SPI control to connect TPM Modules
>
>> --- a/drivers/spi/spi-dw.c
>> +++ b/drivers/spi/spi-dw.c
>> @@ -288,6 +288,8 @@ static int dw_spi_transfer_one(struct spi_controller *master,
>> dws->rx_end = dws->rx + transfer->len;
>> dws->len = transfer->len;
>>
>> + smp_mb();
>> +
>> spi_enable_chip(dws, 0);
>
> I'd be much more comfortable here if I understood what this was
> supposed to be syncing - what exactly gets flushed here and why
> is a memory barrier enough to ensure it's synced? A comment in
> the code would be especially good so anyone modifying the code
> understands this in future.
>
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 it will result
in SPI sending error
next prev parent reply other threads:[~2019-12-28 8:32 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2019-12-26 9:21 Xinwei Kong
2019-12-27 0:22 ` Mark Brown
2019-12-28 8:31 ` kongxinwei [this message]
2020-01-03 1:04 ` Mark Brown
2020-01-03 1:34 ` kongxinwei
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=afad8a97-6159-bf7e-466a-fdbaf0a07d4a@hisilicon.com \
--to=kong.kongxinwei@hisilicon.com \
--cc=broonie@kernel.org \
--cc=fengsheng5@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-spi@vger.kernel.org \
--cc=linuxarm@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®