[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <f4252894-4f35-e296-6a72-e29200d6dcd1@linux.vnet.ibm.com>
Date: Mon, 1 Aug 2016 15:34:09 +0200
From: Frederic Barrat <fbarrat@...ux.vnet.ibm.com>
To: Michael Ellerman <mpe@...erman.id.au>,
Andrew Donnellan <andrew.donnellan@....ibm.com>,
linuxppc-dev@...ts.ozlabs.org
Cc: clombard@...ux.vnet.ibm.com, kernel-janitors@...r.kernel.org,
linux-kernel@...r.kernel.org, julia.lawall@...6.fr,
imunsie@....ibm.com, elfring@...rs.sourceforge.net
Subject: Re: [PATCH] cxl: replace loop with for_each_child_of_node(), remove
unneeded of_node_put()
Le 29/07/2016 à 13:38, Michael Ellerman a écrit :
> But who does keep a reference on the device_node? I can't see it anywhere. Which
> means in theory the device_node can be freed out from under you.
>
> You have a reference for afu_np as part of for_each_child_of_node(), but it's
> dropped as soon as you go around the loop.
>
> The typical pattern would be that cxl_guest_init_afu() takes an additional
> reference once it's done all its setup and can't fail.
>
> That way at the end of the loop when the loop construct has dropped all
> references, the nodes you actually init'ed have their reference count
> incremented by 1.
We don't keep a reference on the AFU device_node. Once we've read the
config of the AFU, the AFU device_node is never accessed again. So I
guess it's possible (though unexpected) that it's freed from under us,
but it should not affect the driver.
The AFU is really dependent on the adapter itself, which is one level up
in the device tree, and for which we create a device through
of_platform_device_create(). The properties under the AFU device node
are read directly from the PCI config space in the bare-metal case,
where the cxl adapter is a PCI device.
Do we really have a problem here?
Fred
Powered by blists - more mailing lists