From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-1.web.codeaurora.org [10.30.226.201]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id C9E4B27469 for ; Tue, 10 Oct 2023 15:52:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="kv2I+KjX" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 071C4C433C8; Tue, 10 Oct 2023 15:52:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1696953135; bh=mYZCwt5HRNSmbVd7qcD/9Qla13X/6gnoEYkfuSGghUY=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kv2I+KjXv/r2Lpzhy1Ct+G1P/C2p2lqypWtlwBCoeZ0IX/mTE/cPoNVQHnlaKrLwi qiBGBHav0u5KwcjCJk8Q4g5y2kQeeBdEupLj3JauKg/qgDnhA2cw8cDV0vMPWAHOeG aHmzGfXCyYLG8UY2OaLGUOBAeYv8vc9sJB31raW+PA7rnO9O3zGhwbP81ILhYXS/pw XAbjPci4l+KKKOCObXn9fkViSN2mdL2gN2vj0X+HffreB8uC8vKHWySwY0gD3s8/Tx RBoIut1LVpaemqXF3QWM7Y9uVLY9ic4ip90zarm+BeTmZTDV83deQ4RfHhNeisfuet QuT8Te/zuFBEg== Date: Tue, 10 Oct 2023 17:52:08 +0200 From: Simon Horman To: =?utf-8?B?S8O2cnk=?= Maincent Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org, linux-doc@vger.kernel.org, Thomas Petazzoni , "David S . Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Jonathan Corbet , Jay Vosburgh , Andy Gospodarek , Nicolas Ferre , Claudiu Beznea , Horatiu Vultur , UNGLinuxDriver@microchip.com, Florian Fainelli , Broadcom internal kernel review list , Andrew Lunn , Heiner Kallweit , Russell King , Richard Cochran , Radu Pirea , Willem de Bruijn , Vladimir Oltean , Michael Walle , Jacob Keller , Maxime Chevallier Subject: Re: [PATCH net-next v5 13/16] net: Change the API of PHY default timestamp to MAC Message-ID: References: <20231009155138.86458-1-kory.maincent@bootlin.com> <20231009155138.86458-14-kory.maincent@bootlin.com> Precedence: bulk X-Mailing-List: netdev@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231009155138.86458-14-kory.maincent@bootlin.com> On Mon, Oct 09, 2023 at 05:51:35PM +0200, Köry Maincent wrote: Hi Köry, some minor feedback from my side. ... > diff --git a/drivers/net/phy/phy_device.c b/drivers/net/phy/phy_device.c > index 2ce74593d6e4..2d5a6d57acb3 100644 > --- a/drivers/net/phy/phy_device.c > +++ b/drivers/net/phy/phy_device.c > @@ -1411,6 +1411,68 @@ int phy_sfp_probe(struct phy_device *phydev, > } > EXPORT_SYMBOL(phy_sfp_probe); > > +/* An allowlist for PHYs selected as default timesetamping. > + * Its use is to keep compatibility with old PTP API which is selecting > + * these PHYs as default timestamping. > + * The new API is selecting the MAC as default timestamping. > + */ > +const char * const phy_timestamping_allowlist[] = { Should this be static? As flagged by Sparse. > + "Broadcom BCM5411", > + "Broadcom BCM5421", > + "Broadcom BCM54210E", > + "Broadcom BCM5461", > + "Broadcom BCM54612E", > + "Broadcom BCM5464", > + "Broadcom BCM5481", > + "Broadcom BCM54810", > + "Broadcom BCM54811", > + "Broadcom BCM5482", > + "Broadcom BCM50610", > + "Broadcom BCM50610M", > + "Broadcom BCM57780", > + "Broadcom BCM5395", > + "Broadcom BCM53125", > + "Broadcom BCM53128", > + "Broadcom BCM89610", > + "NatSemi DP83640", > + "Microchip LAN8841 Gigabit PHY", > + "Microchip INDY Gigabit Quad PHY", > + "Microsemi GE VSC856X SyncE", > + "Microsemi GE VSC8575 SyncE", > + "Microsemi GE VSC8582 SyncE", > + "Microsemi GE VSC8584 SyncE", > + "NXP C45 TJA1103", > + NULL, > +}; > + > +/** > + * phy_set_timestamp - set the default selected timestamping device > + * @dev: Pointer to net_device > + * @phydev: Pointer to phy_device > + * > + * This is used to set default timestamping device taking into account > + * the new API choice, which is selecting the timestamping from MAC by > + * default. > + */ ... > @@ -1484,6 +1546,7 @@ int phy_attach_direct(struct net_device *dev, struct phy_device *phydev, > > phydev->phy_link_change = phy_link_change; > if (dev) { > + phy_set_timestamp(dev, phydev); > phydev->attached_dev = dev; > dev->phydev = phydev; > > @@ -1794,6 +1857,7 @@ EXPORT_SYMBOL_GPL(devm_phy_package_join); > void phy_detach(struct phy_device *phydev) > { > struct net_device *dev = phydev->attached_dev; > + const struct ethtool_ops *ops = dev->ethtool_ops; Elsewhere in this function it is assumed that dev may be NULL. But here it is dereferenced unconditionally. As flagged by Smatch. > struct module *ndev_owner = NULL; > struct mii_bus *bus; > > @@ -1812,6 +1876,10 @@ void phy_detach(struct phy_device *phydev) > > phy_suspend(phydev); > if (dev) { > + if (ops->get_ts_info) > + dev->ts_layer = NETDEV_TIMESTAMPING; > + else > + dev->ts_layer = NO_TIMESTAMPING; > phydev->attached_dev->phydev = NULL; > phydev->attached_dev = NULL; > } ...