The itd_patch() function is responsible for allocating entries in the
buffer page pointer list of the iTD.  Particularly, a new page pointer
is needed every time when buffer data crosses a page boundary.

However, there is a bug in the allocation logic: the function does not
allocate a new entry when the current transaction is the first
transaction in the iTD (as indicated by first!=0).

The consequence is that, when the data of the first transaction begins
somewhere at the end of a page so that it actually does cross the page
boundary, no new page pointer is allocated.  This means that the data
at the end of the first transaction (beyond the page boundary) will be
accessed by the HC using the second page pointer, which is zero.
Furthermore, the first page pointer will be later overwritten by the
page pointers of the other transactions, which will garble it because
the value is or-ed into the iTD field.

All this particular check (for !first) does is cause incorrect
behaviour, so it should be entirely removed (and with it the variable
first that is not used for anything else).

Signed-off-by: Clemens Ladisch <[EMAIL PROTECTED]>


--- a/linux-2.6.11/drivers/usb/host/ehci-sched.c        2005-03-02 
22:00:29.000000000 +0100
+++ b/linux-2.6.11/drivers/usb/host/ehci-sched.c        2005-05-14 
16:41:21.000000000 +0200
@@ -1203,8 +1203,7 @@
        struct ehci_itd         *itd,
        struct ehci_iso_sched   *iso_sched,
        unsigned                index,
-       u16                     uframe,
-       int                     first
+       u16                     uframe
 )
 {
        struct ehci_iso_packet  *uf = &iso_sched->packet [index];
@@ -1221,7 +1220,7 @@
        itd->hw_bufp_hi [pg] |= cpu_to_le32 ((u32)(uf->bufp >> 32));

        /* iso_frame_desc[].offset must be strictly increasing */
-       if (unlikely (!first && uf->cross)) {
+       if (unlikely (uf->cross)) {
                u64     bufp = uf->bufp + 4096;
                itd->pg = ++pg;
                itd->hw_bufp [pg] |= cpu_to_le32 (bufp & ~(u32)0);
@@ -1250,7 +1249,7 @@
        struct ehci_iso_stream  *stream
 )
 {
-       int                     packet, first = 1;
+       int                     packet;
        unsigned                next_uframe, uframe, frame;
        struct ehci_iso_sched   *iso_sched = urb->hcpriv;
        struct ehci_itd         *itd;
@@ -1283,7 +1282,6 @@
                        list_move_tail (&itd->itd_list, &stream->td_list);
                        itd->stream = iso_stream_get (stream);
                        itd->urb = usb_get_urb (urb);
-                       first = 1;
                        itd_init (stream, itd);
                }

@@ -1291,8 +1289,7 @@
                frame = next_uframe >> 3;

                itd->usecs [uframe] = stream->usecs;
-               itd_patch (itd, iso_sched, packet, uframe, first);
-               first = 0;
+               itd_patch (itd, iso_sched, packet, uframe);

                next_uframe += stream->interval;
                stream->depth += stream->interval;



-------------------------------------------------------
This SF.Net email is sponsored by Oracle Space Sweepstakes
Want to be the first software developer in space?
Enter now for the Oracle Space Sweepstakes!
http://ads.osdn.com/?ad_id=7412&alloc_id=16344&op=click
_______________________________________________
linux-usb-devel@lists.sourceforge.net
To unsubscribe, use the last form field at:
https://lists.sourceforge.net/lists/listinfo/linux-usb-devel

Reply via email to