-
Notifications
You must be signed in to change notification settings - Fork 7.3k
rtio: Introduce OP_DELAY as a valid SQE operation #88808
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
/* | ||
* Copyright (c) 2025 Croxel Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
#include <zephyr/rtio/rtio.h> | ||
|
||
/** Required to access Timeout Queue APIs, which are used instead of the | ||
* Timer APIs because of concerns on size on rtio_sqe (k_timer is more | ||
* than double the size of _timeout). Users will have to instantiate a | ||
* pool of SQE objects, thus its size directly impacts memory footprint | ||
* of RTIO applications. | ||
*/ | ||
#include <../kernel/include/timeout_q.h> | ||
|
||
#include "rtio_sched.h" | ||
|
||
static void rtio_sched_alarm_expired(struct _timeout *t) | ||
{ | ||
struct rtio_sqe *sqe = CONTAINER_OF(t, struct rtio_sqe, delay.to); | ||
struct rtio_iodev_sqe *iodev_sqe = CONTAINER_OF(sqe, struct rtio_iodev_sqe, sqe); | ||
|
||
rtio_iodev_sqe_ok(iodev_sqe, 0); | ||
} | ||
|
||
void rtio_sched_alarm(struct rtio_iodev_sqe *iodev_sqe, k_timeout_t timeout) | ||
{ | ||
struct rtio_sqe *sqe = &iodev_sqe->sqe; | ||
|
||
z_init_timeout(&sqe->delay.to); | ||
z_add_timeout(&sqe->delay.to, rtio_sched_alarm_expired, timeout); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. removing the timeout if SQE is cancelled should be added somewhere :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I looked into this, it seems we don't need special handling for canceled OP_DELAY SQEs:
I had added an additional test-case but it already passes with no code changes added: ZTEST(rtio_api, test_rtio_delay_canceled)
{
int res;
struct rtio *r = &r_delay;
struct rtio_sqe *sqe;
struct rtio_cqe *cqe;
sqe = rtio_sqe_acquire(r);
zassert_not_null(sqe, "Expected a valid sqe");
rtio_sqe_prep_delay(sqe, K_SECONDS(10), NULL);
res = rtio_submit(r, 0);
zassert_ok(res, "Should return ok from rtio_execute");
rtio_sqe_cancel(sqe);
k_sleep(K_SECONDS(10));
cqe = rtio_cqe_consume(r);
zassert_null(cqe, "Canceled SQEs should not generate a CQE");
rtio_cqe_release(r, cqe);
} |
||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
/* | ||
* Copyright (c) 2025 Croxel Inc. | ||
* | ||
* SPDX-License-Identifier: Apache-2.0 | ||
*/ | ||
|
||
#include <zephyr/kernel.h> | ||
|
||
#ifndef ZEPHYR_SUBSYS_RTIO_SCHED_H_ | ||
#define ZEPHYR_SUBSYS_RTIO_SCHED_H_ | ||
|
||
void rtio_sched_alarm(struct rtio_iodev_sqe *iodev_sqe, k_timeout_t timeout); | ||
|
||
#endif /* ZEPHYR_SUBSYS_RTIO_SCHED_H_ */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need to pass the timeout as a param, just read the data directly