From: Michal Nazarewicz <mina86@mina86.com>
To: "Du\, Changbin" <changbin.du@intel.com>,
Felipe Balbi <felipe.balbi@linux.intel.com>,
Alan Stern <stern@rowland.harvard.edu>
Cc: Al Viro <viro@zeniv.linux.org.uk>,
"gregkh\@linuxfoundation.org" <gregkh@linuxfoundation.org>,
"rui.silva\@linaro.org" <rui.silva@linaro.org>,
"k.opasiak\@samsung.com" <k.opasiak@samsung.com>,
"lars\@metafoo.de" <lars@metafoo.de>,
"linux-usb\@vger.kernel.org" <linux-usb@vger.kernel.org>,
"linux-kernel\@vger.kernel.org" <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] usb: gadget: f_fs: report error if excess data received
Date: Thu, 19 May 2016 09:34:33 +0200 [thread overview]
Message-ID: <xa1t8tz6qz5i.fsf@mina86.com> (raw)
In-Reply-To: <0C18FE92A7765D4EB9EE5D38D86A563A05D30D7A@SHSMSX103.ccr.corp.intel.com>
On Thu, May 19 2016, Changbin Du wrote:
>> On Wed, May 18 2016, Felipe Balbi wrote:
>> > we've been through this before. This needs to be done at the gadget
>> > layer. Gadget driver can over-allocate ahead of time if
>> > gadget->quirk_ep_out_aligned_size is true, then we avoid memcpy() at
>> > the UDC driver level.
>>
>> Right, all right, so let’s look at it from a regular USB function point
>> of view. If a USB function allocates a request which is not aligned,
>> UDC will align the buffer and *drop* excess data. Seeing how ugly
> Do you mean UDC driver align the buffer? I searched the code, currently
> only DWC3 needs buffer size to be aligned to MaxPacketSize on ep out.
> And the align is done in f_fs driver.
I thought that was what was happening based on Felipe’s comment about
avoiding memcpy. I looked at the code now and dunno what actually
happens.
>> f_fs’s code is becoming, I’m now leaning to letting to f_fs do the same
>> thing: if user space makes an unaligned read, f_fs aligns the buffer and
>> then drops excess data.
>>
>> Any arguments for f_fs to not drop the data apply to UDC, so they should
>> behave identically.
>>
> I'd prefer fail the request at all, and it is better done in HW.
> Because per the USB Spec that device can return NAK if a function was
> unable to accept data From the host. The DWC3 has not been design as
> this, if software fail the transfer, it is a little weird for host.
>
> So, now we have 3 choices:
> 1) buffer the excess data
> 2) fail the transfer
You mean fail when more data has been sent (i.e. drop the whole packet)
or fail at entry to read() if the buffer is not aligned?
> 3) drop the excess data, then print an warning message
>
> Which one do you prefer?
I think f_fs should mimic whatever happens if unaligned request is
queued on dwc3. As far as I understand, this is not 1.
I’ll be travelling again on Friday so I’ll finish up the patch doing 1
so we will have a choice between 1 (my patch) and 3 (your patch).
--
Best regards
ミハウ “𝓶𝓲𝓷𝓪86” ナザレヴイツ
«If at first you don’t succeed, give up skydiving»
next prev parent reply other threads:[~2016-05-19 7:34 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-11 10:19 changbin.du
2016-05-11 10:59 ` Felipe Balbi
2016-05-11 12:30 ` Michal Nazarewicz
2016-05-12 4:25 ` Du, Changbin
2016-05-12 4:21 ` Du, Changbin
2016-05-12 6:52 ` Felipe Balbi
2016-05-12 7:30 ` Du, Changbin
2016-05-12 7:46 ` Felipe Balbi
2016-05-12 8:16 ` Du, Changbin
2016-05-12 9:15 ` Felipe Balbi
2016-05-12 9:22 ` Felipe Balbi
2016-05-12 9:51 ` Du, Changbin
2016-05-12 9:39 ` Du, Changbin
2016-05-12 10:13 ` Felipe Balbi
2016-05-12 10:14 ` Felipe Balbi
2016-05-12 10:45 ` Du, Changbin
2016-05-12 11:22 ` Felipe Balbi
2016-05-13 5:52 ` Du, Changbin
2016-05-13 6:36 ` Felipe Balbi
2016-05-13 10:32 ` Du, Changbin
2016-05-13 14:29 ` Alan Stern
2016-05-14 20:39 ` Michal Nazarewicz
2016-05-16 12:57 ` Felipe Balbi
2016-05-16 13:08 ` Michal Nazarewicz
2016-05-16 13:16 ` Felipe Balbi
2016-05-16 19:09 ` Michal Nazarewicz
2016-05-17 2:53 ` Du, Changbin
2016-05-18 9:45 ` Michal Nazarewicz
2016-05-18 10:15 ` Felipe Balbi
2016-05-18 13:39 ` Michal Nazarewicz
2016-05-19 2:54 ` Du, Changbin
2016-05-19 7:34 ` Michal Nazarewicz [this message]
2016-05-19 8:49 ` Du, Changbin
2016-05-19 2:31 ` Du, Changbin
2016-05-16 16:05 ` Michal Nazarewicz
2016-05-16 16:27 ` Lars-Peter Clausen
2016-05-16 16:48 ` Michal Nazarewicz
2016-05-16 16:35 ` Krzysztof Opasiak
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=xa1t8tz6qz5i.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=changbin.du@intel.com \
--cc=felipe.balbi@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=k.opasiak@samsung.com \
--cc=lars@metafoo.de \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=rui.silva@linaro.org \
--cc=stern@rowland.harvard.edu \
--cc=viro@zeniv.linux.org.uk \
/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®