Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4761358rdb; Tue, 12 Dec 2023 08:36:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IGqWg/oyexkGX54jtJ53MJeckX+P4eOI1rKtGWJAnS9hOsiMRXPAEEdhVF1VqzEqCXMtyv2 X-Received: by 2002:a17:902:f545:b0:1d0:6ffe:1e9f with SMTP id h5-20020a170902f54500b001d06ffe1e9fmr3869930plf.130.1702398994612; Tue, 12 Dec 2023 08:36:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702398994; cv=none; d=google.com; s=arc-20160816; b=I44b2t/2tjVqlSQayGc3UMHd6H0m31ilfPRy0jqLP60CkM7bwABfcH1rxVyGAMEo2B eZTDlzUqXKAgC8X1MhiF8Np59SMeyER6DTTLtnyLmb3vB4qTy+8n6whZoII34EIw/pbW FO78CJoDSexWBVH0wta985Qr9bNw24FTr7DZzjGxmwqDTCsypsU2j1eqwKs327Fp5qql YTL3HlOsndu7od0T0HFCIiKr/4p6QNgEcJ2LDvTF55qZhGxwS0pRZ+KVfNPiD0QJ4Xf+ TUJNNRIKKTZDabP4NOdau5dbkkLhsUe+q1SALvL1lSOMViPZ6WPxjeLSSULwcVUbPqZo 1cKQ== 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=zLrp9lcJ5PQW92KPtBpFPcB6UQzVTee0sSxnR5o7EZA=; fh=t1bsw/gEI8w3DN7ouBpAewoQyybWh2yxEgAHixB9Iis=; b=aBcvaXQhCzRri9dXo6iQwM7y5TrShdIHz2iCXhV1GXi1k5cjLsxjkkjGFCjDFrjXK8 7wEZroJzIUpuCATcSFz5N+9sOpSInAsb87+14UHasndwkl2jW0PsNL0DEGh+uynRhhRT 4Bi6enjvuMRK/TOBh3u64d1OSwhmD4obT3n000tfUvkIwbZNJ0w4A8p5zFymqhJxCZE9 EnHVs0kwMA8503LL/R+tEGUofVVKkkrVCRlwpQq6/CPLH3zPlmyNhLmDsqN4cJZMbIgu KF5djc41eyQsCQxI5qhQB2TijfDGqvTuyfqZmIwTC2KO9rQryEOMt2e1WsX4qDua4RNe Db6Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LbdYo6lR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (morse.vger.email. [23.128.96.31]) by mx.google.com with ESMTPS id k10-20020a170902694a00b001cfd622b80dsi7963121plt.541.2023.12.12.08.36.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 12 Dec 2023 08:36:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 as permitted sender) client-ip=23.128.96.31; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=LbdYo6lR; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.31 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 morse.vger.email (Postfix) with ESMTP id 05FAB801B984; Tue, 12 Dec 2023 08:36:31 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346724AbjLLQgH (ORCPT + 99 others); Tue, 12 Dec 2023 11:36:07 -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: 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 morse.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 (morse.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:36:31 -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 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 = 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