Page MenuHomeFreeBSD

D36669.diff
No OneTemporary

D36669.diff

diff --git a/sys/dev/cxgbe/adapter.h b/sys/dev/cxgbe/adapter.h
--- a/sys/dev/cxgbe/adapter.h
+++ b/sys/dev/cxgbe/adapter.h
@@ -41,6 +41,7 @@
#include <sys/lock.h>
#include <sys/malloc.h>
#include <sys/rwlock.h>
+#include <sys/seqc.h>
#include <sys/sx.h>
#include <sys/vmem.h>
#include <vm/uma.h>
@@ -871,7 +872,7 @@
uint64_t hw_prev;
sbintime_t sbt_cur;
sbintime_t sbt_prev;
- uint32_t gen;
+ seqc_t gen;
};
struct adapter {
diff --git a/sys/dev/cxgbe/t4_main.c b/sys/dev/cxgbe/t4_main.c
--- a/sys/dev/cxgbe/t4_main.c
+++ b/sys/dev/cxgbe/t4_main.c
@@ -1114,35 +1114,41 @@
{
struct adapter *sc;
struct clock_sync *cur, *nex;
+ uint64_t hw;
+ sbintime_t sbt;
int next_up;
sc = (struct adapter *)arg;
+ KASSERT((hw_off_limits(sc) == 0), ("hw_off_limits at t4_calibration"));
+ hw = t4_read_reg64(sc, A_SGE_TIMESTAMP_LO);
+ sbt = sbinuptime();
+
cur = &sc->cal_info[sc->cal_current];
next_up = (sc->cal_current + 1) % CNT_CAL_INFO;
nex = &sc->cal_info[next_up];
if (__predict_false(sc->cal_count == 0)) {
/* First time in, just get the values in */
- cur->hw_cur = t4_read_reg64(sc, A_SGE_TIMESTAMP_LO);
- cur->sbt_cur = sbinuptime();
+ cur->hw_cur = hw;
+ cur->sbt_cur = sbt;
sc->cal_count++;
goto done;
}
- nex->hw_prev = cur->hw_cur;
- nex->sbt_prev = cur->sbt_cur;
- KASSERT((hw_off_limits(sc) == 0), ("hw_off_limits at t4_calibration"));
- nex->hw_cur = t4_read_reg64(sc, A_SGE_TIMESTAMP_LO);
- nex->sbt_cur = sbinuptime();
- if ((nex->hw_cur - nex->hw_prev) == 0) {
+
+ if (cur->hw_cur == hw) {
/* The clock is not advancing? */
sc->cal_count = 0;
atomic_store_rel_int(&cur->gen, 0);
goto done;
}
- atomic_store_rel_int(&cur->gen, 0);
+
+ seqc_write_begin(&nex->gen);
+ nex->hw_prev = cur->hw_cur;
+ nex->sbt_prev = cur->sbt_cur;
+ nex->hw_cur = hw;
+ nex->sbt_cur = sbt;
+ seqc_write_end(&nex->gen);
sc->cal_current = next_up;
- sc->cal_gen++;
- atomic_store_rel_int(&nex->gen, sc->cal_gen);
done:
callout_reset_sbt_curcpu(&sc->cal_callout, SBT_1S, 0, t4_calibration,
sc, C_DIRECT_EXEC);
diff --git a/sys/dev/cxgbe/t4_sge.c b/sys/dev/cxgbe/t4_sge.c
--- a/sys/dev/cxgbe/t4_sge.c
+++ b/sys/dev/cxgbe/t4_sge.c
@@ -1530,16 +1530,17 @@
uint64_t hw_clk_div;
sbintime_t sbt_cur_to_prev, sbt;
uint64_t hw_tstmp = lf & 0xfffffffffffffffULL; /* 60b, not 64b. */
- uint32_t gen;
+ seqc_t gen;
- do {
+ for (;;) {
cur = &sc->cal_info[sc->cal_current];
- gen = atomic_load_acq_int(&cur->gen);
+ gen = seqc_read(&cur->gen);
if (gen == 0)
return (0);
dcur = *cur;
- atomic_thread_fence_acq();
- } while (gen != dcur.gen);
+ if (seqc_consistent(&cur->gen, gen))
+ break;
+ }
/*
* Our goal here is to have a result that is:

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 16, 4:17 PM (20 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
14661266
Default Alt Text
D36669.diff (2 KB)

Event Timeline