Received: by 2002:a05:6a11:4021:0:0:0:0 with SMTP id ky33csp2252437pxb; Mon, 20 Sep 2021 16:40:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxkkH+ayAUZs9ae637TNQsJ4olW3MTFhhyizCrvLe7a1nGmwAtkWN5XRFlU4gQrCNBzeK0x X-Received: by 2002:a6b:28b:: with SMTP id 133mr20602698ioc.107.1632181255492; Mon, 20 Sep 2021 16:40:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1632181255; cv=none; d=google.com; s=arc-20160816; b=YgeoT1JQSrZ9WhWVw0Tc4FZpK2fSl7qZA3lFjZQrUteDUd8UDVxzL6EzoTscr8Rw4Y HkoloTXKLp935H40i0PMHO2YpJqm7Lm77ZoH/MJiQIuoydO3Q5E3jj+XwCJmkK1SF+TP In3SrkUDz0ia+evrOFQMZLXHQrUk5VEqcRL/8K5/CO49s/S/mPeIR4McqmKT0/K0vwF9 Nq6JdUa9KarEnfc4AbON5Mlsni5Xvwq/ha0jml7sV1q5d9yOTu7DdlKzHvOJEgyhu18J hj04To/609ubfkBZHW7d68qlDtbrd33/Y5oRr4rnGnjQ4/9UnQoD1WFkeyDW7kcJkVvC O9DA== 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=Ml6l0rn52QlsFUnOCfmpKHL/TyYLnkrCtmGMxVRDliA=; b=djNrZmjilXYbr+dKkKnzbUeMU0AgtVed/Hc1qvyKwd7crYeALK9PtrPIOPDR8agUI2 YFGUPOZFKHDxhs4I65ebXFFgavaY2eP+BibxspqTJk9fH290ik/UQSa7OqQs00VMXkOk +fu1dvMxWOIftMH3tsRDH6hOnYZdo/WJirkBRzuSd3uRHSWlmCGO+yUuiibpkrzTXXXg V8wDCnq3HZLfbJigU/JRLa/AIq6craQ3iKJXUcQjwEMQuyx9dZAR5g7fytklmH+kcFXh dEQUj0SXFIXs5cD7digGRwNE0l8HcHQNu+xZQiCeZUE1x4qT6us4gvfiYkuVNxgGSu+5 TCBw== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=yd65DEFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id z22si18350389jan.81.2021.09.20.16.40.44; Mon, 20 Sep 2021 16:40:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail (test mode) header.i=@armlinux.org.uk header.s=pandora-2019 header.b=yd65DEFZ; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 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 S236212AbhITN4D (ORCPT + 99 others); Mon, 20 Sep 2021 09:56:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43408 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233461AbhITN4D (ORCPT ); Mon, 20 Sep 2021 09:56:03 -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 2D555C061574; Mon, 20 Sep 2021 06:54:36 -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=Ml6l0rn52QlsFUnOCfmpKHL/TyYLnkrCtmGMxVRDliA=; b=yd65DEFZ25sB3j/ggV0Xl+wDsh phEeQ/Xfp/Ie5T4Emv+TWwNaWVoIe7ZNgyAEWfMmTDNu/nY+MHAGAEoBfMPigvGdh1DQg0FmtdtKK Oo2gOJYUvAqfda08B9g5n6BcoOnN6GGYZvkfenUxmMojG/0LY0BEUw+F5FfCQnmjKl6zvZFrW4B71 WaWkKs0Tu8dwAfsYwfsNoYbGoew4mMDznzGpfzGjTMvLToDfCfSioUQc4o9AI4b7FKTbZJ5KQqU/7 8T9bAiwzoFOGh2xqQsFW5OQkA2wWLKZisi0iVvUUy5BmkaZ2S0UdPdm2kyaPawR1DIUaI/NfBR+Md 0+j7LgZw==; Received: from shell.armlinux.org.uk ([fd8f:7570:feb6:1:5054:ff:fe00:4ec]:54674) by pandora.armlinux.org.uk with esmtpsa (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1mSJkb-0001fr-D8; Mon, 20 Sep 2021 14:54:29 +0100 Received: from linux by shell.armlinux.org.uk with local (Exim 4.94.2) (envelope-from ) id 1mSJkY-0002LQ-Tm; Mon, 20 Sep 2021 14:54:26 +0100 Date: Mon, 20 Sep 2021 14:54:26 +0100 From: "Russell King (Oracle)" To: Horatiu Vultur Cc: davem@davemloft.net, kuba@kernel.org, robh+dt@kernel.org, andrew@lunn.ch, f.fainelli@gmail.com, alexandre.belloni@bootlin.com, vladimir.oltean@nxp.com, UNGLinuxDriver@microchip.com, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, linux-phy@lists.infradead.org, linux-pm@vger.kernel.org Subject: Re: [RFC PATCH net-next 10/12] net: lan966x: add port module support Message-ID: References: <20210920095218.1108151-1-horatiu.vultur@microchip.com> <20210920095218.1108151-11-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210920095218.1108151-11-horatiu.vultur@microchip.com> Sender: Russell King (Oracle) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Sep 20, 2021 at 11:52:16AM +0200, Horatiu Vultur wrote: > +static void lan966x_cleanup_ports(struct lan966x *lan966x) > +{ > + struct lan966x_port *port; > + int portno; > + > + for (portno = 0; portno < lan966x->num_phys_ports; portno++) { > + port = lan966x->ports[portno]; > + if (!port) > + continue; > + > + if (port->phylink) { > + rtnl_lock(); > + lan966x_port_stop(port->dev); > + rtnl_unlock(); > + port->phylink = NULL; This leaks the phylink structure. You need to call phylink_destroy(). > static int lan966x_probe_port(struct lan966x *lan966x, u8 port, > phy_interface_t phy_mode) > { > struct lan966x_port *lan966x_port; > + struct phylink *phylink; > + struct net_device *dev; > + int err; > > if (port >= lan966x->num_phys_ports) > return -EINVAL; > > - lan966x_port = devm_kzalloc(lan966x->dev, sizeof(*lan966x_port), > - GFP_KERNEL); > + dev = devm_alloc_etherdev_mqs(lan966x->dev, > + sizeof(struct lan966x_port), 8, 1); > + if (!dev) > + return -ENOMEM; > > + SET_NETDEV_DEV(dev, lan966x->dev); > + lan966x_port = netdev_priv(dev); > + lan966x_port->dev = dev; > lan966x_port->lan966x = lan966x; > lan966x_port->chip_port = port; > lan966x_port->pvid = PORT_PVID; > lan966x->ports[port] = lan966x_port; > > + dev->max_mtu = ETH_MAX_MTU; > + > + dev->netdev_ops = &lan966x_port_netdev_ops; > + dev->needed_headroom = IFH_LEN * sizeof(u32); > + > + err = register_netdev(dev); > + if (err) { > + dev_err(lan966x->dev, "register_netdev failed\n"); > + goto err_register_netdev; > + } register_netdev() publishes the network device. > + > + lan966x_port->phylink_config.dev = &lan966x_port->dev->dev; > + lan966x_port->phylink_config.type = PHYLINK_NETDEV; > + lan966x_port->phylink_config.pcs_poll = true; > + > + phylink = phylink_create(&lan966x_port->phylink_config, > + lan966x_port->fwnode, > + phy_mode, > + &lan966x_phylink_mac_ops); phylink_create() should always be called _prior_ to the network device being published. In any case... > + if (IS_ERR(phylink)) > + return PTR_ERR(phylink); If this fails, this function returns an error, but leaves the network device published - which is a bug in itself. > +static void lan966x_phylink_mac_link_down(struct phylink_config *config, > + unsigned int mode, > + phy_interface_t interface) > +{ Hmm? Shouldn't this do something? -- RMK's Patch system: https://www.armlinux.org.uk/developer/patches/ FTTP is here! 40Mbps down 10Mbps up. Decent connectivity at last!