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: 12552 Return-Path: X-Original-To: patchwork@peony.canonical.com Delivered-To: patchwork@peony.canonical.com Received: from fiordland.canonical.com (fiordland.canonical.com [91.189.94.145]) by peony.canonical.com (Postfix) with ESMTP id C1A1F23F58 for ; Fri, 26 Oct 2012 21:03:06 +0000 (UTC) Received: from mail-ie0-f180.google.com (mail-ie0-f180.google.com [209.85.223.180]) by fiordland.canonical.com (Postfix) with ESMTP id 2FF51A19273 for ; Fri, 26 Oct 2012 21:03:06 +0000 (UTC) Received: by mail-ie0-f180.google.com with SMTP id e10so4220633iej.11 for ; Fri, 26 Oct 2012 14:03:05 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-forwarded-to:x-forwarded-for:delivered-to:received-spf :x-ironport-av:message-id:date:from:user-agent:mime-version:to:cc :subject:x-beenthere:x-mailman-version:precedence:list-id :list-unsubscribe:list-archive:list-post:list-help:list-subscribe :content-transfer-encoding:content-type:sender:errors-to :x-gm-message-state; bh=qaF//VMYcph+EGBe8Y9UWrRdrx7F0g8dSu/mpWK/dww=; b=ASZ48FiQj6/Z22ZfCbvHYS2KkV8YEBaxshkPycoWq0dT92aw+xNIyVQM4093x3p8uH H+D1Fpb6KhCPS/l55WHVJQxukAOCKqHfPcyN3U4LVVrgLTjEOaDAeBZqW1nYoVB3OveT ntU8sBW32IhBObn0i+uCJs252wp7ZJ/3fxKMEGAhPLx5dJSQ0r4T5Oo0NRF6A7vXhXEW RvrYQEjf7rUXzspaNEzK5gEpRUdKof6YdbcYwKg+Q2Yqs+ExKRCMd0zh1RmHljZClSfw nklzojVelqm4MvrnxsPpVCwtRVcWEkt6YV+Co3YzaZObXZObxbqdkeAEmeo3U0UZKoBC cyyw== Received: by 10.43.7.132 with SMTP id oo4mr20584149icb.6.1351285385603; Fri, 26 Oct 2012 14:03:05 -0700 (PDT) X-Forwarded-To: linaro-patchwork@canonical.com X-Forwarded-For: patch@linaro.org linaro-patchwork@canonical.com Delivered-To: patches@linaro.org Received: by 10.50.67.148 with SMTP id n20csp309353igt; Fri, 26 Oct 2012 14:03:04 -0700 (PDT) Received: by 10.14.223.199 with SMTP id v47mr36443262eep.45.1351285384207; Fri, 26 Oct 2012 14:03:04 -0700 (PDT) Received: from mombin.canonical.com (mombin.canonical.com. [91.189.95.16]) by mx.google.com with ESMTP id n49si3811180eeo.133.2012.10.26.14.02.59; Fri, 26 Oct 2012 14:03:04 -0700 (PDT) Received-SPF: neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) client-ip=91.189.95.16; Authentication-Results: mx.google.com; spf=neutral (google.com: 91.189.95.16 is neither permitted nor denied by best guess record for domain of linaro-mm-sig-bounces@lists.linaro.org) smtp.mail=linaro-mm-sig-bounces@lists.linaro.org Received: from localhost ([127.0.0.1] helo=mombin.canonical.com) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TRr3Q-0006hX-1P; Fri, 26 Oct 2012 21:02:56 +0000 Received: from wolverine01.qualcomm.com ([199.106.114.254]) by mombin.canonical.com with esmtp (Exim 4.71) (envelope-from ) id 1TRr3L-0006hN-3I for linaro-mm-sig@lists.linaro.org; Fri, 26 Oct 2012 21:02:53 +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 Cc: "linux-arm-msm@vger.kernel.org" , vgandhi@codeaurora.org, Russell King Subject: [Linaro-mm-sig] [RFC] Using CMA with devicetree generated devices X-BeenThere: linaro-mm-sig@lists.linaro.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: "Unified memory management interest group." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: linaro-mm-sig-bounces@lists.linaro.org Errors-To: linaro-mm-sig-bounces@lists.linaro.org X-Gm-Message-State: ALoCoQljeOTbLIT0I4LwnjP9JBO7suFwg1/i+TbFehtcLkSOPOFcyn38smV8tV4eztsp7gtUL5fB 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;