1. 29 Jul, 2022 1 commit
  2. 28 Jul, 2022 7 commits
    • Danny van Heumen's avatar
      wifi: brcmfmac: prevent double-free on hardware-reset · cb774bd3
      Danny van Heumen authored
      In case of buggy firmware, brcmfmac may perform a hardware reset. If during
      reset and subsequent probing an early failure occurs, a memory region is
      accidentally double-freed. With hardened memory allocation enabled, this error
      will be detected.
      
      - return early where appropriate to skip unnecessary clean-up.
      - set '.freezer' pointer to NULL to prevent double-freeing under possible
        other circumstances and to re-align result under various different
        behaviors of memory allocation freeing.
      - correctly claim host on func1 for disabling func2.
      - after reset, do not initiate probing immediately, but rely on events.
      
      Given a firmware crash, function 'brcmf_sdio_bus_reset' is called. It calls
      'brcmf_sdiod_remove', then follows up with 'brcmf_sdiod_probe' to reinitialize
      the hardware. If 'brcmf_sdiod_probe' fails to "set F1 blocksize", it exits
      early, which includes calling 'brcmf_sdiod_remove'. In both cases
      'brcmf_sdiod_freezer_detach' is called to free allocated '.freezer', which
      has not yet been re-allocated the second time.
      
      Stacktrace of (failing) hardware reset after firmware-crash:
      
      Code: b9402b82 8b0202c0 eb1a02df 54000041 (d4210000)
       ret_from_fork+0x10/0x20
       kthread+0x154/0x160
       worker_thread+0x188/0x504
       process_one_work+0x1f4/0x490
       brcmf_core_bus_reset+0x34/0x44 [brcmfmac]
       brcmf_sdio_bus_reset+0x68/0xc0 [brcmfmac]
       brcmf_sdiod_probe+0x170/0x21c [brcmfmac]
       brcmf_sdiod_remove+0x48/0xc0 [brcmfmac]
       kfree+0x210/0x220
       __slab_free+0x58/0x40c
      Call trace:
      x2 : 0000000000000040 x1 : fffffc00002d2b80 x0 : ffff00000b4aee40
      x5 : ffff8000013fa728 x4 : 0000000000000001 x3 : ffff00000b4aee00
      x8 : ffff800009967ce0 x7 : ffff8000099bfce0 x6 : 00000006f8005d01
      x11: ffff8000099bfce0 x10: 00000000fffff000 x9 : ffff8000083401d0
      x14: 0000000000000000 x13: 657a69736b636f6c x12: 6220314620746573
      x17: 0000000000000000 x16: 0000000000000000 x15: 0000000000000030
      x20: fffffc00002d2ba0 x19: fffffc00002d2b80 x18: 0000000000000000
      x23: ffff00000b4aee00 x22: ffff00000b4aee00 x21: 0000000000000001
      x26: ffff00000b4aee00 x25: ffff0000f7753705 x24: 000000000001288a
      x29: ffff80000a22bbf0 x28: ffff000000401200 x27: 000000008020001a
      sp : ffff80000a22bbf0
      lr : kfree+0x210/0x220
      pc : __slab_free+0x58/0x40c
      pstate: 60000005 (nZCv daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
      Workqueue: events brcmf_core_bus_reset [brcmfmac]
      Hardware name: Pine64 Pinebook Pro (DT)
      CPU: 2 PID: 639 Comm: kworker/2:2 Tainted: G         C        5.16.0-0.bpo.4-arm64 #1  Debian 5.16.12-1~bpo11+1
       nvmem_rockchip_efuse industrialio_triggered_buffer videodev snd_soc_core snd_pcm_dmaengine kfifo_buf snd_pcm io_domain mc industrialio mt>
      Modules linked in: snd_seq_dummy snd_hrtimer snd_seq snd_seq_device nft_fib_inet nft_fib_ipv4 nft_fib_ipv6 nft_fib nft_reject_inet nf_reje>
      Internal error: Oops - BUG: 0 [#1] SMP
      kernel BUG at mm/slub.c:379!
      Signed-off-by: default avatarDanny van Heumen <danny@dannyvanheumen.nl>
      Reviewed-by: Arend van Spriel <aspriel.gmail.com>
      Reviewed-by: default avatarUlf Hansson <ulf.hansson@linaro.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/id1HN6qCMAirApBzTA6fT7ZFWBBGCJhULpflxQ7NT6cgCboVnn3RHpiOFjA9SbRqzBRFLk9ES0C4FNvO6fUQsNg7pqF6ZSNAYUo99nHy8PY=@dannyvanheumen.nl
      cb774bd3
    • Alvin Šipraga's avatar
      wifi: brcmfmac: support brcm,ccode-map-trivial DT property · 5c54ab24
      Alvin Šipraga authored
      Commit a21bf90e ("brcmfmac: use ISO3166 country code and 0 rev as
      fallback on some devices") introduced a fallback mechanism whereby a
      trivial mapping from ISO3166 country codes to firmware country code and
      revision is used on some devices. This fallback operates on the device
      level, so it is enabled only for certain supported chipsets.
      
      In general though, the firmware country codes are determined by the CLM
      blob, which is board-specific and may vary despite the underlying
      chipset being the same.
      
      The aforementioned commit is actually a refinement of a previous commit
      that was reverted in commit 151a7c12 ("Revert "brcmfmac: use ISO3166
      country code and 0 rev as fallback"") due to regressions with a BCM4359
      device. The refinement restricted the fallback mechanism to specific
      chipsets such as the BCM4345.
      
      We use a chipset - CYW88359 - that the driver identifies as a BCM4359
      too. But in our case, the CLM blob uses ISO3166 country codes
      internally, and all with revision 0. So the trivial mapping is exactly
      what is needed in order for the driver to sync the kernel regulatory
      domain to the firmware. This is just a matter of how the CLM blob was
      prepared by the hardware vendor. The same could hold for other boards
      too.
      
      Although the brcm,ccode-map device tree property is useful for cases
      where the mapping is more complex, the trivial case invites a much
      simpler specification. This patch adds support for parsing the
      brcm,ccode-map-trivial device tree property. Subordinate to the more
      specific brcm,ccode-map property, this new proprety simply informs the
      driver that the fallback method should be used in every case.
      
      In the absence of the new property in the device tree, expect no
      functional change.
      Signed-off-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
      Reviewed-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220711123005.3055300-3-alvin@pqrs.dk
      5c54ab24
    • Alvin Šipraga's avatar
      dt-bindings: bcm4329-fmac: add optional brcm,ccode-map-trivial · 8406993a
      Alvin Šipraga authored
      The bindings already offer a brcm,ccode-map property to describe the
      mapping between the kernel's ISO3166 alpha 2 country code string and the
      firmware's country code string and revision number. This is a
      board-specific property and determined by the CLM blob firmware provided
      by the hardware vendor.
      
      However, in some cases the firmware will also use ISO3166 country codes
      internally, and the revision will always be zero. This implies a trivial
      mapping: cc -> { cc, 0 }.
      
      For such cases, add an optional property brcm,ccode-map-trivial which
      obviates the need to describe every trivial country code mapping in the
      device tree with the existing brcm,ccode-map property. The new property
      is subordinate to the more explicit brcm,ccode-map property.
      Signed-off-by: default avatarAlvin Šipraga <alsi@bang-olufsen.dk>
      Reviewed-by: default avatarAhmad Fatoum <a.fatoum@pengutronix.de>
      Acked-by: default avatarRob Herring <robh@kernel.org>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220711123005.3055300-2-alvin@pqrs.dk
      8406993a
    • Hans de Goede's avatar
      wifi: brcmfmac: Replace default (not configured) MAC with a random MAC · 4af4c0b9
      Hans de Goede authored
      On some boards there is no eeprom to hold the nvram, in this case instead
      a board specific nvram is loaded from /lib/firmware. On most boards the
      macaddr=... setting in the /lib/firmware nvram file is ignored because
      the wifi/bt chip has a unique MAC programmed into the chip itself.
      
      But in some cases the actual MAC from the /lib/firmware nvram file gets
      used, leading to MAC conflicts.
      
      The MAC addresses in the troublesome nvram files seem to all come from
      the same nvram file template, so we can detect this by checking for
      the template nvram file MAC.
      
      Detect that the default MAC address is being used and replace it
      with a random MAC address to avoid MAC address conflicts.
      
      Note that udev will detect this is a random MAC based on
      /sys/class/net/wlan0/addr_assign_type and then replace this with
      a MAC based on hashing the netdev-name + the machine-id. So that
      the MAC address is both guaranteed to be unique per machine while
      it is still the same/persistent at each boot (assuming the
      default Link.MACAddressPolicy=persistent udev setting).
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Reviewed-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220708133712.102179-2-hdegoede@redhat.com
      4af4c0b9
    • Hans de Goede's avatar
      wifi: brcmfmac: Add brcmf_c_set_cur_etheraddr() helper · cf1239e5
      Hans de Goede authored
      Add a little helper to send "cur_etheraddr" commands to the interface
      and to handle the error reporting of it in a single place.
      Signed-off-by: default avatarHans de Goede <hdegoede@redhat.com>
      Acked-by: default avatarArend van Spriel <aspriel@gmail.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220708133712.102179-1-hdegoede@redhat.com
      cf1239e5
    • Paul Cercueil's avatar
      wifi: brcmfmac: Remove #ifdef guards for PM related functions · 02a186f1
      Paul Cercueil authored
      Use the new DEFINE_SIMPLE_DEV_PM_OPS() and pm_sleep_ptr() macros to
      handle the .suspend/.resume callbacks.
      
      These macros allow the suspend and resume functions to be automatically
      dropped by the compiler when CONFIG_SUSPEND is disabled, without having
      to use #ifdef guards.
      
      Some other functions not directly called by the .suspend/.resume
      callbacks, but still related to PM were also taken outside #ifdef
      guards.
      
      The advantage is then that these functions are now always compiled
      independently of any Kconfig option, and thanks to that bugs and
      regressions are easier to catch.
      Signed-off-by: default avatarPaul Cercueil <paul@crapouillou.net>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/20220627193701.31074-1-paul@crapouillou.net
      02a186f1
    • Dan Carpenter's avatar
      wifi: brcmfmac: use strreplace() in brcmf_of_probe() · bef11f1e
      Dan Carpenter authored
      The for loop in brcmf_of_probe() would ideally end with something like
      "i <= strlen(board_type)" instead of "i < board_type[i]".  But
      fortunately, the two are equivalent.
      
      Anyway, it's simpler to use strreplace() instead.
      Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
      Suggested-by: default avatarJohannes Berg <johannes@sipsolutions.net>
      Reviewed-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Acked-by: default avatarArend van Spriel <arend.vanspriel@broadcom.com>
      Signed-off-by: default avatarKalle Valo <kvalo@kernel.org>
      Link: https://lore.kernel.org/r/YqrhsKcjEA7B2pC4@kili
      bef11f1e
  3. 27 Jul, 2022 19 commits
  4. 26 Jul, 2022 9 commits
  5. 25 Jul, 2022 4 commits