Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp2819452pxv; Sun, 18 Jul 2021 02:32:47 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwhnTXg0uI2kVewyYs1pXOrn+bFEUEKAjFfNAAX4p/jJ6uTP9tKxrCFwaJoltfgy3DrULCk X-Received: by 2002:a05:6602:2e11:: with SMTP id o17mr5544891iow.55.1626600766985; Sun, 18 Jul 2021 02:32:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626600766; cv=none; d=google.com; s=arc-20160816; b=aHLB6jyFa4chywMZciNmXvGPtAlZO3IGbQuoG1+m1/JjzNnnOUR3A5fM2cScZN0wJN SfgkloaAkOfWTzDHjp35dNHGRfCYdYh1qZ0U+TmpGg9J+NqvNpDaJ/xqs7VnhyvylU8n EyUtt8BB7IykX0J7GwZIn3Q/bjTkV5cPm1A/Luo/s832zfG2ydG+StM18OLSSAQlXOyZ HySHPqGQosure+awN3c6rn/FPLOJRZf6/1iZwX4NrLGdWQo/o7GWVffIhJ3wq1TDaYXO uRc8UwVC4tZtbobJfcREFTcdvlQbqHIGIjI1NlpnlGu7rd9L/lMeUDT3dl17scQ9XQhg xaVQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=FjzOgP7LbIVFyauKkaPZ3G8cqSiQZBeCpHk7oPFgII4=; b=TKxi5S/cCt/X8aZJAzG9XZDFDV6ewleDp3rHWfJhQl4dkK+hBhGKBonWlDvgt0cF/M ikiHwhoCwTdQd+egcaQCUivDDO9PEd0S31PhjtxWA3kQL5qljLYty45GW7xLdW7nq38F 5Ju+ST/6rc0AM0XgQUui4o+Z5xz3N6iYDeD6BZXATnkBM+64+jdyj3cEmGtVaoFY82CA i0TMzzuBv9OHuSA50uQBByqEa1vNZSnOj1/65WSKXUGYjwTZWJZr6QZ5neVkVyjtMBvC XlE9J3s7n7ANrAXHeJnIsDtop7VrzuIKH3l+KOR8Zp6S0iA4l8uHGhR6Km26BCkpaCPj H2jg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAJYxQFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h4si637169ilj.137.2021.07.18.02.32.35; Sun, 18 Jul 2021 02:32:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=aAJYxQFs; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231901AbhGRJec (ORCPT + 99 others); Sun, 18 Jul 2021 05:34:32 -0400 Received: from mail.kernel.org ([198.145.29.99]:45544 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229863AbhGRJeb (ORCPT ); Sun, 18 Jul 2021 05:34:31 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 34BC960C3F; Sun, 18 Jul 2021 09:31:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626600693; bh=+rDFm9FsoZ08b6sGG01ofP3oHAAfan2l2sSh1XQwSR0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aAJYxQFsJbdGWKQX5mdFOrV/4Mbkl/qDKVE1yIy9pxZq4HHu+AWBm7dAXBHiriHrG M6m8IZZlz8muKxk60d6kD7Ci0+jfD6udeh8+tb/Wjp4ehaNbxOk+whVAujiNEkYQKS PHKvYjq3fNIu4UVm+Z7v4s1fZPkunITPVAf1yELADkVpf4vJWy/8lOCgPU6CkkrMob G2A2DWUH3/st5jP+5I66EBcTvI628tSgsh/H2qXMbgg5RGPD0p0Qgg9hCd2BSvFR0S Mooq4W/uqRwgTonQqFVILswVYaEe6mhHurnQ/7N9BoQJY/gSkg9c01sBSpCcowA3bv jBJiC2NBzPWPw== Date: Sun, 18 Jul 2021 12:31:21 +0300 From: Mike Rapoport To: Rob Herring Cc: Geert Uytterhoeven , Russell King , Nicolas Pitre , Ard Biesheuvel , Linus Walleij , Catalin Marinas , Will Deacon , Nick Kossifidis , Paul Walmsley , Palmer Dabbelt , Albert Ou , Frank Rowand , Dave Young , Baoquan He , Vivek Goyal , Andrew Morton , devicetree@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-riscv@lists.infradead.org, kexec@lists.infradead.org, linux-mm@kvack.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v4 02/10] memblock: Add variables for usable memory limitation Message-ID: References: <04c4d231fb03a3810d72a45c8a5bc2272c5975f3.1626266516.git.geert+renesas@glider.be> <20210714135101.GB2441138@robh.at.kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210714135101.GB2441138@robh.at.kernel.org> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi, On Wed, Jul 14, 2021 at 07:51:01AM -0600, Rob Herring wrote: > On Wed, Jul 14, 2021 at 02:50:12PM +0200, Geert Uytterhoeven wrote: > > Add two global variables (cap_mem_addr and cap_mem_size) for storing a > > base address and size, describing a limited region in which memory may > > be considered available for use by the kernel. If enabled, memory > > outside of this range is not available for use. > > > > These variables can by filled by firmware-specific code, and used in > > calls to memblock_cap_memory_range() by architecture-specific code. > > An example user is the parser of the "linux,usable-memory-range" > > property in the DT "/chosen" node. > > > > Signed-off-by: Geert Uytterhoeven > > --- > > This is similar to how the initial ramdisk (phys_initrd_{start,size}) > > and ELF core headers (elfcorehdr_{addr,size})) are handled. > > > > Does there exist a suitable place in the common memblock code to call > > "memblock_cap_memory_range(cap_mem_addr, cap_mem_size)", or does this > > have to be done in architecture-specific code? > > Can't you just call it from early_init_dt_scan_usablemem? If the > property is present, you want to call it. If the property is not > present, nothing happens. For memblock_cap_memory_range() to work properly it should be called after memory is detected and added to memblock with memblock_add[_node]() I'm not huge fan of adding more globals to memblock so if such ordering can be implemented on the DT side it would be great. I don't see a way to actually enforce this ordering, so maybe we'd want to add warning in memblock_cap_memory_range() if memblock.memory is empty. > Rob -- Sincerely yours, Mike.