From: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
stable@vger.kernel.org,
Sarah Sharp <sarah.a.sharp@linux.intel.com>
Subject: [ 24/26] xhci: Fix TD size for isochronous URBs.
Date: Thu, 7 Feb 2013 16:57:52 -0800 [thread overview]
Message-ID: <20130208004631.165609474@linuxfoundation.org> (raw)
In-Reply-To: <20130208004627.258272404@linuxfoundation.org>
3.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Sarah Sharp <sarah.a.sharp@linux.intel.com>
commit f18f8ed2a9adc41c2d9294b85b6af115829d2af1 upstream.
To calculate the TD size for a particular TRB in an isoc TD, we need
know the endpoint's max packet size. Isochronous endpoints also encode
the number of additional service opportunities in their wMaxPacketSize
field. The TD size calculation did not mask off those bits before using
the field. This resulted in incorrect TD size information for
isochronous TRBs when an URB frame buffer crossed a 64KB boundary.
For example:
- an isoc endpoint has 2 additional service opportunites and
a max packet size of 1020 bytes
- a frame transfer buffer contains 3060 bytes
- one frame buffer crosses a 64KB boundary, and must be split into
one 1276 byte TRB, and one 1784 byte TRB.
The TD size is is the number of packets that remain to be transferred
for a TD after processing all the max packet sized packets in the
current TRB and all previous TRBs.
For this TD, the number of packets to be transferred is (3060 / 1020),
or 3. The first TRB contains 1276 bytes, which means it contains one
full packet, and a 256 byte remainder. After processing all the max
packet-sized packets in the first TRB, the host will have 2 packets left
to transfer.
The old code would calculate the TD size for the first TRB as:
total packet count = DIV_ROUND_UP (TD length / endpoint wMaxPacketSize)
total packet count - (first TRB length / endpoint wMaxPacketSize)
The math should have been:
total packet count = DIV_ROUND_UP (3060 / 1020) = 3
3 - (1276 / 1020) = 2
Since the old code didn't mask off the additional service interval bits
from the wMaxPacketSize field, the math ended up as
total packet count = DIV_ROUND_UP (3060 / 5116) = 1
1 - (1276 / 5116) = 1
Fix this by masking off the number of additional service opportunities
in the wMaxPacketSize field.
This patch should be backported to stable kernels as old as 3.0, that
contain the commit 4da6e6f247a2601ab9f1e63424e4d944ed4124f3 "xhci 1.0:
Update TD size field format." It may not apply well to kernels older
than 3.2 because of commit 29cc88979a8818cd8c5019426e945aed118b400e
"USB: use usb_endpoint_maxp() instead of le16_to_cpu()".
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/host/xhci-ring.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
--- a/drivers/usb/host/xhci-ring.c
+++ b/drivers/usb/host/xhci-ring.c
@@ -3106,7 +3106,7 @@ static u32 xhci_v1_0_td_remainder(int ru
* running_total.
*/
packets_transferred = (running_total + trb_buff_len) /
- usb_endpoint_maxp(&urb->ep->desc);
+ GET_MAX_PACKET(usb_endpoint_maxp(&urb->ep->desc));
if ((total_packet_count - packets_transferred) > 31)
return 31 << 17;
@@ -3640,7 +3640,8 @@ static int xhci_queue_isoc_tx(struct xhc
td_len = urb->iso_frame_desc[i].length;
td_remain_len = td_len;
total_packet_count = DIV_ROUND_UP(td_len,
- usb_endpoint_maxp(&urb->ep->desc));
+ GET_MAX_PACKET(
+ usb_endpoint_maxp(&urb->ep->desc)));
/* A zero-length transfer still involves at least one packet. */
if (total_packet_count == 0)
total_packet_count++;
next prev parent reply other threads:[~2013-02-08 0:57 UTC|newest]
Thread overview: 29+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-02-08 0:57 [ 00/26] 3.4.30-stable review Greg Kroah-Hartman
2013-02-08 0:57 ` [ 01/26] digsig: Fix memory leakage in digsig_verify_rsa() Greg Kroah-Hartman
2013-02-08 0:57 ` [ 02/26] drm/radeon/evergreen+: wait for the MC to settle after MC blackout Greg Kroah-Hartman
2013-02-08 0:57 ` [ 03/26] drm/radeon: add WAIT_UNTIL to the non-VM safe regs list for cayman/TN Greg Kroah-Hartman
2013-02-08 0:57 ` [ 04/26] drm/radeon: add quirk for RV100 board Greg Kroah-Hartman
2013-02-08 0:57 ` [ 05/26] drm/radeon: fix MC blackout on evergreen+ Greg Kroah-Hartman
2013-02-08 0:57 ` [ 06/26] drm/radeon: prevent crash in the ring space allocation Greg Kroah-Hartman
2013-02-08 0:57 ` [ 07/26] drm/radeon: Calling object_unrefer() when creating fb failure Greg Kroah-Hartman
2013-02-08 0:57 ` [ 08/26] x86-64: Replace left over sti/cli in ia32 audit exit code Greg Kroah-Hartman
2013-02-08 0:57 ` [ 09/26] sched/rt: Use root_domain of rt_rq not current processor Greg Kroah-Hartman
2013-02-08 0:57 ` [ 10/26] nilfs2: fix fix very long mount time issue Greg Kroah-Hartman
2013-02-08 0:57 ` [ 11/26] drivers/rtc/rtc-isl1208.c: call rtc_update_irq() from the alarm irq handler Greg Kroah-Hartman
2013-02-08 0:57 ` [ 12/26] USB: ftdi_sio: add Zolix FTDI PID Greg Kroah-Hartman
2013-02-08 0:57 ` [ 13/26] USB: ftdi_sio: add PID/VID entries for ELV WS 300 PC II Greg Kroah-Hartman
2013-02-08 0:57 ` [ 14/26] USB: option: add support for Telit LE920 Greg Kroah-Hartman
2013-02-08 0:57 ` [ 15/26] USB: option: add Changhong CH690 Greg Kroah-Hartman
2013-02-08 0:57 ` [ 16/26] USB: qcserial: add Telit Gobi QDL device Greg Kroah-Hartman
2013-02-08 0:57 ` [ 17/26] USB: EHCI: fix timer bug affecting port resume Greg Kroah-Hartman
2013-02-08 0:57 ` [ 18/26] USB: EHCI: fix bug in scheduling periodic split transfers Greg Kroah-Hartman
2013-02-08 0:57 ` [ 19/26] usb: Using correct way to clear usb3.0 devices remote wakeup feature Greg Kroah-Hartman
2013-02-08 0:57 ` [ 20/26] USB: storage: Define a new macro for USB storage match rules Greg Kroah-Hartman
2013-02-08 0:57 ` [ 21/26] USB: storage: optimize to match the Huawei USB storage devices and support new switch command Greg Kroah-Hartman
2013-02-08 0:57 ` [ 22/26] drivers: xhci: fix incorrect bit test Greg Kroah-Hartman
2013-02-08 0:57 ` [ 23/26] xhci: Fix isoc TD encoding Greg Kroah-Hartman
2013-02-08 0:57 ` Greg Kroah-Hartman [this message]
2013-02-08 0:57 ` [ 25/26] USB: XHCI: fix memory leak of URB-private data Greg Kroah-Hartman
2013-02-08 0:57 ` [ 26/26] usb: Prevent dead ports when xhci is not enabled Greg Kroah-Hartman
2013-02-08 20:28 ` [ 00/26] 3.4.30-stable review Shuah Khan
2013-02-09 12:12 ` Satoru Takeuchi
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=20130208004631.165609474@linuxfoundation.org \
--to=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sarah.a.sharp@linux.intel.com \
--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).