All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ramesh Thomas <ramesh.thomas at intel.com>
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH 3/4] accel-config: Add "forced" option to load-config command
Date: Tue, 07 Dec 2021 19:51:51 -0500	[thread overview]
Message-ID: <20211208005152.220518-4-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20211208005152.220518-1-ramesh.thomas@intel.com

[-- 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

                 reply	other threads:[~2021-12-08  0:51 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20211208005152.220518-4-ramesh.thomas@intel.com \
    --to=accel-config@lists.01.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 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.