Received: by 2002:a05:7412:419a:b0:f3:1519:9f41 with SMTP id i26csp419859rdh; Thu, 23 Nov 2023 07:28:35 -0800 (PST) X-Google-Smtp-Source: AGHT+IE/UYhQqhP6PFQmEfzSxJqp+o+wWpvKW2ydFY1w9TCL+IFEHZpFTVyiUFGj2XXnsLGkBqZy X-Received: by 2002:a05:6a20:7f95:b0:18a:e6aa:cd6a with SMTP id d21-20020a056a207f9500b0018ae6aacd6amr6838914pzj.30.1700753314647; Thu, 23 Nov 2023 07:28:34 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1700753314; cv=none; d=google.com; s=arc-20160816; b=tKFUiyj7kC7zm9yJD2sGcy4cDx9Oo1cXrySyfQ3wfhkXSSJyA56rOh/Gn4PmjFDFuD ikjWnFy45tPiHOi27K3CL4cbTuoi6+gxG9P/71q9FFCNG4SQ73gJGytmUujTnRHvx5JG P4oiqUrFmstCqFHLfUzxEd3yC4isQHwvLpH8xTrl+ZL6jQPxZyuxr/vndTNUN99VCEPf tI3LxS8ZZinFH9+748PTEzMLHEYIgbxi09R5/7LKXzt7dwoNf71bjKO3FjeboWH3LJwm SE0C7Z163bE6oEraxzugWMh1bjJgEsXEya/cXaFSANXKxb1KwtY9OIooagEcikbnQw5/ duCQ== 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=OQ6QBYXrnMmttzb8dPmPuuIY+JuzZPJljkqJPwQZKmvGOK5O+H4EU8GV/Lvvg10kip 6cdrqwF4l39OPQI3ZSEhjYVwZ1e1aCJrN2F/K8yRI1Ow9YeoJSERMxtGQMGoZo9ld1Yn 9O7kDhDZcXOxFCT1Wbz9EsDZoiCyCeQxN/w7WPQI5Ma8S4GDHvbivn59OoebKyAYMk1/ p1LvbMDOyoLKN0kzrxO/gO1+bzG9qDIo8fqbI4JvslEDoYdCG1OE/nybOfuN52gPqyqK fPWN3tAu4Ri0iNq+0HYWPNCjdb7NijoiWxmYl5oZe4TFDF+iX4D7zMp5FTGD+FUplCOJ og5w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UDCEufjk; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from snail.vger.email (snail.vger.email. [2620:137:e000::3:7]) by mx.google.com with ESMTPS id bz3-20020a056a02060300b005acf0458523si1487884pgb.612.2023.11.23.07.28.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 23 Nov 2023 07:28:34 -0800 (PST) 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=@bootlin.com header.s=gm1 header.b=UDCEufjk; 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=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 D6E77804E2F2; Thu, 23 Nov 2023 07:27:39 -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 S1346069AbjKWP1Z (ORCPT + 99 others); Thu, 23 Nov 2023 10:27:25 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45714 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1346103AbjKWP1A (ORCPT ); Thu, 23 Nov 2023 10:27:00 -0500 Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 04612D69; Thu, 23 Nov 2023 07:27:02 -0800 (PST) Received: by mail.gandi.net (Postfix) with ESMTPSA id 1B05A1C0007; Thu, 23 Nov 2023 15:27:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1700753221; 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=UDCEufjkJ/1u4nKt134YGyIOwir5VO2QexjErqbHyxiJmbqn6Gdo1GKtpUIj4oWEVeZ1Zm sAm7KjqPgTiKgZauy+fXpIrUKh2R9a/CQyar7yCkAn8ZeWj32RyFinHDbt3pPFfe/eO0Qu DYdOTHu9EUVieAwaeq9haSOwpasU9X5jgrrMQnQwloUdp0bzKfqw907sSv/IUefTFdGUtu NwoIlqNpl6nEj+qTyqiwyvAV0dZHCf7Xw+MZtUyAfWOtOP8j/BvzeFu+FigiSjdxQE1i0y 3+O0m93mha/eZFJUrSMUP1bZVUdK4zVgzLUjsnd40eDPElvWs0TyLknH38Comg== 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 v2 09/21] MIPS: traps: Handle CPU with non standard vint offset Date: Thu, 23 Nov 2023 16:26:26 +0100 Message-ID: <20231123152639.561231-10-gregory.clement@bootlin.com> X-Mailer: git-send-email 2.42.0 In-Reply-To: <20231123152639.561231-1-gregory.clement@bootlin.com> References: <20231123152639.561231-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, SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE,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]); Thu, 23 Nov 2023 07:27:40 -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