From: Michal Nazarewicz <mina86@mina86.com>
To: David Cohen <david.a.cohen@linux.intel.com>,
balbi@ti.com, gregkh@linuxfoundation.org
Cc: r.baldyga@samsung.com, linux-usb@vger.kernel.org,
linux-kernel@vger.kernel.org,
David Cohen <david.a.cohen@linux.intel.com>,
Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Subject: Re: [PATCH] usb: ffs: fix regression when quirk_ep_out_aligned_size flag is set
Date: Wed, 08 Oct 2014 13:34:16 +0200 [thread overview]
Message-ID: <xa1tsiiysslj.fsf@mina86.com> (raw)
In-Reply-To: <1412727486-479-1-git-send-email-david.a.cohen@linux.intel.com>
On Tue, Oct 07 2014, David Cohen <david.a.cohen@linux.intel.com> wrote:
> The commit '2e4c7553cd usb: gadget: f_fs: add aio support' broke the
> quirk implemented to align buffer size to maxpacketsize on out endpoint.
> As result, functionfs does not work on Intel platforms using dwc3 driver
> (i.e. Bay Trail and Merrifield). This patch fixes the issue.
>
> This code is based on a previous Qiuxu's patch.
>
> Signed-off-by: David Cohen <david.a.cohen@linux.intel.com>
> Signed-off-by: Qiuxu Zhuo <qiuxu.zhuo@intel.com>
Acked-by: Michal Nazarewicz <mina86@mina86.com>
> ---
>
> Hi,
>
> Since this is a feature that worked in past, this patch is meant for 3.17
> kernel. If/when we pass review and accept it on 3.17, I'll send a version for
> stable 3.16 kernel too. It is not required for 3.14, since the regression came
> later.
>
> Br, David Cohen
>
> ---
> drivers/usb/gadget/function/f_fs.c | 21 ++++++++++++++++-----
> 1 file changed, 16 insertions(+), 5 deletions(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 0dc3552d1360..6e2b8063b170 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -648,15 +648,26 @@ static void ffs_user_copy_worker(struct work_struct *work)
> if (io_data->read && ret > 0) {
> int i;
> size_t pos = 0;
> +
> + /*
> + * Since req->length may be bigger than io_data->len (after
> + * being rounded up to maxpacketsize), we may end up with more
> + * data then user space has space for.
> + */
> + ret = min_t(int, ret, io_data->len);
> +
> use_mm(io_data->mm);
> for (i = 0; i < io_data->nr_segs; i++) {
> + size_t len = min_t(size_t, ret - pos,
> + io_data->iovec[i].iov_len);
> + if (!len)
> + break;
> if (unlikely(copy_to_user(io_data->iovec[i].iov_base,
> - &io_data->buf[pos],
> - io_data->iovec[i].iov_len))) {
> + &io_data->buf[pos], len))) {
> ret = -EFAULT;
> break;
> }
> - pos += io_data->iovec[i].iov_len;
> + pos += len;
> }
> unuse_mm(io_data->mm);
> }
> @@ -794,7 +805,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
> goto error_lock;
>
> req->buf = data;
> - req->length = io_data->len;
> + req->length = data_len;
>
> io_data->buf = data;
> io_data->ep = ep->ep;
> @@ -816,7 +827,7 @@ static ssize_t ffs_epfile_io(struct file *file, struct ffs_io_data *io_data)
>
> req = ep->req;
> req->buf = data;
> - req->length = io_data->len;
> + req->length = data_len;
>
> req->context = &done;
> req->complete = ffs_epfile_io_complete;
> --
> 2.1.0
>
--
Best regards, _ _
.o. | Liege of Serenely Enlightened Majesty of o' \,=./ `o
..o | Computer Science, Michał “mina86” Nazarewicz (o o)
ooo +--<mpn@google.com>--<xmpp:mina86@jabber.org>--ooO--(_)--Ooo--
next prev parent reply other threads:[~2014-10-08 11:53 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-08 0:18 [PATCH] usb: ffs: fix regression when quirk_ep_out_aligned_size flag is set David Cohen
2014-10-08 0:31 ` Felipe Balbi
2014-10-08 17:53 ` David Cohen
2014-10-08 0:32 ` Felipe Balbi
2014-10-08 17:55 ` David Cohen
2014-10-08 19:54 ` Felipe Balbi
2014-10-08 11:34 ` Michal Nazarewicz [this message]
2014-10-08 21:12 ` [PATCH v2] " David Cohen
2014-10-12 19:12 ` Al Viro
2014-10-12 19:58 ` Felipe Balbi
2014-10-13 15:32 ` Felipe Balbi
2014-10-13 16:55 ` David Cohen
2014-10-13 17:03 ` Felipe Balbi
2014-10-13 18:15 ` [PATCH v3] " David Cohen
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=xa1tsiiysslj.fsf@mina86.com \
--to=mina86@mina86.com \
--cc=balbi@ti.com \
--cc=david.a.cohen@linux.intel.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=qiuxu.zhuo@intel.com \
--cc=r.baldyga@samsung.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