diff options
author | Dave Jiang <dave.jiang@intel.com> | 2020-01-22 00:44:29 +0100 |
---|---|---|
committer | Vinod Koul <vkoul@kernel.org> | 2020-01-24 06:48:45 +0100 |
commit | 42d279f9137ab7d5503836baec2739284b278d8f (patch) | |
tree | d2876eeee15f34802ffe1d20f5ff0a331ba08d48 /drivers/dma/idxd/idxd.h | |
parent | dmaengine: idxd: connect idxd to dmaengine subsystem (diff) | |
download | linux-42d279f9137ab7d5503836baec2739284b278d8f.tar.xz linux-42d279f9137ab7d5503836baec2739284b278d8f.zip |
dmaengine: idxd: add char driver to expose submission portal to userland
Create a char device region that will allow acquisition of user portals in
order to allow applications to submit DMA operations. A char device will be
created per work queue that gets exposed. The workqueue type "user"
is used to mark a work queue for user char device. For example if the
workqueue 0 of DSA device 0 is marked for char device, then a device node
of /dev/dsa/wq0.0 will be created.
Signed-off-by: Dave Jiang <dave.jiang@intel.com>
Link: https://lore.kernel.org/r/157965026985.73301.976523230037106742.stgit@djiang5-desk3.ch.intel.com
Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma/idxd/idxd.h')
-rw-r--r-- | drivers/dma/idxd/idxd.h | 37 |
1 files changed, 37 insertions, 0 deletions
diff --git a/drivers/dma/idxd/idxd.h b/drivers/dma/idxd/idxd.h index a36214818d1e..b8f8a363b4a7 100644 --- a/drivers/dma/idxd/idxd.h +++ b/drivers/dma/idxd/idxd.h @@ -7,6 +7,7 @@ #include <linux/dmaengine.h> #include <linux/percpu-rwsem.h> #include <linux/wait.h> +#include <linux/cdev.h> #include "registers.h" #define IDXD_DRIVER_VERSION "1.00" @@ -63,6 +64,14 @@ enum idxd_wq_flag { enum idxd_wq_type { IDXD_WQT_NONE = 0, IDXD_WQT_KERNEL, + IDXD_WQT_USER, +}; + +struct idxd_cdev { + struct cdev cdev; + struct device *dev; + int minor; + struct wait_queue_head err_queue; }; #define IDXD_ALLOCATED_BATCH_SIZE 128U @@ -82,6 +91,7 @@ enum idxd_complete_type { struct idxd_wq { void __iomem *dportal; struct device conf_dev; + struct idxd_cdev idxd_cdev; struct idxd_device *idxd; int id; enum idxd_wq_type type; @@ -145,6 +155,7 @@ struct idxd_device { enum idxd_device_state state; unsigned long flags; int id; + int major; struct pci_dev *pdev; void __iomem *reg_base; @@ -196,11 +207,29 @@ struct idxd_desc { #define confdev_to_idxd(dev) container_of(dev, struct idxd_device, conf_dev) #define confdev_to_wq(dev) container_of(dev, struct idxd_wq, conf_dev) +extern struct bus_type dsa_bus_type; + static inline bool wq_dedicated(struct idxd_wq *wq) { return test_bit(WQ_FLAG_DEDICATED, &wq->flags); } +enum idxd_portal_prot { + IDXD_PORTAL_UNLIMITED = 0, + IDXD_PORTAL_LIMITED, +}; + +static inline int idxd_get_wq_portal_offset(enum idxd_portal_prot prot) +{ + return prot * 0x1000; +} + +static inline int idxd_get_wq_portal_full_offset(int wq_id, + enum idxd_portal_prot prot) +{ + return ((wq_id * 4) << PAGE_SHIFT) + idxd_get_wq_portal_offset(prot); +} + static inline void idxd_set_type(struct idxd_device *idxd) { struct pci_dev *pdev = idxd->pdev; @@ -233,6 +262,7 @@ int idxd_setup_sysfs(struct idxd_device *idxd); void idxd_cleanup_sysfs(struct idxd_device *idxd); int idxd_register_driver(void); void idxd_unregister_driver(void); +struct bus_type *idxd_get_bus_type(struct idxd_device *idxd); /* device interrupt control */ irqreturn_t idxd_irq_handler(int vec, void *data); @@ -276,4 +306,11 @@ void idxd_dma_complete_txd(struct idxd_desc *desc, enum idxd_complete_type comp_type); dma_cookie_t idxd_dma_tx_submit(struct dma_async_tx_descriptor *tx); +/* cdev */ +int idxd_cdev_register(void); +void idxd_cdev_remove(void); +int idxd_cdev_get_major(struct idxd_device *idxd); +int idxd_wq_add_cdev(struct idxd_wq *wq); +void idxd_wq_del_cdev(struct idxd_wq *wq); + #endif |