lists.openwall.net | lists / announce owl-users owl-dev john-users john-dev passwdqc-users yescrypt popa3d-users / oss-security kernel-hardening musl sabotage tlsify passwords / crypt-dev xvendor / Bugtraq Full-Disclosure linux-kernel linux-netdev linux-ext4 linux-hardening linux-cve-announce PHC | |
Open Source and information security mailing list archives
| ||
|
Date: Mon, 9 Nov 2020 11:25:39 -0600 From: Rob Herring <robh+dt@...nel.org> To: Saravana Kannan <saravanak@...gle.com> Cc: Mark Brown <broonie@...nel.org>, Greg Kroah-Hartman <gregkh@...uxfoundation.org>, "Rafael J . Wysocki" <rafael@...nel.org>, Daniel Mentz <danielmentz@...gle.com>, LKML <linux-kernel@...r.kernel.org>, Frank Rowand <frowand.list@...il.com> Subject: Re: [PATCH RFC] driver core: Ensure DT devices always have fwnode set On Fri, Nov 6, 2020 at 1:09 PM Saravana Kannan <saravanak@...gle.com> wrote: > > +Rob and Frank > > On Fri, Nov 6, 2020 at 7:09 AM Mark Brown <broonie@...nel.org> wrote: > > > > Currently the fwnode API and things that rely on it like fw_devlink will > > not reliably work for devices created from DT since each subsystem that > > creates devices must individually set dev->fwnode in addition to setting > > dev->of_node, currently a number of subsystems don't do so. Ensure that > > this can't get missed by setting fwnode from of_node if it's not > > previously been set by the subsystem. > > > > Reported-by: Saravana Kannan <saravanak@...gle.com> > > Signed-off-by: Mark Brown <broonie@...nel.org> > > --- > > > > *Very* minimally tested. > > > > drivers/base/core.c | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > diff --git a/drivers/base/core.c b/drivers/base/core.c > > index d661ada1518f..658626bafd76 100644 > > --- a/drivers/base/core.c > > +++ b/drivers/base/core.c > > @@ -2864,6 +2864,10 @@ int device_add(struct device *dev) > > if (parent && (dev_to_node(dev) == NUMA_NO_NODE)) > > set_dev_node(dev, dev_to_node(parent)); > > > > + /* ensure that fwnode is set up */ > > + if (IS_ENABLED(CONFIG_OF) && dev->of_node && !dev->fwnode) > > + dev->fwnode = of_fwnode_handle(dev->of_node); > > + > > I don't think we should add more CONFIG_OF specific code in drivers/base/ It's fwnode specific code because it's fwnode that needs it... > If you want to do this in "one common place", then I think the way to > do this is have include/linux/of.h provide something like: > void of_set_device_of_node(dev, of_node) > { > dev->of_node = of_node; > dev->fw_node = &of_node->fwnode; > /* bunch of other housekeeping like setting OF_POPULATED and doing > proper of_node_get() */ > // Passing NULL for of_node could undo all the above for dev->of_node. > } > > And all the subsystems that create their own device from an of_node > should use of_set_device_of_node() to set the device's of_node. That > way, all this is done in a consistent manner across subsystems and > avoid all of the of_get/put() and OF_POPULATED set/clear strewn all > over the subsystems. Perhaps a fwnode call in device_add instead that implements the above and anything else needed for each type of fwnode. It might even be possible with that to get rid of most of of_platform_device_create_pdata() and of_device_add(). IIRC, those were pretty much copies of the core code. That would also be less fragile than having a coccinelle script. Rob
Powered by blists - more mailing lists