[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <3fe0a4f7-ba9a-4eb2-9df9-0273584ebbc3@rowland.harvard.edu>
Date: Tue, 21 Oct 2025 12:26:19 -0400
From: Alan Stern <stern@...land.harvard.edu>
To: Yi Cong <yicongsrfy@....com>
Cc: andrew+netdev@...n.ch, davem@...emloft.net, edumazet@...gle.com,
kuba@...nel.org, linux-usb@...r.kernel.org, michal.pecio@...il.com,
netdev@...r.kernel.org, oliver@...kum.org, pabeni@...hat.com
Subject: Re: [PATCH net v5 2/3] net: usb: ax88179_178a: add USB device driver
for config selection
On Tue, Oct 21, 2025 at 02:26:29PM +0800, Yi Cong wrote:
> On Mon, 20 Oct 2025 22:59:36 -0400, Alan Stern <stern@...land.harvard.edu> wrote:
> >
> > On Tue, Oct 21, 2025 at 10:29:25AM +0800, Yi Cong wrote:
> > > On Mon, 20 Oct 2025 11:56:50 -0400, Alan Stern <stern@...land.harvard.edu> wrote:
> > > >
> > > > Instead of all this preferred() stuff, why not have the ax88179 driver's
> > > > probe routine check for a different configuration with a vendor-specific
> > > > interface? If that other config is present and the chip is the right
> > > > type then you can call usb_driver_set_configuration() -- this is exactly
> > > > what it's meant for.
> > >
> > > I tried calling usb_driver_set_configuration inside driver's probe()
> > > to select the configuration, but my USB network card has three
> > > configurations (bNumConfigurations=3), which causes usb_driver_set_configuration
> > > to be called twice within probe():
> > > ```
> > > static int ax88179_probe()
> > > {
> > > if (bConfigurationValue != I_WANT) {
> > > usb_driver_set_configuration(udev, I_WANT)
> > > return -ENODEV;
> > > }
> > > //else really probe
> > > }
> > > ```
> >
> > Why is it called twice? The first time probe() runs, it calls
> > usb_driver_set_configuration() with the config that you want. Then the
> > second time probe() runs, the config you want has been installed, so
> > there's no reason to call usb_driver_set_configuration() again.
> >
> > Unless something is going wrong, that's how it should work. And the
> > total number of configurations should not matter.
>
> It might not be caused by the number of configurations, but rather by
> the fact that usb_driver_set_configuration handles configuration changes
> through a work queue.
I don't see why using a work queue should make any difference. If you
really want to find out what's going on, you could add a dump_stack()
call to the probe routine. And maybe a printk at the point where it
calls usb_driver_set_configuration().
Alan Stern
> I suspect this is the reason (although I haven't verified it further
> —I just observed this behavior and switched to a different implementation
> by using choose_configuration):
> ```
> int usb_driver_set_configuration(struct usb_device *udev, int config)
> {
> ...
> INIT_WORK(&req->work, driver_set_config_work);
> schedule_work(&req->work);
> return 0;
> }
> ```
Powered by blists - more mailing lists