Received: by 2002:a5d:925a:0:0:0:0:0 with SMTP id e26csp1246344iol; Fri, 10 Jun 2022 03:34:39 -0700 (PDT) X-Google-Smtp-Source: ABdhPJw2rx4OEPamIdOvWVbpabc3dnWv0R9t8gPiCphUDx2nW5bIHvXqk6+pm3m6E4ARdEnUkt/q X-Received: by 2002:aa7:990e:0:b0:51f:2b9f:6402 with SMTP id z14-20020aa7990e000000b0051f2b9f6402mr3448432pff.9.1654857279200; Fri, 10 Jun 2022 03:34:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1654857279; cv=none; d=google.com; s=arc-20160816; b=hPdywdqOpnjpcqvsPLXrasgGEaxyJa3tOoo/2XFNL/ZLIUbOG67NLW7lgJMBWzn8oj N6d6028egrB2x/kqb7SXGFRvOoqYdGIsG7SAd5TYLTBX3sbJTaRZ609RjZPg3rMbfi/1 8IT7SSGlFLBMz8NnQHy7qPZf0iymRR0qahgYKvd0E+Y02YE2NEaB6mLIYSE7TEFKAz/+ MFc6b/IL6lNJt7vao7X2zUjJBPcdEKdD9N7rCl1GhsfRTw8dog15rBssmyEMfZ/8QL15 1xmiSMYHFF7idWanni8pCVhct9Tabaqk3Sw89CAeqbiJJsY2RpO5YjuAe8HY+QI4odWa aQcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:from :references:cc:to:content-language:subject:user-agent:mime-version :date:message-id; bh=9HWsxvAzYmKSlsPcVRmUsgy4UOeFcsTfpiLC+YE1crM=; b=vUr4yZcBk5/+uAuuvLVk1ii63vOJqlz1FZSK85tTuHhnU7zl5m1xLvucO+v8BEt1qb yVeRV98ij3iuwL7zTUllDg5jy3UiU99h0JpLAJFIJZcc+3jxlLPNYoCMc1NzX2Raj/Dw 71n1HduIGSLq3fV35g1Mx7wzlVD8fkB/eQtFJ8eVZzUSZLN0jJCEcfJsUmga4qRhME/L c+/thirN9TFPCFQ40qdRaGsaVXF52XkfzvfXU0kzgDGpqLw4j36ENwNLBv9sB4LYtORw F6P77v6dzNH6TWke/38qhinex2Eeu0CE5cp0t0HzKlfhpbSzBbKcgtHiEthqbk3+8VNe 2cog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id z9-20020a170902ee0900b00163f4ffead4si31816043plb.349.2022.06.10.03.34.25; Fri, 10 Jun 2022 03:34:39 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=huawei.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346979AbiFJJZL (ORCPT + 99 others); Fri, 10 Jun 2022 05:25:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56288 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1349675AbiFJJYL (ORCPT ); Fri, 10 Jun 2022 05:24:11 -0400 Received: from szxga02-in.huawei.com (szxga02-in.huawei.com [45.249.212.188]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A8F80142A8C; Fri, 10 Jun 2022 02:22:32 -0700 (PDT) Received: from dggpemm500020.china.huawei.com (unknown [172.30.72.55]) by szxga02-in.huawei.com (SkyGuard) with ESMTP id 4LKFlS4W3FzRhtr; Fri, 10 Jun 2022 17:19:16 +0800 (CST) Received: from dggpemm500001.china.huawei.com (7.185.36.107) by dggpemm500020.china.huawei.com (7.185.36.49) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 10 Jun 2022 17:22:30 +0800 Received: from [10.174.177.243] (10.174.177.243) by dggpemm500001.china.huawei.com (7.185.36.107) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.24; Fri, 10 Jun 2022 17:22:28 +0800 Message-ID: <93222719-fcee-2a78-8822-b49944bf1b8b@huawei.com> Date: Fri, 10 Jun 2022 17:22:28 +0800 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Thunderbird/91.9.1 Subject: Re: [PATCH v3 1/6] efi: Make efi_find_mirror() public Content-Language: en-US To: Wupeng Ma , , , , CC: , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , References: <20220607093805.1354256-1-mawupeng1@huawei.com> <20220607093805.1354256-2-mawupeng1@huawei.com> From: Kefeng Wang In-Reply-To: <20220607093805.1354256-2-mawupeng1@huawei.com> Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: 7bit X-Originating-IP: [10.174.177.243] X-ClientProxiedBy: dggems702-chm.china.huawei.com (10.3.19.179) To dggpemm500001.china.huawei.com (7.185.36.107) X-CFilter-Loop: Reflected X-Spam-Status: No, score=-5.4 required=5.0 tests=BAYES_00,NICE_REPLY_A, RCVD_IN_DNSWL_MED,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On 2022/6/7 17:38, Wupeng Ma wrote: > From: Ma Wupeng > > Commit b05b9f5f9dcf ("x86, mirror: x86 enabling - find mirrored memory > ranges") introduce the efi_find_mirror function on x86. In order to reuse > the API we make it public in preparation for arm64 to support mirrord > memory. Reviewed-by: Kefeng Wang > Signed-off-by: Ma Wupeng > --- > arch/x86/include/asm/efi.h | 4 ---- > arch/x86/platform/efi/efi.c | 23 ----------------------- > drivers/firmware/efi/efi.c | 23 +++++++++++++++++++++++ > include/linux/efi.h | 3 +++ > 4 files changed, 26 insertions(+), 27 deletions(-) > > diff --git a/arch/x86/include/asm/efi.h b/arch/x86/include/asm/efi.h > index 71943dce691e..eb90206eae80 100644 > --- a/arch/x86/include/asm/efi.h > +++ b/arch/x86/include/asm/efi.h > @@ -383,7 +383,6 @@ static inline bool efi_is_64bit(void) > extern bool efi_reboot_required(void); > extern bool efi_is_table_address(unsigned long phys_addr); > > -extern void efi_find_mirror(void); > extern void efi_reserve_boot_services(void); > #else > static inline void parse_efi_setup(u64 phys_addr, u32 data_len) {} > @@ -395,9 +394,6 @@ static inline bool efi_is_table_address(unsigned long phys_addr) > { > return false; > } > -static inline void efi_find_mirror(void) > -{ > -} > static inline void efi_reserve_boot_services(void) > { > } > diff --git a/arch/x86/platform/efi/efi.c b/arch/x86/platform/efi/efi.c > index 1591d67e0bcd..6e598bd78eef 100644 > --- a/arch/x86/platform/efi/efi.c > +++ b/arch/x86/platform/efi/efi.c > @@ -108,29 +108,6 @@ static int __init setup_add_efi_memmap(char *arg) > } > early_param("add_efi_memmap", setup_add_efi_memmap); > > -void __init efi_find_mirror(void) > -{ > - efi_memory_desc_t *md; > - u64 mirror_size = 0, total_size = 0; > - > - if (!efi_enabled(EFI_MEMMAP)) > - return; > - > - for_each_efi_memory_desc(md) { > - unsigned long long start = md->phys_addr; > - unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; > - > - total_size += size; > - if (md->attribute & EFI_MEMORY_MORE_RELIABLE) { > - memblock_mark_mirror(start, size); > - mirror_size += size; > - } > - } > - if (mirror_size) > - pr_info("Memory: %lldM/%lldM mirrored memory\n", > - mirror_size>>20, total_size>>20); > -} > - > /* > * Tell the kernel about the EFI memory map. This might include > * more than the max 128 entries that can fit in the passed in e820 > diff --git a/drivers/firmware/efi/efi.c b/drivers/firmware/efi/efi.c > index 860534bcfdac..79c232e07de7 100644 > --- a/drivers/firmware/efi/efi.c > +++ b/drivers/firmware/efi/efi.c > @@ -446,6 +446,29 @@ static int __init efisubsys_init(void) > > subsys_initcall(efisubsys_init); > > +void __init efi_find_mirror(void) > +{ > + efi_memory_desc_t *md; > + u64 mirror_size = 0, total_size = 0; > + > + if (!efi_enabled(EFI_MEMMAP)) > + return; > + > + for_each_efi_memory_desc(md) { > + unsigned long long start = md->phys_addr; > + unsigned long long size = md->num_pages << EFI_PAGE_SHIFT; > + > + total_size += size; > + if (md->attribute & EFI_MEMORY_MORE_RELIABLE) { > + memblock_mark_mirror(start, size); > + mirror_size += size; > + } > + } > + if (mirror_size) > + pr_info("Memory: %lldM/%lldM mirrored memory\n", > + mirror_size>>20, total_size>>20); > +} > + > /* > * Find the efi memory descriptor for a given physical address. Given a > * physical address, determine if it exists within an EFI Memory Map entry, > diff --git a/include/linux/efi.h b/include/linux/efi.h > index 7d9b0bb47eb3..53f64c14a525 100644 > --- a/include/linux/efi.h > +++ b/include/linux/efi.h > @@ -872,6 +872,7 @@ static inline bool efi_rt_services_supported(unsigned int mask) > { > return (efi.runtime_supported_mask & mask) == mask; > } > +extern void efi_find_mirror(void); > #else > static inline bool efi_enabled(int feature) > { > @@ -889,6 +890,8 @@ static inline bool efi_rt_services_supported(unsigned int mask) > { > return false; > } > + > +static inline void efi_find_mirror(void) {} > #endif > > extern int efi_status_to_err(efi_status_t status);