Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp1701714imu; Wed, 21 Nov 2018 00:12:57 -0800 (PST) X-Google-Smtp-Source: AFSGD/WN0b/RyBtca0Aw8O4e8GZZJOHVYOzRS+J23pOpSizF+qtj8HUYtim8OkRSj2UmbNuau3Vx X-Received: by 2002:a62:9f01:: with SMTP id g1mr24345pfe.223.1542787977922; Wed, 21 Nov 2018 00:12:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1542787977; cv=none; d=google.com; s=arc-20160816; b=stouhUpCxZCv76pJDgqh2qShRnreDJKjDOr0QmlI2ndJCrMoZoos8lV/NRI59zUtlF oxf/0+eFeEHeHryRTMr5n8/ieOrxXTQP5SRd7LgvgtWZRg+Hr26XEPlqRWAQNkPYom4F UFk0m+EJgmzDtRTZWzaDe/41t1a7L1w20XbJ/DMRf4tGotJakPqhj4gIsGl+OmyzfSTg hnkBSKPnySuaI1AkHh0KYjImv+SYUK60KAmzdCC20D+cfcHG+pMxyaALOmneK564Mgpo IUGERVedtR1adD8lVC+Vl3imHw0yTyqeryo/TNYKNfHw8skafcvmDDpktbshbmQAnK9y 9YOQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=W8fIyDNDWiSWraDd7K5c0W08PxihjH5bucR1KQVxgvM=; b=clD0gr7z8mf4wzICJ2dF+As9q0cOsjow2LLu4ty3JCtoUWrA74fe3Qy424JdxEHwQf Npu1EuZ3QkJNS1SfI6bm+b/n7wpEGLcvL0oLs24PZIuZUL84zcsgr6Fuujd/ky+HBz8E kYm7vm16a4HxPPwJnCGxu/wDCiCZFfDYkiHTDjEr/m7GrkAKLj6VfHO1n52DHfPnhgYN 3peheTzzXEADcJ1Bx7LHqX2evRMkjydacZglyEVVc4sddEBZNptGBSpmQnhTV08/MOdL 5sT7p2eNE0xxEvO0d06TcWbDesbXcpx+HbVcq9AVDi3NYcieGhyM+pS/IbSl2c+A9IF7 Q31A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b39-v6si49683488pla.22.2018.11.21.00.12.43; Wed, 21 Nov 2018 00:12:57 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728520AbeKUSo7 (ORCPT + 99 others); Wed, 21 Nov 2018 13:44:59 -0500 Received: from mailgw01.mediatek.com ([210.61.82.183]:8165 "EHLO mailgw01.mediatek.com" rhost-flags-OK-FAIL-OK-FAIL) by vger.kernel.org with ESMTP id S1728231AbeKUSo7 (ORCPT ); Wed, 21 Nov 2018 13:44:59 -0500 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 CC: , , , , , Miles Chen 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 Content-Type: text/plain X-MTK: N Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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(); -- 1.9.1