linux-stable/drivers/usb
Hardik Gajjar a04224da1f usb: gadget: f_ncm: Always set current gadget in ncm_bind()
Previously, gadget assignment to the net device occurred exclusively
during the initial binding attempt.

Nevertheless, the gadget pointer could change during bind/unbind
cycles due to various conditions, including the unloading/loading
of the UDC device driver or the detachment/reconnection of an
OTG-capable USB hub device.

This patch relocates the gether_set_gadget() function out from
ncm_opts->bound condition check, ensuring that the correct gadget
is assigned during each bind request.

The provided logs demonstrate the consistency of ncm_opts throughout
the power cycle, while the gadget may change.

* OTG hub connected during boot up and assignment of gadget and
  ncm_opts pointer

[    2.366301] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105
[    2.366304] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[    2.366306] usb 2-1.5: Product: H2H Bridge
[    2.366308] usb 2-1.5: Manufacturer: Aptiv
[    2.366309] usb 2-1.5: SerialNumber: 13FEB2021
[    2.427989] usb 2-1.5: New USB device found, VID=2996, PID=0105
[    2.428959] dabridge 2-1.5:1.0: dabridge 2-4 total endpoints=5, 0000000093a8d681
[    2.429710] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed
[    2.429714] dabridge 2-1.5:1.0: Hub 2-2 P(0151) V(06.87)
[    2.429956] dabridge 2-1.5:1.0: All downstream ports in host mode

[    2.430093] gadget 000000003c414d59 ------> gadget pointer

* NCM opts and associated gadget pointer during First ncm_bind

[   34.763929] NCM opts 00000000aa304ac9
[   34.763930] NCM gadget 000000003c414d59

* OTG capable hub disconnecte or assume driver unload.

[   97.203114] usb 2-1: USB disconnect, device number 2
[   97.203118] usb 2-1.1: USB disconnect, device number 3
[   97.209217] usb 2-1.5: USB disconnect, device number 4
[   97.230990] dabr_udc deleted

* Reconnect the OTG hub or load driver assaign new gadget pointer.

[  111.534035] usb 2-1.1: New USB device found, idVendor=2996, idProduct=0120, bcdDevice= 6.87
[  111.534038] usb 2-1.1: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  111.534040] usb 2-1.1: Product: Vendor
[  111.534041] usb 2-1.1: Manufacturer: Aptiv
[  111.534042] usb 2-1.1: SerialNumber: Superior
[  111.535175] usb 2-1.1: New USB device found, VID=2996, PID=0120
[  111.610995] usb 2-1.5: new high-speed USB device number 8 using xhci-hcd
[  111.630052] usb 2-1.5: New USB device found, idVendor=2996, idProduct=0105, bcdDevice=21.02
[  111.630055] usb 2-1.5: New USB device strings: Mfr=1, Product=2, SerialNumber=3
[  111.630057] usb 2-1.5: Product: H2H Bridge
[  111.630058] usb 2-1.5: Manufacturer: Aptiv
[  111.630059] usb 2-1.5: SerialNumber: 13FEB2021
[  111.687464] usb 2-1.5: New USB device found, VID=2996, PID=0105
[  111.690375] dabridge 2-1.5:1.0: dabridge 2-8 total endpoints=5, 000000000d87c961
[  111.691172] dabridge 2-1.5:1.0: P(0105) D(22.06.22) F(17.3.16) H(1.1) high-speed
[  111.691176] dabridge 2-1.5:1.0: Hub 2-6 P(0151) V(06.87)
[  111.691646] dabridge 2-1.5:1.0: All downstream ports in host mode

[  111.692298] gadget 00000000dc72f7a9 --------> new gadget ptr on connect

* NCM opts and associated gadget pointer during second ncm_bind

[  113.271786] NCM opts 00000000aa304ac9 -----> same opts ptr used during first bind
[  113.271788] NCM gadget 00000000dc72f7a9 ----> however new gaget ptr, that will not set
                                                 in net_device due to ncm_opts->bound = true

Signed-off-by: Hardik Gajjar <hgajjar@de.adit-jv.com>
Link: https://lore.kernel.org/r/20231020153324.82794-1-hgajjar@de.adit-jv.com
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2023-10-21 12:54:53 +02:00
..
atm
c67x00 USB: c67x00: Remove unused declaration c67x00_hcd_msg_received() 2023-10-02 16:42:33 +02:00
cdns3 usb: cdns3: Modify the return value of cdns_set_active () to void when CONFIG_PM_SLEEP is disabled 2023-10-02 14:25:39 +02:00
chipidea usb: chipidea: Fix unused ci_hdrc_usb2_of_match warning for !CONFIG_OF 2023-10-21 12:46:35 +02:00
class TTY/Serial driver changes for 6.6-rc1 2023-09-01 09:38:00 -07:00
common Merge 6.5-rc6 into usb-next 2023-08-14 22:22:31 +02:00
core usb: core: Remove duplicated check in usb_hub_create_port_device 2023-10-21 12:53:55 +02:00
dwc2 usb: Use device_get_match_data() 2023-10-10 08:55:23 +02:00
dwc3 usb: dwc3: add optional PHY interface clocks 2023-10-21 12:49:35 +02:00
early
fotg210 usb: fotg210: Convert to platform remove callback returning void 2023-05-28 12:36:25 +01:00
gadget usb: gadget: f_ncm: Always set current gadget in ncm_bind() 2023-10-21 12:54:53 +02:00
host usb: host: xhci: Avoid XHCI resume delay if SSUSB device is not present 2023-10-21 12:38:54 +02:00
image scsi: usb: uas: Declare two host templates and host template pointers const 2023-03-24 19:20:00 -04:00
isp1760 usb: isp1760: Convert to platform remove callback returning void 2023-05-28 12:38:01 +01:00
misc Merge 6.6-rc6 into usb-next 2023-10-16 17:36:12 +02:00
mon usbmon: Use list_for_each_entry() helper 2023-10-02 16:19:01 +02:00
mtu3 usb: mtu3: Convert to platform remove callback returning void 2023-10-21 12:49:08 +02:00
musb Merge 6.6-rc6 into usb-next 2023-10-16 17:36:12 +02:00
phy usb: phy: mxs: disconnect line when USB charger is attached 2023-07-25 18:24:17 +02:00
renesas_usbhs usb: Explicitly include correct DT includes 2023-07-25 18:20:02 +02:00
roles USB: roles: make role_class a static const structure 2023-06-20 16:20:40 +02:00
serial TTY/Serial driver changes for 6.6-rc1 2023-09-01 09:38:00 -07:00
storage usb-storage,uas: make internal quirks flags 64bit 2023-10-21 12:45:14 +02:00
typec usb: typec: tcpm: Add additional checks for contaminant 2023-10-21 12:52:53 +02:00
usbip usb/usbip: fix wrong data added to platform device 2023-10-16 19:58:49 +02:00
Kconfig usb: pci-quirks: handle HAS_IOPORT dependency for AMD quirk 2023-10-02 16:19:12 +02:00
Makefile usb: host: u132-hcd: Delete driver 2023-03-21 14:06:11 +01:00
usb-skeleton.c