diff options
author | Victor Chong <victor.chong@linaro.org> | 2019-04-12 15:58:07 +0100 |
---|---|---|
committer | Joakim Bech <joakim.bech@linaro.org> | 2019-04-16 21:28:59 +0700 |
commit | e4b2e43c44934b500dbb9dbf7207d9bcd7a2ab77 (patch) | |
tree | 26f8d9fa68be4dfbe8235a8b7e517d9f0e92447f /core | |
parent | 13e224aa32b2a6d928b6b2b5837753e1e966749c (diff) |
pl022_spi: simplify receive of remaining data
If the expected number of packets are not received during the
transmit+receive cycle, just receive the remaining data after the
cycle if the Receive FIFO (SSPSR_RNE) is not empty, without depending
on the busy (SSPSR_BSY) flag, else we might miss reading some data as
indicated in [1].
LINK: [1] https://github.com/OP-TEE/optee_os/issues/1461#issuecomment-306156463
Signed-off-by: Victor Chong <victor.chong@linaro.org>
Acked-by: Jens Wiklander <jens.wiklander@linaro.org>
Acked-by: Etienne Carriere <etienne.carriere@linaro.org>
Diffstat (limited to 'core')
-rw-r--r-- | core/drivers/pl022_spi.c | 18 |
1 files changed, 8 insertions, 10 deletions
diff --git a/core/drivers/pl022_spi.c b/core/drivers/pl022_spi.c index c7fc992a..870cd3e6 100644 --- a/core/drivers/pl022_spi.c +++ b/core/drivers/pl022_spi.c @@ -166,11 +166,10 @@ static enum spi_result pl022_txrx8(struct spi_chip *chip, uint8_t *wdat, /* Capture remaining rdat not read above */ if (rdat) { while ((j < num_pkts) && - (io_read8(pd->base + SSPSR) & SSPSR_BSY)) - if (io_read8(pd->base + SSPSR) & SSPSR_RNE) { - /* rx 1 packet */ - rdat[j++] = io_read8(pd->base + SSPDR); - } + (io_read8(pd->base + SSPSR) & SSPSR_RNE)) { + /* rx 1 packet */ + rdat[j++] = io_read8(pd->base + SSPDR); + } if (j < num_pkts) { EMSG("Packets requested %zu, received %zu", @@ -212,11 +211,10 @@ static enum spi_result pl022_txrx16(struct spi_chip *chip, uint16_t *wdat, /* Capture remaining rdat not read above */ if (rdat) { while ((j < num_pkts) && - (io_read8(pd->base + SSPSR) & SSPSR_BSY)) - if (io_read8(pd->base + SSPSR) & SSPSR_RNE) { - /* rx 1 packet */ - rdat[j++] = io_read8(pd->base + SSPDR); - } + (io_read8(pd->base + SSPSR) & SSPSR_RNE)) { + /* rx 1 packet */ + rdat[j++] = io_read8(pd->base + SSPDR); + } if (j < num_pkts) { EMSG("Packets requested %zu, received %zu", |