From patchwork Fri Oct 18 16:17:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13842035 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3FFFAD30019 for ; Fri, 18 Oct 2024 16:18:18 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id BC61C6B007B; Fri, 18 Oct 2024 12:18:17 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id B75DD6B0082; Fri, 18 Oct 2024 12:18:17 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3D776B0083; Fri, 18 Oct 2024 12:18:17 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 862CF6B007B for ; Fri, 18 Oct 2024 12:18:17 -0400 (EDT) Received: from smtpin29.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay04.hostedemail.com (Postfix) with ESMTP id 4F7CC1A1AF8 for ; Fri, 18 Oct 2024 16:17:55 +0000 (UTC) X-FDA: 82687230108.29.0B6E16A Received: from mail-pf1-f178.google.com (mail-pf1-f178.google.com [209.85.210.178]) by imf13.hostedemail.com (Postfix) with ESMTP id D715E2001A for ; Fri, 18 Oct 2024 16:18:03 +0000 (UTC) Authentication-Results: imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OfZH3XaP; spf=pass (imf13.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729268246; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:references:dkim-signature; bh=lI1lmoX0aShbqtjbwicYm75B+4+2640ny91XLHS0QLk=; b=dgNs3A+yEjY537xmrZTaJU0YoZT8wXILomK3uG9WayTCG3t9w15sV9uaIS49Uecy4QWmCX 5cXbyDy5yd8BeqCLcLhr066/3Yv20ILKOxGyRxxtmuuzzo5EKiRf/8KtYMUJm91gnkDbEv w+/w/37s20qijuZ5CR6d6Y8WFbnvbVo= ARC-Authentication-Results: i=1; imf13.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=OfZH3XaP; spf=pass (imf13.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.178 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729268246; a=rsa-sha256; cv=none; b=iFJsc1WxsAwgYOoO86Mhy9vm/wv0mX4TO3nwoX+NvQsUyPh99NuvwoJUhKkLyGd2VJ5mkC 8lI1DFXFbboEEbymWV4i7XceO/8TsrjrKKIEcCULogFPyTwK5Bnbey/4k692nKwUM2yYEe Wysa0SfV46D1Al1mJcEc9UL3vLHy6wA= Received: by mail-pf1-f178.google.com with SMTP id d2e1a72fcca58-71e5130832aso1643903b3a.0 for ; Fri, 18 Oct 2024 09:18:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729268294; x=1729873094; darn=kvack.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=lI1lmoX0aShbqtjbwicYm75B+4+2640ny91XLHS0QLk=; b=OfZH3XaPSHEu+Vyik6jj4CppCoSEwYn5FJk07hFVNowmcyYuEZICg7cX0SrJoZTe7w m4m8htE1ga0kRhPIwYvBw/Hl7XjLYISRgWwcxlwhpOd7eLvY7ycLRxyQgHwH4f24sCEu qt0YcFfnodkyla2zRCtdhXAMd/YXWs8YT4C0oClMonn7epURUV9B7h3MpodEmK2fHH+b xOuROxp3FZd1xjx/ucRyojC0wlh3HzE9AFEnwxuTjeoiY9T8ujO+Wx6kdBsGakjzpb1t /VgR6MFW+CaY9CN7XZ4P6dGSaAZA3PSVmIc5nzyZGnMAlX1rTlCS4gRjuoYY03lLVmI3 DTRQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729268294; x=1729873094; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=lI1lmoX0aShbqtjbwicYm75B+4+2640ny91XLHS0QLk=; b=qHintU9Ro8UvOWBHcP3KQ7O10ToRlvqqGy3FJLz2OFO9K8pvCsPay3PGeUz6Tz7ew0 umg8ThBurf+7+wp0B6KvgA9ana9QufwkdRiSRMw9HA+1FiSYo6PuYUNXVnEtP1kxYxns Afb8sbqNfdztTkRjVLHhDhOS3kQyiLh+dEigrmDpFcfsiDPZbdQL2XXfJb+9Xs/GPMMv hijcANUZkTHxYZhmmiq3Im/6aj9zTxqZC641Wu1L2XyRBFCV1kpI0pj51hVna1j7RuCc 41mSdXUDDUfwCGv5+EEcPsnze4+czbZXZOJrGgcpXwVlvZH1WAdlVn+80oEjQUCa//QJ qewg== X-Gm-Message-State: AOJu0Yzvsr/6V8GBeOMT0ZFCcFqTBBTVlA8K3TUaMDO1JNPN1hzYkGiF MUOYx5XdcTlNzDPzgI/0Plop5hW5ExdKxPIvx7m13mUYIwIc62Pd X-Google-Smtp-Source: AGHT+IHzJGqOqiYMgY0XNWgsPScuQIuvxXcZGIlbc7649iguD7LwhL7RFqPyEBoqw+pUDCliOqawww== X-Received: by 2002:a05:6a21:6801:b0:1d9:278a:9ab with SMTP id adf61e73a8af0-1d92c56d430mr4837764637.35.1729268294000; Fri, 18 Oct 2024 09:18:14 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea345677asm1692140b3a.147.2024.10.18.09.18.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 09:18:13 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Zi Yan , David Hildenbrand , Sourabh Jain , Hari Bathini , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [PATCH v4 1/3] powerpc/fadump: Refactor and prepare fadump_cma_init for late init Date: Fri, 18 Oct 2024 21:47:55 +0530 Message-ID: X-Mailer: git-send-email 2.46.0 MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: i8bungm77hdtchtnp57kw7i8cb156oyc X-Rspamd-Queue-Id: D715E2001A X-Rspamd-Server: rspam11 X-HE-Tag: 1729268283-122563 X-HE-Meta: U2FsdGVkX18/77U0bnPmE86gW2KJNa46QP71iNSbflvuFAhCPOHFZPVmRleeque3NSnQavpdlYo4hDhMR5u5sW09Qb3ysV2gxjq0VkGAW99BqW26n/Kw5x9ngDJURnpQiwcPka1ohjGve38IDJjy4UDeDlCagvDgUZS+DVAr172hLMW+wUQ2o1LMET8Y9aRNHd2QuMbQRMT+V2xV7EESCeCWFw3rGX+WRwGX+BXubEwOVgJArwTkXqBvJfMSgo7/FTW81B4Fs/gjIzuoreCmV3RORkpeCGQw9gLwEuNXIrESfNa46ZsxYu8rK8n4doGL2FiQ5NilbiBMuK7/R6DMXKlcnUjFpFQNo9GHCL+cv9Swev37I+Rd8ZIJewtcT03g6sTnklXpj+xuoAu9EjDYhcGw9uXgcAPZYVnHQ2xGt9obF4lOfu8hZFbQsR1ei68NqQh4JTGDLDgMORDpc5W8+g68X/4idTLV3eTS0XcsKjpwQzt9vZaECy8v5baWglq6ea8sUq3sUEJlX4u74S3afLBmMRPrzZJ6FpcknByxnm6E/f+pCpPDLxktfXJHHf9f9PKAZ39fMsK7PBbAUFzO0qv9IKr6lgj051u1MgGF+dHCjQANvUhP4euufAvuifATJp8FKRPoliV5hTt+5GaAn5JDzALgEiXtfBWK06hgBL+wAl62O9XXkUWnWrlxPhjPdB6N6xSkznFL3Z1GCNNZdkMYhS0oCNRs324i6nAQPaYb37hCbuWNgyN+u0eouWMiRlU4/TWQNWM60emIwK/fgyn0AfqrdkA8jfJKkKBk1MDosfQn5GzskzPIlIHeXM4FNfdbEpt90+NYM9GDgpCfooCPqLA1EDAv9IYjI1QQ175qHLRl6x+XhA6BbC2CUd1hOlR7yNvvtvZDhiXOrCUtacmo0nO9JdhVmS9IJhkdFH5LIxs5Gvu/2OiNkLksiakxfuItVZ+C7XMo217eqGd pbQBdSXt UM9ppPeDkTjRN4PY7UQhtP0qX74Fl5R1QlP0DieqNQRot5Vv5qSPVzUEW/xREO5XWAa0g98RUdhgSmc7+N05UpbbZwXMVsTr4nazqWv0VmCIwhjQlH+UzMeAKK8hMD4e05q9LVVi/k1KwET6Z0yEnC9uoH3dJIY9NJnv4NcdzBLi72APKvib8IB6OXN74F6riZS+suJS0drUi+5ZPCUV3+Ay9x5e9zk5pVBLT+7ynfV0GIopTvUxm41KHva6dNZyCJEHTLGBEXhEg8Y+PtDLC5kMwLctvBDccunaIecH0j5KUNgNGxerGm2sZQxl2MlgrIJk9gxtTc4PPr7IbEIPVEQ4NXA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: We anyway don't use any return values from fadump_cma_init(). Since fadump_reserve_mem() from where fadump_cma_init() gets called today, already has the required checks. This patch makes this function return type as void. Let's also handle extra cases like return if fadump_supported is false or dump_active, so that in later patches we can call fadump_cma_init() separately from setup_arch(). Acked-by: Hari Bathini Reviewed-by: Madhavan Srinivasan Signed-off-by: Ritesh Harjani (IBM) --- v3 -> v4 ========= 1. Dropped RFC tag. 2. Updated commit subject from fadump: <> powerpc/fadump: 3. Added RvBs and Acks. [v3]: https://lore.kernel.org/linuxppc-dev/030b6d46fddac126a6cf7e119bea48055338f0ed.1728658614.git.ritesh.list@gmail.com/ arch/powerpc/kernel/fadump.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index a612e7513a4f..162327d66982 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -78,27 +78,23 @@ static struct cma *fadump_cma; * But for some reason even if it fails we still have the memory reservation * with us and we can still continue doing fadump. */ -static int __init fadump_cma_init(void) +static void __init fadump_cma_init(void) { unsigned long long base, size; int rc; - if (!fw_dump.fadump_enabled) - return 0; - + if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled || + fw_dump.dump_active) + return; /* * Do not use CMA if user has provided fadump=nocma kernel parameter. - * Return 1 to continue with fadump old behaviour. */ - if (fw_dump.nocma) - return 1; + if (fw_dump.nocma || !fw_dump.boot_memory_size) + return; base = fw_dump.reserve_dump_area_start; size = fw_dump.boot_memory_size; - if (!size) - return 0; - rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma); if (rc) { pr_err("Failed to init cma area for firmware-assisted dump,%d\n", rc); @@ -108,7 +104,7 @@ static int __init fadump_cma_init(void) * blocked from production system usage. Hence return 1, * so that we can continue with fadump. */ - return 1; + return; } /* @@ -125,10 +121,9 @@ static int __init fadump_cma_init(void) cma_get_size(fadump_cma), (unsigned long)cma_get_base(fadump_cma) >> 20, fw_dump.reserve_dump_area_size); - return 1; } #else -static int __init fadump_cma_init(void) { return 1; } +static void __init fadump_cma_init(void) { } #endif /* CONFIG_CMA */ /* @@ -638,7 +633,7 @@ int __init fadump_reserve_mem(void) pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n", (size >> 20), base, (memblock_phys_mem_size() >> 20)); - ret = fadump_cma_init(); + fadump_cma_init(); } return ret; From patchwork Fri Oct 18 16:17:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13842036 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id EB89CD30019 for ; Fri, 18 Oct 2024 16:18:22 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 7807D6B0083; Fri, 18 Oct 2024 12:18:22 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 72FE06B0088; Fri, 18 Oct 2024 12:18:22 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 5AAC46B0089; Fri, 18 Oct 2024 12:18:22 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0012.hostedemail.com [216.40.44.12]) by kanga.kvack.org (Postfix) with ESMTP id 3C5B06B0083 for ; Fri, 18 Oct 2024 12:18:22 -0400 (EDT) Received: from smtpin23.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay02.hostedemail.com (Postfix) with ESMTP id E0AD4121C4F for ; Fri, 18 Oct 2024 16:18:10 +0000 (UTC) X-FDA: 82687230108.23.14CA067 Received: from mail-pf1-f172.google.com (mail-pf1-f172.google.com [209.85.210.172]) by imf03.hostedemail.com (Postfix) with ESMTP id A132F20008 for ; Fri, 18 Oct 2024 16:18:14 +0000 (UTC) Authentication-Results: imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LmuEy8By; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729268180; a=rsa-sha256; cv=none; b=NcI/0vn9Q9w1K9h+Rnd1e8jHDjXqiK25x693f287c2BAQiRW52mDtWhzm5BkIaCFbWIxaM 6BIbuBZKKiczkpiQt3/ZUSSz+XWABMKRVuPSxqOQxeoxlGbHofwzniIbuL85Dj8JjSbjeZ HK8xgm2gtfOgdy3Z+LRlBHWb01yj25Y= ARC-Authentication-Results: i=1; imf03.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=LmuEy8By; dmarc=pass (policy=none) header.from=gmail.com; spf=pass (imf03.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.210.172 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729268180; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=1OVm1aMfcJH+C5h2HeT9933XrsU2qvy2OkpNXm8z7tg=; b=7onBV3T+Zr6auZC0fh7Lwf98EXURDxGai41DJIx2ApDRxGh737uU1FW8vWiYOwSQskRVEX gUE6rdQPf3zce6qQjj8cFGa86UEAYhwrRO14eo0k2B2ZjkLEY6AdLlk4Fj3YPvC69x2jZu W4wtrOuZhvztIerKGxuH2lIRl8/aS6s= Received: by mail-pf1-f172.google.com with SMTP id d2e1a72fcca58-71e579abb99so1646520b3a.2 for ; Fri, 18 Oct 2024 09:18:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729268299; x=1729873099; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=1OVm1aMfcJH+C5h2HeT9933XrsU2qvy2OkpNXm8z7tg=; b=LmuEy8By3BqhCEYxtafmZ+EHUWXSiJybY+fEKIcI/UZXUlkXey52T5KuBFfZwtc76G 62IsYC0YOPvzl5uHMBjkFTtSZVGgysjDTVfe5wVsU1oygFkNJ7RpDABNf775gkdKsrET 4lp73vRD9HLLd/TVTPxgFWR0AK6DaqZldOhswAehalF0cTHgNgg+DZsm8grGfFI8aSpj 70w+SrBy4PJekhUW+IfargPyTHs5AgluB5rI/6RIlKCTu42SOMvr+FCFlTGtyyuvX+hZ MT0GhfoqZ2Mxi8sf9ISnmHWzEAhoR/ekR6Txm2El8S76wsbFHBgP/UyD9cdJdQ/L7rHf w7Hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729268299; x=1729873099; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=1OVm1aMfcJH+C5h2HeT9933XrsU2qvy2OkpNXm8z7tg=; b=bJshj/cbNWpi1a1/WBzPjuu9vU8fcBg8mInY71IjY/pTX4eudDu2butW7YK+crz9Za YC0zkQErCbLmVtbgB9Goi8Qd3ymIIEnpWt2mgSqYyJqu9nZ64ADx/amDEDPqhEn7T7Ps X1JfGVi0WEzuVMfby8BVc8qy+8yzjMYU6ymCSEfECaMYIhkY+xUQx/cT7M4/qml8ga4W xTD16j4R1nvbaCTIoxKX9wQbsMJqvjGBfN4olvxw9UhG6EQ2aabe5lbC+AkVVfmvmycR mOkxHiA7wo0XOy/Hftsi0xMsA2FH1R7UgKOdikeU8+rzFqUmP9B8MFSOby+N4Xu2fbCc iOhw== X-Gm-Message-State: AOJu0Yyeo6BPYBkknObLhg8kJd+fyJbE7baWbtHRM5omuhv5zI6QNLrk iRDJTUt+WevdMwzrb8lPX5MSAUDZjaUnlQRPdzQotHRN+McsVO/w X-Google-Smtp-Source: AGHT+IFYn+jHU87+CuAdiC2bANQdqGrWOhnXYjaGpsSCpU5oDVmDDYqIstLDV3L6h3hQlUt3per1nw== X-Received: by 2002:a05:6a00:c84:b0:71e:58be:3604 with SMTP id d2e1a72fcca58-71ea31923b9mr4310756b3a.4.1729268298529; Fri, 18 Oct 2024 09:18:18 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea345677asm1692140b3a.147.2024.10.18.09.18.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 09:18:17 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Zi Yan , David Hildenbrand , Sourabh Jain , Hari Bathini , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [PATCH v4 2/3] powerpc/fadump: Reserve page-aligned boot_memory_size during fadump_reserve_mem Date: Fri, 18 Oct 2024 21:47:56 +0530 Message-ID: <805d6b900968fb9402ad8f4e4775597db42085c4.1729146153.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspamd-Server: rspam12 X-Rspamd-Queue-Id: A132F20008 X-Stat-Signature: b9ypi3sgah98uxp4todfidxj3rrokgx5 X-Rspam-User: X-HE-Tag: 1729268294-310738 X-HE-Meta: U2FsdGVkX1/HeRITAih+9tDu+fA1n+fWzXjAJytrGR3SnfAvq3RlBSQoO8lvEZk8U1N7KIDJJmCWyYrI1Yx5TlHItc8v+txCminTGSTmbRhKNnJl7jnsyk3Vedngo4OgPjX+fiB6Zo/V2RjJhG8ri8xEXtW1oKbslZ/vav806cJspcEaxyT0qhqgh51CVscA/RrI34j4cPH7Oqvg7hPXMqkRrAHgdCd2NvIQOyTtLnXgG5WGD9+c80VEDyAzIGkt2+M+0s4imixLKwXrRzc2VrOxsxDYd1O9plTcYdJgBHAZsgZuJ1capoNjeDyDZaLn4FRSlXoxHqZt6YzBA8IWMnXZ0PENtpHMq/Fo2YGVjMESfk5skiGU/6rtSQtfdbRVUwA2jc5T6dH3WeF7UsNxxUEEYsjE/Uk9huXhcPLaPmVcKwbhzG6X34RZ9FRYSmRKvBSPhxWhy2JPjMKyfL1VM17XYXhDSkIJHrVNCkBRu8RB4aS8dSkh8ctbvBy9pc0vHam7zowBMhLRgW7+skqiLN+UNTdCjHlj9JLoGsRoP4x2bTOSmvjBCvcZQjX2bD99bvxSf0GqBuQqJCpReQ4fBEGvAgEVFSOKoM+zCJaL79Hr6Arrz+OrCuWt0YpBvvA5YWgsC/nJqyovyDCoGT2tWfNULOm540v/aGggpoL7LJct11Rs48DCQpq2oNM3xewPqAoZ58afFJPzBOl6qjH1OJMTvJU9LKrbPxOMYtHFqy7nlDa6pzaYUU7TUsP/G857OqyTLYext+OuMW7eSA3Qbkdh+dmJC75wxzI1B/d2+oY1gQwadyXwoywzYu2dau5SQvq4VPrVCiHDySS/W1SZnYj0knMzlaosUFJ5GYsNUXFXJxQTbUa9ngPWSxFYTd4Kft+1DjDUdq0IYI+7DlktOQtf8oH1AO+vmRBGYj8GSYipPMy6yqjbUDhE65RytAJNEut6zJrMA2EV+4KkaFO j7pQRZ9U RDtskJ2Pwk3693JctXMkPnUn6oBndYXi7q6RyOekrI9zfkor4y6cezetFgoyoea/HUkKpQoEXoqghFkep4Af646tDnR8RDCOfVv2NSc1F/dj1vYAAgSc6jxxy1PcEji+uRrENMMd+UyP5Zy27/v3euXRlEqqKoTLKtYgvB1m4ig53ddasqUzMLeCUiohTD5/Qq/OjnKx7dIbjmtVCP19a4gfAiH6kAJrrwdqicx3LfnTk03S7yMbyk8bF/oAySHjMadEsLLEOQcaeDJz4zPL8qoqmLDSw35Q/HwYNfvSMFog/c3FS9uCEYTYwXSn8OgdPmLJkmQj8mH0M0+/ojCH69snR7g== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: This patch refactors all CMA related initialization and alignment code to within fadump_cma_init() which gets called in the end. This also means that we keep [reserve_dump_area_start, boot_memory_size] page aligned during fadump_reserve_mem(). Then later in fadump_cma_init() we extract the aligned chunk and provide it to CMA. This inherently also fixes an issue in the current code where the reserve_dump_area_start is not aligned when the physical memory can have holes and the suitable chunk starts at an unaligned boundary. After this we should be able to call fadump_cma_init() independently later in setup_arch() where pageblock_order is non-zero. Suggested-by: Sourabh Jain Acked-by: Hari Bathini Reviewed-by: Madhavan Srinivasan Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/kernel/fadump.c | 34 ++++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 12 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index 162327d66982..ffaec625b7a8 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -80,7 +80,7 @@ static struct cma *fadump_cma; */ static void __init fadump_cma_init(void) { - unsigned long long base, size; + unsigned long long base, size, end; int rc; if (!fw_dump.fadump_supported || !fw_dump.fadump_enabled || @@ -92,8 +92,24 @@ static void __init fadump_cma_init(void) if (fw_dump.nocma || !fw_dump.boot_memory_size) return; + /* + * [base, end) should be reserved during early init in + * fadump_reserve_mem(). No need to check this here as + * cma_init_reserved_mem() already checks for overlap. + * Here we give the aligned chunk of this reserved memory to CMA. + */ base = fw_dump.reserve_dump_area_start; size = fw_dump.boot_memory_size; + end = base + size; + + base = ALIGN(base, CMA_MIN_ALIGNMENT_BYTES); + end = ALIGN_DOWN(end, CMA_MIN_ALIGNMENT_BYTES); + size = end - base; + + if (end <= base) { + pr_warn("%s: Too less memory to give to CMA\n", __func__); + return; + } rc = cma_init_reserved_mem(base, size, 0, "fadump_cma", &fadump_cma); if (rc) { @@ -116,11 +132,12 @@ static void __init fadump_cma_init(void) /* * So we now have successfully initialized cma area for fadump. */ - pr_info("Initialized 0x%lx bytes cma area at %ldMB from 0x%lx " + pr_info("Initialized [0x%llx, %luMB] cma area from [0x%lx, %luMB] " "bytes of memory reserved for firmware-assisted dump\n", - cma_get_size(fadump_cma), - (unsigned long)cma_get_base(fadump_cma) >> 20, - fw_dump.reserve_dump_area_size); + cma_get_base(fadump_cma), cma_get_size(fadump_cma) >> 20, + fw_dump.reserve_dump_area_start, + fw_dump.boot_memory_size >> 20); + return; } #else static void __init fadump_cma_init(void) { } @@ -553,13 +570,6 @@ int __init fadump_reserve_mem(void) if (!fw_dump.dump_active) { fw_dump.boot_memory_size = PAGE_ALIGN(fadump_calculate_reserve_size()); -#ifdef CONFIG_CMA - if (!fw_dump.nocma) { - fw_dump.boot_memory_size = - ALIGN(fw_dump.boot_memory_size, - CMA_MIN_ALIGNMENT_BYTES); - } -#endif bootmem_min = fw_dump.ops->fadump_get_bootmem_min(); if (fw_dump.boot_memory_size < bootmem_min) { From patchwork Fri Oct 18 16:17:57 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Ritesh Harjani (IBM)" X-Patchwork-Id: 13842037 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 kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4670ED3001B for ; Fri, 18 Oct 2024 16:18:27 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id C14EE6B0089; Fri, 18 Oct 2024 12:18:26 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id BC4D96B008A; Fri, 18 Oct 2024 12:18:26 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id A3E5F6B008C; Fri, 18 Oct 2024 12:18:26 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0015.hostedemail.com [216.40.44.15]) by kanga.kvack.org (Postfix) with ESMTP id 8242C6B0089 for ; Fri, 18 Oct 2024 12:18:26 -0400 (EDT) Received: from smtpin04.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay08.hostedemail.com (Postfix) with ESMTP id 7F5FC1402A4 for ; Fri, 18 Oct 2024 16:18:13 +0000 (UTC) X-FDA: 82687230402.04.FF1F41C Received: from mail-pg1-f169.google.com (mail-pg1-f169.google.com [209.85.215.169]) by imf04.hostedemail.com (Postfix) with ESMTP id CE2B340009 for ; Fri, 18 Oct 2024 16:18:09 +0000 (UTC) Authentication-Results: imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DKrnZRdJ; spf=pass (imf04.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1729268255; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=uLmZcdH3+iUB7uSULBBt8ADH32xOpUfbglYzjMZPi2A=; b=sRWrO0dHKtv1qKN3x3HRIR5np2bjubqXnyzY7blMVj2mcu8yDnIjrAYE80eK+Wgq76W4Hq F73VUFBKhgKq1UXzaKNm/MpikQH2CsL+rVE2jRit8xmdVOT0aVIqZYEPczry2r/DiARHXZ b/wmZQyBnAfobx9L3R0wKE7LtH5k/XQ= ARC-Authentication-Results: i=1; imf04.hostedemail.com; dkim=pass header.d=gmail.com header.s=20230601 header.b=DKrnZRdJ; spf=pass (imf04.hostedemail.com: domain of ritesh.list@gmail.com designates 209.85.215.169 as permitted sender) smtp.mailfrom=ritesh.list@gmail.com; dmarc=pass (policy=none) header.from=gmail.com ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1729268255; a=rsa-sha256; cv=none; b=rX+POzUoSxyHBBRCkE4JZcR1+XEViu2uz+CcNG+WV/lWf6L/NrOD9LYOn9m3v7g5F9+g9b 2KrroJz2SqUQbYBVz6u9NDEicy0fonuEw6aGd7pJf0z0PZnOrQLxdcqQm36T4v/f9c3evl 1y45m1fBTlQoDxCZ316CeFV5F+1PC0Q= Received: by mail-pg1-f169.google.com with SMTP id 41be03b00d2f7-7db908c9c83so1523813a12.2 for ; Fri, 18 Oct 2024 09:18:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1729268303; x=1729873103; darn=kvack.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=uLmZcdH3+iUB7uSULBBt8ADH32xOpUfbglYzjMZPi2A=; b=DKrnZRdJn/9OlEp3yxjn2/7j/x8UPQoKbtJOk8zEdq3b6+XYOzIa4XVDpOnqUAO3Jz 6rCSBMncQzJ0Nz6oJEzoczCKENAIDzCeL2hSlAQv4DqCi2avTr8a4cReP/y4C6Tgajqu E1ri6wecLaKwC1TsS/VN17xcJVS8yqK1gr3IO5VUcpFukSYy8N7ypg0fZNOGjYMRHXKy L6KFWQWonn+SYgepD1TuSsLt7Cfo68R90sn0M7bN+P/w49i9NHi3LOTD6EOQgxAtvHCA o+BRNTs7yhuJDEKD+wAGbkD6KZs/dq5bBUERgmVUfkSuifOWoc7ewQQVHRx0LDgrBC9V hS+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1729268303; x=1729873103; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=uLmZcdH3+iUB7uSULBBt8ADH32xOpUfbglYzjMZPi2A=; b=OopnCX9REawc7zn/EpGaEpHEbp8dsmMwrvNdnVlDVklDpvENsAkGsH1vzFoMPMtSDe onVk29PtJ0Y1n8mypo8b0L+y2jK1sqJtJiKD5TRtSyw9SoAc7JFkhYHYwdhW4SnxM5xf qUPOhGM6ZC7IsAagSK6sQULwkmYqTPr9yGiKbqiE/pA4oYvb8SHS2IlCq8iaJYfrQr2Q gtDXNqEstIDVvg/XJK0yFHkRp4Y8Ha+Sf5yV9mAgODCRTs4VztYpCeb9sVcGB1yViDnV 2Eg+LVVI7H24DEsLPbgajGeuxqpdx2BobdkP5pKb6VkEKKKv49rXxKqK0yQ/cA0DnQ9M huCw== X-Gm-Message-State: AOJu0Yw8L46l5cHOLdWt4N7uAFIuaPtdPrqUXxoC3zvdgq8CX8YdI56L IZepHOjo7mhnhmC8Q2VAMeInSwFjBM8P35dUqKp42I4TOcfinm1c X-Google-Smtp-Source: AGHT+IFFH2dXD4/u8KGoMcsdlAu0XJqAkbNBFR0eSBy3BkBtBCA1KnsX++lMxG2V+BFH8gOUwBq8xQ== X-Received: by 2002:a05:6300:668a:b0:1d9:2992:d6c2 with SMTP id adf61e73a8af0-1d92c49fc95mr3759338637.2.1729268303039; Fri, 18 Oct 2024 09:18:23 -0700 (PDT) Received: from dw-tp.ibmuc.com ([171.76.80.151]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-71ea345677asm1692140b3a.147.2024.10.18.09.18.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 18 Oct 2024 09:18:22 -0700 (PDT) From: "Ritesh Harjani (IBM)" To: linuxppc-dev@lists.ozlabs.org Cc: linux-mm@kvack.org, Zi Yan , David Hildenbrand , Sourabh Jain , Hari Bathini , Mahesh J Salgaonkar , Michael Ellerman , Madhavan Srinivasan , "Aneesh Kumar K . V" , Donet Tom , LKML , Sachin P Bappalige , "Ritesh Harjani (IBM)" Subject: [PATCH v4 3/3] powerpc/fadump: Move fadump_cma_init to setup_arch() after initmem_init() Date: Fri, 18 Oct 2024 21:47:57 +0530 Message-ID: <3ae208e48c0d9cefe53d2dc4f593388067405b7d.1729146153.git.ritesh.list@gmail.com> X-Mailer: git-send-email 2.46.0 In-Reply-To: References: MIME-Version: 1.0 X-Rspam-User: X-Stat-Signature: pr557tuk469rqaqy1x55rmkbhjkfcq6u X-Rspamd-Queue-Id: CE2B340009 X-Rspamd-Server: rspam11 X-HE-Tag: 1729268289-884114 X-HE-Meta: U2FsdGVkX19WfoFtCsBtrLLWr/W4xN0jJEFAVndbfXy3QAjFx9yCF81hD22KDM9dZ7eXa6c2Np6oXO3K5PbYQgsKiWVJvDliqhsi+mlCxTxfhfOQxu6EADsLQdxzacolB8FRnVm+ZmCxlEhGibkG55f8hfP0GKa7IBt5T+pV6BFLT/auMFrUT8yPXc62quBNOKCQczb1Ols3TX/SkwikXhQxlehY0MRPcR9V/OpUQtmxNTFDopA0JT+OH4Wm98ABVdq6mf6uojSpurzQNTHYE3JMbhin/lyT7yDW9xbgg63R5wQW7LGi0FgGEDGWprLEEN+xaSK/Irs8pUdk51+pdBUab8kPWM3832D996ZdwVnK8QxgQveo0uvS9UbwVkuRQnlsVvpHuYPyfkWH0UNTlkqAqIM0+y8VwatRb8N3lSQRf8Ly+/5yhXCCPo9LLEADzc2XPLujPNiUJfpBlgzvKKbPA8MEpE1HZL4BQXjvb5I0qOFklNwMctGAmq/cUhyXurGBZ7u4JzlBarPp7ZPbhUIj29esCy2+YEal8MMeViL2Hjrt8BM4j06QkV9WlkEnQ6jZNB3FZYyeU0rn0FYz2niNUWd4DzLhkZ6GdmxyQEioExSc50ArzT+1B4TNcoFIHt380pH41HXi5UNyKF0ZT8JjPvKo3AZaG63C0ODKdXLP27Bwje8WnoMUffTauHhwI6YnLixeemEUlOpKzFHypXU0I0LOiEoFzMhwMxcugzTDQwwnrM6IKIkVQKe6enwfSi9cz619rbEy7MVOBvoLkxSlNzA+3+9UpCeRkDyboAtcIm/XrUynrK81ArUBM0S3QweytyEOK3QBYGAOVcusUJx/eoPWiLPB2CEDXY6I91TeSHqsE5UtkHcqlUClIojRxMvlpMghHdrLT4ZAk3HU2RB4GshKmI0eu9YZctxFsykbVQoEhgJKVBEZtE/oQ1g00y5facGX9GpAlKRyzjc Cdjq6Gtc 14BUe/YuWK53pxIAWsWBB/RYTSP9SC01jPZbHMSjwpJN8JiEYtSzP0xmR1NvKWVFoDoz9pkP0iySWn5Crjoql97aXjji4nA1u/5rHIuZff/enbMrhsp+c+4lHUqtsHo1P0HqU6jJT+6X8dxxZo4qu3UbJa80eV8CDpOfMPTTB0ZJOyepOQTM5AgKBcZhNv/8ghT17/K02TvD2u8qnoUv1comtnBeo2Xchr3rYh6GF+KLUt62v0W3BcYWmGo43yPeZ01hrnTyhbQsjc2empoyiv83BA2CWtmWCiOFQk48U1RYXHtx+LcOC4GeWQFx9OYTV4col+zUzbv6FT7AJJV2TUWVSYA== X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: List-Subscribe: List-Unsubscribe: During early init CMA_MIN_ALIGNMENT_BYTES can be PAGE_SIZE, since pageblock_order is still zero and it gets initialized later during initmem_init() e.g. setup_arch() -> initmem_init() -> sparse_init() -> set_pageblock_order() One such use case where this causes issue is - early_setup() -> early_init_devtree() -> fadump_reserve_mem() -> fadump_cma_init() This causes CMA memory alignment check to be bypassed in cma_init_reserved_mem(). Then later cma_activate_area() can hit a VM_BUG_ON_PAGE(pfn & ((1 << order) - 1)) if the reserved memory area was not pageblock_order aligned. Fix it by moving the fadump_cma_init() after initmem_init(), where other such cma reservations also gets called. ============== page: refcount:0 mapcount:0 mapping:0000000000000000 index:0x0 pfn:0x10010 flags: 0x13ffff800000000(node=1|zone=0|lastcpupid=0x7ffff) CMA raw: 013ffff800000000 5deadbeef0000100 5deadbeef0000122 0000000000000000 raw: 0000000000000000 0000000000000000 00000000ffffffff 0000000000000000 page dumped because: VM_BUG_ON_PAGE(pfn & ((1 << order) - 1)) ------------[ cut here ]------------ kernel BUG at mm/page_alloc.c:778! Call Trace: __free_one_page+0x57c/0x7b0 (unreliable) free_pcppages_bulk+0x1a8/0x2c8 free_unref_page_commit+0x3d4/0x4e4 free_unref_page+0x458/0x6d0 init_cma_reserved_pageblock+0x114/0x198 cma_init_reserved_areas+0x270/0x3e0 do_one_initcall+0x80/0x2f8 kernel_init_freeable+0x33c/0x530 kernel_init+0x34/0x26c ret_from_kernel_user_thread+0x14/0x1c Fixes: 11ac3e87ce09 ("mm: cma: use pageblock_order as the single alignment") Suggested-by: David Hildenbrand Reported-by: Sachin P Bappalige Acked-by: Hari Bathini Reviewed-by: Madhavan Srinivasan Signed-off-by: Ritesh Harjani (IBM) --- arch/powerpc/include/asm/fadump.h | 7 +++++++ arch/powerpc/kernel/fadump.c | 6 +----- arch/powerpc/kernel/setup-common.c | 6 ++++-- 3 files changed, 12 insertions(+), 7 deletions(-) -- 2.46.0 diff --git a/arch/powerpc/include/asm/fadump.h b/arch/powerpc/include/asm/fadump.h index ef40c9b6972a..3638f04447f5 100644 --- a/arch/powerpc/include/asm/fadump.h +++ b/arch/powerpc/include/asm/fadump.h @@ -34,4 +34,11 @@ extern int early_init_dt_scan_fw_dump(unsigned long node, const char *uname, int depth, void *data); extern int fadump_reserve_mem(void); #endif + +#if defined(CONFIG_FA_DUMP) && defined(CONFIG_CMA) +void fadump_cma_init(void); +#else +static inline void fadump_cma_init(void) { } +#endif + #endif /* _ASM_POWERPC_FADUMP_H */ diff --git a/arch/powerpc/kernel/fadump.c b/arch/powerpc/kernel/fadump.c index ffaec625b7a8..c42f89862893 100644 --- a/arch/powerpc/kernel/fadump.c +++ b/arch/powerpc/kernel/fadump.c @@ -78,7 +78,7 @@ static struct cma *fadump_cma; * But for some reason even if it fails we still have the memory reservation * with us and we can still continue doing fadump. */ -static void __init fadump_cma_init(void) +void __init fadump_cma_init(void) { unsigned long long base, size, end; int rc; @@ -139,8 +139,6 @@ static void __init fadump_cma_init(void) fw_dump.boot_memory_size >> 20); return; } -#else -static void __init fadump_cma_init(void) { } #endif /* CONFIG_CMA */ /* @@ -642,8 +640,6 @@ int __init fadump_reserve_mem(void) pr_info("Reserved %lldMB of memory at %#016llx (System RAM: %lldMB)\n", (size >> 20), base, (memblock_phys_mem_size() >> 20)); - - fadump_cma_init(); } return ret; diff --git a/arch/powerpc/kernel/setup-common.c b/arch/powerpc/kernel/setup-common.c index 943430077375..b6b01502e504 100644 --- a/arch/powerpc/kernel/setup-common.c +++ b/arch/powerpc/kernel/setup-common.c @@ -997,9 +997,11 @@ void __init setup_arch(char **cmdline_p) initmem_init(); /* - * Reserve large chunks of memory for use by CMA for KVM and hugetlb. These must - * be called after initmem_init(), so that pageblock_order is initialised. + * Reserve large chunks of memory for use by CMA for fadump, KVM and + * hugetlb. These must be called after initmem_init(), so that + * pageblock_order is initialised. */ + fadump_cma_init(); kvm_cma_reserve(); gigantic_hugetlb_cma_reserve();