All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ioana Ciornei <ciorneiioana@gmail.com>
To: "Russell King (Oracle)" <linux@armlinux.org.uk>
Cc: Ioana Ciornei <ciorneiioana@gmail.com>,
	Andrew Lunn <andrew@lunn.ch>,
	davem@davemloft.net, kuba@kernel.org, netdev@vger.kernel.org,
	calvin.johnson@oss.nxp.com, hkallweit1@gmail.com,
	Ioana Ciornei <ioana.ciornei@nxp.com>
Subject: Re: [PATCH net-next] mdio: mdiobus: setup of_node for the MDIO device
Date: Wed, 16 Jun 2021 14:01:15 +0300	[thread overview]
Message-ID: <20210616110115.i3zykpc73qxu5odk@skbuf> (raw)
In-Reply-To: <20210616094012.GA22278@shell.armlinux.org.uk>

On Wed, Jun 16, 2021 at 10:40:12AM +0100, Russell King (Oracle) wrote:
> On Wed, Jun 16, 2021 at 11:20:52AM +0300, Ioana Ciornei wrote:
> > On Tue, Jun 15, 2021 at 11:31:47PM +0200, Andrew Lunn wrote:
> > > > The fwnode_operations declared in drivers/acpi/property.c also suggest
> > > > the ACPI fwnodes are not refcounted.
> > > 
> > > Is this because ACPI is not dynamic, unlike DT, where you can
> > > add/remove overlays at runtime?
> > > 
> > 
> > I am really not an expert here but the git history suggests so, yes.
> > 
> > Without the CONFIG_OF_DYNAMIC enabled, the fwnode_handle_get() call is
> > actually a no-op even in the OF case.
> 
> More accurately, of_node_get() is a no-op if CONFIG_OF_DYNAMIC is
> disabled, which in turn makes fwnode_handle_get() also a no-op.
> 
> I'm wondering whether we would need two helpers to assign these, or
> just a single helper that takes a fwnode and assigns both pointers.
> to_of_node() returns NULL if the fwnode is not a DT node, so would
> be safe to use even with ACPI.
> 

Yes, I think this approach was exactly what Andrew suggested initially.

> Then there's the cleanup side when the device is released. I haven't
> yet found where we release the reference to the fwnode/of_node when
> we release the phy_device. I would have expected it in
> phy_device_release() but that does nothing.

Looking at the fixed_phy.c use of the refcounts, I would expect that a
call to fwnode_handle_put/of_node_put should be right after a
phy_device_remove() call is made.

	void fixed_phy_unregister(struct phy_device *phy)
	{
		phy_device_remove(phy);
		of_node_put(phy->mdio.dev.of_node);
		fixed_phy_del(phy->mdio.addr);
	}


Now going back to the phy_device.c, the phy_device_remove() call is done
in phy_mdio_device_remove. This is the device_remove callback of any PHY
MDIO device, called when, for example, the MDIO bus is unregistered.

After a first pass through the code, I would expect the refcount to be
released in phy_mdio_device_remove().

> We could only add that
> when we are certain that all users who assign the firmware node to
> the phy device has properly refcounted it in the DT case.
> 

Agree. I think we need a proper mapping of the register/unregister code
paths before any of_node/fwnode_handle put is added.

Ioana

      reply	other threads:[~2021-06-16 11:02 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-06-15 15:44 [PATCH net-next] mdio: mdiobus: setup of_node for the MDIO device Ioana Ciornei
2021-06-15 16:19 ` Andrew Lunn
2021-06-15 16:49   ` Ioana Ciornei
2021-06-15 17:13 ` Russell King (Oracle)
2021-06-15 17:24   ` Ioana Ciornei
2021-06-15 18:25     ` Russell King (Oracle)
2021-06-15 18:31   ` Andrew Lunn
2021-06-15 21:09     ` Russell King (Oracle)
2021-06-15 21:21       ` Ioana Ciornei
2021-06-15 21:31         ` Andrew Lunn
2021-06-16  8:20           ` Ioana Ciornei
2021-06-16  9:40             ` Russell King (Oracle)
2021-06-16 11:01               ` Ioana Ciornei [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20210616110115.i3zykpc73qxu5odk@skbuf \
    --to=ciorneiioana@gmail.com \
    --cc=andrew@lunn.ch \
    --cc=calvin.johnson@oss.nxp.com \
    --cc=davem@davemloft.net \
    --cc=hkallweit1@gmail.com \
    --cc=ioana.ciornei@nxp.com \
    --cc=kuba@kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=netdev@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.