[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 2 Feb 2022 18:45:09 +0300
From: Dmitry Osipenko <digetx@...il.com>
To: Akhil R <akhilrajeev@...dia.com>, devicetree@...r.kernel.org,
dmaengine@...r.kernel.org, jonathanh@...dia.com,
kyarlagadda@...dia.com, ldewangan@...dia.com,
linux-kernel@...r.kernel.org, linux-tegra@...r.kernel.org,
p.zabel@...gutronix.de, rgumasta@...dia.com, robh+dt@...nel.org,
thierry.reding@...il.com, vkoul@...nel.org
Cc: Pavan Kunapuli <pkunapuli@...dia.com>
Subject: Re: [PATCH v18 2/4] dmaengine: tegra: Add tegra gpcdma driver
....
> +static int tegra_dma_pause(struct tegra_dma_channel *tdc)
> +{
> + int ret;
> + u32 val;
> +
> + val = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSRE);
> + val |= TEGRA_GPCDMA_CHAN_CSRE_PAUSE;
> + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSRE, val);
> +
> + /* Wait until busy bit is de-asserted */
> + ret = readl_relaxed_poll_timeout_atomic(tdc->tdma->base_addr +
> + tdc->chan_base_offset + TEGRA_GPCDMA_CHAN_STATUS,
> + val,
> + !(val & TEGRA_GPCDMA_STATUS_BUSY),
> + TEGRA_GPCDMA_BURST_COMPLETE_TIME,
> + TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT);
> +
> + return ret;
> +}
> +
> +static int tegra_dma_device_pause(struct dma_chan *dc)
> +{
> + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
> + unsigned long flags;
> + int ret = 0;
> +
> + if (!tdc->tdma->chip_data->hw_support_pause)
> + return -ENOSYS;
> +
> + spin_lock_irqsave(&tdc->vc.lock, flags);
> + ret = tegra_dma_pause(tdc);
> + if (ret)
> + dev_err(tdc2dev(tdc), "DMA pause timed out\n");
Why error message shouldn't be printed by tegra_dma_terminate_all()?
The error message should be placed inside of tegra_dma_pause().
...
> +static int tegra_dma_stop_client(struct tegra_dma_channel *tdc)
> +{
> + int ret;
> + unsigned long status;
> + u32 csr = tdc_read(tdc, TEGRA_GPCDMA_CHAN_CSR);
> +
> + /*
> + * Change the client associated with the DMA channel
> + * to stop DMA engine from starting any more bursts for
> + * the given client and wait for in flight bursts to complete
> + */
> + csr &= ~(TEGRA_GPCDMA_CSR_REQ_SEL_MASK);
> + csr |= TEGRA_GPCDMA_CSR_REQ_SEL_UNUSED;
> + tdc_write(tdc, TEGRA_GPCDMA_CHAN_CSR, csr);
> +
> + /* Wait for in flight data transfer to finish */
> + udelay(TEGRA_GPCDMA_BURST_COMPLETE_TIME);
> +
> + /* If TX/RX path is still active wait till it becomes
> + * inactive
> + */
> +
> + ret = readl_relaxed_poll_timeout_atomic(tdc->tdma->base_addr +
> + tdc->chan_base_offset +
> + TEGRA_GPCDMA_CHAN_STATUS,
> + status,
> + !(status & (TEGRA_GPCDMA_STATUS_CHANNEL_TX |
> + TEGRA_GPCDMA_STATUS_CHANNEL_RX)),
> + 5,
> + TEGRA_GPCDMA_BURST_COMPLETION_TIMEOUT);
> + if (ret) {
> + dev_err(tdc2dev(tdc), "Timeout waiting for DMA burst completion!\n");
> + tegra_dma_dump_chan_regs(tdc);
> + }
> +
> + return ret;
> +}
> +
> +static int tegra_dma_terminate_all(struct dma_chan *dc)
> +{
> + struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
> + unsigned long flags;
> + LIST_HEAD(head);
> + int err;
> +
> + spin_lock_irqsave(&tdc->vc.lock, flags);
> +
> + if (tdc->dma_desc) {
> + err = tdc->tdma->chip_data->hw_support_pause ?
> + tegra_dma_pause(tdc) :
> + tegra_dma_stop_client(tdc);
The canonical coding style is:
if (tdc->tdma->chip_data->hw_support_pause)
err = tegra_dma_pause(tdc);
else
err = tegra_dma_stop_client(tdc);
But why do you need to pause at all here and can't use
tegra_dma_stop_client() even if pause is supported?
Powered by blists - more mailing lists