Re: how OUT/IN request from host are propogated on gadget side

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 




--- On Mon, 6/21/10, Rajaram R <rajaram.officemail@xxxxxxxxx> wrote:

> From: Rajaram R <rajaram.officemail@xxxxxxxxx>
> Subject: Re: how OUT/IN request from host are propogated on gadget side


Through the usb_request entities  sent from the
gadget driver ... you won't see packets, only
whole transfers (one or more packet each).

For example, if maxpacket is 64 bytes, and the
buffer in the usb_request is 512 bytes, the controller driver will fill (OUT) or empty (IN)
that  buffer using four USB packets.  That's
true whether DMA or PIO is used to empty the
FIFO.




> > I am looking at gadget driver code.
> > I have a question understanding how OUT/IN request,
> sent by USB host, travels on Gadget Side Stack. The requests
> will be received in terms of OUT/IN token by gadget
> controller hardware. Gadget controller driver will receive
> an interrupt for the same.

Not necessarily.  DMA is often in use, so
any IRQ will signify the end of the DMA
transfer rather than a single USB packet.

EP0 is usually packet-at-a-time PIO though,
as you imply; especially SETUP packets

Look at the at91_udc driver for a relatively
straightforward PIO driver.

Look at the omap_udc driver for a driver with
both PIO and DMA support that may be relatively
easy to understand.

Or not ... all USB peripheral drivers are
different.  Tricky bits relate to DMA and
FIFO handling;failover from DMA modes
to PIO modes (and vice versa).


 What happens afterwards ? In any
> case, gadget controller driver should notify gadget side
> driver about such request. But, I do not see any such
> mechanism.



You have it backwards.  

I/O notifications are driven by the
usb_request entities from the gadget driver.


The controller driver just obeys usb_request
commands, in conjunction with packets from
the host.  If there's no usb_request then
nothing hapens.  (Except for SETUP packets,
ISTR ... it's late at night here though, so
I might not be thinking clearly on that.)


> >
> > Going through, file_storage.c, I do see that gadget
> driver always polls for any OUT/IN request. Is it the *only*
> mechanism ?


No.  Polling in that driver is a special case
and is unusual.  Use g_zero as a more typical
example.


> > Is there any other in-kernel mechanism through which
> gadget controller driver can notify about OUT/IN request to
> gadget driver ?

Explained above, and in the kerneldoc 
you reference.


> 
> Did you had a chance to read this document ?
> 
> http://tali.admingilde.org/linux-docbook/gadget.pdf
> 
> In case of net2280(gadget/net2280.c), pls see net2280_irq
> and the
> following routines take care of it.
> 
>  /* handle disconnect, dma, and more */
> 2709     
>    handle_stat1_irqs (dev, readl
> (&dev->regs->irqstat1));
> 2710
> 2711         /* control
> requests and PIO */
> 2712     
>    handle_stat0_irqs (dev, readl
> (&dev->regs->irqstat0));
> 

The net2280 peripheral controller driver is
one of the less straightforward ones, in
part because of the workarounds it has for
early chip errata.



> HTH
> 
> >
> > Thanks,
> > Viral
> >

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux