diff options
Diffstat (limited to 'drivers/crypto/qat/qat_dh895xcc/adf_drv.c')
-rw-r--r-- | drivers/crypto/qat/qat_dh895xcc/adf_drv.c | 32 |
1 files changed, 12 insertions, 20 deletions
diff --git a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c index 0d0435a41be9..948f66be262b 100644 --- a/drivers/crypto/qat/qat_dh895xcc/adf_drv.c +++ b/drivers/crypto/qat/qat_dh895xcc/adf_drv.c | |||
@@ -119,21 +119,6 @@ static void adf_cleanup_accel(struct adf_accel_dev *accel_dev) | |||
119 | kfree(accel_dev); | 119 | kfree(accel_dev); |
120 | } | 120 | } |
121 | 121 | ||
122 | static uint8_t adf_get_dev_node_id(struct pci_dev *pdev) | ||
123 | { | ||
124 | unsigned int bus_per_cpu = 0; | ||
125 | struct cpuinfo_x86 *c = &cpu_data(num_online_cpus() - 1); | ||
126 | |||
127 | if (!c->phys_proc_id) | ||
128 | return 0; | ||
129 | |||
130 | bus_per_cpu = 256 / (c->phys_proc_id + 1); | ||
131 | |||
132 | if (bus_per_cpu != 0) | ||
133 | return pdev->bus->number / bus_per_cpu; | ||
134 | return 0; | ||
135 | } | ||
136 | |||
137 | static int qat_dev_start(struct adf_accel_dev *accel_dev) | 122 | static int qat_dev_start(struct adf_accel_dev *accel_dev) |
138 | { | 123 | { |
139 | int cpus = num_online_cpus(); | 124 | int cpus = num_online_cpus(); |
@@ -235,7 +220,6 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
235 | void __iomem *pmisc_bar_addr = NULL; | 220 | void __iomem *pmisc_bar_addr = NULL; |
236 | char name[ADF_DEVICE_NAME_LENGTH]; | 221 | char name[ADF_DEVICE_NAME_LENGTH]; |
237 | unsigned int i, bar_nr; | 222 | unsigned int i, bar_nr; |
238 | uint8_t node; | ||
239 | int ret; | 223 | int ret; |
240 | 224 | ||
241 | switch (ent->device) { | 225 | switch (ent->device) { |
@@ -246,12 +230,19 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
246 | return -ENODEV; | 230 | return -ENODEV; |
247 | } | 231 | } |
248 | 232 | ||
249 | node = adf_get_dev_node_id(pdev); | 233 | if (num_possible_nodes() > 1 && dev_to_node(&pdev->dev) < 0) { |
250 | accel_dev = kzalloc_node(sizeof(*accel_dev), GFP_KERNEL, node); | 234 | /* If the accelerator is connected to a node with no memory |
235 | * there is no point in using the accelerator since the remote | ||
236 | * memory transaction will be very slow. */ | ||
237 | dev_err(&pdev->dev, "Invalid NUMA configuration.\n"); | ||
238 | return -EINVAL; | ||
239 | } | ||
240 | |||
241 | accel_dev = kzalloc_node(sizeof(*accel_dev), GFP_KERNEL, | ||
242 | dev_to_node(&pdev->dev)); | ||
251 | if (!accel_dev) | 243 | if (!accel_dev) |
252 | return -ENOMEM; | 244 | return -ENOMEM; |
253 | 245 | ||
254 | accel_dev->numa_node = node; | ||
255 | INIT_LIST_HEAD(&accel_dev->crypto_list); | 246 | INIT_LIST_HEAD(&accel_dev->crypto_list); |
256 | 247 | ||
257 | /* Add accel device to accel table. | 248 | /* Add accel device to accel table. |
@@ -264,7 +255,8 @@ static int adf_probe(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
264 | 255 | ||
265 | accel_dev->owner = THIS_MODULE; | 256 | accel_dev->owner = THIS_MODULE; |
266 | /* Allocate and configure device configuration structure */ | 257 | /* Allocate and configure device configuration structure */ |
267 | hw_data = kzalloc_node(sizeof(*hw_data), GFP_KERNEL, node); | 258 | hw_data = kzalloc_node(sizeof(*hw_data), GFP_KERNEL, |
259 | dev_to_node(&pdev->dev)); | ||
268 | if (!hw_data) { | 260 | if (!hw_data) { |
269 | ret = -ENOMEM; | 261 | ret = -ENOMEM; |
270 | goto out_err; | 262 | goto out_err; |