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/device.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/device.c')
-rw-r--r-- | drivers/dma/idxd/device.c | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c index af2bdc18df3d..d626780caa53 100644 --- a/drivers/dma/idxd/device.c +++ b/drivers/dma/idxd/device.c @@ -155,6 +155,9 @@ int idxd_wq_alloc_resources(struct idxd_wq *wq) struct device *dev = &idxd->pdev->dev; int rc, num_descs, i; + if (wq->type != IDXD_WQT_KERNEL) + return 0; + num_descs = wq->size + idxd->hw.gen_cap.max_descs_per_engine * group->num_engines; wq->num_descs = num_descs; @@ -206,6 +209,9 @@ void idxd_wq_free_resources(struct idxd_wq *wq) { struct device *dev = &wq->idxd->pdev->dev; + if (wq->type != IDXD_WQT_KERNEL) + return; + free_hw_descs(wq); free_descs(wq); dma_free_coherent(dev, wq->compls_size, wq->compls, wq->compls_addr); @@ -277,6 +283,31 @@ int idxd_wq_disable(struct idxd_wq *wq) return 0; } +int idxd_wq_map_portal(struct idxd_wq *wq) +{ + struct idxd_device *idxd = wq->idxd; + struct pci_dev *pdev = idxd->pdev; + struct device *dev = &pdev->dev; + resource_size_t start; + + start = pci_resource_start(pdev, IDXD_WQ_BAR); + start = start + wq->id * IDXD_PORTAL_SIZE; + + wq->dportal = devm_ioremap(dev, start, IDXD_PORTAL_SIZE); + if (!wq->dportal) + return -ENOMEM; + dev_dbg(dev, "wq %d portal mapped at %p\n", wq->id, wq->dportal); + + return 0; +} + +void idxd_wq_unmap_portal(struct idxd_wq *wq) +{ + struct device *dev = &wq->idxd->pdev->dev; + + devm_iounmap(dev, wq->dportal); +} + /* Device control bits */ static inline bool idxd_is_enabled(struct idxd_device *idxd) { |