aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'drivers')
-rw-r--r--drivers/acpi/processor_throttling.c10
-rw-r--r--drivers/base/cpu.c48
-rw-r--r--drivers/base/node.c29
-rw-r--r--drivers/base/topology.c41
-rw-r--r--drivers/firmware/dcdbas.c4
-rw-r--r--drivers/pci/pci-driver.c9
-rw-r--r--drivers/pci/pci-sysfs.c20
-rw-r--r--drivers/pci/probe.c27
8 files changed, 158 insertions, 30 deletions
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c
index 1b8e592a8241..0bba3a914e86 100644
--- a/drivers/acpi/processor_throttling.c
+++ b/drivers/acpi/processor_throttling.c
@@ -838,10 +838,10 @@ static int acpi_processor_get_throttling(struct acpi_processor *pr)
838 * Migrate task to the cpu pointed by pr. 838 * Migrate task to the cpu pointed by pr.
839 */ 839 */
840 saved_mask = current->cpus_allowed; 840 saved_mask = current->cpus_allowed;
841 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 841 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
842 ret = pr->throttling.acpi_processor_get_throttling(pr); 842 ret = pr->throttling.acpi_processor_get_throttling(pr);
843 /* restore the previous state */ 843 /* restore the previous state */
844 set_cpus_allowed(current, saved_mask); 844 set_cpus_allowed_ptr(current, &saved_mask);
845 845
846 return ret; 846 return ret;
847} 847}
@@ -1025,7 +1025,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1025 * it can be called only for the cpu pointed by pr. 1025 * it can be called only for the cpu pointed by pr.
1026 */ 1026 */
1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) { 1027 if (p_throttling->shared_type == DOMAIN_COORD_TYPE_SW_ANY) {
1028 set_cpus_allowed(current, cpumask_of_cpu(pr->id)); 1028 set_cpus_allowed_ptr(current, &cpumask_of_cpu(pr->id));
1029 ret = p_throttling->acpi_processor_set_throttling(pr, 1029 ret = p_throttling->acpi_processor_set_throttling(pr,
1030 t_state.target_state); 1030 t_state.target_state);
1031 } else { 1031 } else {
@@ -1056,7 +1056,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1056 continue; 1056 continue;
1057 } 1057 }
1058 t_state.cpu = i; 1058 t_state.cpu = i;
1059 set_cpus_allowed(current, cpumask_of_cpu(i)); 1059 set_cpus_allowed_ptr(current, &cpumask_of_cpu(i));
1060 ret = match_pr->throttling. 1060 ret = match_pr->throttling.
1061 acpi_processor_set_throttling( 1061 acpi_processor_set_throttling(
1062 match_pr, t_state.target_state); 1062 match_pr, t_state.target_state);
@@ -1074,7 +1074,7 @@ int acpi_processor_set_throttling(struct acpi_processor *pr, int state)
1074 &t_state); 1074 &t_state);
1075 } 1075 }
1076 /* restore the previous state */ 1076 /* restore the previous state */
1077 set_cpus_allowed(current, saved_mask); 1077 set_cpus_allowed_ptr(current, &saved_mask);
1078 return ret; 1078 return ret;
1079} 1079}
1080 1080
diff --git a/drivers/base/cpu.c b/drivers/base/cpu.c
index 499b003f9278..2c76afff3b15 100644
--- a/drivers/base/cpu.c
+++ b/drivers/base/cpu.c
@@ -103,6 +103,51 @@ static SYSDEV_ATTR(crash_notes, 0400, show_crash_notes, NULL);
103#endif 103#endif
104 104
105/* 105/*
106 * Print cpu online, possible, present, and system maps
107 */
108static ssize_t print_cpus_map(char *buf, cpumask_t *map)
109{
110 int n = cpulist_scnprintf(buf, PAGE_SIZE-2, *map);
111
112 buf[n++] = '\n';
113 buf[n] = '\0';
114 return n;
115}
116
117#define print_cpus_func(type) \
118static ssize_t print_cpus_##type(struct sysdev_class *class, char *buf) \
119{ \
120 return print_cpus_map(buf, &cpu_##type##_map); \
121} \
122struct sysdev_class_attribute attr_##type##_map = \
123 _SYSDEV_CLASS_ATTR(type, 0444, print_cpus_##type, NULL)
124
125print_cpus_func(online);
126print_cpus_func(possible);
127print_cpus_func(present);
128
129struct sysdev_class_attribute *cpu_state_attr[] = {
130 &attr_online_map,
131 &attr_possible_map,
132 &attr_present_map,
133};
134
135static int cpu_states_init(void)
136{
137 int i;
138 int err = 0;
139
140 for (i = 0; i < ARRAY_SIZE(cpu_state_attr); i++) {
141 int ret;
142 ret = sysdev_class_create_file(&cpu_sysdev_class,
143 cpu_state_attr[i]);
144 if (!err)
145 err = ret;
146 }
147 return err;
148}
149
150/*
106 * register_cpu - Setup a sysfs device for a CPU. 151 * register_cpu - Setup a sysfs device for a CPU.
107 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in 152 * @cpu - cpu->hotpluggable field set to 1 will generate a control file in
108 * sysfs for this CPU. 153 * sysfs for this CPU.
@@ -147,6 +192,9 @@ int __init cpu_dev_init(void)
147 int err; 192 int err;
148 193
149 err = sysdev_class_register(&cpu_sysdev_class); 194 err = sysdev_class_register(&cpu_sysdev_class);
195 if (!err)
196 err = cpu_states_init();
197
150#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT) 198#if defined(CONFIG_SCHED_MC) || defined(CONFIG_SCHED_SMT)
151 if (!err) 199 if (!err)
152 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class); 200 err = sched_create_sysfs_power_savings_entries(&cpu_sysdev_class);
diff --git a/drivers/base/node.c b/drivers/base/node.c
index e59861f18ce5..12fde2d03d69 100644
--- a/drivers/base/node.c
+++ b/drivers/base/node.c
@@ -19,21 +19,34 @@ static struct sysdev_class node_class = {
19}; 19};
20 20
21 21
22static ssize_t node_read_cpumap(struct sys_device * dev, char * buf) 22static ssize_t node_read_cpumap(struct sys_device *dev, int type, char *buf)
23{ 23{
24 struct node *node_dev = to_node(dev); 24 struct node *node_dev = to_node(dev);
25 cpumask_t mask = node_to_cpumask(node_dev->sysdev.id); 25 node_to_cpumask_ptr(mask, node_dev->sysdev.id);
26 int len; 26 int len;
27 27
28 /* 2004/06/03: buf currently PAGE_SIZE, need > 1 char per 4 bits. */ 28 /* 2008/04/07: buf currently PAGE_SIZE, need 9 chars per 32 bits. */
29 BUILD_BUG_ON(MAX_NUMNODES/4 > PAGE_SIZE/2); 29 BUILD_BUG_ON((NR_CPUS/32 * 9) > (PAGE_SIZE-1));
30 30
31 len = cpumask_scnprintf(buf, PAGE_SIZE-1, mask); 31 len = type?
32 len += sprintf(buf + len, "\n"); 32 cpulist_scnprintf(buf, PAGE_SIZE-2, *mask):
33 cpumask_scnprintf(buf, PAGE_SIZE-2, *mask);
34 buf[len++] = '\n';
35 buf[len] = '\0';
33 return len; 36 return len;
34} 37}
35 38
36static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumap, NULL); 39static inline ssize_t node_read_cpumask(struct sys_device *dev, char *buf)
40{
41 return node_read_cpumap(dev, 0, buf);
42}
43static inline ssize_t node_read_cpulist(struct sys_device *dev, char *buf)
44{
45 return node_read_cpumap(dev, 1, buf);
46}
47
48static SYSDEV_ATTR(cpumap, S_IRUGO, node_read_cpumask, NULL);
49static SYSDEV_ATTR(cpulist, S_IRUGO, node_read_cpulist, NULL);
37 50
38#define K(x) ((x) << (PAGE_SHIFT - 10)) 51#define K(x) ((x) << (PAGE_SHIFT - 10))
39static ssize_t node_read_meminfo(struct sys_device * dev, char * buf) 52static ssize_t node_read_meminfo(struct sys_device * dev, char * buf)
@@ -149,6 +162,7 @@ int register_node(struct node *node, int num, struct node *parent)
149 162
150 if (!error){ 163 if (!error){
151 sysdev_create_file(&node->sysdev, &attr_cpumap); 164 sysdev_create_file(&node->sysdev, &attr_cpumap);
165 sysdev_create_file(&node->sysdev, &attr_cpulist);
152 sysdev_create_file(&node->sysdev, &attr_meminfo); 166 sysdev_create_file(&node->sysdev, &attr_meminfo);
153 sysdev_create_file(&node->sysdev, &attr_numastat); 167 sysdev_create_file(&node->sysdev, &attr_numastat);
154 sysdev_create_file(&node->sysdev, &attr_distance); 168 sysdev_create_file(&node->sysdev, &attr_distance);
@@ -166,6 +180,7 @@ int register_node(struct node *node, int num, struct node *parent)
166void unregister_node(struct node *node) 180void unregister_node(struct node *node)
167{ 181{
168 sysdev_remove_file(&node->sysdev, &attr_cpumap); 182 sysdev_remove_file(&node->sysdev, &attr_cpumap);
183 sysdev_remove_file(&node->sysdev, &attr_cpulist);
169 sysdev_remove_file(&node->sysdev, &attr_meminfo); 184 sysdev_remove_file(&node->sysdev, &attr_meminfo);
170 sysdev_remove_file(&node->sysdev, &attr_numastat); 185 sysdev_remove_file(&node->sysdev, &attr_numastat);
171 sysdev_remove_file(&node->sysdev, &attr_distance); 186 sysdev_remove_file(&node->sysdev, &attr_distance);
diff --git a/drivers/base/topology.c b/drivers/base/topology.c
index e1d3ad4db2f0..fdf4044d2e74 100644
--- a/drivers/base/topology.c
+++ b/drivers/base/topology.c
@@ -40,15 +40,38 @@ static ssize_t show_##name(struct sys_device *dev, char *buf) \
40 return sprintf(buf, "%d\n", topology_##name(cpu)); \ 40 return sprintf(buf, "%d\n", topology_##name(cpu)); \
41} 41}
42 42
43#define define_siblings_show_func(name) \ 43static ssize_t show_cpumap(int type, cpumask_t *mask, char *buf)
44static ssize_t show_##name(struct sys_device *dev, char *buf) \ 44{
45 ptrdiff_t len = PTR_ALIGN(buf + PAGE_SIZE - 1, PAGE_SIZE) - buf;
46 int n = 0;
47
48 if (len > 1) {
49 n = type?
50 cpulist_scnprintf(buf, len-2, *mask):
51 cpumask_scnprintf(buf, len-2, *mask);
52 buf[n++] = '\n';
53 buf[n] = '\0';
54 }
55 return n;
56}
57
58#define define_siblings_show_map(name) \
59static inline ssize_t show_##name(struct sys_device *dev, char *buf) \
45{ \ 60{ \
46 ssize_t len = -1; \
47 unsigned int cpu = dev->id; \ 61 unsigned int cpu = dev->id; \
48 len = cpumask_scnprintf(buf, NR_CPUS+1, topology_##name(cpu)); \ 62 return show_cpumap(0, &(topology_##name(cpu)), buf); \
49 return (len + sprintf(buf + len, "\n")); \
50} 63}
51 64
65#define define_siblings_show_list(name) \
66static inline ssize_t show_##name##_list(struct sys_device *dev, char *buf) \
67{ \
68 unsigned int cpu = dev->id; \
69 return show_cpumap(1, &(topology_##name(cpu)), buf); \
70}
71
72#define define_siblings_show_func(name) \
73 define_siblings_show_map(name); define_siblings_show_list(name)
74
52#ifdef topology_physical_package_id 75#ifdef topology_physical_package_id
53define_id_show_func(physical_package_id); 76define_id_show_func(physical_package_id);
54define_one_ro(physical_package_id); 77define_one_ro(physical_package_id);
@@ -68,7 +91,9 @@ define_one_ro(core_id);
68#ifdef topology_thread_siblings 91#ifdef topology_thread_siblings
69define_siblings_show_func(thread_siblings); 92define_siblings_show_func(thread_siblings);
70define_one_ro(thread_siblings); 93define_one_ro(thread_siblings);
71#define ref_thread_siblings_attr &attr_thread_siblings.attr, 94define_one_ro(thread_siblings_list);
95#define ref_thread_siblings_attr \
96 &attr_thread_siblings.attr, &attr_thread_siblings_list.attr,
72#else 97#else
73#define ref_thread_siblings_attr 98#define ref_thread_siblings_attr
74#endif 99#endif
@@ -76,7 +101,9 @@ define_one_ro(thread_siblings);
76#ifdef topology_core_siblings 101#ifdef topology_core_siblings
77define_siblings_show_func(core_siblings); 102define_siblings_show_func(core_siblings);
78define_one_ro(core_siblings); 103define_one_ro(core_siblings);
79#define ref_core_siblings_attr &attr_core_siblings.attr, 104define_one_ro(core_siblings_list);
105#define ref_core_siblings_attr \
106 &attr_core_siblings.attr, &attr_core_siblings_list.attr,
80#else 107#else
81#define ref_core_siblings_attr 108#define ref_core_siblings_attr
82#endif 109#endif
diff --git a/drivers/firmware/dcdbas.c b/drivers/firmware/dcdbas.c
index 1636806ec55e..0ffef3b7c6ca 100644
--- a/drivers/firmware/dcdbas.c
+++ b/drivers/firmware/dcdbas.c
@@ -265,7 +265,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
265 265
266 /* SMI requires CPU 0 */ 266 /* SMI requires CPU 0 */
267 old_mask = current->cpus_allowed; 267 old_mask = current->cpus_allowed;
268 set_cpus_allowed(current, cpumask_of_cpu(0)); 268 set_cpus_allowed_ptr(current, &cpumask_of_cpu(0));
269 if (smp_processor_id() != 0) { 269 if (smp_processor_id() != 0) {
270 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n", 270 dev_dbg(&dcdbas_pdev->dev, "%s: failed to get CPU 0\n",
271 __FUNCTION__); 271 __FUNCTION__);
@@ -285,7 +285,7 @@ static int smi_request(struct smi_cmd *smi_cmd)
285 ); 285 );
286 286
287out: 287out:
288 set_cpus_allowed(current, old_mask); 288 set_cpus_allowed_ptr(current, &old_mask);
289 return ret; 289 return ret;
290} 290}
291 291
diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
index e571c72e6753..e8d94fafc280 100644
--- a/drivers/pci/pci-driver.c
+++ b/drivers/pci/pci-driver.c
@@ -182,15 +182,18 @@ static int pci_call_probe(struct pci_driver *drv, struct pci_dev *dev,
182 struct mempolicy *oldpol; 182 struct mempolicy *oldpol;
183 cpumask_t oldmask = current->cpus_allowed; 183 cpumask_t oldmask = current->cpus_allowed;
184 int node = pcibus_to_node(dev->bus); 184 int node = pcibus_to_node(dev->bus);
185 if (node >= 0 && node_online(node)) 185
186 set_cpus_allowed(current, node_to_cpumask(node)); 186 if (node >= 0) {
187 node_to_cpumask_ptr(nodecpumask, node);
188 set_cpus_allowed_ptr(current, nodecpumask);
189 }
187 /* And set default memory allocation policy */ 190 /* And set default memory allocation policy */
188 oldpol = current->mempolicy; 191 oldpol = current->mempolicy;
189 current->mempolicy = NULL; /* fall back to system default policy */ 192 current->mempolicy = NULL; /* fall back to system default policy */
190#endif 193#endif
191 error = drv->probe(dev, id); 194 error = drv->probe(dev, id);
192#ifdef CONFIG_NUMA 195#ifdef CONFIG_NUMA
193 set_cpus_allowed(current, oldmask); 196 set_cpus_allowed_ptr(current, &oldmask);
194 current->mempolicy = oldpol; 197 current->mempolicy = oldpol;
195#endif 198#endif
196 return error; 199 return error;
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c
index 8dcf1458aa2f..8d9d648daeba 100644
--- a/drivers/pci/pci-sysfs.c
+++ b/drivers/pci/pci-sysfs.c
@@ -73,8 +73,23 @@ static ssize_t local_cpus_show(struct device *dev,
73 73
74 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); 74 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
75 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); 75 len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask);
76 strcat(buf,"\n"); 76 buf[len++] = '\n';
77 return 1+len; 77 buf[len] = '\0';
78 return len;
79}
80
81
82static ssize_t local_cpulist_show(struct device *dev,
83 struct device_attribute *attr, char *buf)
84{
85 cpumask_t mask;
86 int len;
87
88 mask = pcibus_to_cpumask(to_pci_dev(dev)->bus);
89 len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask);
90 buf[len++] = '\n';
91 buf[len] = '\0';
92 return len;
78} 93}
79 94
80/* show resources */ 95/* show resources */
@@ -201,6 +216,7 @@ struct device_attribute pci_dev_attrs[] = {
201 __ATTR_RO(class), 216 __ATTR_RO(class),
202 __ATTR_RO(irq), 217 __ATTR_RO(irq),
203 __ATTR_RO(local_cpus), 218 __ATTR_RO(local_cpus),
219 __ATTR_RO(local_cpulist),
204 __ATTR_RO(modalias), 220 __ATTR_RO(modalias),
205#ifdef CONFIG_NUMA 221#ifdef CONFIG_NUMA
206 __ATTR_RO(numa_node), 222 __ATTR_RO(numa_node),
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c
index 2db2e4bb0d1e..4b3011a23eff 100644
--- a/drivers/pci/probe.c
+++ b/drivers/pci/probe.c
@@ -82,6 +82,7 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; }
82 * PCI Bus Class Devices 82 * PCI Bus Class Devices
83 */ 83 */
84static ssize_t pci_bus_show_cpuaffinity(struct device *dev, 84static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
85 int type,
85 struct device_attribute *attr, 86 struct device_attribute *attr,
86 char *buf) 87 char *buf)
87{ 88{
@@ -89,12 +90,30 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev,
89 cpumask_t cpumask; 90 cpumask_t cpumask;
90 91
91 cpumask = pcibus_to_cpumask(to_pci_bus(dev)); 92 cpumask = pcibus_to_cpumask(to_pci_bus(dev));
92 ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); 93 ret = type?
93 if (ret < PAGE_SIZE) 94 cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask):
94 buf[ret++] = '\n'; 95 cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask);
96 buf[ret++] = '\n';
97 buf[ret] = '\0';
95 return ret; 98 return ret;
96} 99}
97DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); 100
101static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev,
102 struct device_attribute *attr,
103 char *buf)
104{
105 return pci_bus_show_cpuaffinity(dev, 0, attr, buf);
106}
107
108static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev,
109 struct device_attribute *attr,
110 char *buf)
111{
112 return pci_bus_show_cpuaffinity(dev, 1, attr, buf);
113}
114
115DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL);
116DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL);
98 117
99/* 118/*
100 * PCI Bus Class 119 * PCI Bus Class