Skip to contentSkip to conversation

driver core fixes for 2.6.32-git

PATCH New Greg KH 1 participant 10 messages Oct 30, 2009

Subsystems (2)
lore
Share & tools
lore

Greg KH

author
#0 lore raw

PATCH 1/1 driver core fixes for 2.6.32-git

Here are 2 bugfixes for the driver core code for your .32 git tree, and 7 documentation updates.

They do:
- prevent platform devices from being able to be unbound/bound from userspace. This solves an issue that some people were having with keyboards.
- pass the proper error value back to userspace when a driver is already bound to a device.
- cpu sysfs file documentation updates.

Please pull from:
master.kernel.org:/pub/scm/linux/kernel/git/gregkh/driver-core-2.6.git/

All of these patches have been in the linux-next and mm trees for a while.

The patches will be sent as a follow-on to this message to lkml for people to see.

thanks,

greg k-h

------------

 .../ABI/testing/sysfs-devices-cache_disable        |   18 ---
 Documentation/ABI/testing/sysfs-devices-system-cpu |  156 ++++++++++++++++++++
 Documentation/cputopology.txt                      |   47 ++++--
 drivers/base/bus.c                                 |   17 ++-
 drivers/base/driver.c                              |    2 +-
 drivers/base/platform.c                            |    6 +-
 include/linux/device.h                             |    4 +-
 7 files changed, 206 insertions(+), 44 deletions(-)
 delete mode 100644 Documentation/ABI/testing/sysfs-devices-cache_disable
 create mode 100644 Documentation/ABI/testing/sysfs-devices-system-cpu

---------------

Alex Chiang (7):
Documentation: ABI: rename sysfs-devices-cache_disable properly
Documentation: ABI: document /sys/devices/system/cpu/
Documentation: ABI: /sys/devices/system/cpu/ topology files
Documentation: ABI: /sys/devices/system/cpu/cpu#/ topology files
Documentation: ABI: /sys/devices/system/cpu/sched_[mc|smt]_power_savings
Documentation: ABI: /sys/devices/system/cpu/cpuidle/
Documentation: ABI: /sys/devices/system/cpu/cpu#/node

Dmitry Torokhov (1):
Driver core: allow certain drivers prohibit bind/unbind via sysfs

Stas Sergeev (1):
Driver core: fix driver_register() return value

#1 lore raw

PATCH 1/9 Driver core: fix driver_register() return value

From: Stas Sergeev <[email protected]>

In this patch:
http://git.kernel.org/?p=linux/kernel/git/torvalds/linux-2.6.git;a=commitdiff;h=16dc42e018c2868211b4928f20a957c0c216126c
the check was added for another driver to already claim the same device on the same bus. But the returned error code was wrong: to modprobe, the -EEXIST means that _this_ driver is already installed. It therefore doesn't produce the needed error message when _another_ driver is trying to register for the same device. Returning -EBUSY fixes the problem.

---
 drivers/base/driver.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)
drivers/base/driver.c +1 -1
index ed2ebd3..f367885 100644
@@ -236,7 +236,7 @@ int driver_register(struct device_driver *drv)
 		put_driver(other);
 		printk(KERN_ERR "Error: Driver '%s' is already registered, "
 			"aborting...\n", drv->name);
-		return -EEXIST;
+		return -EBUSY;
 	}
 
 	ret = bus_add_driver(drv);
Signature · 1 line
1.6.4.2
#4 lore raw

PATCH 4/9 Documentation: ABI: document /sys/devices/system/cpu/

In reply to Greg KH

From: Alex Chiang <[email protected]>

This interface has been around for a long time, but hasn't been officially documented.

Document the top level sysfs directory for CPU attributes.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +12 -0
index 175bb4f..86126b1 100644
@@ -1,3 +1,15 @@
+What:		/sys/devices/system/cpu/
+Date:		pre-git history
+Contact:	Linux kernel mailing list <[email protected]>
+Description:
+		A collection of both global and individual CPU attributes
+
+		Individual CPU attributes are contained in subdirectories
+		named by the kernel's logical CPU number, e.g.:
+
+		/sys/devices/system/cpu/cpu#/
+
+
 What:      /sys/devices/system/cpu/cpu*/cache/index*/cache_disable_X
 Date:      August 2008
 KernelVersion:	2.6.27
Signature · 1 line
1.6.4.2
#6 lore raw

PATCH 6/9 Documentation: ABI: /sys/devices/system/cpu/cpu#/ topology files

In reply to Greg KH

From: Alex Chiang <[email protected]>

Add brief descriptions for the following sysfs files:

/sys/devices/system/cpu/cpu#/topology/core_id /sys/devices/system/cpu/cpu#/topology/core_siblings /sys/devices/system/cpu/cpu#/topology/core_siblings_list /sys/devices/system/cpu/cpu#/topology/physical_package_id /sys/devices/system/cpu/cpu#/topology/thread_siblings /sys/devices/system/cpu/cpu#/topology/thread_siblings_list

The descriptions in Documentation/cputopology.txt weren't very informative, so I attempted a better description based on code reading and hopeful guessing.

Updated Documentation/cputopology.txt with the better descriptions and fixed some style issues.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   39 ++++++++++++++++
 Documentation/cputopology.txt                      |   47 ++++++++++++-------
 2 files changed, 69 insertions(+), 17 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +39 -0
index 871acdb..2ade5c0 100644
@@ -38,6 +38,45 @@ Description:	CPU topology files that describe kernel limits related to
 		See Documentation/cputopology.txt for more information.
 
 
+What:		/sys/devices/system/cpu/cpu#/topology/core_id
+		/sys/devices/system/cpu/cpu#/topology/core_siblings
+		/sys/devices/system/cpu/cpu#/topology/core_siblings_list
+		/sys/devices/system/cpu/cpu#/topology/physical_package_id
+		/sys/devices/system/cpu/cpu#/topology/thread_siblings
+		/sys/devices/system/cpu/cpu#/topology/thread_siblings_list
+Date:		December 2008
+Contact:	Linux kernel mailing list <[email protected]>
+Description:	CPU topology files that describe a logical CPU's relationship
+		to other cores and threads in the same physical package.
+
+		One cpu# directory is created per logical CPU in the system,
+		e.g. /sys/devices/system/cpu/cpu42/.
+
+		Briefly, the files above are:
+
+		core_id: the CPU core ID of cpu#. Typically it is the
+		hardware platform's identifier (rather than the kernel's).
+		The actual value is architecture and platform dependent.
+
+		core_siblings: internal kernel map of cpu#'s hardware threads
+		within the same physical_package_id.
+
+		core_siblings_list: human-readable list of the logical CPU
+		numbers within the same physical_package_id as cpu#.
+
+		physical_package_id: physical package id of cpu#. Typically
+		corresponds to a physical socket number, but the actual value
+		is architecture and platform dependent.
+
+		thread_siblings: internel kernel map of cpu#'s hardware
+		threads within the same core as cpu#
+
+		thread_siblings_list: human-readable list of cpu#'s hardware
+		threads within the same core as cpu#
+
+		See Documentation/cputopology.txt for more information.
+
+
 What:      /sys/devices/system/cpu/cpu*/cache/index*/cache_disable_X
 Date:      August 2008
 KernelVersion:	2.6.27
Documentation/cputopology.txt +30 -17

89 lines not on this page · raw message

Signature · 1 line
1.6.4.2
#7 lore raw

PATCH 7/9 Documentation: ABI: /sys/devices/system/cpu/sched_[mc|smt]_power_savings

In reply to Greg KH

From: Alex Chiang <[email protected]>

Document sched_[mc|smt]_power_savings by reading existing code and git logs.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   24 ++++++++++++++++++++
 1 files changed, 24 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +24 -0
index 2ade5c0..8cdda1c 100644
@@ -9,6 +9,30 @@ Description:
 
 		/sys/devices/system/cpu/cpu#/
 
+What:		/sys/devices/system/cpu/sched_mc_power_savings
+		/sys/devices/system/cpu/sched_smt_power_savings
+Date:		June 2006
+Contact:	Linux kernel mailing list <[email protected]>
+Description:	Discover and adjust the kernel's multi-core scheduler support.
+
+		Possible values are:
+
+		0 - No power saving load balance (default value)
+		1 - Fill one thread/core/package first for long running threads
+		2 - Also bias task wakeups to semi-idle cpu package for power
+		    savings
+
+		sched_mc_power_savings is dependent upon SCHED_MC, which is
+		itself architecture dependent.
+
+		sched_smt_power_savings is dependent upon SCHED_SMT, which
+		is itself architecture dependent.
+
+		The two files are independent of each other. It is possible
+		that one file may be present without the other.
+
+		Introduced by git commit 5c45bf27.
+
 
 What:		/sys/devices/system/cpu/kernel_max
 		/sys/devices/system/cpu/offline
Signature · 1 line
1.6.4.2
#5 lore raw

PATCH 5/9 Documentation: ABI: /sys/devices/system/cpu/ topology files

In reply to Greg KH

From: Alex Chiang <[email protected]>

Add brief descriptions for the following sysfs files:

/sys/devices/system/cpu/kernel_max
/sys/devices/system/cpu/offline
/sys/devices/system/cpu/online
/sys/devices/system/cpu/possible
/sys/devices/system/cpu/present

Excerpted the relevant information from Documentation/cputopology.txt and pointed back to cputopology.txt as the authoritative source of information.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   28 ++++++++++++++++++++
 1 files changed, 28 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +28 -0
index 86126b1..871acdb 100644
@@ -10,6 +10,34 @@ Description:
 		/sys/devices/system/cpu/cpu#/
 
 
+What:		/sys/devices/system/cpu/kernel_max
+		/sys/devices/system/cpu/offline
+		/sys/devices/system/cpu/online
+		/sys/devices/system/cpu/possible
+		/sys/devices/system/cpu/present
+Date:		December 2008
+Contact:	Linux kernel mailing list <[email protected]>
+Description:	CPU topology files that describe kernel limits related to
+		hotplug. Briefly:
+
+		kernel_max: the maximum cpu index allowed by the kernel
+		configuration.
+
+		offline: cpus that are not online because they have been
+		HOTPLUGGED off or exceed the limit of cpus allowed by the
+		kernel configuration (kernel_max above).
+
+		online: cpus that are online and being scheduled.
+
+		possible: cpus that have been allocated resources and can be
+		brought online if they are present.
+
+		present: cpus that have been identified as being present in
+		the system.
+
+		See Documentation/cputopology.txt for more information.
+
+
 What:      /sys/devices/system/cpu/cpu*/cache/index*/cache_disable_X
 Date:      August 2008
 KernelVersion:	2.6.27
Signature · 1 line
1.6.4.2
#9 lore raw

PATCH 9/9 Documentation: ABI: /sys/devices/system/cpu/cpu#/node

In reply to Greg KH

From: Alex Chiang <[email protected]>

Describe NUMA node symlink created for CPUs when CONFIG_NUMA is set.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +15 -0
index 968d8ba..a703b9e 100644
@@ -62,6 +62,21 @@ Description:	CPU topology files that describe kernel limits related to
 		See Documentation/cputopology.txt for more information.
 
 
+
+What:		/sys/devices/system/cpu/cpu#/node
+Date:		October 2009
+Contact:	Linux memory management mailing list <[email protected]>
+Description:	Discover NUMA node a CPU belongs to
+
+		When CONFIG_NUMA is enabled, a symbolic link that points
+		to the corresponding NUMA node directory.
+
+		For example, the following symlink is created for cpu42
+		in NUMA node 2:
+
+		/sys/devices/system/cpu/cpu42/node2 -> ../../node/node2
+
+
 What:		/sys/devices/system/cpu/cpu#/topology/core_id
 		/sys/devices/system/cpu/cpu#/topology/core_siblings
 		/sys/devices/system/cpu/cpu#/topology/core_siblings_list
Signature · 1 line
1.6.4.2
#8 lore raw

PATCH 8/9 Documentation: ABI: /sys/devices/system/cpu/cpuidle/

In reply to Greg KH

From: Alex Chiang <[email protected]>

Document cpuidle sysfs attributes by reading code, Documentation/cpuidle/, and git logs.

---
 Documentation/ABI/testing/sysfs-devices-system-cpu |   20 ++++++++++++++++++++
 1 files changed, 20 insertions(+), 0 deletions(-)
Documentation/ABI/testing/sysfs-devices-system-cpu +20 -0
index 8cdda1c..968d8ba 100644
@@ -101,6 +101,26 @@ Description:	CPU topology files that describe a logical CPU's relationship
 		See Documentation/cputopology.txt for more information.
 
 
+What:		/sys/devices/system/cpu/cpuidle/current_driver
+		/sys/devices/system/cpu/cpuidle/current_governer_ro
+Date:		September 2007
+Contact:	Linux kernel mailing list <[email protected]>
+Description:	Discover cpuidle policy and mechanism
+
+		Various CPUs today support multiple idle levels that are
+		differentiated by varying exit latencies and power
+		consumption during idle.
+
+		Idle policy (governor) is differentiated from idle mechanism
+		(driver)
+
+		current_driver: displays current idle mechanism
+
+		current_governor_ro: displays current idle policy
+
+		See files in Documentation/cpuidle/ for more information.
+
+
 What:      /sys/devices/system/cpu/cpu*/cache/index*/cache_disable_X
 Date:      August 2008
 KernelVersion:	2.6.27
Signature · 1 line
1.6.4.2
#3 lore raw

PATCH 3/9 Documentation: ABI: rename sysfs-devices-cache_disable properly

In reply to Greg KH

From: Alex Chiang <[email protected]>

Rename sysfs-devices-cache_disable to sysfs-devices-system-cpu, in order to keep a stricter correlation between a sysfs directory and its documentation.

---
 ...ices-cache_disable => sysfs-devices-system-cpu} |    0
 1 files changed, 0 insertions(+), 0 deletions(-)
 rename Documentation/ABI/testing/{sysfs-devices-cache_disable => sysfs-devices-system-cpu} (100%)
Documentation/ABI/testing/sysfs-devices-system-cpu renamed from Documentation/ABI/testing/sysfs-devices-cache_disable +0 -0
similarity index 100%
rename from Documentation/ABI/testing/sysfs-devices-cache_disable
rename to Documentation/ABI/testing/sysfs-devices-system-cpu
Signature · 1 line
1.6.4.2
#2 lore raw

PATCH 2/9 Driver core: allow certain drivers prohibit bind/unbind via sysfs

In reply to Greg KH

From: Dmitry Torokhov <[email protected]>

Platform drivers registered via platform_driver_probe() can be bound to devices only once, upon registration, because discard their probe() routines to save memory. Unbinding the driver through sysfs 'unbind' leaves the device stranded and confuses users so let's not create bind and unbind attributes for such drivers.

---
 drivers/base/bus.c      |   17 +++++++++++------
 drivers/base/platform.c |    6 +++++-
 include/linux/device.h  |    4 +++-
 3 files changed, 19 insertions(+), 8 deletions(-)
drivers/base/bus.c +11 -6
index 973bf2a..63c143e 100644
@@ -689,15 +689,19 @@ int bus_add_driver(struct device_driver *drv)
 		printk(KERN_ERR "%s: driver_add_attrs(%s) failed\n",
 			__func__, drv->name);
 	}
-	error = add_bind_files(drv);
-	if (error) {
-		/* Ditto */
-		printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
-			__func__, drv->name);
+
+	if (!drv->suppress_bind_attrs) {
+		error = add_bind_files(drv);
+		if (error) {
+			/* Ditto */
+			printk(KERN_ERR "%s: add_bind_files(%s) failed\n",
+				__func__, drv->name);
+		}
 	}
 
 	kobject_uevent(&priv->kobj, KOBJ_ADD);
 	return 0;
+
 out_unregister:
 	kfree(drv->p);
 	drv->p = NULL;
@@ -720,7 +724,8 @@ void bus_remove_driver(struct device_driver *drv)
 	if (!drv->bus)
 		return;
 
-	remove_bind_files(drv);
+	if (!drv->suppress_bind_attrs)
+		remove_bind_files(drv);
 	driver_remove_attrs(drv->bus, drv);
 	driver_remove_file(drv, &driver_attr_uevent);
 	klist_remove(&drv->p->knode_bus);
drivers/base/platform.c +5 -1
index ed156a1..4fa954b 100644
@@ -521,11 +521,15 @@ int __init_or_module platform_driver_probe(struct platform_driver *drv,
 {
 	int retval, code;
 
+	/* make sure driver won't have bind/unbind attributes */
+	drv->driver.suppress_bind_attrs = true;
+
 	/* temporary section violation during probe() */
 	drv->probe = probe;
 	retval = code = platform_driver_register(drv);
 
-	/* Fixup that section violation, being paranoid about code scanning
+	/*
+	 * Fixup that section violation, being paranoid about code scanning
 	 * the list of drivers in order to probe new devices.  Check to see
 	 * if the probe was successful, and make sure any forced probes of
 	 * new devices fail.
include/linux/device.h +3 -1
index aca31bf..2ea3e49 100644
@@ -124,7 +124,9 @@ struct device_driver {
 	struct bus_type		*bus;
 
 	struct module		*owner;
-	const char 		*mod_name;	/* used for built-in modules */
+	const char		*mod_name;	/* used for built-in modules */
+
+	bool suppress_bind_attrs;	/* disables bind/unbind via sysfs */
 
 	int (*probe) (struct device *dev);
 	int (*remove) (struct device *dev);
Signature · 1 line
1.6.4.2