Received: by 2002:a05:7412:d8a:b0:e2:908c:2ebd with SMTP id b10csp236595rdg; Tue, 10 Oct 2023 08:52:32 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEcfzt86E0K+i5HwLdvQXpZPp7ab9tlU3g+NpukkpODO+YWiYYDdNh6CFqc5ZJOHz2q4P/i X-Received: by 2002:a05:6a00:2d1d:b0:68f:ece2:ac3b with SMTP id fa29-20020a056a002d1d00b0068fece2ac3bmr17216126pfb.5.1696953152427; Tue, 10 Oct 2023 08:52:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696953152; cv=none; d=google.com; s=arc-20160816; b=S0RYyN+Fjv20XTW0x+1QCVPRlhGceF6c0/wBHDC/u3+spCj0N0DIFa5zfC8CrwEOQp iZLFgqvpxfQyvH8gX49uISq8PyTm68nE1evT01tZ+NeyaNnZ5W+k0cXrxIwN9sAvw+gu YvydH0/SbfyfKRsiDJvj5jgXX20bAS/W11esyT4uoHRn4UyuoMMHxXn4eCHh7t6Wkdru bAxDRvEyE5CcMc+hdBtVHApBBU+r7VjTN6mXEMRysv64MoY67+sEF+gEDhaPPzqabEE4 0tU0JPqgordnOfJEIcSi8dTgONJCop4MKkp5PaF993o/g1jrXo5e9HjG1ZF5mEKtA7Vl wagA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-transfer-encoding :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:dkim-signature; bh=xW0LtTkFDJc3tcSNwRWR03ZkjcQ/Rs1DArqjRWWMWrQ=; fh=jrLK9J412zi3Ef9LTVIk3Bejog+MTjtcnxMatmbgd0k=; b=QPwTf2+V9wWjMt7bR0hfeugC/3nwJImHbH1nBxNPRG2TFKQI0YOvxVykIPszzjhrwx xIas1nFps8brtPwV3CmJ5v4gN7aCV0tlwiexuIRwL1/7PyS+/KtS80pp0QlUy55izFyQ mhNi1vRXDYEGqHdwXVFGnPwl+G3ZsUjkZmjfmzxAjnlUCj6hzVVP8Z8tIMfU2UIRbTly 96fz8FbFBe3m6bGVNlZFgaPgo1zFSVzi4G3YtuSHd9FfnC16q4BbxdMCNw4BVyYP0+kn O9+yw8/yHqpe2lOvlGTBEbMcE6u9nl5sf9ag16VtxnP08eKbDhJSiYfCsM1vayxddl4/ eh6w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kv2I+KjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from groat.vger.email (groat.vger.email. [2620:137:e000::3:5]) by mx.google.com with ESMTPS id bv193-20020a632eca000000b00578d3f8d4d4si11905080pgb.448.2023.10.10.08.52.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 10 Oct 2023 08:52:32 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) client-ip=2620:137:e000::3:5; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kv2I+KjX; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:5 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by groat.vger.email (Postfix) with ESMTP id 641CA80A4996; Tue, 10 Oct 2023 08:52:29 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at groat.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229833AbjJJPwT (ORCPT + 99 others); Tue, 10 Oct 2023 11:52:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55200 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232344AbjJJPwR (ORCPT ); Tue, 10 Oct 2023 11:52:17 -0400 Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01E24C4; Tue, 10 Oct 2023 08:52:16 -0700 (PDT) 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> 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> X-Spam-Status: No, score=2.4 required=5.0 tests=DKIMWL_WL_HIGH,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,MAILING_LIST_MULTI, RCVD_IN_SBL_CSS,SPF_HELO_NONE,SPF_PASS autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on groat.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (groat.vger.email [0.0.0.0]); Tue, 10 Oct 2023 08:52:29 -0700 (PDT) X-Spam-Level: ** 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; > } ...