From: Fenghua Yu <fenghua.yu@intel.com>
To: "Vinod Koul" <vkoul@kernel.org>, "Dave Jiang" <dave.jiang@intel.com>
Cc: dmaengine@vger.kernel.org,
"linux-kernel" <linux-kernel@vger.kernel.org>,
Fenghua Yu <fenghua.yu@intel.com>
Subject: [PATCH v2 2/5] dmaengine: idxd: Binding and unbinding IDXD device and driver
Date: Fri, 22 Nov 2024 15:30:25 -0800 [thread overview]
Message-ID: <20241122233028.2762809-3-fenghua.yu@intel.com> (raw)
In-Reply-To: <20241122233028.2762809-1-fenghua.yu@intel.com>
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>
---
drivers/dma/idxd/init.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/drivers/dma/idxd/init.c b/drivers/dma/idxd/init.c
index 6679105336ca..a76ec4312a94 100644
--- a/drivers/dma/idxd/init.c
+++ b/drivers/dma/idxd/init.c
@@ -723,6 +723,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.
--
2.37.1
next prev parent reply other threads:[~2024-11-22 23:30 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-22 23:30 [PATCH v2 0/5] Enable FLR for IDXD halt Fenghua Yu
2024-11-22 23:30 ` [PATCH v2 1/5] dmaengine: idxd: Add idxd_pci_probe_alloc() helper Fenghua Yu
2024-11-22 23:30 ` Fenghua Yu [this message]
2024-11-22 23:30 ` [PATCH v2 3/5] dmaengine: idxd: Add idxd_device_config_save() and idxd_device_config_restore() helpers Fenghua Yu
2024-11-22 23:30 ` [PATCH v2 4/5] dmaengine: idxd: Refactor halt handler Fenghua Yu
2024-11-22 23:30 ` [PATCH v2 5/5] dmaengine: idxd: Enable Function Level Reset (FLR) for halt Fenghua Yu
2024-12-02 22:15 ` [PATCH v2 0/5] Enable FLR for IDXD halt Dave Jiang
2024-12-24 10:42 ` Vinod Koul
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20241122233028.2762809-3-fenghua.yu@intel.com \
--to=fenghua.yu@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=vkoul@kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox