From patchwork Wed Nov 21 08:11:13 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Miles Chen X-Patchwork-Id: 10692099 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8D78D14BD for ; Wed, 21 Nov 2018 08:11:45 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DB042B8C7 for ; Wed, 21 Nov 2018 08:11:45 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F69C2B8D4; Wed, 21 Nov 2018 08:11:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-3.6 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_LOW,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 157F12B8C7 for ; Wed, 21 Nov 2018 08:11:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:To :From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=vkSndiSd5kXuRBueuLEecnHeCuS02svCt61xfKA1r3Q=; b=j3jgN1aGXZhsOr YhS2h1D7ML06g2Y7bhWCFFl7EwEMu3fJAWPnCAn6MHtwu1GfHzlGaNECplNPmiIpOMyMgNydDZwU0 Iur3l5muG1uVrPKLt4OKtIabVAtXK76+6UFVQbngHHoyJpSbiPXl+s2Ct5+6K6DdPtcaiSjiy4JGB pmOIA8VgpvZ9u3ezJwwQbgdhtLAlWd71p/9bcWeew5Rup7GN3XtJdZDvBjUjiu0SqhD85EmTSyBHj NV3hhHvBtgfNxECQfTEl8s271LBxv99/uuQoNCsgPLdg/GBtyHXOv8nY4jmY06S7mwGYo3ZFW70TW lGQ41S9FVMV4JfZmcArQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPNbs-0002Lw-Ny; Wed, 21 Nov 2018 08:11:44 +0000 Received: from [210.61.82.183] (helo=mailgw01.mediatek.com) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1gPNbq-0002Kc-LR; Wed, 21 Nov 2018 08:11:44 +0000 X-UUID: b9184564d42f476192ec877e5f520667-20181121 X-UUID: b9184564d42f476192ec877e5f520667-20181121 Received: from mtkcas06.mediatek.inc [(172.21.101.30)] by mailgw01.mediatek.com (envelope-from ) (mhqrelay.mediatek.com ESMTP with TLS) with ESMTP id 300876385; Wed, 21 Nov 2018 16:11:17 +0800 Received: from mtkcas09.mediatek.inc (172.21.101.178) by mtkmbs03n1.mediatek.inc (172.21.101.181) with Microsoft SMTP Server (TLS) id 15.0.1395.4; Wed, 21 Nov 2018 16:11:16 +0800 Received: from mtksdccf07.mediatek.inc (172.21.84.99) by mtkcas09.mediatek.inc (172.21.101.73) with Microsoft SMTP Server id 15.0.1395.4 via Frontend Transport; Wed, 21 Nov 2018 16:11:16 +0800 From: To: Rob Herring , Frank Rowand Subject: [RFC PATCH] of: make MAX_RESERVED_REGIONS configurable Date: Wed, 21 Nov 2018 16:11:13 +0800 Message-ID: <1542787873-8429-1-git-send-email-miles.chen@mediatek.com> X-Mailer: git-send-email 1.9.1 MIME-Version: 1.0 X-MTK: N X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20181121_001142_823278_DF7EB40C X-CRM114-Status: GOOD ( 12.69 ) X-BeenThere: linux-mediatek@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: devicetree@vger.kernel.org, wsd_upstream@mediatek.com, linux-kernel@vger.kernel.org, Miles Chen , linux-mediatek@lists.infradead.org, linux-arm-kernel@lists.infradead.org Sender: "Linux-mediatek" Errors-To: linux-mediatek-bounces+patchwork-linux-mediatek=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP From: Miles Chen When we use more than 32 entries in /resered-memory, there will be an error message: "not enough space all defined regions.". We can increase MAX_RESERVED_REGIONS to fix this. commit 22f8cc6e3373 ("drivers: of: increase MAX_RESERVED_REGIONS to 32") increased MAX_RESERVED_REGIONS to 32 but I'm not sure if increasing MAX_RESERVED_REGIONS to 64 is suitable for everyone. In this RFC patch, CONFIG_MAX_OF_RESERVED_REGIONS is added and used as MAX_RESERVED_REGIONS. Add a sanity test to make sure that MAX_RESERVED_REGIONS is less than INIT_MEMBLOCK_REGIONS. Users can configure CONFIG_MAX_OF_RESERVED_REGIONS according to their need. Signed-off-by: Miles Chen --- drivers/of/Kconfig | 9 +++++++++ drivers/of/of_reserved_mem.c | 5 ++++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/drivers/of/Kconfig b/drivers/of/Kconfig index ad3fcad..63fff2e 100644 --- a/drivers/of/Kconfig +++ b/drivers/of/Kconfig @@ -86,6 +86,15 @@ config OF_RESERVED_MEM help Helpers to allow for reservation of memory regions +config MAX_OF_RESERVED_REGIONS + int "the max number of devicetree reserved memory regions" + depends on OF_RESERVED_MEM + default 32 + help + Setup the max number of devicetree reserved memory regions + If unsure, leave the default value "32". + + config OF_RESOLVE bool diff --git a/drivers/of/of_reserved_mem.c b/drivers/of/of_reserved_mem.c index 1977ee0..18a7729 100644 --- a/drivers/of/of_reserved_mem.c +++ b/drivers/of/of_reserved_mem.c @@ -22,7 +22,7 @@ #include #include -#define MAX_RESERVED_REGIONS 32 +#define MAX_RESERVED_REGIONS CONFIG_MAX_OF_RESERVED_REGIONS static struct reserved_mem reserved_mem[MAX_RESERVED_REGIONS]; static int reserved_mem_count; @@ -246,6 +246,9 @@ void __init fdt_init_reserved_mem(void) { int i; + /* MAX_RESERVED_REGIONS should be bounded by INIT_MEMBLOCK_REGIONS */ + BUILD_BUG_ON(MAX_RESERVED_REGIONS > INIT_MEMBLOCK_REGIONS); + /* check for overlapping reserved regions */ __rmem_check_for_overlap();