From: Christian Marangi Date: Wed, 10 May 2023 13:45:49 +0000 (+0200) Subject: kernel: broadcom-wl: multiple fix to make the package compilable again X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=3ccdc15c6ab14df898d9f36f0d7fa752ac1c15d6;p=openwrt%2Fstaging%2Fblogic.git kernel: broadcom-wl: multiple fix to make the package compilable again Add multiple patch to make the package compilable again. Aside from some fixup of obvius wrong code, some real fix were needed. This fix any compilation warning found on compiling the package on bcm47xx. (omitted since they are too much) The real problem of this package was the missing MODULE_LICENSE now mandatory even without WERROR. Set to Proprietary. And the big blocker is that Broadcom provided an object file targetting an old kernel version. The module on modprobe try to find the symbol printk but printk was dropped and replaced to _printk. To handle this change we use objcopy tool to rename the symbol to the new name permitting a correct modprobe and creation of .ko Signed-off-by: Christian Marangi --- diff --git a/package/kernel/broadcom-wl/Makefile b/package/kernel/broadcom-wl/Makefile index fe8045d4a9a5..a1feacbe2901 100644 --- a/package/kernel/broadcom-wl/Makefile +++ b/package/kernel/broadcom-wl/Makefile @@ -105,6 +105,15 @@ MAKE_KMOD := $(KERNEL_MAKE) \ define Build/Prepare $(call Build/Prepare/Default) + + # New kernel version changed the sysmbol exported from printk to _printk + # The object file provided by broadcom require modification to correctly + # modprobe and generate a .ko + $(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta/wl_prebuilt.o \ + --redefine-sym printk=_printk + $(TARGET_CROSS)objcopy $(PKG_BUILD_DIR)/driver/wl_apsta_mini/wl_prebuilt.o \ + --redefine-sym printk=_printk + $(CP) $(PKG_BUILD_DIR)/driver $(PKG_BUILD_DIR)/driver-mini $(CP) ./src/glue $(PKG_BUILD_DIR)/glue endef diff --git a/package/kernel/broadcom-wl/patches/919-fix-compilation-warning-for-stack-limit.patch b/package/kernel/broadcom-wl/patches/919-fix-compilation-warning-for-stack-limit.patch new file mode 100644 index 000000000000..3149ce34b918 --- /dev/null +++ b/package/kernel/broadcom-wl/patches/919-fix-compilation-warning-for-stack-limit.patch @@ -0,0 +1,297 @@ +--- a/driver/wl_iw.c ++++ b/driver/wl_iw.c +@@ -495,9 +495,9 @@ wl_iw_get_range( + ) + { + struct iw_range *range = (struct iw_range *) extra; +- int channels[MAXCHANNEL+1]; +- wl_uint32_list_t *list = (wl_uint32_list_t *) channels; +- wl_rateset_t rateset; ++ int *channels; ++ wl_uint32_list_t *list; ++ wl_rateset_t *rateset; + int error, i; + uint sf, ch; + +@@ -506,6 +506,17 @@ wl_iw_get_range( + if (!extra) + return -EINVAL; + ++ channels = kcalloc(MAXCHANNEL+1, sizeof(*channels), GFP_KERNEL); ++ if (!channels) ++ return -ENOMEM; ++ list = (wl_uint32_list_t *) channels; ++ ++ rateset = kzalloc(sizeof(*rateset), GFP_KERNEL); ++ if (!rateset) { ++ error = -ENOMEM; ++ goto free_channels; ++ } ++ + dwrq->length = sizeof(struct iw_range); + memset(range, 0, sizeof(range)); + +@@ -514,8 +525,9 @@ wl_iw_get_range( + + /* Set available channels/frequencies */ + list->count = htod32(MAXCHANNEL); +- if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, sizeof(channels)))) +- return error; ++ if ((error = dev_wlc_ioctl(dev, WLC_GET_VALID_CHANNELS, channels, ++ (MAXCHANNEL+1) * sizeof(*channels)))) ++ goto free_rateset; + for (i = 0; i < dtoh32(list->count) && i < IW_MAX_FREQUENCIES; i++) { + range->freq[i].i = dtoh32(list->element[i]); + +@@ -549,19 +561,19 @@ wl_iw_get_range( + #endif /* WIRELESS_EXT > 11 */ + + /* Set available bitrates */ +- if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, &rateset, sizeof(rateset)))) +- return error; +- rateset.count = dtoh32(rateset.count); +- range->num_bitrates = rateset.count; +- for (i = 0; i < rateset.count && i < IW_MAX_BITRATES; i++) +- range->bitrate[i] = (rateset.rates[i] & 0x7f) * 500000; /* convert to bps */ ++ if ((error = dev_wlc_ioctl(dev, WLC_GET_CURR_RATESET, rateset, sizeof(*rateset)))) ++ goto free_rateset; ++ rateset->count = dtoh32(rateset->count); ++ range->num_bitrates = rateset->count; ++ for (i = 0; i < rateset->count && i < IW_MAX_BITRATES; i++) ++ range->bitrate[i] = (rateset->rates[i] & 0x7f) * 500000; /* convert to bps */ + + /* Set an indication of the max TCP throughput + * in bit/s that we can expect using this interface. + * May be use for QoS stuff... Jean II + */ + if ((error = dev_wlc_ioctl(dev, WLC_GET_PHYTYPE, &i, sizeof(i)))) +- return error; ++ goto free_rateset; + i = dtoh32(i); + if (i == WLC_PHY_TYPE_A) + range->throughput = 24000000; /* 24 Mbits/s */ +@@ -624,7 +636,12 @@ wl_iw_get_range( + #endif + #endif /* WIRELESS_EXT > 17 */ + +- return 0; ++free_rateset: ++ kfree(rateset); ++free_channels: ++ kfree(channels); ++ ++ return error; + } + + static int +--- a/driver/bcmsrom.c ++++ b/driver/bcmsrom.c +@@ -437,20 +437,37 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + uint byteoff, uint nbytes, uint16 *buf) + { + uint i, nw, crc_range; +- uint16 old[SROM_MAXW], new[SROM_MAXW]; ++ uint16 *old, *new; + uint8 crc; + volatile uint32 val32; ++ int rc = 0; + + ASSERT(bustype == BUSTYPE(bustype)); + ++ old = MALLOC(osh, SROM_MAXW); ++ ASSERT(old != NULL); ++ if (!old) ++ return -2; ++ ++ new = MALLOC(osh, SROM_MAXW); ++ ASSERT(new != NULL); ++ if (!new) { ++ rc = -2; ++ goto free_old; ++ } ++ + /* check input - 16-bit access only. use byteoff 0x55aa to indicate + * srclear + */ +- if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1))) +- return 1; ++ if ((byteoff != 0x55aa) && ((byteoff & 1) || (nbytes & 1))) { ++ rc = 1; ++ goto free_new; ++ } + +- if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX)) +- return 1; ++ if ((byteoff != 0x55aa) && ((byteoff + nbytes) > SROM_MAX)) { ++ rc = 1; ++ goto free_new; ++ } + + if (BUSTYPE(bustype) == PCMCIA_BUS) { + crc_range = SROM_MAX; +@@ -467,8 +484,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + + nw = crc_range / 2; + /* read first small number words from srom, then adjust the length, read all */ +- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) +- return 1; ++ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) { ++ rc = 1; ++ goto free_new; ++ } + + BS_ERROR(("%s: old[SROM4_SIGN] 0x%x, old[SROM8_SIGN] 0x%x\n", + __FUNCTION__, old[SROM4_SIGN], old[SROM8_SIGN])); +@@ -481,10 +500,13 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + __FUNCTION__, buf[SROM4_SIGN], buf[SROM8_SIGN])); + + /* block invalid buffer size */ +- if (nbytes < SROM4_WORDS * 2) +- return BCME_BUFTOOSHORT; +- else if (nbytes > SROM4_WORDS * 2) +- return BCME_BUFTOOLONG; ++ if (nbytes < SROM4_WORDS * 2) { ++ rc = BCME_BUFTOOSHORT; ++ goto free_new; ++ } else if (nbytes > SROM4_WORDS * 2) { ++ rc = BCME_BUFTOOLONG; ++ goto free_new; ++ } + + nw = SROM4_WORDS; + } else if (nbytes == SROM_WORDS * 2){ /* the other possible SROM format */ +@@ -493,17 +515,22 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + nw = SROM_WORDS; + } else { + BS_ERROR(("%s: Invalid input file signature\n", __FUNCTION__)); +- return BCME_BADARG; ++ rc = BCME_BADARG; ++ goto free_new; + } + crc_range = nw * 2; +- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) +- return 1; ++ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) { ++ rc = 1; ++ goto free_new; ++ } + } else if ((old[SROM4_SIGN] == SROM4_SIGNATURE) || + (old[SROM8_SIGN] == SROM4_SIGNATURE)) { + nw = SROM4_WORDS; + crc_range = nw * 2; +- if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) +- return 1; ++ if (srom_read(sih, bustype, curmap, osh, 0, crc_range, old, FALSE)) { ++ rc = 1; ++ goto free_new; ++ } + } else { + /* Assert that we have already read enough for sromrev 2 */ + ASSERT(crc_range >= SROM_WORDS * 2); +@@ -562,8 +589,10 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + } + } else if (BUSTYPE(bustype) == PCMCIA_BUS) { + /* enable writes to the SPROM */ +- if (sprom_cmd_pcmcia(osh, SROM_WEN)) +- return 1; ++ if (sprom_cmd_pcmcia(osh, SROM_WEN)) { ++ rc = 1; ++ goto free_new; ++ } + bcm_mdelay(WRITE_ENABLE_DELAY); + /* write srom */ + for (i = 0; i < nw; i++) { +@@ -573,14 +602,15 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + } + } + /* disable writes to the SPROM */ +- if (sprom_cmd_pcmcia(osh, SROM_WDS)) +- return 1; ++ if (sprom_cmd_pcmcia(osh, SROM_WDS)) { ++ rc = 1; ++ goto free_new; ++ } + } else if (BUSTYPE(bustype) == SI_BUS) { + #if defined(BCMUSBDEV) + if (SPROMBUS == PCMCIA_BUS) { + uint origidx; + void *regs; +- int rc; + bool wasup; + + origidx = si_coreidx(sih); +@@ -596,16 +626,24 @@ srom_write(si_t *sih, uint bustype, void *curmap, osl_t *osh, + si_core_disable(sih, 0); + + si_setcoreidx(sih, origidx); +- return rc; ++ goto free_new; + } + #endif +- return 1; ++ rc = 1; ++ goto free_new; + } else { +- return 1; ++ rc = 1; ++ goto free_new; + } + + bcm_mdelay(WRITE_ENABLE_DELAY); +- return 0; ++ rc = 0; ++ ++free_new: ++ MFREE(osh, new, SROM_MAXW); ++free_old: ++ MFREE(osh, old, SROM_MAXW); ++ return rc; + } + + #if defined(BCMUSBDEV) +--- a/driver/linux_osl.c ++++ b/driver/linux_osl.c +@@ -600,20 +600,29 @@ int + osl_printf(const char *format, ...) + { + va_list args; +- char buf[1024]; ++ char *buf; + int len; + ++ buf = kcalloc(1024, sizeof(*buf), GFP_KERNEL); ++ if (!buf) ++ return (-ENOMEM); ++ + /* sprintf into a local buffer because there *is* no "vprintk()".. */ + va_start(args, format); + len = vsnprintf(buf, 1024, format, args); + va_end(args); + +- if (len > sizeof(buf)) { ++ if (len > (sizeof(*buf) * 1024)) { + printk("osl_printf: buffer overrun\n"); +- return (0); ++ goto exit; + } + +- return (printk(buf)); ++ printk(buf); ++ ++exit: ++ kfree(buf); ++ ++ return (0); + } + + int +--- a/driver/bcmutils.c ++++ b/driver/bcmutils.c +@@ -13,6 +13,7 @@ + + #include + #include ++#define __need___va_list + #include + #include + #ifdef BCMDRIVER diff --git a/package/kernel/broadcom-wl/patches/920-aiutils-fix-wrong-misleading-if.patch b/package/kernel/broadcom-wl/patches/920-aiutils-fix-wrong-misleading-if.patch new file mode 100644 index 000000000000..c43dca9e896f --- /dev/null +++ b/package/kernel/broadcom-wl/patches/920-aiutils-fix-wrong-misleading-if.patch @@ -0,0 +1,14 @@ +--- a/driver/aiutils.c ++++ b/driver/aiutils.c +@@ -228,9 +228,10 @@ ai_scan(si_t *sih, void *regs, uint devid) + do { + asd = get_asd(sih, &eromptr, 0, j, AD_ST_SLAVE, &addrl, &addrh, + &sizel, &sizeh); +- if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) ++ if ((asd != 0) && (j == 1) && (sizel == SI_CORE_SIZE)) { + sii->coresba2[idx] = addrl; + sii->coresba2_size[idx] = sizel; ++ } + j++; + } while (asd != 0); + diff --git a/package/kernel/broadcom-wl/patches/921-fix-simple-compilation-warning.patch b/package/kernel/broadcom-wl/patches/921-fix-simple-compilation-warning.patch new file mode 100644 index 000000000000..2158dc67b80a --- /dev/null +++ b/package/kernel/broadcom-wl/patches/921-fix-simple-compilation-warning.patch @@ -0,0 +1,63 @@ +--- a/driver/hnddma.c ++++ b/driver/hnddma.c +@@ -1896,7 +1896,8 @@ dma64_txfast(dma_info_t *di, void *p0, bool commit) + if (!(flags & D64_CTRL1_EOF)) { + #if defined(linux) && defined(__mips__) + if (CHIPID(di->sih->chip) == BCM5356_CHIP_ID && di->sih->chiprev == 0) { +- uint32 ctrl1, ctrl2, addrlow, addrhigh; ++ uint32 ctrl2, addrlow, addrhigh; ++ // uint32 ctrl1; + + addrlow = R_SM((volatile uint32 *)&di->txd64[PREVTXD(txout)].addrlow); + addrhigh = R_SM((volatile uint32 *)&di->txd64[PREVTXD(txout)].addrhigh); + +--- a/driver/include/linux_osl.h ++++ b/driver/include/linux_osl.h +@@ -580,9 +580,9 @@ extern void osl_writew(uint16 v, volatile uint16 *r); + extern void osl_writel(uint32 v, volatile uint32 *r); + + /* uncached/cached virtual address */ +-#define OSL_UNCACHED(va) osl_uncached((va)) ++#define OSL_UNCACHED(va) osl_uncached((void *)(va)) + extern void *osl_uncached(void *va); +-#define OSL_CACHED(va) osl_cached((va)) ++#define OSL_CACHED(va) osl_cached((void *)(va)) + extern void *osl_cached(void *va); + + /* get processor cycle count */ +--- a/driver/siutils.c ++++ b/driver/siutils.c +@@ -495,11 +495,13 @@ BCMATTACHFN(si_doattach)(si_info_t *sii, uint devid, osl_t *osh, void *regs, + } + + sih->bustype = bustype; ++#ifdef BCMBUSTYPE + if (bustype != BUSTYPE(bustype)) { + SI_ERROR(("si_doattach: bus type %d does not match configured bus type %d\n", + bustype, BUSTYPE(bustype))); + return NULL; + } ++#endif + + /* bus/core/clk setup for register access */ + if (!si_buscore_prep(sii, bustype, devid, sdh)) { +@@ -1716,6 +1718,9 @@ si_clkctl_xtal(si_t *sih, uint what, bool on) + outen); + } + ++ return (0); ++ ++ + default: + return (-1); + } +--- a/driver/bcmsrom.c ++++ b/driver/bcmsrom.c +@@ -1005,6 +1043,7 @@ BCMNMIATTACHFN(srom_parsecis)(osl_t *osh, uint8 *pcis[], uint ciscnt, char **var + break; + } + ++ fallthrough; + case CISTPL_MANFID: FROMHOST(); + varbuf_append(&b, vstr_manfid, (cis[i + 1] << 8) + cis[i]); + varbuf_append(&b, vstr_prodid, (cis[i + 3] << 8) + cis[i + 2]); diff --git a/package/kernel/broadcom-wl/patches/930-wl_linux-set-module-license-Proprietary.patch b/package/kernel/broadcom-wl/patches/930-wl_linux-set-module-license-Proprietary.patch new file mode 100644 index 000000000000..6d0571711c47 --- /dev/null +++ b/package/kernel/broadcom-wl/patches/930-wl_linux-set-module-license-Proprietary.patch @@ -0,0 +1,10 @@ +--- a/driver/wl_linux.c ++++ b/driver/wl_linux.c +@@ -1109,6 +1109,7 @@ wl_module_exit(void) + + module_init(wl_module_init); + module_exit(wl_module_exit); ++MODULE_LICENSE("Proprietary"); + + /** + * This function frees the WL per-device resources.