forked from ~ljy/RK356X_SDK_RELEASE

hc
2024-05-11 297b60346df8beafee954a0fd7c2d64f33f3b9bc
kernel/drivers/bus/fsl-mc/fsl-mc-allocator.c
....@@ -297,6 +297,14 @@
297297 goto error;
298298 }
299299
300
+ mc_adev->consumer_link = device_link_add(&mc_dev->dev,
301
+ &mc_adev->dev,
302
+ DL_FLAG_AUTOREMOVE_CONSUMER);
303
+ if (!mc_adev->consumer_link) {
304
+ error = -EINVAL;
305
+ goto error;
306
+ }
307
+
300308 *new_mc_adev = mc_adev;
301309 return 0;
302310 error:
....@@ -323,6 +331,8 @@
323331 return;
324332
325333 fsl_mc_resource_free(resource);
334
+
335
+ mc_adev->consumer_link = NULL;
326336 }
327337 EXPORT_SYMBOL_GPL(fsl_mc_object_free);
328338
....@@ -336,7 +346,7 @@
336346 * Initialize the interrupt pool associated with an fsl-mc bus.
337347 * It allocates a block of IRQs from the GIC-ITS.
338348 */
339
-int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus,
349
+int fsl_mc_populate_irq_pool(struct fsl_mc_device *mc_bus_dev,
340350 unsigned int irq_count)
341351 {
342352 unsigned int i;
....@@ -344,9 +354,13 @@
344354 struct fsl_mc_device_irq *irq_resources;
345355 struct fsl_mc_device_irq *mc_dev_irq;
346356 int error;
347
- struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
357
+ struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
348358 struct fsl_mc_resource_pool *res_pool =
349359 &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
360
+
361
+ /* do nothing if the IRQ pool is already populated */
362
+ if (mc_bus->irq_resources)
363
+ return 0;
350364
351365 if (irq_count == 0 ||
352366 irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS)
....@@ -399,9 +413,9 @@
399413 * Teardown the interrupt pool associated with an fsl-mc bus.
400414 * It frees the IRQs that were allocated to the pool, back to the GIC-ITS.
401415 */
402
-void fsl_mc_cleanup_irq_pool(struct fsl_mc_bus *mc_bus)
416
+void fsl_mc_cleanup_irq_pool(struct fsl_mc_device *mc_bus_dev)
403417 {
404
- struct fsl_mc_device *mc_bus_dev = &mc_bus->mc_dev;
418
+ struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
405419 struct fsl_mc_resource_pool *res_pool =
406420 &mc_bus->resource_pools[FSL_MC_POOL_IRQ];
407421