Re: [PATCH v2] dmaengine: add CSR SiRFprimaII DMAC driver

From: Barry Song
Date: Sat Sep 17 2011 - 10:58:18 EST


2011/9/17 Jassi Brar <jassisinghbrar@xxxxxxxxx>:
> On Fri, Sep 16, 2011 at 3:26 PM, Barry Song <Baohua.Song@xxxxxxx> wrote:
>
>> +static int sirfsoc_dma_slave_config(struct sirfsoc_dma_chan *schan,
>> + Â Â Â struct dma_slave_config *config)
>> +{
>> + Â Â Â u32 addr, direction;
>> + Â Â Â unsigned long flags;
>> +
>> + Â Â Â switch (config->direction) {
>> + Â Â Â case DMA_FROM_DEVICE:
>> + Â Â Â Â Â Â Â direction = 0;
>> + Â Â Â Â Â Â Â addr = config->dst_addr;
>> + Â Â Â Â Â Â Â break;
>> +
>> + Â Â Â case DMA_TO_DEVICE:
>> + Â Â Â Â Â Â Â direction = 1;
>> + Â Â Â Â Â Â Â addr = config->src_addr;
>> + Â Â Â Â Â Â Â break;
>> +
>> + Â Â Â default:
>> + Â Â Â Â Â Â Â return -EINVAL;
>> + Â Â Â }
>> +
>> + Â Â Â if ((config->src_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES) ||
>> + Â Â Â Â Â Â Â (config->dst_addr_width != DMA_SLAVE_BUSWIDTH_4_BYTES))
>> + Â Â Â Â Â Â Â return -EINVAL;
>> +
>> + Â Â Â spin_lock_irqsave(&schan->lock, flags);
>> + Â Â Â schan->addr = addr;
>> + Â Â Â schan->direction = direction;
>> + Â Â Â schan->mode = (config->src_maxburst == 4 ? 1 : 0);
>> + Â Â Â spin_unlock_irqrestore(&schan->lock, flags);
>> +
>> + Â Â Â return 0;
>> +}
> You don't need to pass as much info via dma_slave_config as you do here.
>
> dmaxfer_template.src_inc Â&& !dmaxfer_template.dst_inc Â=> DMA_TO_DEVICE
> !dmaxfer_template.src_inc Â&& dmaxfer_template.dst_inc Â=> DMA_FROM_DEVICE

it seems direct DMA_TO_DEVICE/DMA_FROM_DEVICE is more feasible and
explict to me. "dmaxfer_template.src_inc &&
!dmaxfer_template.dst_inc" is probably DMA_TO_DEVICE, but it is not
always true for all scenerios to all kinds of devices. anyway, for my
case, they are always true. so i can use them.

>
> Pass addresses using dmaxfer_template.src_start and dmaxfer_template.dst_start
> instead of dma_slave_config.dst_addr and dma_slave_config.src_addr
>
> So, currently you need dma_slave_config only to pass src_addr_width,
> dst_addr_width and src_maxburst to the dmac driver.

i agree that can decrease the calling of config. let the genxfer
decide the address of every transfer should be more flexible.

>
>
>> +
>> +static struct dma_async_tx_descriptor *sirfsoc_dma_prep_slave_sg(
>> + Â Â Â struct dma_chan *chan, struct scatterlist *sgl,
>> + Â Â Â unsigned int sg_len, enum dma_data_direction direction,
>> + Â Â Â unsigned long flags)
>> +{
>> + Â Â Â return NULL;
>> +}
>> +
> In v3 I'll remove the BUG_ON check that requires every SLAVE channel
> provides device_prep_slave_sg, so you should be able to simply discard
> this stub.

ok, that is going to make the api better.

-barry
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/