layerscape: make uImage with zImage for 32-bit kernel
[openwrt/openwrt.git] / target / linux / layerscape / patches-4.4 / 7149-staging-fsl-mc-Populate-the-IRQ-pool-for-an-MC-bus-i.patch
1 From 78ab7589777526022757e9c95b9d5864786eb4e5 Mon Sep 17 00:00:00 2001
2 From: "J. German Rivera" <German.Rivera@freescale.com>
3 Date: Wed, 6 Jan 2016 16:03:25 -0600
4 Subject: [PATCH 149/226] staging: fsl-mc: Populate the IRQ pool for an MC bus
5 instance
6
7 Scan the corresponding DPRC container to get total count
8 of IRQs needed by all its child DPAA2 objects. Then,
9 preallocate a set of MSI IRQs with the DPRC's ICID
10 (GIT-ITS device Id) to populate the the DPRC's IRQ pool.
11 Each child DPAA2 object in the DPRC and the DPRC object itself
12 will allocate their necessary MSI IRQs from the DPRC's IRQ pool,
13 in their driver probe function.
14
15 Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
16 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
17 ---
18 drivers/staging/fsl-mc/bus/dprc-driver.c | 24 ++++++++++++++++++++++--
19 drivers/staging/fsl-mc/include/mc-private.h | 3 ++-
20 2 files changed, 24 insertions(+), 3 deletions(-)
21
22 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
23 +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
24 @@ -241,6 +241,7 @@ static void dprc_cleanup_all_resource_po
25 * dprc_scan_objects - Discover objects in a DPRC
26 *
27 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
28 + * @total_irq_count: total number of IRQs needed by objects in the DPRC.
29 *
30 * Detects objects added and removed from a DPRC and synchronizes the
31 * state of the Linux bus driver, MC by adding and removing
32 @@ -254,11 +255,13 @@ static void dprc_cleanup_all_resource_po
33 * populated before they can get allocation requests from probe callbacks
34 * of the device drivers for the non-allocatable devices.
35 */
36 -int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev)
37 +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
38 + unsigned int *total_irq_count)
39 {
40 int num_child_objects;
41 int dprc_get_obj_failures;
42 int error;
43 + unsigned int irq_count = mc_bus_dev->obj_desc.irq_count;
44 struct dprc_obj_desc *child_obj_desc_array = NULL;
45
46 error = dprc_get_obj_count(mc_bus_dev->mc_io,
47 @@ -307,6 +310,7 @@ int dprc_scan_objects(struct fsl_mc_devi
48 continue;
49 }
50
51 + irq_count += obj_desc->irq_count;
52 dev_dbg(&mc_bus_dev->dev,
53 "Discovered object: type %s, id %d\n",
54 obj_desc->type, obj_desc->id);
55 @@ -319,6 +323,7 @@ int dprc_scan_objects(struct fsl_mc_devi
56 }
57 }
58
59 + *total_irq_count = irq_count;
60 dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
61 num_child_objects);
62
63 @@ -344,6 +349,7 @@ EXPORT_SYMBOL_GPL(dprc_scan_objects);
64 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev)
65 {
66 int error;
67 + unsigned int irq_count;
68 struct fsl_mc_bus *mc_bus = to_fsl_mc_bus(mc_bus_dev);
69
70 dprc_init_all_resource_pools(mc_bus_dev);
71 @@ -352,11 +358,25 @@ int dprc_scan_container(struct fsl_mc_de
72 * Discover objects in the DPRC:
73 */
74 mutex_lock(&mc_bus->scan_mutex);
75 - error = dprc_scan_objects(mc_bus_dev);
76 + error = dprc_scan_objects(mc_bus_dev, &irq_count);
77 mutex_unlock(&mc_bus->scan_mutex);
78 if (error < 0)
79 goto error;
80
81 + if (dev_get_msi_domain(&mc_bus_dev->dev) && !mc_bus->irq_resources) {
82 + if (irq_count > FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS) {
83 + dev_warn(&mc_bus_dev->dev,
84 + "IRQs needed (%u) exceed IRQs preallocated (%u)\n",
85 + irq_count, FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
86 + }
87 +
88 + error = fsl_mc_populate_irq_pool(
89 + mc_bus,
90 + FSL_MC_IRQ_POOL_MAX_TOTAL_IRQS);
91 + if (error < 0)
92 + goto error;
93 + }
94 +
95 return 0;
96 error:
97 dprc_cleanup_all_resource_pools(mc_bus_dev);
98 --- a/drivers/staging/fsl-mc/include/mc-private.h
99 +++ b/drivers/staging/fsl-mc/include/mc-private.h
100 @@ -114,7 +114,8 @@ void fsl_mc_device_remove(struct fsl_mc_
101
102 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
103
104 -int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev);
105 +int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
106 + unsigned int *total_irq_count);
107
108 int __init dprc_driver_init(void);
109