* [Accel-config] [PATCH 1/5] accel-config: Update for driver deferred mdev registration
@ 2021-04-06 3:34 ramesh.thomas
0 siblings, 0 replies; only message in thread
From: ramesh.thomas @ 2021-04-06 3:34 UTC (permalink / raw)
To: accel-config
[-- Attachment #1: Type: text/plain, Size: 2563 bytes --]
From: Ramesh Thomas <ramesh.thomas(a)intel.com>
Mdev is now registered when the first mdev wq is created. It will be
deregistered when the last mdev wq is removed. Change will check for
presence of /sys/class/mdev_bus at the point of mdev use instead of
initializing context at start.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/lib/libaccfg.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index a8d18ff..24ae65c 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -108,6 +108,11 @@ const char *accfg_device_cmd_status[] = {
[ACCFG_CMD_STATUS_MAX] = "",
};
+static inline bool is_mdev_registered(struct accfg_device *device)
+{
+ return device->mdev_path && !access(device->mdev_path, R_OK);
+}
+
static long accfg_get_param_long(struct accfg_ctx *ctx, int dfd, char *name)
{
int fd = openat(dfd, name, O_RDONLY);
@@ -593,11 +598,7 @@ static void *add_device(void *parent, int id, const char *ctl_base,
goto err_dev_path;
}
free(device->mdev_path);
- if (access(p, R_OK)) {
- free(p);
- device->mdev_path = NULL;
- } else
- device->mdev_path = p;
+ device->mdev_path = p;
device->device_buf = calloc(1, strlen(device->device_path) +
MAX_PARAM_LEN);
@@ -614,7 +615,7 @@ static void *add_device(void *parent, int id, const char *ctl_base,
device->bus_type_str = bus_type;
- if (device->mdev_path && add_device_mdevs(ctx, device))
+ if (is_mdev_registered(device) && add_device_mdevs(ctx, device))
goto err_dev_path;
list_add_tail(&ctx->devices, &device->list);
@@ -1050,7 +1051,7 @@ ACCFG_EXPORT int accfg_create_mdev(struct accfg_device *device,
unsigned int version;
int rc;
- if (!device->mdev_path)
+ if (!is_mdev_registered(device))
return -ENOENT;
if (type >= ACCFG_MDEV_TYPE_UNKNOWN || type < 0)
@@ -1110,7 +1111,7 @@ ACCFG_EXPORT int accfg_remove_mdev(struct accfg_device *device, uuid_t uuid)
struct accfg_device_mdev *entry, *next;
int rc, all;
- if (!device->mdev_path)
+ if (!is_mdev_registered(device))
return -ENOENT;
/* remove all mdevs if null uuid is passed */
@@ -1266,7 +1267,7 @@ ACCFG_EXPORT bool accfg_device_get_pasid_enabled(
ACCFG_EXPORT bool accfg_device_get_mdev_enabled(
struct accfg_device *device)
{
- return device->mdev_path != NULL;
+ return is_mdev_registered(device);
}
ACCFG_EXPORT int accfg_device_get_errors(struct accfg_device *device,
--
2.26.3
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2021-04-06 3:34 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2021-04-06 3:34 [Accel-config] [PATCH 1/5] accel-config: Update for driver deferred mdev registration ramesh.thomas
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.