Received: by 2002:a05:6358:7058:b0:131:369:b2a3 with SMTP id 24csp6933002rwp; Tue, 18 Jul 2023 07:48:44 -0700 (PDT) X-Google-Smtp-Source: APBJJlHDcUgv+tYZuXIll4MCHpOE6FsDcp25X5QB0CMUWk7TV6OjhX3spObZ+eqnPd8//EoWhleX X-Received: by 2002:a17:906:c:b0:994:1956:2331 with SMTP id 12-20020a170906000c00b0099419562331mr15100eja.13.1689691724756; Tue, 18 Jul 2023 07:48:44 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1689691724; cv=none; d=google.com; s=arc-20160816; b=0BEi/dYOX3gl0znHE7qrTYcjoG/pey+80fHECJ/exK04BfSnFIgi0aMjN/Gg7RFfZT d4oVM5rKnP+0jMSbfRVOrRxRvFNXKIkZK0Hr1knRcvrHe74sFExOQLxLteeBk4uad6Bk IcvqiBq7rMfkdnxZ+/2LY5/LGSEjM3ymzFT4AnKIqmKIGM2fH8ktk1LP2ORnWjKfHZAq t4/UJJXEI4hP7K8MamzR0Jrt9XF4Xrk5hPF8OOnBNYc1hbZSJ+jb5bVr4SZg1UtHAY/i j1CJ+YN5IPzEupFQJIT+2czDREUD+M832neNUD0re1SwmtZbJYWFfc8ZfeiGVVcwyPOh VnHA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=CCWgwOpFRQ5XqsiPbGDMwwFojNqf8ujX2CR9i45zWzI=; fh=FQpGiJqXcDAKdIeOpDvf0PXe5BQsBpqV61wNNvIszzM=; b=aqYKfUMQhJRWwvFEiAIUKx0GmqEdEEvy0cfjydEis61g3UTzqUSTZET8sOLCd+HD/V 3WAnSeCrt2iws/L1KhfneLdjfWM3S8JOgJ9MkVc2lqv0DA6zX0XuuGwRM9Q1kS8uYISy LL2PxlNzKEUNYZRSDwbOH0qYdfOEEuqnCuGf2VknpvvBuPFyi7FmrbsmO9shvew1vGpl b8CtTaQrTCRE6xw1GAPaT8RFb6qTx01W7lTHr7MogjnFfAPO1qHhB+0wUKzrLqqgkn8s ravnurm4o5WbrWZJ28rRZaHkZ8qfBdUEwUKzgjxmtSZtm4UX91Im/OTBlyLvny2oyFXW LsDQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=cUaiaLEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id lc9-20020a170906dfe900b009827e07cca6si1282837ejc.17.2023.07.18.07.48.20; Tue, 18 Jul 2023 07:48:44 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=cUaiaLEw; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=armlinux.org.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232642AbjGROUf (ORCPT + 99 others); Tue, 18 Jul 2023 10:20:35 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44528 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232185AbjGROUd (ORCPT ); Tue, 18 Jul 2023 10:20:33 -0400 Received: from pandora.armlinux.org.uk (pandora.armlinux.org.uk [IPv6:2001:4d48:ad52:32c8:5054:ff:fe00:142]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DAD10E7E; Tue, 18 Jul 2023 07:20:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=armlinux.org.uk; s=pandora-2019; h=Sender:In-Reply-To:Content-Type: MIME-Version:References:Message-ID:Subject:Cc:To:From:Date:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=CCWgwOpFRQ5XqsiPbGDMwwFojNqf8ujX2CR9i45zWzI=; b=cUaiaLEwT86VbsrvDDtd3lmfsc 6P6lhJsp4LilqQUvzPzwBsNp/DT7K/cdlQlz8og1QXVqJLswf0xjZyJ9/+toh4MpakkQmZ/N2Lb3Y ssgfpIgQ3+5SM22Z9tKYZq7nBk421B0656m1oY50TVHXmMA3p7D8o4sulipB/HHVuvX2qLKRpasfG j9wbyjuQi9djwAN2mZ4NV2ivYzvwk2EGP88VJxPLC09zvDEItY+mXRP22IcOr80xwymzv137lHfnN YOshTBsvJxiTlhnYYzMQWkNxdhIrid39KCCJZ2yfByL+s2dbnv05mSwrqCpUIc9FLz6dOJL1UKLsd wxxLM7MQ==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:51756) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1qLlYp-0005nb-1w; Tue, 18 Jul 2023 15:20:19 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1qLlYj-00036j-CY; Tue, 18 Jul 2023 15:20:13 +0100 Date: Tue, 18 Jul 2023 15:20:13 +0100 From: "Russell King (Oracle)" To: Vladimir Oltean Cc: netdev@vger.kernel.org, "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni , Andrew Lunn , Florian Fainelli , Maxim Georgiev , Horatiu Vultur , =?iso-8859-1?Q?K=F6ry?= Maincent , Maxime Chevallier , Richard Cochran , Vadim Fedorenko , Gerhard Engleder , Hangbin Liu , Heiner Kallweit , Jacob Keller , Jay Vosburgh , Andy Gospodarek , Wei Fang , Shenwei Wang , Clark Wang , NXP Linux Team , UNGLinuxDriver@microchip.com, Lars Povlsen , Steen Hegelund , Daniel Machon , Simon Horman , Casper Andersson , Sergey Organov , Michal Kubecek , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v8 net-next 06/12] net: fec: convert to ndo_hwtstamp_get() and ndo_hwtstamp_set() Message-ID: References: <20230717152709.574773-1-vladimir.oltean@nxp.com> <20230717152709.574773-7-vladimir.oltean@nxp.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20230717152709.574773-7-vladimir.oltean@nxp.com> Sender: Russell King (Oracle) X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, SPF_HELO_NONE,SPF_NONE,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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!