SShortSingh.
Back to feed

Linux DMA API: How Coherent and Streaming Mappings Work in Device Drivers

0
·1 views

The Linux DMA API bridges the gap between the addresses a CPU uses and those a device places on the bus, while also handling cache coherency on non-coherent platforms like ARM SoCs. Coherent mappings, allocated via dma_alloc_coherent(), provide memory accessible by both CPU and device without manual cache maintenance, suited for long-lived structures like descriptor rings. Streaming mappings, created with dma_map_single() or dma_map_sg(), are used for single transfers and rely on the kernel to perform cache clean or invalidate operations at map, sync, and unmap time. A critical rule is that only memory from the page allocator or kmalloc() is DMA-safe — using vmalloc(), stack, or module image addresses can cause data corruption that may not appear until the driver runs on a different board. Developers must also declare the correct DMA address mask via dma_set_mask_and_coherent() to avoid subtle bugs introduced by IOMMUs or bus offsets on different hardware platforms.

Read the full story at DEV Community

This is an AI-generated summary. ShortSingh links to the original source for the complete article.

Discussion (0)

Log in to join the discussion and vote.

Log in

Related stories

0
ProgrammingDEV Community ·

Benchmark: MariaDB 11.4 Is the Only Upgrade That Meaningfully Speeds Up WordPress

A developer benchmarked six MariaDB versions — 10.6 through 13.0 RC — against an identical WordPress and WooCommerce dataset to assess real-world query performance gains. The tests found that upgrading from 10.6 to 10.11 produces no perceptible improvement, with most query time differences falling within noise margins. The only notable jump comes at 11.4, where two optimizer changes — semi-join handling for UPDATE/DELETE and sargable date functions — cut certain query times by up to 98%. Versions 11.8, 12.3, and 13.0 RC showed no further meaningful gains over 11.4 in the tested workloads. While skipping straight to 11.4 or beyond is recommended for performance, upgrading from 10.6 is still advisable as that version reached end of life on July 6, 2026.

0
ProgrammingDEV Community ·

How Rate Limiting Shields APIs From Abuse, Overload, and Traffic Spikes

Rate limiting is a mechanism that controls how many requests a client can make to an API within a defined time window, typically returning an HTTP 429 error when the limit is exceeded. Without such controls, a sudden surge of requests — whether from a viral launch, a buggy client, or a deliberate attack — can overload servers, spike costs, and cause outages for legitimate users. Different endpoints can carry different limits, with security-sensitive routes like login or password reset set far stricter than general browsing endpoints. Several algorithms are commonly used to enforce these limits, including Fixed Window, Sliding Window, Token Bucket, and Leaky Bucket, each with its own trade-offs in complexity and accuracy. Rate limiting is also distinct from throttling, where the former restricts how much traffic is allowed while the latter controls the speed at which requests are processed.

0
ProgrammingDEV Community ·

PII-Shield sidecar strips sensitive data from Kubernetes logs before Fluentd reads them

A new approach to protecting personally identifiable information in Kubernetes logging pipelines uses a lightweight Go sidecar called PII-Shield, placed before Fluentd or Fluent Bit ever processes log data. Instead of relying on fragile regex filters embedded in Fluentd's record_transformer or Fluent Bit's Lua scripts, the sidecar intercepts raw application logs written to a shared ephemeral volume and scrubs sensitive fields using entropy-based detection. Masked values are replaced with traceable tokens like [HIDDEN:a1b2c3], preserving correlation across log lines without exposing actual secrets. The cleaned logs are then emitted to stdout, where the existing DaemonSet-based log collectors pick them up with no configuration changes needed. This design eliminates per-line interpreter overhead from Ruby or Lua processing and removes the risk of new secret formats silently bypassing unupdated regex patterns.

0
ProgrammingDEV Community ·

Schema Gate offers pay-per-use signed validation layer for AI-generated JSON payloads

A developer has launched Schema Gate, a deterministic validation service designed to sit between AI-generated JSON output and the downstream systems that consume it. The tool checks candidate JSON against a target schema and explicit acceptance criteria before issuing a cryptographically signed ACCEPT or REJECT receipt via ES256. The service uses the x402 v2 payment protocol on Solana mainnet, charging 0.010 USDC per completed evaluation, with no accounts or API keys required. Unlike local validation, the signed receipt can travel with the result across agent handoffs or automation boundaries and be verified by any system using a published public key. The creator is currently seeking early adopters building AI agent workflows to conduct funded production evaluations and provide integration feedback.