Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp4761364rdb; Tue, 12 Dec 2023 08:36:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IEqyLgENpHwPFzX4PftB279Lq9nq3zRaPmzlaFZ506nCfjctn3j+7Xk6NBMMT6tK9D2UENK X-Received: by 2002:a05:6a20:f397:b0:18f:c875:6b3b with SMTP id qr23-20020a056a20f39700b0018fc8756b3bmr3303174pzb.100.1702398994934; 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=CQEUrjZRwbMxEPMVWGe2zJ2T/7N6G911B5EfqpL5yDRca3RrH94IWKWPLv3wo1KJ4x sC70oR3CPX6GPiYp3uQS2UzI4iTqTVZu+zKOi4nG4ygMrZzK80hAcu4V/lkMlQ037hWJ 0ScMaeV6QlzImXwVYs7Vizht22T2+FaYeEpp9I4FSGdeVk1vkoQ5K4DaupgbLjPRqvhQ Xsdrk0TFLm48HTyfNMPBfjR/VcrQ/e126++LwvID6mXkHVMsylRu3oi2RyaG/ZPt+lwo hdH63lm9x63nJEVptT7uruh4h9c9AN16t47ruDKCJqnodE5SAGlgxa3cdT3sgQWqjEu6 5qVQ== 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=s2HCa2+WQTWUMv9knwwE3fae1I7Q3ql8eVrDv9QUTaY=; fh=t1bsw/gEI8w3DN7ouBpAewoQyybWh2yxEgAHixB9Iis=; b=nU+bStgHisY3Of7AJjYnq6Ey3qcV7m+TeLR1iIkJpogHQEvfwRy/HVDTDDozfpQxT1 XcSgNhUnuEjJRDdqrnaSbk/zf2i8DKCu3IxMy1kXl2tzC3uPMZTREy3bv07jIxoKcRJj KQVIp2Q9Q3CwtlNKoYLC4L7GyNdV7U9EaW2Wo2f7gG1J2euRQ2bszKx/wYSK9ooX4HFh 6s4O1yfWbvE+hS2Y3zsySjxVLcYQ4eXzgItKKOU9V5S6CAfpqo+aJ/3SJCbkmcXdXBg+ l7gaL/AyUuZjZA8PNWOUtP+PuTco9vn1/vh1+0xg7b0WnXim7MxJWPth0llyPMoFXJWU C3Ow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Tf9jdRrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id g184-20020a636bc1000000b005c668a5a906si7904365pgc.282.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 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=Tf9jdRrS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 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 agentk.vger.email (Postfix) with ESMTP id 13E2D80A916D; Tue, 12 Dec 2023 08:36:32 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1376379AbjLLQgD (ORCPT + 99 others); Tue, 12 Dec 2023 11:36:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48924 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233056AbjLLQf1 (ORCPT ); Tue, 12 Dec 2023 11:35:27 -0500 Received: from relay8-d.mail.gandi.net (relay8-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::228]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4939CE3; Tue, 12 Dec 2023 08:35:33 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 678F01BF20E; Tue, 12 Dec 2023 16:35:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1702398931; 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=s2HCa2+WQTWUMv9knwwE3fae1I7Q3ql8eVrDv9QUTaY=; b=Tf9jdRrSxXhoqOSFjwX/EXp1SxnnFjE15jIf+AR/W97xv7LdNXNXSiQKMPBtJBaI8jsM8u SOqyEZyudl2wAnWdTGS8im3yKZxp+EcuYsmEaTHSQoDPcQtO9bWp5CcsVK16xiTHfNJxf4 zK8EtY1PpfaouL3na3P0lEvbAVjnjLTMiYV5AY1DdBmYzc951qg3qT12Ck1zmx/613V4In oKEV3dQ3SZyMlhdXo1SxKXirl8s7fIPySmjxznNgRtwEoGdoHfdARgmJK/llgpF2DEg2Jw B996h7VjwNbbVaLSn4EzA0gIxTTZFkggUFXU5Sm4VJEPZQNfi0QNnbFHoml5cA== 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 09/22] MIPS: traps: Handle CPU with non standard vint offset Date: Tue, 12 Dec 2023 17:34:41 +0100 Message-ID: <20231212163459.1923041-10-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 agentk.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 (agentk.vger.email [0.0.0.0]); Tue, 12 Dec 2023 08:36:32 -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..7e6e6df59e6d7 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