All of lore.kernel.org
 help / color / mirror / Atom feed
* [Accel-config] [PATCH 3/4] accel-config: Add "forced" option to load-config command
@ 2021-12-08  0:51 Ramesh Thomas
  0 siblings, 0 replies; only message in thread
From: Ramesh Thomas @ 2021-12-08  0:51 UTC (permalink / raw)
  To: accel-config

[-- Attachment #1: Type: text/plain, Size: 1813 bytes --]

Add forced disabling of devices option as a convenience. Disabling of
devices also disables wqs so users can use different configuration files
without having to manually disable enabled devices and wqs before
reconfiguring. The option is -f, forced=true

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

diff --git a/accfg/config.c b/accfg/config.c
index 9fb8874..e96d3fb 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -22,6 +22,7 @@
 
 static bool verbose;
 static bool enable;
+static bool forced;
 static struct util_filter_params util_param;
 
 static LIST_HEAD(activate_dev_list);
@@ -526,10 +527,21 @@ static int configure_json_value(struct accfg_ctx *ctx,
 				}
 				dev_state = accfg_device_get_state(dev);
 				if (dev_state == ACCFG_DEVICE_ENABLED) {
-					fprintf(stderr,
-						"%s is active, will skip...\n", parsed_string);
-					dev = NULL;
-					return 0;
+					fprintf(stderr, "%s is active. ",
+							parsed_string);
+					if (forced) {
+						fprintf(stderr, "Disabling...\n");
+						rc = accfg_device_disable(dev, true);
+						if (rc) {
+							fprintf(stderr,
+								"Failed disabling device\n");
+							return rc;
+						}
+					} else {
+						fprintf(stderr, "Skipping...\n");
+						dev = NULL;
+						return 0;
+					}
 				}
 
 				if (enable) {
@@ -1065,6 +1077,8 @@ int cmd_config(int argc, const char **argv, void *ctx)
 				"emit extra debug messages to stderr"),
 		OPT_BOOLEAN('e', "enable", &enable,
 				"enable configured devices and wqs"),
+		OPT_BOOLEAN('f', "forced", &forced,
+				"enabled devices will be disabled before configuring"),
 		OPT_END(),
 	};
 	const char *const u[] = {
-- 
2.26.3

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-12-08  0:51 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-12-08  0:51 [Accel-config] [PATCH 3/4] accel-config: Add "forced" option to load-config command 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.