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 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 | |||
82 | static 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 | */ |
84 | static ssize_t pci_bus_show_cpuaffinity(struct device *dev, | 84 | static 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 | } |
97 | DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpuaffinity, NULL); | 100 | |
101 | static 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 | |||
108 | static 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 | |||
115 | DEVICE_ATTR(cpuaffinity, S_IRUGO, pci_bus_show_cpumaskaffinity, NULL); | ||
116 | DEVICE_ATTR(cpulistaffinity, S_IRUGO, pci_bus_show_cpulistaffinity, NULL); | ||
98 | 117 | ||
99 | /* | 118 | /* |
100 | * PCI Bus Class | 119 | * PCI Bus Class |