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/+/56231 )
Change subject: soc/amd/common/block/lpc/spi_dma: Use mutex to protect DMA registers ......................................................................
soc/amd/common/block/lpc/spi_dma: Use mutex to protect DMA registers
Once we enable COOP_MULTITASKING, we need to guarantee that we don't have multiple threads trhing to access the DMA hardware.
BUG=b:179699789 TEST=Boot guybrush with APOB patches.
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: Ibb8e31c95d6722521425772f4210af45626c8e09 --- M src/soc/amd/common/block/lpc/spi_dma.c 1 file changed, 7 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/31/56231/1
diff --git a/src/soc/amd/common/block/lpc/spi_dma.c b/src/soc/amd/common/block/lpc/spi_dma.c index 9bee259..dede449 100644 --- a/src/soc/amd/common/block/lpc/spi_dma.c +++ b/src/soc/amd/common/block/lpc/spi_dma.c @@ -13,6 +13,7 @@ #include <soc/pci_devs.h> #include <spi_flash.h> #include <string.h> +#include <thread.h> #include <types.h>
/* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */ @@ -139,6 +140,8 @@ return false; }
+struct mutex spi_dma_hw_mutex; + static ssize_t spi_dma_readat_dma(const struct region_device *rd, void *b, size_t offset, size_t size) { @@ -152,12 +155,16 @@ printk(BIOS_SPEW, "%s: start: dest: %p, offset: %#zx, size: %zu\n", __func__, b, offset, size);
+ mutex_lock(&spi_dma_hw_mutex); + start_spi_dma_transaction(&transaction);
do { udelay(10); } while (continue_spi_dma_transaction(rd, &transaction));
+ mutex_unlock(&spi_dma_hw_mutex); + printk(BIOS_SPEW, "%s: end: dest: %p, offset: %#zx, size: %zu, remaining: %zu\n", __func__, b, offset, size, transaction.remaining);