* [PATCH 0/1] x86/hyperv: MSI parent domain conversion @ 2025-06-26 14:47 Nam Cao 2025-06-26 14:47 ` [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() Nam Cao 0 siblings, 1 reply; 4+ messages in thread From: Nam Cao @ 2025-06-26 14:47 UTC (permalink / raw) To: K . Y . Srinivasan, Marc Zyngier, Haiyang Zhang, Wei Liu, Dexuan Cui, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, linux-hyperv, linux-kernel Cc: Nam Cao The initial implementation of PCI/MSI interrupt domains in the hierarchical interrupt domain model used a shortcut by providing a global PCI/MSI domain. This works because the PCI/MSI[X] hardware is standardized and uniform, but it violates the basic design principle of hierarchical interrupt domains: Each hardware block involved in the interrupt delivery chain should have a separate interrupt domain. For PCI/MSI[X], the interrupt controller is per PCI device and not a global made-up entity. Unsurprisingly, the shortcut turned out to have downsides as it does not allow dynamic allocation of interrupt vectors after initialization and it prevents supporting IMS on PCI. For further details, see: https://lore.kernel.org/lkml/20221111120501.026511281@linutronix.de/ The solution is implementing per device MSI domains, this means the entities which provide global PCI/MSI domain so far have to implement MSI parent domain functionality instead. This series converts the x86 hyperv driver to implement MSI parent domain. arch/x86/hyperv/irqdomain.c | 107 ++++++++++++++++++++++++------------ drivers/hv/Kconfig | 1 + 2 files changed, 73 insertions(+), 35 deletions(-) -- 2.39.5 ^ permalink raw reply [flat|nested] 4+ messages in thread
* [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() 2025-06-26 14:47 [PATCH 0/1] x86/hyperv: MSI parent domain conversion Nam Cao @ 2025-06-26 14:47 ` Nam Cao 2025-06-27 21:03 ` kernel test robot 2025-06-28 15:18 ` kernel test robot 0 siblings, 2 replies; 4+ messages in thread From: Nam Cao @ 2025-06-26 14:47 UTC (permalink / raw) To: K . Y . Srinivasan, Marc Zyngier, Haiyang Zhang, Wei Liu, Dexuan Cui, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, linux-hyperv, linux-kernel Cc: Nam Cao Move away from the legacy MSI domain setup, switch to use msi_create_parent_irq_domain(). Signed-off-by: Nam Cao <namcao@linutronix.de> --- arch/x86/hyperv/irqdomain.c | 107 ++++++++++++++++++++++++------------ drivers/hv/Kconfig | 1 + 2 files changed, 73 insertions(+), 35 deletions(-) diff --git a/arch/x86/hyperv/irqdomain.c b/arch/x86/hyperv/irqdomain.c index 31f0d29cbc5e3..924400c31d368 100644 --- a/arch/x86/hyperv/irqdomain.c +++ b/arch/x86/hyperv/irqdomain.c @@ -10,6 +10,7 @@ #include <linux/pci.h> #include <linux/irq.h> +#include <linux/irqchip/irq-msi-lib.h> #include <asm/mshyperv.h> static int hv_map_interrupt(union hv_device_id device_id, bool level, @@ -276,59 +277,95 @@ static void hv_teardown_msi_irq(struct pci_dev *dev, struct irq_data *irqd) hv_status_err(status, "\n"); } -static void hv_msi_free_irq(struct irq_domain *domain, - struct msi_domain_info *info, unsigned int virq) -{ - struct irq_data *irqd = irq_get_irq_data(virq); - struct msi_desc *desc; - - if (!irqd) - return; - - desc = irq_data_get_msi_desc(irqd); - if (!desc || !desc->irq || WARN_ON_ONCE(!dev_is_pci(desc->dev))) - return; - - hv_teardown_msi_irq(to_pci_dev(desc->dev), irqd); -} - /* * IRQ Chip for MSI PCI/PCI-X/PCI-Express Devices, * which implement the MSI or MSI-X Capability Structure. */ static struct irq_chip hv_pci_msi_controller = { .name = "HV-PCI-MSI", - .irq_unmask = pci_msi_unmask_irq, - .irq_mask = pci_msi_mask_irq, .irq_ack = irq_chip_ack_parent, - .irq_retrigger = irq_chip_retrigger_hierarchy, .irq_compose_msi_msg = hv_irq_compose_msi_msg, - .irq_set_affinity = msi_domain_set_affinity, - .flags = IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MOVE_DEFERRED, + .irq_set_affinity = irq_chip_set_affinity_parent, }; -static struct msi_domain_ops pci_msi_domain_ops = { - .msi_free = hv_msi_free_irq, - .msi_prepare = pci_msi_prepare, +static bool hv_init_dev_msi_info(struct device *dev, struct irq_domain *domain, + struct irq_domain *real_parent, struct msi_domain_info *info) +{ + struct irq_chip *chip = info->chip; + + if (!msi_lib_init_dev_msi_info(dev, domain, real_parent, info)) + return false; + + chip->flags |= IRQCHIP_SKIP_SET_WAKE | IRQCHIP_MOVE_DEFERRED; + + info->ops->msi_prepare = pci_msi_prepare; + + return true; +} + +#define HV_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | MSI_FLAG_PCI_MSIX) +#define HV_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS) + +static struct msi_parent_ops hv_msi_parent_ops = { + .supported_flags = HV_MSI_FLAGS_SUPPORTED, + .required_flags = HV_MSI_FLAGS_REQUIRED, + .bus_select_token = DOMAIN_BUS_NEXUS, + .bus_select_mask = MATCH_PCI_MSI, + .chip_flags = MSI_CHIP_FLAG_SET_ACK, + .prefix = "HV-", + .init_dev_msi_info = hv_init_dev_msi_info, }; -static struct msi_domain_info hv_pci_msi_domain_info = { - .flags = MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS | - MSI_FLAG_PCI_MSIX, - .ops = &pci_msi_domain_ops, - .chip = &hv_pci_msi_controller, - .handler = handle_edge_irq, - .handler_name = "edge", +static int hv_msi_domain_alloc(struct irq_domain *d, unsigned int virq, unsigned int nr_irqs, + void *arg) +{ + /* TODO: move the content of hv_irq_compose_msi_msg() in here */ + int ret; + + ret = irq_domain_alloc_irqs_parent(d, virq, nr_irqs, arg); + if (ret) + return ret; + + for (int i = 0; i < nr_irqs; ++i) { + irq_domain_set_info(d, virq + i, 0, &hv_pci_msi_controller, NULL, + handle_edge_irq, NULL, "edge"); + } + return 0; +} + +static void hv_msi_domain_free(struct irq_domain *d, unsigned int virq, unsigned int nr_irqs) +{ + for (int i = 0; i < nr_irqs; ++i) { + struct irq_data *irqd = irq_domain_get_irq_data(d, virq); + struct msi_desc *desc; + + desc = irq_data_get_msi_desc(irqd); + if (!desc || !desc->irq || WARN_ON_ONCE(!dev_is_pci(desc->dev))) + continue; + + hv_teardown_msi_irq(to_pci_dev(desc->dev), irqd); + } + irq_domain_free_irqs_top(d, virq, nr_irqs); +} + +static const struct irq_domain_ops hv_msi_domain_ops = { + .select = msi_lib_irq_domain_select, + .alloc = hv_msi_domain_alloc, + .free = hv_msi_domain_free, }; struct irq_domain * __init hv_create_pci_msi_domain(void) { struct irq_domain *d = NULL; - struct fwnode_handle *fn; - fn = irq_domain_alloc_named_fwnode("HV-PCI-MSI"); - if (fn) - d = pci_msi_create_irq_domain(fn, &hv_pci_msi_domain_info, x86_vector_domain); + struct irq_domain_info info = { + .fwnode = irq_domain_alloc_named_fwnode("HV-PCI-MSI"), + .ops = &hv_msi_domain_ops, + .parent = x86_vector_domain, + }; + + if (info.fwnode) + d = msi_create_parent_irq_domain(&info, &hv_msi_parent_ops); /* No point in going further if we can't get an irq domain */ BUG_ON(!d); diff --git a/drivers/hv/Kconfig b/drivers/hv/Kconfig index 1cd188b73b743..e62a0f8b34198 100644 --- a/drivers/hv/Kconfig +++ b/drivers/hv/Kconfig @@ -10,6 +10,7 @@ config HYPERV select X86_HV_CALLBACK_VECTOR if X86 select OF_EARLY_FLATTREE if OF select SYSFB if !HYPERV_VTL_MODE + select IRQ_MSI_LIB if X86 help Select this option to run Linux as a Hyper-V client operating system. -- 2.39.5 ^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() 2025-06-26 14:47 ` [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() Nam Cao @ 2025-06-27 21:03 ` kernel test robot 2025-06-28 15:18 ` kernel test robot 1 sibling, 0 replies; 4+ messages in thread From: kernel test robot @ 2025-06-27 21:03 UTC (permalink / raw) To: Nam Cao, K . Y . Srinivasan, Marc Zyngier, Haiyang Zhang, Wei Liu, Dexuan Cui, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, linux-hyperv, linux-kernel Cc: oe-kbuild-all, Nam Cao Hi Nam, kernel test robot noticed the following build errors: [auto build test ERROR on tip/master] [also build test ERROR on linus/master v6.16-rc3 next-20250627] [cannot apply to tip/x86/core tip/auto-latest] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Nam-Cao/x86-hyperv-Switch-to-msi_create_parent_irq_domain/20250626-225420 base: tip/master patch link: https://lore.kernel.org/r/0eafade05acb51022242635750cd4990f3adb0ac.1750947640.git.namcao%40linutronix.de patch subject: [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() config: i386-randconfig-014-20250628 (https://download.01.org/0day-ci/archive/20250628/202506280404.eZJ6vN93-lkp@intel.com/config) compiler: gcc-12 (Debian 12.2.0-14+deb12u1) 12.2.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250628/202506280404.eZJ6vN93-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506280404.eZJ6vN93-lkp@intel.com/ All error/warnings (new ones prefixed by >>): In file included from drivers/irqchip/irq-msi-lib.c:7: >> include/linux/irqchip/irq-msi-lib.h:25:39: warning: 'struct msi_domain_info' declared inside parameter list will not be visible outside of this definition or declaration 25 | struct msi_domain_info *info); | ^~~~~~~~~~~~~~~ >> drivers/irqchip/irq-msi-lib.c:28:39: warning: 'struct msi_domain_info' declared inside parameter list will not be visible outside of this definition or declaration 28 | struct msi_domain_info *info) | ^~~~~~~~~~~~~~~ >> drivers/irqchip/irq-msi-lib.c:26:6: error: conflicting types for 'msi_lib_init_dev_msi_info'; have 'bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)' {aka '_Bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)'} 26 | bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/irqchip/irq-msi-lib.h:23:6: note: previous declaration of 'msi_lib_init_dev_msi_info' with type 'bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)' {aka '_Bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)'} 23 | bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c: In function 'msi_lib_init_dev_msi_info': >> drivers/irqchip/irq-msi-lib.c:30:56: error: 'struct irq_domain' has no member named 'msi_parent_ops' 30 | const struct msi_parent_ops *pops = real_parent->msi_parent_ops; | ^~ >> drivers/irqchip/irq-msi-lib.c:31:37: error: invalid use of undefined type 'struct msi_domain_info' 31 | struct irq_chip *chip = info->chip; | ^~ >> drivers/irqchip/irq-msi-lib.c:43:38: error: invalid use of undefined type 'const struct msi_parent_ops' 43 | if (domain->bus_token == pops->bus_select_token) { | ^~ drivers/irqchip/irq-msi-lib.c:51:30: error: invalid use of undefined type 'const struct msi_parent_ops' 51 | required_flags = pops->required_flags; | ^~ drivers/irqchip/irq-msi-lib.c:54:20: error: invalid use of undefined type 'struct msi_domain_info' 54 | switch(info->bus_token) { | ^~ In file included from arch/x86/include/asm/bug.h:103, from arch/x86/include/asm/alternative.h:9, from arch/x86/include/asm/barrier.h:5, from include/asm-generic/bitops/generic-non-atomic.h:7, from include/linux/bitops.h:28, from include/linux/of.h:15, from include/linux/irqdomain.h:14, from include/linux/irqchip/irq-msi-lib.h:9: drivers/irqchip/irq-msi-lib.c:68:38: error: invalid use of undefined type 'struct msi_domain_info' 68 | if (WARN_ON_ONCE(info->flags)) | ^~ include/asm-generic/bug.h:117:32: note: in definition of macro 'WARN_ON_ONCE' 117 | int __ret_warn_on = !!(condition); \ | ^~~~~~~~~ drivers/irqchip/irq-msi-lib.c:72:21: error: invalid use of undefined type 'struct msi_domain_info' 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ^~ >> drivers/irqchip/irq-msi-lib.c:72:31: error: 'MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS' undeclared (first use in this function) 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c:72:31: note: each undeclared identifier is reported only once for each function it appears in >> drivers/irqchip/irq-msi-lib.c:72:65: error: 'MSI_FLAG_FREE_MSI_DESCS' undeclared (first use in this function) 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ^~~~~~~~~~~~~~~~~~~~~~~ >> drivers/irqchip/irq-msi-lib.c:76:36: error: 'MSI_FLAG_PCI_MSI_MASK_PARENT' undeclared (first use in this function) 76 | required_flags &= ~MSI_FLAG_PCI_MSI_MASK_PARENT; | ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c:91:13: error: invalid use of undefined type 'struct msi_domain_info' 91 | info->flags &= pops->supported_flags; | ^~ drivers/irqchip/irq-msi-lib.c:91:48: error: invalid use of undefined type 'const struct msi_parent_ops' 91 | info->flags &= pops->supported_flags; | ^~ drivers/irqchip/irq-msi-lib.c:93:13: error: invalid use of undefined type 'struct msi_domain_info' 93 | info->flags |= required_flags; | ^~ drivers/irqchip/irq-msi-lib.c:96:36: error: invalid use of undefined type 'const struct msi_parent_ops' 96 | if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) | ^~ >> drivers/irqchip/irq-msi-lib.c:96:51: error: 'MSI_CHIP_FLAG_SET_EOI' undeclared (first use in this function) 96 | if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c:98:36: error: invalid use of undefined type 'const struct msi_parent_ops' 98 | if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) | ^~ >> drivers/irqchip/irq-msi-lib.c:98:51: error: 'MSI_CHIP_FLAG_SET_ACK' undeclared (first use in this function) 98 | if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) | ^~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c:113:46: error: invalid use of undefined type 'struct msi_domain_info' 113 | if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY)) | ^~ >> drivers/irqchip/irq-msi-lib.c:113:56: error: 'MSI_FLAG_NO_AFFINITY' undeclared (first use in this function) 113 | if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY)) | ^~~~~~~~~~~~~~~~~~~~ >> drivers/irqchip/irq-msi-lib.c:114:42: error: 'msi_domain_set_affinity' undeclared (first use in this function); did you mean 'msi_domain_get_virq'? 114 | chip->irq_set_affinity = msi_domain_set_affinity; | ^~~~~~~~~~~~~~~~~~~~~~~ | msi_domain_get_virq In file included from drivers/irqchip/irq-msi-lib.c:5: drivers/irqchip/irq-msi-lib.c: At top level: drivers/irqchip/irq-msi-lib.c:117:19: error: conflicting types for 'msi_lib_init_dev_msi_info'; have 'bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)' {aka '_Bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)'} 117 | EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); | ^~~~~~~~~~~~~~~~~~~~~~~~~ include/linux/export.h:76:28: note: in definition of macro '__EXPORT_SYMBOL' 76 | extern typeof(sym) sym; \ | ^~~ include/linux/export.h:90:41: note: in expansion of macro '_EXPORT_SYMBOL' 90 | #define EXPORT_SYMBOL_GPL(sym) _EXPORT_SYMBOL(sym, "GPL") | ^~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c:117:1: note: in expansion of macro 'EXPORT_SYMBOL_GPL' 117 | EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); | ^~~~~~~~~~~~~~~~~ include/linux/irqchip/irq-msi-lib.h:23:6: note: previous declaration of 'msi_lib_init_dev_msi_info' with type 'bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)' {aka '_Bool(struct device *, struct irq_domain *, struct irq_domain *, struct msi_domain_info *)'} 23 | bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, | ^~~~~~~~~~~~~~~~~~~~~~~~~ drivers/irqchip/irq-msi-lib.c: In function 'msi_lib_irq_domain_select': drivers/irqchip/irq-msi-lib.c:134:45: error: 'struct irq_domain' has no member named 'msi_parent_ops' 134 | const struct msi_parent_ops *ops = d->msi_parent_ops; | ^~ drivers/irqchip/irq-msi-lib.c:144:29: error: invalid use of undefined type 'const struct msi_parent_ops' 144 | if (bus_token == ops->bus_select_token) | ^~ drivers/irqchip/irq-msi-lib.c:147:22: error: invalid use of undefined type 'const struct msi_parent_ops' 147 | return !!(ops->bus_select_mask & busmask); | ^~ >> drivers/irqchip/irq-msi-lib.c:148:1: warning: control reaches end of non-void function [-Wreturn-type] 148 | } | ^ vim +26 drivers/irqchip/irq-msi-lib.c 72e257c6f05803 Thomas Gleixner 2024-06-23 8 72e257c6f05803 Thomas Gleixner 2024-06-23 9 /** 72e257c6f05803 Thomas Gleixner 2024-06-23 10 * msi_lib_init_dev_msi_info - Domain info setup for MSI domains 72e257c6f05803 Thomas Gleixner 2024-06-23 11 * @dev: The device for which the domain is created for 72e257c6f05803 Thomas Gleixner 2024-06-23 12 * @domain: The domain providing this callback 72e257c6f05803 Thomas Gleixner 2024-06-23 13 * @real_parent: The real parent domain of the domain to be initialized 72e257c6f05803 Thomas Gleixner 2024-06-23 14 * which might be a domain built on top of @domain or 72e257c6f05803 Thomas Gleixner 2024-06-23 15 * @domain itself 72e257c6f05803 Thomas Gleixner 2024-06-23 16 * @info: The domain info for the domain to be initialize 72e257c6f05803 Thomas Gleixner 2024-06-23 17 * 72e257c6f05803 Thomas Gleixner 2024-06-23 18 * This function is to be used for all types of MSI domains above the root 72e257c6f05803 Thomas Gleixner 2024-06-23 19 * parent domain and any intermediates. The topmost parent domain specific 72e257c6f05803 Thomas Gleixner 2024-06-23 20 * functionality is determined via @real_parent. 72e257c6f05803 Thomas Gleixner 2024-06-23 21 * 72e257c6f05803 Thomas Gleixner 2024-06-23 22 * All intermediate domains between the root and the device domain must 72e257c6f05803 Thomas Gleixner 2024-06-23 23 * have either msi_parent_ops.init_dev_msi_info = msi_parent_init_dev_msi_info 72e257c6f05803 Thomas Gleixner 2024-06-23 24 * or invoke it down the line. 72e257c6f05803 Thomas Gleixner 2024-06-23 25 */ 72e257c6f05803 Thomas Gleixner 2024-06-23 @26 bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, 72e257c6f05803 Thomas Gleixner 2024-06-23 27 struct irq_domain *real_parent, 72e257c6f05803 Thomas Gleixner 2024-06-23 @28 struct msi_domain_info *info) 72e257c6f05803 Thomas Gleixner 2024-06-23 29 { 72e257c6f05803 Thomas Gleixner 2024-06-23 @30 const struct msi_parent_ops *pops = real_parent->msi_parent_ops; 1c000dcaad2bef Thomas Gleixner 2025-02-17 @31 struct irq_chip *chip = info->chip; 8c41ccec839c62 Thomas Gleixner 2024-06-23 32 u32 required_flags; 72e257c6f05803 Thomas Gleixner 2024-06-23 33 72e257c6f05803 Thomas Gleixner 2024-06-23 34 /* Parent ops available? */ 72e257c6f05803 Thomas Gleixner 2024-06-23 35 if (WARN_ON_ONCE(!pops)) 72e257c6f05803 Thomas Gleixner 2024-06-23 36 return false; 72e257c6f05803 Thomas Gleixner 2024-06-23 37 72e257c6f05803 Thomas Gleixner 2024-06-23 38 /* 72e257c6f05803 Thomas Gleixner 2024-06-23 39 * MSI parent domain specific settings. For now there is only the 72e257c6f05803 Thomas Gleixner 2024-06-23 40 * root parent domain, e.g. NEXUS, acting as a MSI parent, but it is 72e257c6f05803 Thomas Gleixner 2024-06-23 41 * possible to stack MSI parents. See x86 vector -> irq remapping 72e257c6f05803 Thomas Gleixner 2024-06-23 42 */ 72e257c6f05803 Thomas Gleixner 2024-06-23 @43 if (domain->bus_token == pops->bus_select_token) { 72e257c6f05803 Thomas Gleixner 2024-06-23 44 if (WARN_ON_ONCE(domain != real_parent)) 72e257c6f05803 Thomas Gleixner 2024-06-23 45 return false; 72e257c6f05803 Thomas Gleixner 2024-06-23 46 } else { 72e257c6f05803 Thomas Gleixner 2024-06-23 47 WARN_ON_ONCE(1); 72e257c6f05803 Thomas Gleixner 2024-06-23 48 return false; 72e257c6f05803 Thomas Gleixner 2024-06-23 49 } 72e257c6f05803 Thomas Gleixner 2024-06-23 50 8c41ccec839c62 Thomas Gleixner 2024-06-23 51 required_flags = pops->required_flags; 8c41ccec839c62 Thomas Gleixner 2024-06-23 52 72e257c6f05803 Thomas Gleixner 2024-06-23 53 /* Is the target domain bus token supported? */ 72e257c6f05803 Thomas Gleixner 2024-06-23 54 switch(info->bus_token) { 8c41ccec839c62 Thomas Gleixner 2024-06-23 55 case DOMAIN_BUS_PCI_DEVICE_MSI: 8c41ccec839c62 Thomas Gleixner 2024-06-23 56 case DOMAIN_BUS_PCI_DEVICE_MSIX: 8c41ccec839c62 Thomas Gleixner 2024-06-23 57 if (WARN_ON_ONCE(!IS_ENABLED(CONFIG_PCI_MSI))) 8c41ccec839c62 Thomas Gleixner 2024-06-23 58 return false; 8c41ccec839c62 Thomas Gleixner 2024-06-23 59 496436f4a514a3 Thomas Gleixner 2024-06-23 60 break; 496436f4a514a3 Thomas Gleixner 2024-06-23 61 case DOMAIN_BUS_DEVICE_MSI: 496436f4a514a3 Thomas Gleixner 2024-06-23 62 /* 496436f4a514a3 Thomas Gleixner 2024-06-23 63 * Per device MSI should never have any MSI feature bits 496436f4a514a3 Thomas Gleixner 2024-06-23 64 * set. It's sole purpose is to create a dumb interrupt 496436f4a514a3 Thomas Gleixner 2024-06-23 65 * chip which has a device specific irq_write_msi_msg() 496436f4a514a3 Thomas Gleixner 2024-06-23 66 * callback. 496436f4a514a3 Thomas Gleixner 2024-06-23 67 */ 496436f4a514a3 Thomas Gleixner 2024-06-23 68 if (WARN_ON_ONCE(info->flags)) 496436f4a514a3 Thomas Gleixner 2024-06-23 69 return false; 496436f4a514a3 Thomas Gleixner 2024-06-23 70 496436f4a514a3 Thomas Gleixner 2024-06-23 71 /* Core managed MSI descriptors */ 496436f4a514a3 Thomas Gleixner 2024-06-23 @72 info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; 64a855324311dd Thomas Gleixner 2024-06-23 73 fallthrough; 64a855324311dd Thomas Gleixner 2024-06-23 74 case DOMAIN_BUS_WIRED_TO_MSI: 496436f4a514a3 Thomas Gleixner 2024-06-23 75 /* Remove PCI specific flags */ 496436f4a514a3 Thomas Gleixner 2024-06-23 @76 required_flags &= ~MSI_FLAG_PCI_MSI_MASK_PARENT; 8c41ccec839c62 Thomas Gleixner 2024-06-23 77 break; 72e257c6f05803 Thomas Gleixner 2024-06-23 78 default: 72e257c6f05803 Thomas Gleixner 2024-06-23 79 /* 72e257c6f05803 Thomas Gleixner 2024-06-23 80 * This should never be reached. See 72e257c6f05803 Thomas Gleixner 2024-06-23 81 * msi_lib_irq_domain_select() 72e257c6f05803 Thomas Gleixner 2024-06-23 82 */ 72e257c6f05803 Thomas Gleixner 2024-06-23 83 WARN_ON_ONCE(1); 72e257c6f05803 Thomas Gleixner 2024-06-23 84 return false; 72e257c6f05803 Thomas Gleixner 2024-06-23 85 } 72e257c6f05803 Thomas Gleixner 2024-06-23 86 72e257c6f05803 Thomas Gleixner 2024-06-23 87 /* 72e257c6f05803 Thomas Gleixner 2024-06-23 88 * Mask out the domain specific MSI feature flags which are not 72e257c6f05803 Thomas Gleixner 2024-06-23 89 * supported by the real parent. 72e257c6f05803 Thomas Gleixner 2024-06-23 90 */ 72e257c6f05803 Thomas Gleixner 2024-06-23 91 info->flags &= pops->supported_flags; 72e257c6f05803 Thomas Gleixner 2024-06-23 92 /* Enforce the required flags */ 8c41ccec839c62 Thomas Gleixner 2024-06-23 93 info->flags |= required_flags; 72e257c6f05803 Thomas Gleixner 2024-06-23 94 72e257c6f05803 Thomas Gleixner 2024-06-23 95 /* Chip updates for all child bus types */ 1c000dcaad2bef Thomas Gleixner 2025-02-17 @96 if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) 1c000dcaad2bef Thomas Gleixner 2025-02-17 97 chip->irq_eoi = irq_chip_eoi_parent; 1c000dcaad2bef Thomas Gleixner 2025-02-17 @98 if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) 1c000dcaad2bef Thomas Gleixner 2025-02-17 99 chip->irq_ack = irq_chip_ack_parent; 72e257c6f05803 Thomas Gleixner 2024-06-23 100 72e257c6f05803 Thomas Gleixner 2024-06-23 101 /* 72e257c6f05803 Thomas Gleixner 2024-06-23 102 * The device MSI domain can never have a set affinity callback. It 72e257c6f05803 Thomas Gleixner 2024-06-23 103 * always has to rely on the parent domain to handle affinity 72e257c6f05803 Thomas Gleixner 2024-06-23 104 * settings. The device MSI domain just has to write the resulting 72e257c6f05803 Thomas Gleixner 2024-06-23 105 * MSI message into the hardware which is the whole purpose of the 72e257c6f05803 Thomas Gleixner 2024-06-23 106 * device MSI domain aside of mask/unmask which is provided e.g. by 72e257c6f05803 Thomas Gleixner 2024-06-23 107 * PCI/MSI device domains. 06526443a34c06 Marc Zyngier 2025-05-13 108 * 06526443a34c06 Marc Zyngier 2025-05-13 109 * The exception to the rule is when the underlying domain 06526443a34c06 Marc Zyngier 2025-05-13 110 * tells you that affinity is not a thing -- for example when 06526443a34c06 Marc Zyngier 2025-05-13 111 * everything is muxed behind a single interrupt. 72e257c6f05803 Thomas Gleixner 2024-06-23 112 */ 06526443a34c06 Marc Zyngier 2025-05-13 @113 if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY)) 1c000dcaad2bef Thomas Gleixner 2025-02-17 @114 chip->irq_set_affinity = msi_domain_set_affinity; 72e257c6f05803 Thomas Gleixner 2024-06-23 115 return true; 72e257c6f05803 Thomas Gleixner 2024-06-23 116 } 72e257c6f05803 Thomas Gleixner 2024-06-23 117 EXPORT_SYMBOL_GPL(msi_lib_init_dev_msi_info); 72e257c6f05803 Thomas Gleixner 2024-06-23 118 72e257c6f05803 Thomas Gleixner 2024-06-23 119 /** 72e257c6f05803 Thomas Gleixner 2024-06-23 120 * msi_lib_irq_domain_select - Shared select function for NEXUS domains 72e257c6f05803 Thomas Gleixner 2024-06-23 121 * @d: Pointer to the irq domain on which select is invoked 72e257c6f05803 Thomas Gleixner 2024-06-23 122 * @fwspec: Firmware spec describing what is searched 72e257c6f05803 Thomas Gleixner 2024-06-23 123 * @bus_token: The bus token for which a matching irq domain is looked up 72e257c6f05803 Thomas Gleixner 2024-06-23 124 * 72e257c6f05803 Thomas Gleixner 2024-06-23 125 * Returns: %0 if @d is not what is being looked for 72e257c6f05803 Thomas Gleixner 2024-06-23 126 * 72e257c6f05803 Thomas Gleixner 2024-06-23 127 * %1 if @d is either the domain which is directly searched for or 72e257c6f05803 Thomas Gleixner 2024-06-23 128 * if @d is providing the parent MSI domain for the functionality 72e257c6f05803 Thomas Gleixner 2024-06-23 129 * requested with @bus_token. 72e257c6f05803 Thomas Gleixner 2024-06-23 130 */ 72e257c6f05803 Thomas Gleixner 2024-06-23 131 int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec, 72e257c6f05803 Thomas Gleixner 2024-06-23 132 enum irq_domain_bus_token bus_token) 72e257c6f05803 Thomas Gleixner 2024-06-23 133 { 72e257c6f05803 Thomas Gleixner 2024-06-23 134 const struct msi_parent_ops *ops = d->msi_parent_ops; 72e257c6f05803 Thomas Gleixner 2024-06-23 135 u32 busmask = BIT(bus_token); 72e257c6f05803 Thomas Gleixner 2024-06-23 136 880799fc7a3a12 Maxime Chevallier 2024-08-23 137 if (!ops) 880799fc7a3a12 Maxime Chevallier 2024-08-23 138 return 0; 880799fc7a3a12 Maxime Chevallier 2024-08-23 139 72e257c6f05803 Thomas Gleixner 2024-06-23 140 if (fwspec->fwnode != d->fwnode || fwspec->param_count != 0) 72e257c6f05803 Thomas Gleixner 2024-06-23 141 return 0; 72e257c6f05803 Thomas Gleixner 2024-06-23 142 72e257c6f05803 Thomas Gleixner 2024-06-23 143 /* Handle pure domain searches */ 72e257c6f05803 Thomas Gleixner 2024-06-23 144 if (bus_token == ops->bus_select_token) 72e257c6f05803 Thomas Gleixner 2024-06-23 145 return 1; 72e257c6f05803 Thomas Gleixner 2024-06-23 146 880799fc7a3a12 Maxime Chevallier 2024-08-23 147 return !!(ops->bus_select_mask & busmask); 72e257c6f05803 Thomas Gleixner 2024-06-23 @148 } -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() 2025-06-26 14:47 ` [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() Nam Cao 2025-06-27 21:03 ` kernel test robot @ 2025-06-28 15:18 ` kernel test robot 1 sibling, 0 replies; 4+ messages in thread From: kernel test robot @ 2025-06-28 15:18 UTC (permalink / raw) To: Nam Cao, K . Y . Srinivasan, Marc Zyngier, Haiyang Zhang, Wei Liu, Dexuan Cui, Thomas Gleixner, Ingo Molnar, Borislav Petkov, Dave Hansen, x86, H . Peter Anvin, linux-hyperv, linux-kernel Cc: llvm, oe-kbuild-all, Nam Cao Hi Nam, kernel test robot noticed the following build warnings: [auto build test WARNING on tip/master] [also build test WARNING on linus/master v6.16-rc3 next-20250627] [cannot apply to tip/x86/core tip/auto-latest] [If your patch is applied to the wrong git tree, kindly drop us a note. And when submitting patch, we suggest to use '--base' as documented in https://git-scm.com/docs/git-format-patch#_base_tree_information] url: https://github.com/intel-lab-lkp/linux/commits/Nam-Cao/x86-hyperv-Switch-to-msi_create_parent_irq_domain/20250626-225420 base: tip/master patch link: https://lore.kernel.org/r/0eafade05acb51022242635750cd4990f3adb0ac.1750947640.git.namcao%40linutronix.de patch subject: [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() config: x86_64-buildonly-randconfig-002-20250628 (https://download.01.org/0day-ci/archive/20250628/202506282256.cHlEHrdc-lkp@intel.com/config) compiler: clang version 20.1.7 (https://github.com/llvm/llvm-project 6146a88f60492b520a36f8f8f3231e15f3cc6082) reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250628/202506282256.cHlEHrdc-lkp@intel.com/reproduce) If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags | Reported-by: kernel test robot <lkp@intel.com> | Closes: https://lore.kernel.org/oe-kbuild-all/202506282256.cHlEHrdc-lkp@intel.com/ All warnings (new ones prefixed by >>): In file included from drivers/irqchip/irq-msi-lib.c:7: >> include/linux/irqchip/irq-msi-lib.h:25:18: warning: declaration of 'struct msi_domain_info' will not be visible outside of this function [-Wvisibility] 25 | struct msi_domain_info *info); | ^ >> drivers/irqchip/irq-msi-lib.c:28:18: warning: declaration of 'struct msi_domain_info' will not be visible outside of this function [-Wvisibility] 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:26:6: error: conflicting types for 'msi_lib_init_dev_msi_info' 26 | bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, | ^ include/linux/irqchip/irq-msi-lib.h:23:6: note: previous declaration is here 23 | bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, | ^ drivers/irqchip/irq-msi-lib.c:30:51: error: no member named 'msi_parent_ops' in 'struct irq_domain' 30 | const struct msi_parent_ops *pops = real_parent->msi_parent_ops; | ~~~~~~~~~~~ ^ drivers/irqchip/irq-msi-lib.c:31:30: error: incomplete definition of type 'struct msi_domain_info' 31 | struct irq_chip *chip = info->chip; | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:43:31: error: incomplete definition of type 'const struct msi_parent_ops' 43 | if (domain->bus_token == pops->bus_select_token) { | ~~~~^ include/linux/irqdomain.h:27:8: note: forward declaration of 'struct msi_parent_ops' 27 | struct msi_parent_ops; | ^ drivers/irqchip/irq-msi-lib.c:51:23: error: incomplete definition of type 'const struct msi_parent_ops' 51 | required_flags = pops->required_flags; | ~~~~^ include/linux/irqdomain.h:27:8: note: forward declaration of 'struct msi_parent_ops' 27 | struct msi_parent_ops; | ^ drivers/irqchip/irq-msi-lib.c:54:13: error: incomplete definition of type 'struct msi_domain_info' 54 | switch(info->bus_token) { | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:68:24: error: incomplete definition of type 'struct msi_domain_info' 68 | if (WARN_ON_ONCE(info->flags)) | ~~~~^ include/asm-generic/bug.h:117:25: note: expanded from macro 'WARN_ON_ONCE' 117 | int __ret_warn_on = !!(condition); \ | ^~~~~~~~~ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:72:7: error: incomplete definition of type 'struct msi_domain_info' 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:72:17: error: use of undeclared identifier 'MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS' 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ^ drivers/irqchip/irq-msi-lib.c:72:51: error: use of undeclared identifier 'MSI_FLAG_FREE_MSI_DESCS' 72 | info->flags = MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS; | ^ drivers/irqchip/irq-msi-lib.c:76:22: error: use of undeclared identifier 'MSI_FLAG_PCI_MSI_MASK_PARENT' 76 | required_flags &= ~MSI_FLAG_PCI_MSI_MASK_PARENT; | ^ drivers/irqchip/irq-msi-lib.c:91:6: error: incomplete definition of type 'struct msi_domain_info' 91 | info->flags &= pops->supported_flags; | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:91:23: error: incomplete definition of type 'const struct msi_parent_ops' 91 | info->flags &= pops->supported_flags; | ~~~~^ include/linux/irqdomain.h:27:8: note: forward declaration of 'struct msi_parent_ops' 27 | struct msi_parent_ops; | ^ drivers/irqchip/irq-msi-lib.c:93:6: error: incomplete definition of type 'struct msi_domain_info' 93 | info->flags |= required_flags; | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) | ^ drivers/irqchip/irq-msi-lib.c:96:29: error: incomplete definition of type 'const struct msi_parent_ops' 96 | if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) | ~~~~^ include/linux/irqdomain.h:27:8: note: forward declaration of 'struct msi_parent_ops' 27 | struct msi_parent_ops; | ^ drivers/irqchip/irq-msi-lib.c:96:44: error: use of undeclared identifier 'MSI_CHIP_FLAG_SET_EOI' 96 | if (!chip->irq_eoi && (pops->chip_flags & MSI_CHIP_FLAG_SET_EOI)) | ^ drivers/irqchip/irq-msi-lib.c:98:29: error: incomplete definition of type 'const struct msi_parent_ops' 98 | if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) | ~~~~^ include/linux/irqdomain.h:27:8: note: forward declaration of 'struct msi_parent_ops' 27 | struct msi_parent_ops; | ^ drivers/irqchip/irq-msi-lib.c:98:44: error: use of undeclared identifier 'MSI_CHIP_FLAG_SET_ACK' 98 | if (!chip->irq_ack && (pops->chip_flags & MSI_CHIP_FLAG_SET_ACK)) | ^ drivers/irqchip/irq-msi-lib.c:113:39: error: incomplete definition of type 'struct msi_domain_info' 113 | if (!chip->irq_set_affinity && !(info->flags & MSI_FLAG_NO_AFFINITY)) | ~~~~^ drivers/irqchip/irq-msi-lib.c:28:18: note: forward declaration of 'struct msi_domain_info' 28 | struct msi_domain_info *info) vim +25 include/linux/irqchip/irq-msi-lib.h 496436f4a514a3 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 19 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 20 int msi_lib_irq_domain_select(struct irq_domain *d, struct irq_fwspec *fwspec, 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 21 enum irq_domain_bus_token bus_token); 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 22 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 23 bool msi_lib_init_dev_msi_info(struct device *dev, struct irq_domain *domain, 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 24 struct irq_domain *real_parent, 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 @25 struct msi_domain_info *info); 72e257c6f05803 drivers/irqchip/irq-msi-lib.h Thomas Gleixner 2024-06-23 26 -- 0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki ^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2025-06-28 15:19 UTC | newest] Thread overview: 4+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2025-06-26 14:47 [PATCH 0/1] x86/hyperv: MSI parent domain conversion Nam Cao 2025-06-26 14:47 ` [PATCH 1/1] x86/hyperv: Switch to msi_create_parent_irq_domain() Nam Cao 2025-06-27 21:03 ` kernel test robot 2025-06-28 15:18 ` kernel test robot
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for NNTP newsgroup(s).