From: Thinh Nguyen <Thinh.Nguyen@synopsys.com>
To: Pawel Laszczak <pawell@cadence.com>,
Thinh Nguyen <Thinh.Nguyen@synopsys.com>,
Jayshri Dajiram Pawar <jpawar@cadence.com>,
"linux-usb@vger.kernel.org" <linux-usb@vger.kernel.org>
Cc: "gregkh@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"balbi@kernel.org" <balbi@kernel.org>,
"heikki.krogerus@linux.intel.com"
<heikki.krogerus@linux.intel.com>,
"rogerq@ti.com" <rogerq@ti.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"jbergsagel@ti.com" <jbergsagel@ti.com>,
"nsekhar@ti.com" <nsekhar@ti.com>, "nm@ti.com" <nm@ti.com>,
"peter.chen@nxp.com" <peter.chen@nxp.com>,
"Rahul Kumar" <kurahul@cadence.com>,
Sanket Parmar <sparmar@cadence.com>
Subject: Re: [PATCH v1] usb:gadget: Fix issue with config_ep_by_speed function.
Date: Fri, 14 Feb 2020 19:26:22 +0000 [thread overview]
Message-ID: <7ef4b9c5-8694-4d8e-2866-95ec11546bec@synopsys.com> (raw)
In-Reply-To: <BYAPR07MB47098648C28E5E4BB9B78DCADD150@BYAPR07MB4709.namprd07.prod.outlook.com>
Pawel Laszczak wrote:
> Hi,
>
>> Hi,
>>
>> Jayshri Pawar wrote:
>>> This patch adds additional parameter alt to config_ep_by_speed function.
>>> This additional parameter allows to improve this function and
>>> find proper usb_ss_ep_comp_descriptor.
>>>
>>> Problem has appeared during testing f_tcm (BOT/UAS) driver function.
>>>
>>> f_tcm function for SS use array of headers for both BOT/UAS alternate
>>> setting:
>>>
>>> static struct usb_descriptor_header *uasp_ss_function_desc[] = {
>>> (struct usb_descriptor_header *) &bot_intf_desc,
>>> (struct usb_descriptor_header *) &bot_uasp_ss_bi_desc,
>>> (struct usb_descriptor_header *) &bot_bi_ep_comp_desc,
>>> (struct usb_descriptor_header *) &bot_uasp_ss_bo_desc,
>>> (struct usb_descriptor_header *) &bot_bo_ep_comp_desc,
>>>
>>> (struct usb_descriptor_header *) &uasp_intf_desc,
>>> (struct usb_descriptor_header *) &bot_uasp_ss_bi_desc,
>>> (struct usb_descriptor_header *) &uasp_bi_ep_comp_desc,
>>> (struct usb_descriptor_header *) &uasp_bi_pipe_desc,
>>> (struct usb_descriptor_header *) &bot_uasp_ss_bo_desc,
>>> (struct usb_descriptor_header *) &uasp_bo_ep_comp_desc,
>>> (struct usb_descriptor_header *) &uasp_bo_pipe_desc,
>>> (struct usb_descriptor_header *) &uasp_ss_status_desc,
>>> (struct usb_descriptor_header *) &uasp_status_in_ep_comp_desc,
>>> (struct usb_descriptor_header *) &uasp_status_pipe_desc,
>>> (struct usb_descriptor_header *) &uasp_ss_cmd_desc,
>>> (struct usb_descriptor_header *) &uasp_cmd_comp_desc,
>>> (struct usb_descriptor_header *) &uasp_cmd_pipe_desc,
>>> NULL,
>>> };
>>>
>>> The first 5 descriptors are associated with BOT alternate setting,
>>> and others are associated with UAS.
>>>
>>> During handling UAS alternate setting f_tcm drivr invokes
>>> config_ep_by_speed and this function sets incorrect companion endpoint
>>> descriptor in usb_ep object.
>>>
>>> Instead setting ep->comp_desc to uasp_bi_ep_comp_desc function in this
>>> case set ep->comp_desc to bot_uasp_ss_bi_desc.
>>>
>>> This is due to the fact that it search endpoint based on endpoint
>>> address:
>>>
>>> for_each_ep_desc(speed_desc, d_spd) {
>>> chosen_desc = (struct usb_endpoint_descriptor *)*d_spd;
>>> if (chosen_desc->bEndpoitAddress == _ep->address)
>>> goto ep_found;
>>> }
>>>
>>> And in result it uses the descriptor from BOT alternate setting
>>> instead UAS.
>>>
>>> Finally, it causes that controller driver during enabling endpoints
>>> detect that just enabled endpoint for bot.
>>>
>>> Signed-off-by: Jayshri Pawar <jpawar@cadence.com>
>>> Signed-off-by: Pawel Laszczak <pawell@cadence.com>
>>> ---
>>> drivers/usb/gadget/composite.c | 46 ++++++++++++++------
>>> drivers/usb/gadget/function/f_acm.c | 7 +--
>>> drivers/usb/gadget/function/f_ecm.c | 7 +--
>>> drivers/usb/gadget/function/f_eem.c | 4 +-
>>> drivers/usb/gadget/function/f_fs.c | 3 +-
>>> drivers/usb/gadget/function/f_hid.c | 4 +-
>>> drivers/usb/gadget/function/f_loopback.c | 2 +-
>>> drivers/usb/gadget/function/f_mass_storage.c | 5 ++-
>>> drivers/usb/gadget/function/f_midi.c | 2 +-
>>> drivers/usb/gadget/function/f_ncm.c | 7 +--
>>> drivers/usb/gadget/function/f_obex.c | 4 +-
>>> drivers/usb/gadget/function/f_phonet.c | 4 +-
>>> drivers/usb/gadget/function/f_rndis.c | 7 +--
>>> drivers/usb/gadget/function/f_serial.c | 4 +-
>>> drivers/usb/gadget/function/f_sourcesink.c | 11 +++--
>>> drivers/usb/gadget/function/f_subset.c | 4 +-
>>> drivers/usb/gadget/function/f_tcm.c | 36 +++++++--------
>>> drivers/usb/gadget/function/f_uac1_legacy.c | 2 +-
>>> drivers/usb/gadget/function/f_uvc.c | 5 ++-
>>> drivers/usb/gadget/function/u_audio.c | 4 +-
>>> include/linux/usb/composite.h | 2 +-
>>> 21 files changed, 99 insertions(+), 71 deletions(-)
>>>
>> I think we should create a new function and keep the old
>> config_ep_by_speed() for default alt-setting (e.i. have
>> config_ep_by_speed calls the new function with default alt-setting 0).
>> This way, we can keep compatibility with old function drivers and
>> minimize changes. At least that's what we did.
>>
> I don't think we need the separate function.
> If we set last parameter alt=0 then this function will work in the same way as old one.
>
I wasn't talking about that. This patch modifies the
config_ep_by_speed() parameters, which requires to make a change to
every function driver of the kernel, and all in a single patch. This
makes it difficult to backport this fix. The only function driver that
you really need this fix for is f_tcm because of the stream eps right?
You could just add a function like
int config_ep_by_speed_and_alt(struct usb_gadget *g, struct
usb_function *f, unsigned int alt, struct usb_ep *_ep);
Then redefine config_ep_by_speed() to use it
int config_ep_by_speed(struct usb_gadget *g,
struct usb_function *f,
struct usb_ep *_ep)
{
return config_ep_by_speed_and_alt(g, f, 0, _ep);
}
This way, 1) you can split this patch, 2) you only need to make a fix to
f_tcm, 3) this fix can be backported much easier.
Anyways, this is just a suggestion. It's up to the maintainers to decide.
BR,
Thinh
next prev parent reply other threads:[~2020-02-14 19:26 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-02-12 10:19 Jayshri Pawar
2020-02-14 3:40 ` Thinh Nguyen
2020-02-14 4:26 ` Pawel Laszczak
2020-02-14 19:26 ` Thinh Nguyen [this message]
2020-02-14 19:55 ` Pawel Laszczak
2020-03-04 9:29 ` Roger Quadros
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=7ef4b9c5-8694-4d8e-2866-95ec11546bec@synopsys.com \
--to=thinh.nguyen@synopsys.com \
--cc=balbi@kernel.org \
--cc=gregkh@linuxfoundation.org \
--cc=heikki.krogerus@linux.intel.com \
--cc=jbergsagel@ti.com \
--cc=jpawar@cadence.com \
--cc=kurahul@cadence.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=nm@ti.com \
--cc=nsekhar@ti.com \
--cc=pawell@cadence.com \
--cc=peter.chen@nxp.com \
--cc=rogerq@ti.com \
--cc=sparmar@cadence.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
all inboxes | Powered by JetHome®