From: Vinod Koul <vinod.koul@intel.com>
To: Xiang Wang <wangxfdu@gmail.com>
Cc: Dan Williams <djbw@fb.com>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
cxie4@marvell.com, Xiang Wang <wangx@marvell.com>
Subject: Re: [PATCH V2] dma: mmp_pdma: support for getting residual bytes
Date: Mon, 29 Jul 2013 10:53:13 +0530 [thread overview]
Message-ID: <20130729052313.GB29095@intel.com> (raw)
In-Reply-To: <CACDNBm0HA_Ptgq_he-07-PpocZ6Qf7E+rP_W1yAFpSnmoZVaeQ@mail.gmail.com>
On Thu, Jul 11, 2013 at 10:54:29AM +0800, Xiang Wang wrote:
> >> +static u32 mmp_pdma_get_bytes_residue(struct mmp_pdma_chan *chan)
> >> +{
> >> + u32 reg, orig_pos, cur_pos, ddadr, residue = 0;
> >> + bool running_desc_found = false;
> >> + struct mmp_pdma_desc_sw *desc_sw;
> >> +
> >> + /*
> >> + * When a phy channel is unavailable, maybe it has been freed, return
> >> + * last stored value for safe.
> >> + */
> >> + if (!chan->phy)
> >> + return chan->bytes_residue;
> >> +
> >> + reg = (chan->phy->idx << 4) + DDADR;
> >> + ddadr = readl_relaxed(chan->phy->base + reg);
> >> +
> >> + /* iterate over all descriptors to sum up the number of pending bytes */
> > and why?
> >
> > Residue does not mean sum of all pending bytes across all descriptors submitted
> > You need to find the residue of current descriptor only and return
> >
> Here are my thoughts:
> We tell dma engine to transmit x bytes for us and it creates n
> descriptors to transmit which is transparent to us.
> So when we want to find out how many bytes are left, dma engine should
> sum up all pending bytes across all descriptors.
> What's your opinion?
but you may have multiple transactions submmited. Iterating over _all_
descriptors doesnt make sense then. You need to iterate over descriptors for
current transaction only.
> >> + list_for_each_entry(desc_sw, &chan->chain_running, node) {
> >> + /* for the case of a running descriptor */
> >> + if (desc_sw->desc.ddadr == ddadr && !running_desc_found) {
> >> + switch (chan->dir) {
> >> + case DMA_DEV_TO_MEM:
> >> + case DMA_MEM_TO_MEM:
> >> + reg = (chan->phy->idx << 4) + DTADR;
> >> + cur_pos = readl_relaxed(chan->phy->base + reg);
> >> + orig_pos = desc_sw->desc.dtadr;
> >> + break;
> >> +
> >> + case DMA_MEM_TO_DEV:
> >> + reg = (chan->phy->idx << 4) + DSADR;
> >> + cur_pos = readl_relaxed(chan->phy->base + reg);
> >> + orig_pos = desc_sw->desc.dsadr;
> >> + break;
> >> +
> >> + default:
> >> + cur_pos = 0;
> >> + orig_pos = 0;
> > This makes no sense...
> What do you recommend for the default case? Just return 0?
why should direction be anything other than these? This is error!
~Vinod
--
prev parent reply other threads:[~2013-07-29 6:03 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-06-18 8:41 [PATCH V2] dma: mmp_pdma: support for getting residual bytes Xiang Wang
2013-07-03 12:14 ` Xiang Wang
2013-07-05 6:44 ` Vinod Koul
2013-07-11 2:54 ` Xiang Wang
2013-07-29 5:23 ` Vinod Koul [this message]
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=20130729052313.GB29095@intel.com \
--to=vinod.koul@intel.com \
--cc=cxie4@marvell.com \
--cc=djbw@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=wangx@marvell.com \
--cc=wangxfdu@gmail.com \
/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