From nobody Wed Dec 17 07:28:33 2025 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0E330C4167D for ; Tue, 12 Dec 2023 16:36:17 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376415AbjLLQgI (ORCPT ); Tue, 12 Dec 2023 11:36:08 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39480 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233017AbjLLQf3 (ORCPT ); Tue, 12 Dec 2023 11:35:29 -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 D21F5F5; Tue, 12 Dec 2023 08:35:34 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id ACB801C0007; Tue, 12 Dec 2023 16:35:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702398933; 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=zLrp9lcJ5PQW92KPtBpFPcB6UQzVTee0sSxnR5o7EZA=; b=LbdYo6lRPpwdkiC1qRLoOCK7PkZyJJ8wPXnnbyNgoAFGmOwuqvKikSrMRM7k5MIp4LySGy YltKy8oLdARmXSzPt/H2hjukhd4OrjJaL90nUzQoc/XOYGoZSl39h43pNxRnZ+FZvOZ/yW nBXl1fK+nBShY7Yhc31I8JtVQyC1oKSjYcGXIuym6db2d0DUx6fWaQybMqwO+/5+F+Sj9k e6vFs040Q8Zg5Rio2cwx+YrTk0Q5GCoM27leEtGxSMEHRD200gsQZ0JcSLEzcnCjKnlpdY r0PxkoWG1gZU/K/S+KTqQQSlG/Qowm/QoQFB05Irb75f8kS5V5mDf395KD+MmA== 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 v5 11/22] MIPS: traps: Enhance memblock ebase allocation process Date: Tue, 12 Dec 2023 17:34:43 +0100 Message-ID: <20231212163459.1923041-12-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231212163459.1923041-1-gregory.clement@bootlin.com> References: <20231212163459.1923041-1-gregory.clement@bootlin.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: gregory.clement@bootlin.com Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" 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 a6d0ae12b3c4c..089247555c752 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 =3D max(vec_size, PAGE_SIZE); - ebase_pa =3D memblock_phys_alloc(vec_size, 1 << fls(vec_size)); + ebase_pa =3D 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 =3D memblock_phys_alloc(vec_size, 1 << fls(vec_size)); + if (!ebase_pa) panic("%s: Failed to allocate %lu bytes align=3D0x%x\n", __func__, vec_size, 1 << fls(vec_size)); --=20 2.42.0