1. Dec 04, 2023
    • Douglas Anderson's avatar
      r8152: Add RTL8152_INACCESSIBLE to r8156b_wait_loading_flash() · 8a67b47f
      Douglas Anderson authored
      Delay loops in r8152 should break out if RTL8152_INACCESSIBLE is set
      so that they don't delay too long if the device becomes
      inaccessible. Add the break to the loop in
      r8156b_wait_loading_flash().
      
      Fixes: 195aae32
      
       ("r8152: support new chips")
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Acked-by: default avatarHayes Wang <hayeswang@realtek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8a67b47f
    • Douglas Anderson's avatar
      r8152: Add RTL8152_INACCESSIBLE checks to more loops · 32a574c7
      Douglas Anderson authored
      Previous commits added checks for RTL8152_INACCESSIBLE in the loops in
      the driver. There are still a few more that keep tripping the driver
      up in error cases and make things take longer than they should. Add
      those in.
      
      All the loops that are part of this commit existed in some form or
      another since the r8152 driver was first introduced, though
      RTL8152_INACCESSIBLE was known as RTL8152_UNPLUG before commit
      715f67f3 ("r8152: Rename RTL8152_UNPLUG to RTL8152_INACCESSIBLE")
      
      Fixes: ac718b69
      
       ("net/usb: new driver for RTL8152")
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Acked-by: default avatarHayes Wang <hayeswang@realtek.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      32a574c7
    • Douglas Anderson's avatar
      r8152: Hold the rtnl_lock for all of reset · e62adaee
      Douglas Anderson authored
      As of commit d9962b0d ("r8152: Block future register access if
      register access fails") there is a race condition that can happen
      between the USB device reset thread and napi_enable() (not) getting
      called during rtl8152_open(). Specifically:
      * While rtl8152_open() is running we get a register access error
        that's _not_ -ENODEV and queue up a USB reset.
      * rtl8152_open() exits before calling napi_enable() due to any reason
        (including usb_submit_urb() returning an error).
      
      In that case:
      * Since the USB reset is perform in a separate thread asynchronously,
        it can run at anytime USB device lock is not held - even before
        rtl8152_open() has exited with an error and caused __dev_open() to
        clear the __LINK_STATE_START bit.
      * The rtl8152_pre_reset() will notice that the netif_running() returns
        true (since __LINK_STATE_START wasn't cleared) so it won't exit
        early.
      * rtl8152_pre_reset() will then hang in napi_disable() because
        napi_enable() was never called.
      
      We can fix the race by making sure that the r8152 reset routines don't
      run at the same time as we're opening the device. Specifically we need
      the reset routines in their entirety rely on the return value of
      netif_running(). The only way to reliably depend on that is for them
      to hold the rntl_lock() mutex for the duration of reset.
      
      Grabbing the rntl_lock() mutex for the duration of reset seems like a
      long time, but reset is not expected to be common and the rtnl_lock()
      mutex is already held for long durations since the core grabs it
      around the open/close calls.
      
      Fixes: d9962b0d
      
       ("r8152: Block future register access if register access fails")
      Reviewed-by: default avatarGrant Grundler <grundler@chromium.org>
      Signed-off-by: default avatarDouglas Anderson <dianders@chromium.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      e62adaee
  2. Dec 03, 2023
  3. Dec 02, 2023
    • Randy Dunlap's avatar
      hv_netvsc: rndis_filter needs to select NLS · 6c89f499
      Randy Dunlap authored
      rndis_filter uses utf8s_to_utf16s() which is provided by setting
      NLS, so select NLS to fix the build error:
      
      ERROR: modpost: "utf8s_to_utf16s" [drivers/net/hyperv/hv_netvsc.ko] undefined!
      
      Fixes: 1ce09e89
      
       ("hyperv: Add support for setting MAC from within guests")
      Signed-off-by: default avatarRandy Dunlap <rdunlap@infradead.org>
      Cc: Haiyang Zhang <haiyangz@microsoft.com>
      Cc: K. Y. Srinivasan <kys@microsoft.com>
      Cc: Wei Liu <wei.liu@kernel.org>
      Cc: Dexuan Cui <decui@microsoft.com>
      Reviewed-by: default avatarSimon Horman <horms@kernel.org>
      Tested-by: Simon Horman <horms@kernel.org> # build-tested
      Reviewed-by: default avatarMichael Kelley <mikelley@microsoft.com>
      Link: https://lore.kernel.org/r/20231130055853.19069-1-rdunlap@infradead.org
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      6c89f499
    • Thinh Tran's avatar
      net/tg3: fix race condition in tg3_reset_task() · 16b55b1f
      Thinh Tran authored
      
      
      When an EEH error is encountered by a PCI adapter, the EEH driver
      modifies the PCI channel's state as shown below:
      
         enum {
            /* I/O channel is in normal state */
            pci_channel_io_normal = (__force pci_channel_state_t) 1,
      
            /* I/O to channel is blocked */
            pci_channel_io_frozen = (__force pci_channel_state_t) 2,
      
            /* PCI card is dead */
            pci_channel_io_perm_failure = (__force pci_channel_state_t) 3,
         };
      
      If the same EEH error then causes the tg3 driver's transmit timeout
      logic to execute, the tg3_tx_timeout() function schedules a reset
      task via tg3_reset_task_schedule(), which may cause a race condition
      between the tg3 and EEH driver as both attempt to recover the HW via
      a reset action.
      
      EEH driver gets error event
      --> eeh_set_channel_state()
          and set device to one of
          error state above           scheduler: tg3_reset_task() get
                                      returned error from tg3_init_hw()
                                   --> dev_close() shuts down the interface
      tg3_io_slot_reset() and
      tg3_io_resume() fail to
      reset/resume the device
      
      To resolve this issue, we avoid the race condition by checking the PCI
      channel state in the tg3_reset_task() function and skip the tg3 driver
      initiated reset when the PCI channel is not in the normal state.  (The
      driver has no access to tg3 device registers at this point and cannot
      even complete the reset task successfully without external assistance.)
      We'll leave the reset procedure to be managed by the EEH driver which
      calls the tg3_io_error_detected(), tg3_io_slot_reset() and
      tg3_io_resume() functions as appropriate.
      
      Adding the same checking in tg3_dump_state() to avoid dumping all
      device registers when the PCI channel is not in the normal state.
      
      Signed-off-by: default avatarThinh Tran <thinhtr@linux.vnet.ibm.com>
      Tested-by: default avatarVenkata Sai Duggi <venkata.sai.duggi@ibm.com>
      Reviewed-by: default avatarDavid Christensen <drc@linux.vnet.ibm.com>
      Reviewed-by: default avatarMichael Chan <michael.chan@broadcom.com>
      Link: https://lore.kernel.org/r/20231201001911.656-1-thinhtr@linux.vnet.ibm.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      16b55b1f
  4. Dec 01, 2023
  5. Nov 30, 2023
  6. Nov 29, 2023
    • Linus Torvalds's avatar
      Merge tag 'pinctrl-v6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl · 3b47bc03
      Linus Torvalds authored
      Pull pin control fixes from Linus Walleij:
      
       - Fix a really interesting potential core bug in the list iterator
         requireing the use of READ_ONCE() discovered when testing kernel
         compiles with clang.
      
       - Check devm_kcalloc() return value and an array bounds in the STM32
         driver.
      
       - Fix an exotic string truncation issue in the s32cc driver, found by
         the kernel test robot (impressive!)
      
       - Fix an undocumented struct member in the cy8c95x0 driver.
      
       - Fix a symbol overlap with MIPS in the Lochnagar driver, MIPS defines
         a global symbol "RST" which is a bit too generic and collide with
         stuff. OK this one should be renamed too, we will fix that as well.
      
       - Fix erroneous branch taking in the Realtek driver.
      
       - Fix the mail address in MAINTAINERS for the s32g2 driver.
      
      * tag 'pinctrl-v6.7-2' of git://git.kernel.org/pub/scm/linux/kernel/git/linusw/linux-pinctrl:
        dt-bindings: pinctrl: s32g2: change a maintainer email address
        pinctrl: realtek: Fix logical error when finding descriptor
        pinctrl: lochnagar: Don't build on MIPS
        pinctrl: avoid reload of p state in list iteration
        pinctrl: cy8c95x0: Fix doc warning
        pinctrl: s32cc: Avoid possible string truncation
        pinctrl: stm32: fix array read out of bound
        pinctrl: stm32: Add check for devm_kcalloc
      3b47bc03
    • Yoshihiro Shimoda's avatar
      ravb: Fix races between ravb_tx_timeout_work() and net related ops · 9870257a
      Yoshihiro Shimoda authored
      Fix races between ravb_tx_timeout_work() and functions of net_device_ops
      and ethtool_ops by using rtnl_trylock() and rtnl_unlock(). Note that
      since ravb_close() is under the rtnl lock and calls cancel_work_sync(),
      ravb_tx_timeout_work() should calls rtnl_trylock(). Otherwise, a deadlock
      may happen in ravb_tx_timeout_work() like below:
      
      CPU0			CPU1
      			ravb_tx_timeout()
      			schedule_work()
      ...
      __dev_close_many()
      // Under rtnl lock
      ravb_close()
      cancel_work_sync()
      // Waiting
      			ravb_tx_timeout_work()
      			rtnl_lock()
      			// This is possible to cause a deadlock
      
      If rtnl_trylock() fails, rescheduling the work with sleep for 1 msec.
      
      Fixes: c156633f
      
       ("Renesas Ethernet AVB driver proper")
      Signed-off-by: default avatarYoshihiro Shimoda <yoshihiro.shimoda.uh@renesas.com>
      Reviewed-by: default avatarSergey Shtylyov <s.shtylyov@omp.ru>
      Link: https://lore.kernel.org/r/20231127122420.3706751-1-yoshihiro.shimoda.uh@renesas.com
      
      
      Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
      9870257a
    • Linus Torvalds's avatar
      Merge tag 'for-6.7-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux · 18d46e76
      Linus Torvalds authored
      Pull btrfs fixes from David Sterba:
       "A few fixes and message updates:
      
         - for simple quotas, handle the case when a snapshot is created and
           the target qgroup already exists
      
         - fix a warning when file descriptor given to send ioctl is not
           writable
      
         - fix off-by-one condition when checking chunk maps
      
         - free pages when page array allocation fails during compression
           read, other cases were handled
      
         - fix memory leak on error handling path in ref-verify debugging
           feature
      
         - copy missing struct member 'version' in 64/32bit compat send ioctl
      
         - tree-checker verifies inline backref ordering
      
         - print messages to syslog on first mount and last unmount
      
         - update error messages when reading chunk maps"
      
      * tag 'for-6.7-rc3-tag' of git://git.kernel.org/pub/scm/linux/kernel/git/kdave/linux:
        btrfs: send: ensure send_fd is writable
        btrfs: free the allocated memory if btrfs_alloc_page_array() fails
        btrfs: fix 64bit compat send ioctl arguments not initializing version member
        btrfs: make error messages more clear when getting a chunk map
        btrfs: fix off-by-one when checking chunk map includes logical address
        btrfs: ref-verify: fix memory leaks in btrfs_ref_tree_mod()
        btrfs: add dmesg output for first mount and last unmount of a filesystem
        btrfs: do not abort transaction if there is already an existing qgroup
        btrfs: tree-checker: add type and sequence check for inline backrefs
      18d46e76
  7. Nov 28, 2023