diff options
Diffstat (limited to 'drivers/pci')
-rw-r--r-- | drivers/pci/pci-driver.c | 9 | ||||
-rw-r--r-- | drivers/pci/pci-sysfs.c | 20 | ||||
-rw-r--r-- | drivers/pci/probe.c | 27 |
3 files changed, 47 insertions, 9 deletions
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 ae9a7695be97..271d41cc05ab 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
@@ -74,8 +74,23 @@ static ssize_t local_cpus_show(struct device *dev, | |||
74 | 74 | ||
75 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); | 75 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); |
76 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); | 76 | len = cpumask_scnprintf(buf, PAGE_SIZE-2, mask); |
77 | strcat(buf,"\n"); | 77 | buf[len++] = '\n'; |
78 | return 1+len; | 78 | buf[len] = '\0'; |
79 | return len; | ||
80 | } | ||
81 | |||
82 | |||
83 | static ssize_t local_cpulist_show(struct device *dev, | ||
84 | struct device_attribute *attr, char *buf) | ||
85 | { | ||
86 | cpumask_t mask; | ||
87 | int len; | ||
88 | |||
89 | mask = pcibus_to_cpumask(to_pci_dev(dev)->bus); | ||
90 | len = cpulist_scnprintf(buf, PAGE_SIZE-2, mask); | ||
91 | buf[len++] = '\n'; | ||
92 | buf[len] = '\0'; | ||
93 | return len; | ||
79 | } | 94 | } |
80 | 95 | ||
81 | /* show resources */ | 96 | /* show resources */ |
@@ -202,6 +217,7 @@ struct device_attribute pci_dev_attrs[] = { | |||
202 | __ATTR_RO(class), | 217 | __ATTR_RO(class), |
203 | __ATTR_RO(irq), | 218 | __ATTR_RO(irq), |
204 | __ATTR_RO(local_cpus), | 219 | __ATTR_RO(local_cpus), |
220 | __ATTR_RO(local_cpulist), | ||
205 | __ATTR_RO(modalias), | 221 | __ATTR_RO(modalias), |
206 | #ifdef CONFIG_NUMA | 222 | #ifdef CONFIG_NUMA |
207 | __ATTR_RO(numa_node), | 223 | __ATTR_RO(numa_node), |
diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 46a475384362..f991359f0c36 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c | |||
@@ -92,6 +92,7 @@ void pci_remove_legacy_files(struct pci_bus *bus) { return; } | |||
92 | * PCI Bus Class Devices | 92 | * PCI Bus Class Devices |
93 | */ | 93 | */ |
94 | static ssize_t pci_bus_show_cpuaffinity(struct device *dev, | 94 | static ssize_t pci_bus_show_cpuaffinity(struct device *dev, |
95 | int type, | ||
95 | struct device_attribute *attr, | 96 | struct device_attribute *attr, |
96 | char *buf) | 97 | char *buf) |
97 | { | 98 | { |
@@ -99,12 +100,30 @@ static ssize_t pci_bus_show_cpuaffinity(struct device *dev, | |||
99 | cpumask_t cpumask; | 100 | cpumask_t cpumask; |
100 | 101 | ||
101 | cpumask = pcibus_to_cpumask(to_pci_bus(dev)); | 102 | cpumask = pcibus_to_cpumask(to_pci_bus(dev)); |
102 | ret = cpumask_scnprintf(buf, PAGE_SIZE, cpumask); | 103 | ret = type? |
103 | if (ret < PAGE_SIZE) | 104 | cpulist_scnprintf(buf, PAGE_SIZE-2, cpumask): |
104 | buf[ret++] = '\n'; | 105 | cpumask_scnprintf(buf, PAGE_SIZE-2, cpumask); |
106 | buf[ret++] = '\n'; | ||
107 | buf[ret] = '\0'; | ||
105 | return ret; | 108 | return ret; |
106 | } | 109 | } |
107 | DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); | 110 | |
111 | static ssize_t inline pci_bus_show_cpumaskaffinity(struct device *dev, | ||
112 | struct device_attribute *attr, | ||
113 | char *buf) | ||
114 | { | ||
115 | return pci_bus_show_cpuaffinity(dev, 0, attr, buf); | ||
116 | } | ||
117 | |||
118 | static ssize_t inline pci_bus_show_cpulistaffinity(struct device *dev, | ||
119 | struct device_attribute *attr, | ||
120 | char *buf) | ||
121 | { | ||
122 | return pci_bus_show_cpuaffinity(dev, 1, attr, buf); | ||
123 | } | ||
124 | |||
125 | DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL); | ||
126 | DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL); | ||
108 | 127 | ||
109 | /* | 128 | /* |
110 | * PCI Bus Class | 129 | * PCI Bus Class |