Linux USB
 help / color / mirror / Atom feed
From: Oliver Neukum <oneukum@suse.com>
To: Michal Pecio <michal.pecio@gmail.com>, Oliver Neukum <oneukum@suse.com>
Cc: Alan Stern <stern@rowland.harvard.edu>,
	yicongsrfy@163.com, andrew+netdev@lunn.ch, davem@davemloft.net,
	edumazet@google.com, kuba@kernel.org, linux-usb@vger.kernel.org,
	netdev@vger.kernel.org, pabeni@redhat.com
Subject: Re: [PATCH net v5 2/3] net: usb: ax88179_178a: add USB device driver for config selection
Date: Tue, 21 Oct 2025 11:02:25 +0200	[thread overview]
Message-ID: <806d82e6-6db6-4ec8-a49c-665a97ea36f8@suse.com> (raw)
In-Reply-To: <20251020175921.37f35e5a.michal.pecio@gmail.com>

On 20.10.25 17:59, Michal Pecio wrote:
> On Mon, 20 Oct 2025 11:59:06 +0200, Oliver Neukum wrote:
>> On 18.10.25 17:21, Michal Pecio wrote:

>>> @@ -1255,6 +1257,8 @@ struct usb_driver {
>>>    
>>>    	void (*shutdown)(struct usb_interface *intf);
>>>    
>>> +	bool (*preferred)(struct usb_device *udev);
>>
>> I am sorry, but this is a bit clunky. If you really want to
>> introduce such a method, why not just return the preferred
>> configuration?
> 
> Because I wanted to introduce exactly such a method, rather than one
> which returns the configuration ;)

Well, then I have to state that your patch perfectly implements
your wish. >:->
Would you allow me a follow up question, though? Why have you
developed that wish?

> The point was to pull configuration selection *out* of those drivers.

While I appreciate the goal, it is not clear to me how adding
a method to the generic interface driver template achieves that goal.
In fact this approach seems counterproductive.

In particular a bool will not work for the generic case.
If you really want to make this generic, you'll have to face
the unfortunate possibility that a configuration have
multiple interfaces whose drivers disagree in that regard.
At a minimum you'd have to be able to return a "don't care"
value to compute a reasonable pick.
  > They already do it, and it makes them copy-paste the same trivial loop
> which iterates through configs until it finds the vendor interface.

If the concern is simply getting the code centralized (which
is not wrong), then Alan's original proposal of having a flag
(let's not call it a quirk) in usbcore for devices that need
the logic in the heuristic for picking a configuration to be
inverted would seem to be the simplest approach.

> The idea is to have a maximally simple check for a known-good vendor
> interface driver before making unfounded assumptions like:
> 
> /* From the remaining configs, choose the first one whose
>   * first interface is for a non-vendor-specific class.
>   * Reason: Linux is more likely to have a class driver
>   * than a vendor-specific driver. */
> 
> Unfortunately, that's only half the battle. The other half is forcing
> configuration reevaluation when such a driver is loaded. I hoped it

Exactly. Hence don't put the information that the assumption
must not be made into a driver but into usbcore. Problem avoided.

It looks like this is an issue we are not going to find a perfect
solution for. Hence our priority should be finding the simplest
change. IMHO that's a new quirk just inverting existing logic.
Sure, it is a bit ugly because it depends on the kernel configuration,
but that is what we have a preprocessor for.

	Regards
		Oliver



  reply	other threads:[~2025-10-21  9:02 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-10-11  7:53 [PATCH net v5 0/3] ax88179 driver optimization yicongsrfy
2025-10-11  7:53 ` [PATCH net v5 1/3] net: usb: support quirks in cdc_ncm yicongsrfy
2025-10-11  7:53 ` [PATCH net v5 2/3] net: usb: ax88179_178a: add USB device driver for config selection yicongsrfy
2025-10-13  9:07   ` Michal Pecio
2025-10-17  2:42     ` yicongsrfy
2025-10-17 13:10       ` Alan Stern
2025-10-17 17:15         ` Michal Pecio
2025-10-18  2:27           ` Alan Stern
2025-10-18 15:21             ` Michal Pecio
2025-10-18 15:36               ` Alan Stern
2025-10-18 15:56                 ` Michal Pecio
2025-10-20 15:56                   ` Alan Stern
2025-10-20 16:23                     ` Michal Pecio
2025-10-20 16:59                       ` Alan Stern
2025-10-21  9:13                         ` Oliver Neukum
2025-10-21 16:33                           ` Alan Stern
2025-10-22  7:58                             ` Oliver Neukum
2025-10-22 14:28                               ` Alan Stern
2025-10-21  2:29                     ` Yi Cong
2025-10-21  2:59                       ` Alan Stern
2025-10-21  6:26                         ` Yi Cong
2025-10-21 16:26                           ` Alan Stern
2025-10-20  9:59               ` Oliver Neukum
2025-10-20 10:48                 ` Greg KH
2025-10-20 15:59                 ` Michal Pecio
2025-10-21  9:02                   ` Oliver Neukum [this message]
2025-10-20 10:27           ` Oliver Neukum
2025-10-11  7:53 ` [PATCH net v5 3/3] Revert "net: usb: ax88179_178a: Bind only to vendor-specific interface" yicongsrfy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=806d82e6-6db6-4ec8-a49c-665a97ea36f8@suse.com \
    --to=oneukum@suse.com \
    --cc=andrew+netdev@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=kuba@kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=michal.pecio@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pabeni@redhat.com \
    --cc=stern@rowland.harvard.edu \
    --cc=yicongsrfy@163.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox