summaryrefslogtreecommitdiff
path: root/drivers/dma
diff options
context:
space:
mode:
authorFenghua Yu <fenghua.yu@intel.com>2024-11-22 15:30:25 -0800
committerVinod Koul <vkoul@kernel.org>2024-12-24 16:08:04 +0530
commit3ab45516772b813315324dc63a900703144e80c4 (patch)
tree39205975a274318524983d49bbe052f92e7194d8 /drivers/dma
parent087e89b69b5fe5529a8809a06b4b4680e54f87e2 (diff)
dmaengine: idxd: Binding and unbinding IDXD device and driver
Add idxd_bind() and idxd_unbind() helpers to bind and unbind the IDXD device and driver. These helpers will be called during Function Level Reset (FLR) processing. Signed-off-by: Fenghua Yu <fenghua.yu@intel.com> Reviewed-by: Dave Jiang <dave.jiang@intel.com> Link: https://lore.kernel.org/r/20241122233028.2762809-3-fenghua.yu@intel.com Signed-off-by: Vinod Koul <vkoul@kernel.org>
Diffstat (limited to 'drivers/dma')
-rw-r--r--drivers/dma/idxd/init.c33
1 files changed, 33 insertions, 0 deletions
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 02c285499c5a..eb64a38444c1 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -726,6 +726,39 @@ static void idxd_cleanup(struct idxd_device *idxd)
}
/*
+ * Attach IDXD device to IDXD driver.
+ */
+static int idxd_bind(struct device_driver *drv, const char *buf)
+{
+ const struct bus_type *bus = drv->bus;
+ struct device *dev;
+ int err = -ENODEV;
+
+ dev = bus_find_device_by_name(bus, NULL, buf);
+ if (dev)
+ err = device_driver_attach(drv, dev);
+
+ put_device(dev);
+
+ return err;
+}
+
+/*
+ * Detach IDXD device from driver.
+ */
+static void idxd_unbind(struct device_driver *drv, const char *buf)
+{
+ const struct bus_type *bus = drv->bus;
+ struct device *dev;
+
+ dev = bus_find_device_by_name(bus, NULL, buf);
+ if (dev && dev->driver == drv)
+ device_release_driver(dev);
+
+ put_device(dev);
+}
+
+/*
* Probe idxd PCI device.
* If idxd is not given, need to allocate idxd and set up its data.
*