@@ -170,6 +170,7 @@ struct irq_domain *fsl_mc_msi_create_irq_domain(struct fwnode_handle *fwnode,
170170 fsl_mc_msi_update_dom_ops (info );
171171 if (info -> flags & MSI_FLAG_USE_DEF_CHIP_OPS )
172172 fsl_mc_msi_update_chip_ops (info );
173+ info -> flags |= MSI_FLAG_ALLOC_SIMPLE_MSI_DESCS | MSI_FLAG_FREE_MSI_DESCS ;
173174
174175 domain = msi_create_irq_domain (fwnode , info , parent );
175176 if (domain )
@@ -210,45 +211,7 @@ struct irq_domain *fsl_mc_find_msi_domain(struct device *dev)
210211 return msi_domain ;
211212}
212213
213- static void fsl_mc_msi_free_descs (struct device * dev )
214- {
215- struct msi_desc * desc , * tmp ;
216-
217- list_for_each_entry_safe (desc , tmp , dev_to_msi_list (dev ), list ) {
218- list_del (& desc -> list );
219- free_msi_entry (desc );
220- }
221- }
222-
223- static int fsl_mc_msi_alloc_descs (struct device * dev , unsigned int irq_count )
224-
225- {
226- unsigned int i ;
227- int error ;
228- struct msi_desc * msi_desc ;
229-
230- for (i = 0 ; i < irq_count ; i ++ ) {
231- msi_desc = alloc_msi_entry (dev , 1 , NULL );
232- if (!msi_desc ) {
233- dev_err (dev , "Failed to allocate msi entry\n" );
234- error = - ENOMEM ;
235- goto cleanup_msi_descs ;
236- }
237-
238- msi_desc -> msi_index = i ;
239- INIT_LIST_HEAD (& msi_desc -> list );
240- list_add_tail (& msi_desc -> list , dev_to_msi_list (dev ));
241- }
242-
243- return 0 ;
244-
245- cleanup_msi_descs :
246- fsl_mc_msi_free_descs (dev );
247- return error ;
248- }
249-
250- int fsl_mc_msi_domain_alloc_irqs (struct device * dev ,
251- unsigned int irq_count )
214+ int fsl_mc_msi_domain_alloc_irqs (struct device * dev , unsigned int irq_count )
252215{
253216 struct irq_domain * msi_domain ;
254217 int error ;
@@ -261,28 +224,17 @@ int fsl_mc_msi_domain_alloc_irqs(struct device *dev,
261224 if (error )
262225 return error ;
263226
264- if (! list_empty ( dev_to_msi_list ( dev ) ))
227+ if (msi_first_desc ( dev , MSI_DESC_ALL ))
265228 return - EINVAL ;
266229
267- error = fsl_mc_msi_alloc_descs (dev , irq_count );
268- if (error < 0 )
269- return error ;
270-
271230 /*
272231 * NOTE: Calling this function will trigger the invocation of the
273232 * its_fsl_mc_msi_prepare() callback
274233 */
275234 error = msi_domain_alloc_irqs (msi_domain , dev , irq_count );
276235
277- if (error ) {
236+ if (error )
278237 dev_err (dev , "Failed to allocate IRQs\n" );
279- goto cleanup_msi_descs ;
280- }
281-
282- return 0 ;
283-
284- cleanup_msi_descs :
285- fsl_mc_msi_free_descs (dev );
286238 return error ;
287239}
288240
@@ -295,9 +247,4 @@ void fsl_mc_msi_domain_free_irqs(struct device *dev)
295247 return ;
296248
297249 msi_domain_free_irqs (msi_domain , dev );
298-
299- if (list_empty (dev_to_msi_list (dev )))
300- return ;
301-
302- fsl_mc_msi_free_descs (dev );
303250}
0 commit comments