From patchwork Mon Feb 26 04:07:41 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 206227 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:a81b:b0:108:e6aa:91d0 with SMTP id bq27csp1859984dyb; Sun, 25 Feb 2024 20:12:40 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCVqWMnZoObsTOLOEi6XNXYBJAENjGhKowHmNA5rVQOCcNvSxYQWrDVdL0JAm4GVNMXPT6mcS/CFslLPUnd+X1nSZ6E2AQ== X-Google-Smtp-Source: AGHT+IEPGs+xuDQMnXLy/wWKlZNBUGcJ1iZqhmrW0U2lvzkO6IW1MFtkH1sZchE3myBD4YbVva12 X-Received: by 2002:a17:903:32cc:b0:1dc:24f8:61b2 with SMTP id i12-20020a17090332cc00b001dc24f861b2mr6932332plr.51.1708920760029; Sun, 25 Feb 2024 20:12:40 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708920760; cv=pass; d=google.com; s=arc-20160816; b=Kx9MfCumgN6bKuxsMIOaLrTPZMT4egdK//hyfz7dG51vXgW6axhWELza7Ht+TFsN8k MQ9Nxcwn/qJXNEFTzwJmAHA7EyivjLjkUCZ2t+ddxsDs2fWTUtvNx7YMc2K7vsdLqw26 /5z/seUncJ4/eTSFXbfaVH0qd8kxsKTHyXmlTglakBEEP3SuKf2PcsraPOdFOz0RIWEe 8ZZEEb/1oZ5RG6hAsdCz07AVE4RfK2v7Fywj6SQtt9RK3A9fA4xNrjwIQJiHBHaKWOIM NVSYQqznbbpOKbAYa9sGcrTVTkSspJHW27CImuKv1TK0xlcJogUTOCUd77WfFTSIWH3V Vc3g== 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=7jRh4tMvuYcqr95qV4EQU7BolCnIgD6A0sDxFfSdHTU=; fh=ywv9l85zZ2Tk/hQAlKBOIvIu1yuF5r/nGbJvlKgFXIg=; b=ZcJebjjBz4pkAkDGcj6wBWrhEzZ1cnliDaemNdI7Kt4OHMvTFfmwH3yS8uk3UDh6rm NX1u2OMJYTmWK86UPB4wTpaVc8jhdmchmFTl4pFJrvyEcLyZIKnVN84sdrUgI0szYlkD WYmLQRbAoGhdeVI0cFcvO/z95/NqFKr0T9YJpoN8uZQhIaMdKJpWdDdw4JSPWJEu1Tdg vq0hiUP6KUFddNVmm0aUOyvhZl2wYvW6SRJhblqafLyNoItqpTj5mUUQTfuPyjTpEpyD P4bwm4Ngv031eym/iDua3HMNdYhqOk9SeDso2IM3Pn/BzJDSnlDPz1rB8L1suI1Berig GI/w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WSjrYg7l; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-80534-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80534-ouuuleilei=gmail.com@vger.kernel.org" Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id e7-20020a170902784700b001dc42bd343bsi2933095pln.268.2024.02.25.20.12.39 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 20:12:40 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80534-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=WSjrYg7l; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-80534-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80534-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id EF0FD2836D8 for ; Mon, 26 Feb 2024 04:10:55 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 23FE81C6B9; Mon, 26 Feb 2024 04:09:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="WSjrYg7l" Received: from mail-pl1-f178.google.com (mail-pl1-f178.google.com [209.85.214.178]) (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 0CE6C1C683 for ; Mon, 26 Feb 2024 04:09:28 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.214.178 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708920571; cv=none; b=LuK2hmz6BXcW91MpIKseAejnIM68KYmNm1QGq1l3Oy3LObalj49OwCT0COin2atzikomVF3XAnQ1pJaRf3t+FqV5E1cE7vSaS969R5Uj1tAfbC8zK1bAE7We5elPgMdBbc9qLqA1ezk2nanNzjkWVdAbR8driHSGCZIPuqiT5VM= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708920571; c=relaxed/simple; bh=1EX8L1zE26OQw962MFbAys4CFWP3ww+6xmUKKdVPt6M=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=EsPAmmd66fWKeZNVlSweu3G9XuD6TPRHdpMHYHDh8cxM+3wUxX70YK1uQzKmFbW4vD2Le9g2lRyrf6waZvQJBIPYcScKOMALdvJw4PPHMmpQF1QZu3TjN+DKh87Htjb47skEAxedVhjQ0MKt/O1yuj9SuVDq4QK1yYmKIjzAhR4= 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=WSjrYg7l; arc=none smtp.client-ip=209.85.214.178 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-f178.google.com with SMTP id d9443c01a7336-1dc13fb0133so18519845ad.3 for ; Sun, 25 Feb 2024 20:09:28 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1708920568; x=1709525368; 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=7jRh4tMvuYcqr95qV4EQU7BolCnIgD6A0sDxFfSdHTU=; b=WSjrYg7lkRUQ4rOEfyKCFrQoE6RxLCV0b3V3Enjrr/50FDO4c/e1LtIdnFt6EMxAWI fzpfLFAwHxXyCg+TDslTDRE1Co07jDw8QM1Mm30xteY78AprJGEcSktmO5SogIInFveT M1kh63mRZqRgOffsZXZa0avQRmJj46eEHWOxpIvW2f0o+8Cb3RvnAK9tuKo23DcbCqyt ubeBslhszxtyHux43eKs8HTcpKTPAsWA49L4vlyq2nQfWakLUSDPvsWQ+F/QolKFycrs hB1KbNSRS3D4jhhymHaDXqv71OAMhYU5j+fBvAd/+o9GvbX7zBxOFVYPi6GDdmlhyfpl gelA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1708920568; x=1709525368; 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=7jRh4tMvuYcqr95qV4EQU7BolCnIgD6A0sDxFfSdHTU=; b=akcAAtLzBrmIOaeMGf71kSOYITNBsRLOYNgIRMw7aE7ku8c9SuqeYVKkXgqc4qsD2A 2UM9n/rExxDLXVfbFE6/6UQVvOmoImeFWYZG3IgU64kS0xUIqOj/dd6dc90KkD1bslEI kHMElSBHRALOZi8JdmrakTZUkGDh9jpyz4+pfvdo24TRILJ5yyrF2duWDpIK0SkFXBhE DHFItaiBhTHfBsNgjHAmeCWKw5KnZAmgRAbW/E937u2Rg7+n+sbL82UhaB15Pn0LYhAT Bwkt4E7vnqliFt94j8D9/bIab/RDBIDnqBVeknVIPO/xwkC+8CUqGT4q9gYXCskvLM12 XCcw== X-Forwarded-Encrypted: i=1; AJvYcCV2cxM/n10Czu4ZeXKNgUPiGdFUHt71YQt02JMFVaZf6hfeaXovk1UBmzbP8Ip4AecG+OFnP9OqNg5LhLU8xkLvPb6+VeZNUvfH2pAD X-Gm-Message-State: AOJu0Yyi28ntvZWVzKB1FZUjt0zNoUdEYL47P8uA9uwONMLe2DKsl/P3 Bhhm2SxrZ7Zg7aBWoLrCSr4qi48tIzCJlRH6A8JgrqqxmZrYw05Rqnd8dSYu65g= X-Received: by 2002:a17:902:e885:b0:1dc:a84c:987c with SMTP id w5-20020a170902e88500b001dca84c987cmr626941plg.10.1708920568219; Sun, 25 Feb 2024 20:09:28 -0800 (PST) Received: from localhost.localdomain ([171.76.86.62]) by smtp.gmail.com with ESMTPSA id d11-20020a170902654b00b001dc6f7e794dsm3023258pln.16.2024.02.25.20.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 20:09:27 -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?b?QmrDtnJuIFTDtnBlbA==?= , 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 v15 05/10] irqchip/riscv-imsic: Add device MSI domain support for PCI devices Date: Mon, 26 Feb 2024 09:37:41 +0530 Message-Id: <20240226040746.1396416-6-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240226040746.1396416-1-apatel@ventanamicro.com> References: <20240226040746.1396416-1-apatel@ventanamicro.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1791933294794413196 X-GMAIL-MSGID: 1791933294794413196 The Linux PCI framework supports per-device MSI domains for PCI devices so extend the IMSIC driver to allow PCI per-device MSI domains. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 +++++ drivers/irqchip/irq-riscv-imsic-platform.c | 35 ++++++++++++++++++++-- 2 files changed, 40 insertions(+), 2 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 85f86e31c996..2fc0cb32341a 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -553,6 +553,13 @@ config RISCV_IMSIC select GENERIC_IRQ_MATRIX_ALLOCATOR 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 35291bf90d65..1e6dddfd3046 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include #include @@ -207,6 +208,28 @@ static const struct irq_domain_ops imsic_base_domain_ops = { #endif }; +#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) +{ + irq_chip_unmask_parent(d); + pci_msi_unmask_irq(d); +} + +#define MATCH_PCI_MSI BIT(DOMAIN_BUS_PCI_MSI) + +#else + +#define MATCH_PCI_MSI 0 + +#endif + static bool imsic_init_dev_msi_info(struct device *dev, struct irq_domain *domain, struct irq_domain *real_parent, @@ -230,6 +253,13 @@ static bool imsic_init_dev_msi_info(struct device *dev, /* Is the target supported? */ switch (info->bus_token) { +#ifdef CONFIG_RISCV_IMSIC_PCI + case DOMAIN_BUS_PCI_DEVICE_MSI: + case DOMAIN_BUS_PCI_DEVICE_MSIX: + info->chip->irq_mask = imsic_pci_mask_irq; + info->chip->irq_unmask = imsic_pci_unmask_irq; + break; +#endif case DOMAIN_BUS_DEVICE_MSI: /* * Per-device MSI should never have any MSI feature bits @@ -269,11 +299,12 @@ static bool imsic_init_dev_msi_info(struct device *dev, #define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI) static const struct msi_parent_ops imsic_msi_parent_ops = { - .supported_flags = MSI_GENERIC_FLAGS_MASK, + .supported_flags = MSI_GENERIC_FLAGS_MASK | + MSI_FLAG_PCI_MSIX, .required_flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS, .bus_select_token = DOMAIN_BUS_NEXUS, - .bus_select_mask = MATCH_PLATFORM_MSI, + .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, .init_dev_msi_info = imsic_init_dev_msi_info, };