$ git show bfda044533b2
commit bfda044533b213985bc62bd7ca96f2b984d21b80
Author: Xinwei Kong <email address hidden>
Date: Fri Jan 3 10:52:10 2020 +0800
spi: dw: use "smp_mb()" to avoid sending spi data error
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
In linux-next but not hit mainline yet.
$ git show bfda044533b2 85bc62bd7ca96f2 b984d21b80
commit bfda044533b2139
Author: Xinwei Kong <email address hidden>
Date: Fri Jan 3 10:52:10 2020 +0800
spi: dw: use "smp_mb()" to avoid sending spi data error
Because of out-of-order execution about some CPU architecture, transfer" function
In this debug stage we find Completing spi interrupt enable ->
prodrucing TXEI interrupt -> running "interrupt_
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 locality: : error -1
kernel: tpm tpm0: tpm_relinquish_
Signed-off-by: fengsheng <email address hidden> /lore<email address hidden>
Signed-off-by: Xinwei Kong <email address hidden>
Link: https:/
Signed-off-by: Mark Brown <email address hidden>
diff --git a/drivers/ spi/spi- dw.c b/drivers/ spi/spi- dw.c .310492e21b33 100644 spi/spi- dw.c spi/spi- dw.c transfer_ one(struct spi_controller *master,
spin_unlock_ irqrestore( &dws->buf_ lock, flags);
index c547ae38ed69.
--- a/drivers/
+++ b/drivers/
@@ -297,6 +297,9 @@ static int dw_spi_
dws->len = transfer->len;
+ /* Ensure dw->rx and dw->rx_end are visible */
spi_enable_ chip(dws, 0);
+ smp_mb();
+
/* Handle per transfer options for bpw and speed */