]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
cache: Check dcache availability before calling cache functions
authorBoon Khai Ng <boon.khai.ng@altera.com>
Thu, 14 Aug 2025 03:17:40 +0000 (11:17 +0800)
committerTien Fong Chee <tien.fong.chee@intel.com>
Tue, 30 Sep 2025 06:29:55 +0000 (14:29 +0800)
When the data cache (dcache) is disabled, calling related
status functions can lead to compilation errors due to
undefined references.

Adding a !CONFIG_IS_ENABLED(SYS_DCACHE_OFF) check before
invoking dcache_status() (used in common/memsize.c:get_ram_size())
and mmu_status() (from arch/arm/include/asm/io.h).

Without this check, builds with dcache disabled will fail to compile.

Signed-off-by: Boon Khai Ng <boon.khai.ng@altera.com>
Reviewed-by: Tom Rini <trini@konsulko.com>
arch/arm/include/asm/io.h
common/memsize.c

index 85ec0e6937e8beb0f7f7bff021bceca636781252..cebed7397d4352d55785079d8a657a1fbb1ec12b 100644 (file)
@@ -386,12 +386,14 @@ void __memcpy_fromio(void *to, const volatile void __iomem *from, size_t count)
                count--;
        }
 
-       if (mmu_status()) {
-               while (count >= 8) {
-                       *(u64 *)to = __raw_readq(from);
-                       from += 8;
-                       to += 8;
-                       count -= 8;
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) {
+               if (mmu_status()) {
+                       while (count >= 8) {
+                               *(u64 *)to = __raw_readq(from);
+                               from += 8;
+                               to += 8;
+                               count -= 8;
+                       }
                }
        }
 
@@ -416,12 +418,14 @@ void __memcpy_toio(volatile void __iomem *to, const void *from, size_t count)
                count--;
        }
 
-       if (mmu_status()) {
-               while (count >= 8) {
-                       __raw_writeq(*(u64 *)from, to);
-                       from += 8;
-                       to += 8;
-                       count -= 8;
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF)) {
+               if (mmu_status()) {
+                       while (count >= 8) {
+                               __raw_writeq(*(u64 *)from, to);
+                               from += 8;
+                               to += 8;
+                               count -= 8;
+                       }
                }
        }
 
index 86109579c95402f2e2230971973700c87c2d1d94..3c3ae6f1eba7e53f658461a1befabf4fe7022edf 100644 (file)
@@ -52,7 +52,10 @@ long get_ram_size(long *base, long maxsize)
        long           val;
        long           size;
        int            i = 0;
-       int            dcache_en = dcache_status();
+       int            dcache_en = 0;
+
+       if (!CONFIG_IS_ENABLED(SYS_DCACHE_OFF))
+               dcache_en = dcache_status();
 
        for (cnt = (maxsize / sizeof(long)) >> 1; cnt > 0; cnt >>= 1) {
                addr = base + cnt;      /* pointer arith! */