public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: "Tang, Feng" <feng.tang@intel.com>
To: "mina86@mina86.com" <mina86@mina86.com>
Cc: "linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"m.szyprowski@samsung.com" <m.szyprowski@samsung.com>,
	"kyungmin.park@samsung.com" <kyungmin.park@samsung.com>,
	"akpm@linux-foundation.org" <akpm@linux-foundation.org>,
	"iamjoonsoo.kim@lge.com" <iamjoonsoo.kim@lge.com>
Subject: Re: [PATCH] CMA: Don't return a valid cma for non-cma dev
Date: Fri, 31 Jul 2015 02:51:11 +0000	[thread overview]
Message-ID: <1438311070.4299.1.camel@intel.com> (raw)
In-Reply-To: <xa1tmvydeofi.fsf@mina86.com>

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain; charset="utf-8", Size: 2034 bytes --]

Hi Michal Nazarewicz,

Thanks for the review.

On Thu, 2015-07-30 at 15:59 +0200, Michal Nazarewicz wrote:
> On Thu, Jul 30 2015, Feng Tang wrote:
> > When system(one x86 soc) boot, we saw many normal dma allocation requests
> > goes to cma area. The call chain is
> > 	dma_generic_alloc_coherent
> > 	    dma_alloc_from_contiguous	-- arch/x86/kernel/pci-dma.c
> > 	        cma_alloc(dev_get_cma_area(dev), count, align)
> >
> > Current dev_get_cma_area() will return a valid "cma" anyway. Then all
> > these requests will be taken as valid cma request, and get pages from
> > cma area, which has 2 problems:
> > 1. make the cma area fragmented
> > 2. confuse the cma reservation, usually cma memory size is set according
> >    to the expectation of system scenario, these unexpected requests
> >    will affect the designed cma usage.
> >
> > So this patch will enforce the judgement, and only return valid "cma"
> > for real cma user, thus make normal user like IO device driver not
> > abuse cma reserved region.
> 
> Just don’t set dma_contiguous_default_area.  This patch defeats the
> purpose of a *default* area.

Yes! This is exactly what I tried when I first saw this problem, but
this failed as there 2 places inside drivers/base/dma-contiguous.c
which set the dma_contiguous_default_area

1) 
void __init dma_contiguous_reserve(phys_addr_t limit)
{
    ....
    dma_contiguous_reserve_area(selected_size, selected_base,
                                            selected_limit,
                                   &dma_contiguous_default_area,
                                            fixed);
     ....
}

2) 
static int __init rmem_cma_setup(struct reserved_mem *rmem)
{
    ...
    if (of_get_flat_dt_prop(node, "linux,cma-default", NULL))
                dma_contiguous_set_default(cma);
    ...
}

Are you suggesting me to remove them?

Thanks,
Feng


ÿôèº{.nÇ+‰·Ÿ®‰­†+%ŠËÿ±éݶ\x17¥Šwÿº{.nÇ+‰·¥Š{±þG«éÿŠ{ayº\x1dʇڙë,j\a­¢f£¢·hšïêÿ‘êçz_è®\x03(­éšŽŠÝ¢j"ú\x1a¶^[m§ÿÿ¾\a«þG«éÿ¢¸?™¨è­Ú&£ø§~á¶iO•æ¬z·švØ^\x14\x04\x1a¶^[m§ÿÿÃ\fÿ¶ìÿ¢¸?–I¥

  reply	other threads:[~2015-07-31  2:56 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-07-30  2:37 [PATCH] CMA: Don't return a valid cma for non-cma dev Feng Tang
2015-07-30 13:59 ` Michal Nazarewicz
2015-07-31  2:51   ` Tang, Feng [this message]
2015-07-31 12:05     ` Michal Nazarewicz
2015-07-31 15:18       ` Feng Tang
2015-07-31 17:46         ` Michal Nazarewicz
2015-08-05  9:19           ` Feng Tang
2015-08-05 10:28             ` Michal Nazarewicz
2015-08-05 10:46               ` Feng Tang
2015-08-05 10:55               ` Feng Tang
2015-08-05 11:15                 ` Michal Nazarewicz
2015-08-05 13:22                   ` Feng Tang

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=1438311070.4299.1.camel@intel.com \
    --to=feng.tang@intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=iamjoonsoo.kim@lge.com \
    --cc=kyungmin.park@samsung.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=m.szyprowski@samsung.com \
    --cc=mina86@mina86.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