diff options
author | Dave Jiang <dave.jiang@intel.com> | 2020-01-22 02:44:05 +0300 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2020-01-24 08:48:45 +0300 |
commit | c52ca478233c172b2d322b5241d6279a8661cbba (patch) | |
tree | 7006d7e739952f598ff1a308239d2b794fc2cd22 /drivers/dma/idxd/init.c | |
parent | bfe1d56091c1a404b3d4ce7e9809d745fc4453bb (diff) | |
download | linux-c52ca478233c172b2d322b5241d6279a8661cbba.tar.xz |
dmaengine: idxd: add configuration component of driver
The device is left unconfigured when the driver is loaded. Various
components are configured via the driver sysfs attributes. Once
configuration is done, the device can be enabled by writing the device name
to the bind attribute of the device driver sysfs. Disabling can be done
similarly. Also the individual work queues can also be enabled and disabled
through the bind/unbind attributes. A constructed hierarchy is created
through the struct device framework in order to provide appropriate
configuration points and device state and status. This hierarchy is
presented off the virtual DSA bus.
i.e. /sys/bus/dsa/...
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/157965024585.73301.6431413676230150589.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/idxd/init.c')
-rw-r--r-- | drivers/dma/idxd/init.c | 27 |
1 files changed, 26 insertions, 1 deletions
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c index 6e89a87d62b0..229386464923 100644 --- a/drivers/dma/idxd/init.c +++ b/drivers/dma/idxd/init.c @@ -244,6 +244,7 @@ static void idxd_read_caps(struct idxd_device *idxd) dev_dbg(dev, "max groups: %u\n", idxd->max_groups); idxd->max_tokens = idxd->hw.group_cap.total_tokens; dev_dbg(dev, "max tokens: %u\n", idxd->max_tokens); + idxd->nr_tokens = idxd->max_tokens; /* read engine capabilities */ idxd->hw.engine_cap.bits = @@ -381,6 +382,14 @@ static int idxd_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id) return -ENODEV; } + rc = idxd_setup_sysfs(idxd); + if (rc) { + dev_err(dev, "IDXD sysfs setup failed\n"); + return -ENODEV; + } + + idxd->state = IDXD_DEV_CONF_READY; + dev_info(&pdev->dev, "Intel(R) Accelerator Device (v%x)\n", idxd->hw.version); @@ -418,6 +427,7 @@ static void idxd_remove(struct pci_dev *pdev) struct idxd_device *idxd = pci_get_drvdata(pdev); dev_dbg(&pdev->dev, "%s called\n", __func__); + idxd_cleanup_sysfs(idxd); idxd_shutdown(pdev); idxd_wqs_free_lock(idxd); mutex_lock(&idxd_idr_lock); @@ -453,16 +463,31 @@ static int __init idxd_init_module(void) for (i = 0; i < IDXD_TYPE_MAX; i++) idr_init(&idxd_idrs[i]); + err = idxd_register_bus_type(); + if (err < 0) + return err; + + err = idxd_register_driver(); + if (err < 0) + goto err_idxd_driver_register; + err = pci_register_driver(&idxd_pci_driver); if (err) - return err; + goto err_pci_register; return 0; + +err_pci_register: + idxd_unregister_driver(); +err_idxd_driver_register: + idxd_unregister_bus_type(); + return err; } module_init(idxd_init_module); static void __exit idxd_exit_module(void) { pci_unregister_driver(&idxd_pci_driver); + idxd_unregister_bus_type(); } module_exit(idxd_exit_module); |