1. 13 May, 2022 27 commits
    • Vasyl Vavrychuk's avatar
      Bluetooth: core: Fix missing power_on work cancel on HCI close · ff7f2926
      Vasyl Vavrychuk authored
      Move power_on work cancel to hci_dev_close_sync to ensure that power_on
      work is canceled after HCI interface down, power off, rfkill, etc.
      
      For example, if
      
          hciconfig hci0 down
      
      is done early enough during boot, it may run before power_on work.
      Then, power_on work will actually bring up interface despite above
      hciconfig command.
      Signed-off-by: default avatarVasyl Vavrychuk <vasyl.vavrychuk@opensynergy.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      ff7f2926
    • Zijun Hu's avatar
      Bluetooth: btusb: add support for Qualcomm WCN785x · 46225947
      Zijun Hu authored
      Qualcomm WCN785x has PID/VID 0cf3/e700 as shown by
      /sys/kernel/debug/usb/devices:
      
      T:  Bus=02 Lev=02 Prnt=02 Port=01 Cnt=02 Dev#=  8 Spd=12   MxCh= 0
      D:  Ver= 1.10 Cls=e0(wlcon) Sub=01 Prot=01 MxPS=64 #Cfgs=  1
      P:  Vendor=0cf3 ProdID=e700 Rev= 0.01
      C:* #Ifs= 2 Cfg#= 1 Atr=e0 MxPwr=100mA
      I:* If#= 0 Alt= 0 #EPs= 3 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=81(I) Atr=03(Int.) MxPS=  16 Ivl=1ms
      E:  Ad=82(I) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      E:  Ad=02(O) Atr=02(Bulk) MxPS=  64 Ivl=0ms
      I:* If#= 1 Alt= 0 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   0 Ivl=1ms
      I:  If#= 1 Alt= 1 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=   9 Ivl=1ms
      I:  If#= 1 Alt= 2 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  17 Ivl=1ms
      I:  If#= 1 Alt= 3 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  25 Ivl=1ms
      I:  If#= 1 Alt= 4 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  33 Ivl=1ms
      I:  If#= 1 Alt= 5 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  49 Ivl=1ms
      I:  If#= 1 Alt= 6 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  63 Ivl=1ms
      I:  If#= 1 Alt= 7 #EPs= 2 Cls=e0(wlcon) Sub=01 Prot=01 Driver=btusb
      E:  Ad=83(I) Atr=01(Isoc) MxPS=  65 Ivl=1ms
      E:  Ad=03(O) Atr=01(Isoc) MxPS=  65 Ivl=1ms
      Signed-off-by: default avatarZijun Hu <quic_zijuhu@quicinc.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      46225947
    • Niels Dossche's avatar
      Bluetooth: protect le accept and resolv lists with hdev->lock · 5e2b6064
      Niels Dossche authored
      Concurrent operations from events on le_{accept,resolv}_list are
      currently unprotected by hdev->lock.
      Most existing code do already protect the lists with that lock.
      This can be observed in hci_debugfs and hci_sync.
      Add the protection for these events too.
      
      Fixes: b950aa88 ("Bluetooth: Add definitions and track LE resolve list modification")
      Fixes: 0f36b589 ("Bluetooth: Track LE white list modification via HCI commands")
      Signed-off-by: default avatarNiels Dossche <dossche.niels@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      5e2b6064
    • Niels Dossche's avatar
      Bluetooth: use hdev lock for accept_list and reject_list in conn req · fb048cae
      Niels Dossche authored
      All accesses (both reads and modifications) to
      hdev->{accept,reject}_list are protected by hdev lock,
      except the ones in hci_conn_request_evt. This can cause a race
      condition in the form of a list corruption.
      The solution is to protect these lists in hci_conn_request_evt as well.
      
      I was unable to find the exact commit that introduced the issue for the
      reject list, I was only able to find it for the accept list.
      
      Fixes: a55bd29d ("Bluetooth: Add white list lookup for incoming connection requests")
      Signed-off-by: default avatarNiels Dossche <dossche.niels@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      fb048cae
    • Niels Dossche's avatar
      Bluetooth: use hdev lock in activate_scan for hci_is_adv_monitoring · 50a3633a
      Niels Dossche authored
      hci_is_adv_monitoring's function documentation states that it must be
      called under the hdev lock. Paths that leads to an unlocked call are:
      discov_update => start_discovery => interleaved_discov => active_scan
      and: discov_update => start_discovery => active_scan
      
      The solution is to take the lock in active_scan during the duration of
      the call to hci_is_adv_monitoring.
      
      Fixes: c32d6246 ("Bluetooth: disable filter dup when scan for adv monitor")
      Signed-off-by: default avatarNiels Dossche <dossche.niels@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      50a3633a
    • Max Chou's avatar
      Bluetooth: btrtl: Add support for RTL8852C · 8b1d66b5
      Max Chou authored
      Add the support for RTL8852C BT controller on USB interface.
      The necessary firmware file will be submitted to linux-firmware.
      Signed-off-by: default avatarMax Chou <max.chou@realtek.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      8b1d66b5
    • Luiz Augusto von Dentz's avatar
      Bluetooth: btusb: Set HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN for QCA · d44e1dbd
      Luiz Augusto von Dentz authored
      This sets HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN for QCA controllers
      since SCO appear to not work when using HCI_OP_ENHANCED_SETUP_SYNC_CONN.
      
      Link: https://bugzilla.kernel.org/show_bug.cgi?id=215576Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      d44e1dbd
    • Luiz Augusto von Dentz's avatar
      Bluetooth: Print broken quirks · 6b5c1cda
      Luiz Augusto von Dentz authored
      This prints warnings for controllers setting broken quirks to increase
      their visibility and warn about broken controllers firmware that
      probably needs updates to behave properly.
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      6b5c1cda
    • Luiz Augusto von Dentz's avatar
      Bluetooth: HCI: Add HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN quirk · 05abad85
      Luiz Augusto von Dentz authored
      This adds HCI_QUIRK_BROKEN_ENHANCED_SETUP_SYNC_CONN quirk which can be
      used to mark HCI_Enhanced_Setup_Synchronous_Connection as broken even
      if its support command bit are set since some controller report it as
      supported but the command don't work properly with some configurations
      (e.g. BT_VOICE_TRANSPARENT/mSBC).
      Signed-off-by: default avatarLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      05abad85
    • Steven Rostedt's avatar
      Bluetooth: hci_qca: Use del_timer_sync() before freeing · 72ef9844
      Steven Rostedt authored
      While looking at a crash report on a timer list being corrupted, which
      usually happens when a timer is freed while still active. This is
      commonly triggered by code calling del_timer() instead of
      del_timer_sync() just before freeing.
      
      One possible culprit is the hci_qca driver, which does exactly that.
      
      Eric mentioned that wake_retrans_timer could be rearmed via the work
      queue, so also move the destruction of the work queue before
      del_timer_sync().
      
      Cc: Eric Dumazet <eric.dumazet@gmail.com>
      Cc: stable@vger.kernel.org
      Fixes: 0ff252c1 ("Bluetooth: hciuart: Add support QCA chipset for UART")
      Signed-off-by: default avatarSteven Rostedt (Google) <rostedt@goodmis.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      72ef9844
    • Rikard Falkeborn's avatar
      Bluetooth: btintel: Constify static struct regmap_bus · bf7380e2
      Rikard Falkeborn authored
      The only usage of regmap_ibt is to (after the regmap_init() macro is
      expanded), pass its address to __regmap_init(), which takes a pointer to
      const struct regmap_bus as input. Make it const to allow the compiler to
      put it in read-only memory.
      Signed-off-by: default avatarRikard Falkeborn <rikard.falkeborn@gmail.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      bf7380e2
    • Brian Gix's avatar
      Bluetooth: Keep MGMT pending queue ordered FIFO · 31396dd5
      Brian Gix authored
      Small change to add new commands to tail of the list, and find/remove them
      from the head of the list.
      Signed-off-by: default avatarBrian Gix <brian.gix@intel.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      31396dd5
    • Ying Hsu's avatar
      Bluetooth: fix dangling sco_conn and use-after-free in sco_sock_timeout · 7aa1e7d1
      Ying Hsu authored
      Connecting the same socket twice consecutively in sco_sock_connect()
      could lead to a race condition where two sco_conn objects are created
      but only one is associated with the socket. If the socket is closed
      before the SCO connection is established, the timer associated with the
      dangling sco_conn object won't be canceled. As the sock object is being
      freed, the use-after-free problem happens when the timer callback
      function sco_sock_timeout() accesses the socket. Here's the call trace:
      
      dump_stack+0x107/0x163
      ? refcount_inc+0x1c/
      print_address_description.constprop.0+0x1c/0x47e
      ? refcount_inc+0x1c/0x7b
      kasan_report+0x13a/0x173
      ? refcount_inc+0x1c/0x7b
      check_memory_region+0x132/0x139
      refcount_inc+0x1c/0x7b
      sco_sock_timeout+0xb2/0x1ba
      process_one_work+0x739/0xbd1
      ? cancel_delayed_work+0x13f/0x13f
      ? __raw_spin_lock_init+0xf0/0xf0
      ? to_kthread+0x59/0x85
      worker_thread+0x593/0x70e
      kthread+0x346/0x35a
      ? drain_workqueue+0x31a/0x31a
      ? kthread_bind+0x4b/0x4b
      ret_from_fork+0x1f/0x30
      
      Link: https://syzkaller.appspot.com/bug?extid=2bef95d3ab4daa10155b
      Reported-by: syzbot+2bef95d3ab4daa10155b@syzkaller.appspotmail.com
      Fixes: e1dee2c1 ("Bluetooth: fix repeated calls to sco_sock_kill")
      Signed-off-by: default avatarYing Hsu <yinghsu@chromium.org>
      Reviewed-by: default avatarJoseph Hwang <josephsih@chromium.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      7aa1e7d1
    • Sean Wang's avatar
      Bluetooth: mt7921s: Fix the incorrect pointer check · 789f6b8a
      Sean Wang authored
      Fix the incorrect pointer check on ven_data.
      
      Fixes: f41b91fa ("Bluetooth: mt7921s: Add .btmtk_get_codec_config_data")
      Co-developed-by: default avatarYake Yang <yake.yang@mediatek.com>
      Signed-off-by: default avatarYake Yang <yake.yang@mediatek.com>
      Signed-off-by: default avatarSean Wang <sean.wang@mediatek.com>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      789f6b8a
    • Linus Walleij's avatar
      Bluetooth: btbcm: Support per-board firmware variants · 63fac334
      Linus Walleij authored
      There are provedly different firmware variants for the different
      phones using some of these chips. These were extracted from a few
      Samsung phones:
      
      37446 BCM4334B0.samsung,codina-tmo.hcd
      37366 BCM4334B0.samsung,golden.hcd
      37403 BCM4334B0.samsung,kyle.hcd
      37366 BCM4334B0.samsung,skomer.hcd
      
      This patch supports the above naming schedule with inserting
      [.board_name] between the firmware name and ".hcd". This scheme
      is the same as used by the companion BRCM wireless chips
      as can be seen in
      drivers/net/wireless/broadcom/brcm80211/brcmfmac/firmware.c
      or just by looking at the firmwares in linux-firmware/brcm.
      
      Currently we only support board variants using the device
      tree compatible string as board type, but other schemes are
      possible.
      
      This makes it possible to successfully load a few unique
      firmware variants for some Samsung phones.
      
      Cc: phone-devel@vger.kernel.org
      Cc: Markuss Broks <markuss.broks@gmail.com>
      Cc: Stephan Gerhold <stephan@gerhold.net>
      Signed-off-by: default avatarLinus Walleij <linus.walleij@linaro.org>
      Signed-off-by: default avatarMarcel Holtmann <marcel@holtmann.org>
      63fac334
    • Amit Cohen's avatar
      selftests: fib_nexthops: Make the test more robust · 49bb39bd
      Amit Cohen authored
      Rarely some of the test cases fail. Make the test more robust by increasing
      the timeout of ping commands to 5 seconds.
      Signed-off-by: default avatarAmit Cohen <amcohen@nvidia.com>
      Reviewed-by: default avatarDavid Ahern <dsahern@kernel.org>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      49bb39bd
    • David S. Miller's avatar
      Merge branch 'lan95xx-no-polling' · b7da9c6b
      David S. Miller authored
      Lukas Wunner says:
      
      ====================
      Polling be gone on LAN95xx
      
      Do away with link status polling on LAN95xx USB Ethernet
      and rely on interrupts instead, thereby reducing bus traffic,
      CPU overhead and improving interface bringup latency.
      
      Link to v2:
      https://lore.kernel.org/netdev/cover.1651574194.git.lukas@wunner.de/
      
      Only change since v2:
      
      * Patch [5/7]:
        * Drop call to __irq_enter_raw() which worked around a warning in
          generic_handle_domain_irq().  That warning is gone since
          792ea6a0 (queued on tip.git/irq/urgent).
          (Marc Zyngier, Thomas Gleixner)
      ====================
      b7da9c6b
    • Lukas Wunner's avatar
      net: phy: smsc: Cope with hot-removal in interrupt handler · 1e7b81ed
      Lukas Wunner authored
      If reading the Interrupt Source Flag register fails with -ENODEV, then
      the PHY has been hot-removed and the correct response is to bail out
      instead of throwing a WARN splat and attempting to suspend the PHY.
      The PHY should be stopped in due course anyway as the kernel
      asynchronously tears down the device.
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1e7b81ed
    • Lukas Wunner's avatar
      net: phy: smsc: Cache interrupt mask · 7e8b617e
      Lukas Wunner authored
      Cache the interrupt mask to avoid re-reading it from the PHY upon every
      interrupt.
      
      This will simplify a subsequent commit which detects hot-removal in the
      interrupt handler and bails out.
      
      Analyzing and debugging PHY transactions also becomes simpler if such
      redundant reads are avoided.
      
      Last not least, interrupt overhead and latency is slightly improved.
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7e8b617e
    • Lukas Wunner's avatar
      usbnet: smsc95xx: Forward PHY interrupts to PHY driver to avoid polling · 1ce8b372
      Lukas Wunner authored
      Link status of SMSC LAN95xx chips is polled once per second, even though
      they're capable of signaling PHY interrupts through the MAC layer.
      
      Forward those interrupts to the PHY driver to avoid polling.  Benefits
      are reduced bus traffic, reduced CPU overhead and quicker interface
      bringup.
      
      Polling was introduced in 2016 by commit d69d1694 ("usbnet:
      smsc95xx: fix link detection for disabled autonegotiation").
      Back then, the LAN95xx driver neglected to enable the ENERGYON interrupt,
      hence couldn't detect link-up events when auto-negotiation was disabled.
      The proper solution would have been to enable the ENERGYON interrupt
      instead of polling.
      
      Since then, PHY handling was moved from the LAN95xx driver to the SMSC
      PHY driver with commit 05b35e7e ("smsc95xx: add phylib support").
      That PHY driver is capable of link detection with auto-negotiation
      disabled because it enables the ENERGYON interrupt.
      
      Note that signaling interrupts through the MAC layer not only works with
      the integrated PHY, but also with an external PHY, provided its
      interrupt pin is attached to LAN95xx's nPHY_INT pin.
      
      In the unlikely event that the interrupt pin of an external PHY is
      attached to a GPIO of the SoC (or not connected at all), the driver can
      be amended to retrieve the irq from the PHY's of_node.
      
      To forward PHY interrupts to phylib, it is not sufficient to call
      phy_mac_interrupt().  Instead, the PHY's interrupt handler needs to run
      so that PHY interrupts are cleared.  That's because according to page
      119 of the LAN950x datasheet, "The source of this interrupt is a level.
      The interrupt persists until it is cleared in the PHY."
      
      https://www.microchip.com/content/dam/mchp/documents/UNG/ProductDocuments/DataSheets/LAN950x-Data-Sheet-DS00001875D.pdf
      
      Therefore, create an IRQ domain with a single IRQ for the PHY.  In the
      future, the IRQ domain may be extended to support the 11 GPIOs on the
      LAN95xx.
      
      Normally the PHY interrupt should be masked until the PHY driver has
      cleared it.  However masking requires a (sleeping) USB transaction and
      interrupts are received in (non-sleepable) softirq context.  I decided
      not to mask the interrupt at all (by using the dummy_irq_chip's noop
      ->irq_mask() callback):  The USB interrupt endpoint is polled in 1 msec
      intervals and normally that's sufficient to wake the PHY driver's IRQ
      thread and have it clear the interrupt.  If it does take longer, worst
      thing that can happen is the IRQ thread is woken again.  No big deal.
      
      Because PHY interrupts are now perpetually enabled, there's no need to
      selectively enable them on suspend.  So remove all invocations of
      smsc95xx_enable_phy_wakeup_interrupts().
      
      In smsc95xx_resume(), move the call of phy_init_hw() before
      usbnet_resume() (which restarts the status URB) to ensure that the PHY
      is fully initialized when an interrupt is handled.
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Reviewed-by: Andrew Lunn <andrew@lunn.ch> # from a PHY perspective
      Cc: Andre Edich <andre.edich@microchip.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      1ce8b372
    • Lukas Wunner's avatar
      usbnet: smsc95xx: Avoid link settings race on interrupt reception · 8960f878
      Lukas Wunner authored
      When a PHY interrupt is signaled, the SMSC LAN95xx driver updates the
      MAC full duplex mode and PHY flow control registers based on cached data
      in struct phy_device:
      
        smsc95xx_status()                 # raises EVENT_LINK_RESET
          usbnet_deferred_kevent()
            smsc95xx_link_reset()         # uses cached data in phydev
      
      Simultaneously, phylib polls link status once per second and updates
      that cached data:
      
        phy_state_machine()
          phy_check_link_status()
            phy_read_status()
              lan87xx_read_status()
                genphy_read_status()      # updates cached data in phydev
      
      If smsc95xx_link_reset() wins the race against genphy_read_status(),
      the registers may be updated based on stale data.
      
      E.g. if the link was previously down, phydev->duplex is set to
      DUPLEX_UNKNOWN and that's what smsc95xx_link_reset() will use, even
      though genphy_read_status() may update it to DUPLEX_FULL afterwards.
      
      PHY interrupts are currently only enabled on suspend to trigger wakeup,
      so the impact of the race is limited, but we're about to enable them
      perpetually.
      
      Avoid the race by delaying execution of smsc95xx_link_reset() until
      phy_state_machine() has done its job and calls back via
      smsc95xx_handle_link_change().
      
      Signaling EVENT_LINK_RESET on wakeup is not necessary because phylib
      picks up link status changes through polling.  So drop the declaration
      of a ->link_reset() callback.
      
      Note that the semicolon on a line by itself added in smsc95xx_status()
      is a placeholder for a function call which will be added in a subsequent
      commit.  That function call will actually handle the INT_ENP_PHY_INT_
      interrupt.
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      8960f878
    • Lukas Wunner's avatar
      usbnet: smsc95xx: Don't reset PHY behind PHY driver's back · 14021da6
      Lukas Wunner authored
      smsc95xx_reset() resets the PHY behind the PHY driver's back, which
      seems like a bad idea generally.  Remove that portion of the function.
      
      We're about to use PHY interrupts instead of polling to detect link
      changes on SMSC LAN95xx chips.  Because smsc95xx_reset() is called from
      usbnet_open(), PHY interrupt settings are lost whenever the net_device
      is brought up.
      
      There are two other callers of smsc95xx_reset(), namely smsc95xx_bind()
      and smsc95xx_reset_resume(), and both may indeed benefit from a PHY
      reset.  However they already perform one through their calls to
      phy_connect_direct() and phy_init_hw().
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Cc: Martyn Welch <martyn.welch@collabora.com>
      Cc: Gabriel Hojda <ghojda@yo2urs.ro>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      14021da6
    • Lukas Wunner's avatar
      usbnet: smsc95xx: Don't clear read-only PHY interrupt · 3108871f
      Lukas Wunner authored
      Upon receiving data from the Interrupt Endpoint, the SMSC LAN95xx driver
      attempts to clear the signaled interrupts by writing "all ones" to the
      Interrupt Status Register.
      
      However the driver only ever enables a single type of interrupt, namely
      the PHY Interrupt.  And according to page 119 of the LAN950x datasheet,
      its bit in the Interrupt Status Register is read-only.  There's no other
      way to clear it than in a separate PHY register:
      
      https://www.microchip.com/content/dam/mchp/documents/UNG/ProductDocuments/DataSheets/LAN950x-Data-Sheet-DS00001875D.pdf
      
      Consequently, writing "all ones" to the Interrupt Status Register is
      pointless and can be dropped.
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Reviewed-by: default avatarAndrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      3108871f
    • Lukas Wunner's avatar
      usbnet: Run unregister_netdev() before unbind() again · d1408f6b
      Lukas Wunner authored
      Commit 2c9d6c2b ("usbnet: run unbind() before unregister_netdev()")
      sought to fix a use-after-free on disconnect of USB Ethernet adapters.
      
      It turns out that a different fix is necessary to address the issue:
      https://lore.kernel.org/netdev/18b3541e5372bc9b9fc733d422f4e698c089077c.1650177997.git.lukas@wunner.de/
      
      So the commit was not necessary.
      
      The commit made binding and unbinding of USB Ethernet asymmetrical:
      Before, usbnet_probe() first invoked the ->bind() callback and then
      register_netdev().  usbnet_disconnect() mirrored that by first invoking
      unregister_netdev() and then ->unbind().
      
      Since the commit, the order in usbnet_disconnect() is reversed and no
      longer mirrors usbnet_probe().
      
      One consequence is that a PHY disconnected (and stopped) in ->unbind()
      is afterwards stopped once more by unregister_netdev() as it closes the
      netdev before unregistering.  That necessitates a contortion in ->stop()
      because the PHY may only be stopped if it hasn't already been
      disconnected.
      
      Reverting the commit allows making the call to phy_stop() unconditional
      in ->stop().
      
      Tested-by: Oleksij Rempel <o.rempel@pengutronix.de> # LAN9514/9512/9500
      Tested-by: Ferry Toth <fntoth@gmail.com> # LAN9514
      Signed-off-by: default avatarLukas Wunner <lukas@wunner.de>
      Acked-by: default avatarOliver Neukum <oneukum@suse.com>
      Cc: Martyn Welch <martyn.welch@collabora.com>
      Cc: Andrew Lunn <andrew@lunn.ch>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      d1408f6b
    • Yang Li's avatar
      net: ethernet: fix platform_no_drv_owner.cocci warning · 7b8b8222
      Yang Li authored
      Remove .owner field if calls are used which set it automatically.
      ./drivers/net/ethernet/sunplus/spl2sw_driver.c:569:3-8: No need to set
      .owner here. The core will do it.
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarYang Li <yang.lee@linux.alibaba.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      7b8b8222
    • Jie Wang's avatar
      net: page_pool: add page allocation stats for two fast page allocate path · 0f6deac3
      Jie Wang authored
      Currently If use page pool allocation stats to analysis a RX performance
      degradation problem. These stats only count for pages allocate from
      page_pool_alloc_pages. But nic drivers such as hns3 use
      page_pool_dev_alloc_frag to allocate pages, so page stats in this API
      should also be counted.
      Signed-off-by: default avatarJie Wang <wangjie125@huawei.com>
      Signed-off-by: default avatarGuangbin Huang <huangguangbin2@huawei.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      0f6deac3
    • Jiapeng Chong's avatar
      net: ethernet: Use swap() instead of open coding it · a19cef45
      Jiapeng Chong authored
      Clean the following coccicheck warning:
      
      ./drivers/net/ethernet/sunplus/spl2sw_driver.c:217:27-28: WARNING
      opportunity for swap().
      
      ./drivers/net/ethernet/sunplus/spl2sw_driver.c:222:27-28: WARNING
      opportunity for swap().
      Reported-by: default avatarAbaci Robot <abaci@linux.alibaba.com>
      Signed-off-by: default avatarJiapeng Chong <jiapeng.chong@linux.alibaba.com>
      Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
      a19cef45
  2. 12 May, 2022 13 commits