···11-PXA/MMP - DMA Slave controller22-==============================33-44-Constraints55------------66- a) Transfers hot queuing77- A driver submitting a transfer and issuing it should be granted the transfer88- is queued even on a running DMA channel.99- This implies that the queuing doesn't wait for the previous transfer end,1010- and that the descriptor chaining is not only done in the irq/tasklet code1111- triggered by the end of the transfer.1212- A transfer which is submitted and issued on a phy doesn't wait for a phy to1313- stop and restart, but is submitted on a "running channel". The other1414- drivers, especially mmp_pdma waited for the phy to stop before relaunching1515- a new transfer.1616-1717- b) All transfers having asked for confirmation should be signaled1818- Any issued transfer with DMA_PREP_INTERRUPT should trigger a callback call.1919- This implies that even if an irq/tasklet is triggered by end of tx1, but2020- at the time of irq/dma tx2 is already finished, tx1->complete() and2121- tx2->complete() should be called.2222-2323- c) Channel running state2424- A driver should be able to query if a channel is running or not. For the2525- multimedia case, such as video capture, if a transfer is submitted and then2626- a check of the DMA channel reports a "stopped channel", the transfer should2727- not be issued until the next "start of frame interrupt", hence the need to2828- know if a channel is in running or stopped state.2929-3030- d) Bandwidth guarantee3131- The PXA architecture has 4 levels of DMAs priorities : high, normal, low.3232- The high priorities get twice as much bandwidth as the normal, which get twice3333- as much as the low priorities.3434- A driver should be able to request a priority, especially the real-time3535- ones such as pxa_camera with (big) throughputs.3636-3737-Design3838-------3939- a) Virtual channels4040- Same concept as in sa11x0 driver, ie. a driver was assigned a "virtual4141- channel" linked to the requestor line, and the physical DMA channel is4242- assigned on the fly when the transfer is issued.4343-4444- b) Transfer anatomy for a scatter-gather transfer4545- +------------+-----+---------------+----------------+-----------------+4646- | desc-sg[0] | ... | desc-sg[last] | status updater | finisher/linker |4747- +------------+-----+---------------+----------------+-----------------+4848-4949- This structure is pointed by dma->sg_cpu.5050- The descriptors are used as follows :5151- - desc-sg[i]: i-th descriptor, transferring the i-th sg5252- element to the video buffer scatter gather5353- - status updater5454- Transfers a single u32 to a well known dma coherent memory to leave5555- a trace that this transfer is done. The "well known" is unique per5656- physical channel, meaning that a read of this value will tell which5757- is the last finished transfer at that point in time.5858- - finisher: has ddadr=DADDR_STOP, dcmd=ENDIRQEN5959- - linker: has ddadr= desc-sg[0] of next transfer, dcmd=06060-6161- c) Transfers hot-chaining6262- Suppose the running chain is :6363- Buffer 1 Buffer 26464- +---------+----+---+ +----+----+----+---+6565- | d0 | .. | dN | l | | d0 | .. | dN | f |6666- +---------+----+-|-+ ^----+----+----+---+6767- | |6868- +----+6969-7070- After a call to dmaengine_submit(b3), the chain will look like :7171- Buffer 1 Buffer 2 Buffer 37272- +---------+----+---+ +----+----+----+---+ +----+----+----+---+7373- | d0 | .. | dN | l | | d0 | .. | dN | l | | d0 | .. | dN | f |7474- +---------+----+-|-+ ^----+----+----+-|-+ ^----+----+----+---+7575- | | | |7676- +----+ +----+7777- new_link7878-7979- If while new_link was created the DMA channel stopped, it is _not_8080- restarted. Hot-chaining doesn't break the assumption that8181- dma_async_issue_pending() is to be used to ensure the transfer is actually started.8282-8383- One exception to this rule :8484- - if Buffer1 and Buffer2 had all their addresses 8 bytes aligned8585- - and if Buffer3 has at least one address not 4 bytes aligned8686- - then hot-chaining cannot happen, as the channel must be stopped, the8787- "align bit" must be set, and the channel restarted As a consequence,8888- such a transfer tx_submit() will be queued on the submitted queue, and8989- this specific case if the DMA is already running in aligned mode.9090-9191- d) Transfers completion updater9292- Each time a transfer is completed on a channel, an interrupt might be9393- generated or not, up to the client's request. But in each case, the last9494- descriptor of a transfer, the "status updater", will write the latest9595- transfer being completed into the physical channel's completion mark.9696-9797- This will speed up residue calculation, for large transfers such as video9898- buffers which hold around 6k descriptors or more. This also allows without9999- any lock to find out what is the latest completed transfer in a running100100- DMA chain.101101-102102- e) Transfers completion, irq and tasklet103103- When a transfer flagged as "DMA_PREP_INTERRUPT" is finished, the dma irq104104- is raised. Upon this interrupt, a tasklet is scheduled for the physical105105- channel.106106- The tasklet is responsible for :107107- - reading the physical channel last updater mark108108- - calling all the transfer callbacks of finished transfers, based on109109- that mark, and each transfer flags.110110- If a transfer is completed while this handling is done, a dma irq will111111- be raised, and the tasklet will be scheduled once again, having a new112112- updater mark.113113-114114- f) Residue115115- Residue granularity will be descriptor based. The issued but not completed116116- transfers will be scanned for all of their descriptors against the117117- currently running descriptor.118118-119119- g) Most complicated case of driver's tx queues120120- The most tricky situation is when :121121- - there are not "acked" transfers (tx0)122122- - a driver submitted an aligned tx1, not chained123123- - a driver submitted an aligned tx2 => tx2 is cold chained to tx1124124- - a driver issued tx1+tx2 => channel is running in aligned mode125125- - a driver submitted an aligned tx3 => tx3 is hot-chained126126- - a driver submitted an unaligned tx4 => tx4 is put in submitted queue,127127- not chained128128- - a driver issued tx4 => tx4 is put in issued queue, not chained129129- - a driver submitted an aligned tx5 => tx5 is put in submitted queue, not130130- chained131131- - a driver submitted an aligned tx6 => tx6 is put in submitted queue,132132- cold chained to tx5133133-134134- This translates into (after tx4 is issued) :135135- - issued queue136136- +-----+ +-----+ +-----+ +-----+137137- | tx1 | | tx2 | | tx3 | | tx4 |138138- +---|-+ ^---|-+ ^-----+ +-----+139139- | | | |140140- +---+ +---+141141- - submitted queue142142- +-----+ +-----+143143- | tx5 | | tx6 |144144- +---|-+ ^-----+145145- | |146146- +---+147147- - completed queue : empty148148- - allocated queue : tx0149149-150150- It should be noted that after tx3 is completed, the channel is stopped, and151151- restarted in "unaligned mode" to handle tx4.152152-153153-Author: Robert Jarzmik <robert.jarzmik@free.fr>
+10
Documentation/driver-api/dmaengine/index.rst
···37373838 dmatest39394040+PXA DMA documentation4141+----------------------4242+4343+This book adds some notes about PXA DMA4444+4545+.. toctree::4646+ :maxdepth: 14747+4848+ pxa_dma4949+4050.. only:: subproject41514252 Indices
+190
Documentation/driver-api/dmaengine/pxa_dma.rst
···11+==============================22+PXA/MMP - DMA Slave controller33+==============================44+55+Constraints66+===========77+88+a) Transfers hot queuing99+A driver submitting a transfer and issuing it should be granted the transfer1010+is queued even on a running DMA channel.1111+This implies that the queuing doesn't wait for the previous transfer end,1212+and that the descriptor chaining is not only done in the irq/tasklet code1313+triggered by the end of the transfer.1414+A transfer which is submitted and issued on a phy doesn't wait for a phy to1515+stop and restart, but is submitted on a "running channel". The other1616+drivers, especially mmp_pdma waited for the phy to stop before relaunching1717+a new transfer.1818+1919+b) All transfers having asked for confirmation should be signaled2020+Any issued transfer with DMA_PREP_INTERRUPT should trigger a callback call.2121+This implies that even if an irq/tasklet is triggered by end of tx1, but2222+at the time of irq/dma tx2 is already finished, tx1->complete() and2323+tx2->complete() should be called.2424+2525+c) Channel running state2626+A driver should be able to query if a channel is running or not. For the2727+multimedia case, such as video capture, if a transfer is submitted and then2828+a check of the DMA channel reports a "stopped channel", the transfer should2929+not be issued until the next "start of frame interrupt", hence the need to3030+know if a channel is in running or stopped state.3131+3232+d) Bandwidth guarantee3333+The PXA architecture has 4 levels of DMAs priorities : high, normal, low.3434+The high priorities get twice as much bandwidth as the normal, which get twice3535+as much as the low priorities.3636+A driver should be able to request a priority, especially the real-time3737+ones such as pxa_camera with (big) throughputs.3838+3939+Design4040+======4141+a) Virtual channels4242+Same concept as in sa11x0 driver, ie. a driver was assigned a "virtual4343+channel" linked to the requestor line, and the physical DMA channel is4444+assigned on the fly when the transfer is issued.4545+4646+b) Transfer anatomy for a scatter-gather transfer4747+4848+::4949+5050+ +------------+-----+---------------+----------------+-----------------+5151+ | desc-sg[0] | ... | desc-sg[last] | status updater | finisher/linker |5252+ +------------+-----+---------------+----------------+-----------------+5353+5454+This structure is pointed by dma->sg_cpu.5555+The descriptors are used as follows :5656+5757+ - desc-sg[i]: i-th descriptor, transferring the i-th sg5858+ element to the video buffer scatter gather5959+6060+ - status updater6161+ Transfers a single u32 to a well known dma coherent memory to leave6262+ a trace that this transfer is done. The "well known" is unique per6363+ physical channel, meaning that a read of this value will tell which6464+ is the last finished transfer at that point in time.6565+6666+ - finisher: has ddadr=DADDR_STOP, dcmd=ENDIRQEN6767+6868+ - linker: has ddadr= desc-sg[0] of next transfer, dcmd=06969+7070+c) Transfers hot-chaining7171+Suppose the running chain is:7272+7373+::7474+7575+ Buffer 1 Buffer 27676+ +---------+----+---+ +----+----+----+---+7777+ | d0 | .. | dN | l | | d0 | .. | dN | f |7878+ +---------+----+-|-+ ^----+----+----+---+7979+ | |8080+ +----+8181+8282+After a call to dmaengine_submit(b3), the chain will look like:8383+8484+::8585+8686+ Buffer 1 Buffer 2 Buffer 38787+ +---------+----+---+ +----+----+----+---+ +----+----+----+---+8888+ | d0 | .. | dN | l | | d0 | .. | dN | l | | d0 | .. | dN | f |8989+ +---------+----+-|-+ ^----+----+----+-|-+ ^----+----+----+---+9090+ | | | |9191+ +----+ +----+9292+ new_link9393+9494+If while new_link was created the DMA channel stopped, it is _not_9595+restarted. Hot-chaining doesn't break the assumption that9696+dma_async_issue_pending() is to be used to ensure the transfer is actually started.9797+9898+One exception to this rule :9999+100100+- if Buffer1 and Buffer2 had all their addresses 8 bytes aligned101101+102102+- and if Buffer3 has at least one address not 4 bytes aligned103103+104104+- then hot-chaining cannot happen, as the channel must be stopped, the105105+ "align bit" must be set, and the channel restarted As a consequence,106106+ such a transfer tx_submit() will be queued on the submitted queue, and107107+ this specific case if the DMA is already running in aligned mode.108108+109109+d) Transfers completion updater110110+Each time a transfer is completed on a channel, an interrupt might be111111+generated or not, up to the client's request. But in each case, the last112112+descriptor of a transfer, the "status updater", will write the latest113113+transfer being completed into the physical channel's completion mark.114114+115115+This will speed up residue calculation, for large transfers such as video116116+buffers which hold around 6k descriptors or more. This also allows without117117+any lock to find out what is the latest completed transfer in a running118118+DMA chain.119119+120120+e) Transfers completion, irq and tasklet121121+When a transfer flagged as "DMA_PREP_INTERRUPT" is finished, the dma irq122122+is raised. Upon this interrupt, a tasklet is scheduled for the physical123123+channel.124124+125125+The tasklet is responsible for :126126+127127+- reading the physical channel last updater mark128128+129129+- calling all the transfer callbacks of finished transfers, based on130130+ that mark, and each transfer flags.131131+132132+If a transfer is completed while this handling is done, a dma irq will133133+be raised, and the tasklet will be scheduled once again, having a new134134+updater mark.135135+136136+f) Residue137137+Residue granularity will be descriptor based. The issued but not completed138138+transfers will be scanned for all of their descriptors against the139139+currently running descriptor.140140+141141+g) Most complicated case of driver's tx queues142142+The most tricky situation is when :143143+144144+ - there are not "acked" transfers (tx0)145145+146146+ - a driver submitted an aligned tx1, not chained147147+148148+ - a driver submitted an aligned tx2 => tx2 is cold chained to tx1149149+150150+ - a driver issued tx1+tx2 => channel is running in aligned mode151151+152152+ - a driver submitted an aligned tx3 => tx3 is hot-chained153153+154154+ - a driver submitted an unaligned tx4 => tx4 is put in submitted queue,155155+ not chained156156+157157+ - a driver issued tx4 => tx4 is put in issued queue, not chained158158+159159+ - a driver submitted an aligned tx5 => tx5 is put in submitted queue, not160160+ chained161161+162162+ - a driver submitted an aligned tx6 => tx6 is put in submitted queue,163163+ cold chained to tx5164164+165165+ This translates into (after tx4 is issued) :166166+167167+ - issued queue168168+169169+ ::170170+171171+ +-----+ +-----+ +-----+ +-----+172172+ | tx1 | | tx2 | | tx3 | | tx4 |173173+ +---|-+ ^---|-+ ^-----+ +-----+174174+ | | | |175175+ +---+ +---+176176+ - submitted queue177177+ +-----+ +-----+178178+ | tx5 | | tx6 |179179+ +---|-+ ^-----+180180+ | |181181+ +---+182182+183183+- completed queue : empty184184+185185+- allocated queue : tx0186186+187187+It should be noted that after tx3 is completed, the channel is stopped, and188188+restarted in "unaligned mode" to handle tx4.189189+190190+Author: Robert Jarzmik <robert.jarzmik@free.fr>