Received: by 2002:a05:7412:cfc7:b0:fc:a2b0:25d7 with SMTP id by7csp1546196rdb; Mon, 19 Feb 2024 22:08:37 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCUyoHh5N6TzikGYH/U7Ql8NQLrL6OZXZQt6XSXEdXCvh5BON4k3UohLQCmmaFb4Mf9/yxGQPpiYB5ZokzJdguj9eXeRCkrPV4VpPRKwTw== X-Google-Smtp-Source: AGHT+IHK/qFzPjoIg5CEpOXPMx+A2Cy4CZJb9FUL4Pw+P2QUdJ8v0tmuFjdWIH+WTtkDcm76EV64 X-Received: by 2002:a2e:88d4:0:b0:2d2:3898:f1ea with SMTP id a20-20020a2e88d4000000b002d23898f1eamr3356003ljk.5.1708409317085; Mon, 19 Feb 2024 22:08:37 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708409317; cv=pass; d=google.com; s=arc-20160816; b=qY1ia9TV7nXvvgi2ZUQSn9JAlf+Rh55MRl0qegUiQBVetjN0lwuA3QQH3Td24IdmCf imLVpzI/i5xh2rVJjgQ67EY5iRCtaDSoFnyCuv4SC1NSpkomz13GbRZgWoGWxgrd8EZu pud7e1HNWqfueVZJ6E+hFM6fNv1lOfJxwtocCHcl1r092y0c+PJb014p7MWzyuaa6A72 21AztUN2KuOrxUAuVh18hlF1F7x3tvXKWne7BRIrkvmbaaLAuJ/0hB/qrZ/rKvyb5K1i FjhR6fNjITCvb+tKFGEGsnAqr4gkvNZozne54/YgPdYMG2A79aAOgDOfOf29YWopXbXa QGvg== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72378-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 d24-20020aa7d698000000b005641e601f02si2765669edr.98.2024.02.19.22.08.37 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 19 Feb 2024 22:08:37 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-72378-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=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-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.80.249 as permitted sender) smtp.mailfrom="linux-kernel+bounces-72378-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 A7C131F221C5 for ; Tue, 20 Feb 2024 06:08:36 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B21B759150; Tue, 20 Feb 2024 06:08:07 +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?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 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 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