stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Sasha Levin <sashal@kernel.org>
To: Jack Pham <jackp@codeaurora.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	stable@vger.kernel.org,
	Felipe Balbi <felipe.balbi@linux.intel.com>
Subject: Re: [PATCH 4.14,4.19,4.20] usb: dwc3: gadget: Clear req->unaligned and zero flags on cleanup
Date: Sat, 26 Jan 2019 13:21:02 -0500	[thread overview]
Message-ID: <20190126182102.GG30183@sasha-vm> (raw)
In-Reply-To: <20190126015153.2757-1-jackp@codeaurora.org>

On Fri, Jan 25, 2019 at 05:51:53PM -0800, Jack Pham wrote:
>commit bd6742249b9ca918565e4e3abaa06665e587f4b5 upstream.
>
>OUT endpoint requests may somtimes have one of these flags set
>when preparing to be submitted to HW indicating that there is an
>additional TRB chained to the request for alignment purposes.
>If that request is removed before the controller can execute the
>transfer (e.g. ep_dequeue/ep_disable), the request will not go
>through the dwc3_gadget_ep_cleanup_completed_request() handler
>and will not have its unaligned or zero flag cleared when
>dwc3_gadget_giveback() is called.  This same request could be
>later requeued for a new transfer that does not require an
>extra TRB and if it is successfully completed, the cleanup
>and TRB reclamation will incorrectly process the additional TRB
>which belongs to the next request, and incorrectly advances the
>TRB dequeue pointer, thereby messing up calculation of the next
>requeust's actual/remaining count when it completes.
>
>The right thing to do here is to ensure that the flags are cleared
>before it is given back to the function driver.  A good place
>to do that is in dwc3_gadget_del_and_unmap_request().
>
>Fixes: c6267a51639b ("usb: dwc3: gadget: align transfers to wMaxPacketSize")
>Signed-off-by: Jack Pham <jackp@codeaurora.org>
>Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
>[jackp: backport to <= 4.20: replaced 'needs_extra_trb' with 'unaligned'
>        and 'zero' members in patch and reworded commit text]
>Signed-off-by: Jack Pham <jackp@codeaurora.org>
>---
> drivers/usb/dwc3/gadget.c | 2 ++
> 1 file changed, 2 insertions(+)
>
>diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c
>index 9f92ee03dde7..2a4ea9a1b1e3 100644
>--- a/drivers/usb/dwc3/gadget.c
>+++ b/drivers/usb/dwc3/gadget.c
>@@ -177,6 +177,8 @@ static void dwc3_gadget_del_and_unmap_request(struct dwc3_ep *dep,
> 	req->started = false;
> 	list_del(&req->list);
> 	req->remaining = 0;
>+	req->unaligned = false;
>+	req->zero = false;
>
> 	if (req->request.status == -EINPROGRESS)
> 		req->request.status = status;

Thanks! I'll let Greg pick it up (as the upstream patch was explicitly
tagged for stable).

--
Thanks,
Sasha

  reply	other threads:[~2019-01-26 18:21 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <87pnt5c53o.fsf@linux.intel.com>
2019-01-10 20:39 ` [PATCH v2] usb: dwc3: gadget: Clear req->needs_extra_trb flag on cleanup Jack Pham
     [not found]   ` <20190116133553.B64662086D@mail.kernel.org>
2019-01-26  1:18     ` Jack Pham
2019-01-26  1:51       ` [PATCH 4.14,4.19,4.20] usb: dwc3: gadget: Clear req->unaligned and zero flags " Jack Pham
2019-01-26 18:21         ` Sasha Levin [this message]
2019-01-26 18:19       ` [PATCH v2] usb: dwc3: gadget: Clear req->needs_extra_trb flag " Sasha Levin

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=20190126182102.GG30183@sasha-vm \
    --to=sashal@kernel.org \
    --cc=felipe.balbi@linux.intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jackp@codeaurora.org \
    --cc=stable@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).