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
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <20231005165852.4619ebb2@xps-13>
Date:   Thu, 5 Oct 2023 16:58:52 +0200
From:   Miquel Raynal <miquel.raynal@...tlin.com>
To:     Srinivas Kandagatla <srinivas.kandagatla@...aro.org>
Cc:     Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Michael Walle <michael@...le.cc>,
        Thomas Petazzoni <thomas.petazzoni@...tlin.com>,
        Robert Marko <robert.marko@...tura.hr>,
        Luka Perkov <luka.perkov@...tura.hr>,
        linux-kernel@...r.kernel.org, Randy Dunlap <rdunlap@...radead.org>,
        Chen-Yu Tsai <wenst@...omium.org>,
        Daniel Golle <daniel@...rotopia.org>,
        Rafał Miłecki <rafal@...ecki.pl>
Subject: Re: [PATCH v10 1/3] nvmem: core: Rework layouts to become platform
 devices

Hi Miquel,

miquel.raynal@...tlin.com wrote on Tue, 3 Oct 2023 11:43:26 +0200:

> Hi Srinivas,
> 
> > > +static int nvmem_dev_match_available_layout(struct device *dev, void *data)
> > > +{
> > > +	struct nvmem_device *nvmem = to_nvmem_device(dev);
> > > +
> > > +	return nvmem_match_available_layout(nvmem);
> > > +}
> > > +
> > > +static int nvmem_for_each_dev(int (*fn)(struct device *dev, void *data))
> > > +{
> > > +	return bus_for_each_dev(&nvmem_bus_type, NULL, NULL, fn);
> > > +}
> > > +
> > > +/*
> > > + * When an NVMEM device is registered, try to match against a layout and
> > > + * populate the cells. When an NVMEM layout is probed, ensure all NVMEM devices
> > > + * which could use it properly expose their cells.
> > > + */
> > > +static int nvmem_notifier_call(struct notifier_block *notifier,
> > > +			       unsigned long event_flags, void *context)
> > > +{
> > > +	struct nvmem_device *nvmem = NULL;
> > > +	int ret;
> > > +
> > > +	switch (event_flags) {
> > > +	case NVMEM_ADD:
> > > +		nvmem = context;
> > > +		break;
> > > +	case NVMEM_LAYOUT_ADD:
> > > +		break;
> > > +	default:
> > > +		return NOTIFY_DONE;
> > > +	}    
> > 
> > It looks bit unnatural for core to register notifier for its own events.
> > 
> > 
> > Why do we need the notifier at core level, can we not just handle this in core before raising these events, instead of registering a notifier cb?  
> 
> There is no good place to do that "synchronously". We need some kind of
> notification mechanism in these two cases:
> * A memory device is being probed -> if a matching layout driver is
>   already available, we need to parse the device and expose the cells,
>   but not in the thread registering the memory device.
> * A layout driver is being insmod'ed -> if a memory device needs it to
>   create cells we need to parse the device content, but I find it
>   crappy to start device-specific parsing in the registration handler.
> 
> So probe of the memory device is not a good place for this, nor is the
> registration of the layout driver. Yet, we need to do the same
> operation upon two different "events".
> 
> This notifier mechanism is a clean and easy way to get notified and
> implement a callback which is also not blocking the thread doing the
> initial registration. I am personally not bothered using it only
> internally. If you have another mechanism in mind to perform a similar
> operation, or a way to avoid this need I'll do the switch.

Since I've changed the way nvmem devices and layouts are dependent in
v11, I've been giving this a second thought and I think this can now be
avoided. I've improved the layout registration callback to actually
retrieve the nvmem device this layout is probing on and populates
the dynamic cells *there* (instead of during the probe of the nvmem
device itself). This way I could drop some boilerplate which is no
longer necessary. It comes at a low cost: there are now two places were
sysfs cells can be added.

I am cleaning up all this stuff and then let you and Greg review the
v12.

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ