Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp8091164rwp; Wed, 19 Jul 2023 05:15:31 -0700 (PDT) X-Google-Smtp-Source: APBJJlGLUCvtRwYs6y9H03LC85hKqG1iK1K9JiaaDnl4QAEqrPxNoAhVHIZuq9QoupwWhyyA8orc X-Received: by 2002:a05:6512:23a0:b0:4f9:5519:78b8 with SMTP id c32-20020a05651223a000b004f9551978b8mr2075224lfv.63.1689768931607; Wed, 19 Jul 2023 05:15:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689768931; cv=none; d=google.com; s=arc-20160816; b=aUBVXBcY7RxnjBw0yQuGgfFysST2N/k4t5MUud50vBSvq1jWKaRMA3ErvGfAgm2CJg 2iwe8Pqa9YPJChiRUec7B6YSLfR2XTWaNr3qG1qVUp12sRyKeQTH/3aErMERa1CDsGjy GECS2RtxCmskFPaLGheM/cQEVALZrUrQ4iVhsdaiOKn5rdGXDF/z7r9Qtsr2FeLx8Zc5 c0jNLoGeXncUGhwb7OcImLlxeVZUiuznZdv7dw2CQ6hudESsKaaYgHv39D44xd+Db/Xx Fa24JYsEu/VI7HnxLGNm5gkTEnIdlYj/8sHzHJlrI4csMRTyzlD1QSzkAAfTnAFWx8T+ tt8g== 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=hqMLD6GnTmKyZf6qDJ2/qOFn7vKzTS5oYxh4x8Esfkk=; fh=f+ph7VIwhX7iLJOrfHJ1YQ1ojo0XBG5+jaAb/hL4mCY=; b=fasf9BCHUE+IDEplaoqGOxL8xcdMQV4NVrQk1slCBjIWWhzlmknK/3i2qxrJC/2zBO ynk/dY2iKyjUutvj++LZ1loEe7xtMXm3svHvi2LlTvwzZsaRz3/RmGH/stUmr3UOd7ih NxIKkGGv27evaxFiD0y4ZOeYz01+yCxzjPphxB1H5mKJTGO6WlDwoLjZvsLRFO1xnQGz 5zi2n6X6bA764GyWQu8AkECbO+bu01U29awhhqR2/ysYHrpChrUyzHZxL2pIUbWijPKx FdTtV6HF3xzzJoBZAZtVf/BXca+NDzYx0rI6AU2ZOleixmhOk+xFJ+TllAse7DfrKI9H hRjQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=NN12gld9; 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 y1-20020a50eb01000000b00518744a06a4si3113794edp.83.2023.07.19.05.15.00; Wed, 19 Jul 2023 05:15:31 -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=NN12gld9; 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 S230308AbjGSLhb (ORCPT + 99 others); Wed, 19 Jul 2023 07:37:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54624 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230293AbjGSLh3 (ORCPT ); Wed, 19 Jul 2023 07:37:29 -0400 Received: from mail-pf1-x430.google.com (mail-pf1-x430.google.com [IPv6:2607:f8b0:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 13C0B171D for ; Wed, 19 Jul 2023 04:37:01 -0700 (PDT) Received: by mail-pf1-x430.google.com with SMTP id d2e1a72fcca58-6689430d803so4597124b3a.0 for ; Wed, 19 Jul 2023 04:37:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1689766603; x=1690371403; 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=hqMLD6GnTmKyZf6qDJ2/qOFn7vKzTS5oYxh4x8Esfkk=; b=NN12gld9xeVSD1XqFYqqOkUsDLTAOj0BChmw1+LO9CBPoy65dIN72zPlCUuYmm/oH1 BCY/jD67qb6hcwtMqmHVe6fn9DAMB+ymN/4IuUBou9LDlg/OYKJkJwYCc0tKoA4mFQai +1k4PyeVVFgfFzVRSdYqeI/piNwuh5LLs4ByrddtO/6NzBHaIujdZLhww+uw3ehQgjzj S3HjM3q8VRa2brVvquULOSNzkZOrcFWe0BkzAxhKdX6ilEjIZJtbkQ8hbCfWzwQV4gBt sL6A55Jzl07cOON7oq38+AG6fW7DOr1sYGCnivE0UJQxVv9O78KiNEV5U7KrzVN7efa3 TzqQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1689766603; x=1690371403; 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=hqMLD6GnTmKyZf6qDJ2/qOFn7vKzTS5oYxh4x8Esfkk=; b=DuEEUvSIKDeUcwoxxl5ZB36ZLmbmyiitsYL8uDPV4oAIPDCugyM/ysUM899m0CICcW cMNGPzk+K8dtyLqd/+eA3IP3gCh+OTN1t9AETRMzcXyqwErhB3OZ01eUtGcg6UFm1JGA lyFWrgC2VXSHx2SikwU9KW93w3PFPXCL3cRFVeVZqlHWF+gErh42k5Ww5sRYncNxf1Z1 D/VLal6gSQNYBZkCxBgvkQEZGmKj4yCucy7o3SiMvRZiZmDJVT+LgrzKyV1AgqMZmOKK MYh6QnRYoJQ8jUs4wICHdxY6/gSygh9M34ceVo4v0QpF4H2oTh7y3ZqHMbfO/FR+1r7b Oe/w== X-Gm-Message-State: ABy/qLaPKyf9GXgVFKs0jFkah+2310jxfXu66zJhdLrH018ExjpGtj/r jPSXTumm/C+IRDzhPN86wc9yVw== X-Received: by 2002:a05:6a21:6d8f:b0:137:7198:af9b with SMTP id wl15-20020a056a216d8f00b001377198af9bmr332146pzb.56.1689766603141; Wed, 19 Jul 2023 04:36:43 -0700 (PDT) Received: from anup-ubuntu-vm.localdomain ([171.76.86.130]) by smtp.gmail.com with ESMTPSA id j10-20020aa783ca000000b00669c99d05fasm3050408pfn.150.2023.07.19.04.36.37 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 19 Jul 2023 04:36:42 -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 v6 09/14] irqchip/riscv-imsic: Add support for PCI MSI irqdomain Date: Wed, 19 Jul 2023 17:05:37 +0530 Message-Id: <20230719113542.2293295-10-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230719113542.2293295-1-apatel@ventanamicro.com> References: <20230719113542.2293295-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_BLOCKED, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED 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 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 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-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index db896b6e51ff..02175e4e5cb9 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 __init 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