Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp2442315rdb; Fri, 8 Dec 2023 08:13:50 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYsAZxrl9mhnlltICYhjvpIMkWNuT4YPMRU5YGM8lI/Nxna0lXeNHoFGbQnGLPAzfLje1k X-Received: by 2002:a05:6a20:54a9:b0:190:1c0:1c25 with SMTP id i41-20020a056a2054a900b0019001c01c25mr284300pzk.91.1702052030124; Fri, 08 Dec 2023 08:13:50 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1702052030; cv=none; d=google.com; s=arc-20160816; b=X2zd/mgWJmrxE4/G8j/5a9gXEJWsxaQRM2QesXCyjWqOO/vSBAhsW0xHytm/7m5Msg tomvYRtpHbp8pXPci7yeQSQqc+g6XkdcpplHJc9tqLqKD48FlxOP87y7J4j36emT+tmn xblmPCJ6q963K3TNdhy8x1NTpiqHL69pdxqZwtzEp2zXYcMrrL041koz3xSM1RHRbic6 4kickMViHwbJg/jtlyOEwI5bVDdGTHlsVsXcjr2lmpVUNHNlj47xX6ItEW5jgOVCLSVw WpHDiKfSpmCL6L6n1Kk+w1Y5KxE0gQvxatiMgwdm1y8gPdKrkJOR6D6ql93C68vz3Fqc /MCQ== 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=imSdkuhb1bmbiT2B28YIP5ZVYeyaD1qizr5YYVEXZZM=; fh=t1bsw/gEI8w3DN7ouBpAewoQyybWh2yxEgAHixB9Iis=; b=Xs+5bvbpKwCYG26LmTdS4ZDosmepA2TwrBf1PelNCzdyrV78oORzQGuVQfuU0CneB9 iE5h7ZjE9FZoq53UgMa8wqPf8+OaHNXt0A2Dq1qfmbNNbpKziIOYGP2EnExsXp4s9vzo RmOnaKKctjGbPfIPuGGH/O1OMFsqQRnUPdeiSu46z7KDX6Oagd8xHnKgOfzdsByJ5f/C t2JYrHqcZvecotR8y5Omu2gW6gsbUVIvZ9inETdEMNwUOQXdIL16nbYCuJ4OdvCUCK7R 0AIAUXFhUSjuiLJeYFixJYIdf6pX5S2AVZJI1djuhEWuqbKxBp27GgcvUoNDks2XzTOM HlKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=k7TY1Q+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (fry.vger.email. [23.128.96.38]) by mx.google.com with ESMTPS id e20-20020a656794000000b005c620f350fdsi1731291pgr.341.2023.12.08.08.13.49 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 08 Dec 2023 08:13:50 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 as permitted sender) client-ip=23.128.96.38; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=k7TY1Q+U; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.38 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 fry.vger.email (Postfix) with ESMTP id 554C181BE83C; Fri, 8 Dec 2023 08:13:43 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at fry.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1574436AbjLHQNU (ORCPT + 99 others); Fri, 8 Dec 2023 11:13:20 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51490 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1574081AbjLHQNA (ORCPT ); Fri, 8 Dec 2023 11:13:00 -0500 Received: from relay3-d.mail.gandi.net (relay3-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::223]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5917C19AA; Fri, 8 Dec 2023 08:13:03 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id A20A060009; Fri, 8 Dec 2023 16:13:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702051982; 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=imSdkuhb1bmbiT2B28YIP5ZVYeyaD1qizr5YYVEXZZM=; b=k7TY1Q+UwTJuyIzB1zXiOsCFYY9OY5knmQArel3rY1qdnyV6kG8zLvgaXlAsOLtTm0py8x BPqzTvLeGyDfWcURujGB/0M4caOHgS/PnwUwTl2ErXUnAW6WuqROkUYU+uUlwmOAjtpqj6 sSrChGm4I6Gezw7DsN6HF5J8bZyIAlu7QFK3yJHBQg0Bklr5e1YW1MiGP0FveClJKDNJSG Lv4QS5B7ArNXiI2HuiJ92yZmVmZghTHTq8IE/tlbsPe1ZFJryi7qsvcxZr1LUzr61F17zy +PJCuauEDOU4WVuEMEkc5ztrpw6yeDZH0lN2oF6YldAtxnR6DttXIBQKSVu4hQ== 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 v4 09/22] MIPS: traps: Handle CPU with non standard vint offset Date: Fri, 8 Dec 2023 17:12:25 +0100 Message-ID: <20231208161249.1827174-10-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231208161249.1827174-1-gregory.clement@bootlin.com> References: <20231208161249.1827174-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 fry.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 (fry.vger.email [0.0.0.0]); Fri, 08 Dec 2023 08:13:43 -0800 (PST) From: Jiaxun Yang Some BMIPS cpus has none standard start offset for vector interrupts. Handle those CPUs in vector size calculation and handler setup process. Signed-off-by: Jiaxun Yang --- arch/mips/kernel/traps.c | 32 +++++++++++++++++++++++--------- 1 file changed, 23 insertions(+), 9 deletions(-) diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c index ea59d321f713e..651c9ec6265a9 100644 --- a/arch/mips/kernel/traps.c +++ b/arch/mips/kernel/traps.c @@ -74,7 +74,6 @@ #include "access-helper.h" -#define MAX(a, b) ((a) >= (b) ? (a) : (b)) extern void check_wait(void); extern asmlinkage void rollback_handle_int(void); @@ -2005,6 +2004,7 @@ void __noreturn nmi_exception_handler(struct pt_regs *regs) unsigned long ebase; EXPORT_SYMBOL_GPL(ebase); unsigned long exception_handlers[32]; +static unsigned long vi_vecbase; unsigned long vi_handlers[64]; void reserve_exception_space(phys_addr_t addr, unsigned long size) @@ -2074,7 +2074,7 @@ static void *set_vi_srs_handler(int n, vi_handler_t addr, int srs) handler = (unsigned long) addr; vi_handlers[n] = handler; - b = (unsigned char *)(ebase + 0x200 + n*VECTORSPACING); + b = (unsigned char *)(vi_vecbase + n*VECTORSPACING); if (srs >= srssets) panic("Shadow register set %d not supported", srs); @@ -2370,20 +2370,33 @@ void __init trap_init(void) extern char except_vec3_generic; extern char except_vec4; extern char except_vec3_r4000; - unsigned long i, vec_size; + unsigned long i, vec_size, vi_vec_offset; phys_addr_t ebase_pa; check_wait(); + if (cpu_has_veic || cpu_has_vint) { + switch (current_cpu_type()) { + case CPU_BMIPS3300: + case CPU_BMIPS4380: + vi_vec_offset = 0x400; + break; + case CPU_BMIPS5000: + vi_vec_offset = 0x1000; + break; + default: + vi_vec_offset = 0x200; + break; + } + vec_size = vi_vec_offset + VECTORSPACING*64; + } else { + vec_size = 0x400; + } + if (!cpu_has_mips_r2_r6) { ebase = CAC_BASE; - vec_size = 0x400; } else { - if (cpu_has_veic || cpu_has_vint) - vec_size = 0x200 + VECTORSPACING*64; - else - vec_size = PAGE_SIZE; - + vec_size = max(vec_size, PAGE_SIZE); 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", @@ -2450,6 +2463,7 @@ void __init trap_init(void) * Initialise interrupt handlers */ if (cpu_has_veic || cpu_has_vint) { + vi_vecbase = ebase + vi_vec_offset; int nvec = cpu_has_veic ? 64 : 8; for (i = 0; i < nvec; i++) set_vi_handler(i, NULL); -- 2.42.0