layerscape: add ls1088ardb device support
[openwrt/staging/lynxis/omap.git] / target / linux / layerscape / patches-4.4 / 7192-staging-fsl-mc-Propagate-driver_override-for-a-child.patch
1 From 2b9110586a96afc0d0e246835da176c48ae7c973 Mon Sep 17 00:00:00 2001
2 From: "J. German Rivera" <German.Rivera@freescale.com>
3 Date: Fri, 13 Mar 2015 15:03:32 -0500
4 Subject: [PATCH 192/226] staging: fsl-mc: Propagate driver_override for a
5 child DPRC's children
6
7 When a child DPRC is bound to the vfio_fsl_mc driver via driver_override,
8 its own children should not be bound to corresponding host kernel
9 drivers, but instead should be bound to the vfio_fsl_mc driver as
10 well.
11
12 Currently, when a child container is scanned by the vfio_fsl_mc driver,
13 child devices found are automatically bound to corresponding host kernel
14 drivers (e.g., DPMCP and DPBP objects are bound to the fsl_mc_allocator
15 driver, DPNI objects are bound to the ldpaa_eth driver, etc), Then,
16 the user has to manually unbind these child devices from their drivers,
17 set the driver_override sysfs attribute to vfio_fsl_mc driver, for each
18 of them and rebind them.
19
20 Signed-off-by: J. German Rivera <German.Rivera@freescale.com>
21 Signed-off-by: Stuart Yoder <stuart.yoder@nxp.com>
22 ---
23 drivers/staging/fsl-mc/bus/dprc-driver.c | 14 ++++++++++----
24 drivers/staging/fsl-mc/bus/mc-bus.c | 20 +++++++++++++++++---
25 drivers/staging/fsl-mc/include/mc-private.h | 2 ++
26 drivers/staging/fsl-mc/include/mc.h | 2 ++
27 4 files changed, 31 insertions(+), 7 deletions(-)
28
29 --- a/drivers/staging/fsl-mc/bus/dprc-driver.c
30 +++ b/drivers/staging/fsl-mc/bus/dprc-driver.c
31 @@ -152,6 +152,8 @@ static void check_plugged_state_change(s
32 * dprc_add_new_devices - Adds devices to the logical bus for a DPRC
33 *
34 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
35 + * @driver_override: driver override to apply to new objects found in the DPRC,
36 + * or NULL, if none.
37 * @obj_desc_array: array of device descriptors for child devices currently
38 * present in the physical DPRC.
39 * @num_child_objects_in_mc: number of entries in obj_desc_array
40 @@ -161,6 +163,7 @@ static void check_plugged_state_change(s
41 * in the physical DPRC.
42 */
43 static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
44 + const char *driver_override,
45 struct dprc_obj_desc *obj_desc_array,
46 int num_child_objects_in_mc)
47 {
48 @@ -184,7 +187,7 @@ static void dprc_add_new_devices(struct
49 }
50
51 error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
52 - &child_dev);
53 + driver_override, &child_dev);
54 if (error < 0)
55 continue;
56 }
57 @@ -243,6 +246,8 @@ static void dprc_cleanup_all_resource_po
58 * dprc_scan_objects - Discover objects in a DPRC
59 *
60 * @mc_bus_dev: pointer to the fsl-mc device that represents a DPRC object
61 + * @driver_override: driver override to apply to new objects found in the DPRC,
62 + * or NULL, if none.
63 * @total_irq_count: total number of IRQs needed by objects in the DPRC.
64 *
65 * Detects objects added and removed from a DPRC and synchronizes the
66 @@ -258,6 +263,7 @@ static void dprc_cleanup_all_resource_po
67 * of the device drivers for the non-allocatable devices.
68 */
69 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
70 + const char *driver_override,
71 unsigned int *total_irq_count)
72 {
73 int num_child_objects;
74 @@ -338,7 +344,7 @@ int dprc_scan_objects(struct fsl_mc_devi
75 dprc_remove_devices(mc_bus_dev, child_obj_desc_array,
76 num_child_objects);
77
78 - dprc_add_new_devices(mc_bus_dev, child_obj_desc_array,
79 + dprc_add_new_devices(mc_bus_dev, driver_override, child_obj_desc_array,
80 num_child_objects);
81
82 if (child_obj_desc_array)
83 @@ -369,7 +375,7 @@ int dprc_scan_container(struct fsl_mc_de
84 * Discover objects in the DPRC:
85 */
86 mutex_lock(&mc_bus->scan_mutex);
87 - error = dprc_scan_objects(mc_bus_dev, &irq_count);
88 + error = dprc_scan_objects(mc_bus_dev, NULL, &irq_count);
89 mutex_unlock(&mc_bus->scan_mutex);
90 if (error < 0)
91 goto error;
92 @@ -456,7 +462,7 @@ static irqreturn_t dprc_irq0_handler_thr
93 DPRC_IRQ_EVENT_OBJ_CREATED)) {
94 unsigned int irq_count;
95
96 - error = dprc_scan_objects(mc_dev, &irq_count);
97 + error = dprc_scan_objects(mc_dev, NULL, &irq_count);
98 if (error < 0) {
99 /*
100 * If the error is -ENXIO, we ignore it, as it indicates
101 --- a/drivers/staging/fsl-mc/bus/mc-bus.c
102 +++ b/drivers/staging/fsl-mc/bus/mc-bus.c
103 @@ -116,7 +116,7 @@ static ssize_t rescan_store(struct devic
104
105 if (val) {
106 mutex_lock(&root_mc_bus->scan_mutex);
107 - dprc_scan_objects(root_mc_dev, &irq_count);
108 + dprc_scan_objects(root_mc_dev, NULL, &irq_count);
109 mutex_unlock(&root_mc_bus->scan_mutex);
110 }
111
112 @@ -149,7 +149,7 @@ static int scan_fsl_mc_bus(struct device
113 root_mc_dev = to_fsl_mc_device(dev);
114 root_mc_bus = to_fsl_mc_bus(root_mc_dev);
115 mutex_lock(&root_mc_bus->scan_mutex);
116 - dprc_scan_objects(root_mc_dev, &irq_count);
117 + dprc_scan_objects(root_mc_dev, NULL, &irq_count);
118 mutex_unlock(&root_mc_bus->scan_mutex);
119 }
120
121 @@ -503,6 +503,7 @@ bool fsl_mc_is_root_dprc(struct device *
122 int fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
123 struct fsl_mc_io *mc_io,
124 struct device *parent_dev,
125 + const char *driver_override,
126 struct fsl_mc_device **new_mc_dev)
127 {
128 int error;
129 @@ -535,6 +536,18 @@ int fsl_mc_device_add(struct dprc_obj_de
130
131 mc_dev->obj_desc = *obj_desc;
132 mc_dev->mc_io = mc_io;
133 + if (driver_override) {
134 + /*
135 + * We trust driver_override, so we don't need to use
136 + * kstrndup() here
137 + */
138 + mc_dev->driver_override = kstrdup(driver_override, GFP_KERNEL);
139 + if (!mc_dev->driver_override) {
140 + error = -ENOMEM;
141 + goto error_cleanup_dev;
142 + }
143 + }
144 +
145 device_initialize(&mc_dev->dev);
146 mc_dev->dev.parent = parent_dev;
147 mc_dev->dev.bus = &fsl_mc_bus_type;
148 @@ -858,7 +871,8 @@ static int fsl_mc_bus_probe(struct platf
149 obj_desc.irq_count = 1;
150 obj_desc.region_count = 0;
151
152 - error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, &mc_bus_dev);
153 + error = fsl_mc_device_add(&obj_desc, mc_io, &pdev->dev, NULL,
154 + &mc_bus_dev);
155 if (error < 0)
156 goto error_cleanup_mc_io;
157
158 --- a/drivers/staging/fsl-mc/include/mc-private.h
159 +++ b/drivers/staging/fsl-mc/include/mc-private.h
160 @@ -110,6 +110,7 @@ struct fsl_mc_bus {
161 int __must_check fsl_mc_device_add(struct dprc_obj_desc *obj_desc,
162 struct fsl_mc_io *mc_io,
163 struct device *parent_dev,
164 + const char *driver_override,
165 struct fsl_mc_device **new_mc_dev);
166
167 void fsl_mc_device_remove(struct fsl_mc_device *mc_dev);
168 @@ -117,6 +118,7 @@ void fsl_mc_device_remove(struct fsl_mc_
169 int dprc_scan_container(struct fsl_mc_device *mc_bus_dev);
170
171 int dprc_scan_objects(struct fsl_mc_device *mc_bus_dev,
172 + const char *driver_override,
173 unsigned int *total_irq_count);
174
175 int __init dprc_driver_init(void);
176 --- a/drivers/staging/fsl-mc/include/mc.h
177 +++ b/drivers/staging/fsl-mc/include/mc.h
178 @@ -129,6 +129,7 @@ struct fsl_mc_device_irq {
179 * @regions: pointer to array of MMIO region entries
180 * @irqs: pointer to array of pointers to interrupts allocated to this device
181 * @resource: generic resource associated with this MC object device, if any.
182 + * @driver_override: Driver name to force a match
183 *
184 * Generic device object for MC object devices that are "attached" to a
185 * MC bus.
186 @@ -161,6 +162,7 @@ struct fsl_mc_device {
187 struct resource *regions;
188 struct fsl_mc_device_irq **irqs;
189 struct fsl_mc_resource *resource;
190 + const char *driver_override;
191 };
192
193 #define to_fsl_mc_device(_dev) \