]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
dmaengine: idxd: Binding and unbinding IDXD device and driver
authorFenghua Yu <fenghua.yu@intel.com>
Fri, 22 Nov 2024 23:30:25 +0000 (15:30 -0800)
committerVinod Koul <vkoul@kernel.org>
Tue, 24 Dec 2024 10:38:04 +0000 (16:08 +0530)
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>
drivers/dma/idxd/init.c

index 02c285499c5a16313fc52f1bbd287e2d747f8308..eb64a38444c116481ece2a4c66eb47981f0b4d5c 100644 (file)
@@ -725,6 +725,39 @@ static void idxd_cleanup(struct idxd_device *idxd)
                idxd_disable_sva(idxd->pdev);
 }
 
+/*
+ * 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.