Skip to content

Commit 2de74c2

Browse files
IoanaCiorneigregkh
authored andcommitted
bus: fsl-mc: do not add a device-link for the UAPI used DPMCP device
commit dd7d8e0 upstream. The fsl-mc bus associated to the root DPRC in a DPAA2 system exports a device file for userspace access to the MC firmware. In case the DPRC's local MC portal (DPMCP) is currently in use, a new DPMCP device is allocated through the fsl_mc_portal_allocate() function. In this case, the call to fsl_mc_portal_allocate() will fail with -EINVAL when trying to add a device link between the root DPRC (consumer) and the newly allocated DPMCP device (supplier). This is because the DPMCP is a dependent of the DPRC device (the bus). Fix this by not adding a device link in case the DPMCP is allocated for the root DPRC's usage. Fixes: afb7742 ("bus: fsl-mc: automatically add a device_link on fsl_mc_[portal,object]_allocate") Signed-off-by: Ioana Ciornei <[email protected]> Cc: [email protected] Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Christophe Leroy <[email protected]> Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent 4d0686b commit 2de74c2

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

drivers/bus/fsl-mc/mc-io.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -214,12 +214,19 @@ int __must_check fsl_mc_portal_allocate(struct fsl_mc_device *mc_dev,
214214
if (error < 0)
215215
goto error_cleanup_resource;
216216

217-
dpmcp_dev->consumer_link = device_link_add(&mc_dev->dev,
218-
&dpmcp_dev->dev,
219-
DL_FLAG_AUTOREMOVE_CONSUMER);
220-
if (!dpmcp_dev->consumer_link) {
221-
error = -EINVAL;
222-
goto error_cleanup_mc_io;
217+
/* If the DPRC device itself tries to allocate a portal (usually for
218+
* UAPI interaction), don't add a device link between them since the
219+
* DPMCP device is an actual child device of the DPRC and a reverse
220+
* dependency is not allowed.
221+
*/
222+
if (mc_dev != mc_bus_dev) {
223+
dpmcp_dev->consumer_link = device_link_add(&mc_dev->dev,
224+
&dpmcp_dev->dev,
225+
DL_FLAG_AUTOREMOVE_CONSUMER);
226+
if (!dpmcp_dev->consumer_link) {
227+
error = -EINVAL;
228+
goto error_cleanup_mc_io;
229+
}
223230
}
224231

225232
*new_mc_io = mc_io;

0 commit comments

Comments
 (0)