stable.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Johan Hovold <johan@kernel.org>
To: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Felipe Balbi <balbi@ti.com>,
	Alan Stern <stern@rowland.harvard.edu>
Cc: linux-usb@vger.kernel.org, linux-kernel@vger.kernel.org,
	Stephen Warren <swarren@wwwdotorg.org>,
	Thierry Reding <thierry.reding@gmail.com>,
	Alexandre Courbot <gnurou@gmail.com>,
	linux-tegra@vger.kernel.org, Johan Hovold <johan@kernel.org>,
	stable <stable@vger.kernel.org>
Subject: [PATCH 1/2] USB: musb: fix inefficient copy of unaligned buffers
Date: Tue,  7 Apr 2015 11:46:51 +0200	[thread overview]
Message-ID: <1428400012-7563-2-git-send-email-johan@kernel.org> (raw)
In-Reply-To: <1428400012-7563-1-git-send-email-johan@kernel.org>

Make sure only to copy any actual data rather than the whole buffer,
when releasing the temporary buffer used for unaligned transfer buffers.

Note that this also fixes a lockup on disconnect, where repeated failed
transfers would starve the hub workqueue from processing the disconnect,
which would have prevented the urbs from being resubmitted. In this case
there is no data to forward, but the full buffer length was being copied
nonetheless.

The disconnect lockup can easily be reproduced using four unaligned
4k-bulk-in urbs on Beaglebone Black.

Fixes: 8408fd1d83e3 ("usb: musb: implement (un)map_urb_for_dma hooks")
Cc: stable <stable@vger.kernel.org>	# v3.10
Signed-off-by: Johan Hovold <johan@kernel.org>
---
 drivers/usb/musb/musb_host.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/usb/musb/musb_host.c b/drivers/usb/musb/musb_host.c
index c3d5fc9dfb5b..d8327ec19a1f 100644
--- a/drivers/usb/musb/musb_host.c
+++ b/drivers/usb/musb/musb_host.c
@@ -2523,7 +2523,7 @@ static void musb_free_temp_buffer(struct urb *urb)
 
 	if (dir == DMA_FROM_DEVICE) {
 		memcpy(temp->old_xfer_buffer, temp->data,
-		       urb->transfer_buffer_length);
+		       urb->actual_length);
 	}
 	urb->transfer_buffer = temp->old_xfer_buffer;
 	kfree(temp->kmalloc_ptr);
-- 
2.0.5


       reply	other threads:[~2015-04-07  9:46 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <1428400012-7563-1-git-send-email-johan@kernel.org>
2015-04-07  9:46 ` Johan Hovold [this message]
2015-04-07  9:46 ` [PATCH 2/2] USB: ehci-tegra: fix inefficient copy of unaligned buffers Johan Hovold
2015-04-07 15:30   ` Alan Stern
2015-04-07 19:59     ` Johan Hovold

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=1428400012-7563-2-git-send-email-johan@kernel.org \
    --to=johan@kernel.org \
    --cc=balbi@ti.com \
    --cc=gnurou@gmail.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=stable@vger.kernel.org \
    --cc=stern@rowland.harvard.edu \
    --cc=swarren@wwwdotorg.org \
    --cc=thierry.reding@gmail.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;
as well as URLs for NNTP newsgroup(s).