init.c (a39c7cd0438ee2f0b859ee1eb86cdc52217d2223) | init.c (f7f7739847bd68b3c3103fd1b50d943038bd14c7) |
---|---|
1// SPDX-License-Identifier: GPL-2.0 2/* Copyright(c) 2019 Intel Corporation. All rights rsvd. */ 3#include <linux/init.h> 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/slab.h> 7#include <linux/pci.h> 8#include <linux/interrupt.h> --- 20 unchanged lines hidden (view full) --- 29static bool sva = true; 30module_param(sva, bool, 0644); 31MODULE_PARM_DESC(sva, "Toggle SVA support on/off"); 32 33#define DRV_NAME "idxd" 34 35bool support_enqcmd; 36 | 1// SPDX-License-Identifier: GPL-2.0 2/* Copyright(c) 2019 Intel Corporation. All rights rsvd. */ 3#include <linux/init.h> 4#include <linux/kernel.h> 5#include <linux/module.h> 6#include <linux/slab.h> 7#include <linux/pci.h> 8#include <linux/interrupt.h> --- 20 unchanged lines hidden (view full) --- 29static bool sva = true; 30module_param(sva, bool, 0644); 31MODULE_PARM_DESC(sva, "Toggle SVA support on/off"); 32 33#define DRV_NAME "idxd" 34 35bool support_enqcmd; 36 |
37static struct idr idxd_idrs[IDXD_TYPE_MAX]; 38static DEFINE_MUTEX(idxd_idr_lock); | 37static struct ida idxd_idas[IDXD_TYPE_MAX]; |
39 40static struct pci_device_id idxd_pci_tbl[] = { 41 /* DSA ver 1.0 platforms */ 42 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_DSA_SPR0) }, 43 44 /* IAX ver 1.0 platforms */ 45 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IAX_SPR0) }, 46 { 0, } --- 296 unchanged lines hidden (view full) --- 343 goto err_setup; 344 345 rc = idxd_setup_interrupts(idxd); 346 if (rc) 347 goto err_setup; 348 349 dev_dbg(dev, "IDXD interrupt setup complete.\n"); 350 | 38 39static struct pci_device_id idxd_pci_tbl[] = { 40 /* DSA ver 1.0 platforms */ 41 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_DSA_SPR0) }, 42 43 /* IAX ver 1.0 platforms */ 44 { PCI_VDEVICE(INTEL, PCI_DEVICE_ID_INTEL_IAX_SPR0) }, 45 { 0, } --- 296 unchanged lines hidden (view full) --- 342 goto err_setup; 343 344 rc = idxd_setup_interrupts(idxd); 345 if (rc) 346 goto err_setup; 347 348 dev_dbg(dev, "IDXD interrupt setup complete.\n"); 349 |
351 mutex_lock(&idxd_idr_lock); 352 idxd->id = idr_alloc(&idxd_idrs[idxd->type], idxd, 0, 0, GFP_KERNEL); 353 mutex_unlock(&idxd_idr_lock); | 350 idxd->id = ida_alloc(&idxd_idas[idxd->type], GFP_KERNEL); |
354 if (idxd->id < 0) { 355 rc = -ENOMEM; | 351 if (idxd->id < 0) { 352 rc = -ENOMEM; |
356 goto err_idr_fail; | 353 goto err_ida_fail; |
357 } 358 359 idxd->major = idxd_cdev_get_major(idxd); 360 361 dev_dbg(dev, "IDXD device %d probed successfully\n", idxd->id); 362 return 0; 363 | 354 } 355 356 idxd->major = idxd_cdev_get_major(idxd); 357 358 dev_dbg(dev, "IDXD device %d probed successfully\n", idxd->id); 359 return 0; 360 |
364 err_idr_fail: | 361 err_ida_fail: |
365 idxd_mask_error_interrupts(idxd); 366 idxd_mask_msix_vectors(idxd); 367 err_setup: 368 if (device_pasid_enabled(idxd)) 369 idxd_disable_system_pasid(idxd); 370 return rc; 371} 372 --- 140 unchanged lines hidden (view full) --- 513{ 514 struct idxd_device *idxd = pci_get_drvdata(pdev); 515 516 dev_dbg(&pdev->dev, "%s called\n", __func__); 517 idxd_cleanup_sysfs(idxd); 518 idxd_shutdown(pdev); 519 if (device_pasid_enabled(idxd)) 520 idxd_disable_system_pasid(idxd); | 362 idxd_mask_error_interrupts(idxd); 363 idxd_mask_msix_vectors(idxd); 364 err_setup: 365 if (device_pasid_enabled(idxd)) 366 idxd_disable_system_pasid(idxd); 367 return rc; 368} 369 --- 140 unchanged lines hidden (view full) --- 510{ 511 struct idxd_device *idxd = pci_get_drvdata(pdev); 512 513 dev_dbg(&pdev->dev, "%s called\n", __func__); 514 idxd_cleanup_sysfs(idxd); 515 idxd_shutdown(pdev); 516 if (device_pasid_enabled(idxd)) 517 idxd_disable_system_pasid(idxd); |
521 mutex_lock(&idxd_idr_lock); 522 idr_remove(&idxd_idrs[idxd->type], idxd->id); 523 mutex_unlock(&idxd_idr_lock); | 518 ida_free(&idxd_idas[idxd->type], idxd->id); |
524} 525 526static struct pci_driver idxd_pci_driver = { 527 .name = DRV_NAME, 528 .id_table = idxd_pci_tbl, 529 .probe = idxd_pci_probe, 530 .remove = idxd_remove, 531 .shutdown = idxd_shutdown, --- 13 unchanged lines hidden (view full) --- 545 } 546 547 if (!boot_cpu_has(X86_FEATURE_ENQCMD)) 548 pr_warn("Platform does not have ENQCMD(S) support.\n"); 549 else 550 support_enqcmd = true; 551 552 for (i = 0; i < IDXD_TYPE_MAX; i++) | 519} 520 521static struct pci_driver idxd_pci_driver = { 522 .name = DRV_NAME, 523 .id_table = idxd_pci_tbl, 524 .probe = idxd_pci_probe, 525 .remove = idxd_remove, 526 .shutdown = idxd_shutdown, --- 13 unchanged lines hidden (view full) --- 540 } 541 542 if (!boot_cpu_has(X86_FEATURE_ENQCMD)) 543 pr_warn("Platform does not have ENQCMD(S) support.\n"); 544 else 545 support_enqcmd = true; 546 547 for (i = 0; i < IDXD_TYPE_MAX; i++) |
553 idr_init(&idxd_idrs[i]); | 548 ida_init(&idxd_idas[i]); |
554 555 err = idxd_register_bus_type(); 556 if (err < 0) 557 return err; 558 559 err = idxd_register_driver(); 560 if (err < 0) 561 goto err_idxd_driver_register; --- 28 unchanged lines hidden --- | 549 550 err = idxd_register_bus_type(); 551 if (err < 0) 552 return err; 553 554 err = idxd_register_driver(); 555 if (err < 0) 556 goto err_idxd_driver_register; --- 28 unchanged lines hidden --- |