[Accel-config] [PATCH v1] accel-config: While initing devices also init groups

ramesh.thomas at intel.com
Newsgroups dev.linux.lists.accel-config
Message-ID <[email protected]>
From: Ramesh Thomas <ramesh.thomas(a)intel.com>

Grouped workqueues and engines rely on state stored in structures
associated with groups. Initialize the groups at the time of device init
so they are available when workqueues are enabled. Flags are used to
ensure groups do not get initialized again if they are already
initialized once.

Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 accfg/lib/libaccfg.c | 31 ++++++++++++++++++-------------
 1 file changed, 18 insertions(+), 13 deletions(-)

diff --git a/accfg/lib/libaccfg.c b/accfg/lib/libaccfg.c
index 316f724..ae862f8 100644
--- a/accfg/lib/libaccfg.c
+++ b/accfg/lib/libaccfg.c
@@ -911,10 +911,26 @@ static int filter_file_name_prefix(const struct dirent *d)
 	return !strncmp(filename_prefix, d->d_name, filename_prefix_len);
 }
 
+static void groups_init(struct accfg_device *device)
+{
+	struct accfg_ctx *ctx = device->ctx;
+
+	if (device->group_init) {
+		dbg(ctx, "group is initialized already\n");
+		return;
+	}
+	device->group_init = 1;
+	set_filename_prefix("group");
+	device_parse(device->ctx, device->device_path, "group",
+			filter_file_name_prefix,
+			device, add_group);
+}
+
 static void devices_init(struct accfg_ctx *ctx)
 {
 	char **accel_name;
 	char *path;
+	struct accfg_device *device;
 
 	if (ctx->devices_init) {
 		dbg(ctx, "device is initialized already\n");
@@ -933,21 +949,10 @@ static void devices_init(struct accfg_ctx *ctx)
 				filter_file_name_prefix, ctx, add_device);
 		free(path);
 	}
-}
 
-static void groups_init(struct accfg_device *device)
-{
-	struct accfg_ctx *ctx = device->ctx;
-
-	if (device->group_init) {
-		dbg(ctx, "group is intialized already\n");
-		return;
+	accfg_device_foreach(ctx, device) {
+		groups_init(device);
 	}
-	device->group_init = 1;
-	set_filename_prefix("group");
-	device_parse(device->ctx, device->device_path, "group",
-			filter_file_name_prefix,
-			device, add_group);
 }
 
 static void engines_init(struct accfg_device *device)
-- 
2.26.2
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.