Skip to contentSkip to conversation

accel-config/test: Fix bug about finding a mismatched wq

PATCH Dave Jiang 2 participants 2 messages May 11, 2023 – May 12, 2023 2 messages not in the archive

lore
Share & tools
lore

Dave Jiang

author
#2 lore raw
In reply to a message not in the archive
Quoted 44 lines · Rex Zhang

When both DSA wq and IAA wq are enabled, the test code would find the first available wq for submitting descriptors. If the DSA wq is prior to IAA wq, the IAA test code would use DSA wq. It's incorrect. For fixing this bug, jump over the wq with mismatched device type.

---
  test/accel_test.c | 3 +++
  test/accel_test.h | 1 +
  test/dsa_test.c   | 1 +
  test/iaa_test.c   | 1 +
  4 files changed, 6 insertions(+)
test/accel_test.c +3 -0
index 7bbe780..d8fd70f 100644
@@ -125,6 +125,9 @@ static struct accfg_wq *acctest_get_wq(struct acctest_context *ctx,
  			enum accfg_wq_mode mode;
  			enum accfg_wq_type type;
 
+			if (strncmp(accfg_device_get_type_str(device), ctx->device_type, 3))
+				continue;
+
  			/* Get a workqueue that's enabled */
  			wstate = accfg_wq_get_state(wq);
  			if (wstate != ACCFG_WQ_ENABLED)
test/accel_test.h +1 -0
index 3b41a78..17d4097 100644
@@ -160,6 +160,7 @@ struct acctest_context {
  	unsigned int wq_max_batch_size;
  	unsigned long wq_max_xfer_size;
  	int ats_disable;
+	char device_type[3];
 
  	int is_batch;
  	int is_evl_test;
test/dsa_test.c +0 -0
index a4aad29..6eaf8cb 100644

test/dsa_test.c int main(int argc, char *argv[]) · line 900

Quoted 4 lines
test/dsa_test.c +1 -0
@@ -897,6 +897,7 @@ int main(int argc, char *argv[])
  	}
 
  	dsa = acctest_init(tflags);
+	strncpy(dsa->device_type, "dsa", 3);

It's probably cleaner to convert string to device type enum here and then compare it against accfg_device_get_type() later on.

Maybe libaccel-config can export a helper function to convert device string to device type?

accfg_str_to_device_type()?

Quoted 15 lines
test/dsa_test.c +0 -0
  	if (!dsa)
  		return -ENOMEM;
test/iaa_test.c +1 -0
index a1f529d..74a6027 100644
@@ -643,6 +643,7 @@ int main(int argc, char *argv[])
  	}
 
  	iaa = acctest_init(tflags);
+	strncpy(iaa->device_type, "iax", 3);
 
  	if (!iaa)
  		return -ENOMEM;
#3 lore raw

How about using device type enum directly?
Please help review my v3 patch.
Thanks.

----------------------------
Best wishes,
Rex Zhang
[email protected]

-----Original Message-----
From: Jiang, Dave <[email protected]>
Sent: Friday, May 12, 2023 12:49 AM
To: Zhang, Rex <[email protected]>; Yu, Fenghua <[email protected]>; Thomas, Ramesh <[email protected]>; Zhu, Tony <[email protected]>; [email protected]
Subject: Re: [PATCH v2 2/2] accel-config/test: Fix bug about finding a mismatched wq

Quoted 44 lines · Rex Zhang

When both DSA wq and IAA wq are enabled, the test code would find the first available wq for submitting descriptors. If the DSA wq is prior to IAA wq, the IAA test code would use DSA wq. It's incorrect. For fixing this bug, jump over the wq with mismatched device type.

---
  test/accel_test.c | 3 +++
  test/accel_test.h | 1 +
  test/dsa_test.c   | 1 +
  test/iaa_test.c   | 1 +
  4 files changed, 6 insertions(+)
test/accel_test.c index renamed from test/accel_test.c +0 -0

7bbe780..d8fd70f 100644

test/accel_test.c +3 -0
@@ -125,6 +125,9 @@ static struct accfg_wq *acctest_get_wq(struct acctest_context *ctx,
  			enum accfg_wq_mode mode;
  			enum accfg_wq_type type;
 
+			if (strncmp(accfg_device_get_type_str(device), ctx->device_type, 3))
+				continue;
+
  			/* Get a workqueue that's enabled */
  			wstate = accfg_wq_get_state(wq);
  			if (wstate != ACCFG_WQ_ENABLED)
test/accel_test.h index renamed from test/accel_test.h +0 -0

3b41a78..17d4097 100644

test/accel_test.h +1 -0
@@ -160,6 +160,7 @@ struct acctest_context {
  	unsigned int wq_max_batch_size;
  	unsigned long wq_max_xfer_size;
  	int ats_disable;
+	char device_type[3];
 
  	int is_batch;
  	int is_evl_test;
test/dsa_test.c index a4aad29..6eaf8cb renamed from test/dsa_test.c +0 -0

100644

test/dsa_test.c int main(int argc, char *argv[]) · line 900

Quoted 4 lines
test/dsa_test.c +1 -0
@@ -897,6 +897,7 @@ int main(int argc, char *argv[])
  	}
 
  	dsa = acctest_init(tflags);
+	strncpy(dsa->device_type, "dsa", 3);

It's probably cleaner to convert string to device type enum here and then compare it against accfg_device_get_type() later on.

Maybe libaccel-config can export a helper function to convert device string to device type?

accfg_str_to_device_type()?

Quoted 15 lines
test/dsa_test.c +0 -0
  	if (!dsa)
  		return -ENOMEM;
test/iaa_test.c index a1f529d..74a6027 renamed from test/iaa_test.c +0 -0

100644

test/iaa_test.c +1 -0
@@ -643,6 +643,7 @@ int main(int argc, char *argv[])
  	}
 
  	iaa = acctest_init(tflags);
+	strncpy(iaa->device_type, "iax", 3);
 
  	if (!iaa)
  		return -ENOMEM;