From patchwork Tue Feb 20 06:07:08 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 203432 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:693c:2685:b0:108:e6aa:91d0 with SMTP id mn5csp215833dyc; Mon, 19 Feb 2024 22:08:44 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCWSaEkYXKyB2XNZsZO1gG+lIeIzE/Ge55LQGo0crB6x4V4bol9AYMz88ZsC5xPX47GbxzQqmqUFIW1YVrQskCulF+0yNA== X-Google-Smtp-Source: AGHT+IG9oZUZJVs4y0DAVdGfcdPea7bcYehsTx4AVjFy9NOXFNeRDuqOkihgdDAFcTHV4TwLG38q X-Received: by 2002:a17:906:b106:b0:a3e:e84a:ccfb with SMTP id u6-20020a170906b10600b00a3ee84accfbmr959604ejy.9.1708409324650; Mon, 19 Feb 2024 22:08:44 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708409324; cv=pass; d=google.com; s=arc-20160816; b=OWapaidDsjIfuk1pwOECoJDVZXPC/xV1OCpvTQhfcbtJ8lIInjhGJnqyluvMF9Y+Lz LglrE22sITQj56wEJ4ZdUiLr6N3qHEBinizkhaSjCcv7t/B+cM3Mk4nX4JfGBDBY7RkM /vWQqJgfvtAuorqV8BUB9iK93iZOsgVz/bsczDIJWhh+lOuRa8mVcWPvagH61zReUmN8 /iJc0gy74ss7VreCuthSZWQ8AjbeDpKYfB7+w5dzWKPah03weV+eDAp9CRmw84UgXqyf z9rffFhb9bXaxmr5xqRoCT/efmXFu+9GN9IqQlyL9iINyLtHXuNJwnLekSHnAPJoJYXO Dvnw== 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=lwCJWA25BI+Si7jYI+PxNTvvF3DTXZV8tHpiDzr2c0E=; b=Mz3B6T+DI5RFdshG7MYtnIAgOQR4nLOvF6YY/4NnXKC23CtcZNvnUlwZHgk+mdwtmz 8e2t77HOFxGgQzUDCD9pk6F8QLAwD2/v5qXIwn57WjoAK3vpzzmuBgGBeCxTCe924KLs EbGZI544wAiXYTt5BbTfVrhFqDw50FntaQ9E85SzmFxPnYGyffBgwNNZW3mKkbrNkUtm P6POd54C216C5pxuwnzZWbPGw/aw9171iqvNSqMHIlZyNxdPnHPtRxtCU8NBRQhYNvra Qic0hEplbfI/trny78WcozVR0Y18rvrHpRdKBnHZr9DupTNg2VLKZifh+2MMSYXeAeYm qgSg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=FpKssdaq; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-72378-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72378-ouuuleilei=gmail.com@vger.kernel.org" Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [147.75.80.249]) by mx.google.com with ESMTPS id gs8-20020a1709072d0800b00a3e39a874dasi2667153ejc.889.2024.02.19.22.08.44 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:08:44 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72378-ouuuleilei=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=FpKssdaq; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-72378-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72378-ouuuleilei=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 CD77B1F21BB8 for ; Tue, 20 Feb 2024 06:08:43 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E670B5915C; Tue, 20 Feb 2024 06:08:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="FpKssdaq" Received: from mail-pl1-f181.google.com (mail-pl1-f181.google.com [209.85.214.181]) (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 5F5E65914E for ; Tue, 20 Feb 2024 06:08:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.181 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708409286; cv=none; b=uzp5VKUGCPf3HYCEHD1gid+QHmZmsB+ee0JrCk1X5/7j8it0NlDCBmjgdCfQ4CyBy650i1QXL9JGB6VxPuq148t41qDDLiCROVR7AEgc3rwDDX/EOxj/AsfC7Khd5AIg7cqO6SFdwEyW6yh4QYV1hGit05VXl3hd/lHw0C1dJO4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708409286; c=relaxed/simple; bh=NedQTssx+bEK6yK03BuZhPdTxJAmlvDpkxuNfU2rSeA=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=N2LqGUfqtL5Z52vDttCAgd9knQS5/c6wtOdb6IwxC/XM+t7onV55yL7CmvgjYwkLsIfcQB6zjQsOp74UxnpZ+H0YRa/WiOLxG2PF+X5/s6Kc6BhC3L6N5OBXvSj4+AOHf7T4NkadN9542E+354BVLsGjdcS53eIIqEm4da/RK6Y= 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=FpKssdaq; arc=none smtp.client-ip=209.85.214.181 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-pl1-f181.google.com with SMTP id d9443c01a7336-1dc139ed11fso3090585ad.0 for ; Mon, 19 Feb 2024 22:08:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708409284; x=1709014084; 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=FpKssdaqpbmDg1uJCFD7+yJs3Zj0Uvwk7VwdsBK/gTv03osNgbdIFkl2tsGWuyyMjc U4HjehNE+oTVYW61wviFDPgUfGNIwYCcGF3HHg+IpsUDy+beJ1WHZipWkMbJTEiwKPk3 lKMCyR75asbR1wfYIIbSkJ5iLXEQqa03PYZ9dMa1J661GElniKIR2bXW1+ULoAqLrEXt 5ADBfdS5sDUu5fF0HBchb0J0rbW3BEMDeTNPP60PO+ePgxIvHCb3sa2u8+LLvklmCNWv naVAPVpQHm/3Ur+YW3WoxD/UHunY+CpgewdrCX9Mpv1i2CHsryWJxXp7pxiQk4JCR1za k4ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708409284; x=1709014084; 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=loJLRFNLZ/ZP11PTgqnmPubA7pEhGROwzoarP73RbiYhna4CgyuJDZh4KDUZ3VYIwj 21YapfSv8vaclfnvgpQOZ7hhyn6FAprzbsEQPAC+dyTx0HiXIVjETVQKUcR4gxFkvKK6 YisvCAgSzw6Pg2tuPRioZkcVLXzz52NjvmsDn7xQPCtqryXcR241Q4EkTM+smkRarSH3 xeWjLUlaeAvuI/BSqa9Wa0plLNjpKmY2tMR4Y0AGLvO6X23DCBfK+XayGQkxmOeUB3iD ODYcuRf/pAASGlYA6prY5ML2ACf+sFtqrx+q5E943FEpvDPwxmjR/4R4VmI2Ip78l5OZ eW2A== X-Forwarded-Encrypted: i=1; AJvYcCU2y0oGyJbxX2Gxa9SJu25AVYi8leEkcdUwnDeLLpDixcfFRYVwjjpkAYUNtjLCr54uP594ApGKmURW2HxTK/IKTOKXGCFkEy1h2Xor X-Gm-Message-State: AOJu0YwZn8ydviR2OEEtdM/x7xNKCUVugYlezpmo0sKMcKsbkzkro7w3 Kbgw+VfXYxVYpvLlHS/LUsUjL9FHOfTHkCWuMiTug67awvxoKqmi9qQYFS6vCeg= X-Received: by 2002:a17:902:e545:b0:1db:ecf1:3b83 with SMTP id n5-20020a170902e54500b001dbecf13b83mr7080645plf.23.1708409284467; Mon, 19 Feb 2024 22:08:04 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.80.86]) by smtp.gmail.com with ESMTPSA id j6-20020a17090276c600b001db4c89aea5sm5368114plt.158.2024.02.19.22.07.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:08:04 -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?b?QmrDtnJuIFTDtnBlbA==?= , 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 v13 03/13] irqchip/riscv-intc: Add support for RISC-V AIA Date: Tue, 20 Feb 2024 11:37:08 +0530 Message-Id: <20240220060718.823229-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240220060718.823229-1-apatel@ventanamicro.com> References: <20240220060718.823229-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791397015926317115 X-GMAIL-MSGID: 1791397015926317115 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; }