From: Feng Tang <feng.tang@intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
Michal Nazarewicz <mina86@mina86.com>,
Kyungmin Park <kyungmin.park@samsung.com>,
Marek Szyprowski <m.szyprowski@samsung.com>,
Joonsoo Kim <iamjoonsoo.kim@lge.com>,
linux-kernel@vger.kernel.org
Cc: Feng Tang <feng.tang@intel.com>
Subject: [PATCH] CMA: Don't return a valid cma for non-cma dev
Date: Thu, 30 Jul 2015 10:37:08 +0800 [thread overview]
Message-ID: <1438223828-26140-1-git-send-email-feng.tang@intel.com> (raw)
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.
Signed-off-by: Feng Tang <feng.tang@intel.com>
---
include/linux/dma-contiguous.h | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/include/linux/dma-contiguous.h b/include/linux/dma-contiguous.h
index 569bbd0..d6ccc19 100644
--- a/include/linux/dma-contiguous.h
+++ b/include/linux/dma-contiguous.h
@@ -66,7 +66,8 @@ static inline struct cma *dev_get_cma_area(struct device *dev)
{
if (dev && dev->cma_area)
return dev->cma_area;
- return dma_contiguous_default_area;
+ else
+ return NULL;
}
static inline void dev_set_cma_area(struct device *dev, struct cma *cma)
--
1.7.9.5
next reply other threads:[~2015-07-30 2:44 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-07-30 2:37 Feng Tang [this message]
2015-07-30 13:59 ` Michal Nazarewicz
2015-07-31 2:51 ` Tang, Feng
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=1438223828-26140-1-git-send-email-feng.tang@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
all inboxes | Powered by JetHome®