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/+/56322 )
Change subject: soc/amd/common/block/lpc/spi_dma: Add ability to verify SPI DMA hardware ......................................................................
soc/amd/common/block/lpc/spi_dma: Add ability to verify SPI DMA hardware
The SPI DMA controller was not completely functional prior to RN/CZN. This code can be used to sanity check the DMA hardware.
BUG=b:179699789 TEST=Boot guybrush with VERIFY=1 and make sure no DMA errors occur.
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I2dd54cab86ad31b135a93d4667df346c60357337 --- M src/soc/amd/common/block/lpc/spi_dma.c 1 file changed, 24 insertions(+), 0 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/22/56322/1
diff --git a/src/soc/amd/common/block/lpc/spi_dma.c b/src/soc/amd/common/block/lpc/spi_dma.c index 00cd593..cd3958b 100644 --- a/src/soc/amd/common/block/lpc/spi_dma.c +++ b/src/soc/amd/common/block/lpc/spi_dma.c @@ -13,9 +13,16 @@ #include <soc/pci_devs.h> #include <spi_flash.h> #include <string.h> +#include <lib.h> #include <thread.h> #include <types.h>
+/* + * Set to 1 to verify the buffer contents after the DMA transaction. + * This is helpful in building confidence in the SPI DMA controller. + */ +#define VERIFY_BUFFER 0 + /* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */ #define rom_base ((void *)(uintptr_t)(0x100000000ULL - CONFIG_ROM_SIZE))
@@ -119,6 +126,9 @@ ctrl |= LPC_ROM_DMA_CTRL_ERROR; /* Clear error */ ctrl |= LPC_ROM_DMA_CTRL_START;
+ if (VERIFY_BUFFER) + memset(transaction->destination, 0xFC, transaction->transfer_size); + pci_write_config32(SOC_LPC_DEV, LPC_ROM_DMA_EC_HOST_CONTROL, ctrl); }
@@ -135,6 +145,20 @@ if (spi_dma_has_error()) return false;
+ if (VERIFY_BUFFER) { + uint8_t *mmap = + spi_dma_mmap(rd, transaction->source, transaction->transfer_size); + if (memcmp(mmap, transaction->destination, transaction->transfer_size)) { + printk(BIOS_ERR, "We had a DMA error!!!\n"); + hexdump(mmap, transaction->transfer_size); + printk(BIOS_ERR, "---------------------\n"); + hexdump(transaction->destination, transaction->transfer_size); + die("---------------------\n"); + } else { + printk(BIOS_DEBUG, "Verification successful\n"); + } + } + transaction->destination += transaction->transfer_size; transaction->source += transaction->transfer_size; transaction->remaining -= transaction->transfer_size;