Re: [PATCH RFC v4] ALSA: pci: add analog support for ESI MAYA44e

From: Takashi Iwai

Date: Mon Nov 16 2026 - 10:39:51 EST


On Mon, 16 Nov 2026 05:11:02 +0100,
Nordschamane via B4 Relay wrote:
>
> From: Nordschamane <nordschamane1@xxxxxxxxx>
>
> Add four-channel analog playback and capture for the ESI MAYA44e PCIe
> card (19fe:7000, subsystem 0e51:0001). Playback and capture share the
> sample clock and can use independent period sizes. Expose analog source,
> gain, direct monitoring, DAC and crossmix controls.
>
> The playback DMA rings and ALSA staging buffer are cleared during the
> reset that completes prepare. This keeps clearing and pointer rebasing
> under the same PCM stream lock, including for linked streams.
> Both streams use the locked reset path. A linked PREPARE holds the
> peer's buffer mutex but does not block its ALSA read or write copies.
> Take a driver buffer-access gate before touching either stream's
> buffers, and keep it until the reset callback. The stream lock then
> covers the remaining pointer rebase. Return -EBUSY if a copy is active.
> Explicit RESET takes its own gate when no prepare is in progress.
>
> Treat unavailable MMIO as an error during DMA setup, start and
> position tracking. A failed read must not be interpreted as a running
> engine or a completed capture period. After confirmed loss of access,
> skip BAR operations and use PCI configuration space for best-effort
> shutdown.
>
> Publish capture samples and the copied position under the same lock.
> Use the DMA position and elapsed time to detect missed capture periods.
> Skip early or repeated interrupts and report a capture XRUN when the
> ring may have wrapped without the driver copying the preceding half.
>
> The ES7010L register sequence comes from observed PCI transactions and
> analysis of the ESI Windows driver. The existing ALSA PCI MAYA44 driver
> was a reference for the WM8776 command format.
>
> OpenAI Codex assisted with PCI trace analysis, driver implementation,
> test tooling and the changelog. The requests covered analog playback,
> capture, mixer controls and suspend/resume.
>
> Signed-off-by: Nordschamane <nordschamane1@xxxxxxxxx>

Thanks for the patch.

First, off, as Signed-off-by is a legal requirement, could you try to
fill a real name here? At best align the From address together, too.

About the code changes: it looks well readable in general, and the
code is rather straightforward. Yet a few things:

- Try to use guard() & co instead of the open mutex or spin lock
calls. This will avoid the lock unbalance drastically.

- The handling of the work, at least, for finishing the work doesn't
look good. In general, at PCM close callback, all streams have been
already stopped and finished, hence there shouldn't be much work
there at all. If something race is still found there, it's already
wrong. Most of such stop synchronization should have been done in
sync_stop callback, instead.

- The sample packing in the loop in ack doesn't look good, either.
Do we really need a manual expansion and the format conversion in a
loop there at all? The driver should avoid such a loop but just
copy the data as-is, as much as possible.


thanks,

Takashi