]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
ARM: stm32mp: fix RIFSC semaphores acquisition
authorGatien Chevallier <gatien.chevallier@foss.st.com>
Fri, 8 Aug 2025 14:03:56 +0000 (16:03 +0200)
committerPatrice Chotard <patrice.chotard@foss.st.com>
Thu, 18 Sep 2025 15:20:30 +0000 (17:20 +0200)
Fix RIFSC semaphores acquisition by not returning an error when the
current CID already possess the semaphore. Also fix an incorrect mask
for the CID value in the SEMCR register.

Signed-off-by: Gatien Chevallier <gatien.chevallier@foss.st.com>
Signed-off-by: Patrice Chotard <patrice.chotard@foss.st.com>
Reviewed-by: Patrick Delaunay <patrick.delaunay@foss.st.com>
arch/arm/mach-stm32mp/stm32mp2/rifsc.c

index 50dececf77b78c502b42dc1352d11814cf59c0cb..136ed68bba1c7deffbfd267a31c465c13a531094 100644 (file)
@@ -73,7 +73,8 @@ static int stm32_rif_acquire_semaphore(void *base, u32 id)
        void *addr = base + RIFSC_RISC_PER0_SEMCR(id);
 
        /* Check that the semaphore is available */
-       if (!stm32_rif_is_semaphore_available(base, id))
+       if (!stm32_rif_is_semaphore_available(base, id) &&
+           FIELD_GET(RIFSC_RISC_SCID_MASK, (readl(addr)) != RIF_CID1))
                return -EACCES;
 
        setbits_le32(addr, SEMCR_MUTEX);
@@ -171,7 +172,7 @@ static int rifsc_check_access(void *base, u32 id)
                        return -EACCES;
                }
                if (!stm32_rif_is_semaphore_available(base, id) &&
-                   !(FIELD_GET(RIFSC_RISC_SCID_MASK, sem_reg_value) & BIT(RIF_CID1))) {
+                   !(FIELD_GET(RIFSC_RISC_SCID_MASK, sem_reg_value) & RIF_CID1)) {
                        log_debug("Semaphore unavailable for peripheral %d\n", id);
                        return -EACCES;
                }