Received: by 2002:a05:7412:9c07:b0:fa:6e18:a558 with SMTP id lr7csp335616rdb; Sat, 27 Jan 2024 08:24:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IFMi+2dPhwST/tFGVved4njQUiGNoBtSAaDSTneXJ2rYQKepNpNPKSaFK6ewnWpnCjNF9Za X-Received: by 2002:a05:6a00:80b:b0:6db:d223:1178 with SMTP id m11-20020a056a00080b00b006dbd2231178mr3539103pfk.2.1706372666561; Sat, 27 Jan 2024 08:24:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1706372666; cv=pass; d=google.com; s=arc-20160816; b=yaK4BXOAExzLjtVnTucMUrpTDAvwRfS3PPT8PMqIeG2Af6qdMDg4MvFl9DfsxeHMDR Y8BBWqyBoFuAtxzJB+s1bnUAFULBxKhV0x74fT2STWan+TPQreH/lJ0FxSOY+9YFycGY nCf4u9hhrYwXa77Bsx1qjidHWC4vbJavREAGbGB732YzrCi6vzQX6LwSL6YdCjAGUIPo 9cX23MAlKDDHk+sNwh62AZboQMfKxiHDbMtqvDgwCqg6ZYhz/nBXVw4uKQISgT1kSVi6 2C07oGerrblsA9kEf40DkT6bblhEb8dZuAvwtTWjMogYGWUQterIvxpsoQ8P87syTARR E+yw== 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=VWyTlHThOIP2PmYrOkTqrnYOBnpBzPmOIxliRiyO7gY=; fh=706cnY5t7hpwBXQypCTGH3HYLPe+/lcVAB5kbpxvl24=; b=Q04bu2EIv0zMBwdVJ2oPe5kV9Qh/3ECeLV3sGjwPqOIMK8PSjY0m52elPE3UsVfi7q tWhQPf8csjdTsIhnFw3GaplLTXyCha5xrafmi+lMO7aUJK60N03CoPt2qrb9iGfFAm+R nw8s9pE/72XtfQ950DHb0x9byMHiMHbbyhC5iS+4RAekL3mb+6Th4kAJFUle0dNUFvaE 1xICQxQeomC903mCnTsYviKRS7UIANyGyQYgy7dEpcD5bcVtzjPpEvd/CLb3sYb/qk// 3Ga5bAWOwI4ncpRsRlLmJt7Ds1x2XKJ5jUD+W8N/g6vWlpiJ9tzNZqcuotu7ORj5u/tW alxA== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@ventanamicro.com header.s=google header.b=ipfksZdH; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41294-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41294-linux.lists.archive=gmail.com@vger.kernel.org" Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id le10-20020a056a004fca00b006ddd0b1c391si3021703pfb.364.2024.01.27.08.24.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:24:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-41294-linux.lists.archive=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=ipfksZdH; arc=pass (i=1 spf=pass spfdomain=ventanamicro.com dkim=pass dkdomain=ventanamicro.com); spf=pass (google.com: domain of linux-kernel+bounces-41294-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-41294-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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 356A728308B for ; Sat, 27 Jan 2024 16:24:26 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 29CD22C6B4; Sat, 27 Jan 2024 16:20:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ventanamicro.com header.i=@ventanamicro.com header.b="ipfksZdH" Received: from mail-pg1-f177.google.com (mail-pg1-f177.google.com [209.85.215.177]) (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 C8BBD2E827 for ; Sat, 27 Jan 2024 16:20:12 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.215.177 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372414; cv=none; b=AEuHLYbmLRV7w9C8AGE2krVZ7D7KQXJhOzlb9FXu2hlYalo6QvALQ2W1tfjtpXGfzFWvfeEEc8k7KVRb7NMiGL53C1NFF1jKvLYc6ub1hvXtlHVi4kVSwhEvG/M5FHV7NVKeLV8N7JKOZ+5WT1Qw+BbFderNlukSZgjWcdyfjBI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706372414; c=relaxed/simple; bh=UqlJj0IR1+RS9SlqlFzG9aXPcDUbmBNLb5E1jNbJsB0=; h=From:To:Cc:Subject:Date:Message-Id:In-Reply-To:References: MIME-Version; b=OrDHAZNAMGG9PnjovMnywxavuXVVl76PNqfCaLNYaVAAQAJgd6Jb4LcByC3D3IlD6U34Bfmjl4hOJ2cAmh3veNG4He5/DFy+AVBDlv/AR/TptKYiY0XSsE5Wt0C2kWvXNugAIXcGyWsr3ztt70Fjy2mvBo0vPbzQkSyNO/tvg5c= 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=ipfksZdH; arc=none smtp.client-ip=209.85.215.177 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-pg1-f177.google.com with SMTP id 41be03b00d2f7-5cf2d73a183so1980210a12.1 for ; Sat, 27 Jan 2024 08:20:12 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1706372412; x=1706977212; 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=VWyTlHThOIP2PmYrOkTqrnYOBnpBzPmOIxliRiyO7gY=; b=ipfksZdHfi8smu7kIuPtJaz/f+U9EGLX07VMiRJ6l47ION5B60VAYEZh2gLTB+K5dq p9+pVZy+802NoREFOV+BHZEsiaWq4EVvaAzIgNtzYVrzGqsNjNBXmCRGkGw7HN1d4Ja0 D1ahoHhcxZp9B+B7a1QglcspUgQJkGI95cNh/0GwvAcHWszcCfLu8VSjDogmc5mGdNCv 0c1zTzSUPyemwdalYb6yd1i3oAgpk7HcAnpQTk2rCL3THawz3PhPvynjzeiRa9uOiLMP xn8vtBIOfUGB6epWrEV+QqKtis9bNasF9iufVQYhgfmkBZ7s7cfWe4G581lJEfI1GMyL nGMQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706372412; x=1706977212; 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=VWyTlHThOIP2PmYrOkTqrnYOBnpBzPmOIxliRiyO7gY=; b=nKiIWakS0akfRoMxTEww+H6XCghPBgBpEipzD2Hgi/ZWhRDMwzn4KMnFJsz5EMyC7E pPOLz+EVNiTaiZmKbR1eUVEzCQzLlWADvpSTfz+vYlXstACNjuqWYCFfbI/xcAu8Qgsw 551GIwz2HhdBdLwpYP6wCE5GET1XZMXNP9meQWByLPttCFfQuJ+HJK8y7uiFkcqg/55Z krO22AB2Am334+iZ4hAtXOWIF5Ru9H3LKVNNbom+0IXH72us9SnkGDMYT56cr8merfpm 7v5e3fERR/EF+It2tDKocGwVC6RAidw8ng3Yq3wRJKHlYjTeufFoJhVbhJ3Yu+9YBXr8 7XrQ== X-Gm-Message-State: AOJu0YxlL4JHxWUFYfZopJUJV7+5AutuUYOV23eZTNCxlop52dNE/mic GhZjJAlzn9ERsltLkUaQesK8iVnsz7pQfnivwYxvJmjcGS/ktm6P8PGbmtoV0Pk= X-Received: by 2002:a17:90a:d48a:b0:28e:8e78:8ba6 with SMTP id s10-20020a17090ad48a00b0028e8e788ba6mr1902639pju.43.1706372412102; Sat, 27 Jan 2024 08:20:12 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([171.76.86.17]) by smtp.gmail.com with ESMTPSA id d11-20020a17090ac24b00b00290f8c708d0sm5091620pjx.57.2024.01.27.08.20.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 27 Jan 2024 08:20:11 -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 v12 20/25] irqchip/riscv-imsic: Add device MSI domain support for PCI devices Date: Sat, 27 Jan 2024 21:47:48 +0530 Message-Id: <20240127161753.114685-21-apatel@ventanamicro.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240127161753.114685-1-apatel@ventanamicro.com> References: <20240127161753.114685-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 let us extend the IMSIC driver to allow per-device MSI domains for PCI devices. Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 7 +++++ drivers/irqchip/irq-riscv-imsic-platform.c | 36 ++++++++++++++++++++-- 2 files changed, 41 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 65791a6b0727..d78c93e2cf2b 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 @@ -233,6 +234,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) +{ + pci_msi_unmask_irq(d); + irq_chip_unmask_parent(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, @@ -242,6 +265,7 @@ static bool imsic_init_dev_msi_info(struct device *dev, /* MSI parent domain specific settings */ switch (real_parent->bus_token) { + case DOMAIN_BUS_PCI_MSI: case DOMAIN_BUS_NEXUS: if (WARN_ON_ONCE(domain != real_parent)) return false; @@ -256,6 +280,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_IMS: /* * Per device IMS should never have any MSI feature bits @@ -295,11 +326,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