All of lore.kernel.org
 help / color / mirror / Atom feed
From: lee.jones@linaro.org (Lee Jones)
To: linux-arm-kernel@lists.infradead.org
Subject: [PATCH 3/8] dmaengine: ste_dma40: Actually write the runtime configuration to registers
Date: Mon, 15 Apr 2013 15:28:24 +0100	[thread overview]
Message-ID: <20130415142824.GG6512@gmail.com> (raw)
In-Reply-To: <CACRpkdawUPPzh-EgVdmvOVP2SOjgKXYrfus=yMee7n+PtAQPHg@mail.gmail.com>

On Mon, 15 Apr 2013, Linus Walleij wrote:

> On Mon, Apr 15, 2013 at 1:59 PM, Lee Jones <lee.jones@linaro.org> wrote:
> > On Mon, 15 Apr 2013, Rabin Vincent wrote:
> >> 2013/4/15 Lee Jones <lee.jones@linaro.org>:
> >> > On Fri, 12 Apr 2013, Rabin Vincent wrote:
> >> >> 2013/4/9 Lee Jones <lee.jones@linaro.org>:
> >> >> > Someone has spent a fair amount of effort writing a runtime configuration
> >> >> > changing algorithm for DMA clients. However, the config appears to never
> >> >> > actually make it to hardware. In order for the configuration to take hold
> >> >> > we need to issue a d40_config_write(), as this is the routine which writes
> >> >> > it into the hardware's registers.
> >> >>
> >> >> No, it's not.  This function is only for initial configuration which
> >> >> should only be written when the channel is allocated.  In fact, by
> >> >> calling it here in runtime_config, you are introducing a serious bug:
> >> >> other logical channels on the same physical channel will stop because of
> >> >> the SSLNK/SDLNK of the physical channel being zeroed.
> >> >>
> >> >> The runtime config already makes it the hardware in the existing code,
> >> >> via d40_*_cfg().
> >> >
> >> > Sorry Rabin, but the only place I can see the config being written is
> >> > in d40_config_write().
> >> >
> >> > Can you paste the line of code in d40_*_cfg() which actually writes
> >> > the config to hardware please? I don't see it.
> >>
> >> It's not that simple.  There are some pointers passed to d40_*_cfg() and
> >> that function writes the configuration to the variables those pointers
> >> point to (d40c->log_def.lcsp1, d40c->src_def_cfg, etc.).  Please read
> >> the code to see how those variables end up being used later when the
> >> LLIs are prepared for the HW.
> >
> > I have read the code, which is why I know that the config only gets
> > written in d40_config_write(). :)
> >
> > So the configuration which gets set in the runtime_config routine
> > doesn't ever make it to hardware - hence this patch.
> >
> > Unless I'm missing something?
> 
> The runtime config sets up the config for all *subsequent* jobs.
> struct d40_chan contains e.g. runtime_addr, runtime_direction
> etc to store up the stuff being configured. This is done for
> all the other config as well using d40_log_cfg() or
> d40_phy_cfg(), and the result is cached in the channel
> struct, here called d40c.
> 
> Next, when preparing jobs, the DMA40 LLI engine will fill in
> job descriptors using e.g. d40_get_dev_addr()
> and pick settings from this cached runtime config.
> 
> When the subsequent jobs trigger, it allocates channel resources
> by calling d40_alloc_chan_resources(). The config is written to the
> hardware by calling d40_config_write().
> 
> So the basic misunderstanding here is that you think
> the config shall take effect immediately, that is not the
> idea. The configuration will be cached in the channel
> struct, then it will take effect when the next job that is
> queued up allocates its resources to commence.
> 
> Maybe you haven't grasped the asynchronous nature
> of the DMAengine? It's a bit like multithreading. You
> queue up things, then they commence at a later time.
> Not immediately.
> 
> Example: the SPI driver for PL022 may talk to a
> 8, 16 or 32bit capable device. Depending on which device
> it wants to queue a job for, it need to be configured differently,
> like for another width.
> 
> At the time you are queueing a new job, another job may
> already be in flight. If you issue d40_config_write() at this
> point, you will cause undesired effects to the job that may
> already be running. Such as reconfiguring the width
> of the channel.
> 
> You may not observe that bug because there is no
> job in flight, or because the actual configuration is identical
> for two consecutive jobs, but if you're really stressing something,
> queuing jobs while others are already in flight, you will
> see it immediately.
> 
> Therefore, this patch should be dropped.

Ah right, thanks for your explanation.

I have also just finished speaking to Rabin privately, who painted a
good picture of how the configuration side of this driver should
work.

I have dropped this patch and will shortly be replacing it with
something else.

Thanks again to both of you.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org ? Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

WARNING: multiple messages have this Message-ID (diff)
From: Lee Jones <lee.jones@linaro.org>
To: Linus Walleij <linus.walleij@linaro.org>
Cc: Rabin Vincent <rabin@rab.in>,
	"linux-arm-kernel@lists.infradead.org" 
	<linux-arm-kernel@lists.infradead.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	Arnd Bergmann <arnd@arndb.de>,
	Linus WALLEIJ <linus.walleij@stericsson.com>
Subject: Re: [PATCH 3/8] dmaengine: ste_dma40: Actually write the runtime configuration to registers
Date: Mon, 15 Apr 2013 15:28:24 +0100	[thread overview]
Message-ID: <20130415142824.GG6512@gmail.com> (raw)
In-Reply-To: <CACRpkdawUPPzh-EgVdmvOVP2SOjgKXYrfus=yMee7n+PtAQPHg@mail.gmail.com>

On Mon, 15 Apr 2013, Linus Walleij wrote:

> On Mon, Apr 15, 2013 at 1:59 PM, Lee Jones <lee.jones@linaro.org> wrote:
> > On Mon, 15 Apr 2013, Rabin Vincent wrote:
> >> 2013/4/15 Lee Jones <lee.jones@linaro.org>:
> >> > On Fri, 12 Apr 2013, Rabin Vincent wrote:
> >> >> 2013/4/9 Lee Jones <lee.jones@linaro.org>:
> >> >> > Someone has spent a fair amount of effort writing a runtime configuration
> >> >> > changing algorithm for DMA clients. However, the config appears to never
> >> >> > actually make it to hardware. In order for the configuration to take hold
> >> >> > we need to issue a d40_config_write(), as this is the routine which writes
> >> >> > it into the hardware's registers.
> >> >>
> >> >> No, it's not.  This function is only for initial configuration which
> >> >> should only be written when the channel is allocated.  In fact, by
> >> >> calling it here in runtime_config, you are introducing a serious bug:
> >> >> other logical channels on the same physical channel will stop because of
> >> >> the SSLNK/SDLNK of the physical channel being zeroed.
> >> >>
> >> >> The runtime config already makes it the hardware in the existing code,
> >> >> via d40_*_cfg().
> >> >
> >> > Sorry Rabin, but the only place I can see the config being written is
> >> > in d40_config_write().
> >> >
> >> > Can you paste the line of code in d40_*_cfg() which actually writes
> >> > the config to hardware please? I don't see it.
> >>
> >> It's not that simple.  There are some pointers passed to d40_*_cfg() and
> >> that function writes the configuration to the variables those pointers
> >> point to (d40c->log_def.lcsp1, d40c->src_def_cfg, etc.).  Please read
> >> the code to see how those variables end up being used later when the
> >> LLIs are prepared for the HW.
> >
> > I have read the code, which is why I know that the config only gets
> > written in d40_config_write(). :)
> >
> > So the configuration which gets set in the runtime_config routine
> > doesn't ever make it to hardware - hence this patch.
> >
> > Unless I'm missing something?
> 
> The runtime config sets up the config for all *subsequent* jobs.
> struct d40_chan contains e.g. runtime_addr, runtime_direction
> etc to store up the stuff being configured. This is done for
> all the other config as well using d40_log_cfg() or
> d40_phy_cfg(), and the result is cached in the channel
> struct, here called d40c.
> 
> Next, when preparing jobs, the DMA40 LLI engine will fill in
> job descriptors using e.g. d40_get_dev_addr()
> and pick settings from this cached runtime config.
> 
> When the subsequent jobs trigger, it allocates channel resources
> by calling d40_alloc_chan_resources(). The config is written to the
> hardware by calling d40_config_write().
> 
> So the basic misunderstanding here is that you think
> the config shall take effect immediately, that is not the
> idea. The configuration will be cached in the channel
> struct, then it will take effect when the next job that is
> queued up allocates its resources to commence.
> 
> Maybe you haven't grasped the asynchronous nature
> of the DMAengine? It's a bit like multithreading. You
> queue up things, then they commence at a later time.
> Not immediately.
> 
> Example: the SPI driver for PL022 may talk to a
> 8, 16 or 32bit capable device. Depending on which device
> it wants to queue a job for, it need to be configured differently,
> like for another width.
> 
> At the time you are queueing a new job, another job may
> already be in flight. If you issue d40_config_write() at this
> point, you will cause undesired effects to the job that may
> already be running. Such as reconfiguring the width
> of the channel.
> 
> You may not observe that bug because there is no
> job in flight, or because the actual configuration is identical
> for two consecutive jobs, but if you're really stressing something,
> queuing jobs while others are already in flight, you will
> see it immediately.
> 
> Therefore, this patch should be dropped.

Ah right, thanks for your explanation.

I have also just finished speaking to Rabin privately, who painted a
good picture of how the configuration side of this driver should
work.

I have dropped this patch and will shortly be replacing it with
something else.

Thanks again to both of you.

-- 
Lee Jones
Linaro ST-Ericsson Landing Team Lead
Linaro.org │ Open source software for ARM SoCs
Follow Linaro: Facebook | Twitter | Blog

  reply	other threads:[~2013-04-15 14:28 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-04-09 18:39 [PATCH 1/8] dmaengine: ste_dma40: Assign memcpy channels in the driver Lee Jones
2013-04-09 18:39 ` Lee Jones
2013-04-09 18:39 ` [PATCH 2/8] dmaengine: ste_dma40: Move default memcpy configs into " Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:39 ` [PATCH 3/8] dmaengine: ste_dma40: Actually write the runtime configuration to registers Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:59   ` Arnd Bergmann
2013-04-09 18:59     ` Arnd Bergmann
2013-04-09 19:07     ` Lee Jones
2013-04-09 19:07       ` Lee Jones
2013-04-09 20:37   ` Arnd Bergmann
2013-04-09 20:37     ` Arnd Bergmann
2013-04-12 13:49   ` Rabin Vincent
2013-04-12 13:49     ` Rabin Vincent
2013-04-12 16:13     ` Lee Jones
2013-04-12 16:13       ` Lee Jones
2013-04-15 11:06     ` Lee Jones
2013-04-15 11:06       ` Lee Jones
2013-04-15 11:36       ` Rabin Vincent
2013-04-15 11:36         ` Rabin Vincent
2013-04-15 11:59         ` Lee Jones
2013-04-15 11:59           ` Lee Jones
2013-04-15 13:47           ` Linus Walleij
2013-04-15 13:47             ` Linus Walleij
2013-04-15 14:28             ` Lee Jones [this message]
2013-04-15 14:28               ` Lee Jones
2013-04-09 18:39 ` [PATCH 4/8] dmaengine: ste_dma40: Do not configure channels during an channel allocation Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-12 13:54   ` Rabin Vincent
2013-04-12 13:54     ` Rabin Vincent
2013-04-12 16:38     ` Lee Jones
2013-04-12 16:38       ` Lee Jones
2013-04-14 16:34       ` Rabin Vincent
2013-04-14 16:34         ` Rabin Vincent
2013-04-09 18:39 ` [PATCH 5/8] dmaengine: ste_dma40: Ensure src and dst registers are configured correctly Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:57   ` Arnd Bergmann
2013-04-09 18:57     ` Arnd Bergmann
2013-04-09 19:09     ` Lee Jones
2013-04-09 19:09       ` Lee Jones
2013-04-09 20:38       ` Arnd Bergmann
2013-04-09 20:38         ` Arnd Bergmann
2013-04-12 14:02   ` Rabin Vincent
2013-04-12 14:02     ` Rabin Vincent
2013-04-09 18:39 ` [PATCH 6/8] dmaengine: ste_dma40: Move LCPA allocation and real-time config Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:56   ` Arnd Bergmann
2013-04-09 18:56     ` Arnd Bergmann
2013-04-09 18:39 ` [PATCH 7/8] dmaengine: ste_dma40: Use the BIT macro to replace ugly '(1 << x)'s Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:55   ` Arnd Bergmann
2013-04-09 18:55     ` Arnd Bergmann
2013-04-09 19:04   ` Harvey Harrison
2013-04-09 19:04     ` Harvey Harrison
2013-04-09 19:12     ` Arnd Bergmann
2013-04-09 19:12       ` Arnd Bergmann
2013-04-10  9:34       ` Lee Jones
2013-04-10  9:34         ` Lee Jones
2013-04-10 12:22         ` Arnd Bergmann
2013-04-10 12:22           ` Arnd Bergmann
2013-04-09 19:12     ` Lee Jones
2013-04-09 19:12       ` Lee Jones
2013-04-09 18:39 ` [PATCH 8/8] ARM: ux500: Amalgamate DMA source and destination channel numbers Lee Jones
2013-04-09 18:39   ` Lee Jones
2013-04-09 18:51   ` Arnd Bergmann
2013-04-09 18:51     ` Arnd Bergmann
2013-04-24 13:45 ` [PATCH 1/8] dmaengine: ste_dma40: Assign memcpy channels in the driver Linus Walleij
2013-04-24 13:45   ` Linus Walleij
     [not found]   ` <CAF2Aj3jHPvc=hOcgLq8LONppGtnxUPP96HRPLfCwQ5x4HONUOw@mail.gmail.com>
2013-04-24 15:05     ` Linus Walleij
2013-04-24 15:05       ` Linus Walleij

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=20130415142824.GG6512@gmail.com \
    --to=lee.jones@linaro.org \
    --cc=linux-arm-kernel@lists.infradead.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.