From patchwork Tue Jun 13 15:34:10 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13278997 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 098A2EB64D9 for ; Tue, 13 Jun 2023 15:35:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=487bHbFV3kmkuQ2pCF1eGP50dEhZc2vlJEcnOwcdwDc=; b=2UtiJX85+HZuJ7 K4GfD0iH9u0pTmPiUY4bH5o2jaHJSxb1PUdwYnmkegKdUDr0kHDIXqvGD7lTywihklVSEMrCQFX04 MhrQMY355Gr9nJFkA+jd25ZFw76hLAhtyWNlrgGT0Tj+cleIF0lkIgw7cHEWx3uJ7ieetmNL+oxu3 d+vmbmxyiSU/R9Yg1DxevUpazJKwp2rrNYxYC6HuOsCvnkXMD5MjKpV5OVV1ySeFLMiEInPFrLlqJ ySSm8+wwp7PgaqxndGWvZhYBwOYvCFMIA0okITK/WEh4KTk/TXn+jxN4GyLE1UBzfG6DjB2Ey5XW4 oKDgczIj88QxzzRxR/OA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q963C-008U1C-0Q; Tue, 13 Jun 2023 15:35:18 +0000 Received: from mail-oi1-x22f.google.com ([2607:f8b0:4864:20::22f]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q9638-008Txi-0E for linux-riscv@lists.infradead.org; Tue, 13 Jun 2023 15:35:16 +0000 Received: by mail-oi1-x22f.google.com with SMTP id 5614622812f47-39c84b14d6aso2341792b6e.2 for ; Tue, 13 Jun 2023 08:35:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1686670512; x=1689262512; 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=WZx8pVyFJqTIpr4BnDr/88VmIIeD0a98LNl1bXs4aCI=; b=bobahJF8kidzPjUWHZY+LrqiNoPUHXIkK9UI+jd9QvV+X/+mrS/m2AnbefOsXv4q81 dF7lTH/FeOOmnMTBgVnEA+m24ozLFeM9ocJc3P/P/b/K8prClc66SJnQnrBrH0eT2Nd9 CeDAlxeXbZri6qrvKwsY+z8khr2WY13NbPXANr0n3a4YLwU4yrF57x8TrL3sZhLB0EAQ slT9whhsVY5gtQMvB5menspdXOYQqMX0tA76imnLnBLQVDJftIxhXbaSOqna+i8mCHex fOzUiqKCDm1M36J4iGTJT5SQlzDqf19N1w5INZFS5fhWeZMY1V+gZzeEi7UX/PMUQs4f zY/g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1686670512; x=1689262512; 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=WZx8pVyFJqTIpr4BnDr/88VmIIeD0a98LNl1bXs4aCI=; b=Tzer50269DcNLgGeyAZQJfm3mMeHYUff5b1mhTKgfyq5xyZlBxKp5qJ2DM5aBfKWwe R7Oi1Q0TJQ8b4UBDAH3a6ldcDM3XtmOBCcId1WOH0eeI1iujEExtH7J5HdjegTYNstQb cEB+lXnW4isi90jl4wftTKMyVUxqgpirt6sUejcDDG7XGWABnW1btgoQyK1i3DFSZlLp tmuXm08G2chQoQGCrqdvaPqVLzj9aVpwBpI1fF/kx9pBGm+QlWWM31jt/69QlYO2ENXA 3Gx8nDWrf+lWLQJfLXtWT/YnsB/qjKLhLg98GtzCElXIHWytDHG/+jguTrjISwMT09Ot GmQA== X-Gm-Message-State: AC+VfDyP2YyzMczeXJSRE1vVJ0PYN1X4GvxI/eddD48dSKPpafJWvU9g m+SrIUtodOdUGGMJ0e2aRAMN9w== X-Google-Smtp-Source: ACHHUZ4RbSBoRkEKSHPgVAtKK5OZ3eD2vb3A5rLfAl+gm4q9/BmEvai8MXNvxWtLM2OjtVY53qfU8g== X-Received: by 2002:a54:4486:0:b0:398:462e:5068 with SMTP id v6-20020a544486000000b00398462e5068mr6841916oiv.43.1686670512028; Tue, 13 Jun 2023 08:35:12 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([103.97.165.210]) by smtp.gmail.com with ESMTPSA id n2-20020acabd02000000b0039ce305ea4fsm1630807oif.14.2023.06.13.08.35.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 13 Jun 2023 08:35:11 -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 , Conor Dooley , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, iommu@lists.linux.dev, Anup Patel Subject: [PATCH v4 05/10] irqchip/riscv-imsic: Add support for PCI MSI irqdomain Date: Tue, 13 Jun 2023 21:04:10 +0530 Message-Id: <20230613153415.350528-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230613153415.350528-1-apatel@ventanamicro.com> References: <20230613153415.350528-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230613_083514_114561_F79B769F X-CRM114-Status: GOOD ( 17.13 ) X-BeenThere: linux-riscv@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org The Linux PCI framework requires it's own dedicated MSI irqdomain so let us create PCI MSI irqdomain as child of the IMSIC base irqdomain. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 +++++ drivers/irqchip/irq-riscv-imsic.c | 49 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 8ef18be5f37b..d700980372ef 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -550,6 +550,13 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY select GENERIC_MSI_IRQ +config RISCV_IMSIC_PCI + bool + depends on RISCV_IMSIC + depends on PCI + depends on PCI_MSI + default RISCV_IMSIC + config EXYNOS_IRQ_COMBINER bool "Samsung Exynos IRQ combiner support" if COMPILE_TEST depends on (ARCH_EXYNOS && ARM) || COMPILE_TEST diff --git a/drivers/irqchip/irq-riscv-imsic.c b/drivers/irqchip/irq-riscv-imsic.c index 971fad638c9f..30247c84a6b0 100644 --- a/drivers/irqchip/irq-riscv-imsic.c +++ b/drivers/irqchip/irq-riscv-imsic.c @@ -18,6 +18,7 @@ #include #include #include +#include #include #include #include @@ -81,6 +82,7 @@ struct imsic_priv { /* IRQ domains */ struct irq_domain *base_domain; + struct irq_domain *pci_domain; struct irq_domain *plat_domain; }; @@ -547,6 +549,39 @@ static const struct irq_domain_ops imsic_base_domain_ops = { .free = imsic_irq_domain_free, }; +#ifdef CONFIG_RISCV_IMSIC_PCI + +static void imsic_pci_mask_irq(struct irq_data *d) +{ + pci_msi_mask_irq(d); + irq_chip_mask_parent(d); +} + +static void imsic_pci_unmask_irq(struct irq_data *d) +{ + pci_msi_unmask_irq(d); + irq_chip_unmask_parent(d); +} + +static struct irq_chip imsic_pci_irq_chip = { + .name = "RISC-V IMSIC-PCI", + .irq_mask = imsic_pci_mask_irq, + .irq_unmask = imsic_pci_unmask_irq, + .irq_eoi = irq_chip_eoi_parent, +}; + +static struct msi_domain_ops imsic_pci_domain_ops = { +}; + +static struct msi_domain_info imsic_pci_domain_info = { + .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSIX | MSI_FLAG_MULTI_PCI_MSI), + .ops = &imsic_pci_domain_ops, + .chip = &imsic_pci_irq_chip, +}; + +#endif + static struct irq_chip imsic_plat_irq_chip = { .name = "RISC-V IMSIC-PLAT", }; @@ -571,12 +606,26 @@ static int __init imsic_irq_domains_init(struct fwnode_handle *fwnode) } irq_domain_update_bus_token(imsic->base_domain, DOMAIN_BUS_NEXUS); +#ifdef CONFIG_RISCV_IMSIC_PCI + /* Create PCI MSI domain */ + imsic->pci_domain = pci_msi_create_irq_domain(fwnode, + &imsic_pci_domain_info, + imsic->base_domain); + if (!imsic->pci_domain) { + pr_err("Failed to create IMSIC PCI domain\n"); + irq_domain_remove(imsic->base_domain); + return -ENOMEM; + } +#endif + /* Create Platform MSI domain */ imsic->plat_domain = platform_msi_create_irq_domain(fwnode, &imsic_plat_domain_info, imsic->base_domain); if (!imsic->plat_domain) { pr_err("Failed to create IMSIC platform domain\n"); + if (imsic->pci_domain) + irq_domain_remove(imsic->pci_domain); irq_domain_remove(imsic->base_domain); return -ENOMEM; }