Skip to content

Commit 4e30e98

Browse files
IoanaCiorneikuba-moo
authored andcommitted
dpaa2-mac: return -EPROBE_DEFER from dpaa2_mac_open in case the fwnode is not set
We could get into a situation when the fwnode of the parent device is not yet set because its probe didn't yet finish. When this happens, any caller of the dpaa2_mac_open() will not have the fwnode available, thus cause problems at the PHY connect time. Avoid this by just returning -EPROBE_DEFER from the dpaa2_mac_open when this happens. Signed-off-by: Ioana Ciornei <[email protected]> Signed-off-by: Jakub Kicinski <[email protected]>
1 parent 5b1e38c commit 4e30e98

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

drivers/net/ethernet/freescale/dpaa2/dpaa2-mac.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ static struct fwnode_handle *dpaa2_mac_get_node(struct device *dev,
5454
parent = of_fwnode_handle(dpmacs);
5555
} else if (is_acpi_node(fwnode)) {
5656
parent = fwnode;
57+
} else {
58+
/* The root dprc device didn't yet get to finalize it's probe,
59+
* thus the fwnode field is not yet set. Defer probe if we are
60+
* facing this situation.
61+
*/
62+
return ERR_PTR(-EPROBE_DEFER);
5763
}
5864

5965
if (!parent)
@@ -330,6 +336,7 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
330336
{
331337
struct fsl_mc_device *dpmac_dev = mac->mc_dev;
332338
struct net_device *net_dev = mac->net_dev;
339+
struct fwnode_handle *fw_node;
333340
int err;
334341

335342
err = dpmac_open(mac->mc_io, 0, dpmac_dev->obj_desc.id,
@@ -349,7 +356,13 @@ int dpaa2_mac_open(struct dpaa2_mac *mac)
349356
/* Find the device node representing the MAC device and link the device
350357
* behind the associated netdev to it.
351358
*/
352-
mac->fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
359+
fw_node = dpaa2_mac_get_node(&mac->mc_dev->dev, mac->attr.id);
360+
if (IS_ERR(fw_node)) {
361+
err = PTR_ERR(fw_node);
362+
goto err_close_dpmac;
363+
}
364+
365+
mac->fw_node = fw_node;
353366
net_dev->dev.of_node = to_of_node(mac->fw_node);
354367

355368
return 0;

0 commit comments

Comments
 (0)