From: Jack Pham <jackp@codeaurora.org>
To: Peter Chen <hzpeterchen@gmail.com>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Felipe Balbi <balbi@kernel.org>,
linux-usb@vger.kernel.org,
Sebastian Andrzej Siewior <bigeasy@linutronix.de>,
Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
Subject: Re: [PATCH v2] usb: gadget: configfs: Preserve function ordering after bind failure
Date: Fri, 1 Jan 2021 13:17:37 -0800 [thread overview]
Message-ID: <20210101211737.GA29962@jackp-linux.qualcomm.com> (raw)
In-Reply-To: <20201231100122.GA12514@b29397-desktop>
On Thu, Dec 31, 2020 at 06:04:00PM +0800, Peter Chen wrote:
> On 20-12-29 14:44:43, Jack Pham wrote:
> > From: Chandana Kishori Chiluveru <cchiluve@codeaurora.org>
> >
> > When binding the ConfigFS gadget to a UDC, the functions in each
> > configuration are added in list order. However, if usb_add_function()
> > fails, the failed function is put back on its configuration's
> > func_list and purge_configs_funcs() is called to further clean up.
> >
> > purge_configs_funcs() iterates over the configurations and functions
> > in forward order, calling unbind() on each of the previously added
> > functions. But after doing so, each function gets moved to the
> > tail of the configuration's func_list. This results in reshuffling
> > the original order of the functions within a configuration such
> > that the failed function now appears first even though it may have
> > originally appeared in the middle or even end of the list. At this
> > point if the ConfigFS gadget is attempted to re-bind to the UDC,
> > the functions will be added in a different order than intended,
> > with the only recourse being to remove and relink the functions all
> > over again.
<snip>
> Hi Jack,
>
> I am curious what features are broken if the functions are added with
> not planned order?
Hi Peter,
This is mainly an issue for devices with functions that use vendor-
specific instead of standard class/subclass IDs for their interface
descriptors. Android ADB and Qualcomm QMI are a couple examples. So
host interface drivers would only be able to install or bind based on
matching VID/PID and interface position only. This is true for both
Windows as well as Linux (see USB_DEVICE_INTERFACE_NUMBER).
So if the gadget's function bind order gets jumbled up from the intended
order, the resulting assigned interface numbers would be different and
the host would not match its drivers to the correct interface. Instead
we see the host driver gets bound but the endpoints it communicates with
are wrong as they are for a completely different interface.
Thanks,
Jack
--
The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum,
a Linux Foundation Collaborative Project
next prev parent reply other threads:[~2021-01-01 21:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-29 22:44 [PATCH v2] usb: gadget: configfs: Preserve function ordering after bind failure Jack Pham
2020-12-31 10:04 ` Peter Chen
2021-01-01 21:17 ` Jack Pham [this message]
2021-01-04 0:58 ` Peter Chen
2021-01-04 7:55 ` Jack Pham
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=20210101211737.GA29962@jackp-linux.qualcomm.com \
--to=jackp@codeaurora.org \
--cc=balbi@kernel.org \
--cc=bigeasy@linutronix.de \
--cc=cchiluve@codeaurora.org \
--cc=gregkh@linuxfoundation.org \
--cc=hzpeterchen@gmail.com \
--cc=linux-usb@vger.kernel.org \
/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;
as well as URLs for NNTP newsgroup(s).