On Wed, Mar 07, 2001, Jean Tourrilhes <[EMAIL PROTECTED]> wrote:
> Hi everybody,
>
> The USB stack is driving me nuts. I've found that changing the
> transmit buffer from one place to another make the USB transfer
> succedd or fail. This is absolutely crazy, so I would like someone to
> explain me what's happening...
>
> Context :
> o kernel 2.4.2
> o usb-uhci
> o irda-usb
>
> The code look like this :
> -----------------------------------------------
> #define IRDA_USB_SPEED_MTU 128
> #define USB_IRDA_HEADER 0x01
>
> struct irda_usb_cb {
> ...
> char *speed_buff; /* Buffer for speed changes */
> char spd_buff[IRDA_USB_SPEED_MTU]; /* Buffer for speed changes */
> ...
> }
>
> static int irda_usb_open(struct irda_usb_cb *self)
> {
> ...
> self->speed_buff = (__u8 *) kmalloc(IRDA_USB_SPEED_MTU, GFP_KERNEL);
> memset(self->speed_buff, 0, IRDA_USB_SPEED_MTU);
> memset(self->spd_buff, 0, IRDA_USB_SPEED_MTU);
> ...
> }
>
> static void irda_usb_change_speed_xbofs(struct irda_usb_cb *self)
> {
> __u8 *frame;
> ...
> frame = self->spd_buff;
> frame = self->speed_buff; /* ### Line to comment ### */
> frame[0] = new_speed;
>
> FILL_BULK_URB(purb, self->usbdev,
> usb_sndbulkpipe(self->usbdev, self->bulk_out_ep),
> frame, IRDA_USB_SPEED_MTU,
> speed_bulk_callback, self);
> purb->transfer_buffer_length = USB_IRDA_HEADER;
> purb->transfer_flags = USB_QUEUE_BULK;
> purb->timeout = MSECS_TO_JIFFIES(100);
>
> usb_submit_urb(purb);
> }
> -----------------------------------------------
>
> As it is above, the code works perfectly, and I never have any
> trouble. Perfect.
> If I just comment the line mentioned above (all the rest
> beeing equal), the callback is never called and after one full second
> the transfer is still in progress (-115) and I have to cancel it. Any
> subsequent retry also fail and I can never manage to get anything
> through to the dongle.
> Of course, between each try, I restart fully the USB and the
> IrDA stack. And guess what, it's 100% reproductible.
>
> This is beyond my comprehension. I'm open to suggestions...
The key is probably the function that calls irda_usb_change_speed_xbofs.
Most likely it allocates self on the stack (as an automatic variable)
which is not a valid memory location to DMA from and to.
I'm sure if you kmalloc self before calling irda_usb_change_speed_xbofs,
everything will work fine.
JE
_______________________________________________
[EMAIL PROTECTED]
To unsubscribe, use the last form field at:
http://lists.sourceforge.net/lists/listinfo/linux-usb-devel