Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp954739rdb; Fri, 1 Dec 2023 03:17:19 -0800 (PST) X-Google-Smtp-Source: AGHT+IFdEkuLimj53S/+VJCht7Fsl8Eii7ziGG+4BSdjY7poGOc5ioc7nXrGb/t6d/8X5uumUByU X-Received: by 2002:a05:6a20:841e:b0:188:444e:2b74 with SMTP id c30-20020a056a20841e00b00188444e2b74mr26823948pzd.50.1701429439581; Fri, 01 Dec 2023 03:17:19 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701429439; cv=none; d=google.com; s=arc-20160816; b=hEB0kP+rNmBa8Md7Ii/6axUzHMWspkik3dO5Tdzgl8quaIkMajcssTQf/mkD6/yszw jwyo0ugaGf8JvCm6NkyAmBJyPctLlCqUEApnLoKWslUTw9324OfVvdGBD7Ve6+iQ9jPj KeSSMdv/46KTY2ip/6cIYkm0KXcdCA9/MJv55P4xWOqVhgTlEaMbmFBvUaKGBcRN/zE2 J+FDw0Ct1sx4ab3JRNw4ug1Qdt1THO2E2YfwsscP0zKGx9RF5Do99thT05c+ShgJQGYo lz9PHP1ipAceEQu/uo+6sWyOkRTFeq3QOSAF2yOyNfBjNetemkziEOr36pjJRKmRBZtG gRIw== 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=t1KwVfwaytmU+6pa2w2zPn3wpp4PXfvOD6jxAW+JZu6IKH+jzW+0pM0GJwUvyQncRw GRXR1RtOh4eyJj3i+vKXfkaIL0TgXag/7cDklBASA1HMHtaU/AnjDOogJAini4+SgC5a UlHsC03yMFfGGNAQSAG43sA/XL3OzVkep3cHpSo74jYGbfjItorPLzbvJoGh55TmxSTN oC89Eam+jCN5JY21DAtBIimBFdhaqbfWuSoaa7mO1WGFt4y4dmgXBp4dMr+7LRAWlKGZ eEYY1soApxWmnWBJhpCJLNbVSGNc8d8VsL5rsdECKyxSWtATr1IBIjiYnfwHRUW939G+ LXCQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ID55cpOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (snail.vger.email. [23.128.96.37]) by mx.google.com with ESMTPS id b2-20020a056a00114200b006cdaac97b57si3145421pfm.213.2023.12.01.03.17.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 03:17:19 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 as permitted sender) client-ip=23.128.96.37; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=ID55cpOW; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.37 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 snail.vger.email (Postfix) with ESMTP id D2F3380A777A; Fri, 1 Dec 2023 03:16:35 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at snail.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378631AbjLALQJ (ORCPT + 99 others); Fri, 1 Dec 2023 06:16:09 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36022 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378514AbjLALP1 (ORCPT ); Fri, 1 Dec 2023 06:15:27 -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 3A4FC10F8; Fri, 1 Dec 2023 03:15:32 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 283781C000C; Fri, 1 Dec 2023 11:15:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701429331; 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=ID55cpOWhIKsrlvBDFEiMQsd/i+9SVHpFmKiSgSrf4ea2szu210SB8aO2yquFUAHiUG2nv ypReEnWoH6+ahhhbuluGNSmcGzaXfwcRZ7S9As+VDn3AmJydh/gIQfAfkeFanqET1aNpQr 7M/iSXvedKpG9dqb+vArtGOi/mxXQGNX36ViAOoQDjtq6DU+Nqo4OlpIUOVshc5ywsBjVa zFWoGDvDs5H3wVzoKaF1FxmmECafAiHanzY/s2zI4vFS04C8w15ybfYwia+j+dCpoFTQ/N STIEp0faDUMzPLnDDCO/k+6mVuEEHVAJF6gBkLJIdKKTypccSspQEmZXRqBGpQ== 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 v3 11/22] MIPS: traps: Enhance memblock ebase allocation process Date: Fri, 1 Dec 2023 12:14:54 +0100 Message-ID: <20231201111512.803120-12-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231201111512.803120-1-gregory.clement@bootlin.com> References: <20231201111512.803120-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=-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_H3,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS, T_SCC_BODY_TEXT_LINE 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, 01 Dec 2023 03:16:36 -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