lwfinger / rtl8723bu

Driver for RTL8723BU
283 stars 143 forks source link

Cannot run dirver on OpenWRT 19.07 MT7688 #169

Open bigdolphin opened 3 years ago

bigdolphin commented 3 years ago

Hello, I am trying to implement the driver into MT7688 with OpenWRT 19.07. I successfully compiled the driver but cannot run it, everytime I insmod or modprobe the module, the system says:

[ 179.297161] RTL871X: module init start [ 179.300977] RTL871X: rtl8723bu v4.3.6.11_12942.20141204_BTCOEX20140507-4E40 [ 179.308113] RTL871X: rtl8723bu BT-Coex version = BTCOEX20140507-4E40 [ 179.315968] ------------[ cut here ]------------ [ 179.320796] WARNING: CPU: 0 PID: 4777 at backports-4.19.137-1/net/wireless/core.c:743 wiphy_register+0x2a4/0x9d0 [cfg80211] [ 179.332173] Modules linked in: 8723bu(+) rtl8192cu rtl8192c_common rtl_usb rt2800usb rt2800lib rt2500usb qcserial pppoe ppp_async option mt76x0u mt76x0_common ipw cdc_mbim w1_therm uvcvideo usb_wwan usb_serial_simple ti_usb_3410_5052 sr9700 snd_usb_audio smsc95xx sierra_net sierra rtlwifi rtl8187 rt73usb rt2x00usb rt2x00lib rndis_host qmi_wwan pppox ppp_synctty ppp_generic plusb pl2303 p54usb p54common oti6858 nf_conntrack_ipv6 mt76x2u mt76x2e mt76x2_common mt76x02_usb mt76x02_lib mt7603e mt7601u mt76_usb mt76 mos7840 mos7720 mmc_spi mct_u232 mcs7830 mac80211 keyspan kalmia iptable_nat ipt_REJECT ipt_MASQUERADE io_edgeport huawei_cdc_ncm garmin_gps ftdi_sio dm9601 cypress_m8 cp210x ch341 cfg80211 cdc_subset cdc_ncm cdc_ether cdc_eem belkin_sa ax88179_178a at25 at24 asix ark3116 xt_time xt_tcpudp [ 179.403925] xt_tcpmss xt_statistic xt_state xt_recent xt_nat xt_multiport xt_mark xt_mac xt_limit xt_length xt_hl xt_helper xt_ecn xt_dscp xt_conntrack xt_connmark xt_connlimit xt_connbytes xt_comment xt_TCPMSS xt_REDIRECT xt_LOG xt_HL xt_FLOWOFFLOAD xt_DSCP xt_CT xt_CLASSIFY xr_usb_serial_common wire visor videobuf2_v4l2 vhci_hcd usbserial usbnet usblp usbip_host usbip_core usbhid ums_usbat ums_sddr55 ums_sddr09 ums_karma ums_jumpshot ums_isd200 ums_freecom ums_datafab ums_cypress ums_alauda tpm_rng spidev snd_usbmidi_lib slhc rtl8150 rng_core rfcomm r8712u r8152 pwm_mediatek_ramips pegasus of_mmc_spi nvmem_core nf_reject_ipv4 nf_nat_redirect nf_nat_masquerade_ipv4 nf_conntrack_ipv4 nf_nat_ipv4 nf_nat nf_log_ipv4 nf_flow_table_hw nf_flow_table nf_defrag_ipv6 nf_defrag_ipv4 nf_conntrack_rtcache [ 179.475823] lzo libcrc32c kaweth iptable_raw iptable_mangle iptable_filter ipt_ECN ipheth ip_tables hwmon hso hidp hid_generic hci_uart ezusb dmx_usb crc7 crc_itu_t crc_ccitt compat cdc_wdm btusb btintel bnep bluetooth snd_soc_wm8960 regmap_i2c snd_soc_simple_card snd_soc_simple_card_utils snd_soc_ralink_i2s fuse act_connmark nf_conntrack sch_tbf sch_ingress sch_htb sch_hfsc em_u32 cls_u32 cls_tcindex cls_route cls_matchall cls_fw cls_flow cls_basic act_skbedit act_mirred videobuf2_vmalloc videobuf2_memops videobuf2_core hid v4l2_common videodev evdev i2c_mt7621 snd_soc_core gpio_pcf857x ralink_gdma virt_dma i2c_dev i2c_core xt_set ip_set_list_set ip_set_hash_netportnet ip_set_hash_netport ip_set_hash_netnet ip_set_hash_netiface ip_set_hash_net ip_set_hash_mac ip_set_hash_ipportnet ip_set_hash_ipportip [ 179.548530] ip_set_hash_ipport ip_set_hash_ipmark ip_set_hash_ip ip_set_bitmap_port ip_set_bitmap_ipmac ip_set_bitmap_ip ip_set nfnetlink nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 msdos ifb snd_rawmidi snd_seq_device snd_pcm_oss snd_pcm_dmaengine snd_pcm snd_timer snd_mixer_oss snd_hwdep snd_compress snd soundcore input_core vfat fat autofs4 nls_utf8 nls_iso8859_1 nls_cp437 eeprom_93cx6 dma_shared_buffer ecdh_generic sha256_generic md5 kpp ecb cmac crypto_acompress mmc_block usb_storage sdhci_pltfm sdhci mmc_core leds_gpio uhci_hcd ohci_platform ohci_hcd ehci_pci ehci_platform sd_mod scsi_mod ehci_hcd gpio_button_hotplug ext4 mbcache jbd2 exfat btrfs zstd_decompress zstd_compress zlib_inflate zlib_deflate xxhash xor raid6_pq lzo_decompress [ 179.620926] lzo_compress usbcore nls_base usb_common crc16 mii tpm aead crypto_null cryptomgr crc32c_generic crypto_hash [ 179.632119] CPU: 0 PID: 4777 Comm: insmod Not tainted 4.14.193 #0 [ 179.638314] Stack : 804b0000 80469d5c 00000000 00000000 80441aa0 85fa9a74 857cc2dc 80495947 [ 179.646862] 8043dae8 000012a9 805f3660 000002e7 87ff0400 00000001 85fa9a28 fd0ec6b0 [ 179.655389] 00000000 00000000 805f0000 00007cc0 00000000 0000018d 00000007 00000000 [ 179.663892] 00000000 804a0000 0009a537 00000000 80000000 00000009 00000000 86774520 [ 179.672381] 8674057c 000002e7 87ff0400 00000028 00000000 80210cd0 00000000 805f0000 [ 179.680880] ... [ 179.683375] Call Trace: [ 179.685881] [<8000af90>] show_stack+0x58/0x100 [ 179.690392] [<80026990>] __warn+0xe4/0x13c [ 179.694565] [<80026a78>] warn_slowpath_null+0x1c/0x34 [ 179.699796] [<8674057c>] wiphy_register+0x2a4/0x9d0 [cfg80211] [ 179.706340] [<8355392c>] rtw_wdev_alloc+0x1a8/0x2e4 [8723bu] [ 179.713211] [<83540a94>] rtw_set_hal_ops+0x350/0x550 [8723bu] [ 180.129843] ---[ end trace 9cbf6cb6f031612a ]--- [ 180.134800] usbcore: registered new interface driver rtl8723bu [ 180.140720] RTL871X: module init ret=0

These are makefile files for compiling under OpenWRT SDK:

Path: package/kmod-rtl8723bu/Makefile

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

# Name and release number of this package
PKG_NAME:=kmod-rtl8723bu
PKG_VERSION:=1.0.0
PKG_RELEASE:=1

# This specifies the directory where we're going to build the program.
# The root build directory, $(BUILD_DIR), is by default the build_mipsel
# directory in your OpenWrt SDK directory
PKG_BUILD_DIR := $(BUILD_DIR)/$(PKG_NAME)

include $(INCLUDE_DIR)/package.mk

# Specify package information for this program.
# The variables defined here should be self explanatory.
define Package/$(PKG_NAME)      
    CATEGORY:=Kernel modules
    SUBMENU:=Wireless Drivers
    TITLE:=Realtek RTL8723BU Driver
    DEPENDS:=+libstdcpp +kmod-cfg80211 +kmod-usb-core
endef

define Package/$(PKG_NAME)/description
 If you can't figure out what this program does,
 you're probably brain-dead and need immediate
 medical attention.
endef

# Specify what needs to be done to prepare for building the package.
# In our case, we need to copy the source files to the build directory.
# This is NOT the default.  The default uses the PKG_SOURCE_URL and the
# PKG_SOURCE which is not defined here to download the source from the web.
# In order to just build a simple program that we have just written, it is
# much easier to do it this way.
define Build/Prepare
    mkdir -p $(PKG_BUILD_DIR)
    $(CP) ./src/* $(PKG_BUILD_DIR)/
endef

# We do not need to define Build/Configure or Build/Compile directives
# The defaults are appropriate for compiling a simple program such as this one

# Specify where and how to install the program. Since we only have one file,
# the hellocpp executable, install it by copying it to the /bin directory on
# the router. The $(1) variable represents the root directory on the router running
# OpenWrt. The $(INSTALL_DIR) variable contains a command to prepare the install
# directory if it does not already exist.  Likewise $(INSTALL_BIN) contains the
# command to copy the binary file from its current location (in our case the build
# directory) to the install directory.
define Package/$(PKG_NAME)/install
    $(INSTALL_DIR) $(1)/bin
    $(INSTALL_DIR) $(1)/lib
    $(INSTALL_DIR) $(1)/lib/modules
    $(INSTALL_DIR) $(1)/lib/modules/$(LINUX_VERSION)
    $(INSTALL_DIR) $(1)/lib/firmware
    $(INSTALL_DIR) $(1)/lib/firmware/rtl_bt
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/convert_firmware $(1)/bin/rtl8723bu_convert
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/8723bu.ko $(1)/lib/modules/$(LINUX_VERSION)/rtl8723bu.ko
    $(INSTALL_BIN) $(PKG_BUILD_DIR)/rtl8723b_fw.bin $(1)/lib/firmware/rtl_bt/
endef

# This line executes the necessary commands to compile our program.
# The above define directives specify all the information needed, but this
# line calls BuildPackage which in turn actually uses this information to
# build a package.
$(eval $(call BuildPackage,$(PKG_NAME),+kmod-cfg80211))

Path: package/kmod-rtl8723bu/src/Makefile (I place all source codes in the path package/kmod-rtl8723bu/src)

include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/kernel.mk

INSTALL_FW_PATH = $(INSTALL_MOD_PATH)/lib/firmware
FW_DIR  := $(INSTALL_FW_PATH)/rtl_bt

DEPMOD  = /sbin/depmod

EXTRA_CFLAGS += $(USER_EXTRA_CFLAGS)
EXTRA_CFLAGS += -O1
#EXTRA_CFLAGS += -O3
#EXTRA_CFLAGS += -Wall
#EXTRA_CFLAGS += -Wextra
#EXTRA_CFLAGS += -Werror
#EXTRA_CFLAGS += -pedantic
#EXTRA_CFLAGS += -Wshadow -Wpointer-arith -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes

EXTRA_CFLAGS += -Wno-unused-variable
EXTRA_CFLAGS += -Wno-unused-value
EXTRA_CFLAGS += -Wno-unused-label
EXTRA_CFLAGS += -Wno-unused-parameter
EXTRA_CFLAGS += -Wno-unused-function
EXTRA_CFLAGS += -Wno-unused
EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE

ccflags-y += -D__CHECK_ENDIAN__

#EXTRA_CFLAGS += -Wno-uninitialized

EXTRA_CFLAGS += -g -I$(src)/include

#EXTRA_LDFLAGS += --strip-debug

CONFIG_AUTOCFG_CP = n

########################## WIFI IC ############################
CONFIG_RTL8723B = y
########################## Features ###########################
CONFIG_POWER_SAVING = n
CONFIG_USB_AUTOSUSPEND = n
CONFIG_HW_PWRP_DETECTION = n
CONFIG_WIFI_TEST = n
CONFIG_BT_COEXIST = y
CONFIG_INTEL_WIDI = n
CONFIG_WAPI_SUPPORT = n
CONFIG_EFUSE_CONFIG_FILE = n
CONFIG_EXT_CLK = n
CONFIG_TRAFFIC_PROTECT = y
CONFIG_LOAD_PHY_PARA_FROM_FILE = y
CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY = n
CONFIG_CALIBRATE_TX_POWER_TO_MAX = n
CONFIG_RTW_ADAPTIVITY_EN = auto
CONFIG_RTW_ADAPTIVITY_MODE = normal
CONFIG_SKIP_SIGNAL_SCALE_MAPPING = n
######################## Wake On Lan ##########################
CONFIG_WOWLAN = n
CONFIG_GPIO_WAKEUP = n
CONFIG_PNO_SUPPORT = n
CONFIG_PNO_SET_DEBUG = n
CONFIG_AP_WOWLAN = n
###################### Platform Related #######################
CONFIG_PLATFORM_MT76X8 = y
CONFIG_PLATFORM_I386_PC = n
CONFIG_PLATFORM_FS_MX61 = n
###############################################################

CONFIG_DRVEXT_MODULE = n

export TopDIR ?= $(shell pwd)

########### COMMON  #################################
HCI_NAME = usb

_OS_INTFS_FILES :=  os_dep/osdep_service.o \
            os_dep/os_intfs.o \
            os_dep/usb_intf.o \
            os_dep/usb_ops_linux.o \
            os_dep/ioctl_linux.o \
            os_dep/xmit_linux.o \
            os_dep/mlme_linux.o \
            os_dep/recv_linux.o \
            os_dep/ioctl_cfg80211.o \
            os_dep/wifi_regd.o \
            os_dep/rtw_android.o \
            os_dep/rtw_proc.o

_HAL_INTFS_FILES := hal/hal_intf.o \
            hal/hal_com.o \
            hal/hal_com_phycfg.o \
            hal/hal_phy.o \
            hal/hal_btcoex.o \
            hal/hal_usb.o \
            hal/hal_usb_led.o

_OUTSRC_FILES := hal/odm_debug.o    \
        hal/odm_AntDiv.o\
        hal/odm_interface.o\
        hal/odm_HWConfig.o\
        hal/odm.o\
        hal/HalPhyRf.o\
        hal/odm_EdcaTurboCheck.o\
        hal/odm_DIG.o\
        hal/odm_PathDiv.o\
        hal/odm_RaInfo.o\
        hal/odm_DynamicBBPowerSaving.o\
        hal/odm_DynamicTxPower.o\
        hal/odm_CfoTracking.o\
        hal/odm_NoiseMonitor.o

EXTRA_CFLAGS += -I$(src)/platform
_PLATFORM_FILES := platform/platform_ops.o

ifeq ($(CONFIG_BT_COEXIST), y)
EXTRA_CFLAGS += -I$(src)/hal
_OUTSRC_FILES += hal/HalBtc8723b1Ant.o \
         hal/HalBtc8723b2Ant.o
endif

########### HAL_RTL8723B #################################

RTL871X = rtl8723b
MODULE_NAME = 8723bu

_HAL_INTFS_FILES += hal/HalPwrSeqCmd.o \
                    hal/Hal8723BPwrSeq.o\
                    hal/$(RTL871X)_sreset.o

_HAL_INTFS_FILES += hal/$(RTL871X)_hal_init.o \
            hal/$(RTL871X)_phycfg.o \
            hal/$(RTL871X)_rf6052.o \
            hal/$(RTL871X)_dm.o \
            hal/$(RTL871X)_rxdesc.o \
            hal/$(RTL871X)_cmd.o \

_HAL_INTFS_FILES += \
            hal/usb_halinit.o \
            hal/rtl$(MODULE_NAME)_led.o \
            hal/rtl$(MODULE_NAME)_xmit.o \
            hal/rtl$(MODULE_NAME)_recv.o

_HAL_INTFS_FILES += hal/usb_ops.o

_OUTSRC_FILES += hal/HalHWImg8723B_BB.o\
            hal/HalHWImg8723B_MAC.o\
            hal/HalHWImg8723B_RF.o\
            hal/HalHWImg8723B_FW.o\
            hal/odm_RegConfig8723B.o\
            hal/HalPhyRf_8723B.o\
            hal/odm_RTL8723B.o

########### AUTO_CFG  ################################# 

ifeq ($(CONFIG_AUTOCFG_CP), y)
$(shell cp $(TopDIR)/autoconf_$(RTL871X)_usb_linux.h $(TopDIR)/include/autoconf.h)
endif

########### END OF PATH  #################################

ifeq ($(CONFIG_USB_AUTOSUSPEND), y)
EXTRA_CFLAGS += -DCONFIG_USB_AUTOSUSPEND
endif

ifeq ($(CONFIG_POWER_SAVING), y)
EXTRA_CFLAGS += -DCONFIG_POWER_SAVING
endif

ifeq ($(CONFIG_HW_PWRP_DETECTION), y)
EXTRA_CFLAGS += -DCONFIG_HW_PWRP_DETECTION
endif

ifeq ($(CONFIG_WIFI_TEST), y)
EXTRA_CFLAGS += -DCONFIG_WIFI_TEST
endif

ifeq ($(CONFIG_BT_COEXIST), y)
EXTRA_CFLAGS += -DCONFIG_BT_COEXIST
endif

ifeq ($(CONFIG_INTEL_WIDI), y)
EXTRA_CFLAGS += -DCONFIG_INTEL_WIDI
endif

ifeq ($(CONFIG_WAPI_SUPPORT), y)
EXTRA_CFLAGS += -DCONFIG_WAPI_SUPPORT
endif

ifeq ($(CONFIG_EFUSE_CONFIG_FILE), y)
EXTRA_CFLAGS += -DCONFIG_EFUSE_CONFIG_FILE
ifeq ($(MODULE_NAME), 8189es)
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"/system/etc/wifi/wifi_efuse_8189e.map\"
else
EXTRA_CFLAGS += -DEFUSE_MAP_PATH=\"/system/etc/wifi/wifi_efuse_$(MODULE_NAME).map\"
endif
EXTRA_CFLAGS += -DWIFIMAC_PATH=\"/data/wifimac.txt\"
endif

ifeq ($(CONFIG_EXT_CLK), y)
EXTRA_CFLAGS += -DCONFIG_EXT_CLK
endif

ifeq ($(CONFIG_TRAFFIC_PROTECT), y)
EXTRA_CFLAGS += -DCONFIG_TRAFFIC_PROTECT
endif

ifeq ($(CONFIG_LOAD_PHY_PARA_FROM_FILE), y)
EXTRA_CFLAGS += -DCONFIG_LOAD_PHY_PARA_FROM_FILE
endif

ifeq ($(CONFIG_CALIBRATE_TX_POWER_BY_REGULATORY), y)
EXTRA_CFLAGS += -DCONFIG_CALIBRATE_TX_POWER_BY_REGULATORY
endif

ifeq ($(CONFIG_CALIBRATE_TX_POWER_TO_MAX), y)
EXTRA_CFLAGS += -DCONFIG_CALIBRATE_TX_POWER_TO_MAX
endif

ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), disable)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=0
else ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), enable)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=1
else ifeq ($(CONFIG_RTW_ADAPTIVITY_EN), auto)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_EN=2
endif

ifeq ($(CONFIG_RTW_ADAPTIVITY_MODE), normal)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_MODE=0
else ifeq ($(CONFIG_RTW_ADAPTIVITY_MODE), carrier_sense)
EXTRA_CFLAGS += -DCONFIG_RTW_ADAPTIVITY_MODE=1
endif

ifeq ($(CONFIG_SKIP_SIGNAL_SCALE_MAPPING), y)
EXTRA_CFLAGS += -DCONFIG_SKIP_SIGNAL_SCALE_MAPPING
endif

ifeq ($(CONFIG_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_WOWLAN
endif

ifeq ($(CONFIG_AP_WOWLAN), y)
EXTRA_CFLAGS += -DCONFIG_AP_WOWLAN
endif

ifeq ($(CONFIG_PNO_SUPPORT), y)
EXTRA_CFLAGS += -DCONFIG_PNO_SUPPORT
ifeq ($(CONFIG_PNO_SET_DEBUG), y)
EXTRA_CFLAGS += -DCONFIG_PNO_SET_DEBUG
endif
endif

ifeq ($(CONFIG_GPIO_WAKEUP), y)
EXTRA_CFLAGS += -DCONFIG_GPIO_WAKEUP
endif

ifeq ($(CONFIG_PLATFORM_MT76X8), y)
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211
EXTRA_CFLAGS += -DRTW_USE_CFG80211_STA_EVENT # only enable when kernel >= 3.2
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN
THIS_ARCH := $(LINUX_KARCH)
KVER  := $(LINUX_VERSION)
CROSS_COMPILE := $(TOOLCHAIN_DIR)/bin/mipsel-openwrt-linux-musl-
CC = $(CROSS_COMPILE)gcc
CXX = $(CROSS_COMPILE)g++
KSRC := $(LINUX_DIR)
MODDESTDIR := $(MODLIB)
ENDINESS = -EL
endif 

ifeq ($(CONFIG_PLATFORM_I386_PC), y)
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211
EXTRA_CFLAGS += -DRTW_USE_CFG80211_STA_EVENT # only enable when kernel >= 3.2
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
SUBARCH := $(shell uname -m | sed -e s/i.86/i386/ | sed -e s/ppc/powerpc/ | sed -e s/armv.l/arm/)
THIS_ARCH ?= $(SUBARCH)
CROSS_COMPILE ?=
KVER  := $(shell uname -r)
KSRC := /lib/modules/$(KVER)/build
MODDESTDIR := $(INSTALL_MOD_PATH)/lib/modules/$(KVER)/kernel/drivers/net/wireless/
INSTALL_PREFIX :=
ENDINESS =
endif

ifeq ($(CONFIG_PLATFORM_FS_MX61), y)
EXTRA_CFLAGS += -DCONFIG_IOCTL_CFG80211
EXTRA_CFLAGS += -DRTW_USE_CFG80211_STA_EVENT # only enable when kernel >= 3.2
EXTRA_CFLAGS += -DCONFIG_P2P_IPS
EXTRA_CFLAGS += -DCONFIG_LITTLE_ENDIAN -Wno-error=date-time
THIS_ARCH := arm
KSRC ?= $(KERNEL_SRC)
MODDESTDIR := kernel/drivers/net/wireless/
LICENSE = "GPLv2"
ENDINESS = -EL
endif

ifneq ($(USER_MODULE_NAME),)
MODULE_NAME := $(USER_MODULE_NAME)
endif

ifneq ($(KERNELRELEASE),)

rtk_core := core/rtw_cmd.o \
        core/rtw_security.o \
        core/rtw_debug.o \
        core/rtw_io.o \
        core/rtw_ioctl_query.o \
        core/rtw_ioctl_set.o \
        core/rtw_ieee80211.o \
        core/rtw_mlme.o \
        core/rtw_mlme_ext.o \
        core/rtw_wlan_util.o \
        core/rtw_vht.o \
        core/rtw_pwrctrl.o \
        core/rtw_rf.o \
        core/rtw_recv.o \
        core/rtw_sta_mgt.o \
        core/rtw_ap.o \
        core/rtw_xmit.o \
        core/rtw_p2p.o \
        core/rtw_tdls.o \
        core/rtw_br_ext.o \
        core/rtw_iol.o \
        core/rtw_sreset.o \
        core/rtw_btcoex.o \
        core/rtw_beamforming.o \
        core/rtw_odm.o \
        core/rtw_efuse.o

$(MODULE_NAME)-y += $(rtk_core)

$(MODULE_NAME)-$(CONFIG_INTEL_WIDI) += core/rtw_intel_widi.o

$(MODULE_NAME)-$(CONFIG_WAPI_SUPPORT) += core/rtw_wapi.o    \
                    core/rtw_wapi_sms4.o

$(MODULE_NAME)-y += $(_OS_INTFS_FILES)
$(MODULE_NAME)-y += $(_HAL_INTFS_FILES)
$(MODULE_NAME)-y += $(_OUTSRC_FILES)
$(MODULE_NAME)-y += $(_PLATFORM_FILES)

obj-m := $(MODULE_NAME).o

else

all: modules

modules:    
    $(CC) $(ENDINESS) -o convert_firmware convert_firmware.c        
    $(MAKE) ARCH=$(THIS_ARCH) \
               CROSS_COMPILE=$(CROSS_COMPILE) \
               -C $(KSRC) \
               M=$(shell pwd) \
               modules

strip:
    $(CROSS_COMPILE)strip $(MODULE_NAME).ko --strip-unneeded

install:
    install -p -m 644 -D $(MODULE_NAME).ko $(MODDESTDIR)$(MODULE_NAME).ko
    $(DEPMOD)  -a ${KVER}
    install rtl8723b_fw.bin -D $(FW_DIR)/rtl8723b_fw.bin

modules_install:
    $(MAKE) INSTALL_MOD_DIR=$(MODDESTDIR) -C $(KSRC) M=$(shell pwd) modules_install

uninstall:
    rm -f $(MODDESTDIR)$(MODULE_NAME).ko
    $(DEPMOD) -a ${KVER}
    rm -f $(FW_DIR)/rtl8723b_fw.bin

config_r:
    @echo "make config"
    /bin/bash script/Configure script/config.in

.PHONY: modules clean

clean:
    cd hal ; rm -fr *.mod.c *.mod *.o .*.cmd */*.ko
    cd core ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    cd os_dep ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    cd platform ; rm -fr *.mod.c *.mod *.o .*.cmd *.ko
    rm -fr Module.symvers ; rm -fr Module.markers ; rm -fr modules.order
    rm -fr *.mod.c *.mod *.o .*.cmd *.ko *~
    rm -fr .tmp_versions .cache.mk
    rm convert_firmware
endif

Please help me solve it, I am being in stuck of this issue for months. Thank you very much. Best regards.

lwfinger commented 3 years ago

Please check the code in the kernel at backports-4.19.137-1/net/wireless/core.c line 743 to see what warning is being triggered. Once we know that, perhaps we will know how to fix it.

bigdolphin commented 3 years ago

Thank you for your help, I see that there are two warnings on dmesg output:

WARNING: CPU: 0 PID: 1646 at backports-4.19.137-1/net/wireless/core.c:743 wiphy_register+0x2a4/0x9d0 [cfg80211] WARNING: CPU: 0 PID: 1646 at backports-4.19.137-1/net/wireless/core.c:821 wiphy_register+0x61c/0x9d0 [cfg80211]

If I do not use CONFIG_IOCTL_CFG80211, I can load the module in OpenWRT and dmesg show wlan2 for this module, however, iw does not see it then I cannot scan any wifi.

This is the dmesg output when not using CONFIG_IOCTL_CFG80211:

[ 140.800350] RTL871X: module init start [ 140.804248] RTL871X: rtl8723bu v4.3.6.11_12942.20141204_BTCOEX20140507-4E40 [ 140.811305] RTL871X: rtl8723bu BT-Coex version = BTCOEX20140507-4E40 [ 140.976836] RTL871X: rtw_ndev_init(wlan1) [ 140.982461] RTL871X: rtw_ndev_init(wlan2) [ 140.988317] usbcore: registered new interface driver rtl8723bu [ 140.994309] RTL871X: module init ret=0 [ 174.729178] RTL871X: RTW_ADAPTIVITYEN [ 174.729204] AUTO, chplan:0x20, Regulation:3,3 [ 174.737563] RTL871X: RTW_ADAPTIVITYMODE [ 174.737567] NORMAL [ 175.459655] IPv6: ADDRCONF(NETDEV_UP): wlan2: link is not ready

And this the core.c code in the backports:


1. /*
2.  * This is the linux wireless configuration interface.
3.  *
4.  * Copyright 2006-2010       Johannes Berg <johannes@sipsolutions.net>
5.  * Copyright 2013-2014  Intel Mobile Communications GmbH
6.  * Copyright 2015-2017   Intel Deutschland GmbH
7.  */
8. 
9. #define pr_fmt(fmt) KBUILD_MODNAME ": " fmt
10. 
11. #include <linux/if.h>
12. #include <linux/module.h>
13. #include <linux/err.h>
14. #include <linux/list.h>
15. #include <linux/slab.h>
16. #include <linux/nl80211.h>
17. #include <linux/debugfs.h>
18. #include <linux/notifier.h>
19. #include <linux/device.h>
20. #include <linux/etherdevice.h>
21. #include <linux/rtnetlink.h>
22. #include <linux/sched.h>
23. #include <net/genetlink.h>
24. #include <net/cfg80211.h>
25. #include "nl80211.h"
26. #include "core.h"
27. #include "sysfs.h"
28. #include "debugfs.h"
29. #include "wext-compat.h"
30. #include "rdev-ops.h"
31. 
32. /* name for sysfs, %d is appended */
33. #define PHY_NAME "phy"
34. 
35. MODULE_AUTHOR("Johannes Berg");
36. MODULE_LICENSE("GPL");
37. MODULE_DESCRIPTION("wireless configuration support");
38. MODULE_ALIAS_GENL_FAMILY(NL80211_GENL_NAME);
39. 
40. /* RCU-protected (and RTNL for writers) */
41. LIST_HEAD(cfg80211_rdev_list);
42. int cfg80211_rdev_list_generation;
43. 
44. /* for debugfs */
45. static struct dentry *ieee80211_debugfs_dir;
46. 
47. /* for the cleanup, scan and event works */
48. struct workqueue_struct *cfg80211_wq;
49. 
50. static bool cfg80211_disable_40mhz_24ghz;
51. module_param(cfg80211_disable_40mhz_24ghz, bool, 0644);
52. MODULE_PARM_DESC(cfg80211_disable_40mhz_24ghz,
53.          "Disable 40MHz support in the 2.4GHz band");
54. 
55. struct cfg80211_registered_device *cfg80211_rdev_by_wiphy_idx(int wiphy_idx)
56. {
57.     struct cfg80211_registered_device *result = NULL, *rdev;
58. 
59.     ASSERT_RTNL();
60. 
61.     list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
62.         if (rdev->wiphy_idx == wiphy_idx) {
63.             result = rdev;
64.             break;
65.         }
66.     }
67. 
68.     return result;
69. }
70. 
71. int get_wiphy_idx(struct wiphy *wiphy)
72. {
73.     struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
74. 
75.     return rdev->wiphy_idx;
76. }
77. 
78. struct wiphy *wiphy_idx_to_wiphy(int wiphy_idx)
79. {
80.     struct cfg80211_registered_device *rdev;
81. 
82.     ASSERT_RTNL();
83. 
84.     rdev = cfg80211_rdev_by_wiphy_idx(wiphy_idx);
85.     if (!rdev)
86.         return NULL;
87.     return &rdev->wiphy;
88. }
89. 
90. static int cfg80211_dev_check_name(struct cfg80211_registered_device *rdev,
91.                    const char *newname)
92. {
93.     struct cfg80211_registered_device *rdev2;
94.     int wiphy_idx, taken = -1, digits;
95. 
96.     ASSERT_RTNL();
97. 
98.     if (strlen(newname) > NL80211_WIPHY_NAME_MAXLEN)
99.         return -EINVAL;
100. 
101.    /* prohibit calling the thing phy%d when %d is not its number */
102.    sscanf(newname, PHY_NAME "%d%n", &wiphy_idx, &taken);
103.    if (taken == strlen(newname) && wiphy_idx != rdev->wiphy_idx) {
104.        /* count number of places needed to print wiphy_idx */
105.        digits = 1;
106.        while (wiphy_idx /= 10)
107.            digits++;
108.        /*
109.         * deny the name if it is phy<idx> where <idx> is printed
110.         * without leading zeroes. taken == strlen(newname) here
111.         */
112.        if (taken == strlen(PHY_NAME) + digits)
113.            return -EINVAL;
114.    }
115. 
116.    /* Ensure another device does not already have this name. */
117.    list_for_each_entry(rdev2, &cfg80211_rdev_list, list)
118.        if (strcmp(newname, wiphy_name(&rdev2->wiphy)) == 0)
119.            return -EINVAL;
120. 
121.    return 0;
122. }
123. 
124. int cfg80211_dev_rename(struct cfg80211_registered_device *rdev,
125.            char *newname)
126. {
127.    int result;
128. 
129.    ASSERT_RTNL();
130. 
131.    /* Ignore nop renames */
132.    if (strcmp(newname, wiphy_name(&rdev->wiphy)) == 0)
133.        return 0;
134. 
135.    result = cfg80211_dev_check_name(rdev, newname);
136.    if (result < 0)
137.        return result;
138. 
139.    result = device_rename(&rdev->wiphy.dev, newname);
140.    if (result)
141.        return result;
142. 
143.    if (rdev->wiphy.debugfsdir &&
144.        !debugfs_rename(rdev->wiphy.debugfsdir->d_parent,
145.                rdev->wiphy.debugfsdir,
146.                rdev->wiphy.debugfsdir->d_parent,
147.                newname))
148.        pr_err("failed to rename debugfs dir to %s!\n", newname);
149. 
150.    nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
151. 
152.    return 0;
153. }
154. 
155. int cfg80211_switch_netns(struct cfg80211_registered_device *rdev,
156.              struct net *net)
157. {
158.    struct wireless_dev *wdev;
159.    int err = 0;
160. 
161.    if (!(rdev->wiphy.flags & WIPHY_FLAG_NETNS_OK))
162.        return -EOPNOTSUPP;
163. 
164.    list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
165.        if (!wdev->netdev)
166.            continue;
167.        wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
168.        err = dev_change_net_namespace(wdev->netdev, net, "wlan%d");
169.        if (err)
170.            break;
171.        wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
172.    }
173. 
174.    if (err) {
175.        /* failed -- clean up to old netns */
176.        net = wiphy_net(&rdev->wiphy);
177. 
178.        list_for_each_entry_continue_reverse(wdev,
179.                             &rdev->wiphy.wdev_list,
180.                             list) {
181.            if (!wdev->netdev)
182.                continue;
183.            wdev->netdev->features &= ~NETIF_F_NETNS_LOCAL;
184.            err = dev_change_net_namespace(wdev->netdev, net,
185.                            "wlan%d");
186.            WARN_ON(err);
187.            wdev->netdev->features |= NETIF_F_NETNS_LOCAL;
188.        }
189. 
190.        return err;
191.    }
192. 
193.    wiphy_net_set(&rdev->wiphy, net);
194. 
195.    err = device_rename(&rdev->wiphy.dev, dev_name(&rdev->wiphy.dev));
196.    WARN_ON(err);
197. 
198.    return 0;
199. }
200. 
201. static void cfg80211_rfkill_poll(struct rfkill *rfkill, void *data)
202. {
203.    struct cfg80211_registered_device *rdev = data;
204. 
205.    rdev_rfkill_poll(rdev);
206. }
207. 
208. void cfg80211_stop_p2p_device(struct cfg80211_registered_device *rdev,
209.                  struct wireless_dev *wdev)
210. {
211.    ASSERT_RTNL();
212. 
213.    if (WARN_ON(wdev->iftype != NL80211_IFTYPE_P2P_DEVICE))
214.        return;
215. 
216.    if (!wdev_running(wdev))
217.        return;
218. 
219.    rdev_stop_p2p_device(rdev, wdev);
220.    wdev->is_running = false;
221. 
222.    rdev->opencount--;
223. 
224.    if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
225.        if (WARN_ON(!rdev->scan_req->notified))
226.            rdev->scan_req->info.aborted = true;
227.        ___cfg80211_scan_done(rdev, false);
228.    }
229. }
230. 
231. void cfg80211_stop_nan(struct cfg80211_registered_device *rdev,
232.               struct wireless_dev *wdev)
233. {
234.    ASSERT_RTNL();
235. 
236.    if (WARN_ON(wdev->iftype != NL80211_IFTYPE_NAN))
237.        return;
238. 
239.    if (!wdev_running(wdev))
240.        return;
241. 
242.    rdev_stop_nan(rdev, wdev);
243.    wdev->is_running = false;
244. 
245.    rdev->opencount--;
246. }
247. 
248. void cfg80211_shutdown_all_interfaces(struct wiphy *wiphy)
249. {
250.    struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
251.    struct wireless_dev *wdev;
252. 
253.    ASSERT_RTNL();
254. 
255.    list_for_each_entry(wdev, &rdev->wiphy.wdev_list, list) {
256.        if (wdev->netdev) {
257.            dev_close(wdev->netdev);
258.            continue;
259.        }
260.        /* otherwise, check iftype */
261.        switch (wdev->iftype) {
262.        case NL80211_IFTYPE_P2P_DEVICE:
263.            cfg80211_stop_p2p_device(rdev, wdev);
264.            break;
265.        case NL80211_IFTYPE_NAN:
266.            cfg80211_stop_nan(rdev, wdev);
267.            break;
268.        default:
269.            break;
270.        }
271.    }
272. }
273. EXPORT_SYMBOL_GPL(cfg80211_shutdown_all_interfaces);
274. 
275. static int cfg80211_rfkill_set_block(void *data, bool blocked)
276. {
277.    struct cfg80211_registered_device *rdev = data;
278. 
279.    if (!blocked)
280.        return 0;
281. 
282.    rtnl_lock();
283.    cfg80211_shutdown_all_interfaces(&rdev->wiphy);
284.    rtnl_unlock();
285. 
286.    return 0;
287. }
288. 
289. static void cfg80211_rfkill_sync_work(struct work_struct *work)
290. {
291.    struct cfg80211_registered_device *rdev;
292. 
293.    rdev = container_of(work, struct cfg80211_registered_device, rfkill_sync);
294.    cfg80211_rfkill_set_block(rdev, rfkill_blocked(rdev->rfkill));
295. }
296. 
297. static void cfg80211_event_work(struct work_struct *work)
298. {
299.    struct cfg80211_registered_device *rdev;
300. 
301.    rdev = container_of(work, struct cfg80211_registered_device,
302.                event_work);
303. 
304.    rtnl_lock();
305.    cfg80211_process_rdev_events(rdev);
306.    rtnl_unlock();
307. }
308. 
309. void cfg80211_destroy_ifaces(struct cfg80211_registered_device *rdev)
310. {
311.    struct wireless_dev *wdev, *tmp;
312. 
313.    ASSERT_RTNL();
314. 
315.    list_for_each_entry_safe(wdev, tmp, &rdev->wiphy.wdev_list, list) {
316.        if (wdev->nl_owner_dead)
317.            rdev_del_virtual_intf(rdev, wdev);
318.    }
319. }
320. 
321. static void cfg80211_destroy_iface_wk(struct work_struct *work)
322. {
323.    struct cfg80211_registered_device *rdev;
324. 
325.    rdev = container_of(work, struct cfg80211_registered_device,
326.                destroy_work);
327. 
328.    rtnl_lock();
329.    cfg80211_destroy_ifaces(rdev);
330.    rtnl_unlock();
331. }
332. 
333. static void cfg80211_sched_scan_stop_wk(struct work_struct *work)
334. {
335.    struct cfg80211_registered_device *rdev;
336.    struct cfg80211_sched_scan_request *req, *tmp;
337. 
338.    rdev = container_of(work, struct cfg80211_registered_device,
339.               sched_scan_stop_wk);
340. 
341.    rtnl_lock();
342.    list_for_each_entry_safe(req, tmp, &rdev->sched_scan_req_list, list) {
343.        if (req->nl_owner_dead)
344.            cfg80211_stop_sched_scan_req(rdev, req, false);
345.    }
346.    rtnl_unlock();
347. }
348. 
349. static void cfg80211_propagate_radar_detect_wk(struct work_struct *work)
350. {
351.    struct cfg80211_registered_device *rdev;
352. 
353.    rdev = container_of(work, struct cfg80211_registered_device,
354.                propagate_radar_detect_wk);
355. 
356.    rtnl_lock();
357. 
358.    regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->radar_chandef,
359.                       NL80211_DFS_UNAVAILABLE,
360.                       NL80211_RADAR_DETECTED);
361. 
362.    rtnl_unlock();
363. }
364. 
365. static void cfg80211_propagate_cac_done_wk(struct work_struct *work)
366. {
367.    struct cfg80211_registered_device *rdev;
368. 
369.    rdev = container_of(work, struct cfg80211_registered_device,
370.                propagate_cac_done_wk);
371. 
372.    rtnl_lock();
373. 
374.    regulatory_propagate_dfs_state(&rdev->wiphy, &rdev->cac_done_chandef,
375.                       NL80211_DFS_AVAILABLE,
376.                       NL80211_RADAR_CAC_FINISHED);
377. 
378.    rtnl_unlock();
379. }
380. 
381. /* exported functions */
382. 
383. struct wiphy *wiphy_new_nm(const struct cfg80211_ops *ops, int sizeof_priv,
384.               const char *requested_name)
385. {
386.    static atomic_t wiphy_counter = ATOMIC_INIT(0);
387. 
388.    struct cfg80211_registered_device *rdev;
389.    int alloc_size;
390. 
391.    /*
392.     * Make sure the padding is >= the rest of the struct so that we
393.     * always keep it large enough to pad out the entire original
394.     * kernel's struct. We really only need to make sure it's larger
395.     * than the kernel compat is compiled against, but since it'll
396.     * only increase in size make sure it's larger than the current
397.     * version of it. Subtract since it's included.
398.     */
399.    BUILD_BUG_ON(WIPHY_COMPAT_PAD_SIZE <
400.             sizeof(struct wiphy) - WIPHY_COMPAT_PAD_SIZE);
401. 
402.    WARN_ON(ops->add_key && (!ops->del_key || !ops->set_default_key));
403.    WARN_ON(ops->auth && (!ops->assoc || !ops->deauth || !ops->disassoc));
404.    WARN_ON(ops->connect && !ops->disconnect);
405.    WARN_ON(ops->join_ibss && !ops->leave_ibss);
406.    WARN_ON(ops->add_virtual_intf && !ops->del_virtual_intf);
407.    WARN_ON(ops->add_station && !ops->del_station);
408.    WARN_ON(ops->add_mpath && !ops->del_mpath);
409.    WARN_ON(ops->join_mesh && !ops->leave_mesh);
410.    WARN_ON(ops->start_p2p_device && !ops->stop_p2p_device);
411.    WARN_ON(ops->start_ap && !ops->stop_ap);
412.    WARN_ON(ops->join_ocb && !ops->leave_ocb);
413.    WARN_ON(ops->suspend && !ops->resume);
414.    WARN_ON(ops->sched_scan_start && !ops->sched_scan_stop);
415.    WARN_ON(ops->remain_on_channel && !ops->cancel_remain_on_channel);
416.    WARN_ON(ops->tdls_channel_switch && !ops->tdls_cancel_channel_switch);
417.    WARN_ON(ops->add_tx_ts && !ops->del_tx_ts);
418. 
419.    alloc_size = sizeof(*rdev) + sizeof_priv;
420. 
421.    rdev = kzalloc(alloc_size, GFP_KERNEL);
422.    if (!rdev)
423.        return NULL;
424. 
425.    rdev->ops = ops;
426. 
427.    rdev->wiphy_idx = atomic_inc_return(&wiphy_counter);
428. 
429.    if (unlikely(rdev->wiphy_idx < 0)) {
430.        /* ugh, wrapped! */
431.        atomic_dec(&wiphy_counter);
432.        kfree(rdev);
433.        return NULL;
434.    }
435. 
436.    /* atomic_inc_return makes it start at 1, make it start at 0 */
437.    rdev->wiphy_idx--;
438. 
439.    /* give it a proper name */
440.    if (requested_name && requested_name[0]) {
441.        int rv;
442. 
443.        rtnl_lock();
444.        rv = cfg80211_dev_check_name(rdev, requested_name);
445. 
446.        if (rv < 0) {
447.            rtnl_unlock();
448.            goto use_default_name;
449.        }
450. 
451.        rv = dev_set_name(&rdev->wiphy.dev, "%s", requested_name);
452.        rtnl_unlock();
453.        if (rv)
454.            goto use_default_name;
455.    } else {
456.        int rv;
457. 
458. use_default_name:
459.        /* NOTE:  This is *probably* safe w/out holding rtnl because of
460.         * the restrictions on phy names.  Probably this call could
461.         * fail if some other part of the kernel (re)named a device
462.         * phyX.  But, might should add some locking and check return
463.         * value, and use a different name if this one exists?
464.         */
465.        rv = dev_set_name(&rdev->wiphy.dev, PHY_NAME "%d", rdev->wiphy_idx);
466.        if (rv < 0) {
467.            kfree(rdev);
468.            return NULL;
469.        }
470.    }
471. 
472.    INIT_LIST_HEAD(&rdev->wiphy.wdev_list);
473.    INIT_LIST_HEAD(&rdev->beacon_registrations);
474.    spin_lock_init(&rdev->beacon_registrations_lock);
475.    spin_lock_init(&rdev->bss_lock);
476.    INIT_LIST_HEAD(&rdev->bss_list);
477.    INIT_LIST_HEAD(&rdev->sched_scan_req_list);
478.    INIT_WORK(&rdev->scan_done_wk, __cfg80211_scan_done);
479.    INIT_LIST_HEAD(&rdev->mlme_unreg);
480.    spin_lock_init(&rdev->mlme_unreg_lock);
481.    INIT_WORK(&rdev->mlme_unreg_wk, cfg80211_mlme_unreg_wk);
482.    INIT_DELAYED_WORK(&rdev->dfs_update_channels_wk,
483.              cfg80211_dfs_channels_update_work);
484.    device_initialize(&rdev->wiphy.dev);
485.    rdev->wiphy.dev.class = &ieee80211_class;
486.    rdev->wiphy.dev.platform_data = rdev;
487.    device_enable_async_suspend(&rdev->wiphy.dev);
488. 
489.    INIT_WORK(&rdev->destroy_work, cfg80211_destroy_iface_wk);
490.    INIT_WORK(&rdev->sched_scan_stop_wk, cfg80211_sched_scan_stop_wk);
491.    INIT_WORK(&rdev->sched_scan_res_wk, cfg80211_sched_scan_results_wk);
492.    INIT_WORK(&rdev->propagate_radar_detect_wk,
493.          cfg80211_propagate_radar_detect_wk);
494.    INIT_WORK(&rdev->propagate_cac_done_wk, cfg80211_propagate_cac_done_wk);
495. 
496. #ifdef CPTCFG_CFG80211_DEFAULT_PS
497.    rdev->wiphy.flags |= WIPHY_FLAG_PS_ON_BY_DEFAULT;
498. #endif
499. 
500.    wiphy_net_set(&rdev->wiphy, &init_net);
501. 
502.    rdev->rfkill_ops.set_block = cfg80211_rfkill_set_block;
503.    rdev->rfkill = rfkill_alloc(dev_name(&rdev->wiphy.dev),
504.                   &rdev->wiphy.dev, RFKILL_TYPE_WLAN,
505.                   &rdev->rfkill_ops, rdev);
506. 
507.    if (!rdev->rfkill) {
508.        wiphy_free(&rdev->wiphy);
509.        return NULL;
510.    }
511. 
512.    INIT_WORK(&rdev->rfkill_sync, cfg80211_rfkill_sync_work);
513.    INIT_WORK(&rdev->conn_work, cfg80211_conn_work);
514.    INIT_WORK(&rdev->event_work, cfg80211_event_work);
515. 
516.    init_waitqueue_head(&rdev->dev_wait);
517. 
518.    /*
519.     * Initialize wiphy parameters to IEEE 802.11 MIB default values.
520.     * Fragmentation and RTS threshold are disabled by default with the
521.     * special -1 value.
522.     */
523.    rdev->wiphy.retry_short = 7;
524.    rdev->wiphy.retry_long = 4;
525.    rdev->wiphy.frag_threshold = (u32) -1;
526.    rdev->wiphy.rts_threshold = (u32) -1;
527.    rdev->wiphy.coverage_class = 0;
528. 
529.    rdev->wiphy.max_num_csa_counters = 1;
530. 
531.    rdev->wiphy.max_sched_scan_plans = 1;
532.    rdev->wiphy.max_sched_scan_plan_interval = U32_MAX;
533. 
534.    return &rdev->wiphy;
535. }
536. EXPORT_SYMBOL(wiphy_new_nm);
537. 
538. static int wiphy_verify_combinations(struct wiphy *wiphy)
539. {
540.    const struct ieee80211_iface_combination *c;
541.    int i, j;
542. 
543.    for (i = 0; i < wiphy->n_iface_combinations; i++) {
544.        u32 cnt = 0;
545.        u16 all_iftypes = 0;
546. 
547.        c = &wiphy->iface_combinations[i];
548. 
549.        /*
550.         * Combinations with just one interface aren't real,
551.         * however we make an exception for DFS.
552.         */
553.        if (WARN_ON((c->max_interfaces < 2) && !c->radar_detect_widths))
554.            return -EINVAL;
555. 
556.        /* Need at least one channel */
557.        if (WARN_ON(!c->num_different_channels))
558.            return -EINVAL;
559. 
560.        /*
561.         * Put a sane limit on maximum number of different
562.         * channels to simplify channel accounting code.
563.         */
564.        if (WARN_ON(c->num_different_channels >
565.                CFG80211_MAX_NUM_DIFFERENT_CHANNELS))
566.            return -EINVAL;
567. 
568.        /* DFS only works on one channel. */
569.        if (WARN_ON(c->radar_detect_widths &&
570.                (c->num_different_channels > 1)))
571.            return -EINVAL;
572. 
573.        if (WARN_ON(!c->n_limits))
574.            return -EINVAL;
575. 
576.        for (j = 0; j < c->n_limits; j++) {
577.            u16 types = c->limits[j].types;
578. 
579.            /* interface types shouldn't overlap */
580.            if (WARN_ON(types & all_iftypes))
581.                return -EINVAL;
582.            all_iftypes |= types;
583. 
584.            if (WARN_ON(!c->limits[j].max))
585.                return -EINVAL;
586. 
587.            /* Shouldn't list software iftypes in combinations! */
588.            if (WARN_ON(wiphy->software_iftypes & types))
589.                return -EINVAL;
590. 
591.            /* Only a single P2P_DEVICE can be allowed */
592.            if (WARN_ON(types & BIT(NL80211_IFTYPE_P2P_DEVICE) &&
593.                    c->limits[j].max > 1))
594.                return -EINVAL;
595. 
596.            /* Only a single NAN can be allowed */
597.            if (WARN_ON(types & BIT(NL80211_IFTYPE_NAN) &&
598.                    c->limits[j].max > 1))
599.                return -EINVAL;
600. 
601.            /*
602.             * This isn't well-defined right now. If you have an
603.             * IBSS interface, then its beacon interval may change
604.             * by joining other networks, and nothing prevents it
605.             * from doing that.
606.             * So technically we probably shouldn't even allow AP
607.             * and IBSS in the same interface, but it seems that
608.             * some drivers support that, possibly only with fixed
609.             * beacon intervals for IBSS.
610.             */
611.            if (WARN_ON(types & BIT(NL80211_IFTYPE_ADHOC) &&
612.                    c->beacon_int_min_gcd)) {
613.                return -EINVAL;
614.            }
615. 
616.            cnt += c->limits[j].max;
617.            /*
618.             * Don't advertise an unsupported type
619.             * in a combination.
620.             */
621.            if (WARN_ON((wiphy->interface_modes & types) != types))
622.                return -EINVAL;
623.        }
624. 
625. #ifndef CPTCFG_WIRELESS_WDS
626.        if (WARN_ON(all_iftypes & BIT(NL80211_IFTYPE_WDS)))
627.            return -EINVAL;
628. #endif
629. 
630.        /* You can't even choose that many! */
631.        if (WARN_ON(cnt < c->max_interfaces))
632.            return -EINVAL;
633.    }
634. 
635.    return 0;
636. }
637. 
638. int wiphy_register(struct wiphy *wiphy)
639. {
640.    struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
641.    int res;
642.    enum nl80211_band band;
643.    struct ieee80211_supported_band *sband;
644.    bool have_band = false;
645.    int i;
646.    u16 ifmodes = wiphy->interface_modes;
647. 
648. #ifdef CONFIG_PM
649.    if (WARN_ON(wiphy->wowlan &&
650.            (wiphy->wowlan->flags & WIPHY_WOWLAN_GTK_REKEY_FAILURE) &&
651.            !(wiphy->wowlan->flags & WIPHY_WOWLAN_SUPPORTS_GTK_REKEY)))
652.        return -EINVAL;
653.    if (WARN_ON(wiphy->wowlan &&
654.            !wiphy->wowlan->flags && !wiphy->wowlan->n_patterns &&
655.            !wiphy->wowlan->tcp))
656.        return -EINVAL;
657. #endif
658.    if (WARN_ON((wiphy->features & NL80211_FEATURE_TDLS_CHANNEL_SWITCH) &&
659.            (!rdev->ops->tdls_channel_switch ||
660.             !rdev->ops->tdls_cancel_channel_switch)))
661.        return -EINVAL;
662. 
663.    if (WARN_ON((wiphy->interface_modes & BIT(NL80211_IFTYPE_NAN)) &&
664.            (!rdev->ops->start_nan || !rdev->ops->stop_nan ||
665.             !rdev->ops->add_nan_func || !rdev->ops->del_nan_func ||
666.             !(wiphy->nan_supported_bands & BIT(NL80211_BAND_2GHZ)))))
667.        return -EINVAL;
668. 
669. #ifndef CPTCFG_WIRELESS_WDS
670.    if (WARN_ON(wiphy->interface_modes & BIT(NL80211_IFTYPE_WDS)))
671.        return -EINVAL;
672. #endif
673. 
674.    /*
675.     * if a wiphy has unsupported modes for regulatory channel enforcement,
676.     * opt-out of enforcement checking
677.     */
678.    if (wiphy->interface_modes & ~(BIT(NL80211_IFTYPE_STATION) |
679.                       BIT(NL80211_IFTYPE_P2P_CLIENT) |
680.                       BIT(NL80211_IFTYPE_AP) |
681.                       BIT(NL80211_IFTYPE_P2P_GO) |
682.                       BIT(NL80211_IFTYPE_ADHOC) |
683.                       BIT(NL80211_IFTYPE_P2P_DEVICE) |
684.                       BIT(NL80211_IFTYPE_NAN) |
685.                       BIT(NL80211_IFTYPE_AP_VLAN) |
686.                       BIT(NL80211_IFTYPE_MONITOR)))
687.        wiphy->regulatory_flags |= REGULATORY_IGNORE_STALE_KICKOFF;
688. 
689.    if (WARN_ON((wiphy->regulatory_flags & REGULATORY_WIPHY_SELF_MANAGED) &&
690.            (wiphy->regulatory_flags &
691.                    (REGULATORY_CUSTOM_REG |
692.                     REGULATORY_STRICT_REG |
693.                     REGULATORY_COUNTRY_IE_FOLLOW_POWER |
694.                     REGULATORY_COUNTRY_IE_IGNORE))))
695.        return -EINVAL;
696. 
697.    if (WARN_ON(wiphy->coalesce &&
698.            (!wiphy->coalesce->n_rules ||
699.             !wiphy->coalesce->n_patterns) &&
700.            (!wiphy->coalesce->pattern_min_len ||
701.             wiphy->coalesce->pattern_min_len >
702.            wiphy->coalesce->pattern_max_len)))
703.        return -EINVAL;
704. 
705.    if (WARN_ON(wiphy->ap_sme_capa &&
706.            !(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME)))
707.        return -EINVAL;
708. 
709.    if (WARN_ON(wiphy->addresses && !wiphy->n_addresses))
710.        return -EINVAL;
711. 
712.    if (WARN_ON(wiphy->addresses &&
713.            !is_zero_ether_addr(wiphy->perm_addr) &&
714.            memcmp(wiphy->perm_addr, wiphy->addresses[0].addr,
715.               ETH_ALEN)))
716.        return -EINVAL;
717. 
718.    if (WARN_ON(wiphy->max_acl_mac_addrs &&
719.            (!(wiphy->flags & WIPHY_FLAG_HAVE_AP_SME) ||
720.             !rdev->ops->set_mac_acl)))
721.        return -EINVAL;
722. 
723.    /* assure only valid behaviours are flagged by driver
724.     * hence subtract 2 as bit 0 is invalid.
725.     */
726.    if (WARN_ON(wiphy->bss_select_support &&
727.            (wiphy->bss_select_support & ~(BIT(__NL80211_BSS_SELECT_ATTR_AFTER_LAST) - 2))))
728.        return -EINVAL;
729. 
730.    if (WARN_ON(wiphy_ext_feature_isset(&rdev->wiphy,
731.                        NL80211_EXT_FEATURE_4WAY_HANDSHAKE_STA_1X) &&
732.            (!rdev->ops->set_pmk || !rdev->ops->del_pmk)))
733.        return -EINVAL;
734. 
735.    if (WARN_ON(!(rdev->wiphy.flags & WIPHY_FLAG_SUPPORTS_FW_ROAM) &&
736.            rdev->ops->update_connect_params))
737.        return -EINVAL;
738. 
739.    if (wiphy->addresses)
740.        memcpy(wiphy->perm_addr, wiphy->addresses[0].addr, ETH_ALEN);
741. 
742.    /* sanity check ifmodes */
743.    WARN_ON(!ifmodes);
744.    ifmodes &= ((1 << NUM_NL80211_IFTYPES) - 1) & ~1;
745.    if (WARN_ON(ifmodes != wiphy->interface_modes))
746.        wiphy->interface_modes = ifmodes;
747. 
748.    res = wiphy_verify_combinations(wiphy);
749.    if (res)
750.        return res;
751. 
752.    /* sanity check supported bands/channels */
753.    for (band = 0; band < NUM_NL80211_BANDS; band++) {
754.        u16 types = 0;
755. 
756.        sband = wiphy->bands[band];
757.        if (!sband)
758.            continue;
759. 
760.        sband->band = band;
761.        if (WARN_ON(!sband->n_channels))
762.            return -EINVAL;
763.        /*
764.         * on 60GHz band, there are no legacy rates, so
765.         * n_bitrates is 0
766.         */
767.        if (WARN_ON(band != NL80211_BAND_60GHZ &&
768.                !sband->n_bitrates))
769.            return -EINVAL;
770. 
771.        /*
772.         * Since cfg80211_disable_40mhz_24ghz is global, we can
773.         * modify the sband's ht data even if the driver uses a
774.         * global structure for that.
775.         */
776.        if (cfg80211_disable_40mhz_24ghz &&
777.            band == NL80211_BAND_2GHZ &&
778.            sband->ht_cap.ht_supported) {
779.            sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SUP_WIDTH_20_40;
780.            sband->ht_cap.cap &= ~IEEE80211_HT_CAP_SGI_40;
781.        }
782. 
783.        /*
784.         * Since we use a u32 for rate bitmaps in
785.         * ieee80211_get_response_rate, we cannot
786.         * have more than 32 legacy rates.
787.         */
788.        if (WARN_ON(sband->n_bitrates > 32))
789.            return -EINVAL;
790. 
791.        for (i = 0; i < sband->n_channels; i++) {
792.            sband->channels[i].orig_flags =
793.                sband->channels[i].flags;
794.            sband->channels[i].orig_mag = INT_MAX;
795.            sband->channels[i].orig_mpwr =
796.                sband->channels[i].max_power;
797.            sband->channels[i].band = band;
798.        }
799. 
800.        for (i = 0; i < sband->n_iftype_data; i++) {
801.            const struct ieee80211_sband_iftype_data *iftd;
802. 
803.            iftd = &sband->iftype_data[i];
804. 
805.            if (WARN_ON(!iftd->types_mask))
806.                return -EINVAL;
807.            if (WARN_ON(types & iftd->types_mask))
808.                return -EINVAL;
809. 
810.            /* at least one piece of information must be present */
811.            if (WARN_ON(!iftd->he_cap.has_he))
812.                return -EINVAL;
813. 
814.            types |= iftd->types_mask;
815.        }
816. 
817.        have_band = true;
818.    }
819. 
820.    if (!have_band) {
821.        WARN_ON(1);
822.        return -EINVAL;
823.    }
824. 
825. #ifdef CONFIG_PM
826.    if (WARN_ON(rdev->wiphy.wowlan && rdev->wiphy.wowlan->n_patterns &&
827.            (!rdev->wiphy.wowlan->pattern_min_len ||
828.             rdev->wiphy.wowlan->pattern_min_len >
829.                rdev->wiphy.wowlan->pattern_max_len)))
830.        return -EINVAL;
831. #endif
832. 
833.    /* check and set up bitrates */
834.    ieee80211_set_bitrate_flags(wiphy);
835. 
836.    rdev->wiphy.features |= NL80211_FEATURE_SCAN_FLUSH;
837. 
838.    rtnl_lock();
839.    res = device_add(&rdev->wiphy.dev);
840.    if (res) {
841.        rtnl_unlock();
842.        return res;
843.    }
844. 
845.    /* set up regulatory info */
846.    wiphy_regulatory_register(wiphy);
847. 
848.    list_add_rcu(&rdev->list, &cfg80211_rdev_list);
849.    cfg80211_rdev_list_generation++;
850. 
851.    /* add to debugfs */
852.    rdev->wiphy.debugfsdir =
853.        debugfs_create_dir(wiphy_name(&rdev->wiphy),
854.                   ieee80211_debugfs_dir);
855.    if (IS_ERR(rdev->wiphy.debugfsdir))
856.        rdev->wiphy.debugfsdir = NULL;
857. 
858.    cfg80211_debugfs_rdev_add(rdev);
859.    nl80211_notify_wiphy(rdev, NL80211_CMD_NEW_WIPHY);
860. 
861.    if (wiphy->regulatory_flags & REGULATORY_CUSTOM_REG) {
862.        struct regulatory_request request;
863. 
864.        request.wiphy_idx = get_wiphy_idx(wiphy);
865.        request.initiator = NL80211_REGDOM_SET_BY_DRIVER;
866.        request.alpha2[0] = '9';
867.        request.alpha2[1] = '9';
868. 
869.        nl80211_send_reg_change_event(&request);
870.    }
871. 
872.    /* Check that nobody globally advertises any capabilities they do not
873.     * advertise on all possible interface types.
874.     */
875.    if (wiphy->extended_capabilities_len &&
876.        wiphy->num_iftype_ext_capab &&
877.        wiphy->iftype_ext_capab) {
878.        u8 supported_on_all, j;
879.        const struct wiphy_iftype_ext_capab *capab;
880. 
881.        capab = wiphy->iftype_ext_capab;
882.        for (j = 0; j < wiphy->extended_capabilities_len; j++) {
883.            if (capab[0].extended_capabilities_len > j)
884.                supported_on_all =
885.                    capab[0].extended_capabilities[j];
886.            else
887.                supported_on_all = 0x00;
888.            for (i = 1; i < wiphy->num_iftype_ext_capab; i++) {
889.                if (j >= capab[i].extended_capabilities_len) {
890.                    supported_on_all = 0x00;
891.                    break;
892.                }
893.                supported_on_all &=
894.                    capab[i].extended_capabilities[j];
895.            }
896.            if (WARN_ON(wiphy->extended_capabilities[j] &
897.                    ~supported_on_all))
898.                break;
899.        }
900.    }
901. 
902.    rdev->wiphy.registered = true;
903.    rtnl_unlock();
904. 
905.    res = rfkill_register(rdev->rfkill);
906.    if (res) {
907.        rfkill_destroy(rdev->rfkill);
908.        rdev->rfkill = NULL;
909.        wiphy_unregister(&rdev->wiphy);
910.        return res;
911.    }
912. 
913.    return 0;
914. }
915. EXPORT_SYMBOL(wiphy_register);
916. 
917. void wiphy_rfkill_start_polling(struct wiphy *wiphy)
918. {
919.    struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
920. 
921.    if (!rdev->ops->rfkill_poll)
922.        return;
923.    rdev->rfkill_ops.poll = cfg80211_rfkill_poll;
924.    rfkill_resume_polling(rdev->rfkill);
925. }
926. EXPORT_SYMBOL(wiphy_rfkill_start_polling);
927. 
928. void wiphy_rfkill_stop_polling(struct wiphy *wiphy)
929. {
930.    struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
931. 
932.    rfkill_pause_polling(rdev->rfkill);
933. }
934. EXPORT_SYMBOL(wiphy_rfkill_stop_polling);
935. 
936. void wiphy_unregister(struct wiphy *wiphy)
937. {
938.    struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
939. 
940.    wait_event(rdev->dev_wait, ({
941.        int __count;
942.        rtnl_lock();
943.        __count = rdev->opencount;
944.        rtnl_unlock();
945.        __count == 0; }));
946. 
947.    if (rdev->rfkill)
948.        rfkill_unregister(rdev->rfkill);
949. 
950.    rtnl_lock();
951.    nl80211_notify_wiphy(rdev, NL80211_CMD_DEL_WIPHY);
952.    rdev->wiphy.registered = false;
953. 
954.    WARN_ON(!list_empty(&rdev->wiphy.wdev_list));
955. 
956.    /*
957.     * First remove the hardware from everywhere, this makes
958.     * it impossible to find from userspace.
959.     */
960.    debugfs_remove_recursive(rdev->wiphy.debugfsdir);
961.    list_del_rcu(&rdev->list);
962.    synchronize_rcu();
963. 
964.    /*
965.     * If this device got a regulatory hint tell core its
966.     * free to listen now to a new shiny device regulatory hint
967.     */
968.    wiphy_regulatory_deregister(wiphy);
969. 
970.    cfg80211_rdev_list_generation++;
971.    device_del(&rdev->wiphy.dev);
972. 
973.    rtnl_unlock();
974. 
975.    flush_work(&rdev->scan_done_wk);
976.    cancel_work_sync(&rdev->conn_work);
977.    flush_work(&rdev->event_work);
978.    cancel_delayed_work_sync(&rdev->dfs_update_channels_wk);
979.    flush_work(&rdev->destroy_work);
980.    flush_work(&rdev->sched_scan_stop_wk);
981.    flush_work(&rdev->mlme_unreg_wk);
982.    flush_work(&rdev->propagate_radar_detect_wk);
983.    flush_work(&rdev->propagate_cac_done_wk);
984. 
985. #ifdef CONFIG_PM
986.    if (rdev->wiphy.wowlan_config && rdev->ops->set_wakeup)
987.        rdev_set_wakeup(rdev, false);
988. #endif
989.    cfg80211_rdev_free_wowlan(rdev);
990.    cfg80211_rdev_free_coalesce(rdev);
991. }
992. EXPORT_SYMBOL(wiphy_unregister);
993. 
994. void cfg80211_dev_free(struct cfg80211_registered_device *rdev)
995. {
996.    struct cfg80211_internal_bss *scan, *tmp;
997.    struct cfg80211_beacon_registration *reg, *treg;
998.    rfkill_destroy(rdev->rfkill);
999.    list_for_each_entry_safe(reg, treg, &rdev->beacon_registrations, list) {
1000.       list_del(&reg->list);
1001.       kfree(reg);
1002.   }
1003.   list_for_each_entry_safe(scan, tmp, &rdev->bss_list, list)
1004.       cfg80211_put_bss(&rdev->wiphy, &scan->pub);
1005.   kfree(rdev);
1006. }
1007. 
1008. void wiphy_free(struct wiphy *wiphy)
1009. {
1010.   put_device(&wiphy->dev);
1011. }
1012. EXPORT_SYMBOL(wiphy_free);
1013. 
1014. void wiphy_rfkill_set_hw_state(struct wiphy *wiphy, bool blocked)
1015. {
1016.   struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1017. 
1018.   if (rfkill_set_hw_state(rdev->rfkill, blocked))
1019.       schedule_work(&rdev->rfkill_sync);
1020. }
1021. EXPORT_SYMBOL(wiphy_rfkill_set_hw_state);
1022. 
1023. void cfg80211_cqm_config_free(struct wireless_dev *wdev)
1024. {
1025.   kfree(wdev->cqm_config);
1026.   wdev->cqm_config = NULL;
1027. }
1028. 
1029. void cfg80211_unregister_wdev(struct wireless_dev *wdev)
1030. {
1031.   struct cfg80211_registered_device *rdev = wiphy_to_rdev(wdev->wiphy);
1032. 
1033.   ASSERT_RTNL();
1034. 
1035.   if (WARN_ON(wdev->netdev))
1036.       return;
1037. 
1038.   nl80211_notify_iface(rdev, wdev, NL80211_CMD_DEL_INTERFACE);
1039. 
1040.   list_del_rcu(&wdev->list);
1041.   synchronize_rcu();
1042.   rdev->devlist_generation++;
1043. 
1044.   switch (wdev->iftype) {
1045.   case NL80211_IFTYPE_P2P_DEVICE:
1046.       cfg80211_mlme_purge_registrations(wdev);
1047.       cfg80211_stop_p2p_device(rdev, wdev);
1048.       break;
1049.   case NL80211_IFTYPE_NAN:
1050.       cfg80211_stop_nan(rdev, wdev);
1051.       break;
1052.   default:
1053.       WARN_ON_ONCE(1);
1054.       break;
1055.   }
1056. 
1057.   cfg80211_cqm_config_free(wdev);
1058. }
1059. EXPORT_SYMBOL(cfg80211_unregister_wdev);
1060. 
1061. static const struct device_type wiphy_type = {
1062.   .name   = "wlan",
1063. };
1064. 
1065. void cfg80211_update_iface_num(struct cfg80211_registered_device *rdev,
1066.                  enum nl80211_iftype iftype, int num)
1067. {
1068.   ASSERT_RTNL();
1069. 
1070.   rdev->num_running_ifaces += num;
1071.   if (iftype == NL80211_IFTYPE_MONITOR)
1072.       rdev->num_running_monitor_ifaces += num;
1073. }
1074. 
1075. void __cfg80211_leave(struct cfg80211_registered_device *rdev,
1076.             struct wireless_dev *wdev)
1077. {
1078.   struct net_device *dev = wdev->netdev;
1079.   struct cfg80211_sched_scan_request *pos, *tmp;
1080. 
1081.   ASSERT_RTNL();
1082.   ASSERT_WDEV_LOCK(wdev);
1083. 
1084.   switch (wdev->iftype) {
1085.   case NL80211_IFTYPE_ADHOC:
1086.       __cfg80211_leave_ibss(rdev, dev, true);
1087.       break;
1088.   case NL80211_IFTYPE_P2P_CLIENT:
1089.   case NL80211_IFTYPE_STATION:
1090.       list_for_each_entry_safe(pos, tmp, &rdev->sched_scan_req_list,
1091.                    list) {
1092.           if (dev == pos->dev)
1093.               cfg80211_stop_sched_scan_req(rdev, pos, false);
1094.       }
1095. 
1096. #ifdef CPTCFG_CFG80211_WEXT
1097.       kfree(wdev->wext.ie);
1098.       wdev->wext.ie = NULL;
1099.       wdev->wext.ie_len = 0;
1100.       wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
1101. #endif
1102.       cfg80211_disconnect(rdev, dev,
1103.                   WLAN_REASON_DEAUTH_LEAVING, true);
1104.       break;
1105.   case NL80211_IFTYPE_MESH_POINT:
1106.       __cfg80211_leave_mesh(rdev, dev);
1107.       break;
1108.   case NL80211_IFTYPE_AP:
1109.   case NL80211_IFTYPE_P2P_GO:
1110.       __cfg80211_stop_ap(rdev, dev, true);
1111.       break;
1112.   case NL80211_IFTYPE_OCB:
1113.       __cfg80211_leave_ocb(rdev, dev);
1114.       break;
1115.   case NL80211_IFTYPE_WDS:
1116.       /* must be handled by mac80211/driver, has no APIs */
1117.       break;
1118.   case NL80211_IFTYPE_P2P_DEVICE:
1119.   case NL80211_IFTYPE_NAN:
1120.       /* cannot happen, has no netdev */
1121.       break;
1122.   case NL80211_IFTYPE_AP_VLAN:
1123.   case NL80211_IFTYPE_MONITOR:
1124.       /* nothing to do */
1125.       break;
1126.   case NL80211_IFTYPE_UNSPECIFIED:
1127.   case NUM_NL80211_IFTYPES:
1128.       /* invalid */
1129.       break;
1130.   }
1131. }
1132. 
1133. void cfg80211_leave(struct cfg80211_registered_device *rdev,
1134.           struct wireless_dev *wdev)
1135. {
1136.   wdev_lock(wdev);
1137.   __cfg80211_leave(rdev, wdev);
1138.   wdev_unlock(wdev);
1139. }
1140. 
1141. void cfg80211_stop_iface(struct wiphy *wiphy, struct wireless_dev *wdev,
1142.            gfp_t gfp)
1143. {
1144.   struct cfg80211_registered_device *rdev = wiphy_to_rdev(wiphy);
1145.   struct cfg80211_event *ev;
1146.   unsigned long flags;
1147. 
1148.   trace_cfg80211_stop_iface(wiphy, wdev);
1149. 
1150.   ev = kzalloc(sizeof(*ev), gfp);
1151.   if (!ev)
1152.       return;
1153. 
1154.   ev->type = EVENT_STOPPED;
1155. 
1156.   spin_lock_irqsave(&wdev->event_lock, flags);
1157.   list_add_tail(&ev->list, &wdev->event_list);
1158.   spin_unlock_irqrestore(&wdev->event_lock, flags);
1159.   queue_work(cfg80211_wq, &rdev->event_work);
1160. }
1161. EXPORT_SYMBOL(cfg80211_stop_iface);
1162. 
1163. static int cfg80211_netdev_notifier_call(struct notifier_block *nb,
1164.                    unsigned long state, void *ptr)
1165. {
1166.   struct net_device *dev = netdev_notifier_info_to_dev(ptr);
1167.   struct wireless_dev *wdev = dev->ieee80211_ptr;
1168.   struct cfg80211_registered_device *rdev;
1169.   struct cfg80211_sched_scan_request *pos, *tmp;
1170. 
1171.   if (!wdev)
1172.       return NOTIFY_DONE;
1173. 
1174.   rdev = wiphy_to_rdev(wdev->wiphy);
1175. 
1176.   WARN_ON(wdev->iftype == NL80211_IFTYPE_UNSPECIFIED);
1177. 
1178.   switch (state) {
1179.   case NETDEV_POST_INIT:
1180.       SET_NETDEV_DEVTYPE(dev, &wiphy_type);
1181.       break;
1182.   case NETDEV_REGISTER:
1183.       /*
1184.        * NB: cannot take rdev->mtx here because this may be
1185.        * called within code protected by it when interfaces
1186.        * are added with nl80211.
1187.        */
1188.       mutex_init(&wdev->mtx);
1189.       INIT_LIST_HEAD(&wdev->event_list);
1190.       spin_lock_init(&wdev->event_lock);
1191.       INIT_LIST_HEAD(&wdev->mgmt_registrations);
1192.       spin_lock_init(&wdev->mgmt_registrations_lock);
1193. 
1194.       /*
1195.        * We get here also when the interface changes network namespaces,
1196.        * as it's registered into the new one, but we don't want it to
1197.        * change ID in that case. Checking if the ID is already assigned
1198.        * works, because 0 isn't considered a valid ID and the memory is
1199.        * 0-initialized.
1200.        */
1201.       if (!wdev->identifier)
1202.           wdev->identifier = ++rdev->wdev_id;
1203.       list_add_rcu(&wdev->list, &rdev->wiphy.wdev_list);
1204.       rdev->devlist_generation++;
1205.       /* can only change netns with wiphy */
1206.       dev->features |= NETIF_F_NETNS_LOCAL;
1207. 
1208.       if (sysfs_create_link(&dev->dev.kobj, &rdev->wiphy.dev.kobj,
1209.                     "phy80211")) {
1210.           pr_err("failed to add phy80211 symlink to netdev!\n");
1211.       }
1212.       wdev->netdev = dev;
1213. #ifdef CPTCFG_CFG80211_WEXT
1214. #ifdef CONFIG_WIRELESS_EXT
1215.       if (!dev->wireless_handlers)
1216.           dev->wireless_handlers = &cfg80211_wext_handler;
1217. #else
1218.       printk_once(KERN_WARNING "cfg80211: wext will not work because "
1219.               "kernel was compiled with CONFIG_WIRELESS_EXT=n. "
1220.               "Tools using wext interface, like iwconfig will "
1221.               "not work.\n");
1222. #endif
1223.       wdev->wext.default_key = -1;
1224.       wdev->wext.default_mgmt_key = -1;
1225.       wdev->wext.connect.auth_type = NL80211_AUTHTYPE_AUTOMATIC;
1226. #endif
1227. 
1228.       if (wdev->wiphy->flags & WIPHY_FLAG_PS_ON_BY_DEFAULT)
1229.           wdev->ps = true;
1230.       else
1231.           wdev->ps = false;
1232.       /* allow mac80211 to determine the timeout */
1233.       wdev->ps_timeout = -1;
1234. 
1235.       if ((wdev->iftype == NL80211_IFTYPE_STATION ||
1236.            wdev->iftype == NL80211_IFTYPE_P2P_CLIENT ||
1237.            wdev->iftype == NL80211_IFTYPE_ADHOC) && !wdev->use_4addr)
1238.           dev->priv_flags |= IFF_DONT_BRIDGE;
1239. 
1240.       INIT_WORK(&wdev->disconnect_wk, cfg80211_autodisconnect_wk);
1241. 
1242.       nl80211_notify_iface(rdev, wdev, NL80211_CMD_NEW_INTERFACE);
1243.       break;
1244.   case NETDEV_GOING_DOWN:
1245.       cfg80211_leave(rdev, wdev);
1246.       break;
1247.   case NETDEV_DOWN:
1248.       cfg80211_update_iface_num(rdev, wdev->iftype, -1);
1249.       if (rdev->scan_req && rdev->scan_req->wdev == wdev) {
1250.           if (WARN_ON(!rdev->scan_req->notified))
1251.               rdev->scan_req->info.aborted = true;
1252.           ___cfg80211_scan_done(rdev, false);
1253.       }
1254. 
1255.       list_for_each_entry_safe(pos, tmp,
1256.                    &rdev->sched_scan_req_list, list) {
1257.           if (WARN_ON(pos && pos->dev == wdev->netdev))
1258.               cfg80211_stop_sched_scan_req(rdev, pos, false);
1259.       }
1260. 
1261.       rdev->opencount--;
1262.       wake_up(&rdev->dev_wait);
1263.       break;
1264.   case NETDEV_UP:
1265.       cfg80211_update_iface_num(rdev, wdev->iftype, 1);
1266.       wdev_lock(wdev);
1267.       switch (wdev->iftype) {
1268. #ifdef CPTCFG_CFG80211_WEXT
1269.       case NL80211_IFTYPE_ADHOC:
1270.           cfg80211_ibss_wext_join(rdev, wdev);
1271.           break;
1272.       case NL80211_IFTYPE_STATION:
1273.           cfg80211_mgd_wext_connect(rdev, wdev);
1274.           break;
1275. #endif
1276. #ifdef CPTCFG_MAC80211_MESH
1277.       case NL80211_IFTYPE_MESH_POINT:
1278.           {
1279.               /* backward compat code... */
1280.               struct mesh_setup setup;
1281.               memcpy(&setup, &default_mesh_setup,
1282.                       sizeof(setup));
1283.                /* back compat only needed for mesh_id */
1284.               setup.mesh_id = wdev->ssid;
1285.               setup.mesh_id_len = wdev->mesh_id_up_len;
1286.               if (wdev->mesh_id_up_len)
1287.                   __cfg80211_join_mesh(rdev, dev,
1288.                           &setup,
1289.                           &default_mesh_config);
1290.               break;
1291.           }
1292. #endif
1293.       default:
1294.           break;
1295.       }
1296.       wdev_unlock(wdev);
1297.       rdev->opencount++;
1298. 
1299.       /*
1300.        * Configure power management to the driver here so that its
1301.        * correctly set also after interface type changes etc.
1302.        */
1303.       if ((wdev->iftype == NL80211_IFTYPE_STATION ||
1304.            wdev->iftype == NL80211_IFTYPE_P2P_CLIENT) &&
1305.           rdev->ops->set_power_mgmt &&
1306.           rdev_set_power_mgmt(rdev, dev, wdev->ps,
1307.                   wdev->ps_timeout)) {
1308.           /* assume this means it's off */
1309.           wdev->ps = false;
1310.       }
1311.       break;
1312.   case NETDEV_UNREGISTER:
1313.       /*
1314.        * It is possible to get NETDEV_UNREGISTER
1315.        * multiple times. To detect that, check
1316.        * that the interface is still on the list
1317.        * of registered interfaces, and only then
1318.        * remove and clean it up.
1319.        */
1320.       if (!list_empty(&wdev->list)) {
1321.           nl80211_notify_iface(rdev, wdev,
1322.                        NL80211_CMD_DEL_INTERFACE);
1323.           sysfs_remove_link(&dev->dev.kobj, "phy80211");
1324.           list_del_rcu(&wdev->list);
1325.           rdev->devlist_generation++;
1326.           cfg80211_mlme_purge_registrations(wdev);
1327. #ifdef CPTCFG_CFG80211_WEXT
1328.           kzfree(wdev->wext.keys);
1329. #endif
1330.           flush_work(&wdev->disconnect_wk);
1331.           cfg80211_cqm_config_free(wdev);
1332.       }
1333.       /*
1334.        * synchronise (so that we won't find this netdev
1335.        * from other code any more) and then clear the list
1336.        * head so that the above code can safely check for
1337.        * !list_empty() to avoid double-cleanup.
1338.        */
1339.       synchronize_rcu();
1340.       INIT_LIST_HEAD(&wdev->list);
1341.       /*
1342.        * Ensure that all events have been processed and
1343.        * freed.
1344.        */
1345.       cfg80211_process_wdev_events(wdev);
1346. 
1347.       if (WARN_ON(wdev->current_bss)) {
1348.           cfg80211_unhold_bss(wdev->current_bss);
1349.           cfg80211_put_bss(wdev->wiphy, &wdev->current_bss->pub);
1350.           wdev->current_bss = NULL;
1351.       }
1352.       break;
1353.   case NETDEV_PRE_UP:
1354.       if (!cfg80211_iftype_allowed(wdev->wiphy, wdev->iftype,
1355.                        wdev->use_4addr, 0))
1356.           return notifier_from_errno(-EOPNOTSUPP);
1357. 
1358.       if (rfkill_blocked(rdev->rfkill))
1359.           return notifier_from_errno(-ERFKILL);
1360.       break;
1361.   default:
1362.       return NOTIFY_DONE;
1363.   }
1364. 
1365.   wireless_nlevent_flush();
1366. 
1367.   return NOTIFY_OK;
1368. }
1369. 
1370. static struct notifier_block cfg80211_netdev_notifier = {
1371.   .notifier_call = cfg80211_netdev_notifier_call,
1372. };
1373. 
1374. static void __net_exit cfg80211_pernet_exit(struct net *net)
1375. {
1376.   struct cfg80211_registered_device *rdev;
1377. 
1378.   rtnl_lock();
1379.   list_for_each_entry(rdev, &cfg80211_rdev_list, list) {
1380.       if (net_eq(wiphy_net(&rdev->wiphy), net))
1381.           WARN_ON(cfg80211_switch_netns(rdev, &init_net));
1382.   }
1383.   rtnl_unlock();
1384. }
1385. 
1386. static struct pernet_operations cfg80211_pernet_ops = {
1387.   .exit = cfg80211_pernet_exit,
1388. };
1389. 
1390. static int __init cfg80211_init(void)
1391. {
1392.   int err;
1393. 
1394.   err = register_pernet_device(&cfg80211_pernet_ops);
1395.   if (err)
1396.       goto out_fail_pernet;
1397. 
1398.   err = wiphy_sysfs_init();
1399.   if (err)
1400.       goto out_fail_sysfs;
1401. 
1402.   err = register_netdevice_notifier(&cfg80211_netdev_notifier);
1403.   if (err)
1404.       goto out_fail_notifier;
1405. 
1406.   err = nl80211_init();
1407.   if (err)
1408.       goto out_fail_nl80211;
1409. 
1410.   ieee80211_debugfs_dir = debugfs_create_dir("ieee80211", NULL);
1411. 
1412.   err = regulatory_init();
1413.   if (err)
1414.       goto out_fail_reg;
1415. 
1416.   cfg80211_wq = alloc_ordered_workqueue("cfg80211", WQ_MEM_RECLAIM);
1417.   if (!cfg80211_wq) {
1418.       err = -ENOMEM;
1419.       goto out_fail_wq;
1420.   }
1421. 
1422.   return 0;
1423. 
1424. out_fail_wq:
1425.   regulatory_exit();
1426. out_fail_reg:
1427.   debugfs_remove(ieee80211_debugfs_dir);
1428.   nl80211_exit();
1429. out_fail_nl80211:
1430.   unregister_netdevice_notifier(&cfg80211_netdev_notifier);
1431. out_fail_notifier:
1432.   wiphy_sysfs_exit();
1433. out_fail_sysfs:
1434.   unregister_pernet_device(&cfg80211_pernet_ops);
1435. out_fail_pernet:
1436.   return err;
1437. }
1438. fs_initcall(cfg80211_init);
1439. 
1440. static void __exit cfg80211_exit(void)
1441. {
1442.   debugfs_remove(ieee80211_debugfs_dir);
1443.   nl80211_exit();
1444.   unregister_netdevice_notifier(&cfg80211_netdev_notifier);
1445.   wiphy_sysfs_exit();
1446.   regulatory_exit();
1447.   unregister_pernet_device(&cfg80211_pernet_ops);
1448.   destroy_workqueue(cfg80211_wq);
1449. }
1450. module_exit(cfg80211_exit);

Thank you very much.

lwfinger commented 3 years ago

I think I know at least part of the problem. This driver can create two wifi devices on a single radio. That is controlled by EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE in Makefile. On your system, it is set; however, your user-space code is only configuring one of the two, thus the warnings. I suspect that you want to comment out that line.

bigdolphin commented 3 years ago

I commented that flag but the warning still occurs and module is not loaded. When I enable the CONFIG_DEBUG, CONFIG_DEBUG_RTL871X and DBG_IOCTL, dmesg output says:

[ 8686.173411] RTL871X: USB_SPEED_HIGH [ 8686.195628] RTL871X: CHIP TYPE: RTL8723BU [ 8686.199759] RTL871X: register rtw_netdev_ops to netdev_ops [ 8686.205425] RTL871X: rtw_wdev_alloc(padapter=c1601000) .............. [ 8686.215528] WARNING: CPU: 0 PID: 20205 at backports-4.19.137-1/net/wireless/core.c:743 wiphy_register+0x2a4/0x9d0 [cfg80211] .............. [ 8686.625526] WARNING: CPU: 0 PID: 20205 at backports-4.19.137-1/net/wireless/core.c:821 wiphy_register+0x61c/0x9d0 [cfg80211] .............. [ 8687.032036] RTL871X: Couldn't register wiphy device [ 8687.037041] RTL871X: rtw_usb_if1_init Failed! [ 8687.041646] usbcore: registered new interface driver rtl8723bu [ 8687.047602] RTL871X: module init ret=0

Best regards.

vbvchauthmal commented 2 years ago

Hi @bigdolphin, Did you able to resolve the issue?

I used same Makefiles and getting kernel panic on modprobe rtl8723bu module.

root@OpenWrt:/# lsusb 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:b720 Realtek Semiconductor Corp. 
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@OpenWrt:/# 
root@OpenWrt:/# modprobe rtl8723bu
[ 1953.734110] RTL871X: module init start
[ 1953.738354] RTL871X: rtl8723bu v4.3.6.11_12942.20141204_BTCOEX20140507-4E40
[ 1953.745717] RTL871X: rtl8723bu BT-Coex version = BTCOEX20140507-4E40
[ 1953.890947] ------------[ cut here ]------------
[ 1953.896072] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/reg.c:2339 wiphy_apply_custom_regulatory+0x3c/0x448 [cfg80211]
[ 1953.909272] wiphy should have REGULATORY_CUSTOM_REG
[ 1953.914420] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1953.990299]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.011488] CPU: 0 PID: 2222 Comm: modprobe Not tainted 4.14.267 #0
[ 1954.018080] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.024487] Backtrace: 
[ 1954.027097] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1954.035061]  r7:bf349884 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1954.041029] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1954.048641] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1954.055965]  r7:bf349884 r6:bf375b88 r5:00000000 r4:de45db90
[ 1954.061924] [<c0131d08>] (__warn) from [<c0131e50>] (warn_slowpath_fmt+0x40/0x48)
[ 1954.069798]  r9:ddf3e470 r8:bf41d498 r7:bf415998 r6:de6f02e0 r5:de6f6000 r4:bf375c54
[ 1954.078077] [<c0131e14>] (warn_slowpath_fmt) from [<bf349884>] (wiphy_apply_custom_regulatory+0x3c/0x448 [cfg80211])
[ 1954.089136]  r3:00000000 r2:bf375c54
[ 1954.092900]  r4:de6f02e0
[ 1954.096234] [<bf349848>] (wiphy_apply_custom_regulatory [cfg80211]) from [<bf3db0a0>] (rtw_regd_init+0x30/0x3c [8723bu])
[ 1954.107693]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1954.115938]  r4:de6f02e0
[ 1954.119160] [<bf3db070>] (rtw_regd_init [8723bu]) from [<bf3dad84>] (rtw_wdev_alloc+0x1b0/0x2d8 [8723bu])
[ 1954.129237]  r5:de6f6000 r4:de6f02e0
[ 1954.133500] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1954.143492]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1954.151915] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1954.161524]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1954.169755]  r4:ddf3e820
[ 1954.172444] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1954.181869]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1954.190099]  r4:ddf3e820
[ 1954.192778] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1954.201655]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1954.209886]  r4:ddf3e820 r3:00000000
[ 1954.213658] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1954.222258]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1954.228217] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1954.236634]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1954.241500] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1954.249831] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1954.258249]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1954.264209] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1954.273171]  r5:c0d4800c r4:bf41d218
[ 1954.277184] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1954.286701]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1954.295080] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1954.304154]  r5:00000000 r4:c0d07548
[ 1954.307945] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1954.316475]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1954.324639] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1954.333074]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1954.339046] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1954.347392]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1954.355637]  r4:0000c574
[ 1954.358329] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1954.366857]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1954.375102]  r4:00000000
[ 1954.378034] ---[ end trace 4f62d3a66bbf2880 ]---
[ 1954.382917] ------------[ cut here ]------------
[ 1954.388044] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/reg.c:2353 wiphy_apply_custom_regulatory+0xc0/0x448 [cfg80211]
[ 1954.401123] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1954.476964]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.498128] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1954.505997] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.512403] Backtrace: 
[ 1954.515006] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1954.522971]  r7:bf349908 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1954.528936] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1954.536544] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1954.543869]  r7:bf349908 r6:bf375b88 r5:00000000 r4:00000000
[ 1954.549828] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1954.557794]  r9:de6f0bb0 r8:00000034 r7:bf415998 r6:de6f02e0 r5:00000000 r4:de6f02e0
[ 1954.566055] [<c0131ea0>] (warn_slowpath_null) from [<bf349908>] (wiphy_apply_custom_regulatory+0xc0/0x448 [cfg80211])
[ 1954.577699] [<bf349848>] (wiphy_apply_custom_regulatory [cfg80211]) from [<bf3db0a0>] (rtw_regd_init+0x30/0x3c [8723bu])
[ 1954.589153]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1954.597398]  r4:de6f02e0
[ 1954.600588] [<bf3db070>] (rtw_regd_init [8723bu]) from [<bf3dad84>] (rtw_wdev_alloc+0x1b0/0x2d8 [8723bu])
[ 1954.610645]  r5:de6f6000 r4:de6f02e0
[ 1954.614901] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1954.624893]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1954.633311] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1954.642919]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1954.651148]  r4:ddf3e820
[ 1954.653831] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1954.663256]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1954.671485]  r4:ddf3e820
[ 1954.674163] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1954.683040]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1954.691271]  r4:ddf3e820 r3:00000000
[ 1954.695044] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1954.703645]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1954.709603] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1954.718020]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1954.722885] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1954.731216] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1954.739634]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1954.745595] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1954.754557]  r5:c0d4800c r4:bf41d218
[ 1954.758562] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1954.768097]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1954.776488] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1954.785542]  r5:00000000 r4:c0d07548
[ 1954.789320] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1954.797832]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1954.805980] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1954.814398]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1954.820358] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1954.828687]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1954.836917]  r4:0000c574
[ 1954.839601] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1954.848113]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1954.856341]  r4:00000000
[ 1954.859213] ---[ end trace 4f62d3a66bbf2881 ]---
[ 1954.864091] ------------[ cut here ]------------
[ 1954.869180] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/core.c:743 wiphy_register+0x2f0/0xa7c [cfg80211]
[ 1954.880954] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1954.956825]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.977994] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1954.985861] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.992267] Backtrace: 
[ 1954.994868] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1955.002832]  r7:bf342884 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1955.008796] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1955.016401] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1955.023725]  r7:bf342884 r6:bf3756e4 r5:00000000 r4:00000000
[ 1955.029684] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1955.037649]  r9:ddf3e470 r8:bf41d498 r7:00000000 r6:00000000 r5:de6f0b00 r4:de6f02e0
[ 1955.045908] [<c0131ea0>] (warn_slowpath_null) from [<bf342884>] (wiphy_register+0x2f0/0xa7c [cfg80211])
[ 1955.056221] [<bf342594>] (wiphy_register [cfg80211]) from [<bf3dad8c>] (rtw_wdev_alloc+0x1b8/0x2d8 [8723bu])
[ 1955.066580]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1955.074827]  r4:de6f02e0
[ 1955.078012] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1955.087986]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1955.096386] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1955.105994]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1955.114224]  r4:ddf3e820
[ 1955.116908] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1955.126332]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1955.134561]  r4:ddf3e820
[ 1955.137240] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1955.146116]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1955.154347]  r4:ddf3e820 r3:00000000
[ 1955.158118] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1955.166718]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1955.172677] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1955.181094]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1955.185959] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1955.194289] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1955.202707]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1955.208666] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1955.217628]  r5:c0d4800c r4:bf41d218
[ 1955.221631] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1955.231147]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1955.239519] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1955.248591]  r5:00000000 r4:c0d07548
[ 1955.252377] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1955.260906]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1955.269068] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1955.277501]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1955.283472] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1955.291816]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1955.300061]  r4:0000c574
[ 1955.302751] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1955.311278]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1955.319524]  r4:00000000
[ 1955.322419] ---[ end trace 4f62d3a66bbf2882 ]---
[ 1955.327355] ------------[ cut here ]------------
[ 1955.332372] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/core.c:821 wiphy_register+0x698/0xa7c [cfg80211]
[ 1955.344142] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1955.419963]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1955.441119] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1955.448987] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1955.455392] Backtrace: 
[ 1955.457993] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1955.465955]  r7:bf342c2c r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1955.471918] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1955.479523] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1955.486847]  r7:bf342c2c r6:bf3756e4 r5:00000000 r4:00000000
[ 1955.492807] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1955.500773]  r9:00000000 r8:00000036 r7:bf379480 r6:de6f0bb0 r5:ffffffea r4:de6f02e0
[ 1955.509030] [<c0131ea0>] (warn_slowpath_null) from [<bf342c2c>] (wiphy_register+0x698/0xa7c [cfg80211])
[ 1955.519342] [<bf342594>] (wiphy_register [cfg80211]) from [<bf3dad8c>] (rtw_wdev_alloc+0x1b8/0x2d8 [8723bu])
[ 1955.529681]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1955.537911]  r4:de6f02e0
[ 1955.541088] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1955.551079]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1955.559491] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1955.569118]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1955.577363]  r4:ddf3e820
[ 1955.580053] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1955.589496]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1955.597742]  r4:ddf3e820
[ 1955.600425] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1955.609318]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1955.617566]  r4:ddf3e820 r3:00000000
[ 1955.621344] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1955.629960]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1955.635930] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1955.644362]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1955.649237] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1955.657582] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1955.666016]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1955.671987] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1955.680966]  r5:c0d4800c r4:bf41d218
[ 1955.684976] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1955.694511]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1955.702903] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1955.711957]  r5:00000000 r4:c0d07548
[ 1955.715734] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1955.724248]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1955.732396] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1955.740814]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1955.746773] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1955.755103]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1955.763331]  r4:0000c574
[ 1955.766014] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1955.774525]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1955.782754]  r4:00000000
[ 1955.785553] ---[ end trace 4f62d3a66bbf2883 ]---
[ 1955.790569] Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
[ 1955.797617] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1955.873150]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1955.894181] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1955.902041] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1955.908444] task: dde55940 task.stack: de45c000
[ 1955.913213] PC is at kfree+0x74/0x158
[ 1955.917372] LR is at rtw_drv_init+0x3d4/0x4cc [8723bu]
[ 1955.922785] pc : [<c0216ea8>]    lr : [<bf3c932c>]    psr: 40000013
[ 1955.929379] sp : de45dc08  ip : de45dc30  fp : de45dc2c
[ 1955.934880] r10: de6f100c  r9 : ddf3e470  r8 : ddb41000
[ 1955.940380] r7 : ffffffea  r6 : e0609000  r5 : e0603000  r4 : dec0c120
[ 1955.947251] r3 : 00000000  r2 : c1270a80  r1 : 1f16f000  r0 : e0609000
[ 1955.954124] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[ 1955.961635] Control: 10c5387d  Table: 9d414019  DAC: 00000051
[ 1955.967685] Process modprobe (pid: 2222, stack limit = 0xde45c218)
[ 1955.974191] Stack: (0xde45dc08 to 0xde45e000)
[ 1955.978789] dc00:                   de6f1000 e0603000 de6f1000 e0603000 ddf3e800 ffffffea
[ 1955.987405] dc20: de45dc64 de45dc30 bf3c932c c0216e40 de45dc64 ddf3e400 c051b830 ddf3e820
[ 1955.996020] dc40: ddf3e470 bf41d268 ddf3e400 00000000 ddf3e800 bf41d2b8 de45dc9c de45dc68
[ 1956.004635] dc60: c05e7a5c bf3c8f64 c02917dc ffffffed de45dc9c ddf3e820 c12892c8 c12892cc
[ 1956.013250] dc80: 00000000 bf41d268 00000010 00000000 de45dccc de45dca0 c05126f8 c05e78b0
[ 1956.021865] dca0: 00000000 ddf3e820 bf41d268 ddf3e854 00000000 bf438bc0 00000000 c0d07548
[ 1956.030480] dcc0: de45dcec de45dcd0 c0512920 c05125ac 00000000 bf41d268 c0512890 00000000
[ 1956.039094] dce0: de45dd14 de45dcf0 c0510af4 c051289c de7beca4 ddf6b450 de7becd4 bf41d268
[ 1956.047708] dd00: ddb57900 c0d4800c de45dd24 de45dd18 c0512150 c0510aac de45dd4c de45dd28
[ 1956.056323] dd20: c0511bf0 c0512138 bf419be4 de45dd38 bf41d268 c0d4800c bf41d268 bf419b80
[ 1956.064937] dd40: de45dd64 de45dd50 c0513078 c0511b0c bf41d218 c0d4800c de45dd8c de45dd68
[ 1956.073552] dd60: c05e6480 c0512fd4 bf41d218 00000000 ffffe000 dd5976c0 bf45a000 00000000
[ 1956.082167] dd80: de45dda4 de45dd90 bf45a0a0 c05e6400 c0d07548 00000000 de45de1c de45dda8
[ 1956.090782] dda0: c0101b30 bf45a00c c0d5ef80 00000000 014000c0 de401e40 014000c0 014000c0
[ 1956.099398] ddc0: ddc94288 bf438bc0 00000000 c0d07548 de45ddec de45dde0 c01d91ec c0173f1c
[ 1956.108013] dde0: de45ddfc de45ddf0 c01d9214 c01d91dc de45de1c d9581522 bf438bc0 ddc94000
[ 1956.116628] de00: ddc94258 dd5976c0 bf438bc0 00000000 de45de44 de45de20 c01abd80 c0101a74
[ 1956.125243] de20: de45de44 de45de30 de45df30 ddc94000 ddc94258 ddc94288 de45df2c de45de48
[ 1956.133858] de40: c01aaef8 c01abd24 bf438bcc 00007fff bf438bc0 c01a8304 c0d0a4c4 c0a69b50
[ 1956.142471] de60: c0a69af8 e0602000 c0d07548 c0a69c60 c0ae6748 bf438ce0 bf438ccc 00000031
[ 1956.151084] de80: c0833bd4 c01a7958 bf438c08 014000c0 00000000 00000000 00000000 00000000
[ 1956.159698] dea0: 00000000 00000000 de45dfa4 de45deb8 c010c478 c01012ac e0600000 b6e5f030
[ 1956.168310] dec0: 6e72656b 00006c65 00000000 00000000 00000000 00000000 00000000 00000000
[ 1956.176922] dee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d9581522
[ 1956.185536] df00: 00000055 0000c574 00000000 b6e60584 e0601574 ffffe000 000128de 00000051
[ 1956.194151] df20: de45dfa4 de45df30 c01ab418 c01a9060 e05be68c e0515000 000ec574 e06011b4
[ 1956.202765] df40: e06010f0 e05cd4c4 000b0000 000be0e0 00000000 00000000 00000000 00019dac
[ 1956.211379] df60: 00000015 00000016 00000011 00000000 0000000c 00000000 000ec574 00000000
[ 1956.219993] df80: 00000000 00000003 00000080 c0107e64 de45c000 00000080 00000000 de45dfa8
[ 1956.228607] dfa0: c0107c60 c01ab2e0 00000000 00000000 b6d74010 000ec574 000128de 0000b302
[ 1956.237220] dfc0: 00000000 00000000 00000003 00000080 000ec574 00000000 00000000 00000000
[ 1956.245833] dfe0: bee0dd04 bee0dce8 00011d50 b6ec5b7c 60000010 b6d74010 00000000 00000000
[ 1956.254435] Backtrace: 
[ 1956.257296] [<c0216e34>] (kfree) from [<bf3c932c>] (rtw_drv_init+0x3d4/0x4cc [8723bu])
[ 1956.265621]  r7:ffffffea r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1956.271827] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1956.281448]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1956.289689]  r4:ddf3e820
[ 1956.292371] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1956.301807]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1956.310048]  r4:ddf3e820
[ 1956.312726] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1956.321614]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1956.329856]  r4:ddf3e820 r3:00000000
[ 1956.333629] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1956.342240]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1956.348205] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1956.356629]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1956.361497] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1956.369836] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1956.378262]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1956.384228] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1956.393199]  r5:c0d4800c r4:bf41d218
[ 1956.397200] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1956.406712]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1956.415080] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1956.424145]  r5:00000000 r4:c0d07548
[ 1956.427921] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1956.436444]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1956.444601] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1956.453030]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1956.458994] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1956.467332]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1956.475571]  r4:0000c574
[ 1956.478252] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1956.486773]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1956.495012]  r4:00000000
[ 1956.497691] Code: 1a000003 e5943014 e3130001 1a000000 (e7f001f2) 
[ 1956.504115] ---[ end trace 4f62d3a66bbf2884 ]---
[ 1956.508979] Kernel panic - not syncing: Fatal exception
[ 1956.514502] Rebooting in 3 seconds..

I am compiling this driver for Beaglebone Black based platform with OpenWrt version v19.07.9.

@lwfinger I have commented EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE in my compilation.

bigdolphin commented 2 years ago

Hi, I gave up using rtl8723bu because the driver source is not compatible with new gcc of OpenWrt v19 (as I remember). I changed to use rtl8723du which is compatible with gcc 7.5.0. RTL8723du is totally same with bu version but its driver source is newer. I confirm that OpenWRT v19.07 works well with rtl8723du.

Hi @bigdolphin, Did you able to resolve the issue?

I used same Makefiles and getting kernel panic on modprobe rtl8723bu module.

root@OpenWrt:/# lsusb 
Bus 002 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
Bus 001 Device 003: ID 0bda:b720 Realtek Semiconductor Corp. 
Bus 001 Device 002: ID 0424:2514 Standard Microsystems Corp. USB 2.0 Hub
Bus 001 Device 001: ID 1d6b:0002 Linux Foundation 2.0 root hub
root@OpenWrt:/# 
root@OpenWrt:/# modprobe rtl8723bu
[ 1953.734110] RTL871X: module init start
[ 1953.738354] RTL871X: rtl8723bu v4.3.6.11_12942.20141204_BTCOEX20140507-4E40
[ 1953.745717] RTL871X: rtl8723bu BT-Coex version = BTCOEX20140507-4E40
[ 1953.890947] ------------[ cut here ]------------
[ 1953.896072] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/reg.c:2339 wiphy_apply_custom_regulatory+0x3c/0x448 [cfg80211]
[ 1953.909272] wiphy should have REGULATORY_CUSTOM_REG
[ 1953.914420] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1953.990299]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.011488] CPU: 0 PID: 2222 Comm: modprobe Not tainted 4.14.267 #0
[ 1954.018080] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.024487] Backtrace: 
[ 1954.027097] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1954.035061]  r7:bf349884 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1954.041029] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1954.048641] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1954.055965]  r7:bf349884 r6:bf375b88 r5:00000000 r4:de45db90
[ 1954.061924] [<c0131d08>] (__warn) from [<c0131e50>] (warn_slowpath_fmt+0x40/0x48)
[ 1954.069798]  r9:ddf3e470 r8:bf41d498 r7:bf415998 r6:de6f02e0 r5:de6f6000 r4:bf375c54
[ 1954.078077] [<c0131e14>] (warn_slowpath_fmt) from [<bf349884>] (wiphy_apply_custom_regulatory+0x3c/0x448 [cfg80211])
[ 1954.089136]  r3:00000000 r2:bf375c54
[ 1954.092900]  r4:de6f02e0
[ 1954.096234] [<bf349848>] (wiphy_apply_custom_regulatory [cfg80211]) from [<bf3db0a0>] (rtw_regd_init+0x30/0x3c [8723bu])
[ 1954.107693]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1954.115938]  r4:de6f02e0
[ 1954.119160] [<bf3db070>] (rtw_regd_init [8723bu]) from [<bf3dad84>] (rtw_wdev_alloc+0x1b0/0x2d8 [8723bu])
[ 1954.129237]  r5:de6f6000 r4:de6f02e0
[ 1954.133500] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1954.143492]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1954.151915] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1954.161524]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1954.169755]  r4:ddf3e820
[ 1954.172444] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1954.181869]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1954.190099]  r4:ddf3e820
[ 1954.192778] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1954.201655]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1954.209886]  r4:ddf3e820 r3:00000000
[ 1954.213658] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1954.222258]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1954.228217] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1954.236634]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1954.241500] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1954.249831] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1954.258249]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1954.264209] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1954.273171]  r5:c0d4800c r4:bf41d218
[ 1954.277184] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1954.286701]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1954.295080] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1954.304154]  r5:00000000 r4:c0d07548
[ 1954.307945] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1954.316475]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1954.324639] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1954.333074]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1954.339046] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1954.347392]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1954.355637]  r4:0000c574
[ 1954.358329] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1954.366857]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1954.375102]  r4:00000000
[ 1954.378034] ---[ end trace 4f62d3a66bbf2880 ]---
[ 1954.382917] ------------[ cut here ]------------
[ 1954.388044] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/reg.c:2353 wiphy_apply_custom_regulatory+0xc0/0x448 [cfg80211]
[ 1954.401123] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1954.476964]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.498128] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1954.505997] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.512403] Backtrace: 
[ 1954.515006] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1954.522971]  r7:bf349908 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1954.528936] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1954.536544] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1954.543869]  r7:bf349908 r6:bf375b88 r5:00000000 r4:00000000
[ 1954.549828] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1954.557794]  r9:de6f0bb0 r8:00000034 r7:bf415998 r6:de6f02e0 r5:00000000 r4:de6f02e0
[ 1954.566055] [<c0131ea0>] (warn_slowpath_null) from [<bf349908>] (wiphy_apply_custom_regulatory+0xc0/0x448 [cfg80211])
[ 1954.577699] [<bf349848>] (wiphy_apply_custom_regulatory [cfg80211]) from [<bf3db0a0>] (rtw_regd_init+0x30/0x3c [8723bu])
[ 1954.589153]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1954.597398]  r4:de6f02e0
[ 1954.600588] [<bf3db070>] (rtw_regd_init [8723bu]) from [<bf3dad84>] (rtw_wdev_alloc+0x1b0/0x2d8 [8723bu])
[ 1954.610645]  r5:de6f6000 r4:de6f02e0
[ 1954.614901] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1954.624893]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1954.633311] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1954.642919]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1954.651148]  r4:ddf3e820
[ 1954.653831] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1954.663256]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1954.671485]  r4:ddf3e820
[ 1954.674163] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1954.683040]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1954.691271]  r4:ddf3e820 r3:00000000
[ 1954.695044] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1954.703645]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1954.709603] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1954.718020]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1954.722885] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1954.731216] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1954.739634]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1954.745595] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1954.754557]  r5:c0d4800c r4:bf41d218
[ 1954.758562] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1954.768097]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1954.776488] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1954.785542]  r5:00000000 r4:c0d07548
[ 1954.789320] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1954.797832]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1954.805980] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1954.814398]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1954.820358] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1954.828687]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1954.836917]  r4:0000c574
[ 1954.839601] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1954.848113]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1954.856341]  r4:00000000
[ 1954.859213] ---[ end trace 4f62d3a66bbf2881 ]---
[ 1954.864091] ------------[ cut here ]------------
[ 1954.869180] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/core.c:743 wiphy_register+0x2f0/0xa7c [cfg80211]
[ 1954.880954] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1954.956825]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1954.977994] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1954.985861] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1954.992267] Backtrace: 
[ 1954.994868] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1955.002832]  r7:bf342884 r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1955.008796] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1955.016401] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1955.023725]  r7:bf342884 r6:bf3756e4 r5:00000000 r4:00000000
[ 1955.029684] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1955.037649]  r9:ddf3e470 r8:bf41d498 r7:00000000 r6:00000000 r5:de6f0b00 r4:de6f02e0
[ 1955.045908] [<c0131ea0>] (warn_slowpath_null) from [<bf342884>] (wiphy_register+0x2f0/0xa7c [cfg80211])
[ 1955.056221] [<bf342594>] (wiphy_register [cfg80211]) from [<bf3dad8c>] (rtw_wdev_alloc+0x1b8/0x2d8 [8723bu])
[ 1955.066580]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1955.074827]  r4:de6f02e0
[ 1955.078012] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1955.087986]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1955.096386] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1955.105994]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1955.114224]  r4:ddf3e820
[ 1955.116908] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1955.126332]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1955.134561]  r4:ddf3e820
[ 1955.137240] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1955.146116]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1955.154347]  r4:ddf3e820 r3:00000000
[ 1955.158118] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1955.166718]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1955.172677] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1955.181094]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1955.185959] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1955.194289] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1955.202707]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1955.208666] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1955.217628]  r5:c0d4800c r4:bf41d218
[ 1955.221631] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1955.231147]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1955.239519] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1955.248591]  r5:00000000 r4:c0d07548
[ 1955.252377] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1955.260906]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1955.269068] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1955.277501]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1955.283472] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1955.291816]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1955.300061]  r4:0000c574
[ 1955.302751] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1955.311278]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1955.319524]  r4:00000000
[ 1955.322419] ---[ end trace 4f62d3a66bbf2882 ]---
[ 1955.327355] ------------[ cut here ]------------
[ 1955.332372] WARNING: CPU: 0 PID: 2222 at backports-4.19.221-1/net/wireless/core.c:821 wiphy_register+0x698/0xa7c [cfg80211]
[ 1955.344142] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1955.419963]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1955.441119] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1955.448987] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1955.455392] Backtrace: 
[ 1955.457993] [<c010b598>] (dump_backtrace) from [<c010b890>] (show_stack+0x18/0x1c)
[ 1955.465955]  r7:bf342c2c r6:60000013 r5:00000000 r4:c0d5ed5c
[ 1955.471918] [<c010b878>] (show_stack) from [<c0812a1c>] (dump_stack+0x9c/0xb0)
[ 1955.479523] [<c0812980>] (dump_stack) from [<c0131df4>] (__warn+0xec/0x108)
[ 1955.486847]  r7:bf342c2c r6:bf3756e4 r5:00000000 r4:00000000
[ 1955.492807] [<c0131d08>] (__warn) from [<c0131ec8>] (warn_slowpath_null+0x28/0x30)
[ 1955.500773]  r9:00000000 r8:00000036 r7:bf379480 r6:de6f0bb0 r5:ffffffea r4:de6f02e0
[ 1955.509030] [<c0131ea0>] (warn_slowpath_null) from [<bf342c2c>] (wiphy_register+0x698/0xa7c [cfg80211])
[ 1955.519342] [<bf342594>] (wiphy_register [cfg80211]) from [<bf3dad8c>] (rtw_wdev_alloc+0x1b8/0x2d8 [8723bu])
[ 1955.529681]  r10:de6f100c r9:ddf3e470 r8:bf41d498 r7:ddb41000 r6:e0603000 r5:de6f6000
[ 1955.537911]  r4:de6f02e0
[ 1955.541088] [<bf3dabd4>] (rtw_wdev_alloc [8723bu]) from [<bf3c92e4>] (rtw_drv_init+0x38c/0x4cc [8723bu])
[ 1955.551079]  r9:ddf3e470 r8:ddb41000 r7:e0603000 r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1955.559491] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1955.569118]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1955.577363]  r4:ddf3e820
[ 1955.580053] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1955.589496]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1955.597742]  r4:ddf3e820
[ 1955.600425] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1955.609318]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1955.617566]  r4:ddf3e820 r3:00000000
[ 1955.621344] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1955.629960]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1955.635930] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1955.644362]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1955.649237] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1955.657582] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1955.666016]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1955.671987] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1955.680966]  r5:c0d4800c r4:bf41d218
[ 1955.684976] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1955.694511]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1955.702903] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1955.711957]  r5:00000000 r4:c0d07548
[ 1955.715734] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1955.724248]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1955.732396] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1955.740814]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1955.746773] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1955.755103]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1955.763331]  r4:0000c574
[ 1955.766014] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1955.774525]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1955.782754]  r4:00000000
[ 1955.785553] ---[ end trace 4f62d3a66bbf2883 ]---
[ 1955.790569] Internal error: Oops - undefined instruction: 0 [#1] SMP ARM
[ 1955.797617] Modules linked in: 8723bu(+) cfg80211 compat qcserial pppoe ppp_async option cdc_mbim usb_wwan qmi_wwan pppox ppp_generic nf_conntrack_ipv6 iptable_nat ipt_REJECT ipt_MASQUERADE huawei_cdc_ncm cde
[ 1955.873150]  usb_f_ecm u_ether libcomposite nf_log_ipv6 nf_log_common ip6table_mangle ip6table_filter ip6_tables ip6t_REJECT x_tables nf_reject_ipv6 uas usb_storage xhci_plat_hcd xhci_hcd ohci_platform ohci_m
[ 1955.894181] CPU: 0 PID: 2222 Comm: modprobe Tainted: G        W       4.14.267 #0
[ 1955.902041] Hardware name: Generic AM33XX (Flattened Device Tree)
[ 1955.908444] task: dde55940 task.stack: de45c000
[ 1955.913213] PC is at kfree+0x74/0x158
[ 1955.917372] LR is at rtw_drv_init+0x3d4/0x4cc [8723bu]
[ 1955.922785] pc : [<c0216ea8>]    lr : [<bf3c932c>]    psr: 40000013
[ 1955.929379] sp : de45dc08  ip : de45dc30  fp : de45dc2c
[ 1955.934880] r10: de6f100c  r9 : ddf3e470  r8 : ddb41000
[ 1955.940380] r7 : ffffffea  r6 : e0609000  r5 : e0603000  r4 : dec0c120
[ 1955.947251] r3 : 00000000  r2 : c1270a80  r1 : 1f16f000  r0 : e0609000
[ 1955.954124] Flags: nZcv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[ 1955.961635] Control: 10c5387d  Table: 9d414019  DAC: 00000051
[ 1955.967685] Process modprobe (pid: 2222, stack limit = 0xde45c218)
[ 1955.974191] Stack: (0xde45dc08 to 0xde45e000)
[ 1955.978789] dc00:                   de6f1000 e0603000 de6f1000 e0603000 ddf3e800 ffffffea
[ 1955.987405] dc20: de45dc64 de45dc30 bf3c932c c0216e40 de45dc64 ddf3e400 c051b830 ddf3e820
[ 1955.996020] dc40: ddf3e470 bf41d268 ddf3e400 00000000 ddf3e800 bf41d2b8 de45dc9c de45dc68
[ 1956.004635] dc60: c05e7a5c bf3c8f64 c02917dc ffffffed de45dc9c ddf3e820 c12892c8 c12892cc
[ 1956.013250] dc80: 00000000 bf41d268 00000010 00000000 de45dccc de45dca0 c05126f8 c05e78b0
[ 1956.021865] dca0: 00000000 ddf3e820 bf41d268 ddf3e854 00000000 bf438bc0 00000000 c0d07548
[ 1956.030480] dcc0: de45dcec de45dcd0 c0512920 c05125ac 00000000 bf41d268 c0512890 00000000
[ 1956.039094] dce0: de45dd14 de45dcf0 c0510af4 c051289c de7beca4 ddf6b450 de7becd4 bf41d268
[ 1956.047708] dd00: ddb57900 c0d4800c de45dd24 de45dd18 c0512150 c0510aac de45dd4c de45dd28
[ 1956.056323] dd20: c0511bf0 c0512138 bf419be4 de45dd38 bf41d268 c0d4800c bf41d268 bf419b80
[ 1956.064937] dd40: de45dd64 de45dd50 c0513078 c0511b0c bf41d218 c0d4800c de45dd8c de45dd68
[ 1956.073552] dd60: c05e6480 c0512fd4 bf41d218 00000000 ffffe000 dd5976c0 bf45a000 00000000
[ 1956.082167] dd80: de45dda4 de45dd90 bf45a0a0 c05e6400 c0d07548 00000000 de45de1c de45dda8
[ 1956.090782] dda0: c0101b30 bf45a00c c0d5ef80 00000000 014000c0 de401e40 014000c0 014000c0
[ 1956.099398] ddc0: ddc94288 bf438bc0 00000000 c0d07548 de45ddec de45dde0 c01d91ec c0173f1c
[ 1956.108013] dde0: de45ddfc de45ddf0 c01d9214 c01d91dc de45de1c d9581522 bf438bc0 ddc94000
[ 1956.116628] de00: ddc94258 dd5976c0 bf438bc0 00000000 de45de44 de45de20 c01abd80 c0101a74
[ 1956.125243] de20: de45de44 de45de30 de45df30 ddc94000 ddc94258 ddc94288 de45df2c de45de48
[ 1956.133858] de40: c01aaef8 c01abd24 bf438bcc 00007fff bf438bc0 c01a8304 c0d0a4c4 c0a69b50
[ 1956.142471] de60: c0a69af8 e0602000 c0d07548 c0a69c60 c0ae6748 bf438ce0 bf438ccc 00000031
[ 1956.151084] de80: c0833bd4 c01a7958 bf438c08 014000c0 00000000 00000000 00000000 00000000
[ 1956.159698] dea0: 00000000 00000000 de45dfa4 de45deb8 c010c478 c01012ac e0600000 b6e5f030
[ 1956.168310] dec0: 6e72656b 00006c65 00000000 00000000 00000000 00000000 00000000 00000000
[ 1956.176922] dee0: 00000000 00000000 00000000 00000000 00000000 00000000 00000000 d9581522
[ 1956.185536] df00: 00000055 0000c574 00000000 b6e60584 e0601574 ffffe000 000128de 00000051
[ 1956.194151] df20: de45dfa4 de45df30 c01ab418 c01a9060 e05be68c e0515000 000ec574 e06011b4
[ 1956.202765] df40: e06010f0 e05cd4c4 000b0000 000be0e0 00000000 00000000 00000000 00019dac
[ 1956.211379] df60: 00000015 00000016 00000011 00000000 0000000c 00000000 000ec574 00000000
[ 1956.219993] df80: 00000000 00000003 00000080 c0107e64 de45c000 00000080 00000000 de45dfa8
[ 1956.228607] dfa0: c0107c60 c01ab2e0 00000000 00000000 b6d74010 000ec574 000128de 0000b302
[ 1956.237220] dfc0: 00000000 00000000 00000003 00000080 000ec574 00000000 00000000 00000000
[ 1956.245833] dfe0: bee0dd04 bee0dce8 00011d50 b6ec5b7c 60000010 b6d74010 00000000 00000000
[ 1956.254435] Backtrace: 
[ 1956.257296] [<c0216e34>] (kfree) from [<bf3c932c>] (rtw_drv_init+0x3d4/0x4cc [8723bu])
[ 1956.265621]  r7:ffffffea r6:ddf3e800 r5:e0603000 r4:de6f1000
[ 1956.271827] [<bf3c8f58>] (rtw_drv_init [8723bu]) from [<c05e7a5c>] (usb_probe_interface+0x1b8/0x258)
[ 1956.281448]  r10:bf41d2b8 r9:ddf3e800 r8:00000000 r7:ddf3e400 r6:bf41d268 r5:ddf3e470
[ 1956.289689]  r4:ddf3e820
[ 1956.292371] [<c05e78a4>] (usb_probe_interface) from [<c05126f8>] (driver_probe_device+0x158/0x2f0)
[ 1956.301807]  r10:00000000 r9:00000010 r8:bf41d268 r7:00000000 r6:c12892cc r5:c12892c8
[ 1956.310048]  r4:ddf3e820
[ 1956.312726] [<c05125a0>] (driver_probe_device) from [<c0512920>] (__driver_attach+0x90/0xb4)
[ 1956.321614]  r10:c0d07548 r9:00000000 r8:bf438bc0 r7:00000000 r6:ddf3e854 r5:bf41d268
[ 1956.329856]  r4:ddf3e820 r3:00000000
[ 1956.333629] [<c0512890>] (__driver_attach) from [<c0510af4>] (bus_for_each_dev+0x54/0xa8)
[ 1956.342240]  r7:00000000 r6:c0512890 r5:bf41d268 r4:00000000
[ 1956.348205] [<c0510aa0>] (bus_for_each_dev) from [<c0512150>] (driver_attach+0x24/0x28)
[ 1956.356629]  r6:c0d4800c r5:ddb57900 r4:bf41d268
[ 1956.361497] [<c051212c>] (driver_attach) from [<c0511bf0>] (bus_add_driver+0xf0/0x208)
[ 1956.369836] [<c0511b00>] (bus_add_driver) from [<c0513078>] (driver_register+0xb0/0xec)
[ 1956.378262]  r7:bf419b80 r6:bf41d268 r5:c0d4800c r4:bf41d268
[ 1956.384228] [<c0512fc8>] (driver_register) from [<c05e6480>] (usb_register_driver+0x8c/0x144)
[ 1956.393199]  r5:c0d4800c r4:bf41d218
[ 1956.397200] [<c05e63f4>] (usb_register_driver) from [<bf45a0a0>] (init_module+0xa0/0x1000 [8723bu])
[ 1956.406712]  r9:00000000 r8:bf45a000 r7:dd5976c0 r6:ffffe000 r5:00000000 r4:bf41d218
[ 1956.415080] [<bf45a000>] (init_module [8723bu]) from [<c0101b30>] (do_one_initcall+0xc8/0x18c)
[ 1956.424145]  r5:00000000 r4:c0d07548
[ 1956.427921] [<c0101a68>] (do_one_initcall) from [<c01abd80>] (do_init_module+0x68/0x208)
[ 1956.436444]  r9:00000000 r8:bf438bc0 r7:dd5976c0 r6:ddc94258 r5:ddc94000 r4:bf438bc0
[ 1956.444601] [<c01abd18>] (do_init_module) from [<c01aaef8>] (load_module+0x1ea4/0x2280)
[ 1956.453030]  r7:ddc94288 r6:ddc94258 r5:ddc94000 r4:de45df30
[ 1956.458994] [<c01a9054>] (load_module) from [<c01ab418>] (SyS_init_module+0x144/0x17c)
[ 1956.467332]  r10:00000051 r9:000128de r8:ffffe000 r7:e0601574 r6:b6e60584 r5:00000000
[ 1956.475571]  r4:0000c574
[ 1956.478252] [<c01ab2d4>] (SyS_init_module) from [<c0107c60>] (ret_fast_syscall+0x0/0x54)
[ 1956.486773]  r10:00000080 r9:de45c000 r8:c0107e64 r7:00000080 r6:00000003 r5:00000000
[ 1956.495012]  r4:00000000
[ 1956.497691] Code: 1a000003 e5943014 e3130001 1a000000 (e7f001f2) 
[ 1956.504115] ---[ end trace 4f62d3a66bbf2884 ]---
[ 1956.508979] Kernel panic - not syncing: Fatal exception
[ 1956.514502] Rebooting in 3 seconds..

I am compiling this driver for Beaglebone Black based platform with OpenWrt version v19.07.9.

@lwfinger I have commented EXTRA_CFLAGS += -DCONFIG_CONCURRENT_MODE in my compilation.

lwfinger commented 2 years ago

@vbvchauthmal - It appears as if you are using kernel 4.19. Is that correct? Which branch of the repo? As far as I can see, the first warning about not having REGULATORY_CUSTOM_REG set is bogus as the code definitely sets it. I have not looked into the rest of the warnings or the oops yet.

vbvchauthmal commented 2 years ago

@lwfinger The OpenWrt v19.07.9 which I compiled is with kernel version 4.14.267.

lwfinger commented 2 years ago

What branch of this repo are you using? The 'git branch' command will tell you that information.

vbvchauthmal commented 2 years ago

@lwfinger I am using the master branch of this repo having last commit id 2cd9874d128423c92314324abc7ee0fd7923afcf.