Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp335055rdb; Sat, 27 Jan 2024 08:23:03 -0800 (PST) X-Google-Smtp-Source: AGHT+IGYbC36gbUV0CggPKI5cO4wV/o+lfmcqqavBT3m725L61Fsyk1Zs414ASM2KVemBYPdCv8F X-Received: by 2002:a19:2d5c:0:b0:50f:1502:79e5 with SMTP id t28-20020a192d5c000000b0050f150279e5mr1081307lft.14.1706372583647; Sat, 27 Jan 2024 08:23:03 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372583; cv=pass; d=google.com; s=arc-20160816; b=laK9RRwp2Hmq4+uxFzpTCHBZPA+4Hb/6PnNm6BPwdc5KSQf9M4PNg5pfRzWychY+Hd 0F+oLv2BblAZ+BmUktCWH+EBSNhwmw5TKQ5EJhKT1ihWZj+kSaKeM18/z+iFPYyGw3JJ CjFL/OA1KmZQY5eQVTM2zLJ31nUGqmuvDshahhvqJbuPR71yBGHH+az9St/ZLZ8pbC6B Cy2b4MerFbu//PklqZxp9eFnAf3qvE9L/U8pJQLxNGSOkIY4eBk54n0rrsT/qVgtIfif 50FzycsjYPBapDJ5bGm0OG6h4FPt2j76KU7k3zzDY/mPIfzO6PAoO2yNGe4+jpoCxtpO EHqQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=2RNpF/CWjVyq2jAidq9g4JrMuQdRaRtl2xGmvH6ydPA=; fh=706cnY5t7hpwBXQypCTGH3HYLPe+/lcVAB5kbpxvl24=; b=iUCLx7GzsPn7dxti/DcSexpG+HxJreRy6s5pqd8lApqUVR3X98ZwB1j0Ny4Y7X+Yxa ziuNAqOb3prdRhBDdq7fLnHlzV3eBSwg5fYqgcXS91huPXxc/nhuCRgE/yDHuMgjNBhv up7Cbxk9jNxVEc3bfttb60LT+YpWaux6XzAI18p1NLRQF06O2GXcfPOlcaQHsx1Wa6SE uGmqGA3C7+rqYRJZJhR2PACkvX4No260HSH17mmQqcbF0H/Q/gZzd5JgwTnls8V/q6fc xmmOi3kHlUhF5ri+iD+iQ31aA2we4m4tjYUt2VU9AJlMIFk+SXvm3lOlEQeANy7fw0ly JmdA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=NQnTrdyv; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41289-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41289-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id k8-20020a1709061c0800b00a26b06c521fsi1686205ejg.364.2024.01.27.08.23.03 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:23:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41289-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) client-ip=147.75.80.249; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=NQnTrdyv; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41289-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41289-linux.lists.archive=gmail.com@vger.kernel.org" Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id 3D5201F20FAC for ; Sat, 27 Jan 2024 16:23:03 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id AB8545A7B3; Sat, 27 Jan 2024 16:19:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="NQnTrdyv" Received: from mail-pg1-f182.google.com (mail-pg1-f182.google.com [209.85.215.182]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 53E595B5B5 for ; Sat, 27 Jan 2024 16:19:43 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.182 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372384; cv=none; b=lZsI0hfdhdkdZpkZCf2tjjmomPFK45WE3nElLSjrZADFrBgwufNm3Mg2v5gjr1GjHCKUUFv6zGorwP9PQqVHvWc2jLQ9ew+jYLwqWTAQf9yk+BMB0kxv3rlWRe1qvwEbihLzPjcm/dVsbUBxFRc+JjcFtYoeWUCxM3yZqUSpyzo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372384; c=relaxed/simple; bh=NedQTssx+bEK6yK03BuZhPdTxJAmlvDpkxuNfU2rSeA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=S+NPL+gtujGu9Py05L/2qNV9Sc9dpfqI91ZveYFIM/XzsecmMxEjaIQ2PPi3a8cY2l8rRgD/wwiBwcrFhGSmGZOslBAw3I6scc6bnH4xiLDq3UP1vUlBRFJu2waqrYtB0/rGjh1GenUiy/PaCr2qLsb2omHzsA+PwfqJxzrUAng= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com; spf=pass smtp.mailfrom=ventanamicro.com; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b=NQnTrdyv; arc=none smtp.client-ip=209.85.215.182 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=ventanamicro.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=ventanamicro.com Received: by mail-pg1-f182.google.com with SMTP id 41be03b00d2f7-5cde7afa1d7so597939a12.1 for ; Sat, 27 Jan 2024 08:19:43 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706372383; x=1706977183; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=2RNpF/CWjVyq2jAidq9g4JrMuQdRaRtl2xGmvH6ydPA=; b=NQnTrdyvhSHTQKeyX1bpRRbkLkrVU+w9Ird1sIsu6gQmKceBl8kI9gV5mqSSHXrNNL XV+zW1yCdnWzJxwZ/r5vra58Xjp6oDC1eWqiK95j3wFaVgZRDNAN0BkEDK81Ws8zQw6O 8Lmq9P9sp7i+Roe7O39cugbrmiQM9F12+gko4iOb4Qj8iaE6pIbOM9/b69nfOo9YZaFz kffGj+YitMuokZxLcybsLgRu79OD9CI5rGzex6E0rdpDr7MViNy3/VgrA8g87FpCeUfz tAIj8kaRFFU1kC9N8+mNW8Jv7hkEDfz3HTirbFnfyAsaY3DxGL3O6vxPo7HducxP8rDl TcRA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706372383; x=1706977183; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=2RNpF/CWjVyq2jAidq9g4JrMuQdRaRtl2xGmvH6ydPA=; b=X23+d70SQtUoHpa1ZYwwv1vwKwivk3ExE/QAhi5V5kyvXwAAKnEUW2h1WNRKAhA/VS WF8JK1XNb0/LMPfaYge+zu5bJndCRRCTI6O/S3ovHUTQeiLTyx/d4HDq4gWtLCip5TJr UiQgOWho4Mt/zPVRiZA5A2RWDzIyBH4CJl3u5qbUbQf2Y5SQjxT0J5Yul+6u6iy+FOaZ c5lWQH+V3f77UQbi6Ti1iCT24ZKa8uG5PYHwtlLVAsQ1WJlY5+GcdCEGq1LrdLWJS3rL JZINjIJwosU89qYWin4cTVgs0EdkxIzf9U3TXPDerXlkArb/OSgxWIWnttPVE90n+Cuh J3pw== X-Gm-Message-State: AOJu0YwhtzE2Om5oQrfpKdFLIufFJP7bQyinaZKuyiSOr1NFZm7w356Q +U/+bnJ0Eg94hUqnjF3LI3r87k4NM25ZjxKXDptg8Is5y1XpcDTVSXnro0avf4o= X-Received: by 2002:a17:90a:9205:b0:295:488:5ad7 with SMTP id m5-20020a17090a920500b0029504885ad7mr654558pjo.5.1706372382559; Sat, 27 Jan 2024 08:19:42 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.17]) by smtp.gmail.com with ESMTPSA id d11-20020a17090ac24b00b00290f8c708d0sm5091620pjx.57.2024.01.27.08.19.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:19:42 -0800 (PST) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Marc Zyngier , =?UTF-8?q?Bj=C3=B6rn=20T=C3=B6pel?= , Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v12 15/25] irqchip/riscv-intc: Add support for RISC-V AIA Date: Sat, 27 Jan 2024 21:47:43 +0530 Message-Id: <20240127161753.114685-16-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240127161753.114685-1-apatel@ventanamicro.com> References: <20240127161753.114685-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit The RISC-V advanced interrupt architecture (AIA) extends the per-HART local interrupts in following ways: 1. Minimum 64 local interrupts for both RV32 and RV64 2. Ability to process multiple pending local interrupts in same interrupt handler 3. Priority configuration for each local interrupts 4. Special CSRs to configure/access the per-HART MSI controller We add support for #1 and #2 described above in the RISC-V intc driver. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-intc.c | 34 ++++++++++++++++++++++++++------ 1 file changed, 28 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index e8d01b14ccdd..bab536bbaf2c 100644 --- a/drivers/irqchip/irq-riscv-intc.c +++ b/drivers/irqchip/irq-riscv-intc.c @@ -17,6 +17,7 @@ #include #include #include +#include static struct irq_domain *intc_domain; @@ -30,6 +31,15 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs) generic_handle_domain_irq(intc_domain, cause); } +static asmlinkage void riscv_intc_aia_irq(struct pt_regs *regs) +{ + unsigned long topi; + + while ((topi = csr_read(CSR_TOPI))) + generic_handle_domain_irq(intc_domain, + topi >> TOPI_IID_SHIFT); +} + /* * On RISC-V systems local interrupts are masked or unmasked by writing * the SIE (Supervisor Interrupt Enable) CSR. As CSRs can only be written @@ -39,12 +49,18 @@ static asmlinkage void riscv_intc_irq(struct pt_regs *regs) static void riscv_intc_irq_mask(struct irq_data *d) { - csr_clear(CSR_IE, BIT(d->hwirq)); + if (IS_ENABLED(CONFIG_32BIT) && d->hwirq >= BITS_PER_LONG) + csr_clear(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); + else + csr_clear(CSR_IE, BIT(d->hwirq)); } static void riscv_intc_irq_unmask(struct irq_data *d) { - csr_set(CSR_IE, BIT(d->hwirq)); + if (IS_ENABLED(CONFIG_32BIT) && d->hwirq >= BITS_PER_LONG) + csr_set(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); + else + csr_set(CSR_IE, BIT(d->hwirq)); } static void riscv_intc_irq_eoi(struct irq_data *d) @@ -115,16 +131,20 @@ static struct fwnode_handle *riscv_intc_hwnode(void) static int __init riscv_intc_init_common(struct fwnode_handle *fn) { - int rc; + int rc, nr_irqs = riscv_isa_extension_available(NULL, SxAIA) ? + 64 : BITS_PER_LONG; - intc_domain = irq_domain_create_linear(fn, BITS_PER_LONG, + intc_domain = irq_domain_create_linear(fn, nr_irqs, &riscv_intc_domain_ops, NULL); if (!intc_domain) { pr_err("unable to add IRQ domain\n"); return -ENXIO; } - rc = set_handle_irq(&riscv_intc_irq); + if (riscv_isa_extension_available(NULL, SxAIA)) + rc = set_handle_irq(&riscv_intc_aia_irq); + else + rc = set_handle_irq(&riscv_intc_irq); if (rc) { pr_err("failed to set irq handler\n"); return rc; @@ -132,7 +152,9 @@ static int __init riscv_intc_init_common(struct fwnode_handle *fn) riscv_set_intc_hwnode_fn(riscv_intc_hwnode); - pr_info("%d local interrupts mapped\n", BITS_PER_LONG); + pr_info("%d local interrupts mapped%s\n", + nr_irqs, riscv_isa_extension_available(NULL, SxAIA) ? + " using AIA" : ""); return 0; } -- 2.34.1