public inbox for linux-mips@vger.kernel.org
 help / color / mirror / Atom feed
From: Waldemar Brodkorb <wbx@openadk.org>
To: linux-mips@vger.kernel.org
Subject: Re: Asus WL500g Premium (BCM47XX) problem
Date: Thu, 26 Feb 2026 00:53:26 +0100	[thread overview]
Message-ID: <aZ-Ldi2U-51z3tF5@waldemar-brodkorb.de> (raw)
In-Reply-To: <aZ3NVrKLKgsflL1H@waldemar-brodkorb.de>

Hi,

Waldemar Brodkorb wrote,

> Hi MIPS hackers,
> 
> attached is the bootup log of Linux 6.18.13 (vanilla) on a Asus WL500g Premium
> WLAN router. See here for details:
> https://openwrt.org/toh/asus/wl-500gp
> 
> It is v1 version of the hardware. The CPU BCM3300 is correctly
> recognized, but it seems some of the cpu features might be
> misconfigured? What could be the problem?
> 
> Could this be the problem:
> https://dev.archive.openwrt.org/ticket/1485

It seems this old patch is good to make the userland more stable.
I now can login via SSH to the device. WHat you think about
something like that? It was made for 6.18.13 ATM.

From 9663df570daaa57f412eacb66fdd28d438073102 Mon Sep 17 00:00:00 2001
From: Waldemar Brodkorb <wbx@openadk.org>
Date: Tue, 24 Feb 2026 22:02:00 +0100
Subject: [PATCH] bcm47xx: fix for oops in copy_page() on BCM3300 CPU

On a Asus WL500gP WLAn router, see here for hardware details:
https://openwrt.org/toh/asus/wl-500gp
You get a kernel oops like this:
Data bus error, epc == 80015750, ra == 80013de8
Oops[#1]:
CPU: 0 UID: 0 PID: 1 Comm: preinit Not tainted 6.18.13 #1 NONE
Hardware name: Unknown Board
$ 0   : 00000000 10008800 fffd1000 00000000
$ 4   : 8102e000 fffd1000 8102ef00 805af1e0
$ 8   : 00000034 803b9808 77e3afff 77e39000
$12   : 80534164 00000001 00000801 00001533
$16   : 8102e000 805af1e0 00000001 00000255
$20   : 80bb6700 77e39000 80bb6700 80bb5000
$24   : 00000000 00000003
$28   : 8082e000 8082fe38 00000000 80013de8
Hi    : 00000000
Lo    : 00000000
epc   : 80015750 copy_page+0x48/0x548
ra    : 80013de8 copy_user_highpage+0x94/0xf8
Status: 10008803        KERNEL EXL IE
Cause : 0080001c (ExcCode 07)
PrId  : 00029006 (Broadcom BMIPS3300)
Modules linked in:
Process preinit (pid: 1, threadinfo=(ptrval), task=(ptrval), tls=00000000)
Stack : 77e39000 00000249 80561000 00000000 805c39e0 800c2404 77e39000 77e3afff
        809a150c 00000000 8082feb4 00000000 00000000 00000000 00000a55 804b0000
        00000000 e09c7372 80bbc000 80bb6700 00100cca 0000000f 77e39000 77e39ff8
        00000a55 80ae977c 80ae977c 005ee689 00000000 805af1e0 80bbc8e4 80bb502c
        00000000 e09c7372 8082ff28 77e39ff8 80830000 00000001 00000255 00000001
        ...
Call Trace:
[<80015750>] copy_page+0x48/0x548
[<80013de8>] copy_user_highpage+0x94/0xf8
[<800c2404>] handle_mm_fault+0xbac/0xfec
[<80013528>] do_page_fault+0x118/0x470
[<80017098>] tlb_do_page_fault_1+0x118/0x120

Code: cc9e0060  cc9e0070  cca40100 <8ca80000> 8ca90004  8caa0008  8cab000c  cc9e0080  ac880000

---[ end trace 0000000000000000 ]---
Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b
---[ end Kernel panic - not syncing: Attempted to kill init! exitcode=0x0000000b ]---

Fix is from old OpenWrt svn archive:
https://git.openwrt.org/?p=openwrt/svn-archive/openwrt.git;a=blob;f=target/linux/brcm47xx/patches-3.18/160-kmap_coherent.patch;h=924138690d54757fbfb24569b8730cf2576cc5af;hb=refs/heads/chaos_calmer

See here for details:
https://dev.archive.openwrt.org/ticket/1485

Signed-off-by: Waldemar Brodkorb <wbx@openadk.org>
---
 arch/mips/include/asm/cpu-features.h                       | 3 +++
 arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h | 1 +
 arch/mips/mm/c-r4k.c                                       | 4 ++--
 arch/mips/mm/init.c                                        | 6 +++---
 4 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/arch/mips/include/asm/cpu-features.h b/arch/mips/include/asm/cpu-features.h
index 404390bb87ea..9f1b2c2f3739 100644
--- a/arch/mips/include/asm/cpu-features.h
+++ b/arch/mips/include/asm/cpu-features.h
@@ -257,6 +257,9 @@
 #ifndef cpu_has_pindexed_dcache
 #define cpu_has_pindexed_dcache	(cpu_data[0].dcache.flags & MIPS_CACHE_PINDEX)
 #endif
+#ifndef cpu_use_kmap_coherent
+#define cpu_use_kmap_coherent	1
+#endif
 
 /*
  * I-Cache snoops remote store.	 This only matters on SMP.  Some multiprocessors
diff --git a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
index 69899c1e122d..47314a7048a1 100644
--- a/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
+++ b/arch/mips/include/asm/mach-bcm47xx/cpu-feature-overrides.h
@@ -22,6 +22,7 @@
 #define cpu_has_mcheck			1
 #define cpu_has_ejtag			1
 #define cpu_has_llsc			1
+#define cpu_use_kmap_coherent   	0
 
 /* cpu_has_mips16 */
 #define cpu_has_mdmx			0
diff --git a/arch/mips/mm/c-r4k.c b/arch/mips/mm/c-r4k.c
index 10413b6f6662..558b780b4d72 100644
--- a/arch/mips/mm/c-r4k.c
+++ b/arch/mips/mm/c-r4k.c
@@ -576,7 +576,7 @@ static inline void local_r4k_flush_cache_page(void *args)
 		map_coherent = (cpu_has_dc_aliases &&
 				folio_mapped(folio) &&
 				!folio_test_dcache_dirty(folio));
-		if (map_coherent)
+		if (map_coherent && cpu_use_kmap_coherent)
 			vaddr = kmap_coherent(page, addr);
 		else
 			vaddr = kmap_atomic(page);
@@ -598,7 +598,7 @@ static inline void local_r4k_flush_cache_page(void *args)
 	}
 
 	if (vaddr) {
-		if (map_coherent)
+		if (map_coherent && cpu_use_kmap_coherent)
 			kunmap_coherent();
 		else
 			kunmap_atomic(vaddr);
diff --git a/arch/mips/mm/init.c b/arch/mips/mm/init.c
index a673d3d68254..ab394299d5eb 100644
--- a/arch/mips/mm/init.c
+++ b/arch/mips/mm/init.c
@@ -167,7 +167,7 @@ void copy_user_highpage(struct page *to, struct page *from,
 	void *vfrom, *vto;
 
 	vto = kmap_atomic(to);
-	if (cpu_has_dc_aliases &&
+	if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
 	    folio_mapped(src) && !folio_test_dcache_dirty(src)) {
 		vfrom = kmap_coherent(from, vaddr);
 		copy_page(vto, vfrom);
@@ -191,7 +191,7 @@ void copy_to_user_page(struct vm_area_struct *vma,
 {
 	struct folio *folio = page_folio(page);
 
-	if (cpu_has_dc_aliases &&
+	if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
 	    folio_mapped(folio) && !folio_test_dcache_dirty(folio)) {
 		void *vto = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
 		memcpy(vto, src, len);
@@ -211,7 +211,7 @@ void copy_from_user_page(struct vm_area_struct *vma,
 {
 	struct folio *folio = page_folio(page);
 
-	if (cpu_has_dc_aliases &&
+	if (cpu_has_dc_aliases && cpu_use_kmap_coherent &&
 	    folio_mapped(folio) && !folio_test_dcache_dirty(folio)) {
 		void *vfrom = kmap_coherent(page, vaddr) + (vaddr & ~PAGE_MASK);
 		memcpy(dst, vfrom, len);
-- 
2.47.3


      reply	other threads:[~2026-02-25 23:53 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-24 16:09 Asus WL500g Premium (BCM47XX) problem Waldemar Brodkorb
2026-02-25 23:53 ` Waldemar Brodkorb [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=aZ-Ldi2U-51z3tF5@waldemar-brodkorb.de \
    --to=wbx@openadk.org \
    --cc=linux-mips@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox