[PATCH] dmaengine: add CSR SiRFprimaII DMAC driver

Barry Song 21cnbao at gmail.com
Fri Sep 16 05:06:34 EDT 2011


>>> +/* Interrupt handler */
>>> +static irqreturn_t sirfsoc_dma_irq(int irq, void *data)
>>> +{
>>> +     struct sirfsoc_dma *sdma = data;
>>> +     struct sirfsoc_dma_chan *schan;
>>> +     u32 is;
>>> +     int ch;
>>> +
>>> +     is = readl_relaxed(sdma->regs + SIRFSOC_DMA_CH_INT);
>>> +     while ((ch = fls(is) - 1) >= 0) {
>>> +             is &= ~(1 << ch);
>>> +             writel_relaxed(1 << ch, sdma->regs + SIRFSOC_DMA_CH_INT);
>>> +             schan = &sdma->channels[ch];
>>> +
>>> +             spin_lock(&schan->lock);
>>> +
>>> +             /* Execute queued descriptors */
>>> +             list_splice_tail_init(&schan->active, &schan->completed);
>>> +             if (!list_empty(&schan->queued))
>>> +                     sirfsoc_dma_execute(schan);
>>> +
>>> +             spin_unlock(&schan->lock);
>>> +     }
>> Here you know which channel has triggered interrupt and you may pass
>> this info to your tasklet and avoid scanning again there
>
> ok. let me see.

we really know what channels have been trigger in irq. but we lose a
good way to transfer that to tasklet actually. if we place a flag in
schan data.
1. there can be more 1 channels triggers, then tasklet still need a for(...)
2. we actually need a lock between irq and tasklet. otherwise, new irq
coming in tasklet might change the flag.

so i think current way should be better.

>
>>
>>> +
>>> +     /* Schedule tasklet */
>>> +     tasklet_schedule(&sdma->tasklet);
>>> +
>>> +     return IRQ_HANDLED;
>>> +}
>>> +
>>> +/* process completed descriptors */
>>> +static void sirfsoc_dma_process_completed(struct sirfsoc_dma *sdma)
>>> +{
>>> +     dma_cookie_t last_cookie = 0;
>>> +     struct sirfsoc_dma_chan *schan;
>>> +     struct sirfsoc_dma_desc *mdesc;
>>> +     struct dma_async_tx_descriptor *desc;
>>> +     unsigned long flags;
>>> +     LIST_HEAD(list);
>>> +     int i;
>>> +
>>> +     for (i = 0; i < sdma->dma.chancnt; i++) {
>>> +             schan = &sdma->channels[i];
>>> +
>>> +             /* Get all completed descriptors */
>>> +             spin_lock_irqsave(&schan->lock, flags);
>> this will block interrupts, i dont see a reason why this should be used
>> here??
>
> ok. no irq is accessing completed list.

sorry. after reading more carefully, we actually need this lock since
irq will move finished active node to completed list. we need to keep
the completed safe.

i have fixed other issues and used jassi's v1 patch (generic xfer) and
will send v2.

Thanks
barry



More information about the linux-arm-kernel mailing list