[PATCH 2/2] ath79: mikrotik: Change the moment of routerboot partition parser init

Denis Kalashnikov denis281089 at gmail.com
Tue Nov 9 06:46:07 PST 2021


If kernel invokes routerboot partion parser module
(drivers/platform/mikrotik/routerboot.c) init function too early, when SPI flash
hasn't been found yet, its rb_hardconfig_init() failed with -ENODEV (since no
mtd device with name "hard_config" was found). In this case when kernel calls
ath9k probe function, it tries a sysfs fallback for loading calibration data,
but hotplug script fails to load it, since "/sys/firmware/mikrotik/hard_config"
is missing (whole "/sys/firmware/mikrotik" dir is empty, since
rb_hardconfig_init() has failed). As a result we see no phy0 and no wlan0, and
in logs we found:

root at OpenWrt:/dev# logread | grep ath9k
kern.warn kernel: [   13.818737] ath9k 18100000.wmac: Direct firmware load
  for ath9k-eeprom-ahb-18100000.wmac.bin failed with error -2
kern.warn kernel: [   13.829463] ath9k 18100000.wmac: Falling back to sysfs
  fallback for: ath9k-eeprom-ahb-18100000.wmac.bin
kern.err kernel: [   14.838766] ath: phy0: Unable to load EEPROM file
  ath9k-eeprom-ahb-18100000.wmac.bin
kern.err kernel: [   14.846909] ath9k 18100000.wmac: failed to initialize device
kern.warn kernel: [   14.852870] ath9k: probe of 18100000.wmac failed with error -22

We managed to fix this by changing module_init() to late_initcall()
in routerboot module:

root at OpenWrt:~# logread | grep ath
kern.warn kernel: [   13.661861] ath9k 18100000.wmac: Direct firmware load for
  ath9k-eeprom-ahb-18100000.wmac.bin failed with error -2
kern.warn kernel: [   13.672583] ath9k 18100000.wmac: Falling back to sysfs for:
  ath9k-eeprom-ahb-18100000.wmac.bin
kern.debug kernel: [   14.569014] ath: EEPROM regdomain sanitized
kern.debug kernel: [   14.569038] ath: EEPROM regdomain: 0x64
kern.debug kernel: [   14.569044] ath: EEPROM indicates we should expect a
  direct regpair map
kern.debug kernel: [   14.569073] ath: Country alpha2 being used: 00
kern.debug kernel: [   14.569079] ath: Regpair used: 0x64

root at OpenWrt:~# iw dev
phy#0
	Interface wlan0
		ifindex 3
		wdev 0x1
		addr xx:xx:xx:xx:xx:xx
		type managed
		txpower 20.00 dBm

Signed-off-by: Denis Kalashnikov <denis281089 at gmail.com>
---
 .../linux/generic/files/drivers/platform/mikrotik/routerboot.c  | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
index 4c8c0bfac5..e5745c88a9 100644
--- a/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
+++ b/target/linux/generic/files/drivers/platform/mikrotik/routerboot.c
@@ -210,7 +210,7 @@ ssize_t routerboot_tag_show_u32s(const u8 *pld, u16 pld_len, char *buf)
 	return out - buf;
 }
 
-module_init(routerboot_init);
+late_initcall(routerboot_init);
 module_exit(routerboot_exit);
 
 MODULE_LICENSE("GPL v2");
-- 
2.31.1




More information about the openwrt-devel mailing list