Received: by 2002:a05:6358:9144:b0:117:f937:c515 with SMTP id r4csp4438169rwr; Mon, 8 May 2023 07:42:35 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ47y/zV22/HX1TPtqXMgFYFD2usEdcz9yeZaCcLkwesNNrw2k+e2elf4B5aXojV0JJ90lTk X-Received: by 2002:aa7:88ce:0:b0:645:cfb0:2779 with SMTP id k14-20020aa788ce000000b00645cfb02779mr4458769pff.26.1683556955344; Mon, 08 May 2023 07:42:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1683556955; cv=none; d=google.com; s=arc-20160816; b=nPRUOWcmjnQPcL8MPbDsnp/MdSTJd6rWjCoJb4RJX8g4WfllGDdIiXPSmpmI4N+SY0 woyFds9Dbr7Vg0TJk44C5Nx0jPrG0jEaTeQAyz4WV7rYzrUi1VbQAn0/IVfQ1ZqCkwWS +fdRBWa8qKXbJtPW50c5xLLrxndxwx5KkMVVU0Qeu4+XIgL5PDMjFe3QU66qUvgbJG1c 1k/oLEYd/ijKKGXDPW+jZXmTGQEOuFGzi+4jqxR4TT1TDRBwZDpgMu2C4eJf5H5u6afw 8G5R19CZM4Y4o9EaMQv727PxUH6ksafaiKVsH9eIYjETwklu0I0h7TT0/4qBI7F4dk3G +GLA== 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=XXSsvlQ/R6yHM0Hz/nbqBTRJ+migXFNIKunDjIZh+EE=; b=zgL5pA+EgzU7GMzW6gzfsclsm+AsIrBCjbEe4xhAdO8w2/CLlZhKDD4mu2sNwRHiXH OAaOBO63Vo4ZF+sDABi2HWuk/5WquUP77B9D5CrMbz5hPUlmT8sRziySPs6/NHiolhdY /XPboywGN9rFJ3M/dEdsPKzM0CND2cdgOR+rzaPj4thdGxHJs9RP4k1wj4oyI4646x0e 2MXWNOdPdEuDUeXqKeRXiJkBVgMPl7Vhpo+eB1K1WvuVTycOskjuCHWCCXTxwnGH/Lh/ FmrbnHjB3p9k4vPwqHpG+TUoVcaqsmgywDgHRZM2CZvHWbLmPbBXj5R7ViptfmVuQxhn u5Aw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="DweqYW/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n18-20020a637212000000b0051a8a22a42dsi8694681pgc.268.2023.05.08.07.42.21; Mon, 08 May 2023 07:42:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b="DweqYW/w"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234557AbjEHO3q (ORCPT + 99 others); Mon, 8 May 2023 10:29:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37026 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234631AbjEHO3e (ORCPT ); Mon, 8 May 2023 10:29:34 -0400 Received: from mail-pf1-x432.google.com (mail-pf1-x432.google.com [IPv6:2607:f8b0:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC50E769A for ; Mon, 8 May 2023 07:29:14 -0700 (PDT) Received: by mail-pf1-x432.google.com with SMTP id d2e1a72fcca58-643990c5373so4415741b3a.1 for ; Mon, 08 May 2023 07:29:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1683556154; x=1686148154; 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=XXSsvlQ/R6yHM0Hz/nbqBTRJ+migXFNIKunDjIZh+EE=; b=DweqYW/wrp2Hf6/tVp5eeVH4LnisiW9pU5JubLDyr0brsc0HBnW8Qgyr1eFnd5QfXK 8w4qBpjYMQah6H1nRgtuXFq59MELnCpNXOFOdjeszMPCrkyVCInlZgzLC1Jq6h3U0gzj 1U+VyQRCz1W2lHAYuK9sV/KyTfdpUh/o4R/Umu35gl0DHT+wQ5xhgCQf4yCT+UgnO877 5JzFxsXO14oRxKst0J6FSwH4DF1anEFXBqoEEqBt3Mjr3dS/UbPv59e+DaQhVgNeZPfw JyGEa7GHoWYIj/EDesISBqmzze/6QFm98thoAnFGsp2XFWF2ezTT8bdnc7chD2cr595N FHhw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1683556154; x=1686148154; 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=XXSsvlQ/R6yHM0Hz/nbqBTRJ+migXFNIKunDjIZh+EE=; b=WevlDJF5uIZCOSUmUI6POmfjFpY6tFm4kXFQ3OIA+LMdLsfYFPiiRCtljU3EldjoMq ipGit9o0fYL8G10ukpAkCN/LVfbfDhgWVScpHOYnVAy7UsJg7IcLioQ6TzLcxY/Se9jq TI8tk0bZYBGBvXVGvAPDb4CHEIOkPLP/LqVwzVO07JupCl5C91J7RwBoHodlzNnScQzA eyZB1q3Ri6yfYnh3J3H4lG7cWovxgtpjxIBZz23j6E2MuGmGYVqBIZwGi3CcI9BgpBeK XIa5Y0TLd2Tp3fpDi8deVO7nDK/ogDR1GhNI2hEzrYw9Kvi6dxtKy7h4ZypIQHlPS6Eh C3lw== X-Gm-Message-State: AC+VfDzcGWnu8BAExQtoVULFtwVPeb455RPG+N3w7r6crQNRDXn0bjlS ofHEkx9Qk7hHSoyCJd37S9tT2Q== X-Received: by 2002:a05:6a00:23c4:b0:63d:254a:3901 with SMTP id g4-20020a056a0023c400b0063d254a3901mr13848595pfc.25.1683556154240; Mon, 08 May 2023 07:29:14 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.84.206]) by smtp.gmail.com with ESMTPSA id k3-20020aa790c3000000b0063d46ec5777sm6082pfk.158.2023.05.08.07.29.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 May 2023 07:29:13 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Robin Murphy , Joerg Roedel , Will Deacon , Frank Rowand Cc: Atish Patra , Andrew Jones , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux.dev, Anup Patel Subject: [PATCH v3 03/11] irqchip/riscv-intc: Add support for RISC-V AIA Date: Mon, 8 May 2023 19:58:34 +0530 Message-Id: <20230508142842.854564-4-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230508142842.854564-1-apatel@ventanamicro.com> References: <20230508142842.854564-1-apatel@ventanamicro.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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_NONE, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 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 This patch adds support for RISC-V AIA in the RISC-V intc driver. Signed-off-by: Anup Patel --- drivers/irqchip/irq-riscv-intc.c | 36 ++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) diff --git a/drivers/irqchip/irq-riscv-intc.c b/drivers/irqchip/irq-riscv-intc.c index 4adeee1bc391..e235bf1708a4 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 (d->hwirq < BITS_PER_LONG) + csr_clear(CSR_IE, BIT(d->hwirq)); + else + csr_clear(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); } static void riscv_intc_irq_unmask(struct irq_data *d) { - csr_set(CSR_IE, BIT(d->hwirq)); + if (d->hwirq < BITS_PER_LONG) + csr_set(CSR_IE, BIT(d->hwirq)); + else + csr_set(CSR_IEH, BIT(d->hwirq - BITS_PER_LONG)); } static void riscv_intc_irq_eoi(struct irq_data *d) @@ -115,16 +131,22 @@ 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 = BITS_PER_LONG; + + if (riscv_isa_extension_available(NULL, SxAIA) && BITS_PER_LONG == 32) + nr_irqs = nr_irqs * 2; - 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 +154,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