linux-um.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [PATCH v2 0/1] um: MSI parent domain conversion
@ 2025-06-30  6:51 Nam Cao
  2025-06-30  6:51 ` [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain() Nam Cao
  0 siblings, 1 reply; 6+ messages in thread
From: Nam Cao @ 2025-06-30  6:51 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, 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 um's driver to implement MSI parent domain.

 arch/um/drivers/Kconfig    |  1 +
 arch/um/drivers/virt-pci.c | 45 +++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

-- 
2.39.5



^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain()
  2025-06-30  6:51 [PATCH v2 0/1] um: MSI parent domain conversion Nam Cao
@ 2025-06-30  6:51 ` Nam Cao
  2025-06-30  6:55   ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Nam Cao @ 2025-06-30  6:51 UTC (permalink / raw)
  To: Marc Zyngier, Thomas Gleixner, Richard Weinberger, Anton Ivanov,
	Johannes Berg, linux-um, 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>
---
v2: Remove MSI_FLAG_PCI_MSI_MASK_PARENT to fix a NULL pointer deref
---
 arch/um/drivers/Kconfig    |  1 +
 arch/um/drivers/virt-pci.c | 45 +++++++++++++++++++-------------------
 2 files changed, 23 insertions(+), 23 deletions(-)

diff --git a/arch/um/drivers/Kconfig b/arch/um/drivers/Kconfig
index 34085bfc6d416..6a0354ca032fb 100644
--- a/arch/um/drivers/Kconfig
+++ b/arch/um/drivers/Kconfig
@@ -160,6 +160,7 @@ config UML_RTC
 config UML_PCI
 	bool
 	select FORCE_PCI
+	select IRQ_MSI_LIB
 	select UML_IOMEM_EMULATION
 	select UML_DMA_EMULATION
 	select PCI_MSI
diff --git a/arch/um/drivers/virt-pci.c b/arch/um/drivers/virt-pci.c
index 0fe207ca4b72e..557d93aea00a1 100644
--- a/arch/um/drivers/virt-pci.c
+++ b/arch/um/drivers/virt-pci.c
@@ -7,6 +7,7 @@
 #include <linux/pci.h>
 #include <linux/logic_iomem.h>
 #include <linux/of_platform.h>
+#include <linux/irqchip/irq-msi-lib.h>
 #include <linux/irqdomain.h>
 #include <linux/msi.h>
 #include <linux/unaligned.h>
@@ -29,7 +30,6 @@ static struct um_pci_device *um_pci_platform_device;
 static struct um_pci_device_reg um_pci_devices[MAX_DEVICES];
 static struct fwnode_handle *um_pci_fwnode;
 static struct irq_domain *um_pci_inner_domain;
-static struct irq_domain *um_pci_msi_domain;
 static unsigned long um_pci_msi_used[BITS_TO_LONGS(MAX_MSI_VECTORS)];
 
 static unsigned long um_pci_cfgspace_read(void *priv, unsigned int offset,
@@ -400,21 +400,24 @@ static void um_pci_inner_domain_free(struct irq_domain *domain,
 }
 
 static const struct irq_domain_ops um_pci_inner_domain_ops = {
+	.select = msi_lib_irq_domain_select,
 	.alloc = um_pci_inner_domain_alloc,
 	.free = um_pci_inner_domain_free,
 };
 
-static struct irq_chip um_pci_msi_irq_chip = {
-	.name = "UM virtual PCIe MSI",
-	.irq_mask = pci_msi_mask_irq,
-	.irq_unmask = pci_msi_unmask_irq,
-};
-
-static struct msi_domain_info um_pci_msi_domain_info = {
-	.flags	= MSI_FLAG_USE_DEF_DOM_OPS |
-		  MSI_FLAG_USE_DEF_CHIP_OPS |
-		  MSI_FLAG_PCI_MSIX,
-	.chip	= &um_pci_msi_irq_chip,
+#define UM_PCI_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS		| \
+				   MSI_FLAG_USE_DEF_CHIP_OPS		| \
+				   MSI_FLAG_NO_AFFINITY)
+#define UM_PCI_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK		| \
+				    MSI_FLAG_PCI_MSIX)
+
+static const struct msi_parent_ops um_pci_msi_parent_ops = {
+	.required_flags		= UM_PCI_MSI_FLAGS_REQUIRED,
+	.supported_flags	= UM_PCI_MSI_FLAGS_SUPPORTED,
+	.bus_select_token	= DOMAIN_BUS_NEXUS,
+	.bus_select_mask	= MATCH_PCI_MSI,
+	.prefix			= "UM-virtual-",
+	.init_dev_msi_info	= msi_lib_init_dev_msi_info,
 };
 
 static struct resource busn_resource = {
@@ -559,17 +562,14 @@ static int __init um_pci_init(void)
 		goto free;
 	}
 
-	um_pci_inner_domain = irq_domain_create_linear(um_pci_fwnode, MAX_MSI_VECTORS,
-						       &um_pci_inner_domain_ops, NULL);
-	if (!um_pci_inner_domain) {
-		err = -ENOMEM;
-		goto free;
-	}
+	struct irq_domain_info info = {
+		.fwnode		= um_pci_fwnode,
+		.ops		= &um_pci_inner_domain_ops,
+		.size		= MAX_MSI_VECTORS,
+	};
 
-	um_pci_msi_domain = pci_msi_create_irq_domain(um_pci_fwnode,
-						      &um_pci_msi_domain_info,
-						      um_pci_inner_domain);
-	if (!um_pci_msi_domain) {
+	um_pci_inner_domain = msi_create_parent_irq_domain(&info, &um_pci_msi_parent_ops);
+	if (!um_pci_inner_domain) {
 		err = -ENOMEM;
 		goto free;
 	}
@@ -611,7 +611,6 @@ device_initcall(um_pci_init);
 
 static void __exit um_pci_exit(void)
 {
-	irq_domain_remove(um_pci_msi_domain);
 	irq_domain_remove(um_pci_inner_domain);
 	pci_free_resource_list(&bridge->windows);
 	pci_free_host_bridge(bridge);
-- 
2.39.5



^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain()
  2025-06-30  6:51 ` [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain() Nam Cao
@ 2025-06-30  6:55   ` Johannes Berg
  2025-06-30  7:02     ` Nam Cao
  0 siblings, 1 reply; 6+ messages in thread
From: Johannes Berg @ 2025-06-30  6:55 UTC (permalink / raw)
  To: Nam Cao, Marc Zyngier, Thomas Gleixner, Richard Weinberger,
	Anton Ivanov, linux-um, linux-kernel

On Mon, 2025-06-30 at 08:51 +0200, Nam Cao wrote:
> Move away from the legacy MSI domain setup, switch to use
> msi_create_parent_irq_domain().
> 

Do you want this to go through the UML tree, or is it a dependency
somewhere else? In the latter case, I suppose you can add

Acked-by: Johannes Berg <johannes@sipsolutions.net>
Tested-by: Johannes Berg <johannes@sipsolutions.net>

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain()
  2025-06-30  6:55   ` Johannes Berg
@ 2025-06-30  7:02     ` Nam Cao
  2025-07-03 16:39       ` Thomas Gleixner
  0 siblings, 1 reply; 6+ messages in thread
From: Nam Cao @ 2025-06-30  7:02 UTC (permalink / raw)
  To: Johannes Berg
  Cc: Marc Zyngier, Thomas Gleixner, Richard Weinberger, Anton Ivanov,
	linux-um, linux-kernel

On Mon, Jun 30, 2025 at 08:55:54AM +0200, Johannes Berg wrote:
> On Mon, 2025-06-30 at 08:51 +0200, Nam Cao wrote:
> > Move away from the legacy MSI domain setup, switch to use
> > msi_create_parent_irq_domain().
> > 
> 
> Do you want this to go through the UML tree, or is it a dependency
> somewhere else? In the latter case, I suppose you can add

Please take it into the UML tree.

> Acked-by: Johannes Berg <johannes@sipsolutions.net>
> Tested-by: Johannes Berg <johannes@sipsolutions.net>

Thanks!
Nam


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain()
  2025-06-30  7:02     ` Nam Cao
@ 2025-07-03 16:39       ` Thomas Gleixner
  2025-07-04 12:00         ` Johannes Berg
  0 siblings, 1 reply; 6+ messages in thread
From: Thomas Gleixner @ 2025-07-03 16:39 UTC (permalink / raw)
  To: Nam Cao, Johannes Berg
  Cc: Marc Zyngier, Richard Weinberger, Anton Ivanov, linux-um,
	linux-kernel

Johannes,

On Mon, Jun 30 2025 at 09:02, Nam Cao wrote:
> On Mon, Jun 30, 2025 at 08:55:54AM +0200, Johannes Berg wrote:
>> On Mon, 2025-06-30 at 08:51 +0200, Nam Cao wrote:
>> > Move away from the legacy MSI domain setup, switch to use
>> > msi_create_parent_irq_domain().
>> > 
>> 
>> Do you want this to go through the UML tree, or is it a dependency
>> somewhere else? In the latter case, I suppose you can add
>
> Please take it into the UML tree.
>
>> Acked-by: Johannes Berg <johannes@sipsolutions.net>
>> Tested-by: Johannes Berg <johannes@sipsolutions.net>

are you picking this up or want me to queue it?

Thanks,

        tglx


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain()
  2025-07-03 16:39       ` Thomas Gleixner
@ 2025-07-04 12:00         ` Johannes Berg
  0 siblings, 0 replies; 6+ messages in thread
From: Johannes Berg @ 2025-07-04 12:00 UTC (permalink / raw)
  To: Thomas Gleixner, Nam Cao
  Cc: Marc Zyngier, Richard Weinberger, Anton Ivanov, linux-um,
	linux-kernel

On Thu, 2025-07-03 at 18:39 +0200, Thomas Gleixner wrote:
> Johannes,
> 
> On Mon, Jun 30 2025 at 09:02, Nam Cao wrote:
> > On Mon, Jun 30, 2025 at 08:55:54AM +0200, Johannes Berg wrote:
> > > On Mon, 2025-06-30 at 08:51 +0200, Nam Cao wrote:
> > > > Move away from the legacy MSI domain setup, switch to use
> > > > msi_create_parent_irq_domain().
> > > > 
> > > 
> > > Do you want this to go through the UML tree, or is it a dependency
> > > somewhere else? In the latter case, I suppose you can add
> > 
> > Please take it into the UML tree.
> > 
> > > Acked-by: Johannes Berg <johannes@sipsolutions.net>
> > > Tested-by: Johannes Berg <johannes@sipsolutions.net>
> 
> are you picking this up or want me to queue it?

I've picked it up for uml-next now:

https://git.kernel.org/pub/scm/linux/kernel/git/uml/linux.git/commit/?h=next&id=1528fd400c62b84b9c0e368a62b83fbd9d6fb92b

johannes


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2025-07-04 12:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-30  6:51 [PATCH v2 0/1] um: MSI parent domain conversion Nam Cao
2025-06-30  6:51 ` [PATCH v2 1/1] um: virt-pci: Switch to msi_create_parent_irq_domain() Nam Cao
2025-06-30  6:55   ` Johannes Berg
2025-06-30  7:02     ` Nam Cao
2025-07-03 16:39       ` Thomas Gleixner
2025-07-04 12:00         ` Johannes Berg

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).