20
20
#include <linux/spinlock.h>
21
21
#include <linux/smp.h>
22
22
23
+ #include "irq-msi-lib.h"
23
24
#include "irq-riscv-imsic-state.h"
24
25
25
26
static bool imsic_cpu_page_phys (unsigned int cpu , unsigned int guest_index ,
@@ -174,22 +175,6 @@ static void imsic_irq_domain_free(struct irq_domain *domain, unsigned int virq,
174
175
irq_domain_free_irqs_parent (domain , virq , nr_irqs );
175
176
}
176
177
177
- static int imsic_irq_domain_select (struct irq_domain * domain , struct irq_fwspec * fwspec ,
178
- enum irq_domain_bus_token bus_token )
179
- {
180
- const struct msi_parent_ops * ops = domain -> msi_parent_ops ;
181
- u32 busmask = BIT (bus_token );
182
-
183
- if (fwspec -> fwnode != domain -> fwnode || fwspec -> param_count != 0 )
184
- return 0 ;
185
-
186
- /* Handle pure domain searches */
187
- if (bus_token == ops -> bus_select_token )
188
- return 1 ;
189
-
190
- return !!(ops -> bus_select_mask & busmask );
191
- }
192
-
193
178
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
194
179
static void imsic_irq_debug_show (struct seq_file * m , struct irq_domain * d ,
195
180
struct irq_data * irqd , int ind )
@@ -206,110 +191,21 @@ static void imsic_irq_debug_show(struct seq_file *m, struct irq_domain *d,
206
191
static const struct irq_domain_ops imsic_base_domain_ops = {
207
192
.alloc = imsic_irq_domain_alloc ,
208
193
.free = imsic_irq_domain_free ,
209
- .select = imsic_irq_domain_select ,
194
+ .select = msi_lib_irq_domain_select ,
210
195
#ifdef CONFIG_GENERIC_IRQ_DEBUGFS
211
196
.debug_show = imsic_irq_debug_show ,
212
197
#endif
213
198
};
214
199
215
- #ifdef CONFIG_RISCV_IMSIC_PCI
216
-
217
- static void imsic_pci_mask_irq (struct irq_data * d )
218
- {
219
- pci_msi_mask_irq (d );
220
- irq_chip_mask_parent (d );
221
- }
222
-
223
- static void imsic_pci_unmask_irq (struct irq_data * d )
224
- {
225
- irq_chip_unmask_parent (d );
226
- pci_msi_unmask_irq (d );
227
- }
228
-
229
- #define MATCH_PCI_MSI BIT(DOMAIN_BUS_PCI_MSI)
230
-
231
- #else
232
-
233
- #define MATCH_PCI_MSI 0
234
-
235
- #endif
236
-
237
- static bool imsic_init_dev_msi_info (struct device * dev ,
238
- struct irq_domain * domain ,
239
- struct irq_domain * real_parent ,
240
- struct msi_domain_info * info )
241
- {
242
- const struct msi_parent_ops * pops = real_parent -> msi_parent_ops ;
243
-
244
- /* MSI parent domain specific settings */
245
- switch (real_parent -> bus_token ) {
246
- case DOMAIN_BUS_NEXUS :
247
- if (WARN_ON_ONCE (domain != real_parent ))
248
- return false;
249
- #ifdef CONFIG_SMP
250
- info -> chip -> irq_set_affinity = irq_chip_set_affinity_parent ;
251
- #endif
252
- break ;
253
- default :
254
- WARN_ON_ONCE (1 );
255
- return false;
256
- }
257
-
258
- /* Is the target supported? */
259
- switch (info -> bus_token ) {
260
- #ifdef CONFIG_RISCV_IMSIC_PCI
261
- case DOMAIN_BUS_PCI_DEVICE_MSI :
262
- case DOMAIN_BUS_PCI_DEVICE_MSIX :
263
- info -> chip -> irq_mask = imsic_pci_mask_irq ;
264
- info -> chip -> irq_unmask = imsic_pci_unmask_irq ;
265
- break ;
266
- #endif
267
- case DOMAIN_BUS_DEVICE_MSI :
268
- /*
269
- * Per-device MSI should never have any MSI feature bits
270
- * set. It's sole purpose is to create a dumb interrupt
271
- * chip which has a device specific irq_write_msi_msg()
272
- * callback.
273
- */
274
- if (WARN_ON_ONCE (info -> flags ))
275
- return false;
276
-
277
- /* Core managed MSI descriptors */
278
- info -> flags |= MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS |
279
- MSI_FLAG_FREE_MSI_DESCS ;
280
- break ;
281
- case DOMAIN_BUS_WIRED_TO_MSI :
282
- break ;
283
- default :
284
- WARN_ON_ONCE (1 );
285
- return false;
286
- }
287
-
288
- /* Use hierarchial chip operations re-trigger */
289
- info -> chip -> irq_retrigger = irq_chip_retrigger_hierarchy ;
290
-
291
- /*
292
- * Mask out the domain specific MSI feature flags which are not
293
- * supported by the real parent.
294
- */
295
- info -> flags &= pops -> supported_flags ;
296
-
297
- /* Enforce the required flags */
298
- info -> flags |= pops -> required_flags ;
299
-
300
- return true;
301
- }
302
-
303
- #define MATCH_PLATFORM_MSI BIT(DOMAIN_BUS_PLATFORM_MSI)
304
-
305
200
static const struct msi_parent_ops imsic_msi_parent_ops = {
306
201
.supported_flags = MSI_GENERIC_FLAGS_MASK |
307
202
MSI_FLAG_PCI_MSIX ,
308
203
.required_flags = MSI_FLAG_USE_DEF_DOM_OPS |
309
- MSI_FLAG_USE_DEF_CHIP_OPS ,
204
+ MSI_FLAG_USE_DEF_CHIP_OPS |
205
+ MSI_FLAG_PCI_MSI_MASK_PARENT ,
310
206
.bus_select_token = DOMAIN_BUS_NEXUS ,
311
207
.bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI ,
312
- .init_dev_msi_info = imsic_init_dev_msi_info ,
208
+ .init_dev_msi_info = msi_lib_init_dev_msi_info ,
313
209
};
314
210
315
211
int imsic_irqdomain_init (void )
0 commit comments