From mboxrd@z Thu Jan 1 00:00:00 1970 From: Linus Walleij Subject: Re: [PATCH] of: mdio: Support fixed links in of_phy_get_and_connect() Date: Sun, 12 Aug 2018 13:54:08 +0200 Message-ID: References: <20180711174511.15308-1-linus.walleij@linaro.org> <20180711200452.GD21430@lunn.ch> Mime-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Cc: Florian Fainelli , "David S. Miller" , netdev , Laurent Pinchart To: Andrew Lunn Return-path: Received: from mail-it0-f67.google.com ([209.85.214.67]:53020 "EHLO mail-it0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727748AbeHLOcK (ORCPT ); Sun, 12 Aug 2018 10:32:10 -0400 Received: by mail-it0-f67.google.com with SMTP id d9-v6so8766527itf.2 for ; Sun, 12 Aug 2018 04:54:21 -0700 (PDT) In-Reply-To: <20180711200452.GD21430@lunn.ch> Sender: netdev-owner@vger.kernel.org List-ID: On Wed, Jul 11, 2018 at 10:04 PM Andrew Lunn wrote: > What probably make sense as a followup is add a > of_phy_disconnect_and_put(). When the module is unloaded, you leak a > fixed link, because of_phy_deregister_fixed_link() is not being > called. I looked at this but I get a bit confused. How to handle cleanup of the fixed link is pretty straight forward, I'm more concerned with the proper (today non-existing) way to clean up after of_phy_connect() that is called for all instances. This calls phy_connect_direct() that then does this: /* refcount is held by phy_connect_direct() on success */ put_device(&phy->mdio.dev); Which seems like wrong - it should keep holding that until we do of_phy_disconnect_and_put() in that case. The above seems like some hack, i.e. we are using the MDIO without holding a reference or something, so it can go away cleanly later. Or do I have it wrong? It's confusing, I guess these PHY's don't come and go very much so the plug/play part isn't really exercised. > You also hold a reference to np which does not appear to be > released. That seems to be covered as there is a of_node_put(phy_np); at the end of this function already. Balancing of_node_get()/put() is another area where there is not (AFAICT) much stringency in the kernel. I loosely believe this is mostly for dynamic device trees (so you do not delete a node that is in use e.g.) and people don't use that very much (or at all). I think most systems shut down with a bunch of OF nodes held. :/ (Yeah another universe of cleanups the day we need it to work.) Yours, Linus Walleij