18
18
19
19
#include <linux/irqchip/arm-gic-v3.h>
20
20
21
+ #include "irq-msi-lib.h"
22
+
21
23
struct mbi_range {
22
24
u32 spi_start ;
23
25
u32 nr_spis ;
@@ -138,6 +140,7 @@ static void mbi_irq_domain_free(struct irq_domain *domain,
138
140
}
139
141
140
142
static const struct irq_domain_ops mbi_domain_ops = {
143
+ .select = msi_lib_irq_domain_select ,
141
144
.alloc = mbi_irq_domain_alloc ,
142
145
.free = mbi_irq_domain_free ,
143
146
};
@@ -151,54 +154,6 @@ static void mbi_compose_msi_msg(struct irq_data *data, struct msi_msg *msg)
151
154
iommu_dma_compose_msi_msg (irq_data_get_msi_desc (data ), msg );
152
155
}
153
156
154
- #ifdef CONFIG_PCI_MSI
155
- /* PCI-specific irqchip */
156
- static void mbi_mask_msi_irq (struct irq_data * d )
157
- {
158
- pci_msi_mask_irq (d );
159
- irq_chip_mask_parent (d );
160
- }
161
-
162
- static void mbi_unmask_msi_irq (struct irq_data * d )
163
- {
164
- pci_msi_unmask_irq (d );
165
- irq_chip_unmask_parent (d );
166
- }
167
-
168
- static struct irq_chip mbi_msi_irq_chip = {
169
- .name = "MSI" ,
170
- .irq_mask = mbi_mask_msi_irq ,
171
- .irq_unmask = mbi_unmask_msi_irq ,
172
- .irq_eoi = irq_chip_eoi_parent ,
173
- .irq_compose_msi_msg = mbi_compose_msi_msg ,
174
- };
175
-
176
- static struct msi_domain_info mbi_msi_domain_info = {
177
- .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
178
- MSI_FLAG_PCI_MSIX | MSI_FLAG_MULTI_PCI_MSI ),
179
- .chip = & mbi_msi_irq_chip ,
180
- };
181
-
182
- static int mbi_allocate_pci_domain (struct irq_domain * nexus_domain ,
183
- struct irq_domain * * pci_domain )
184
- {
185
- * pci_domain = pci_msi_create_irq_domain (nexus_domain -> parent -> fwnode ,
186
- & mbi_msi_domain_info ,
187
- nexus_domain );
188
- if (!* pci_domain )
189
- return - ENOMEM ;
190
-
191
- return 0 ;
192
- }
193
- #else
194
- static int mbi_allocate_pci_domain (struct irq_domain * nexus_domain ,
195
- struct irq_domain * * pci_domain )
196
- {
197
- * pci_domain = NULL ;
198
- return 0 ;
199
- }
200
- #endif
201
-
202
157
static void mbi_compose_mbi_msg (struct irq_data * data , struct msi_msg * msg )
203
158
{
204
159
mbi_compose_msi_msg (data , msg );
@@ -210,51 +165,60 @@ static void mbi_compose_mbi_msg(struct irq_data *data, struct msi_msg *msg)
210
165
iommu_dma_compose_msi_msg (irq_data_get_msi_desc (data ), & msg [1 ]);
211
166
}
212
167
213
- /* Platform-MSI specific irqchip */
214
- static struct irq_chip mbi_pmsi_irq_chip = {
215
- .name = "pMSI" ,
216
- .irq_set_type = irq_chip_set_type_parent ,
217
- .irq_compose_msi_msg = mbi_compose_mbi_msg ,
218
- .flags = IRQCHIP_SUPPORTS_LEVEL_MSI ,
219
- };
220
-
221
- static struct msi_domain_ops mbi_pmsi_ops = {
222
- };
168
+ static bool mbi_init_dev_msi_info (struct device * dev , struct irq_domain * domain ,
169
+ struct irq_domain * real_parent , struct msi_domain_info * info )
170
+ {
171
+ if (!msi_lib_init_dev_msi_info (dev , domain , real_parent , info ))
172
+ return false;
173
+
174
+ switch (info -> bus_token ) {
175
+ case DOMAIN_BUS_PCI_DEVICE_MSI :
176
+ case DOMAIN_BUS_PCI_DEVICE_MSIX :
177
+ info -> chip -> irq_compose_msi_msg = mbi_compose_msi_msg ;
178
+ return true;
179
+
180
+ case DOMAIN_BUS_DEVICE_MSI :
181
+ info -> chip -> irq_compose_msi_msg = mbi_compose_mbi_msg ;
182
+ info -> chip -> irq_set_type = irq_chip_set_type_parent ;
183
+ info -> chip -> flags |= IRQCHIP_SUPPORTS_LEVEL_MSI ;
184
+ info -> flags |= MSI_FLAG_LEVEL_CAPABLE ;
185
+ return true;
186
+
187
+ default :
188
+ WARN_ON_ONCE (1 );
189
+ return false;
190
+ }
191
+ }
223
192
224
- static struct msi_domain_info mbi_pmsi_domain_info = {
225
- .flags = (MSI_FLAG_USE_DEF_DOM_OPS | MSI_FLAG_USE_DEF_CHIP_OPS |
226
- MSI_FLAG_LEVEL_CAPABLE ),
227
- .ops = & mbi_pmsi_ops ,
228
- .chip = & mbi_pmsi_irq_chip ,
193
+ #define MBI_MSI_FLAGS_REQUIRED (MSI_FLAG_USE_DEF_DOM_OPS | \
194
+ MSI_FLAG_USE_DEF_CHIP_OPS | \
195
+ MSI_FLAG_PCI_MSI_MASK_PARENT)
196
+
197
+ #define MBI_MSI_FLAGS_SUPPORTED (MSI_GENERIC_FLAGS_MASK | \
198
+ MSI_FLAG_PCI_MSIX | \
199
+ MSI_FLAG_MULTI_PCI_MSI)
200
+
201
+ static const struct msi_parent_ops gic_v3_mbi_msi_parent_ops = {
202
+ .supported_flags = MBI_MSI_FLAGS_SUPPORTED ,
203
+ .required_flags = MBI_MSI_FLAGS_REQUIRED ,
204
+ .bus_select_token = DOMAIN_BUS_NEXUS ,
205
+ .bus_select_mask = MATCH_PCI_MSI | MATCH_PLATFORM_MSI ,
206
+ .prefix = "MBI-" ,
207
+ .init_dev_msi_info = mbi_init_dev_msi_info ,
229
208
};
230
209
231
- static int mbi_allocate_domains (struct irq_domain * parent )
210
+ static int mbi_allocate_domain (struct irq_domain * parent )
232
211
{
233
- struct irq_domain * nexus_domain , * pci_domain , * plat_domain ;
234
- int err ;
212
+ struct irq_domain * nexus_domain ;
235
213
236
214
nexus_domain = irq_domain_create_hierarchy (parent , 0 , 0 , parent -> fwnode ,
237
215
& mbi_domain_ops , NULL );
238
216
if (!nexus_domain )
239
217
return - ENOMEM ;
240
218
241
219
irq_domain_update_bus_token (nexus_domain , DOMAIN_BUS_NEXUS );
242
-
243
- err = mbi_allocate_pci_domain (nexus_domain , & pci_domain );
244
-
245
- plat_domain = platform_msi_create_irq_domain (parent -> fwnode ,
246
- & mbi_pmsi_domain_info ,
247
- nexus_domain );
248
-
249
- if (err || !plat_domain ) {
250
- if (plat_domain )
251
- irq_domain_remove (plat_domain );
252
- if (pci_domain )
253
- irq_domain_remove (pci_domain );
254
- irq_domain_remove (nexus_domain );
255
- return - ENOMEM ;
256
- }
257
-
220
+ nexus_domain -> flags |= IRQ_DOMAIN_FLAG_MSI_PARENT ;
221
+ nexus_domain -> msi_parent_ops = & gic_v3_mbi_msi_parent_ops ;
258
222
return 0 ;
259
223
}
260
224
@@ -317,7 +281,7 @@ int __init mbi_init(struct fwnode_handle *fwnode, struct irq_domain *parent)
317
281
318
282
pr_info ("Using MBI frame %pa\n" , & mbi_phys_base );
319
283
320
- ret = mbi_allocate_domains (parent );
284
+ ret = mbi_allocate_domain (parent );
321
285
if (ret )
322
286
goto err_free_mbi ;
323
287
0 commit comments