From patchwork Sun Dec 8 15:07:11 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anup Patel X-Patchwork-Id: 13898591 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 87A6EE7717F for ; Sun, 8 Dec 2024 15:12:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: MIME-Version:References:In-Reply-To:Message-ID:Date:Subject:Cc:To:From: Reply-To:Content-Type:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=i6SkVd/9C0tJE6hoWneK1VpsLs j2qyAMjDZzxMBDV/DxEcb2I3hIFNDb8yUrciQPk/KKu3zxVh2mZEIb7vK4uOA3U6Bbij0Mm+igOWR sOTwP0l1L1v9NNs2n1bF0I2gNhDTH9r7CkIXpqkqV0clLAGFi2XhQcre9aBIHFkiXJcW9Cvh7wauN mznc3Lv/LJ4GgnEhg5cHXY5d3iXrE+VuNTW/VZfvjPbpvobmq3Ys26TokWGry1x6tyB5hLyLbyzYu tdrodl/2H72syrmBGiAMLmsJl2+HGugnG183ixleh+7RQC/XoTnIiqnJXNEScB1DI7VS55aXpR7Pk XQyPywLg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98 #2 (Red Hat Linux)) id 1tKIxc-00000005RE7-1yfS; Sun, 08 Dec 2024 15:12:40 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by bombadil.infradead.org with esmtps (Exim 4.98 #2 (Red Hat Linux)) id 1tKIsr-00000005QB2-0MOi for linux-arm-kernel@lists.infradead.org; Sun, 08 Dec 2024 15:07:46 +0000 Received: by mail-pl1-x632.google.com with SMTP id d9443c01a7336-21631789fcdso4789245ad.1 for ; Sun, 08 Dec 2024 07:07:45 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ventanamicro.com; s=google; t=1733670464; x=1734275264; darn=lists.infradead.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=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=EPPFtzLD8JSxCjbTh6+4HzWvA1rayF2/wIPILxE+gLTLuygXHEB/ixak7e2rshrjqj hpflGdV2SZVH4yiQM74pIXen04uUewqpRliSDNWnW+SRC5vTegldFB9vMiziKEAdld70 jGYxLgECPcxzsqZ150zCDUOw2EFoNcuqgID+TAPX46+GeeBnraNzmTJt0G4RnvEgRhtS Kf4pV1btEc7wwpB5bbSSXvEGQTOqlNKFUPKx0SyoeSbVUcXMM3ylkcGYhZ9UJlwzHJXR BNy+kQnwfJfLDxPw3u77X6C2U3eU91TpYCn5oFTI7BPXcLGeUhQiMSJGW/KcMFAwi/78 DkDQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1733670464; x=1734275264; 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=20bETIAPAH9IUNDRRJ4w+seEOsz0uHbvsdHALnvxjtk=; b=UgWZeQufHgBqwYwfKicFZhT1nN6kXT4Rm44wO5Jify0jkAEVsjtLE7yT1uU3wg96hL u4nUJEVac9YxxBcawD2z2741S2hlx/d55Fr2l+B9X9GMl5EKLKMF4PCdoL597ZU/I+aw bKAr9NeyNydZf9/DZMHbG1Tk4dBEZAlnCXVWR+9pLUrPtmMUiqC/02o8YwqbXvh7DNxL Jjs6r9PJEKJLmeB5QsKUneFo2xUcQ3nMAVuVQtwR3VdFUYx1Fega8UPTdMzJY6sUJXgP 5iWS5fTydJb7edzccGqJ8ZZTJsJ8Akl9Zxa5113X594wD1hm5LvqDVqZxEqgwTFz38Dm O1AA== X-Forwarded-Encrypted: i=1; AJvYcCVif3n01XVSVhcdqCYvn3jNf4PudfLf+uD7IFoqvUMeNf32bDrJy8piEXBzenEySmhZ/HT1ImEMWOmk4xmTrIjq@lists.infradead.org X-Gm-Message-State: AOJu0Yy2+PwfdY5zcSe42NT6BFOXT4e0faV2kGGKSieiBo4spPkk1EzK 0vPnHDBzVWf0pPqzNpwebfCt/3qhY16Ks9v032KpEaz8vImQ2NbjRMfgKz/0/vI= X-Gm-Gg: ASbGnct1rNQINd7FHFgURGEoLnlzcLYbULNbxlG7sLZ4QNM+kOQQmgxh+h+yeJSms58 Yg1hrQT+Ru08VFE9NznNMKKqdEFDVYmWuHW0cJbnZL/sz9hYAL+HY38C8We/ugaFOxdZln4o5Ce j4oEel914PvTW4mgfHmqi377nStLk6R97vAJNIW2Q9fwzsjMPjlcSNG/Zhi7IW99nFDIU542RUl NrsNnZOY1hn7/WqRmLmwbmOm5fMBxmbFNBYnyOH3vpurIYMqDiHtqzrCPg8A0zz5Ezl8sZnCxH9 QeVVE+k9mvIBEnQ= X-Google-Smtp-Source: AGHT+IHR0mdD2VEjATAsegpj67+DjOHvUJ0NNqFfY3GS7J9zIfiIPyfQ/Az29m1dRZNe7ffz6IP15Q== X-Received: by 2002:a17:902:da8f:b0:215:8847:4377 with SMTP id d9443c01a7336-216112fb5e7mr156331235ad.15.1733670464396; Sun, 08 Dec 2024 07:07:44 -0800 (PST) Received: from anup-ubuntu-vm.localdomain ([223.185.130.223]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-216412293d2sm10274515ad.237.2024.12.08.07.07.39 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 08 Dec 2024 07:07:43 -0800 (PST) From: Anup Patel To: Thomas Gleixner Cc: Marc Zyngier , Shawn Guo , Sascha Hauer , Pengutronix Kernel Team , Andrew Lunn , Gregory Clement , Sebastian Hesselbarth , Palmer Dabbelt , Paul Walmsley , Atish Patra , Andrew Jones , Sunil V L , Anup Patel , linux-riscv@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, imx@lists.linux.dev, Anup Patel Subject: [PATCH 4/4] irqchip/riscv-imsic: Move to common MSI lib Date: Sun, 8 Dec 2024 20:37:11 +0530 Message-ID: <20241208150711.297624-5-apatel@ventanamicro.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20241208150711.297624-1-apatel@ventanamicro.com> References: <20241208150711.297624-1-apatel@ventanamicro.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20241208_070745_126624_0CADE0D7 X-CRM114-Status: GOOD ( 17.43 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org From: Thomas Gleixner Simplify the non-leaf MSI domain handling in the RISC-V IMSIC driver by using msi_lib_init_dev_msi_info() and msi_lib_irq_domain_select() provided by common MSI lib. Signed-off-by: Thomas Gleixner Signed-off-by: Andrew Jones Signed-off-by: Anup Patel --- drivers/irqchip/Kconfig | 8 +- drivers/irqchip/irq-riscv-imsic-platform.c | 114 +-------------------- 2 files changed, 6 insertions(+), 116 deletions(-) diff --git a/drivers/irqchip/Kconfig b/drivers/irqchip/Kconfig index 55d7122121e2..6b767b8c974f 100644 --- a/drivers/irqchip/Kconfig +++ b/drivers/irqchip/Kconfig @@ -587,13 +587,7 @@ config RISCV_IMSIC select IRQ_DOMAIN_HIERARCHY 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 + select IRQ_MSI_LIB config SIFIVE_PLIC bool diff --git a/drivers/irqchip/irq-riscv-imsic-platform.c b/drivers/irqchip/irq-riscv-imsic-platform.c index 33a8261e6017..5bc1f03cbacb 100644 --- a/drivers/irqchip/irq-riscv-imsic-platform.c +++ b/drivers/irqchip/irq-riscv-imsic-platform.c @@ -20,6 +20,7 @@ #include #include +#include "irq-msi-lib.h" #include "irq-riscv-imsic-state.h" static bool imsic_cpu_page_phys(unsigned int cpu, unsigned int guest_index, @@ -201,22 +202,6 @@ static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq, irq_domain_free_irqs_parent(domain, virq, nr_irqs); } -static int imsic_irq_domain_select(struct irq_domain *domain, struct irq_fwspec *fwspec, - enum irq_domain_bus_token bus_token) -{ - const struct msi_parent_ops *ops = domain->msi_parent_ops; - u32 busmask = BIT(bus_token); - - if (fwspec->fwnode != domain->fwnode || fwspec->param_count != 0) - return 0; - - /* Handle pure domain searches */ - if (bus_token == ops->bus_select_token) - return 1; - - return !!(ops->bus_select_mask & busmask); -} - #ifdef CONFIG_GENERIC_IRQ_DEBUGFS static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, struct irq_data *irqd, int ind) @@ -233,110 +218,21 @@ static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d, static const struct irq_domain_ops imsic_base_domain_ops = { .alloc = imsic_irq_domain_alloc, .free = imsic_irq_domain_free, - .select = imsic_irq_domain_select, + .select = msi_lib_irq_domain_select, #ifdef CONFIG_GENERIC_IRQ_DEBUGFS .debug_show = imsic_irq_debug_show, #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, - struct msi_domain_info *info) -{ - const struct msi_parent_ops *pops = real_parent->msi_parent_ops; - - /* MSI parent domain specific settings */ - switch (real_parent->bus_token) { - case DOMAIN_BUS_NEXUS: - if (WARN_ON_ONCE(domain != real_parent)) - return false; -#ifdef CONFIG_SMP - info->chip->irq_set_affinity = irq_chip_set_affinity_parent; -#endif - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* 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 - * set. It's sole purpose is to create a dumb interrupt - * chip which has a device specific irq_write_msi_msg() - * callback. - */ - if (WARN_ON_ONCE(info->flags)) - return false; - - /* Core managed MSI descriptors */ - info->flags |= MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | - MSI_FLAG_FREE_MSI_DESCS; - break; - case DOMAIN_BUS_WIRED_TO_MSI: - break; - default: - WARN_ON_ONCE(1); - return false; - } - - /* Use hierarchial chip operations re-trigger */ - info->chip->irq_retrigger = irq_chip_retrigger_hierarchy; - - /* - * Mask out the domain specific MSI feature flags which are not - * supported by the real parent. - */ - info->flags &= pops->supported_flags; - - /* Enforce the required flags */ - info->flags |= pops->required_flags; - - return true; -} - -#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 | MSI_FLAG_PCI_MSIX, .required_flags = MSI_FLAG_USE_DEF_DOM_OPS | - MSI_FLAG_USE_DEF_CHIP_OPS, + MSI_FLAG_USE_DEF_CHIP_OPS | + MSI_FLAG_PCI_MSI_MASK_PARENT, .bus_select_token = DOMAIN_BUS_NEXUS, .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI, - .init_dev_msi_info = imsic_init_dev_msi_info, + .init_dev_msi_info = msi_lib_init_dev_msi_info, }; int imsic_irqdomain_init(void)