Skip to content

F0018 dma-4

Rule: Every DMA ring consumer counts its overruns.

Code F0018 (stable, never reused)
Id dma-4
Category dma
Source spirit_level
Fix by hand

Level per tier

Tier Level Reason
small off
small-workspace off
medium off
big off
ai off
embedded warn bedrock warning: DMA ring overrun not counted: every ring consumer counts overruns with cnt!
ui off
egui off
units-strict off
units-paranoid off

Why

A DMA ring-buffer consumer (UART RX ring, a sample ring) with no cnt! counter incremented on the overrun path — the case where the producer wraps past data the consumer hasn't read yet.

An overrun silently drops data; without a counter there is nothing in the build-info counters block to show it ever happened, so the first sign of trouble is a user noticing missing data days later with no way to tell how often it occurs.

Example

Typec_dongle FW-26 added pd_rx_overrun after the fact, once the missing-data reports made clear the ring had been overrunning unnoticed.

How to fix

Add a cnt! counter on the overrun branch of every ring consumer, named for what it's counting (see cnt-1 for the same rule generalised to every error branch).

How it is checked

src mid: from the firmware model, every DMA ring consumer's overrun branch (the wrap-detected path) must reach a cnt! call.

Source

Ported from embedded_bedrock's firmware check catalogue, DMA-4 (book/checks.md, detail in book/checks/dma.md). Found on: typec_dongle FW-26.

Configure

[lints.dma-4]
level = "deny"
reason = "why this project wants it at this level"

Allow one finding in the code with // spirit-level: allow(dma-4) <reason> (waivers); the code works there too, as in [lints.F0018].