Received: by 2002:a05:6a10:1287:0:0:0:0 with SMTP id d7csp4270284pxv; Mon, 19 Jul 2021 22:43:13 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyk4LCYQIaq0fTZ6BXF+QDpHF2ruZfaPS1BjWzeZjxVR1hQuYMcGPsnelR/16EDdfdS90Ha X-Received: by 2002:a17:906:a2c4:: with SMTP id by4mr12104636ejb.521.1626759793335; Mon, 19 Jul 2021 22:43:13 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1626759793; cv=none; d=google.com; s=arc-20160816; b=ck/LNlxcI1p4A6O9dO2iPljRuk7hFXGCqQJeInlKQOvIo0pZHYpkz8nec5EzpKWGkG ujReGl1dUloGFrbCinuk1+TlAe6p+OvvAbX/BNctG33Yq5bGP/8WzOlORgiSj1NPpbWm G+kw9yoPAXwRg8AAVX+X4nC3/4wvtWP4FY8TwIcZEkKT/lm2Cx4ov2kHIek8LhzLqePA elbEGtxEx5zUjE3tsXgq2lU41dLC948KBwMD5l4Khe5hCz19Tk5uVIRyxX7LK3uLbPT/ B78XtpNOfMZfZZSPmmgE/UHDaBGWtXptrdGh2ID5eRTml+EE9HM3lpV48carLGOADvBo OPZw== 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=lHkXuoMM7Fd9ydUZTIxZKYOVKIXMrrRnFQjKhkv5TsI=; b=QECA2e566rsQDF9ao8GsUXkWX82NqXmREs5LZs7goXHQfP+oUMo9tFSNBUVp4P8TxU J4u33bcpnzYM+Ys4uePt9fVeWTLd6W7Doq5oIR4Fwr9KIYU0eP5T9N/IbiJfenPh9S1P vS4/LbPL2qOFX3Tmmh7t1YdcKdsK4Y5NZ8E9pcd48T8Z3pTKwasLvHYihNQ8TJrwHusX ePEl52E9fK6Q5jlAZ8Ki3wolAxjx1HNaksmFOiuzFNquvq7YCezwAoBWT5L9N7yGs5CE ujBsbegmUk2ssZxT+ZEFZ5OGAIm2W5X2xQUUVwgVVrmCXwZD9X/iHaZZ9XZXI9YpRY/V pBnw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=LRXfAAm5; 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 k5si24994692edx.484.2021.07.19.22.42.49; Mon, 19 Jul 2021 22:43:13 -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=LRXfAAm5; 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 S237573AbhGTFAy (ORCPT + 99 others); Tue, 20 Jul 2021 01:00:54 -0400 Received: from mail.kernel.org ([198.145.29.99]:33386 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235944AbhGTFAt (ORCPT ); Tue, 20 Jul 2021 01:00:49 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 4F8BA6113A; Tue, 20 Jul 2021 05:41:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1626759688; bh=2GuyoMxAkXwIEuz4kB/1FJuahjlvs/F+Am1H8l4oZ6o=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LRXfAAm56gnQU5zTzJQzg6qkcSv7yw0kl4yYFk/21Z9WHHCS/YfSY1upoAtwKv5bT V2O7oZHWj0fOK1IGM3v79BAcuYxOjoQhqUOKopcwlgQBrVFYG0G449b4T5r51t4r2s npYhouHieUp13RGQWPuxEopMBsodExxP0CTY5MFrJgxjN/YwdfA01vcaOtK+AEq1Yd ORUPos0vJHv62sSB0+yra/zR5L77thXGC2iAERObefhp+jMpFNa8tjsBcsiHoIdhtY VF31HzwBbHUtc22fybXpvdYc58q6NvDcq/5I5KrSiYstSR+a3kuydNUqoSMsfU84YV 3qV/JLV27J/DQ== Date: Tue, 20 Jul 2021 08:41:16 +0300 From: Mike Rapoport To: Geert Uytterhoeven Cc: Rob Herring , 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 , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , Linux ARM , linux-riscv , kexec@lists.infradead.org, Linux MM , Linux-Renesas , Linux Kernel Mailing List 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: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Geert, On Mon, Jul 19, 2021 at 08:59:03AM +0200, Geert Uytterhoeven wrote: > Hi Mike, > > On Sun, Jul 18, 2021 at 11:31 AM Mike Rapoport wrote: > > 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. > > I will have a look... > > > 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. > > Me neither ;-) > > > 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. > > "linux,usable-memory-range" is optional, and typically used only in > crashdump kernels, so it would be a bad idea to add such a warning. If I remember correctly, memblock_cap_memory_range() was added to support "linux,usable-memory-range" for crasdump kernels on arm64 and if it would be called before memory is registered we may silently corrupt the memory because the crash kernel will see all the memory as available. So while WARN() maybe too much a pr_warn() seems to me quite appropriate. -- Sincerely yours, Mike.