aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKevin O'Connor <kevin@koconnor.net>2018-02-11 18:49:27 -0500
committerKevin O'Connor <kevin@koconnor.net>2018-03-06 11:30:41 -0500
commit43ac56766e39d9a85372cdf7c1926ffa049f9342 (patch)
tree8f08858c1a0f6cb2d7967b9ed33fdd5630f3b715
parentafc9bcf27bedf0a4f16265ef3acd4990e8f642fe (diff)
downloadkutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.tar.gz
kutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.tar.xz
kutter-43ac56766e39d9a85372cdf7c1926ffa049f9342.zip
serialqueue: Support sending messages at a background priority
Support low-priority message transmits. This may be useful for bulk commands that should be delayed util the comms are otherwise idle. Signed-off-by: Kevin O'Connor <kevin@koconnor.net>
-rw-r--r--klippy/serialqueue.c13
-rw-r--r--klippy/serialqueue.h3
2 files changed, 12 insertions, 4 deletions
diff --git a/klippy/serialqueue.c b/klippy/serialqueue.c
index 7f7d7fd9..2f7c25a5 100644
--- a/klippy/serialqueue.c
+++ b/klippy/serialqueue.c
@@ -389,6 +389,7 @@ struct serialqueue {
#define MIN_RTO 0.025
#define MAX_RTO 5.000
#define MIN_REQTIME_DELTA 0.250
+#define MIN_BACKGROUND_DELTA 0.005
#define IDLE_QUERY_TIME 1.0
#define DEBUG_QUEUE_SENT 100
@@ -722,8 +723,13 @@ check_send_command(struct serialqueue *sq, double eventtime)
if (!list_empty(&cq->ready_queue)) {
struct queue_message *qm = list_first_entry(
&cq->ready_queue, struct queue_message, node);
- if (qm->req_clock < min_ready_clock)
- min_ready_clock = qm->req_clock;
+ uint64_t req_clock = qm->req_clock;
+ if (req_clock == BACKGROUND_PRIORITY_CLOCK)
+ req_clock = (uint64_t)(
+ (sq->idle_time - sq->last_clock_time + MIN_BACKGROUND_DELTA)
+ * sq->est_freq) + sq->last_clock;
+ if (req_clock < min_ready_clock)
+ min_ready_clock = req_clock;
}
}
@@ -907,7 +913,8 @@ serialqueue_send_batch(struct serialqueue *sq, struct command_queue *cq
int len = 0;
struct queue_message *qm;
list_for_each_entry(qm, msgs, node) {
- if (qm->min_clock + (1LL<<31) < qm->req_clock)
+ if (qm->min_clock + (1LL<<31) < qm->req_clock
+ && qm->req_clock != BACKGROUND_PRIORITY_CLOCK)
qm->min_clock = qm->req_clock - (1LL<<31);
len += qm->len;
}
diff --git a/klippy/serialqueue.h b/klippy/serialqueue.h
index 678885ad..80ab686e 100644
--- a/klippy/serialqueue.h
+++ b/klippy/serialqueue.h
@@ -3,7 +3,8 @@
#include "list.h" // struct list_head
-#define MAX_CLOCK 0x7fffffffffffffff
+#define MAX_CLOCK 0x7fffffffffffffffLL
+#define BACKGROUND_PRIORITY_CLOCK 0x7fffffff00000000LL
#define MESSAGE_MIN 5
#define MESSAGE_MAX 64