Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp1497008pxa; Sun, 2 Aug 2020 09:37:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzJjAqbdHn4sX7B+YTi04BMb3wKuvuCFE/EA1eEDB8yBJcOhGM5VMnBXkHtOc+FLTOeF5J/ X-Received: by 2002:a05:6402:b87:: with SMTP id cf7mr12428443edb.131.1596386262679; Sun, 02 Aug 2020 09:37:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1596386262; cv=none; d=google.com; s=arc-20160816; b=guk3UCVgF4dnRJJ7bBg4+gOc+zUWSHZYwq+G2EWmIVbH4/kA9GD6DjBuabjLzrSmxZ K1bcUMPw5rpeDRKt5XKRgOMUqsx35ma8DIfdyZoKj/CMB2SeYa0PEjHkMtWQv2sTtTjD ZOvZYE6mUDBtq140NJl9OAMuNoWGCCqISrQyhogOwcZa0r0Qd7smB4oJZ2fP8Ga90VJv Bq9vZANK9fj3ul+Po6rVLMEtfJWr1EU9D/TOUIDvli84oJqc6d9gIspt6+ZuW+xQbpsU WM/EN3iE+24eD0Y2+6jzzKCiItsXyGgTb9sNIQwJXe0U7/fk10B5QnNfPMfP1+mjTNvA 7h+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=c5eFxK3DdfkcSt31OAyWpkrPS2CV1RkuShT63Y6567I=; b=auTochrUsCr2P75EOW6X8nNUg1y2tYVJT0QtZ6SJC/E26Z87eCMuEnTxSP78fhdOIS Erc/DL32m/zyCHr9VKYs7sxs72z1wucWVInQQSsycoLFb4RhThSXU8zF9749lDdWM+gF /htdnvSmOE9Ae2c1dd1blsCccfb0vRw4ByzIdY0XLkEI9XXbUMaDz8gWCRwrDJxtNDAt d3VB1ItLxhhTrOqt18ZBGDdTiyqwzW1scR5EMwafTY/2PjvS+/ms+alHLQNy7kSwAIur eB7vQDYTXvB/qtMSDTh1xLI5uXl8nqRbUXQWhoyahmthSjVWZ/rZgV+HVlSaeH6UTj3s lXgA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=SOgVggGM; 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 c18si8560175eds.417.2020.08.02.09.37.20; Sun, 02 Aug 2020 09:37:42 -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=default header.b=SOgVggGM; 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 S1726871AbgHBQgi (ORCPT + 99 others); Sun, 2 Aug 2020 12:36:38 -0400 Received: from mail.kernel.org ([198.145.29.99]:45466 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726814AbgHBQgi (ORCPT ); Sun, 2 Aug 2020 12:36:38 -0400 Received: from aquarius.haifa.ibm.com (nesher1.haifa.il.ibm.com [195.110.40.7]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 6A00E207BB; Sun, 2 Aug 2020 16:36:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1596386197; bh=xcGEWjGQ/q+Opr/28a2ZIyYFBp4V7lSmr/sGm/UAQ8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SOgVggGMxb05aldaV4gL3FEB6ytnfwQ2Hfm+aVpQEhS2YGYbhdfAH/QPMj7HPwMI5 XeDdGGe8NG9Bu+bKWfKtRHFHzAo7hMYHFjPAEpwDsXjCnkv+BRSh91vwkb3pCHvFSs nw74lyhHI2uN7uS39+6+ts/f3izbiKTGZDfFdKRE= From: Mike Rapoport To: Andrew Morton Cc: Andy Lutomirski , Baoquan He , Benjamin Herrenschmidt , Borislav Petkov , Catalin Marinas , Christoph Hellwig , Dave Hansen , Emil Renner Berthing , Ingo Molnar , Hari Bathini , Marek Szyprowski , Max Filippov , Michael Ellerman , Michal Simek , Mike Rapoport , Mike Rapoport , Palmer Dabbelt , Paul Mackerras , Paul Walmsley , Peter Zijlstra , Russell King , Stafford Horne , Thomas Gleixner , Will Deacon , Yoshinori Sato , clang-built-linux@googlegroups.com, iommu@lists.linux-foundation.org, linux-arch@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-kernel@vger.kernel.org, linux-mips@vger.kernel.org, linux-mm@kvack.org, linux-riscv@lists.infradead.org, linux-s390@vger.kernel.org, linux-sh@vger.kernel.org, linux-xtensa@linux-xtensa.org, linuxppc-dev@lists.ozlabs.org, openrisc@lists.librecores.org, sparclinux@vger.kernel.org, uclinux-h8-devel@lists.sourceforge.jp, x86@kernel.org Subject: [PATCH v2 02/17] dma-contiguous: simplify cma_early_percent_memory() Date: Sun, 2 Aug 2020 19:35:46 +0300 Message-Id: <20200802163601.8189-3-rppt@kernel.org> X-Mailer: git-send-email 2.26.2 In-Reply-To: <20200802163601.8189-1-rppt@kernel.org> References: <20200802163601.8189-1-rppt@kernel.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Mike Rapoport The memory size calculation in cma_early_percent_memory() traverses memblock.memory rather than simply call memblock_phys_mem_size(). The comment in that function suggests that at some point there should have been call to memblock_analyze() before memblock_phys_mem_size() could be used. As of now, there is no memblock_analyze() at all and memblock_phys_mem_size() can be used as soon as cold-plug memory is registerd with memblock. Replace loop over memblock.memory with a call to memblock_phys_mem_size(). Signed-off-by: Mike Rapoport Reviewed-by: Christoph Hellwig --- kernel/dma/contiguous.c | 11 +---------- 1 file changed, 1 insertion(+), 10 deletions(-) diff --git a/kernel/dma/contiguous.c b/kernel/dma/contiguous.c index 15bc5026c485..1992afd8ca7b 100644 --- a/kernel/dma/contiguous.c +++ b/kernel/dma/contiguous.c @@ -73,16 +73,7 @@ early_param("cma", early_cma); static phys_addr_t __init __maybe_unused cma_early_percent_memory(void) { - struct memblock_region *reg; - unsigned long total_pages = 0; - - /* - * We cannot use memblock_phys_mem_size() here, because - * memblock_analyze() has not been called yet. - */ - for_each_memblock(memory, reg) - total_pages += memblock_region_memory_end_pfn(reg) - - memblock_region_memory_base_pfn(reg); + unsigned long total_pages = PHYS_PFN(memblock_phys_mem_size()); return (total_pages * CONFIG_CMA_SIZE_PERCENTAGE / 100) << PAGE_SHIFT; } -- 2.26.2