From patchwork Tue Sep 28 10:50:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Peng Fan (OSS)" X-Patchwork-Id: 12522283 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6CA12C433EF for ; Tue, 28 Sep 2021 10:15:24 +0000 (UTC) Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by mail.kernel.org (Postfix) with ESMTP id E852A61131 for ; Tue, 28 Sep 2021 10:15:23 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org E852A61131 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=oss.nxp.com Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=kvack.org Received: by kanga.kvack.org (Postfix) id 7451F940007; Tue, 28 Sep 2021 06:15:23 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 6F460900002; Tue, 28 Sep 2021 06:15:23 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5952B940007; Tue, 28 Sep 2021 06:15:23 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from forelay.hostedemail.com (smtprelay0009.hostedemail.com [216.40.44.9]) by kanga.kvack.org (Postfix) with ESMTP id 4997F900002 for ; Tue, 28 Sep 2021 06:15:23 -0400 (EDT) Received: from smtpin29.hostedemail.com (10.5.19.251.rfc1918.com [10.5.19.251]) by forelay05.hostedemail.com (Postfix) with ESMTP id E7C1F181DFACF for ; Tue, 28 Sep 2021 10:15:22 +0000 (UTC) X-FDA: 78636574884.29.3F73AB3 Received: from EUR04-DB3-obe.outbound.protection.outlook.com (mail-eopbgr60062.outbound.protection.outlook.com [40.107.6.62]) by imf25.hostedemail.com (Postfix) with ESMTP id 735AEB000185 for ; Tue, 28 Sep 2021 10:15:22 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Pz85/mZqKWl/go4M+Lxq0+UnluOH5UEI9dSTYb/3kEB8rlkkLZ9HtQloKtiwt9h2tVhlZktvMOsBJDMiigHHutZTwVJmDx+5yjI9ntB+OYE1O+IZhedQhMwZHwwSvQvolvCooIcX9P1lfq9G132/uq4hvXEVwzTczRPnS8RiPvZhafsYVlScIU7kWz1llFIzMeqqa6bYJvZy89J9u23uUoEmXGx5kUOkeGK1dGx7pefDg7/2Rg+tTaS7+6vM623amtQtNaLNrGRKgf832/sf9zqnXoNvLV/35OMmgcn7KYJTLZQgh1hd+eVQ2wSNzbxzPyeWyKwMxlL2uHJUBXFSHg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=Y+Q5md7kCkvOJj5LShtTrjBP1nvf86UH8IQQDl07gzM=; b=duNejHLw/aDiERafzdm7KqNTHHwVGgmGRRFvDDggiUf0rUHKkKAhzOZ0MUCSoRBQuxCUJ7fn+Iago8jSdK8vOBb6xO362Nu9lTuEZsQBDceOnwp5YpfhvhH4zkbhtVbXLP27w5JAje9n+ErUSr86PheLCyOh+nDXSXPFEh1LRx4qHZFx64JAK/VN51doRQKukxpUhlcAM3dAbEJDOi+wot6rvIr+lU+dp66wqmttxZJvLhxrGlNrega/HtRwiNrTnurrZPgvW4vm1OMa69ygFAVRRQNI9Gag7nBSxBqnph96vo8dKiVY9uxTWbqz/jkavFYd3VT5VQ7+TmaF0o/t8g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=oss.nxp.com; dmarc=pass action=none header.from=oss.nxp.com; dkim=pass header.d=oss.nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=NXP1.onmicrosoft.com; s=selector2-NXP1-onmicrosoft-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=Y+Q5md7kCkvOJj5LShtTrjBP1nvf86UH8IQQDl07gzM=; b=YHJc7AhE+56kRiDcfrcUkDNPW4rD4+gtAuewc63GcDDeYHHAC5LEKX+ySn52pcJdw2YKGJX2uO+aGqJTabVk5YlTHnzR5gf7tItSxzjbHRgzp9PEL+w7m7pzEbuw6cN/+wMH1o8CyKduF2TcnCqQ974TzRgQ7Hbkb9lHPjBab+E= Received: from DU2PR04MB9020.eurprd04.prod.outlook.com (2603:10a6:10:2e3::9) by DU2PR04MB8807.eurprd04.prod.outlook.com (2603:10a6:10:2e2::23) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.13; Tue, 28 Sep 2021 10:15:08 +0000 Received: from DU2PR04MB9020.eurprd04.prod.outlook.com ([fe80::b928:9230:aa10:639a]) by DU2PR04MB9020.eurprd04.prod.outlook.com ([fe80::b928:9230:aa10:639a%9]) with mapi id 15.20.4544.022; Tue, 28 Sep 2021 10:15:08 +0000 From: "Peng Fan (OSS)" To: rppt@kernel.org, akpm@linux-foundation.org, david@redhat.com, geert+renesas@glider.be Cc: linux-mm@kvack.org, linux-kernel@vger.kernel.org, Peng Fan Subject: [PATCH] memblock: check memory total_size Date: Tue, 28 Sep 2021 18:50:57 +0800 Message-Id: <20210928105057.3406-1-peng.fan@oss.nxp.com> X-Mailer: git-send-email 2.30.0 X-ClientProxiedBy: SG2PR06CA0199.apcprd06.prod.outlook.com (2603:1096:4:1::31) To DU2PR04MB9020.eurprd04.prod.outlook.com (2603:10a6:10:2e3::9) MIME-Version: 1.0 X-MS-Exchange-MessageSentRepresentingType: 1 Received: from linux-1xn6.ap.freescale.net (119.31.174.71) by SG2PR06CA0199.apcprd06.prod.outlook.com (2603:1096:4:1::31) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.4544.15 via Frontend Transport; Tue, 28 Sep 2021 10:15:05 +0000 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 05ce8cc3-27b0-4266-5af8-08d98268d8e1 X-MS-TrafficTypeDiagnostic: DU2PR04MB8807: X-MS-Exchange-SharedMailbox-RoutingAgent-Processed: True X-MS-Exchange-Transport-Forked: True X-Microsoft-Antispam-PRVS: X-MS-Oob-TLC-OOBClassifiers: OLM:1360; X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: I5fxvaPbyB+FDKAxk+iGn0R80CVB0dbEJgISODiurbAoe+DN+8lCF+gFzJNNmJJTOs5u8DLRyKO+AqzIFb3e0r2Yay/SsJ2sgjvbYvwxaM/ZKjr3hrmaVIDf59ObzrQke8/M5xh2j6sc5oNgduDGB5dWYhqoiqfjdFrlFJuUShdIuNz0xSbhMKx72s8rdZHF+LWlSKVFNxicfjCbDKyYwJSHJaTbjwdYzqH0OotWIOMeeWrDvxx7RCSRwOf8CWM8PaeoxnKkbStOX/BwHSQkJa46v1vp3vqejdYuUdDZj2/5DgxnWgXf9ahQW4fvJfzq8bqVQv0iVotgaFOD5S6XJiEGdb9m0QnHEYXDpDDvkT5cKjsmniVOj4YbuoZ7r648R0oWMkS3Glys4iBD4Bmntt4gD9pFebIZZyfmc+lhuh5PpQ7/YfOkbiCDyxmhF/EVFfxnejhyvpmNfIn3bVowBS6nmJHRzTpDo7wr2smx5FxUWkjVhyfoG2JSJgknQFa7KYxYQp7U9UaxL/TNDxzjeUWUdk3x4L/yfi7muzpXGTvYh6SQCPTOfTQY14vRpUeqpab+tF9y0LoiFhmom5nZPe3mEqS6LxK6XZ3RctQoLhYazPZSi/1jarVFSt9neNegJ0/yeCGyl6B6gGO1dzsUCWILhnd6Zou0oc2EBDOZZCBZNVOUllSAgzfJk/qTIsG/5r+m5zoy5l3kAr4FtGKveA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DU2PR04MB9020.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(4636009)(366004)(4326008)(38100700002)(8936002)(6512007)(6486002)(83380400001)(38350700002)(8676002)(508600001)(316002)(86362001)(52116002)(2616005)(5660300002)(2906002)(6666004)(186003)(26005)(66946007)(956004)(66556008)(66476007)(6506007)(1076003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: M06GjwV0WvJPA1nM5Hm7TEMb9AqvxEPScnMbuhnOFxFsTBoHi42of6FrBk6Ti0xGvHqwoNroQU/tBN5wMEOx2jlBYeNaGaBsLB0GdFjnXFlL3Nrlufj3c5HfDw/TilHyImEKgJ12HPdm5qzWAzp3J5DsI/Rh7I80ad4UHyLYjKcckHM3vZt02sL0s2b3fDThxgxMjqH1wzY650MjNBCTCC8OIn7GpRUgyFIh+A+aKzyPMTfP9EGothLeg0BYe7krruMb5SGT/arHtvhiLXvzlGJdWNZnmXilYjqOmGM1cLwN3sVa9WlgIpBQtnxAGs9dEIyCrTjHlf5FcEX2FYyTl3cRTfmHt8Chcxv0F9wSjk7pAdTCDTSbb1dKJIQyg+2SqHxp2ZXJRTvUysHoINfPMOJTYEz5J6c4KrjUXl5aONIoveBUKhqCqNMZOzolj3ysyZh0bUUVjL3BiQT6DsqkDDAnJwnH78HME2BpGB36wL7VMgbe9V3kYDQc2FoAvFUev04nGKWYY7egcR0gaIZul2ognY1HVMrj+P2PFIslI6SP6CytP0Zl0GvZsKkI6yY2rPw8Qad4Krn9U2Ypj7cV4WeH6l00FO0XD+v00Gs7Uf5zRtx5qPzjufETjgpedD3iwCse/sY4b8KCfXzPP196eVhbuk0778M/bZfgZchWjegK03RP417mKiLDm0C6QuMowhFeAsn3Fj1f3M4G3F6pwggfVpGyCEatW3+p8XWpa0VMG6u7L/oUX3jPcSQPcpdQD9kYKDlmsBuxgec0saKfdGi5vzvM+POWhilKfAcbURLp+eWf4ZUumAuVCugOGiMRJq/yznPEb/zBZa29yUA2+lb3FUH+/QsspO1HuQ0Ebg8sJRFOd/gZEDivnlMxLVCY52+To4KRycGn+6n5vThqYq1BdDnSOXHriABoV1B9BYRLqkgeOP/HDR5yJa54u2/4iuwCa9FjHtwAC4HA9eE7armck+GfaPacvusAz5YPpgVOCCWvwTdl0DrDnvr0piFRyMBacyVrpz+/zG+53pAjZVSfslFKM4AOU9NFrF/95bnYgAVPFsyRk6uooRrku4sRIm+aa5ecTphJwO1gtwpsk/PYHxhbGvl8HhPnwHpVUSR2JZXcehkZIeP01m5C2n18INnzWySvtxhAHTtcaJsqethBrgTC4Cn6m+eCFCOcbapdALA6jiz0I3IJRdSe9smsMO/mE+n9oKB8q7yBuLredPyq3EeOg2zTpmK6qgsiirm4SKn1oxNofW1VWVrF3RnoUImA1TGgYBilVBJvvwngGLdXeXcKtRcbNSwu9H4w9guUAb+K3M33yuNwMz8ycyd9 X-OriginatorOrg: oss.nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 05ce8cc3-27b0-4266-5af8-08d98268d8e1 X-MS-Exchange-CrossTenant-AuthSource: DU2PR04MB9020.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 28 Sep 2021 10:15:08.0475 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1B/8ktsjXmC9RlqyPIZehEMlunGfXdSOPyIdI61WuwyM2giNMSofIHWaZWNDJrnrRWOQJff41QyKskGHIniwBg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: DU2PR04MB8807 X-Rspamd-Server: rspam01 X-Rspamd-Queue-Id: 735AEB000185 X-Stat-Signature: w61pnu64q6gi7wxjmzwtgx4qybb8nsuq Authentication-Results: imf25.hostedemail.com; dkim=pass header.d=NXP1.onmicrosoft.com header.s=selector2-NXP1-onmicrosoft-com header.b=YHJc7AhE; dmarc=pass (policy=none) header.from=nxp.com; spf=pass (imf25.hostedemail.com: domain of peng.fan@oss.nxp.com designates 40.107.6.62 as permitted sender) smtp.mailfrom=peng.fan@oss.nxp.com X-HE-Tag: 1632824122-497954 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000001, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: From: Peng Fan mem=[X][G|M] is broken on NXP i.MX ARM64 platform, there is cases that even type.cnt is 1, but total_size is not 0 because regions are merged into 1. So only check 'cnt' is not enough, total_size also needs to be taked into consideration, othersize bootargs 'mem=[X][G|B]' not work anymore. Fixes: e888fa7bb882 ("memblock: Check memory add/cap ordering") Cc: Mike Rapoport Cc: Geert Uytterhoeven Cc: David Hildenbrand Signed-off-by: Peng Fan --- mm/memblock.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mm/memblock.c b/mm/memblock.c index 184dcd2e5d99..ab67b82a9cce 100644 --- a/mm/memblock.c +++ b/mm/memblock.c @@ -1687,7 +1687,7 @@ void __init memblock_cap_memory_range(phys_addr_t base, phys_addr_t size) if (!size) return; - if (memblock.memory.cnt <= 1) { + if (memblock_memory->cnt <= 1 && !memblock_memory->total_size) { pr_warn("%s: No memory registered yet\n", __func__); return; }