Received: by 2002:a05:7412:b10a:b0:f3:1519:9f41 with SMTP id az10csp954571rdb; Fri, 1 Dec 2023 03:17:05 -0800 (PST) X-Google-Smtp-Source: AGHT+IEK/5uo+AiR3tuqq8PGkD9+HpW73QaZ8YivsjcDKNARN//r+o10BH1W5BfVJjs0LUuOzrBk X-Received: by 2002:a05:6a20:6a2a:b0:18c:b464:ec5b with SMTP id p42-20020a056a206a2a00b0018cb464ec5bmr17902915pzk.61.1701429425579; Fri, 01 Dec 2023 03:17:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701429425; cv=none; d=google.com; s=arc-20160816; b=ZSbe3oYZ5pcR+bp3eziuTObLOZU2kX783ZMwIlzgCfolglloyqgRWtc+xOu7jETauK ZfxB/c11D610OiLRlqTzuWaEAb1DQhx60xF2nvq+0dTX1K9RMhyab1QZbRtSqe21aFdr ULQ/Il6L+hwHx2Rq3KAdBxL9FpGP5xBn9Aj0Ta8uldSFKGlmdoPaOyUoc8YSRYIaqnd9 airoIUAQX8aV8yLSER/vGffsUAx3Y7h0fOm5hW0XFQeh0NoZc8csi5YSFpnxslYKb8z+ YqgF6NHByhc55jIsyZPMVISSGAT0yDzX4FJMFdn+LCEor2hYL5vMyJdyCp46QbI9ZjmK GVUQ== 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=sDFeDpENvgd0FaxI47Phjkt6Wpk1s4gvAKZp6ZKJrgvIvBEL5YW7UfGhr38vasD5rC 2CJLB1HkVLNKa/hXjjDu/KhRvMtno2pZEn4pbuLUW8rDVUleLh5bPgy30oVTF0d43hYM wAMd40J7FsBnouyOmIXHPSHdwuA520Jfx6UHY2u4pNFDw/UBwsYniEn2r/E+Ek1zIPOH Mm0bfTCKviF4HWZ3TrbWyGpcuLYdHbfzst7hfXdGatt+L8WepsuBijk+YWndKUVQHmA1 n9ZUnGCK5XSwrr0S+yuDeedqKJ5OpSEoz0lmegExic3CPrjo32ycOPEaS8+FVdbMo80n Xxyw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iTgfcOgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (lipwig.vger.email. [2620:137:e000::3:3]) by mx.google.com with ESMTPS id d18-20020a170903231200b001cfd934bda1si3375239plh.232.2023.12.01.03.16.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Dec 2023 03:17:05 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 as permitted sender) client-ip=2620:137:e000::3:3; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=iTgfcOgV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:3 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 lipwig.vger.email (Postfix) with ESMTP id 7EE72816F05B; Fri, 1 Dec 2023 03:16:49 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at lipwig.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378545AbjLALQD (ORCPT + 99 others); Fri, 1 Dec 2023 06:16:03 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378531AbjLALP0 (ORCPT ); Fri, 1 Dec 2023 06:15:26 -0500 Received: from relay2-d.mail.gandi.net (relay2-d.mail.gandi.net [217.70.183.194]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E4581A4; Fri, 1 Dec 2023 03:15:31 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 94A1C40009; Fri, 1 Dec 2023 11:15:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1701429330; 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=iTgfcOgVmiQNTSVv6AoJ70lN5pQllZU5frq7r7c1qUs71NVXbFtMnIWLJrqBo5wCoEBuNe RBNZkqR7C2OAHmBTu8c4rvvYFi7RgQL/DwyKjUUkvWSKQLHqd5MOmpYzx3atcFBWMTXYW0 c/oXxJEKDwCEeoe0+4MQ+Udb70nO7n+KuRZAm9mO2RBmghqpE5/8OIHO+Zo/faky/S+GoW RvxQQwYACPkqceZJIdQuDShUSfLzWP95lxsm/ElhYlerdgeMz/wl7U7y5uuvHHEYDapgWQ Rar35lsqQP9bs1ZuL/4BFfcLtMOumTWVUrPHxtXQdVEdz7e8az+dcD35TlU3VA== 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 09/22] MIPS: traps: Handle CPU with non standard vint offset Date: Fri, 1 Dec 2023 12:14:52 +0100 Message-ID: <20231201111512.803120-10-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=-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 lipwig.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 (lipwig.vger.email [0.0.0.0]); Fri, 01 Dec 2023 03:16:49 -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