public inbox for linux-tegra@vger.kernel.org
 help / color / mirror / Atom feed
From: Dmitry Osipenko <digetx@gmail.com>
To: Akhil R <akhilrajeev@nvidia.com>,
	dan.j.williams@intel.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 v15 2/4] dmaengine: tegra: Add tegra gpcdma driver
Date: Thu, 16 Dec 2021 20:42:28 +0300	[thread overview]
Message-ID: <45ba3abe-5e7e-4917-2b23-0616a758c4eb@gmail.com> (raw)
In-Reply-To: <1639674720-18930-3-git-send-email-akhilrajeev@nvidia.com>

16.12.2021 20:11, Akhil R пишет:
> +static int tegra_dma_terminate_all(struct dma_chan *dc)
> +{
> +	struct tegra_dma_channel *tdc = to_tegra_dma_chan(dc);
> +	unsigned long wcount = 0;
> +	unsigned long status;
> +	unsigned long flags;
> +	int err;
> +
> +	raw_spin_lock_irqsave(&tdc->lock, flags);
> +
> +	if (!tdc->dma_desc) {
> +		raw_spin_unlock_irqrestore(&tdc->lock, flags);
> +		return 0;
> +	}
> +
> +	if (!tdc->busy)
> +		goto skip_dma_stop;
> +
> +	if (tdc->tdma->chip_data->hw_support_pause)
> +		err = tegra_dma_pause(tdc);
> +	else
> +		err = tegra_dma_stop_client(tdc);
> +
> +	if (err) {
> +		raw_spin_unlock_irqrestore(&tdc->lock, flags);
> +		return err;
> +	}
> +
> +	status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
> +	if (status & TEGRA_GPCDMA_STATUS_ISE_EOC) {
> +		dev_dbg(tdc2dev(tdc), "%s():handling isr\n", __func__);
> +		tegra_dma_xfer_complete(tdc);
> +		status = tdc_read(tdc, TEGRA_GPCDMA_CHAN_STATUS);
> +	}
> +
> +	wcount = tdc_read(tdc, TEGRA_GPCDMA_CHAN_XFER_COUNT);
> +	tegra_dma_stop(tdc);
> +
> +	tdc->dma_desc->bytes_transferred +=
> +			tdc->dma_desc->bytes_requested - (wcount * 4);
> +
> +skip_dma_stop:
> +	tegra_dma_sid_free(tdc);
> +	vchan_free_chan_resources(&tdc->vc);
> +	kfree(&tdc->vc);

You really going to kfree the head of tegra_dma_channel here? Once
again, this code was 100% untested :/

You're not allowed to free channel from the dma_terminate_all()
callback. This callback terminates submitted descs, that's it.

https://elixir.bootlin.com/linux/v5.16-rc5/source/include/linux/dmaengine.h#L1105

https://elixir.bootlin.com/linux/v5.16-rc5/source/drivers/i2c/busses/i2c-tegra.c#L962

  reply	other threads:[~2021-12-16 17:42 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-16 17:11 [PATCH v15 0/4] Add NVIDIA Tegra GPC-DMA driver Akhil R
2021-12-16 17:11 ` [PATCH v15 1/4] dt-bindings: dmaengine: Add doc for tegra gpcdma Akhil R
2021-12-16 17:11 ` [PATCH v15 2/4] dmaengine: tegra: Add tegra gpcdma driver Akhil R
2021-12-16 17:42   ` Dmitry Osipenko [this message]
2021-12-20 15:23     ` Akhil R
2021-12-20 16:30       ` Dmitry Osipenko
2021-12-16 17:11 ` [PATCH v15 3/4] arm64: defconfig: tegra: Enable GPCDMA Akhil R
2021-12-16 17:12 ` [PATCH v15 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=45ba3abe-5e7e-4917-2b23-0616a758c4eb@gmail.com \
    --to=digetx@gmail.com \
    --cc=akhilrajeev@nvidia.com \
    --cc=dan.j.williams@intel.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox