Skip to content

Commit cc4342f

Browse files
miquelraynalkuba-moo
authored andcommitted
net: mvpp2: Defer probe if MAC address source is not yet ready
NVMEM layouts are no longer registered early, and thus may not yet be available when Ethernet drivers (or any other consumer) probe, leading to possible probe deferrals errors. Forward the error code if this happens. All other errors being discarded, the driver will eventually use a random MAC address if no other source was considered valid (no functional change on this regard). Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com> Reviewed-by: Marcin Wojtas <mw@semihalf.com> Link: https://lore.kernel.org/r/20230307192927.512757-1-miquel.raynal@bootlin.com Signed-off-by: Jakub Kicinski <kuba@kernel.org>
1 parent a133153 commit cc4342f

File tree

1 file changed

+16
-8
lines changed

1 file changed

+16
-8
lines changed

drivers/net/ethernet/marvell/mvpp2/mvpp2_main.c

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6081,38 +6081,44 @@ static bool mvpp2_port_has_irqs(struct mvpp2 *priv,
60816081
return true;
60826082
}
60836083

6084-
static void mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
6085-
struct fwnode_handle *fwnode,
6086-
char **mac_from)
6084+
static int mvpp2_port_copy_mac_addr(struct net_device *dev, struct mvpp2 *priv,
6085+
struct fwnode_handle *fwnode,
6086+
char **mac_from)
60876087
{
60886088
struct mvpp2_port *port = netdev_priv(dev);
60896089
char hw_mac_addr[ETH_ALEN] = {0};
60906090
char fw_mac_addr[ETH_ALEN];
6091+
int ret;
60916092

60926093
if (!fwnode_get_mac_address(fwnode, fw_mac_addr)) {
60936094
*mac_from = "firmware node";
60946095
eth_hw_addr_set(dev, fw_mac_addr);
6095-
return;
6096+
return 0;
60966097
}
60976098

60986099
if (priv->hw_version == MVPP21) {
60996100
mvpp21_get_mac_address(port, hw_mac_addr);
61006101
if (is_valid_ether_addr(hw_mac_addr)) {
61016102
*mac_from = "hardware";
61026103
eth_hw_addr_set(dev, hw_mac_addr);
6103-
return;
6104+
return 0;
61046105
}
61056106
}
61066107

61076108
/* Only valid on OF enabled platforms */
6108-
if (!of_get_mac_address_nvmem(to_of_node(fwnode), fw_mac_addr)) {
6109+
ret = of_get_mac_address_nvmem(to_of_node(fwnode), fw_mac_addr);
6110+
if (ret == -EPROBE_DEFER)
6111+
return ret;
6112+
if (!ret) {
61096113
*mac_from = "nvmem cell";
61106114
eth_hw_addr_set(dev, fw_mac_addr);
6111-
return;
6115+
return 0;
61126116
}
61136117

61146118
*mac_from = "random";
61156119
eth_hw_addr_random(dev);
6120+
6121+
return 0;
61166122
}
61176123

61186124
static struct mvpp2_port *mvpp2_phylink_to_port(struct phylink_config *config)
@@ -6815,7 +6821,9 @@ static int mvpp2_port_probe(struct platform_device *pdev,
68156821
mutex_init(&port->gather_stats_lock);
68166822
INIT_DELAYED_WORK(&port->stats_work, mvpp2_gather_hw_statistics);
68176823

6818-
mvpp2_port_copy_mac_addr(dev, priv, port_fwnode, &mac_from);
6824+
err = mvpp2_port_copy_mac_addr(dev, priv, port_fwnode, &mac_from);
6825+
if (err < 0)
6826+
goto err_free_stats;
68196827

68206828
port->tx_ring_size = MVPP2_MAX_TXD_DFLT;
68216829
port->rx_ring_size = MVPP2_MAX_RXD_DFLT;

0 commit comments

Comments
 (0)