mirror of
https://github.com/RhapsodiOS/RhapsodiOS.git
synced 2026-11-03 22:01:40 -07:00
[GH-ISSUE #28] drivers: clamp elapsed-time differences against backwards clock steps (disk/SCSI stats, DDM timing) #22
Labels
No labels
bug
documentation
enhancement
enhancement
good first issue
help wanted
help wanted
pull-request
question
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set
Reference
github-starred/RhapsodiOS#22
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @raynorpat on GitHub (Sep 25, 2026).
Original GitHub issue: https://github.com/RhapsodiOS/RhapsodiOS/issues/28
Follow-up to #26. The i386 kernel fix (
cd9fc5abd) stopsIOGetTimestamp()stepping back one tick, and NE2K, AMDPCNet32II, SerialPointingDevice and PS2Mouse are already guarded. A tick can still be lost if IRQ0 is serviced more than one PIT period late, which happens under heavy TCG load. That makes a backward step rare but still possible, so the remaining drivers that computenow - thenon the unsigned 64-bitns_time_tshould tolerate it.A backward step makes that difference wrap to about 1.8e19 ns. None of the sites below times out early. They record nonsense statistics or debug timing.
Transfer statistics (
totalTime/latentTimepassed to the disk stats)drivers-i386/ide/drvEIDE/.../IdeDiskInternal.m:772:delta = end_time - start_timedrivers-i386/ide/drvPCFloppy/.../FloppyDriveInt2.m:~507:endTime - startTimedrivers-i386/scsi/drvBusLogic/.../BusLogicThread.m:474drivers-i386/scsi/drvAdaptec1542B/.../AHAThread.m:473drivers-i386/scsi/drvAdaptec6X60/.../AIC6X60Thread.m:235drivers-i386/scsi/drvDPT2000/.../EATAControllerThread.m:168drivers-i386/scsi/drvAMDPCSCSIDriver/.../AMD_SCSI.m:998:latentTime += currentTime - disconnectTimeDebug-only timing (DDM builds)
AMD_SCSI.m:217: interrupt elapsed timeAMD_x86.m:701: IPL testusTime > 1000logs a false slow intervalChecked and safe (compare absolute deadlines, so a backward step only lengthens the wait)
BusLogic, Adaptec 1542B and AMD SCSI timeout scans (
now >= expire), DPT2000EATAController.m:373, Floppy motor timer (FloppyDriveInt2.m:617), AHCI deadline seconds,IOEthernet/IOTokenRing_absTimeout,IODelay(UsergeneralFuncs.m), EISA PnPDumpIOStubs.m, SYM53c8 (stores but never subtracts), andEventInputperiodic scheduling (already handles an apparent clock wrap).Suggested fix
Clamp each difference to 0 when
now < then(for exampledelta = (end > start) ? end - start : 0), matching the forward-gap-only guards in #26. Drivers with areconstruction/divergences.md(Floppy, and others if they are reconstructions) should record it there as a divergence.Still open from #26
The i386 kernel with the clock fix has been built but not yet boot-tested.