Skip to contentSkip to conversation

accel-config: Do not fail shared wq tests if platform does not support shared wqs

PATCH In review ramesh.thomas at intel.com 2 participants 6 messages Aug 11, 2021

lore
Share & tools
lore

ramesh.thomas at intel.com

#0 lore raw

PATCH 1/1 accel-config: Do not fail shared wq tests if platform does not support shared wqs

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

If shared wq is not supported by platform use dedicated mode to avoid failing batch configuration tests

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
---
 test/libaccfg.c | 17 ++++++++++++++---
 1 file changed, 14 insertions(+), 3 deletions(-)
test/libaccfg.c +14 -3
index 516adbc..a982344 100644
@@ -244,7 +244,13 @@ static int config_wq(struct accfg_ctx *ctx, struct accfg_device *device,
 {
 	int rc = 0;
 
-	SET_ERR(rc, accfg_wq_set_str_mode(wq, wq_param->mode));
+	rc = accfg_wq_set_str_mode(wq, wq_param->mode);
+	if (rc == -EINVAL) {
+		fprintf(stderr, "%s shared wq not supported, configuring as dedicated\n",
+				__func__);
+		rc = accfg_wq_set_str_mode(wq, "dedicated");
+	}
+
 	SET_ERR(rc, accfg_wq_set_str_type(wq, wq_param->type));
 	SET_ERR(rc, accfg_wq_set_str_name(wq, wq_param->name));
 	SET_ERR(rc, accfg_wq_set_size(wq, wq_param->wq_size));
@@ -254,7 +260,7 @@ static int config_wq(struct accfg_ctx *ctx, struct accfg_device *device,
 	SET_ERR(rc, accfg_wq_set_max_batch_size(wq, wq_param->max_batch_size));
 	SET_ERR(rc, accfg_wq_set_max_transfer_size(wq,
 				wq_param->max_transfer_size));
-	if (wq_param->threshold)
+	if (wq_param->threshold && accfg_wq_get_mode(wq) == ACCFG_WQ_SHARED)
 		SET_ERR(rc, accfg_wq_set_threshold(wq, wq_param->threshold));
 
 	SET_ERR(rc, accfg_wq_set_ats_disable(wq, wq_param->ats_disable));
@@ -288,7 +294,7 @@ static int check_wq(struct accfg_ctx *ctx, struct accfg_device *device,
 		fprintf(stderr, "%s failed on block_on_fault\n", __func__);
 		return -EINVAL;
 	}
-	if (wq_param->threshold !=
+	if (accfg_wq_get_mode(wq) == ACCFG_WQ_SHARED && wq_param->threshold !=
 			(unsigned int)accfg_wq_get_threshold(wq)) {
 		fprintf(stderr, "%s failed on threshold\n", __func__);
 		return -EINVAL;
@@ -815,6 +821,11 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
 	if (rc)
 		return rc;
 
+	if (accfg_wq_get_mode(test_ctx.wq[2]) != ACCFG_WQ_SHARED) {
+		fprintf(stderr, "%s shared wq not supported\n", __func__);
+		return -EOPNOTSUPP;
+	}
+
 	rc = set_mdev_type(ctx, test_ctx.wq[2], test_ctx.wq_param[2]);
 	if (rc)
 		return rc;
Signature · 1 line
2.26.3
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · ramesh.thomas(a)intel.com

From: Ramesh Thomas <ramesh.thomas(a)intel.com>

If shared wq is not supported by platform use dedicated mode to avoid failing batch configuration tests

Signed-off-by Ramesh Thomas <ramesh.thomas(a)intel.com>
Reviewed-by Dave Jiang <dave.jiang(a)intel.com>
Quoted 53 lines
---
  test/libaccfg.c | 17 ++++++++++++++---
  1 file changed, 14 insertions(+), 3 deletions(-)
test/libaccfg.c +14 -3
index 516adbc..a982344 100644
@@ -244,7 +244,13 @@ static int config_wq(struct accfg_ctx *ctx, struct accfg_device *device,
  {
  	int rc = 0;
 
-	SET_ERR(rc, accfg_wq_set_str_mode(wq, wq_param->mode));
+	rc = accfg_wq_set_str_mode(wq, wq_param->mode);
+	if (rc == -EINVAL) {
+		fprintf(stderr, "%s shared wq not supported, configuring as dedicated\n",
+				__func__);
+		rc = accfg_wq_set_str_mode(wq, "dedicated");
+	}
+
  	SET_ERR(rc, accfg_wq_set_str_type(wq, wq_param->type));
  	SET_ERR(rc, accfg_wq_set_str_name(wq, wq_param->name));
  	SET_ERR(rc, accfg_wq_set_size(wq, wq_param->wq_size));
@@ -254,7 +260,7 @@ static int config_wq(struct accfg_ctx *ctx, struct accfg_device *device,
  	SET_ERR(rc, accfg_wq_set_max_batch_size(wq, wq_param->max_batch_size));
  	SET_ERR(rc, accfg_wq_set_max_transfer_size(wq,
  				wq_param->max_transfer_size));
-	if (wq_param->threshold)
+	if (wq_param->threshold && accfg_wq_get_mode(wq) == ACCFG_WQ_SHARED)
  		SET_ERR(rc, accfg_wq_set_threshold(wq, wq_param->threshold));
 
  	SET_ERR(rc, accfg_wq_set_ats_disable(wq, wq_param->ats_disable));
@@ -288,7 +294,7 @@ static int check_wq(struct accfg_ctx *ctx, struct accfg_device *device,
  		fprintf(stderr, "%s failed on block_on_fault\n", __func__);
  		return -EINVAL;
  	}
-	if (wq_param->threshold !=
+	if (accfg_wq_get_mode(wq) == ACCFG_WQ_SHARED && wq_param->threshold !=
  			(unsigned int)accfg_wq_get_threshold(wq)) {
  		fprintf(stderr, "%s failed on threshold\n", __func__);
  		return -EINVAL;
@@ -815,6 +821,11 @@ static int test_mdev_1swq(struct accfg_ctx *ctx)
  	if (rc)
  		return rc;
 
+	if (accfg_wq_get_mode(test_ctx.wq[2]) != ACCFG_WQ_SHARED) {
+		fprintf(stderr, "%s shared wq not supported\n", __func__);
+		return -EOPNOTSUPP;
+	}
+
  	rc = set_mdev_type(ctx, test_ctx.wq[2], test_ctx.wq_param[2]);
  	if (rc)
  		return rc;
#2 lore raw
Quoted 2 lines

If shared wq is not supported by platform use dedicated mode to avoid failing batch configuration tests

Seems weird to change type of WQ. If the caller asked for a shared WQ, they are expecting to send work to it using ENQCMD or ENQCMDS. Switching to dedicated would make the requester still fail ... unless they subsequently check to see that this type switch happened.

-Tony

#3 lore raw
Quoted 7 lines · Tony Luck
Quoted 2 lines

If shared wq is not supported by platform use dedicated mode to avoid failing batch configuration tests

Seems weird to change type of WQ. If the caller asked for a shared WQ, they are expecting to send work to it using ENQCMD or ENQCMDS. Switching to dedicated would make the requester still fail ... unless they subsequently check to see that this type switch happened.

This is the unit test that only tests the configuration. It configures a few wqs as shared and dedicated. The option is to skip the wqs set to be tested as shared wqs or configure all wqs as dedicated. There is no change to the config-wq command. I can add "test" to the tag to avoid confusion.

Quoted 2 lines

-Tony

#4 lore raw
Quoted 5 lines

This is the unit test that only tests the configuration. It configures a few wqs as shared and dedicated. The option is to skip the wqs set to be tested as shared wqs or configure all wqs as dedicated. There is no change to the config-wq command. I can add "test" to the tag to avoid confusion.

Sounds like the confusion begins with the specification for the test.

Perhaps divide into two parts:
1) Creation of dedicated WQs
Possible results are PASS or FAIL
2) Creation of shared WQs
Possible results are PASS, FAIL or SKIP

-Tony

#5 lore raw
Quoted 6 lines · Tony Luck
Quoted 5 lines

This is the unit test that only tests the configuration. It configures a few wqs as shared and dedicated. The option is to skip the wqs set to be tested as shared wqs or configure all wqs as dedicated. There is no change to the config-wq command. I can add "test" to the tag to avoid confusion.

Quoted 7 lines

Sounds like the confusion begins with the specification for the test.

Perhaps divide into two parts:
1) Creation of dedicated WQs Possible results are PASS or FAIL
2) Creation of shared WQs Possible results are PASS, FAIL or SKIP

That's a good idea. I can split it into 2 tests for shared and dedicated.

Quoted 2 lines

-Tony