From: Ramesh Thomas <ramesh.thomas at intel.com>
To: accel-config@lists.01.org
Subject: [Accel-config] [PATCH 2/4] accel-config: Fix issues in skipping active configurations
Date: Tue, 07 Dec 2021 19:51:50 -0500 [thread overview]
Message-ID: <20211208005152.220518-3-ramesh.thomas@intel.com> (raw)
In-Reply-To: 20211208005152.220518-1-ramesh.thomas@intel.com
[-- Attachment #1: Type: text/plain, Size: 4151 bytes --]
Skipping of active configurations was not being handled correctly. If
device is active or encounters an error, all configurations related to
that device are skipped. Removed redundant code paths.
Signed-off-by: Ramesh Thomas <ramesh.thomas(a)intel.com>
---
accfg/config.c | 60 ++++++++++++++++++++------------------------------
1 file changed, 24 insertions(+), 36 deletions(-)
diff --git a/accfg/config.c b/accfg/config.c
index 91a71e3..9fb8874 100644
--- a/accfg/config.c
+++ b/accfg/config.c
@@ -486,8 +486,7 @@ static int configure_json_value(struct accfg_ctx *ctx,
char *parsed_string;
char dev_type[MAX_DEV_LEN];
char *accel_type = NULL;
- static char *dev_name;
- static struct accfg_device *dev;
+ static struct accfg_device *dev, *parent;
static struct accfg_wq *wq;
static struct accfg_engine *engine;
static struct accfg_group *group;
@@ -501,6 +500,10 @@ static int configure_json_value(struct accfg_ctx *ctx,
parsed_string = (char *)json_object_get_string(jobj);
if (!parsed_string)
return -EINVAL;
+ dev = NULL;
+ group = NULL;
+ wq = NULL;
+ engine = NULL;
for (accel_type = accfg_basenames[0]; accel_type != NULL; i++) {
memset(dev_type, 0, MAX_DEV_LEN);
if (strstr(parsed_string, accel_type) != NULL) {
@@ -514,6 +517,7 @@ static int configure_json_value(struct accfg_ctx *ctx,
}
if (!strcmp(dev_type, accel_type)) {
+ parent = NULL;
dev = accfg_ctx_device_get_by_name(ctx,
parsed_string);
if (!dev) {
@@ -524,48 +528,43 @@ static int configure_json_value(struct accfg_ctx *ctx,
if (dev_state == ACCFG_DEVICE_ENABLED) {
fprintf(stderr,
"%s is active, will skip...\n", parsed_string);
+ dev = NULL;
return 0;
}
- dev_name = parsed_string;
- wq = NULL;
- engine = NULL;
- group = NULL;
if (enable) {
rc = add_to_activation_list(&activate_dev_list, dev);
if (rc)
return rc;
}
+
+ parent = dev;
+
break;
}
accel_type = accfg_basenames[i];
}
+ /* Skip if device configuration was skipped */
+ if (!parent)
+ return 0;
+
if (strstr(parsed_string, "wq") != NULL) {
rc = sscanf(&parsed_string[strlen("wq")], "%d.%d",
&dev_id, &id);
if (rc != 2)
return -EINVAL;
- if (dev_name)
- dev = accfg_ctx_device_get_by_name(ctx, dev_name);
-
- if (!dev)
- return -ENOENT;
-
- wq = accfg_device_wq_get_by_id(dev, id);
+ wq = accfg_device_wq_get_by_id(parent, id);
if (!wq)
return -ENOENT;
wq_state = accfg_wq_get_state(wq);
if (wq_state == ACCFG_WQ_ENABLED || wq_state == ACCFG_WQ_LOCKED) {
fprintf(stderr, "%s is active, will skip...\n", parsed_string);
+ wq = NULL;
return 0;
}
- dev = NULL;
- engine = NULL;
- group = NULL;
-
if (enable) {
rc = add_to_activation_list(&activate_wq_list, wq);
if (rc)
@@ -579,19 +578,10 @@ static int configure_json_value(struct accfg_ctx *ctx,
if (rc != 2)
return -EINVAL;
- if (dev_name)
- dev = accfg_ctx_device_get_by_name(ctx, dev_name);
-
- if (!dev)
- return -ENOENT;
-
- engine = accfg_device_engine_get_by_id(dev, id);
+ engine = accfg_device_engine_get_by_id(parent, id);
if (!engine)
return -ENOENT;
- dev = NULL;
- wq = NULL;
- group = NULL;
}
if (strstr(parsed_string, "group") != NULL) {
@@ -600,20 +590,18 @@ static int configure_json_value(struct accfg_ctx *ctx,
if (rc != 2)
return -EINVAL;
- if (dev_name)
- dev = accfg_ctx_device_get_by_name(ctx, dev_name);
-
- if (!dev)
- return -ENOENT;
- group = accfg_device_group_get_by_id(dev, id);
+ group = accfg_device_group_get_by_id(parent, id);
if (!group)
return -ENOENT;
- dev = NULL;
- wq = NULL;
- engine = NULL;
}
+
+ return 0;
}
+ /* Skip if device configuration was skipped */
+ if (!parent)
+ return 0;
+
if (dev && dev_state != ACCFG_DEVICE_ENABLED) {
rc = device_json_set_val(dev, jobj, key);
if (rc < 0) {
--
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-3-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.