Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2442316rdb; Fri, 8 Dec 2023 08:13:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IG2my2zxBrsjawUkq71IRsujX9cAS1ojK1gvm0R2BS5e33UZ+rBoyapX3fia4gW+vH9b97M X-Received: by 2002:aa7:8684:0:b0:6ce:725f:7da9 with SMTP id d4-20020aa78684000000b006ce725f7da9mr236096pfo.59.1702052030118; Fri, 08 Dec 2023 08:13:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702052030; cv=none; d=google.com; s=arc-20160816; b=ocCnZHF3AsN4XYkxrMqmkeAfVkg6hexln0yX4C88r8etqS83azdjPuOPc82b1bW9/e 64LnWrMbNabylOHY3E+AH69KZ+cLeQ3DYOZitYo+e9H9tFDEulUjvxzPCQ+TxL+ycFrd LOlGS/0Z+/NyCyrGayPoRrUAqDk9nDIyI6JAHVY3ePqcNqpr21SZm5uijsas9NkL3MuR XfxAfU7AN19wfqDRNSSJcElhkKK72hODv4WDZHLhdVeDic21mm+5lRsFV4gx4oJvNL4g YO2FY6VKxgONe00YC/9lKyhTkPT94Ju2IFbNgCJK3dzRX6PJiSH9IGf4SBzVd889zcmW E4QQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=RcHHna0h/IgIzh58pWB4uS96fnTDDQBk114hJ4c/spg=; fh=t1bsw/gEI8w3DN7ouBpAewoQyybWh2yxEgAHixB9Iis=; b=bcv8pbAJf9vvqWjpeYJigyQfe2uKaiugq79l9kn3VGBYIMdkOTl0m/fgns2+TOmuqL ukzLnUzQjm1odJv7gayeVTTUg62P8hK2Ntg0N/ROsqVcuu2HAoRgRulbm7Dpdb8jrj9v BlvzSH4c+6TAWnwb8rPWmI1ee4CfTpRvfOAdhpGl2AKtQSqRbEEIhHOHN88z3uVChRsC KJKJYz+n2R9gozi1E83FBc2aKPnn10S/ZPsLuQDmE60/ir3WLVgTgxLjv7ltDI0RRV5C HktMRw/RA/LJuWl2t55snK2B6p5PQEzyfvxASyp+EguIq/Lu4Cb7tMp1f4rd6KC8vEmD 9Scw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="ShlMJ/9E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id f13-20020a65400d000000b005c6001ec190si1781873pgp.892.2023.12.08.08.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:13:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b="ShlMJ/9E"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by fry.vger.email (Postfix) with ESMTP id EBC5A81BE830; Fri, 8 Dec 2023 08:13:44 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574453AbjLHQNX (ORCPT + 99 others); Fri, 8 Dec 2023 11:13:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51476 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233589AbjLHQNE (ORCPT ); Fri, 8 Dec 2023 11:13:04 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [217.70.183.197]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2A7E119B6; Fri, 8 Dec 2023 08:13:04 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id D24CB1C0004; Fri, 8 Dec 2023 16:13:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702051983; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=RcHHna0h/IgIzh58pWB4uS96fnTDDQBk114hJ4c/spg=; b=ShlMJ/9E9iWREjauCv+qBvFMf4f8r53G9fhixcuTCpLqY3RgyZz2BVYlB7iG93Jh/LGoYT lhOBXozpMkdt56V0XVKs1tUQ7JGOxdRICcNVLuQvbdMDaZETMZJqrOZ9ZgWgp2PpAKA3v5 qGsoqDIKJSvWtC+rTjGEVfTemCsM6MLX0bLkdZ7ZwoYAUnxxjbzRHI8EVDStbrzvEtrkWG PlwsRuBWriB/++SlD9jMQeQsoSq9GXuBG5GN5oChagh4H0SPxO61u1WTqKa4LAm+AQ4QtI BYKNSCkhszd6OVtjLRL4gO2Uh0rAwkB7sMQyxOOfPUKSCS43ZNcXWn1tTEKb9Q== From: Gregory CLEMENT To: Paul Burton , Thomas Bogendoerfer , linux-mips@vger.kernel.org, Jiaxun Yang , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Vladimir Kondratiev , Tawfik Bayouk , Alexandre Belloni , =?UTF-8?q?Th=C3=A9o=20Lebrun?= , Thomas Petazzoni Subject: [PATCH v4 11/22] MIPS: traps: Enhance memblock ebase allocation process Date: Fri, 8 Dec 2023 17:12:27 +0100 Message-ID: <20231208161249.1827174-12-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208161249.1827174-1-gregory.clement@bootlin.com> References: <20231208161249.1827174-1-gregory.clement@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-GND-Sasl: gregory.clement@bootlin.com X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on fry.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (fry.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:13:45 -0800 (PST) From: Jiaxun Yang We try to allocate from KSEG0 accessible space first, and then if we really can't allocate any memory from KSEG0 and we are sure that we support ebase in higher segment, give it another go without restriction. This can maximize the possibility of having ebase in KSEG0. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/traps.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index b6e94654f6211..68f1dd54cde1c 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -2399,7 +2399,12 @@ void __init trap_init(void) memblock_reserve(ebase_pa, vec_size); } else { vec_size = max(vec_size, PAGE_SIZE); - ebase_pa = memblock_phys_alloc(vec_size, 1 << fls(vec_size)); + ebase_pa = memblock_phys_alloc_range(vec_size, 1 << fls(vec_size), + 0x0, KSEGX_SIZE - 1); + + if (!ebase_pa && (IS_ENABLED(CONFIG_EVA) || cpu_has_ebase_wg)) + ebase_pa = memblock_phys_alloc(vec_size, 1 << fls(vec_size)); + if (!ebase_pa) panic("%s: Failed to allocate %lu bytes align=0x%x\n", __func__, vec_size, 1 << fls(vec_size)); -- 2.42.0