linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Daniel Mack <zonque@gmail.com>
To: Sebastian Andrzej Siewior <bigeasy@linutronix.de>
Cc: linux-usb@vger.kernel.org, linux-omap@vger.kernel.org,
	neumann@teufel.de, sergei.shtylyov@cogentembedded.com,
	vinod.koul@intel.com, dan.j.williams@intel.com, balbi@ti.com,
	gregkh@linuxfoundation.org
Subject: Re: [PATCH v3 4/5] dma: cppi41: only allocate descriptor memory once
Date: Tue, 01 Oct 2013 15:09:27 +0200	[thread overview]
Message-ID: <524AC987.5000301@gmail.com> (raw)
In-Reply-To: <20130926082604.GA24205@linutronix.de>

Hi Sebastian,

sorry for the long delay, I got distracted by other things.


On 26.09.2013 10:26, Sebastian Andrzej Siewior wrote:
> * Daniel Mack | 2013-09-22 16:50:03 [+0200]:
> 
>> cdd->cd and cdd->descs_phys are allocated DESCS_AREAS times from
>> init_descs() and freed as often from purge_descs(). This leads to both
>> memory leaks and double-frees.
>>
>> Fix this by pulling the calls to dma_{alloc,free}_coherent() out of the
>> loops.
>>
>> While at it, remove the intermediate variable mem_decs (I guess it was
>> only there to make the code comply to the 80-chars CodingSytle rule).
>>
>> Signed-off-by: Daniel Mack <zonque@gmail.com>
> 
> Please don't merge the memory descriptors. The idea was initially to
> allocate multiple small descriptors instead one big. The descrriptor
> turned out to be enough so it looks like the way it looks.
> If you want to clean this up, please either remove the for loop and
> allocate only one memory area or please prepare for multiple descripors
> (I think two is the upper limit).

Well, I didn't merge the descriptors. Look again at my changes please.

A simplified version of the code as it stands is:

  for (i = 0; i < DESCS_AREAS; i++)
    cdd->cd = dma_alloc_coherent(dev, ..., &cdd->descs_phys, GFP_KERNEL);

  for (i = 0; i < DESCS_AREAS; i++)
    dma_free_coherent(dev, mem_decs, cdd->cd, cdd->descs_phys);

So you're effectively allocating and freeing the same pointer
DESCS_AREAS times, which is certainly not what you wanted.

And this just doesn't hit you because DESCS_AREAS is always 1:

  BUILD_BUG_ON(DESCS_AREAS != 1);


So, after all, my patch doesn't really change any of the runtime
behaviour. Consider it a cosmetic cleanup if you wish :)


Thanks,
Daniel


  reply	other threads:[~2013-10-01 13:09 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-09-22 14:49 [PATCH v3 0/5] dma: cppi41: some trivial fixes and support for suspend/resume Daniel Mack
     [not found] ` <1379861404-8250-1-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-22 14:50   ` [PATCH v3 1/5] dma: cppi41: pass around device instead of platform_device Daniel Mack
2013-09-23  4:16     ` Vinod Koul
2013-09-22 14:50 ` [PATCH v3 2/5] dma: cppi41: s/deinit_cpii41/deinit_cppi41/ Daniel Mack
2013-09-23  4:16   ` Vinod Koul
2013-09-22 14:50 ` [PATCH v3 3/5] dma: cppi41: add shortcut to &pdev->dev in cppi41_dma_probe() Daniel Mack
     [not found]   ` <1379861404-8250-4-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-23  4:17     ` Vinod Koul
2013-09-22 14:50 ` [PATCH v3 4/5] dma: cppi41: only allocate descriptor memory once Daniel Mack
2013-09-23  4:17   ` Vinod Koul
     [not found]     ` <20130923041754.GZ17188-ral2JQCrhuEAvxtiuMwx3w@public.gmane.org>
2013-09-23 14:51       ` Sebastian Andrzej Siewior
2013-09-23 14:36         ` Vinod Koul
     [not found]   ` <1379861404-8250-5-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-26  8:26     ` Sebastian Andrzej Siewior
2013-10-01 13:09       ` Daniel Mack [this message]
     [not found]         ` <524AC987.5000301-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-10-01 16:22           ` Sebastian Andrzej Siewior
2013-10-01 16:57             ` Daniel Mack
2013-10-02  7:13               ` Sebastian Andrzej Siewior
2013-09-22 14:50 ` [PATCH v3 5/5] dma: cppi41: add support for suspend and resume Daniel Mack
     [not found]   ` <1379861404-8250-6-git-send-email-zonque-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2013-09-23  4:09     ` Vinod Koul
2013-09-23  5:53       ` Daniel Mack
2013-09-23 10:00         ` Vinod Koul
2013-09-23 10:01   ` Vinod Koul

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=524AC987.5000301@gmail.com \
    --to=zonque@gmail.com \
    --cc=balbi@ti.com \
    --cc=bigeasy@linutronix.de \
    --cc=dan.j.williams@intel.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=linux-omap@vger.kernel.org \
    --cc=linux-usb@vger.kernel.org \
    --cc=neumann@teufel.de \
    --cc=sergei.shtylyov@cogentembedded.com \
    --cc=vinod.koul@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).