[PATCH 1/2] usb: gadget: f_ncm: do not notify from ncm_set_alt()

From: Massimo Toscanelli via B4 Relay

Date: Fri Oct 23 2026 - 08:16:20 EST


From: Massimo Toscanelli <massimo.toscanelli@xxxxxxxxxxxxxxxxxxxx>

ncm_set_alt() calls ncm_notify() for both altsettings of the data
interface. So a notification is already queued at SET_CONFIGURATION,
when altsetting 0 is selected, and it waits until the host reads the
interrupt endpoint.

The USB 2.0 LPM ECN (section 2.2.2) lets a device answer NYET to an LPM
request when it has data pending for the host, and DWC3 does so. So
when the host loads no class driver, like the USB-IF test tool, the
device never enters L1 and the LPM L1 test fails.

The CDC NCM spec (version 1.1, section 9.2) [1] asks for the
notifications only when the host selects altsetting 1. There the call
is not needed: gether_connect() already calls ncm_open() or
ncm_close(), and both notify. The extra call only restarts the
sequence while the first notification is in flight, so the host gets
two connection notifications before the speed one.

The old ether.c also notified only for altsetting 1, until commit
da741b8c56d6 ("usb ethernet gadget: split CDC Ethernet function")
moved the call out of that branch in f_ecm. f_ncm copied that
pattern.

Remove the call.

Fixes: 9f6ce4240a2b ("usb: gadget: f_ncm.c added")
Link: https://www.usb.org/sites/default/files/NCM11.pdf # [1]
Signed-off-by: Massimo Toscanelli <massimo.toscanelli@xxxxxxxxxxxxxxxxxxxx>
---
drivers/usb/gadget/function/f_ncm.c | 4 ----
1 file changed, 4 deletions(-)

diff --git a/drivers/usb/gadget/function/f_ncm.c b/drivers/usb/gadget/function/f_ncm.c
index 500c9c19c78..0c7ec74d390 100644
--- a/drivers/usb/gadget/function/f_ncm.c
+++ b/drivers/usb/gadget/function/f_ncm.c
@@ -921,10 +921,6 @@ static int ncm_set_alt(struct usb_function *f, unsigned intf, unsigned alt)
return PTR_ERR(net);
ncm->netdev = net;
}
-
- spin_lock(&ncm->lock);
- ncm_notify(ncm);
- spin_unlock(&ncm->lock);
} else
goto fail;


--
2.43.0