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] [thread-next>] [day] [month] [year] [list]
Date:   Tue, 3 Oct 2023 11:43:26 +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 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.

Thanks,
Miquèl

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ