Attention is currently required from: Jason Glenesk, Marshall Dawson, Felix Held. Raul Rangel has uploaded this change for review. ( https://review.coreboot.org/c/coreboot/+/56267 )
Change subject: soc/amd/common/block: Make SPI DMA readat co-op friendly ......................................................................
soc/amd/common/block: Make SPI DMA readat co-op friendly
We need to make the SPI readat method yield frequently so that we don't block the main thread of execution for too long.
BUG=b:179699789 TEST=Boot guybrush to the OS.
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Id3ec58a2e35e744b5bc2062ae479917f7f57bae9 --- M src/soc/amd/common/block/lpc/spi_dma.c 1 file changed, 21 insertions(+), 2 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/67/56267/1
diff --git a/src/soc/amd/common/block/lpc/spi_dma.c b/src/soc/amd/common/block/lpc/spi_dma.c index dede449..9b17a38 100644 --- a/src/soc/amd/common/block/lpc/spi_dma.c +++ b/src/soc/amd/common/block/lpc/spi_dma.c @@ -41,14 +41,33 @@ return 0; }
-static ssize_t spi_dma_readat_mmap(const struct region_device *rd, void *b, size_t offset, +static ssize_t spi_dma_readat_mmap(const struct region_device *rd, uint8_t *b, size_t offset, size_t size) { const struct mem_region_device *mdev; + /* + * Transfer at most 128 bytes at a time to not block too long. Otherwise + * we can drastically affect the udelay timings and timestamp accounting + * for other components. + */ + const size_t block_size = 128; + size_t remaining = size; + size_t transfer_size;
mdev = container_of(rd, __typeof__(*mdev), rdev);
- memcpy(b, &mdev->base[offset], size); + while (remaining) { + transfer_size = MIN(remaining, block_size); + + memcpy(b, &mdev->base[offset], transfer_size); + + b += transfer_size; + offset += transfer_size; + remaining -= transfer_size; + + /* Yield execution to other threads */ + udelay(0); + }
return size; }