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 trying 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 Reviewed-on: https://review.coreboot.org/c/coreboot/+/56231 Reviewed-by: Karthik Ramasubramanian <kramasub@google.com> Reviewed-by: Furquan Shaikh <furquan@google.com> Tested-by: build bot (Jenkins) <no-reply@coreboot.org>
This commit is contained in:
parent
b29f9d471b
commit
6f3c9018c6
|
@ -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. */
|
||||
|
@ -164,6 +165,8 @@ static bool continue_spi_dma_transaction(const struct region_device *rd,
|
|||
return false;
|
||||
}
|
||||
|
||||
static struct thread_mutex spi_dma_hw_mutex;
|
||||
|
||||
static ssize_t spi_dma_readat_dma(const struct region_device *rd, void *destination,
|
||||
size_t source, size_t size)
|
||||
{
|
||||
|
@ -177,12 +180,16 @@ static ssize_t spi_dma_readat_dma(const struct region_device *rd, void *destinat
|
|||
printk(BIOS_SPEW, "%s: start: dest: %p, source: %#zx, size: %zu\n", __func__,
|
||||
destination, source, size);
|
||||
|
||||
thread_mutex_lock(&spi_dma_hw_mutex);
|
||||
|
||||
start_spi_dma_transaction(&transaction);
|
||||
|
||||
do {
|
||||
udelay(2);
|
||||
} while (continue_spi_dma_transaction(rd, &transaction));
|
||||
|
||||
thread_mutex_unlock(&spi_dma_hw_mutex);
|
||||
|
||||
printk(BIOS_SPEW, "%s: end: dest: %p, source: %#zx, remaining: %zu\n",
|
||||
__func__, destination, source, transaction.remaining);
|
||||
|
||||
|
|
Loading…
Reference in New Issue