Skip to contentSkip to conversation

Fix eventobj_wait for EVOBJ_ALL

PATCH New Jan Kiszka 1 participant 4 messages Jan 31, 2020

lore
Share & tools
lore

Jan Kiszka

author
#0 lore raw

cover Fix eventobj_wait for EVOBJ_ALL

See patches for details.

Jan

Jan Kiszka (3):
lib/alchemy/testsuite: Add event test case for EV_ALL bug kernel/cobalt/posix: Fix cobalt_event_wait for COBALT_EVENT_ALL case lib/copperplate: Fix eventobj_wait for COBALT_EVENT_ALL case

 kernel/cobalt/posix/event.c     | 2 +-
 lib/alchemy/testsuite/event-1.c | 9 +++++++++
 lib/copperplate/eventobj.c      | 2 +-
 3 files changed, 11 insertions(+), 2 deletions(-)
Signature · 1 line
2.16.4
author
#1 lore raw

PATCH 1/3 lib/alchemy/testsuite: Add event test case for EV_ALL bug

From: Jan Kiszka <[email protected]>

This fails so far due to a bug in the event wait implementations, both with cobalt and mercury.

---
 lib/alchemy/testsuite/event-1.c | 9 +++++++++
 1 file changed, 9 insertions(+)
lib/alchemy/testsuite/event-1.c +9 -0
index fdf962736e..0893df36de 100644
@@ -63,6 +63,7 @@ static void foreground_task(void *arg)
 
 int main(int argc, char *const argv[])
 {
+	unsigned int flags;
 	int ret;
 
 	traceobj_init(&trobj, argv[0], 0);
@@ -70,6 +71,14 @@ int main(int argc, char *const argv[])
 	ret = rt_event_create(&event, "EVENT", 0, EV_FIFO);
 	traceobj_check(&trobj, ret, 0);
 
+	ret = rt_event_signal(&event, 0x3);
+	traceobj_check(&trobj, ret, 0);
+	ret = rt_event_wait(&event, 0x1, &flags, EV_ALL, TM_NONBLOCK);
+	traceobj_check(&trobj, ret, 0);
+	traceobj_assert(&trobj, flags == 0x1);
+	ret = rt_event_clear(&event, 0x3, NULL);
+	traceobj_check(&trobj, ret, 0);
+
 	ret = rt_task_create(&t_bgnd, "BGND", 0,  20, 0);
 	traceobj_check(&trobj, ret, 0);
 
Signature · 1 line
2.16.4
author
#2 lore raw

PATCH 2/3 kernel/cobalt/posix: Fix cobalt_event_wait for COBALT_EVENT_ALL case

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

When we wait for all passed event bits to be set, we need to test for those bits, not the ones that are currently pending. The current code fails to detect that the condition is met when both the desired as well as other events are already pending.

Reported by: Ronny Meeus <[email protected]>

---
 kernel/cobalt/posix/event.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
kernel/cobalt/posix/event.c +1 -1
index 407ef8d8e1..c566a09e36 100644
@@ -153,7 +153,7 @@ int __cobalt_event_wait(struct cobalt_event_shadow __user *u_event,
 
 	state->flags |= COBALT_EVENT_PENDED;
 	rbits = state->value & bits;
-	testval = mode & COBALT_EVENT_ANY ? rbits : state->value;
+	testval = mode & COBALT_EVENT_ANY ? rbits : bits;
 	if (rbits && rbits == testval)
 		goto done;
 
Signature · 1 line
2.16.4
author
#3 lore raw

PATCH 3/3 lib/copperplate: Fix eventobj_wait for COBALT_EVENT_ALL case

In reply to Jan Kiszka

From: Jan Kiszka <[email protected]>

When we wait for all passed event bits to be set, we need to test for those bits, not the ones that are currently pending. The current code fails to detect that the condition is met when both the desired as well as other events are already pending.

Reported by: Ronny Meeus <[email protected]>

---
 lib/copperplate/eventobj.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
lib/copperplate/eventobj.c +1 -1
index ff8c526282..dce5bd242f 100644
@@ -217,7 +217,7 @@ int eventobj_wait(struct eventobj *evobj,
 	}
 
 	waitval = evobj->core.value & bits;
-	testval = mode & EVOBJ_ANY ? waitval : evobj->core.value;
+	testval = mode & EVOBJ_ANY ? waitval : bits;
 
 	if (waitval && waitval == testval) {
 		*bits_r = waitval;
Signature · 1 line
2.16.4