Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp1455523rdh; Fri, 27 Oct 2023 15:12:46 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHgXlZafPzuvSjZJrc5u5d+RHuleg3muJyh4PDBffuPUiTwzE7/+8ka7pLre699LT/Lkw03 X-Received: by 2002:a05:6358:7e92:b0:169:57f3:7554 with SMTP id o18-20020a0563587e9200b0016957f37554mr1133569rwn.21.1698444765683; Fri, 27 Oct 2023 15:12:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698444765; cv=none; d=google.com; s=arc-20160816; b=SdPLTbQHCJoibAvUN4rq04B69E9Clox5QewoWfesbPlnEk5I4g3vx1ADKsypc7TkBB Pm4oEiVFRnc6NhbMZ+GuEnSRy/GYIHjvlb4ktQUylSO2+4AnOY+O00piHEmEkXC6G9AW QcA+1F8i57u6WTE/oY+BH/njOiaQPHetzPPbeg5BtTnuM3DgNLWoDsFJFFpOeCR9r/dQ V6V5tk3eddj4DZrO7aAvNDcQvXQHLdJdnoVGQZKDTeeHQPe8Y4pyLVIhm7u55aUQB4Yg aiZK1hemuBDgNXGykul3MwRBpB9UhuqbjPrKyMqBGCmnkyJoOK5Wz0NcNf9DoPUAi1vA 9AZw== 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 :feedback-id:dkim-signature:dkim-signature; bh=Tr/TAb04SGgGEOsJanw3F3kr/0Ce06JzReERHar06zI=; fh=34VXqKbbbRVUWYKB0XlF9D4jmhXxe51P2+smd1zcTfU=; b=wVZVW9nVXgmG9YibMnEfbZy7D9gD73em9HBIoxP8sG9SafWt0Lr/BiI6mM+WebHWKM LPXeUCBhcVHN9fOQBIvo0bJleXqF7NOVyYoONbBvErBbKOm8hdsh7oYxEJ08g1GT1IQK uTIgSqPnd+gh/w6/0rxBQId+zf09W2n7dgr+KW3lcmt5HQlYbUzJG2G/42VsSJXodLgB x33223sen5P34B/AB/tolYitMSPxe393xe58CFp2vajXeBMbDGjJIfRapa0lWV5cjE1J Vcw37lROWlD3ghr2YFs2qxZl4fqGS1gUpBuLGdCTtgUre3S9evdRFq1zLgYNuurEf4Td 85iQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=DI3igvTc; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=L50aUpio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id r29-20020a63205d000000b0057745d87b50si1562018pgm.139.2023.10.27.15.12.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 27 Oct 2023 15:12:45 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) client-ip=2620:137:e000::3:7; Authentication-Results: mx.google.com; dkim=pass header.i=@flygoat.com header.s=fm1 header.b=DI3igvTc; dkim=pass header.i=@messagingengine.com header.s=fm3 header.b=L50aUpio; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:7 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by snail.vger.email (Postfix) with ESMTP id 21EB4834C54F; Fri, 27 Oct 2023 15:12:24 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1346703AbjJ0WMP (ORCPT + 99 others); Fri, 27 Oct 2023 18:12:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47294 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346731AbjJ0WLx (ORCPT ); Fri, 27 Oct 2023 18:11:53 -0400 Received: from wout4-smtp.messagingengine.com (wout4-smtp.messagingengine.com [64.147.123.20]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 72986170F; Fri, 27 Oct 2023 15:11:35 -0700 (PDT) Received: from compute5.internal (compute5.nyi.internal [10.202.2.45]) by mailout.west.internal (Postfix) with ESMTP id D888532008FE; Fri, 27 Oct 2023 18:11:33 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute5.internal (MEProxy); Fri, 27 Oct 2023 18:11:34 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=flygoat.com; h= cc:cc:content-transfer-encoding:content-type:date:date:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to; s=fm1; t=1698444693; x= 1698531093; bh=Tr/TAb04SGgGEOsJanw3F3kr/0Ce06JzReERHar06zI=; b=D I3igvTc0X3IIXEx9TqmJrqMHtqRy0ldREmqW7oPdW2oX088sqJOPLdhQToP/Z/SX 66ddy/mLaTGkDySXh94EPIe7TdiGvrEI61CPHk09nM32WbKD/ZDEmP6S1sjPe+8p Cq23UghDFcyIe5HtsuUzjcCZE0AsHmwnF76SWHi2NAxMLH/2T9zhC1w4hLa7G4Kr 1+JofBWB2KkVrqtYc551rufoTof3WttjChngXJpnXaO8eEwm+RaX7WGkKCb4Gpsl 47TJ9Q1K6dPM1CRxNZIlzgu9BqqSffSEWYG5BJ//lFpV6a2SWJyBCk8NPoYPiuqz btoBi4NxD2HHIEihrPqAQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding :content-type:date:date:feedback-id:feedback-id:from:from :in-reply-to:in-reply-to:message-id:mime-version:references :reply-to:sender:subject:subject:to:to:x-me-proxy:x-me-proxy :x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t=1698444693; x= 1698531093; bh=Tr/TAb04SGgGEOsJanw3F3kr/0Ce06JzReERHar06zI=; b=L 50aUpiouRR02XAY0YNvD36dCLMlJLUcVmnlBQavFz4vu3mtBVhmAnxIKcX3vyJip Pxc7MwO2vk02SnYqjUS3Z/gojfcaZdZg7DNDyZJtubI9JSTNVtsHuf0m96ATuRsO fDxGkIy3TpRk3DidfX0K/PJVnF/+hjnfxblGhQHWEh/51Z5AzFQgIpZ6SXi4IJ1s qnxB+8ZNhpxIHGXtOeT2E6vSL9+WdtxPwZwjs8IjOmmPI+qhGN61PsXllnfKI5eH lzOCv65BoIhtRG1s+y589Nt7Ns3YkwqrsPfL2lFYpiQT2BH1WK5YjHwaB7f/zv40 w+uSVxL5zIe4ndve6xTvg== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvkedrleehgddtiecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvvefufffkofgjfhgggfestdekre dtredttdenucfhrhhomheplfhirgiguhhnucgjrghnghcuoehjihgrgihunhdrhigrnhhg sehflhihghhorghtrdgtohhmqeenucggtffrrghtthgvrhhnpeefledufeehgedvuedvvd egkefgvddttedtleeiiefhgeetudegkefhvdfhjeeftdenucevlhhushhtvghrufhiiigv pedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehjihgrgihunhdrhigrnhhgsehflhihgh horghtrdgtohhm X-ME-Proxy: Feedback-ID: ifd894703:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 27 Oct 2023 18:11:32 -0400 (EDT) From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: linux-kernel@vger.kernel.org, tsbogend@alpha.franken.de, gregory.clement@bootlin.com, vladimir.kondratiev@intel.com, Jiaxun Yang Subject: [PATCH v2 09/10] MIPS: traps: Enhance memblock ebase allocation process Date: Fri, 27 Oct 2023 23:11:05 +0100 Message-Id: <20231027221106.405666-10-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231027221106.405666-1-jiaxun.yang@flygoat.com> References: <20231027221106.405666-1-jiaxun.yang@flygoat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, URIBL_BLOCKED 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (snail.vger.email [0.0.0.0]); Fri, 27 Oct 2023 15:12:24 -0700 (PDT) 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 b6e94654f621..68f1dd54cde1 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.34.1