From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752270AbbGaC4R (ORCPT ); Thu, 30 Jul 2015 22:56:17 -0400 Received: from mga03.intel.com ([134.134.136.65]:4168 "EHLO mga03.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1750877AbbGaC4P (ORCPT ); Thu, 30 Jul 2015 22:56:15 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,581,1432623600"; d="scan'208";a="774943965" From: "Tang, Feng" To: "mina86@mina86.com" CC: "linux-kernel@vger.kernel.org" , "m.szyprowski@samsung.com" , "kyungmin.park@samsung.com" , "akpm@linux-foundation.org" , "iamjoonsoo.kim@lge.com" Subject: Re: [PATCH] CMA: Don't return a valid cma for non-cma dev Thread-Topic: [PATCH] CMA: Don't return a valid cma for non-cma dev Thread-Index: AQHQynGhltm0oS7tkEmJcrmA2SLj4Z3zhPuAgADXiAA= Date: Fri, 31 Jul 2015 02:51:11 +0000 Message-ID: <1438311070.4299.1.camel@intel.com> References: <1438223828-26140-1-git-send-email-feng.tang@intel.com> In-Reply-To: Accept-Language: zh-CN, en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.239.154.19] Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id t6V2uLEw006367 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++%ݶw{.n+{G{ayʇڙ,jfhz_(階ݢj"mG?&~iOzv^m ?I