From patchwork Wed Dec 25 23:12:39 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ivaylo Dimitrov X-Patchwork-Id: 3405721 Return-Path: X-Original-To: patchwork-linux-omap@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id 8BF2C9F375 for ; Wed, 25 Dec 2013 23:14:22 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id B482B20144 for ; Wed, 25 Dec 2013 23:14:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id E1FFE2013A for ; Wed, 25 Dec 2013 23:14:20 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752477Ab3LYXOE (ORCPT ); Wed, 25 Dec 2013 18:14:04 -0500 Received: from mail-ea0-f172.google.com ([209.85.215.172]:51963 "EHLO mail-ea0-f172.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752428Ab3LYXOC (ORCPT ); Wed, 25 Dec 2013 18:14:02 -0500 Received: by mail-ea0-f172.google.com with SMTP id q10so2950153ead.17 for ; Wed, 25 Dec 2013 15:14:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=l/toJmZr3W4XBwqyB81uk3USsV0AfxFgjFgz4lKa5CA=; b=G9XrlKct3tSa6hyEfkJuPqfw9D8TAlrVTm9PklUqt7KImvBpLuhU4oBpnGnjOANwN7 r+oTVJIzMlcPSgpPlejFzSyY7ffr0HqeaBTi1u1bj0VPhM0RbFvWLtGgy6dG6ZDsQLkm 3uW4wHMY8b0JKFJG9AnA9fAUGbyqx4MunWyIpeZbgat08Y2dy9M+Z6yaPNTdNTZIwlVE gy28Ja77QQPfVedrKulKLG/0ZTooRF+4AiX0Xt3WWIEbTdTY0q6GATGhp6aFOJYas35R Hmh7cBzbOr/0eZ7fhR0Xq4fpQlF87WRZjojqPOx320je26tvmYgEpEtejjPyM5msBOey /bPw== X-Received: by 10.15.53.200 with SMTP id r48mr3977246eew.111.1388013240692; Wed, 25 Dec 2013 15:14:00 -0800 (PST) Received: from localhost ([46.249.74.23]) by mx.google.com with ESMTPSA id g7sm67767002eet.12.2013.12.25.15.13.58 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 25 Dec 2013 15:13:59 -0800 (PST) From: Ivaylo Dimitrov To: tomi.valkeinen@ti.com Cc: tony@atomide.com, linux@arm.linux.org.uk, pali.rohar@gmail.com, pavel@ucw.cz, linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, Ivaylo Dimitrov Subject: [PATCH] ARM: omapfb: Add early framebuffer memory allocator Date: Thu, 26 Dec 2013 01:12:39 +0200 Message-Id: <1388013159-3036-1-git-send-email-ivo.g.dimitrov.75@gmail.com> X-Mailer: git-send-email 1.8.4.msysgit.0 In-Reply-To: <52A062A0.3070005@ti.com> References: <52A062A0.3070005@ti.com> Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org X-Spam-Status: No, score=-7.4 required=5.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Ivaylo Dimitrov On memory limited devices, CMA fails easily when asked to allocate big chunks of memory like framebuffer memory needed for video playback. Add boot parameter "omapfb_memsize" which allocates memory to be used as dma coherent memory, so dma_alloc_attrs won't hit CMA allocator when trying to allocate memory for the framebuffers Signed-off-by: Ivaylo Dimitrov --- arch/arm/mach-omap2/common.c | 1 + arch/arm/mach-omap2/common.h | 2 + arch/arm/mach-omap2/fb.c | 46 +++++++++++++++++++++++++++++++++++++++++- 3 files changed, 48 insertions(+), 1 deletions(-) diff --git a/arch/arm/mach-omap2/common.c b/arch/arm/mach-omap2/common.c index 2dabb9e..9beecde 100644 --- a/arch/arm/mach-omap2/common.c +++ b/arch/arm/mach-omap2/common.c @@ -33,4 +33,5 @@ void __init omap_reserve(void) omap_dsp_reserve_sdram_memblock(); omap_secure_ram_reserve_memblock(); omap_barrier_reserve_memblock(); + omap_fb_reserve_memblock(); } diff --git a/arch/arm/mach-omap2/common.h b/arch/arm/mach-omap2/common.h index e30ef67..21afdc0 100644 --- a/arch/arm/mach-omap2/common.h +++ b/arch/arm/mach-omap2/common.h @@ -304,6 +304,8 @@ extern void omap_reserve(void); struct omap_hwmod; extern int omap_dss_reset(struct omap_hwmod *); +extern void omap_fb_reserve_memblock(void); + /* SoC specific clock initializer */ extern int (*omap_clk_init)(void); diff --git a/arch/arm/mach-omap2/fb.c b/arch/arm/mach-omap2/fb.c index 26e28e9..0eacbe9 100644 --- a/arch/arm/mach-omap2/fb.c +++ b/arch/arm/mach-omap2/fb.c @@ -30,6 +30,7 @@ #include #include +#include #include "soc.h" #include "display.h" @@ -106,10 +107,53 @@ static struct platform_device omap_fb_device = { .num_resources = 0, }; +static phys_addr_t omapfb_mem_base __initdata; +static phys_addr_t omapfb_mem_size __initdata; + +void __init omap_fb_reserve_memblock(void) +{ + if (omapfb_mem_size) { + omapfb_mem_base = arm_memblock_steal(omapfb_mem_size, SZ_1M); + if (omapfb_mem_base) + pr_info("omapfb: reserved %u bytes at %x\n", + omapfb_mem_size, omapfb_mem_base); + else + pr_err("omapfb: arm_memblock_steal failed\n"); + } +} + int __init omap_init_fb(void) { - return platform_device_register(&omap_fb_device); + int ret; + + ret = platform_device_register(&omap_fb_device); + + if (ret) + return ret; + + if (!omapfb_mem_base) + return 0; + + ret = dma_declare_coherent_memory(&omap_fb_device.dev, + omapfb_mem_base, omapfb_mem_base, + omapfb_mem_size, DMA_MEMORY_MAP | + DMA_MEMORY_EXCLUSIVE); + if (!(ret & DMA_MEMORY_MAP)) + pr_err("omapfb: dma_declare_coherent_memory failed\n"); + + return 0; +} + +static int __init early_omapfb_memsize(char *p) +{ + omapfb_mem_size = ALIGN(memparse(p, &p), SZ_1M); + + if(!omapfb_mem_size) + pr_err("omapfb: bad memsize parameter\n"); + + return 0; } +early_param("omapfb_memsize", early_omapfb_memsize); #else int __init omap_init_fb(void) { return 0; } #endif