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 int ia64_set_msi_irq_affinity(struct irq_data
*idata
,
16 const cpumask_t
*cpu_mask
, bool force
)
20 int cpu
= first_cpu(*cpu_mask
);
21 unsigned int irq
= idata
->irq
;
26 if (irq_prepare_move(irq
, cpu
))
29 get_cached_msi_msg(irq
, &msg
);
31 addr
= msg
.address_lo
;
32 addr
&= MSI_ADDR_DEST_ID_MASK
;
33 addr
|= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu
));
34 msg
.address_lo
= addr
;
37 data
&= MSI_DATA_VECTOR_MASK
;
38 data
|= MSI_DATA_VECTOR(irq_to_vector(irq
));
41 write_msi_msg(irq
, &msg
);
42 cpumask_copy(idata
->affinity
, cpumask_of(cpu
));
46 #endif /* CONFIG_SMP */
48 int ia64_setup_msi_irq(struct pci_dev
*pdev
, struct msi_desc
*desc
)
51 unsigned long dest_phys_id
;
59 irq_set_msi_desc(irq
, desc
);
60 cpus_and(mask
, irq_to_domain(irq
), cpu_online_map
);
61 dest_phys_id
= cpu_physical_id(first_cpu(mask
));
62 vector
= irq_to_vector(irq
);
67 MSI_ADDR_DEST_MODE_PHYS
|
68 MSI_ADDR_REDIRECTION_CPU
|
69 MSI_ADDR_DEST_ID_CPU(dest_phys_id
);
72 MSI_DATA_TRIGGER_EDGE
|
73 MSI_DATA_LEVEL_ASSERT
|
74 MSI_DATA_DELIVERY_FIXED
|
75 MSI_DATA_VECTOR(vector
);
77 write_msi_msg(irq
, &msg
);
78 irq_set_chip_and_handler(irq
, &ia64_msi_chip
, handle_edge_irq
);
83 void ia64_teardown_msi_irq(unsigned int irq
)
88 static void ia64_ack_msi_irq(struct irq_data
*data
)
90 irq_complete_move(data
->irq
);
95 static int ia64_msi_retrigger_irq(struct irq_data
*data
)
97 unsigned int vector
= irq_to_vector(data
->irq
);
98 ia64_resend_irq(vector
);
104 * Generic ops used on most IA64 platforms.
106 static struct irq_chip ia64_msi_chip
= {
108 .irq_mask
= mask_msi_irq
,
109 .irq_unmask
= unmask_msi_irq
,
110 .irq_ack
= ia64_ack_msi_irq
,
112 .irq_set_affinity
= ia64_set_msi_irq_affinity
,
114 .irq_retrigger
= ia64_msi_retrigger_irq
,
118 int arch_setup_msi_irq(struct pci_dev
*pdev
, struct msi_desc
*desc
)
120 if (platform_setup_msi_irq
)
121 return platform_setup_msi_irq(pdev
, desc
);
123 return ia64_setup_msi_irq(pdev
, desc
);
126 void arch_teardown_msi_irq(unsigned int irq
)
128 if (platform_teardown_msi_irq
)
129 return platform_teardown_msi_irq(irq
);
131 return ia64_teardown_msi_irq(irq
);
136 static int dmar_msi_set_affinity(struct irq_data
*data
,
137 const struct cpumask
*mask
, bool force
)
139 unsigned int irq
= data
->irq
;
140 struct irq_cfg
*cfg
= irq_cfg
+ irq
;
142 int cpu
= cpumask_first(mask
);
144 if (!cpu_online(cpu
))
147 if (irq_prepare_move(irq
, cpu
))
150 dmar_msi_read(irq
, &msg
);
152 msg
.data
&= ~MSI_DATA_VECTOR_MASK
;
153 msg
.data
|= MSI_DATA_VECTOR(cfg
->vector
);
154 msg
.address_lo
&= ~MSI_ADDR_DEST_ID_MASK
;
155 msg
.address_lo
|= MSI_ADDR_DEST_ID_CPU(cpu_physical_id(cpu
));
157 dmar_msi_write(irq
, &msg
);
158 cpumask_copy(data
->affinity
, mask
);
162 #endif /* CONFIG_SMP */
164 static struct irq_chip dmar_msi_type
= {
166 .irq_unmask
= dmar_msi_unmask
,
167 .irq_mask
= dmar_msi_mask
,
168 .irq_ack
= ia64_ack_msi_irq
,
170 .irq_set_affinity
= dmar_msi_set_affinity
,
172 .irq_retrigger
= ia64_msi_retrigger_irq
,
176 msi_compose_msg(struct pci_dev
*pdev
, unsigned int irq
, struct msi_msg
*msg
)
178 struct irq_cfg
*cfg
= irq_cfg
+ irq
;
182 cpus_and(mask
, irq_to_domain(irq
), cpu_online_map
);
183 dest
= cpu_physical_id(first_cpu(mask
));
188 MSI_ADDR_DEST_MODE_PHYS
|
189 MSI_ADDR_REDIRECTION_CPU
|
190 MSI_ADDR_DEST_ID_CPU(dest
);
193 MSI_DATA_TRIGGER_EDGE
|
194 MSI_DATA_LEVEL_ASSERT
|
195 MSI_DATA_DELIVERY_FIXED
|
196 MSI_DATA_VECTOR(cfg
->vector
);
200 int arch_setup_dmar_msi(unsigned int irq
)
205 ret
= msi_compose_msg(NULL
, irq
, &msg
);
208 dmar_msi_write(irq
, &msg
);
209 irq_set_chip_and_handler_name(irq
, &dmar_msi_type
, handle_edge_irq
,
213 #endif /* CONFIG_DMAR */