[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <ZLafnWuAlytSN7B+@shell.armlinux.org.uk>
Date: Tue, 18 Jul 2023 15:20:13 +0100
From: "Russell King (Oracle)" <linux@...linux.org.uk>
To: Vladimir Oltean <vladimir.oltean@....com>
Cc: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>,
Jakub Kicinski <kuba@...nel.org>,
Paolo Abeni <pabeni@...hat.com>, Andrew Lunn <andrew@...n.ch>,
Florian Fainelli <f.fainelli@...il.com>,
Maxim Georgiev <glipus@...il.com>,
Horatiu Vultur <horatiu.vultur@...rochip.com>,
Köry Maincent <kory.maincent@...tlin.com>,
Maxime Chevallier <maxime.chevallier@...tlin.com>,
Richard Cochran <richardcochran@...il.com>,
Vadim Fedorenko <vadim.fedorenko@...ux.dev>,
Gerhard Engleder <gerhard@...leder-embedded.com>,
Hangbin Liu <liuhangbin@...il.com>,
Heiner Kallweit <hkallweit1@...il.com>,
Jacob Keller <jacob.e.keller@...el.com>,
Jay Vosburgh <j.vosburgh@...il.com>,
Andy Gospodarek <andy@...yhouse.net>,
Wei Fang <wei.fang@....com>,
Shenwei Wang <shenwei.wang@....com>,
Clark Wang <xiaoning.wang@....com>,
NXP Linux Team <linux-imx@....com>,
UNGLinuxDriver@...rochip.com,
Lars Povlsen <lars.povlsen@...rochip.com>,
Steen Hegelund <Steen.Hegelund@...rochip.com>,
Daniel Machon <daniel.machon@...rochip.com>,
Simon Horman <simon.horman@...igine.com>,
Casper Andersson <casper.casan@...il.com>,
Sergey Organov <sorganov@...il.com>,
Michal Kubecek <mkubecek@...e.cz>,
linux-arm-kernel@...ts.infradead.org, linux-kernel@...r.kernel.org
Subject: Re: [PATCH v8 net-next 06/12] net: fec: convert to
ndo_hwtstamp_get() and ndo_hwtstamp_set()
On Mon, Jul 17, 2023 at 06:27:03PM +0300, Vladimir Oltean wrote:
> -static int fec_enet_ioctl(struct net_device *ndev, struct ifreq *rq, int cmd)
> -{
> - struct fec_enet_private *fep = netdev_priv(ndev);
> - struct phy_device *phydev = ndev->phydev;
> -
> - if (!netif_running(ndev))
> - return -EINVAL;
> -
> - if (!phydev)
> - return -ENODEV;
> -
... process hwtstamp calls
So if the network device is not running, ioctl() returns -EINVAL. From
what I can see in fec_enet_mii_probe() called from fec_enet_open(), we
guarantee that phydev will not be NULL once the first open has
succeeded, so I don't think the second if() statement has any effect.
> +static int fec_hwtstamp_get(struct net_device *ndev,
> + struct kernel_hwtstamp_config *config)
> +{
> + struct fec_enet_private *fep = netdev_priv(ndev);
> + struct phy_device *phydev = ndev->phydev;
> +
> + if (phy_has_hwtstamp(phydev))
> + return phy_mii_ioctl(phydev, config->ifr, SIOCGHWTSTAMP);
> +
> + if (!fep->bufdesc_ex)
> + return -EOPNOTSUPP;
If the interface hasn't been brought up at least once, then phydev
here will be NULL, and we'll drop through to this test. If the FEC
doesn't support extended buffer descriptors, userspace will see
-EOPNOTSUPP rather than -EINVAL. This could be misleading to userspace.
Does this need something like:
if (!netif_running(ndev))
return -EINVAL;
before, or maybe just after phy_has_hwtstamp() to give equivalent
behaviour?
> +static int fec_hwtstamp_set(struct net_device *ndev,
> + struct kernel_hwtstamp_config *config,
> + struct netlink_ext_ack *extack)
> +{
> + struct fec_enet_private *fep = netdev_priv(ndev);
> + struct phy_device *phydev = ndev->phydev;
> +
> + if (phy_has_hwtstamp(phydev)) {
> + fec_ptp_disable_hwts(ndev);
> +
> + return phy_mii_ioctl(phydev, config->ifr, SIOCSHWTSTAMP);
> + }
> +
> + if (!fep->bufdesc_ex)
> + return -EOPNOTSUPP;
Same comment here.
--
RMK's Patch system: https://www.armlinux.org.uk/developer/patches/
FTTP is here! 80Mbps down 10Mbps up. Decent connectivity at last!
Powered by blists - more mailing lists