From patchwork Fri Oct 26 21:02:48 2012 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laura Abbott X-Patchwork-Id: 1653881 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork1.kernel.org Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) by patchwork1.kernel.org (Postfix) with ESMTP id 80C143FD4E for ; Fri, 26 Oct 2012 21:04:15 +0000 (UTC) Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.76 #1 (Red Hat Linux)) id 1TRr3N-0005CQ-Vz; Fri, 26 Oct 2012 21:02:54 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by merlin.infradead.org with esmtps (Exim 4.76 #1 (Red Hat Linux)) id 1TRr3L-0005Bc-5A for linux-arm-kernel@lists.infradead.org; Fri, 26 Oct 2012 21:02:51 +0000 X-IronPort-AV: E=McAfee;i="5400,1158,6877"; a="2166909" Received: from pdmz-ns-snip_115_219.qualcomm.com (HELO mostmsg01.qualcomm.com) ([199.106.115.219]) by wolverine01.qualcomm.com with ESMTP/TLS/DHE-RSA-AES256-SHA; 26 Oct 2012 14:02:49 -0700 Received: from [10.46.166.175] (pdmz-ns-snip_218_1.qualcomm.com [192.168.218.1]) by mostmsg01.qualcomm.com (Postfix) with ESMTPA id D7FD010004BC; Fri, 26 Oct 2012 14:02:48 -0700 (PDT) Message-ID: <508AFA78.4080602@codeaurora.org> Date: Fri, 26 Oct 2012 14:02:48 -0700 From: Laura Abbott User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:16.0) Gecko/20121010 Thunderbird/16.0.1 MIME-Version: 1.0 To: linaro-mm-sig@lists.linaro.org, "linux-arm-kernel@lists.infradead.org" , Marek Szyprowski Subject: [RFC] Using CMA with devicetree generated devices X-Spam-Note: CRM114 invocation failed X-Spam-Score: -4.2 (----) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-4.2 points) pts rule name description ---- ---------------------- -------------------------------------------------- -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, medium trust [199.106.114.254 listed in list.dnswl.org] -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: "linux-arm-msm@vger.kernel.org" , vgandhi@codeaurora.org, Russell King X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linux-arm-kernel-bounces@lists.infradead.org Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org Is it possible to use the devices generated from device tree for use with CMA? The API for reserving a CMA region (dma_declare_contiguous) requires a device pointer to properly associate a region with a device. By the time the devices from devicetree are actually available (generally during machine_init), dma_contiguous_remap has already been called so it's too late to have a properly setup region. I currently see several options: 1) All CMA devices must be statically declared in the board file 2) Scan the FDT to set up 'dummy' devices early which can later be used to set up CMA with the 'proper' devices 3) My assumption is completely wrong and the check that I was using is invalid: dma_mmu_remap[dma_mmu_remap_num].size = size; dma_mmu_remap_num++; @@ -404,6 +406,7 @@ void __init dma_contiguous_remap(void) iotable_init(&map, 1); } + is_remapped = 1; } static void * I'm currently leaning towards setting up #2 unless I'm missing something obvious here. Thanks. Laura diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 8404601..6d37516 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -368,9 +368,11 @@ struct dma_contig_early_reserve { static struct dma_contig_early_reserve dma_mmu_remap[MAX_CMA_AREAS] __initdata; static int dma_mmu_remap_num __initdata; +static int is_remapped; void __init dma_contiguous_early_fixup(phys_addr_t base, unsigned long size) { + BUG_ON(is_remapped); dma_mmu_remap[dma_mmu_remap_num].base = base;