All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jerry Zhang <zhangjerry@google.com>
To: Felipe Balbi <balbi@kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	linux-usb@vger.kernel.org
Cc: Michal Nazarewicz <mina86@mina86.com>,
	Krzysztof Opasiak <kopasiak90@gmail.com>,
	Badhri Jagan Sridharan <badhri@google.com>,
	Andrzej Pietrasiewicz <andrzej.p@samsung.com>,
	Lars-Peter Clausen <lars@metafoo.de>,
	felixhaedicke@web.de
Subject: [1/3] usb: gadget: f_fs: Only return delayed status when len is 0
Date: Mon, 4 Jun 2018 12:44:57 -0700	[thread overview]
Message-ID: <CA+JE3bfB_XjQoSePUdaMq=v_mj63dH0qr64GbYdPfMGZ9ayO5Q@mail.gmail.com> (raw)

Hi Felipe,

I noticed this wasn't queued up for 4.18. Do you think there is
anything I need to do to get this patch set into 4.19? Also, can we at
least add just this patch ('usb: gadget: f_fs: Only return delayed
status when len is 0') to 4.18 as functionfs control requests won't
work without it?

Thanks,

Jerry
On Mon, Apr 16, 2018 at 6:18 PM Jerry Zhang <zhangjerry@google.com> wrote:
>
> Commit 1b9ba000 ("Allow function drivers to pause control
> transfers") states that USB_GADGET_DELAYED_STATUS is only
> supported if data phase is 0 bytes.
>
> It seems that when the length is not 0 bytes, there is no
> need to explicitly delay the data stage since the transfer
> is not completed until the user responds. However, when the
> length is 0, there is no data stage and the transfer is
> finished once setup() returns, hence there is a need to
> explicitly delay completion.
>
> This manifests as the following bugs:
>
> Prior to 946ef68ad4e4 ('Let setup() return
> USB_GADGET_DELAYED_STATUS'), when setup is 0 bytes, ffs
> would require user to queue a 0 byte request in order to
> clear setup state. However, that 0 byte request was actually
> not needed and would hang and cause errors in other setup
> requests.
>
> After the above commit, 0 byte setups work since the gadget
> now accepts empty queues to ep0 to clear the delay, but all
> other setups hang.
>
> Fixes: 946ef68ad4e4 ("Let setup() return USB_GADGET_DELAYED_STATUS")
> Signed-off-by: Jerry Zhang <zhangjerry@google.com>
> ---
>  drivers/usb/gadget/function/f_fs.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/function/f_fs.c b/drivers/usb/gadget/function/f_fs.c
> index 7d5b1c448eb2..4b2cb9d93176 100644
> --- a/drivers/usb/gadget/function/f_fs.c
> +++ b/drivers/usb/gadget/function/f_fs.c
> @@ -3271,7 +3271,7 @@ static int ffs_func_setup(struct usb_function *f,
>         __ffs_event_add(ffs, FUNCTIONFS_SETUP);
>         spin_unlock_irqrestore(&ffs->ev.waitq.lock, flags);
>
> -       return USB_GADGET_DELAYED_STATUS;
> +       return creq->wLength == 0 ? USB_GADGET_DELAYED_STATUS : 0;
>  }
>
>  static bool ffs_func_req_match(struct usb_function *f,
> --
> 2.17.0.484.g0c8726318c-goog
>
---
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

             reply	other threads:[~2018-06-04 19:44 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-04 19:44 Jerry Zhang [this message]
  -- strict thread matches above, loose matches on Subject: below --
2018-07-26 10:45 [1/3] usb: gadget: f_fs: Only return delayed status when len is 0 Felipe Balbi
2018-04-17  1:17 Jerry Zhang

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='CA+JE3bfB_XjQoSePUdaMq=v_mj63dH0qr64GbYdPfMGZ9ayO5Q@mail.gmail.com' \
    --to=zhangjerry@google.com \
    --cc=andrzej.p@samsung.com \
    --cc=badhri@google.com \
    --cc=balbi@kernel.org \
    --cc=felixhaedicke@web.de \
    --cc=gregkh@linuxfoundation.org \
    --cc=kopasiak90@gmail.com \
    --cc=lars@metafoo.de \
    --cc=linux-usb@vger.kernel.org \
    --cc=mina86@mina86.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.