Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp419708rdh; Thu, 23 Nov 2023 07:28:21 -0800 (PST) X-Google-Smtp-Source: AGHT+IFX8GDBhKG1/4hvfot8rgCYTrWoGVDFfsgW7Di8YZ63tbuDZvYtIBKMMeNmaQJx4VwBrdZz X-Received: by 2002:a05:6a00:1d25:b0:6cb:8c70:4792 with SMTP id a37-20020a056a001d2500b006cb8c704792mr5764588pfx.4.1700753301274; Thu, 23 Nov 2023 07:28:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700753301; cv=none; d=google.com; s=arc-20160816; b=lDxvrPoPdagzDoVBaZldsSukmMD53R23/YG4b5M22vM5g71EVLhXL0CBZybWgApkrK iwiiJk7nSphq55LjoHYgIeOl+TQNGxwQeH5oNkHGwEwpsu99RIkPypf7axnIWfmjNvay I2+qoxXRbHAoVh8cvt8TqSyWGBYJPZo9v6l2SiWV4/pYBVwlH5SLi1Qou+5D9da5O5SO 66W8yb0GBuinfx3YaM88W0mfZVD711hQ+e3vkJiFfH6w9smJtCf7MOlpLAhG1wtf0TuO DxBIhcZ/xytvllf3bTVrZnP/A94qMhhllEK5H1K59LvzV4Udow56Yih0L9t+Hemln6MP MzgQ== 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=GTz1MTfwevQbOjt9Okoe52ly+lCrqQ78/IPrJ1dbKWdDnmEU/4/P0Dc27aEAd/J/ni 9SKixuE/ai52Pets3eiN76spyF1reUHIxadpaeYrr8OIEkRghGXYOEXbTMQLDcjVgeO5 oJPCukwm3Inusrj8OZLbzRVxAkC29B17N8WDYZu+/ZKvVSJRJxuTzkPXdaMis/DoOguh F6B9ZEMwABclEhtdgm8CqLcooZhth383lqpA/6ZlDj00fG+mGLrkuvncqs7V3HYUcMzz ntYjeKu2bhcXlmgLrzq+V/ZrlXSghbXZsJA18ffn2cVVOcwQCSkEDbql6yEcx1oBEGT9 y0Dw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=E+jrrnH0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id q1-20020a056a00088100b006c31b7deccesi1522126pfj.106.2023.11.23.07.28.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:28:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=E+jrrnH0; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 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 howler.vger.email (Postfix) with ESMTP id 8A68580977BB; Thu, 23 Nov 2023 07:28:10 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346157AbjKWP1e (ORCPT + 99 others); Thu, 23 Nov 2023 10:27:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45786 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346147AbjKWP1C (ORCPT ); Thu, 23 Nov 2023 10:27:02 -0500 Received: from relay7-d.mail.gandi.net (relay7-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::227]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7A1291B2; Thu, 23 Nov 2023 07:27:05 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 9054A20004; Thu, 23 Nov 2023 15:27:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700753224; 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=E+jrrnH0co7LYu4/GnGewYeLa1EUyGx6KlvfCrPmUt1PjaTCw1sLJBlY44E5cHxqYMQTvQ cSpc5252sJDrCfephHLtcbwTVgUd1qJTdCYuQsIlGC/PKrc83eGjKKTYk/31Copsxv+LCK 115+HtMK732jm6aiFTBDGa387GQ0Cu2bc00hT1XVHRzZJXYPnbXOFCeLFJqK8t0HPUxL4+ WPv5Jv+SQBtWf+OZvjeN51sV38ZgjUAvg2STXQc55653nKYzbXUO3L4dq8IeV+/RRgccL/ tphMGs94TvwtZ4ZU9dBIBCMLbe7MxNZJVJIDAIhzJFT32lopeQnw8blt5RuODw== 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 v2 11/21] MIPS: traps: Enhance memblock ebase allocation process Date: Thu, 23 Nov 2023 16:26:28 +0100 Message-ID: <20231123152639.561231-12-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231123152639.561231-1-gregory.clement@bootlin.com> References: <20231123152639.561231-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 howler.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 (howler.vger.email [0.0.0.0]); Thu, 23 Nov 2023 07:28:10 -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