Skip to content

Commit 3ab4551

Browse files
Fenghua Yuvinodkoul
authored andcommitted
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>
1 parent 087e89b commit 3ab4551

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

drivers/dma/idxd/init.c

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,39 @@ static void idxd_cleanup(struct idxd_device *idxd)
725725
idxd_disable_sva(idxd->pdev);
726726
}
727727

728+
/*
729+
* Attach IDXD device to IDXD driver.
730+
*/
731+
static int idxd_bind(struct device_driver *drv, const char *buf)
732+
{
733+
const struct bus_type *bus = drv->bus;
734+
struct device *dev;
735+
int err = -ENODEV;
736+
737+
dev = bus_find_device_by_name(bus, NULL, buf);
738+
if (dev)
739+
err = device_driver_attach(drv, dev);
740+
741+
put_device(dev);
742+
743+
return err;
744+
}
745+
746+
/*
747+
* Detach IDXD device from driver.
748+
*/
749+
static void idxd_unbind(struct device_driver *drv, const char *buf)
750+
{
751+
const struct bus_type *bus = drv->bus;
752+
struct device *dev;
753+
754+
dev = bus_find_device_by_name(bus, NULL, buf);
755+
if (dev && dev->driver == drv)
756+
device_release_driver(dev);
757+
758+
put_device(dev);
759+
}
760+
728761
/*
729762
* Probe idxd PCI device.
730763
* If idxd is not given, need to allocate idxd and set up its data.

0 commit comments

Comments
 (0)