linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Vinod Koul <vinod.koul@intel.com>
To: Andy Shevchenko <andy.shevchenko@gmail.com>
Cc: Andy Shevchenko <andriy.shevchenko@linux.intel.com>,
	"linux-acpi@vger.kernel.org" <linux-acpi@vger.kernel.org>,
	"linux-pm@vger.kernel.org" <linux-pm@vger.kernel.org>,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Lee Jones <lee.jones@linaro.org>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	dmaengine <dmaengine@vger.kernel.org>,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>,
	mturquette@baylibre.com
Subject: Re: [PATCH v5 7/8] dmaengine: add a driver for Intel integrated DMA 64-bit
Date: Tue, 21 Jul 2015 10:20:55 +0530	[thread overview]
Message-ID: <20150721045055.GG23525@localhost> (raw)
In-Reply-To: <CAHp75VcMej=a0pLT61hbnHmTvY7Mn_aBrrk0Rq0nYbU7e_C67A@mail.gmail.com>

On Mon, Jul 20, 2015 at 11:46:28AM +0300, Andy Shevchenko wrote:
> >> +static void idma64_chan_init(struct idma64 *idma64, struct idma64_chan *idma64c)
> >> +{
> >> +     u32 cfghi = IDMA64C_CFGH_SRC_PER(1) | IDMA64C_CFGH_DST_PER(0);
> >> +     u32 cfglo = 0;
> >> +
> >> +     /* Enforce FIFO drain when channel is suspended */
> >> +     cfglo |= IDMA64C_CFGL_CH_DRAIN;
> >> +
> >> +     /* Set default burst alignment */
> >> +     cfglo |= IDMA64C_CFGL_DST_BURST_ALIGN | IDMA64C_CFGL_SRC_BURST_ALIGN;
> >> +
> >> +     channel_writel(idma64c, CFG_LO, cfglo);
> >> +     channel_writel(idma64c, CFG_HI, cfghi);
> >> +
> >> +     /* Enable interrupts */
> >> +     channel_set_bit(idma64, MASK(XFER), idma64c->mask);
> >> +     channel_set_bit(idma64, MASK(ERROR), idma64c->mask);
> >> +
> >> +     /*
> >> +      * Enforce the controller to be turned on.
> >> +      *
> >> +      * The iDMA is turned off in ->probe() and looses context during system
> >> +      * suspend / resume cycle. That's why we have to enable it each time we
> >> +      * use it.
> >> +      */
> >> +     idma64_on(idma64);
> > would it be better that you do this in resume and runtime_resume cycle. That
> > way it need not be called for every channel init
> 
> Mika, I don't remember details here, but this piece came from you. Can
> you shed a light?
> 
> My understanding that DMA IP is private to the host controller and has
> the same power rail. Thus, there is no need to do separate power
> management for it, which makes things more complicated for no profit.
> It is also needed for time period from probe till first transfer
> (otherwise we have to check the status of DMA anyway and enable it if
> required), which currently remains DMA off.
so who does runtime management of this power rail and whosoever does that
how do they ensure the dma is not active at that time?

> 
> >
> >> +static size_t idma64_desc_size(struct idma64_desc *desc, unsigned int active)
> >> +{
> >> +     size_t bytes = 0;
> >> +     unsigned int i;
> >> +
> >> +     for (i = active; i < desc->ndesc; i++)
> >> +             bytes += desc->hw[i].len;
> > it can help for the non active case to have this size stored in desc while
> > preparing, that gets rid of runtime calculation for that case
> 
> I don't see much improvement, since it's a rare cases, but waste of
> memory. If you consider that should be done I can implement it.
The users of timing information will invoke this in non sleeping context so
it will help in using one more variable, maybe a good trade off. Also if
this is a rare case do you have use of this calculation and code?

> >> +static int idma64_terminate_all(struct dma_chan *chan)
> >> +{
> >> +     struct idma64_chan *idma64c = to_idma64_chan(chan);
> >> +     unsigned long flags;
> >> +     LIST_HEAD(head);
> >> +
> >> +     spin_lock_irqsave(&idma64c->vchan.lock, flags);
> >> +     idma64_stop_transfer(idma64c);
> > I dont think this is the right method for terminate. Can you check, it
> > might be that we have to suspend the channel before terminating an active
> > one. For non active case this should be okay
> 
> Do you mean hardware can become into wrong state?
Yes at least that was true for 32bit version of this IP

> Only what can actually happen is the data loss which is in DMA FIFO,
> but we already know we would like to terminate the transfer we don't
> care about any data loss since that.
The terminate flow expect you to suspend the channel first and then terminate

> >> +static const struct dev_pm_ops idma64_dev_pm_ops = {
> >> +     SET_LATE_SYSTEM_SLEEP_PM_OPS(idma64_suspend_late, idma64_resume_early)
> > any reason why late ops?
> 
> We already discussed this several times. There is no dependency
> between DMA and its users during PM cycles. We have to be sure that
> device (host controller) is quiescent before we stop DMA.
And the realities change! you should be looking at deferred probing for this
rather than using late ops. Clients should be suspended first which means
they should be probed last and in the probe ensure all the resources (dma)
are available if not defer the probe.

-- 
~Vinod

  reply	other threads:[~2015-07-21  4:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-06 12:22 [PATCH v5 0/8] mfd: introduce a driver for LPSS devices on SPT Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 1/8] PM / QoS: Make it possible to expose device latency tolerance to userspace Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 2/8] ACPI / PM: Attach ACPI power domain only once Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 3/8] Driver core: wakeup the parent device before trying probe Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 4/8] klist: implement klist_prev() Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 5/8] driver core: implement device_for_each_child_reverse() Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 6/8] mfd: make mfd_remove_devices() iterate in reverse order Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 7/8] dmaengine: add a driver for Intel integrated DMA 64-bit Andy Shevchenko
2015-07-17  4:38   ` Vinod Koul
2015-07-20  8:46     ` Andy Shevchenko
2015-07-21  4:50       ` Vinod Koul [this message]
2015-07-21  7:08         ` Andy Shevchenko
2015-07-22  4:57           ` Vinod Koul
2015-07-23  8:50             ` Andy Shevchenko
2015-07-06 12:22 ` [PATCH v5 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices Andy Shevchenko
2015-07-24 15:14   ` Lee Jones
2015-07-15 12:15 ` [PATCH v5 0/8] mfd: introduce a driver for LPSS devices on SPT Andy Shevchenko
2015-07-16 13:28   ` Vinod Koul
2015-07-16 13:55     ` Andy Shevchenko
2015-07-23 11:40 ` Andy Shevchenko
2015-07-24 15:16   ` Lee Jones
2015-07-24 15:29     ` Andy Shevchenko

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=20150721045055.GG23525@localhost \
    --to=vinod.koul@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=andriy.shevchenko@linux.intel.com \
    --cc=andy.shevchenko@gmail.com \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=mturquette@baylibre.com \
    --cc=rafael.j.wysocki@intel.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;
as well as URLs for NNTP newsgroup(s).