Re: [PATCH V4 2/3] dmaengine: tegra-adma: Add support for Tegra210 ADMA

Vinod Koul
2016-04-05T21:36:50Z

On Tue, Mar 15, 2016 at 03:56:29PM +0000, Jon Hunter wrote:

> +static void tegra_adma_request_free(struct tegra_adma_chan *tdc)
> +{
> + struct tegra_adma *tdma = tdc->tdma;
> +
> + if (!tdc->sreq_reserved)
> + return;
> +
> + switch (tdc->sreq_dir) {
> + case DMA_MEM_TO_DEV:
> + clear_bit(tdc->sreq_index, &tdma->tx_requests_reserved);
> + break;

empty line here woould be nicer

> + ret = dma_cookie_status(dc, cookie, txstate);
> + if (ret == DMA_COMPLETE || !txstate)
> + return ret;
> +
> + spin_lock_irqsave(&tdc->vc.lock, flags);
> +
> + vd = vchan_find_desc(&tdc->vc, cookie);
> + if (vd) {
> + desc = to_tegra_adma_desc(&vd->tx);
> + residual = desc->ch_regs.tc;

Here we are filling up residue for desc found in issued list

> + } else if (tdc->desc && tdc->desc->vd.tx.cookie == cookie) {
> + residual = tegra_adma_get_residue(tdc);

Well if it is not issued then why we we need to caluclate, its full size of
descriptor

> + } else {
> + residual = 0;

why this?

> +static struct dma_async_tx_descriptor *tegra_adma_prep_slave_sg(
> + struct dma_chan *dc, struct scatterlist *sgl, unsigned int sg_len,
> + enum dma_transfer_direction direction, unsigned long flags,
> + void *context)
> +{
> + struct tegra_adma_chan *tdc = to_tegra_adma_chan(dc);
> +
> + dev_warn(tdc2dev(tdc), "scatter-gather transfers are not supported\n");
> +
> + return NULL;
> +}

Why do we need this placeholder, If you dont support slave_sg dont add this
as capability

> +static const struct tegra_adma_chip_data tegra210_chip_data = {
> + .nr_channels = 22,
> +};

why should this be hard coded in kernel and not queried from something like
DT? This case seems to be hardware property

> + dma_cap_set(DMA_SLAVE, tdma->dma_dev.cap_mask);
> + dma_cap_set(DMA_PRIVATE, tdma->dma_dev.cap_mask);
> + dma_cap_set(DMA_CYCLIC, tdma->dma_dev.cap_mask);

I think you should not set DMA_SLAVE, do you need caps to be exported. I
think that should be exported for cyclic too, let me know if that was the
issue?

--
~Vinod