From: Sanjay R Mehta <sanmehta@amd.com>
To: Vinod Koul <vkoul@kernel.org>, 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: Tue, 26 May 2020 12:18:39 +0530 [thread overview]
Message-ID: <b88126b6-0f5a-8b5c-1cb4-444d854f8af9@amd.com> (raw)
In-Reply-To: <20200504061445.GK1375924@vkoul-mobl>
On 5/4/2020 11:44 AM, Vinod Koul wrote:
> [CAUTION: External Email]
>
> 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.
>
Sure, will incorporate the changes in the next version of patch.
>> +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..
Right.
>> +
>> + 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
>
Here before making call to issue next cmd, "vchan_vdesc_fini()" is been used in place of
vchan_cookie_complete() in the pt_handle_active_desc() function.
>> +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
>
Sure, will incorporate the changes in the next version of patch.
>> + 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
>
Sure, will incorporate the changes in the next version of patch.
>> +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!
>
Sure, will incorporate the changes in the next version of patch.
>> +
>> + 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?
You are right. will remove channel status from here.
> --
> ~Vinod
>
next prev parent reply other threads:[~2020-05-26 6:49 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
2020-05-26 6:48 ` Sanjay R Mehta [this message]
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=b88126b6-0f5a-8b5c-1cb4-444d854f8af9@amd.com \
--to=sanmehta@amd.com \
--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 \
--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;
as well as URLs for NNTP newsgroup(s).