git: 9front

Download patch

ref: 9269c36959eeadb1c60152085d30ec3500b2c964
parent: cc91d6df568db5f900bcab50dfabdb07d35a713f
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Jul 21 13:35:18 EDT 2024

etherimx: fix missing barrier for doorbell (thanks sigrid)

the symptom is that ping is apparently skipping
transmits which recover with the next send,
resulting in exactly send-period spikes in
the ping rtt.

It appears that the core seems to reorder writes
to uncached memory, which can result in the doorbell
being written before the descriptor status bits
are written.

put a coherence() barrier before writing doorbell
fixes it.

thanks sigrid for reporting the issue!

--- a/sys/src/9/imx8/etherimx.c
+++ b/sys/src/9/imx8/etherimx.c
@@ -362,6 +362,7 @@
 			d->status = BLEN(b) | TD_OWN | TD_R | TD_L | TD_TC;
 			i++;
 		}
+		coherence();
 		wr(ctlr, ENET_TDAR, TDAR_ACTIVE);
 	}
 }
@@ -453,6 +454,7 @@
 			d->status = RD_E;
 			i++;
 		}
+		coherence();
 		wr(ctlr, ENET_RDAR, RDAR_ACTIVE);
 	}
 }
--