[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CACRpkdb_moz2076y2Wcu88BqEOuKkKvj4seZt+-1v0+LYbaW8w@mail.gmail.com>
Date: Sun, 12 Aug 2018 13:54:08 +0200
From: Linus Walleij <linus.walleij@...aro.org>
To: Andrew Lunn <andrew@...n.ch>
Cc: Florian Fainelli <f.fainelli@...il.com>,
"David S. Miller" <davem@...emloft.net>,
netdev <netdev@...r.kernel.org>,
Laurent Pinchart <Laurent.pinchart@...asonboard.com>
Subject: Re: [PATCH] of: mdio: Support fixed links in of_phy_get_and_connect()
On Wed, Jul 11, 2018 at 10:04 PM Andrew Lunn <andrew@...n.ch> 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
Powered by blists - more mailing lists