Skip to content

Commit 20f7151

Browse files
Grigore Popescugregkh
authored andcommitted
bus: fsl-mc: probe the allocatable objects first
Because the DPNIs are probed before DPMCPs and other objects that need to be allocated, messages like "No more resources of type X left" are printed by the fsl-mc bus driver. This patch resolves the issue by probing the allocatable objects first and then any other object that may use them. Signed-off-by: Grigore Popescu <grigore.popescu@nxp.com> Signed-off-by: Ioana Ciornei <ioana.ciornei@nxp.com> Reviewed-by: Laurentiu Tudor <laurentiu.tudor@nxp.com> Link: https://lore.kernel.org/r/20200717154800.17169-4-ioana.ciornei@nxp.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent 9a872de commit 20f7151

1 file changed

Lines changed: 40 additions & 17 deletions

File tree

‎drivers/bus/fsl-mc/dprc-driver.c‎

Lines changed: 40 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,16 @@ static bool fsl_mc_device_match(struct fsl_mc_device *mc_dev,
2727
{
2828
return mc_dev->obj_desc.id == obj_desc->id &&
2929
strcmp(mc_dev->obj_desc.type, obj_desc->type) == 0;
30+
}
3031

32+
static bool fsl_mc_obj_desc_is_allocatable(struct fsl_mc_obj_desc *obj)
33+
{
34+
if (strcmp(obj->type, "dpmcp") == 0 ||
35+
strcmp(obj->type, "dpcon") == 0 ||
36+
strcmp(obj->type, "dpbp") == 0)
37+
return true;
38+
else
39+
return false;
3140
}
3241

3342
static int __fsl_mc_device_remove_if_not_in_mc(struct device *dev, void *data)
@@ -150,6 +159,27 @@ static void check_plugged_state_change(struct fsl_mc_device *mc_dev,
150159
}
151160
}
152161

162+
static void fsl_mc_obj_device_add(struct fsl_mc_device *mc_bus_dev,
163+
struct fsl_mc_obj_desc *obj_desc)
164+
{
165+
int error;
166+
struct fsl_mc_device *child_dev;
167+
168+
/*
169+
* Check if device is already known to Linux:
170+
*/
171+
child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
172+
if (child_dev) {
173+
check_plugged_state_change(child_dev, obj_desc);
174+
put_device(&child_dev->dev);
175+
} else {
176+
error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
177+
&child_dev);
178+
if (error < 0)
179+
return;
180+
}
181+
}
182+
153183
/**
154184
* dprc_add_new_devices - Adds devices to the logical bus for a DPRC
155185
*
@@ -166,30 +196,23 @@ static void dprc_add_new_devices(struct fsl_mc_device *mc_bus_dev,
166196
struct fsl_mc_obj_desc *obj_desc_array,
167197
int num_child_objects_in_mc)
168198
{
169-
int error;
170199
int i;
171200

201+
/* probe the allocable objects first */
172202
for (i = 0; i < num_child_objects_in_mc; i++) {
173-
struct fsl_mc_device *child_dev;
174203
struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i];
175204

176-
if (strlen(obj_desc->type) == 0)
177-
continue;
205+
if (strlen(obj_desc->type) > 0 &&
206+
fsl_mc_obj_desc_is_allocatable(obj_desc))
207+
fsl_mc_obj_device_add(mc_bus_dev, obj_desc);
208+
}
178209

179-
/*
180-
* Check if device is already known to Linux:
181-
*/
182-
child_dev = fsl_mc_device_lookup(obj_desc, mc_bus_dev);
183-
if (child_dev) {
184-
check_plugged_state_change(child_dev, obj_desc);
185-
put_device(&child_dev->dev);
186-
continue;
187-
}
210+
for (i = 0; i < num_child_objects_in_mc; i++) {
211+
struct fsl_mc_obj_desc *obj_desc = &obj_desc_array[i];
188212

189-
error = fsl_mc_device_add(obj_desc, NULL, &mc_bus_dev->dev,
190-
&child_dev);
191-
if (error < 0)
192-
continue;
213+
if (strlen(obj_desc->type) > 0 &&
214+
!fsl_mc_obj_desc_is_allocatable(obj_desc))
215+
fsl_mc_obj_device_add(mc_bus_dev, obj_desc);
193216
}
194217
}
195218

0 commit comments

Comments
 (0)