Skip to content

Commit d7f5a9d

Browse files
IoanaCiorneidavem330
authored andcommitted
dpaa2-eth: defer probe on object allocate
The fsl_mc_object_allocate function can fail because not all allocatable objects are probed by the fsl_mc_allocator at the call time. Defer the dpaa2-eth probe when this happens. Signed-off-by: Ioana Ciornei <[email protected]> Reviewed-by: Andrew Lunn <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 029a374 commit d7f5a9d

File tree

1 file changed

+22
-10
lines changed

1 file changed

+22
-10
lines changed

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

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1434,8 +1434,11 @@ static struct fsl_mc_device *setup_dpcon(struct dpaa2_eth_priv *priv)
14341434
err = fsl_mc_object_allocate(to_fsl_mc_device(dev),
14351435
FSL_MC_POOL_DPCON, &dpcon);
14361436
if (err) {
1437-
dev_info(dev, "Not enough DPCONs, will go on as-is\n");
1438-
return NULL;
1437+
if (err == -ENXIO)
1438+
err = -EPROBE_DEFER;
1439+
else
1440+
dev_info(dev, "Not enough DPCONs, will go on as-is\n");
1441+
return ERR_PTR(err);
14391442
}
14401443

14411444
err = dpcon_open(priv->mc_io, 0, dpcon->obj_desc.id, &dpcon->mc_handle);
@@ -1493,8 +1496,10 @@ alloc_channel(struct dpaa2_eth_priv *priv)
14931496
return NULL;
14941497

14951498
channel->dpcon = setup_dpcon(priv);
1496-
if (!channel->dpcon)
1499+
if (IS_ERR_OR_NULL(channel->dpcon)) {
1500+
err = PTR_ERR(channel->dpcon);
14971501
goto err_setup;
1502+
}
14981503

14991504
err = dpcon_get_attributes(priv->mc_io, 0, channel->dpcon->mc_handle,
15001505
&attr);
@@ -1513,7 +1518,7 @@ alloc_channel(struct dpaa2_eth_priv *priv)
15131518
free_dpcon(priv, channel->dpcon);
15141519
err_setup:
15151520
kfree(channel);
1516-
return NULL;
1521+
return ERR_PTR(err);
15171522
}
15181523

15191524
static void free_channel(struct dpaa2_eth_priv *priv,
@@ -1547,10 +1552,11 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
15471552
for_each_online_cpu(i) {
15481553
/* Try to allocate a channel */
15491554
channel = alloc_channel(priv);
1550-
if (!channel) {
1551-
dev_info(dev,
1552-
"No affine channel for cpu %d and above\n", i);
1553-
err = -ENODEV;
1555+
if (IS_ERR_OR_NULL(channel)) {
1556+
err = PTR_ERR(channel);
1557+
if (err != -EPROBE_DEFER)
1558+
dev_info(dev,
1559+
"No affine channel for cpu %d and above\n", i);
15541560
goto err_alloc_ch;
15551561
}
15561562

@@ -1608,9 +1614,12 @@ static int setup_dpio(struct dpaa2_eth_priv *priv)
16081614
err_service_reg:
16091615
free_channel(priv, channel);
16101616
err_alloc_ch:
1617+
if (err == -EPROBE_DEFER)
1618+
return err;
1619+
16111620
if (cpumask_empty(&priv->dpio_cpumask)) {
16121621
dev_err(dev, "No cpu with an affine DPIO/DPCON\n");
1613-
return err;
1622+
return -ENODEV;
16141623
}
16151624

16161625
dev_info(dev, "Cores %*pbl available for processing ingress traffic\n",
@@ -1732,7 +1741,10 @@ static int setup_dpbp(struct dpaa2_eth_priv *priv)
17321741
err = fsl_mc_object_allocate(to_fsl_mc_device(dev), FSL_MC_POOL_DPBP,
17331742
&dpbp_dev);
17341743
if (err) {
1735-
dev_err(dev, "DPBP device allocation failed\n");
1744+
if (err == -ENXIO)
1745+
err = -EPROBE_DEFER;
1746+
else
1747+
dev_err(dev, "DPBP device allocation failed\n");
17361748
return err;
17371749
}
17381750

0 commit comments

Comments
 (0)