2 * MSI hooks for standard x86 apic
8 #include <linux/dmar.h>
10 #include <asm/msidef.h>
12 static struct irq_chip ia64_msi_chip;
15 static void ia64_set_msi_irq_affinity(unsigned int irq,
16 const cpumask_t *cpu_mask)
20 int cpu = first_cpu(*cpu_mask);
25 if (irq_prepare_move(irq, cpu))
28 read_msi_msg(irq, &msg);
30 addr = msg.address_lo;
31 addr &= MSI_ADDR_DEST_ID_MASK;
32 addr |= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu));
33 msg.address_lo = addr;
36 data &= MSI_DATA_VECTOR_MASK;
37 data |= MSI_DATA_VECTOR(irq_to_vector(irq));
40 write_msi_msg(irq, &msg);
41 cpumask_copy(irq_desc[irq].affinity, cpumask_of(cpu));
43 #endif /* CONFIG_SMP */
45 int ia64_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
48 unsigned long dest_phys_id;
56 set_irq_msi(irq, desc);
57 cpus_and(mask, irq_to_domain(irq), cpu_online_map);
58 dest_phys_id = cpu_physical_id(first_cpu(mask));
59 vector = irq_to_vector(irq);
64 MSI_ADDR_DEST_MODE_PHYS |
65 MSI_ADDR_REDIRECTION_CPU |
66 MSI_ADDR_DEST_ID_CPU(dest_phys_id);
69 MSI_DATA_TRIGGER_EDGE |
70 MSI_DATA_LEVEL_ASSERT |
71 MSI_DATA_DELIVERY_FIXED |
72 MSI_DATA_VECTOR(vector);
74 write_msi_msg(irq, &msg);
75 set_irq_chip_and_handler(irq, &ia64_msi_chip, handle_edge_irq);
80 void ia64_teardown_msi_irq(unsigned int irq)
85 static void ia64_ack_msi_irq(unsigned int irq)
87 irq_complete_move(irq);
92 static int ia64_msi_retrigger_irq(unsigned int irq)
94 unsigned int vector = irq_to_vector(irq);
95 ia64_resend_irq(vector);
101 * Generic ops used on most IA64 platforms.
103 static struct irq_chip ia64_msi_chip = {
105 .mask = mask_msi_irq,
106 .unmask = unmask_msi_irq,
107 .ack = ia64_ack_msi_irq,
109 .set_affinity = ia64_set_msi_irq_affinity,
111 .retrigger = ia64_msi_retrigger_irq,
115 int arch_setup_msi_irq(struct pci_dev *pdev, struct msi_desc *desc)
117 if (platform_setup_msi_irq)
118 return platform_setup_msi_irq(pdev, desc);
120 return ia64_setup_msi_irq(pdev, desc);
123 void arch_teardown_msi_irq(unsigned int irq)
125 if (platform_teardown_msi_irq)
126 return platform_teardown_msi_irq(irq);
128 return ia64_teardown_msi_irq(irq);
133 static void dmar_msi_set_affinity(unsigned int irq, const struct cpumask *mask)
135 struct irq_cfg *cfg = irq_cfg + irq;
137 int cpu = cpumask_first(mask);
139 if (!cpu_online(cpu))
142 if (irq_prepare_move(irq, cpu))
145 dmar_msi_read(irq, &msg);
147 msg.data &= ~MSI_DATA_VECTOR_MASK;
148 msg.data |= MSI_DATA_VECTOR(cfg->vector);
149 msg.address_lo &= ~MSI_ADDR_DEST_ID_MASK;
150 msg.address_lo |= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu));
152 dmar_msi_write(irq, &msg);
153 cpumask_copy(irq_desc[irq].affinity, mask);
155 #endif /* CONFIG_SMP */
157 struct irq_chip dmar_msi_type = {
159 .unmask = dmar_msi_unmask,
160 .mask = dmar_msi_mask,
161 .ack = ia64_ack_msi_irq,
163 .set_affinity = dmar_msi_set_affinity,
165 .retrigger = ia64_msi_retrigger_irq,
169 msi_compose_msg(struct pci_dev *pdev, unsigned int irq, struct msi_msg *msg)
171 struct irq_cfg *cfg = irq_cfg + irq;
175 cpus_and(mask, irq_to_domain(irq), cpu_online_map);
176 dest = cpu_physical_id(first_cpu(mask));
181 MSI_ADDR_DEST_MODE_PHYS |
182 MSI_ADDR_REDIRECTION_CPU |
183 MSI_ADDR_DEST_ID_CPU(dest);
186 MSI_DATA_TRIGGER_EDGE |
187 MSI_DATA_LEVEL_ASSERT |
188 MSI_DATA_DELIVERY_FIXED |
189 MSI_DATA_VECTOR(cfg->vector);
193 int arch_setup_dmar_msi(unsigned int irq)
198 ret = msi_compose_msg(NULL, irq, &msg);
201 dmar_msi_write(irq, &msg);
202 set_irq_chip_and_handler_name(irq, &dmar_msi_type, handle_edge_irq,
206 #endif /* CONFIG_DMAR */