Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4005932pxj; Tue, 15 Jun 2021 13:18:55 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyR4yzL0QOqhJX5KYRqVq4rKKIdis8zK3d1Q2wzAaxDoF8IFGBqWfMg8Rq8m7XuuxaKRRbb X-Received: by 2002:aa7:db18:: with SMTP id t24mr1660728eds.72.1623788334955; Tue, 15 Jun 2021 13:18:54 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623788334; cv=none; d=google.com; s=arc-20160816; b=CJGle/515L6w2N2639rtQFPQpcocckvML8nTClR6awOeuDIGGVe9Q3PiLmzjKCB+Lr pgPoeB21bssj6U/GyPYyEZHoqRZiCCKSRYTqpRRYh1dcJCbfKOB6auwzmGEjUnxrDH+4 i2489vfnVO9SBZ4sRl4HSBRPsiZb+S6ZbpgBPQ9GNjolzSKriwphaiVT10df7+N3nO9T fBe0C9ZAOJNoAPW2R6upexUtqMmbL0uSMW4aGSDRtgbBRYmJKViTA+YWKMFcRDx+hIZv Q2c/2ZVJHlh8Rz50vV6S5Yxx+dp3hJk58jdgZoTkSvkwCyLL27AHfeXr7R5RZyz8qmPh d++w== 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-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=U17IZRnXbBD5Iv+MrLF20+p6qgDfSxWADNI6EmaMSQ4=; b=oTiWTClFVVR/M4ZOjFZGOvW5BN0QyqP2dU9v+cfI0r2pcmSKJJ6CJTG4GlNB4bnwo2 JrCk3JDjkQbUkf+iMWZSmb5Q0H6SuuhuvfnCoUUZe6ORL5Wuny/XsFmb2iOnp50NX7WI lWJm3xdAw+B/PD27SHTbxAnGrFW03ePduMGn9Ejh0QnxEoiZodnnM7uMvK7JReVgZy3E BvMVs8vhGB7anRH07smh3FU1NUWDeEzQuqAXBIPtOsWQaLhC8W+dYcA42quVBqZ3QOoH c+K/ybfxlFih/x+gWSGfxqQm5EQ65sbdT329XmLKja+n8arRwugOUsjHx+9c4n+GiUO+ 57pg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j27si22167ejo.342.2021.06.15.13.18.31; Tue, 15 Jun 2021 13:18:54 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230238AbhFOUSI (ORCPT + 99 others); Tue, 15 Jun 2021 16:18:08 -0400 Received: from fgw20-7.mail.saunalahti.fi ([62.142.5.81]:23024 "EHLO fgw20-7.mail.saunalahti.fi" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229979AbhFOUSH (ORCPT ); Tue, 15 Jun 2021 16:18:07 -0400 Received: from localhost (88-115-248-186.elisa-laajakaista.fi [88.115.248.186]) by fgw20.mail.saunalahti.fi (Halon) with ESMTP id 7e9e6777-ce16-11eb-ba24-005056bd6ce9; Tue, 15 Jun 2021 23:15:59 +0300 (EEST) Date: Tue, 15 Jun 2021 23:15:57 +0300 From: andy@surfacebook.localdomain To: Ioana Ciornei Cc: davem@davemloft.net, kuba@kernel.org, hkallweit1@gmail.com, netdev@vger.kernel.org, Grant Likely , "Rafael J . Wysocki" , Jeremy Linton , Andrew Lunn , Andy Shevchenko , Florian Fainelli , Russell King - ARM Linux admin , Heikki Krogerus , Marcin Wojtas , Pieter Jansen Van Vuuren , Jon , Saravana Kannan , Randy Dunlap , calvin.johnson@oss.nxp.com, Cristi Sovaiala , Florin Laurentiu Chiculita , Madalin Bucur , linux-arm-kernel@lists.infradead.org, Diana Madalina Craciun , linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, linux.cj@gmail.com, Laurentiu Tudor , Len Brown , "Rafael J . Wysocki" , Ioana Ciornei Subject: Re: [PATCH net-next v9 08/15] net: mdiobus: Introduce fwnode_mdiobus_register_phy() Message-ID: References: <20210611105401.270673-1-ciorneiioana@gmail.com> <20210611105401.270673-9-ciorneiioana@gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210611105401.270673-9-ciorneiioana@gmail.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Fri, Jun 11, 2021 at 01:53:54PM +0300, Ioana Ciornei kirjoitti: > From: Calvin Johnson > > Introduce fwnode_mdiobus_register_phy() to register PHYs on the > mdiobus. From the compatible string, identify whether the PHY is > c45 and based on this create a PHY device instance which is > registered on the mdiobus. > > Along with fwnode_mdiobus_register_phy() also introduce > fwnode_find_mii_timestamper() and fwnode_mdiobus_phy_device_register() > since they are needed. > While at it, also use the newly introduced fwnode operation in > of_mdiobus_phy_device_register(). I understand that this patch series is applied, but I think we have a problem that has to be fixed before the release. See below for the details. ... > +int fwnode_mdiobus_phy_device_register(struct mii_bus *mdio, > + struct phy_device *phy, > + struct fwnode_handle *child, u32 addr) > +{ > + int rc; > + > + rc = fwnode_irq_get(child, 0); > + if (rc == -EPROBE_DEFER) > + return rc; > + > + if (rc > 0) { > + phy->irq = rc; > + mdio->irq[addr] = rc; > + } else { > + phy->irq = mdio->irq[addr]; > + } > + > + if (fwnode_property_read_bool(child, "broken-turn-around")) > + mdio->phy_ignore_ta_mask |= 1 << addr; > + > + fwnode_property_read_u32(child, "reset-assert-us", > + &phy->mdio.reset_assert_delay); > + fwnode_property_read_u32(child, "reset-deassert-us", > + &phy->mdio.reset_deassert_delay); > + > + /* Associate the fwnode with the device structure so it > + * can be looked up later > + */ > + fwnode_handle_get(child); We take a reference counting here. Who and when should drop it? > + phy->mdio.dev.fwnode = child; > + > + /* All data is now stored in the phy struct; > + * register it > + */ > + rc = phy_device_register(phy); > + if (rc) { > + fwnode_handle_put(child); > + return rc; > + } > + > + dev_dbg(&mdio->dev, "registered phy %p fwnode at address %i\n", > + child, addr); > + return 0; > +} > +EXPORT_SYMBOL(fwnode_mdiobus_phy_device_register); > + > +int fwnode_mdiobus_register_phy(struct mii_bus *bus, > + struct fwnode_handle *child, u32 addr) > +{ > + struct mii_timestamper *mii_ts = NULL; > + struct phy_device *phy; > + bool is_c45 = false; > + u32 phy_id; > + int rc; > + > + mii_ts = fwnode_find_mii_timestamper(child); > + if (IS_ERR(mii_ts)) > + return PTR_ERR(mii_ts); > + > + rc = fwnode_property_match_string(child, "compatible", > + "ethernet-phy-ieee802.3-c45"); > + if (rc >= 0) > + is_c45 = true; > + > + if (is_c45 || fwnode_get_phy_id(child, &phy_id)) > + phy = get_phy_device(bus, addr, is_c45); > + else > + phy = phy_device_create(bus, addr, phy_id, 0, NULL); > + if (IS_ERR(phy)) { > + unregister_mii_timestamper(mii_ts); > + return PTR_ERR(phy); > + } > + > + if (is_acpi_node(child)) { > + phy->irq = bus->irq[addr]; > + > + /* Associate the fwnode with the device structure so it > + * can be looked up later. > + */ > + phy->mdio.dev.fwnode = child; > + > + /* All data is now stored in the phy struct, so register it */ > + rc = phy_device_register(phy); > + if (rc) { > + phy_device_free(phy); > + fwnode_handle_put(phy->mdio.dev.fwnode); We dropped reference counting here, but who and when acquired it? > + return rc; > + } > + } else if (is_of_node(child)) { > + rc = fwnode_mdiobus_phy_device_register(bus, phy, child, addr); > + if (rc) { > + unregister_mii_timestamper(mii_ts); > + phy_device_free(phy); > + return rc; > + } > + } > + > + /* phy->mii_ts may already be defined by the PHY driver. A > + * mii_timestamper probed via the device tree will still have > + * precedence. > + */ > + if (mii_ts) > + phy->mii_ts = mii_ts; > + return 0; > +} -- With Best Regards, Andy Shevchenko