All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Akhil R <akhilrajeev@nvidia.com>,
	devicetree@vger.kernel.org, dmaengine@vger.kernel.org,
	jonathanh@nvidia.com, kyarlagadda@nvidia.com,
	ldewangan@nvidia.com, linux-kernel@vger.kernel.org,
	linux-tegra@vger.kernel.org, p.zabel@pengutronix.de,
	rgumasta@nvidia.com, robh+dt@kernel.org,
	thierry.reding@gmail.com, vkoul@kernel.org
Cc: Pavan Kunapuli <pkunapuli@nvidia.com>
Subject: Re: [PATCH v18 2/4] dmaengine: tegra: Add tegra gpcdma driver
Date: Wed, 2 Feb 2022 18:45:09 +0300	[thread overview]
Message-ID: <3feaa359-31bb-bb07-75d7-2a39c837a7a2@gmail.com> (raw)
In-Reply-To: <1643729199-19161-3-git-send-email-akhilrajeev@nvidia.com>

....
> +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?

  reply	other threads:[~2022-02-02 15:45 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-02-01 15:26 [PATCH v18 0/4] Add NVIDIA Tegra GPC-DMA driver Akhil R
2022-02-01 15:26 ` [PATCH v18 1/4] dt-bindings: dmaengine: Add doc for tegra gpcdma Akhil R
2022-02-01 15:26 ` [PATCH v18 2/4] dmaengine: tegra: Add tegra gpcdma driver Akhil R
2022-02-02 15:45   ` Dmitry Osipenko [this message]
2022-02-03  3:44     ` Akhil R
2022-02-03 18:22       ` Dmitry Osipenko
2022-02-04  6:47         ` Akhil R
2022-02-04 12:15           ` Dmitry Osipenko
2022-02-04 12:28             ` Dmitry Osipenko
2022-02-03  0:18   ` kernel test robot
2022-02-01 15:26 ` [PATCH v18 3/4] arm64: defconfig: tegra: Enable GPCDMA Akhil R
2022-02-01 15:26 ` [PATCH v18 4/4] arm64: tegra: Add GPCDMA node for tegra186 and tegra194 Akhil R

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=3feaa359-31bb-bb07-75d7-2a39c837a7a2@gmail.com \
    --to=digetx@gmail.com \
    --cc=akhilrajeev@nvidia.com \
    --cc=devicetree@vger.kernel.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kyarlagadda@nvidia.com \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=p.zabel@pengutronix.de \
    --cc=pkunapuli@nvidia.com \
    --cc=rgumasta@nvidia.com \
    --cc=robh+dt@kernel.org \
    --cc=thierry.reding@gmail.com \
    --cc=vkoul@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.