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]
Message-ID: <113992061.ktikQHQeGn@vostro.rjw.lan>
Date:	Fri, 03 May 2013 13:48:51 +0200
From:	"Rafael J. Wysocki" <rjw@...k.pl>
To:	Toshi Kani <toshi.kani@...com>
Cc:	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	ACPI Devel Maling List <linux-acpi@...r.kernel.org>,
	LKML <linux-kernel@...r.kernel.org>,
	isimatu.yasuaki@...fujitsu.com,
	vasilis.liaskovitis@...fitbricks.com
Subject: Re: [PATCH 1/3 RFC] Driver core: Add offline/online device operations

On Thursday, May 02, 2013 05:29:33 PM Toshi Kani wrote:
> On Thu, 2013-05-02 at 02:58 +0200, Rafael J. Wysocki wrote:
> > On Tuesday, April 30, 2013 05:38:38 PM Toshi Kani wrote:
> > > On Mon, 2013-04-29 at 14:26 +0200, Rafael J. Wysocki wrote:
> > > > From: Rafael J. Wysocki <rafael.j.wysocki@...el.com>
>  :
> > > > + */
> > > > +int device_offline(struct device *dev)
> > > > +{
> > > > +	int ret;
> > > > +
> > > > +	if (dev->offline_disabled)
> > > > +		return -EPERM;
> > > > +
> > > > +	ret = device_for_each_child(dev, NULL, device_check_offline);
> > > > +	if (ret)
> > > > +		return ret;
> > > > +
> > > > +	device_lock(dev);
> > > > +	if (device_supports_offline(dev)) {
> > > > +		if (dev->offline) {
> > > > +			ret = 1;
> > > > +		} else {
> > > > +			ret = dev->bus->offline(dev);
> > > > +			if (!ret) {
> > > > +				kobject_uevent(&dev->kobj, KOBJ_OFFLINE);
> > > > +				dev->offline = true;
> > > 
> > > Shouldn't this offline flag be set before sending KOBJ_OFFLINE?
> > > 
> > > > +			}
> > > > +		}
> > > > +	}
> > > > +	device_unlock(dev);
> > > > +
> > > > +	return ret;
> > > > +}
> > > > +
> > > > +/**
> > > > + * device_online - Put the device back online after successful device_offline().
> > > > + * @dev: Device to be put back online.
> > > > + *
> > > > + * If device_offline() has been successfully executed for @dev, but the device
> > > > + * has not been removed subsequently, execute its bus type's .online() callback
> > > > + * to indicate that the device can be used again.
> > > 
> > > There is another use-case for online().  When a device like CPU is
> > > hot-added, it is added in offline.  I am not sure why, but it has been
> > > this way.  So, we need to call online() to make a new device available
> > > for use after a hot-add.
> > 
> > Actually, in the CPU case that is left to user space as far as I can say.
> > That is, the device appears initially offline and user space is supposed to
> > bring it online via sysfs.
> > 
> > > > + *
> > > > + * Call under device_offline_lock.
> > > > + */
> > > > +int device_online(struct device *dev)
> > > > +{
> > > > +	int ret = 0;
> > > > +
> > > > +	device_lock(dev);
> > > > +	if (device_supports_offline(dev)) {
> > > > +		if (dev->offline) {
> > > > +			ret = dev->bus->online(dev);
> > > > +			if (!ret) {
> > > > +				kobject_uevent(&dev->kobj, KOBJ_ONLINE);
> > > > +				dev->offline = false;
> > > 
> > > Same comment as KOBJ_OFFLINE.
> > 
> > I wonder why the ordering may be important?
> 
> I do not think it causes any race condition (so this isn't a big deal),
> but it seems to make more sense to emit an ONLINE/OFFLINE event after
> its object is marked online/offline.

Well, dev->offline only matters for device_offline() and device_online()
themselves at this time.

Thanks,
Rafael


-- 
I speak only for myself.
Rafael J. Wysocki, Intel Open Source Technology Center.
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ