Re: [PATCH RFC 2/2] usb: dwc3: qcom: Vote ICC DDR bandwidth based on connected device speed

From: Peter Chen

Date: Tue Dec 01 2026 - 21:44:04 EST


On 26-12-01 23:51:17, Krishna Kurapati wrote:
>
>
> On 12/1/2026 11:28 PM, Val Packett wrote:
> > Hi,
> >
> > On 11/30/26 2:41 PM, Krishna Kurapati wrote:
> > > In host mode the actual transfer speed is not known at probe time. The
> > > DDR interconnect bandwidth has historically been voted at the maximum
> > > (SuperSpeed) value unconditionally, wasting power when only a
> > > Full/High-Speed device is attached.
> > >
> > > Add a USB notifier that fires on USB_DEVICE_ADD / USB_DEVICE_REMOVE for
> > > devices directly attached to the DWC3 root hub.  On addition, inspect
> > > all USB 3.x root-hub ports via xhci_portsc_readl(). If at least one
> > > SuperSpeed connection is active, vote SS bandwidth, otherwise vote HS
> > > bandwidth. On removal, drop the vote back to the idle/unknown level.
> > >
> > > [..]
> > > @@ -749,8 +828,12 @@ static int dwc3_qcom_probe(struct
> > > platform_device *pdev)
> > >               qcom->current_role = USB_ROLE_DEVICE;
> > >       }
> > > -    qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
> > > +    if (qcom->current_role == USB_ROLE_HOST) {
> > > +        qcom->host_nb.notifier_call = dwc3_qcom_host_notifier;
> > > +        usb_register_notify(&qcom->host_nb);
> > > +    }
> > > +    qcom->dwc.glue_ops = &dwc3_qcom_glue_ops;
> > >       qcom->dwc.dev = dev;
> > >       probe_data.dwc = &qcom->dwc;
> > >       probe_data.res = &res;
> > > [..]
> >
> > Seems like it might be registering with a NULL function ptr or something?
> >
> > CONFIG_DEBUG_NOTIFIERS's `!func_ptr_is_kernel_text(nb->notifier_call)`
> > check fires when busses are probed upon booting:
> >
> >
> > [   17.606811] xhci-hcd xhci-hcd.1.auto: xHCI Host Controller
> > [   17.606825] ------------[ cut here ]------------
> > [   17.606826] Invalid notifier called!
> > [   17.606833] WARNING: kernel/notifier.c:80 at
> > notifier_call_chain+0x80/0x1b0, CPU#0: kworker/0:0/10
> > [   17.607029] CPU: 0 UID: 0 PID: 10 Comm: kworker/0:0 Tainted: G     W
> >          7.4.0-rc5-next-20261130-uwu+ #250 PREEMPT(full)
> > [   17.607034] Tainted: [W]=WARN
> > [   17.607035] Hardware name: Dell Inc. Latitude 7455/0FK7MX, BIOS
> > 2.13.0 09/19/2025
> > [   17.607037] Workqueue: events_freezable __dwc3_set_mode
> > [   17.607045] pstate: 61400009 (nZCv daif +PAN -UAO -TCO +DIT -SSBS
> > BTYPE=--)
> > [   17.607091] Call trace:
> > [   17.607093]  notifier_call_chain+0x80/0x1b0 (P)
> > [   17.607097]  blocking_notifier_call_chain+0x4c/0x80
> > [   17.607100]  usb_notify_add_bus+0x28/0x40
> > [   17.607105]  usb_register_bus+0x88/0xb8
> > [   17.607111]  usb_add_hcd+0x144/0x4b0
> > [   17.607115]  xhci_plat_probe+0x4f4/0x6f0
> >
> I did hit a NULL ptr deref when I was testing this but i fixed it before
> sending. I did test this on standalone (dr_mode==host) and (dr_mode==otg).
> Will try to repro this particular crash and fix it before sending next
> version. Thanks for reporting this.
>

It probably dues to Bot's comment:

- [High] usb: dwc3: qcom: use-after-free of host_nb on dwc3_qcom_probe()
error paths

If the 1st time Qcom USB probe fails, it leaves a stale entry for block notifier
chain, and when the 2nd time Qcom USB probe executes, it will visit that
stale entry.

--

Thanks,
Peter Chen