dw3000/mac: Accept t0 in the past
Instead of returning an error when CCC start delay is in the past,
schedule the start as soon as possible.
Bug: 285596493
Change-Id: I7838da8473adb26f2da9bfcf37f20c0a51fe2019
Signed-off-by: Mathieu Mandret <mathieu.mandret@qorvo.com>
diff --git a/kernel/drivers/net/ieee802154/dw3000_spi.c b/kernel/drivers/net/ieee802154/dw3000_spi.c
index 76f1f3f..cadc9b1 100644
--- a/kernel/drivers/net/ieee802154/dw3000_spi.c
+++ b/kernel/drivers/net/ieee802154/dw3000_spi.c
@@ -116,7 +116,7 @@
hrtimer_init(&dw->idle_timer, CLOCK_MONOTONIC, HRTIMER_MODE_REL);
dw->idle_timer.function = dw3000_idle_timeout;
- dev_info(dw->dev, "Loading driver...050423");
+ dev_info(dw->dev, "Loading driver...06202023");
dw3000_sysfs_init(dw);
/* Setup SPI parameters */
diff --git a/mac/nfcc_coex_region_call.c b/mac/nfcc_coex_region_call.c
index a7e63cd..bf8fb9b 100644
--- a/mac/nfcc_coex_region_call.c
+++ b/mac/nfcc_coex_region_call.c
@@ -64,7 +64,7 @@
struct nfcc_coex_session *session = &local->session;
struct nfcc_coex_session_params *p = &session->params;
/* Maximum dtu duration is INT32_MAX. */
- const u64 max_time0_ns =
+ const s64 max_time0_ns =
(S32_MAX * NS_PER_SECOND) / local->llhw->dtu_freq_hz;
int r;
@@ -98,7 +98,7 @@
local->llhw->dtu_freq_hz + now_ns;
}
- if (p->time0_ns - now_ns > max_time0_ns)
+ if ((s64)(p->time0_ns - now_ns) > max_time0_ns)
return -ERANGE;
return 0;
}
@@ -129,9 +129,13 @@
return r;
diff_ns = p->time0_ns - now_ns;
- diff_dtu = (diff_ns * local->llhw->dtu_freq_hz) / NS_PER_SECOND;
- if (diff_dtu < local->llhw->anticip_dtu)
- return -ETIMEDOUT;
+ diff_dtu = div64_s64(diff_ns * local->llhw->dtu_freq_hz, NS_PER_SECOND);
+ /* If the requested start date is in the past, start immediately */
+ if (diff_dtu < local->llhw->anticip_dtu) {
+ pr_warn("dw3000: Computed start date is in the past, scheduling"
+ " to anticip_dtu instead");
+ diff_dtu = local->llhw->anticip_dtu;
+ }
session->region_demand.timestamp_dtu = now_dtu + diff_dtu;
session->region_demand.max_duration_dtu = 0;