All of lore.kernel.org
 help / color / mirror / Atom feed
From: Vinod Koul <vkoul@kernel.org>
To: Sanjay R Mehta <Sanju.Mehta@amd.com>
Cc: gregkh@linuxfoundation.org, dan.j.williams@intel.com,
	Thomas.Lendacky@amd.com, Shyam-sundar.S-k@amd.com,
	Nehal-bakulchandra.Shah@amd.com, robh@kernel.org,
	mchehab+samsung@kernel.org, davem@davemloft.net,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org
Subject: Re: [PATCH v4 2/3] dmaengine: ptdma: register PTDMA controller as a DMA resource
Date: Mon, 4 May 2020 11:44:45 +0530	[thread overview]
Message-ID: <20200504061445.GK1375924@vkoul-mobl> (raw)
In-Reply-To: <1588108416-49050-3-git-send-email-Sanju.Mehta@amd.com>

On 28-04-20, 16:13, Sanjay R Mehta wrote:

> +static void pt_do_cmd_complete(unsigned long data)
> +{
> +	struct pt_tasklet_data *tdata = (struct pt_tasklet_data *)data;
> +	struct pt_cmd *cmd = tdata->cmd;
> +	struct pt_cmd_queue *cmd_q = &cmd->pt->cmd_q;
> +	u32 tail;
> +
> +	tail = lower_32_bits(cmd_q->qdma_tail + cmd_q->qidx * Q_DESC_SIZE);
> +	if (cmd_q->cmd_error) {
> +	       /*
> +		* Log the error and flush the queue by
> +		* moving the head pointer
> +		*/
> +		pt_log_error(cmd_q->pt, cmd_q->cmd_error);
> +		iowrite32(tail, cmd_q->reg_head_lo);
> +	}
> +
> +	cmd->pt_cmd_callback(cmd->data, cmd->ret);

So in the isr you schedule this tasklet and this invokes the calback..
this is very inefficient.

You should submit the next txn to dmaengine in your isr, keeping the dma
idle at this point is very inefficient.

> +static void pt_cmd_callback(void *data, int err)
> +{
> +	struct pt_dma_desc *desc = data;
> +	struct pt_dma_chan *chan;
> +	int ret;

This is called as callback from pt layer..
> +
> +	if (err == -EINPROGRESS)
> +		return;
> +
> +	chan = container_of(desc->vd.tx.chan, struct pt_dma_chan,
> +			    vc.chan);
> +
> +	dev_dbg(chan->pt->dev, "%s - tx %d callback, err=%d\n",
> +		__func__, desc->vd.tx.cookie, err);
> +
> +	if (err)
> +		desc->status = DMA_ERROR;
> +
> +	while (true) {
> +		/* Check for DMA descriptor completion */
> +		desc = pt_handle_active_desc(chan, desc);
> +
> +		/* Don't submit cmd if no descriptor or DMA is paused */
> +		if (!desc || chan->status == DMA_PAUSED)
> +			break;
> +
> +		ret = pt_issue_next_cmd(desc);

And you call this to issue next cmd... The missing thing I am seeing
here is vchan_cookie_complete() you need to call that here for correct
vchan list mgmt

> +static struct pt_dma_desc *pt_create_desc(struct dma_chan *dma_chan,
> +					  struct scatterlist *dst_sg,
> +					    unsigned int dst_nents,
> +					    struct scatterlist *src_sg,
> +					    unsigned int src_nents,
> +					    unsigned long flags)

unaligned add indentation! Pls run checkpatch --strict to check for
these oddities

> +	dma_dev->dev = pt->dev;
> +	dma_dev->src_addr_widths = PT_DMA_WIDTH(dma_get_mask(pt->dev));
> +	dma_dev->dst_addr_widths = PT_DMA_WIDTH(dma_get_mask(pt->dev));
> +	dma_dev->directions = DMA_MEM_TO_MEM;
> +	dma_dev->residue_granularity = DMA_RESIDUE_GRANULARITY_DESCRIPTOR;
> +	dma_cap_set(DMA_MEMCPY, dma_dev->cap_mask);
> +	dma_cap_set(DMA_INTERRUPT, dma_dev->cap_mask);
> +	dma_cap_set(DMA_PRIVATE, dma_dev->cap_mask);
> +
> +	INIT_LIST_HEAD(&dma_dev->channels);
> +
> +	chan = pt->pt_dma_chan;
> +	chan->pt = pt;
> +	dma_chan = &chan->vc.chan;
> +
> +	dma_dev->device_free_chan_resources = pt_free_chan_resources;
> +	dma_dev->device_prep_dma_memcpy = pt_prep_dma_memcpy;
> +	dma_dev->device_prep_dma_interrupt = pt_prep_dma_interrupt;
> +	dma_dev->device_issue_pending = pt_issue_pending;
> +	dma_dev->device_tx_status = pt_tx_status;
> +	dma_dev->device_pause = pt_pause;
> +	dma_dev->device_resume = pt_resume;
> +	dma_dev->device_terminate_all = pt_terminate_all;

Pls implement .device_synchronize as well

> +struct pt_dma_desc {
> +	struct virt_dma_desc vd;
> +
> +	struct pt_device *pt;
> +
> +	struct list_head pending;
> +	struct list_head active;

why not use vc->desc_submitted, desc_issued instead!

> +
> +	enum dma_status status;
> +
> +	size_t len;
> +};
> +
> +struct pt_dma_chan {
> +	struct virt_dma_chan vc;
> +
> +	struct pt_device *pt;
> +
> +	enum dma_status status;

channel status as well as desc, why do you need both?
-- 
~Vinod

  reply	other threads:[~2020-05-04  6:14 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-04-28 21:13 [PATCH v4 0/3] Add support for AMD PTDMA controller driver Sanjay R Mehta
2020-04-28 21:13 ` [PATCH v4 1/3] dmaengine: ptdma: Initial driver for the AMD PTDMA controller Sanjay R Mehta
2020-05-04  5:55   ` Vinod Koul
2020-05-26  6:05     ` Sanjay R Mehta
2020-05-26  6:29       ` Greg KH
2020-05-26  6:36         ` Sanjay R Mehta
2020-04-28 21:13 ` [PATCH v4 2/3] dmaengine: ptdma: register PTDMA controller as a DMA resource Sanjay R Mehta
2020-05-04  6:14   ` Vinod Koul [this message]
2020-05-26  6:48     ` Sanjay R Mehta
2020-04-28 21:13 ` [PATCH v4 3/3] dmaengine: ptdma: Add debugfs entries for PTDMA information Sanjay R Mehta
2020-05-04  6:20   ` Vinod Koul
2020-05-26  6:10     ` Sanjay R Mehta

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=20200504061445.GK1375924@vkoul-mobl \
    --to=vkoul@kernel.org \
    --cc=Nehal-bakulchandra.Shah@amd.com \
    --cc=Sanju.Mehta@amd.com \
    --cc=Shyam-sundar.S-k@amd.com \
    --cc=Thomas.Lendacky@amd.com \
    --cc=dan.j.williams@intel.com \
    --cc=davem@davemloft.net \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mchehab+samsung@kernel.org \
    --cc=robh@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.