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/+/59323 )
Change subject: lib/thread,soc/amd/common: Delete thread_mutex ......................................................................
lib/thread,soc/amd/common: Delete thread_mutex
The functionality has been moved into `struct mutex`.
BUG=b:179699789
Signed-off-by: Raul E Rangel rrangel@chromium.org Change-Id: I9c6d00a72a37bcc3f9f772c96b61003c280c6b19 --- M src/include/thread.h M src/lib/thread.c M src/soc/amd/common/block/include/amdblocks/spi.h M src/soc/amd/common/block/lpc/spi_dma.c M src/soc/amd/common/block/spi/fch_spi_ctrl.c M src/soc/amd/common/block/spi/fch_spi_util.c 6 files changed, 13 insertions(+), 40 deletions(-)
git pull ssh://review.coreboot.org:29418/coreboot refs/changes/23/59323/1
diff --git a/src/include/thread.h b/src/include/thread.h index 19b69fa..74be485 100644 --- a/src/include/thread.h +++ b/src/include/thread.h @@ -5,12 +5,9 @@ #include <arch/cpu.h> #include <bootstate.h> #include <commonlib/bsd/cb_err.h> +#include <mutex.h> #include <types.h>
-struct thread_mutex { - bool locked; -}; - enum thread_state { THREAD_UNINITIALIZED, THREAD_STARTED, @@ -70,9 +67,6 @@ void thread_coop_enable(void); void thread_coop_disable(void);
-void thread_mutex_lock(struct thread_mutex *mutex); -void thread_mutex_unlock(struct thread_mutex *mutex); - /* Architecture specific thread functions. */ asmlinkage void switch_to_thread(uintptr_t new_stack, uintptr_t *saved_stack); /* Set up the stack frame for a new thread so that a switch_to_thread() call @@ -91,10 +85,6 @@ } static inline void thread_coop_enable(void) {} static inline void thread_coop_disable(void) {} - -static inline void thread_mutex_lock(struct thread_mutex *mutex) {} - -static inline void thread_mutex_unlock(struct thread_mutex *mutex) {} #endif
#endif /* THREAD_H_ */ diff --git a/src/lib/thread.c b/src/lib/thread.c index 0393ca7..87a7d1b 100644 --- a/src/lib/thread.c +++ b/src/lib/thread.c @@ -409,22 +409,3 @@
return handle->error; } - -void thread_mutex_lock(struct thread_mutex *mutex) -{ - struct stopwatch sw; - - stopwatch_init(&sw); - - while (mutex->locked) - assert(thread_yield() == 0); - mutex->locked = true; - - printk(BIOS_SPEW, "took %lu us to acquire mutex\n", stopwatch_duration_usecs(&sw)); -} - -void thread_mutex_unlock(struct thread_mutex *mutex) -{ - assert(mutex->locked); - mutex->locked = 0; -} diff --git a/src/soc/amd/common/block/include/amdblocks/spi.h b/src/soc/amd/common/block/include/amdblocks/spi.h index 81da5dd..6fa2637 100644 --- a/src/soc/amd/common/block/include/amdblocks/spi.h +++ b/src/soc/amd/common/block/include/amdblocks/spi.h @@ -3,7 +3,7 @@ #ifndef AMD_BLOCK_SPI_H #define AMD_BLOCK_SPI_H
-#include <thread.h> +#include <mutex.h> #include <types.h>
#define SPI_CNTRL0 0x00 @@ -121,6 +121,6 @@ void mainboard_spi_fast_speed_override(uint8_t *fast_speed);
/* Ensure you hold the mutex when performing SPI transactions */ -extern struct thread_mutex spi_hw_mutex; +extern struct mutex spi_hw_mutex;
#endif /* AMD_BLOCK_SPI_H */ diff --git a/src/soc/amd/common/block/lpc/spi_dma.c b/src/soc/amd/common/block/lpc/spi_dma.c index baf1eb8..b998989 100644 --- a/src/soc/amd/common/block/lpc/spi_dma.c +++ b/src/soc/amd/common/block/lpc/spi_dma.c @@ -14,6 +14,7 @@ #include <spi_flash.h> #include <string.h> #include <thread.h> +#include <mutex.h> #include <types.h>
/* The ROM is memory mapped just below 4GiB. Form a pointer for the base. */ @@ -126,7 +127,7 @@ * Ensure we have exclusive access to the SPI controller before starting the LPC SPI DMA * transaction. */ - thread_mutex_lock(&spi_hw_mutex); + mutex_lock(&spi_hw_mutex);
pci_write_config32(SOC_LPC_DEV, LPC_ROM_DMA_EC_HOST_CONTROL, ctrl); } @@ -145,7 +146,7 @@ * Unlock the SPI mutex between DMA transactions to allow other users of the SPI * controller to interleave their transactions. */ - thread_mutex_unlock(&spi_hw_mutex); + mutex_unlock(&spi_hw_mutex);
if (spi_dma_has_error()) { printk(BIOS_ERR, @@ -177,7 +178,7 @@ return false; }
-static struct thread_mutex spi_dma_hw_mutex; +static struct 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) @@ -192,7 +193,7 @@ printk(BIOS_SPEW, "%s: start: dest: %p, source: %#zx, size: %zu\n", __func__, destination, source, size);
- thread_mutex_lock(&spi_dma_hw_mutex); + mutex_lock(&spi_dma_hw_mutex);
start_spi_dma_transaction(&transaction);
@@ -200,7 +201,7 @@ udelay(2); } while (continue_spi_dma_transaction(rd, &transaction));
- thread_mutex_unlock(&spi_dma_hw_mutex); + mutex_unlock(&spi_dma_hw_mutex);
printk(BIOS_SPEW, "%s: end: dest: %p, source: %#zx, remaining: %zu\n", __func__, destination, source, transaction.remaining); diff --git a/src/soc/amd/common/block/spi/fch_spi_ctrl.c b/src/soc/amd/common/block/spi/fch_spi_ctrl.c index d95b642..62456e3 100644 --- a/src/soc/amd/common/block/spi/fch_spi_ctrl.c +++ b/src/soc/amd/common/block/spi/fch_spi_ctrl.c @@ -144,9 +144,9 @@ { int rc;
- thread_mutex_lock(&spi_hw_mutex); + mutex_lock(&spi_hw_mutex); rc = spi_flash_vector_helper(slave, vectors, count, spi_ctrlr_xfer); - thread_mutex_unlock(&spi_hw_mutex); + mutex_unlock(&spi_hw_mutex);
return rc; } diff --git a/src/soc/amd/common/block/spi/fch_spi_util.c b/src/soc/amd/common/block/spi/fch_spi_util.c index 862962f..6f5920c 100644 --- a/src/soc/amd/common/block/spi/fch_spi_util.c +++ b/src/soc/amd/common/block/spi/fch_spi_util.c @@ -5,9 +5,10 @@ #include <arch/mmio.h> #include <assert.h> #include <stdint.h> +#include <mutex.h>
/* Global SPI controller mutex */ -struct thread_mutex spi_hw_mutex; +struct mutex spi_hw_mutex;
static uintptr_t spi_base;