Skip to content

feat(diagnostics): expose sanitized driver health and USB counters - #3

Open
pvurda wants to merge 1 commit into
refactor/device-usb-topologyfrom
feat/driver-diagnostics
Open

feat(diagnostics): expose sanitized driver health and USB counters#3
pvurda wants to merge 1 commit into
refactor/device-usb-topologyfrom
feat/driver-diagnostics

Conversation

@pvurda

@pvurda pvurda commented Aug 26, 2026

Copy link
Copy Markdown
Owner

Summary

  • add per-device atomic health counters and lifecycle/failure state
  • expose resolved USB topology and sanitized runtime status at /proc/asound/cardN/ozzy_status
  • retain exact URB completion and resubmit failures in rate-limited logs without packet payloads
  • identify the precise failed Ploytec handshake stage
  • add a fixture-tested tools/ozzy-report.sh collector that never opens PCM or rawmidi devices
  • extend CI with shellcheck and report fixture tests

Diagnostics contract

The proc entry contains no USB serial number, PCM samples, MIDI payloads, memory addresses, or hex dumps. Counters are connection-scoped and read-only. Missing ALSA proc support does not prevent the module from loading.

ozzy-report.sh --card N --output FILE writes mode 0600, reports unavailable sources explicitly, and sanitizes serials, usernames, home paths, memory addresses, and unrelated kernel logs.

Validation

  • make -C linux ci KERNELDIR=/lib/modules/6.14.0-37-generic/build
  • make -C linux ci KERNELDIR=/lib/modules/6.8.0-100-generic/build
  • make -C tests/ploytec test
  • make -C tests/ploytec sanitize
  • shellcheck tools/ozzy-report.sh tests/report/test-report.sh
  • tests/report/test-report.sh
  • Linux v6.14 checkpatch.pl: no errors or warnings
  • static scan confirms five Ploytec IDs and no 22f0:000f, %p, buffer dumps, or per-successful-URB logging

Local Clang was unavailable; the existing Ubuntu 24.04 GCC/Clang CI matrix remains the authoritative Clang gate.

Scope

No codec, audio format, packet geometry, USB ID, or Xone:43C runtime support changes.

Stacked on #2.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 6141d5579d

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread linux/ozzy_pcm.c
usb_urb->status == -ECONNRESET ||
usb_urb->status == -ESHUTDOWN))
goto in_fail;
if (unlikely(usb_urb->status != 0)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Keep recoverable URB errors from permanently panicking PCM

When a PCM completion reports a recoverable transport error such as -EPROTO or -EILSEQ, this broadened predicate now enters the panic path instead of resubmitting the URB. Because rt->panic then makes every remaining input and output callback return without resubmission, a single transient USB error permanently stops all audio until a device reset or replug; checked both PCM completion handlers, which should distinguish teardown/fatal statuses from errors that can be recorded and retried.

Useful? React with 👍 / 👎.

Comment thread linux/ozzy_diag.c
Comment on lines +70 to +71
snd_iprintf(buffer, "packet_bytes=%u:%u\n", chip->info->out_packet_size,
chip->info->in_packet_size);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Report the resolved playback packet size

On a Ploytec device whose playback endpoint resolves to interrupt transport, this reports the static bulk default of 4096 bytes even though ploytec_get_out_packet_size() allocates 3856-byte output URBs. Consequently packet_bytes is deterministically wrong for that supported topology and can mislead comparisons with the new completion logs; derive the value through the device callback or the initialized URB instead.

Useful? React with 👍 / 👎.

Comment thread linux/ozzy_diag.c
Comment on lines +134 to +136
atomic_set(&chip->diag.last_stage, stage);
atomic_set(&chip->diag.last_usb_status, usb_status);
atomic_set(&chip->diag.last_errno, error);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Publish the last-failure fields as one snapshot

When input, output, or MIDI URBs fail concurrently, these three independent stores can interleave with another ozzy_diag_failure() call, while the proc reader also reads them independently. The resulting last_failure may combine one event's stage with another event's USB status or errno, defeating the intended exact failure diagnostic; serialize the tuple or protect it with a sequence counter so readers obtain one coherent event.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant