Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1733725rdb; Mon, 2 Oct 2023 21:46:12 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGW9fjdtdffpT8AgY4ib6b0feCujO2KRZdB1GPDoBXwZ23M2WDGxx7WIR77xxrGiYBv2Ei/ X-Received: by 2002:a05:6870:8a25:b0:1e1:9e8:5be0 with SMTP id p37-20020a0568708a2500b001e109e85be0mr16679491oaq.17.1696308372199; Mon, 02 Oct 2023 21:46:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696308372; cv=none; d=google.com; s=arc-20160816; b=FrICl6azdmZGmJ5kkukZlIRU4RLSNTR3kuWuBaPlCW06Fb4s9N0Y0p/wt9nMMcWXIc 12mv928WmiNja2OKJ7JcTc/b4dPFLshsspDzWPvHBaCXe39W2v3RzJ672yBEbIITL3YL mNwFHeQesS18o2tC5vlwZJi32aW0ziqynARQMLv4DSUxcEtGsdfqStcWAFnm1UMzMRrz BRlShPPlB7lNPR3JdCbLXXrFTThDUWsF1zWaHr7zF9Etq0s6bG7y2o5Y/RWujWSHbRr2 t3a+NBcVlLAQQ5idTnALWwsFRISm1TQ0JK1nL3CZc0l52VB+kV8oXRjrj9wSvLKU8sLW kXbQ== 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=lYcKkQdCCxqxCPBVBdSrbjYHAJU172pfy751bGjOCyI=; fh=ZYtQOaPQ3bv/nEoeNBBJi+8gjEgXnsUn5nizHK4ZU74=; b=FpMaMFjLCq9PAnzhvEGnGS4i+vQavnLTzu5r/R+0VXddaaYODbTAm6KlW9mwThUfpr jsRW8JT8zG5+OA6V1KwTzUW6FukBB03khZjea4mtqqENXVXjCmscps0bBh/dV7I4ZTGu L+7vgbvB9HCWKAOgQvlZbP8G07LQ/zX+ZxKySQ8ZOYrCbVyak5ByVJYGddXDG4PjfxCp cr/ozVWgNKs0wA4tW5Uwut40GGvfmu2FPG/d+8V3ct8lF9vgTEhDwMfAN6pQKQhVFALt SpkE8duM5JQ/7UOAQ+MTjDI6YpFFf7zEa/dTGJydrms82YkCPlyf7OFiUBvhjagEL9rD 6EXw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=NKAhoSgq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id h130-20020a636c88000000b00537c6c285a0si586715pgc.167.2023.10.02.21.46.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 21:46:12 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=NKAhoSgq; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 291AC806858F; Mon, 2 Oct 2023 21:46:10 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239126AbjJCEpx (ORCPT + 99 others); Tue, 3 Oct 2023 00:45:53 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:35568 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239107AbjJCEpf (ORCPT ); Tue, 3 Oct 2023 00:45:35 -0400 Received: from mail-oo1-xc32.google.com (mail-oo1-xc32.google.com [IPv6:2607:f8b0:4864:20::c32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 10776C4 for ; Mon, 2 Oct 2023 21:45:25 -0700 (PDT) Received: by mail-oo1-xc32.google.com with SMTP id 006d021491bc7-57d086365f7so280775eaf.0 for ; Mon, 02 Oct 2023 21:45:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1696308324; x=1696913124; 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=lYcKkQdCCxqxCPBVBdSrbjYHAJU172pfy751bGjOCyI=; b=NKAhoSgqUSEp1MjoLYpuNmyO2AxankcPHK63uQ/bFp++vuhCzPDiwLgUkBbn74LHQn goFlfyZJo4TYi2AYyPhCt/Epjwf/84x1my7EzfAOF7lGucfCi5j8kd/qTqwOXCXStPMj T17ikE0Is9Wl/ZzXZZs+A4s2T2db9nc7VU9XoXZfVjir4aVwKwy5U4olxDr9pnocI1S1 IQqbXXuPVKr30bMmPcXTWqmKpIZwzdxLnDt+CWSJbvWGQ+uLCWho1gDCYBkngYjvX3BG MlVoXKsHIk+L7l5vXLSVDdXbulIIWFu0eVTeJetbVNiQfHq8JCeFnxXLLvonPi/p8Qw6 eOyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1696308324; x=1696913124; 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=lYcKkQdCCxqxCPBVBdSrbjYHAJU172pfy751bGjOCyI=; b=YoyPjoG95THNmYy5bj6EH/Xnn4K4C/BTOMbIar5qbIKvhYf0xPmD21B6xa32YLBlIS gj6Yr5O/jn8lOjCEdeOI8Hf9dGjnSpjTrMOv/LciwxX7lpFPYnPR0PNuTJWM2gv7RuJ6 jHp1T3aM1397Nd23VzllTR7fjcMiXyy+znUCJ2NtULlTErAvY46fYZVll0GRrIqm3HY3 FyH5kixNCetPfuK0gr4zgBzNAA8vSOqUreyfHGWwnHJrzkhP4S7fpdO80i+fbxvB3NZe /+nwIwzRFImuAgDm/LP37LGxVOJh3Op+17KrSBOHTGXdhqzOnMjC43tkj0nYnGM46St2 FvHg== X-Gm-Message-State: AOJu0YxBZ0gvz4bRnwoYRR9dBxCnzUCrixZ1lx6M24PSuY4d//igvg3A 4UiMnIutsj4L1XP43Abw5kn7gA== X-Received: by 2002:a05:6358:90f:b0:135:b4c:a490 with SMTP id r15-20020a056358090f00b001350b4ca490mr16245093rwi.10.1696308324085; Mon, 02 Oct 2023 21:45:24 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.84.132]) by smtp.gmail.com with ESMTPSA id h9-20020aa786c9000000b0068e49cb1692sm346421pfo.1.2023.10.02.21.45.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 21:45:23 -0700 (PDT) From: Anup Patel To: Palmer Dabbelt , Paul Walmsley , Thomas Gleixner , Marc Zyngier , Rob Herring , Krzysztof Kozlowski , Frank Rowand , Conor Dooley Cc: Atish Patra , Andrew Jones , Sunil V L , Saravana Kannan , Anup Patel , linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org, devicetree@vger.kernel.org, Anup Patel Subject: [PATCH v10 10/15] irqchip/riscv-imsic: Add support for PCI MSI irqdomain Date: Tue, 3 Oct 2023 10:13:58 +0530 Message-Id: <20231003044403.1974628-11-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20231003044403.1974628-1-apatel@ventanamicro.com> References: <20231003044403.1974628-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 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 X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Mon, 02 Oct 2023 21:46:10 -0700 (PDT) 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-platform.c | 48 ++++++++++++++++++++++ drivers/irqchip/irq-riscv-imsic-state.h | 1 + 3 files changed, 56 insertions(+) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index bdd80716114d..c1d69b418dfb 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -552,6 +552,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-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 809e338bf9c3..ff46b85ca45a 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -12,6 +12,7 @@ #include #include #include +#include #include #include #include @@ -184,6 +185,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 = "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 = "IMSIC-PLAT", }; @@ -208,12 +242,26 @@ static int imsic_irq_domains_init(struct device *dev) } 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(dev->fwnode, + &imsic_pci_domain_info, + imsic->base_domain); + if (!imsic->pci_domain) { + dev_err(dev, "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(dev->fwnode, &imsic_plat_domain_info, imsic->base_domain); if (!imsic->plat_domain) { dev_err(dev, "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; } diff --git a/drivers/irqchip/irq-riscv-imsic-state.h b/drivers/irqchip/irq-riscv-imsic-state.h index 3170018949a8..ff3c377b9b33 100644 --- a/drivers/irqchip/irq-riscv-imsic-state.h +++ b/drivers/irqchip/irq-riscv-imsic-state.h @@ -31,6 +31,7 @@ struct imsic_priv { /* IRQ domains (created by platform driver) */ struct irq_domain *base_domain; + struct irq_domain *pci_domain; struct irq_domain *plat_domain; }; -- 2.34.1