x86/msi: Move compose message callback where it belongs
authorThomas Gleixner <tglx@linutronix.de>
Wed, 26 Aug 2020 11:16:33 +0000 (13:16 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 16 Sep 2020 14:52:28 +0000 (16:52 +0200)
Composing the MSI message at the MSI chip level is wrong because the
underlying parent domain is the one which knows how the message should be
composed for the direct vector delivery or the interrupt remapping table
entry.

The interrupt remapping aware PCI/MSI chip does that already. Make the
direct delivery chip do the same and move the composition of the direct
delivery MSI message to the vector domain irq chip.

This prepares for the upcoming device MSI support to avoid having
architecture specific knowledge in the device MSI domain irq chips.

Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Link: https://lore.kernel.org/r/20200826112331.157603198@linutronix.de
arch/x86/include/asm/apic.h
arch/x86/kernel/apic/msi.c
arch/x86/kernel/apic/vector.c

index 2cc44e957c318f342251604f2169afd2c75d250e..1c129abb7f09d28772d1c2cc990e20ad098b630b 100644 (file)
@@ -519,6 +519,14 @@ static inline bool apic_id_is_primary_thread(unsigned int id) { return false; }
 static inline void apic_smt_update(void) { }
 #endif
 
+struct msi_msg;
+
+#ifdef CONFIG_PCI_MSI
+void x86_vector_msi_compose_msg(struct irq_data *data, struct msi_msg *msg);
+#else
+# define x86_vector_msi_compose_msg NULL
+#endif
+
 extern void ioapic_zap_locks(void);
 
 #endif /* _ASM_X86_APIC_H */
index 7f7bc6a59527fb49e3e737c16d62007cee9b35bb..5e8465e3e27f1f9f1e5ec1973704abc6797f7250 100644 (file)
@@ -45,7 +45,7 @@ static void __irq_msi_compose_msg(struct irq_cfg *cfg, struct msi_msg *msg)
                MSI_DATA_VECTOR(cfg->vector);
 }
 
-static void irq_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
+void x86_vector_msi_compose_msg(struct irq_data *data, struct msi_msg *msg)
 {
        __irq_msi_compose_msg(irqd_cfg(data), msg);
 }
@@ -177,7 +177,6 @@ static struct irq_chip pci_msi_controller = {
        .irq_mask               = pci_msi_mask_irq,
        .irq_ack                = irq_chip_ack_parent,
        .irq_retrigger          = irq_chip_retrigger_hierarchy,
-       .irq_compose_msi_msg    = irq_msi_compose_msg,
        .irq_set_affinity       = msi_set_affinity,
        .flags                  = IRQCHIP_SKIP_SET_WAKE,
 };
@@ -321,7 +320,6 @@ static struct irq_chip dmar_msi_controller = {
        .irq_ack                = irq_chip_ack_parent,
        .irq_set_affinity       = msi_domain_set_affinity,
        .irq_retrigger          = irq_chip_retrigger_hierarchy,
-       .irq_compose_msi_msg    = irq_msi_compose_msg,
        .irq_write_msi_msg      = dmar_msi_write_msg,
        .flags                  = IRQCHIP_SKIP_SET_WAKE,
 };
@@ -419,7 +417,6 @@ static struct irq_chip hpet_msi_controller __ro_after_init = {
        .irq_ack = irq_chip_ack_parent,
        .irq_set_affinity = msi_domain_set_affinity,
        .irq_retrigger = irq_chip_retrigger_hierarchy,
-       .irq_compose_msi_msg = irq_msi_compose_msg,
        .irq_write_msi_msg = hpet_msi_write_msg,
        .flags = IRQCHIP_SKIP_SET_WAKE,
 };
@@ -479,13 +476,10 @@ struct irq_domain *hpet_create_irq_domain(int hpet_id)
        info.type = X86_IRQ_ALLOC_TYPE_HPET;
        info.hpet_id = hpet_id;
        parent = irq_remapping_get_ir_irq_domain(&info);
-       if (parent == NULL) {
+       if (parent == NULL)
                parent = x86_vector_domain;
-       } else {
+       else
                hpet_msi_controller.name = "IR-HPET-MSI";
-               /* Temporary fix: Will go away */
-               hpet_msi_controller.irq_compose_msi_msg = NULL;
-       }
 
        fn = irq_domain_alloc_named_id_fwnode(hpet_msi_controller.name,
                                              hpet_id);
index f8a56b5dc29fe572a2e2fcb50e5e0c57b661c043..66516d818d7a3aa4d5186ab3db30a5bda1940a57 100644 (file)
@@ -824,6 +824,7 @@ static struct irq_chip lapic_controller = {
        .name                   = "APIC",
        .irq_ack                = apic_ack_edge,
        .irq_set_affinity       = apic_set_affinity,
+       .irq_compose_msi_msg    = x86_vector_msi_compose_msg,
        .irq_retrigger          = apic_retrigger_irq,
 };