Re: [PATCH 1/4] usb: musb: Enable DMA Mode1 for device mode RX

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

 



On Fri, Feb 08, 2013 at 01:59:41PM +0530, Supriya Karanth wrote:
> From: supriya karanth <supriya.karanth@xxxxxxxxxxxxxx>
> 
> Generic changes for enabling DMA Mode1.
> Cleanup of rxtsate function making programming
> same for all platforms
> 
> Handles:
> 1) Known transfer length
>       a) Non multiple of packet size
>       b) Multiple of packet size
> 
> 2) Unknown transfer lengths
>       - Short packet indicates end of transfer
> 
> ---------------> OUT Endpoint interrupt recieved
> |                          |
> |      ____________________|_________________
> |      |                                     |
> | -> No ongoing transfer   ->DMA Transfer ongoing and RXPKTRDY set?
> |      |                   ->Short Packet recieved
> |  request queued?         ->PAUSE DMA transfer, Read Residue
> |      |                    ________________|____________
> |      |                    |                            |
> |      |                   residue!=0                 residue=0
> |      |            -> abort DMA                    ->Resume DMA
> |      |            ->Update request->actual_len    ->Wait for DMA
> |      |            -> Clear DMA bits in CSR            completion
> |      |            -> Read Short Packet                   |
> |      |__________________________|                        |______
> |                          |                                      |
> |                     call rxstate                                |
> |                    ->RXPKTRDY set? Read RXCOUNT                 |
> |      _____________________|____________________                 |
> |      |                                          |               |
> | ->RXCOUNT == EP MAX packet Size   ->RXCOUNT < EP MAX packet Size|
> | ->Program DMA in Mode1 for length -> Program in PIO / Mode0     |
> |    which is multiple of packet    -> Read Short packet from FIFO|
> |    size                           -> Update request->actual_len |
> |       |                           -> call musb_giveback         |
> |       |________________________________________|                |
> |____________________________|                                    |
> |                            |                                    |
> |                            |____________________________________|
> |                               |
> |               DMA completion interrupt recieved
> |        _______________________|_________________
> |        |                                        |
> |  ->req->len = req->actual            ->req->len < req->actual
> |  ->Clear DMA bits                    -> Short packet expected
> |  ->Call musb_giveback                ->Clear DMA bits
> |       |                              ->wait for next OUT
> |       |_________________________________________|
> |_______________________________|
> 
> Signed-off-by: Supriya Karanth <supriya.karanth@xxxxxxxxxxxxxx>
> Signed-off-by: Praveena NADAHALLY <praveen.nadahally@xxxxxxxxxxxxxx>
> Acked-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
> ---

How have you tested this ?

This should survive a week or so running testusb with its companion
test.sh.

You should also run my msc.c [1] with its companion msc.sh [2] with a
mass storage device and it should pass all tests. Mode1 DMA has the
tendency to break very, very easily.

Also, the way you implemented isn't the best possible way. You shouldn't
need all those extra fields added to struct dma_channel or struct
dma_controller.

If you want to add Mode1 DMA, first thing that needs to be done is
cleanup current code. Here's a quick list off the top of my head:

- split txstate()/rxstate() into DMA and PIO counterparts
- remove all if (dma_is_*()) checks by sticking to the programming model
  layed out in MUSB's Programming Guide document
- Modify ->channel_abort() to update channel->actual_len
- Start adding Mode1 support

Note that this is not an exaustive list and that each patch should be
tested for at least a couple of days with testusb/test.sh plus full
msc.c/msc.sh.

[1] http://gitorious.org/usb/usb-tools/blobs/master/msc.c
[2] http://gitorious.org/usb/usb-tools/blobs/master/msc.sh

You might want to look at Jolla's kernel which is a fork of the Nokia
kernel where mode1 support was originally added.

You might want to have a look at this kernel which is a fork of the
original Nokia kernel where mode1 was first added:

https://github.com/nemomobile/kernel-adaptation-n950-n9/blob/mer-n9-2.6.32-20121301/drivers/usb/musb/musb_gadget.c

-- 
balbi

Attachment: signature.asc
Description: Digital signature


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

  Powered by Linux