RE: [PATCH net-next] net: enetc: use generic interfaces to get phc_index for ENETC v1

From: Wei Fang

Date: Thu Sep 18 2025 - 22:02:27 EST


> On Thu, Sep 18, 2025 at 03:44:54PM +0800, Wei Fang wrote:
> > @@ -954,17 +957,9 @@ static int enetc_get_ts_info(struct net_device
> *ndev,
> > if (!enetc_ptp_clock_is_enabled(si))
> > goto timestamp_tx_sw;
> >
> > - if (is_enetc_rev1(si)) {
> > - phc_idx = symbol_get(enetc_phc_index);
> > - if (phc_idx) {
> > - info->phc_index = *phc_idx;
>
> phc_idx remains unused in enetc_get_ts_info() after this change, and it
> produces a build warning.

Oh, I missed the build warning, sorry.

>
> > - symbol_put(enetc_phc_index);
> > - }
> > - } else {
> > - info->phc_index = enetc4_get_phc_index(si);
> > - if (info->phc_index < 0)
> > - goto timestamp_tx_sw;
> > - }
> > + info->phc_index = enetc_get_phc_index(si);
> > + if (info->phc_index < 0)
> > + goto timestamp_tx_sw;
> >
> > enetc_get_ts_generic_info(ndev, info);
> >
>
> It looks like we have a problem and can't call pci_get_slot(), which
> sleeps on down_read(&pci_bus_sem), from ethtool_ops :: get_ts_info(),
> which can't sleep, as of commit 4c61d809cf60 ("net: ethtool: Fix
> suspicious rcu_dereference usage").
>

Thanks for catching this issue. CONFIG_DEBUG_ATOMIC_SLEEP was not
enabled in my config file, so I did not see this issue on both i.MX95 and
LS1028A. :(

The introduction of rcu_read_lock() in __ethtool_get_ts_info() makes
the device drivers cannot use any functions which might sleep, I do not
have an idea to fix this issue in the upper layer. Currently, I can use
pci_get_domain_bus_and_slot() to instead of pci_get_slot() to fix this
issue in the enetc driver.

> pw-bot: cr