Received: by 2002:a05:7208:9594:b0:7e:5202:c8b4 with SMTP id gs20csp1099820rbb; Sun, 25 Feb 2024 20:28:53 -0800 (PST) X-Forwarded-Encrypted: i=3; AJvYcCV/bwY4+XEju+bp0WEEU2As7YEbR7wpxoS9iwmH4EjzBeP1XGjBKiNuscfrbCB/ied5i/mhrfgSXdXAaLX6oR9omfM+LlwArrYS2tQbAg== X-Google-Smtp-Source: AGHT+IFv0qkwSZhZ17+BLsG/Ntsqjc8OFoOH7ooH3tU/PymZUVSbK/lJa5BGbaYtqPImMztT4MpC X-Received: by 2002:a05:6a21:3949:b0:1a0:e839:abf with SMTP id ac9-20020a056a21394900b001a0e8390abfmr5487857pzc.44.1708921733533; Sun, 25 Feb 2024 20:28:53 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1708921733; cv=pass; d=google.com; s=arc-20160816; b=TOJ/IQNgCVs2QSWwepKhiDkM0qvn/usD3fNbRq867PWxJ4W9F3wFIb8jGMrkM42QEq 2BFLu7mhF/VIGmojBvqpZiq4XS9XcZIwH1oMWEVuJO69dIzh/twaiMfUmUZxsHDfFNst tb4hKCTpLSfsduQWvwZn0I5dnSIGedWIhaxSJWtMQc8inPBQTMTT65CLzFiLD5hhKIoI HZ6BACuJLnL57Yq+jqusygCZ6nSJwzC0TbyuKs/68uUY3+dVZcEezOAGVy2wXodFgx9J QHeQWR6FQEjG8ZoaMXA3FZ7UwmVwP0wX6c3N9UgNh+Ot4AQm6IN5IDUQ5F8866DEIdyV DV0w== 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80534-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id h9-20020a170902680900b001db594c55b6si3022555plk.51.2024.02.25.20.28.53 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 25 Feb 2024 20:28:53 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-80534-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; 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-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-80534-linux.lists.archive=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 379CCB2507E for ; Mon, 26 Feb 2024 04:10:47 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 1D9051BC35; Mon, 26 Feb 2024 04:09:32 +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?q?Bj=C3=B6rn=20T=C3=B6pel?= , 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 Content-Transfer-Encoding: 8bit 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, }; -- 2.34.1