Skip to content

nfc: order NCI UART and firmware teardown

Shubham Antil netdev oe-linux-nfc stable 3 versions – New

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v8 Latest4 patches 0 repliesNew
  2. v73 patches 0 repliesSuperseded
  3. v66 patches 2 repliesSuperseded

Changes in v8 from the cover letter

- keep asynchronous core completion lockless to avoid an inverse lock

Patches in v8 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/4nfc: nci: uart: serialize driver selectioninclude/net/nfc/nci_core.h net/nfc/nci/uart.c+100 -430 replies
2/4nfc: reject overlapping firmware downloadsdrivers/nfc/nfcmrvl/main.c drivers/nfc/nfcmrvl/uart.c net/nfc/core.c+12 -70 replies
3/4nfc: nci: uart: quiesce callbacks during teardowndrivers/nfc/nfcmrvl/main.c drivers/nfc/nfcmrvl/nfcmrvl.h drivers/nfc/nfcmrvl/uart.c +5 more+496 -580 replies
4/4nfc: nfcmrvl: stop firmware work before unregisteringdrivers/nfc/nfcmrvl/fw_dnld.c drivers/nfc/nfcmrvl/fw_dnld.h drivers/nfc/nfcmrvl/main.c +2 more+223 -820 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v8 yet.

Read the v8 thread

Cover letter [PATCH net v8 0/4] nfc: order NCI UART and firmware teardown

Make NCI UART driver selection, callback shutdown, close-time command handling, and Marvell firmware completion explicit and ordered.

Patch 1 serializes NCIUARTSETDRIVER and protects the driver registry while a transport takes its module reference. Patch 2 rejects a second firmware request without disturbing the active core state. Patch 3 orders UART publication and shutdown, preserves close-time reset and driver commands, and bounds transport draining. Patch 4 stops firmware timer, receive, and command producers before their queues and private state are released.

Source auditing, patch development, review triage, and test planning were assisted by OpenAI Codex, gpt-5.6-sol. I reviewed and tested the resulting changes and take responsibility for them under my Signed-off-by.

The final v8 code was tested with:

- strict checkpatch and git diff checks for every patch;
- targeted W=1 builds and current sparse checks;
- full x86_64 bzImage and module builds with KASAN, UBSAN, lockdep, and

    DEBUG_LIST, and separately with strict-mode KCSAN;

- 20 concurrent driver-selection cycles under each configuration;
- 5 registration/publication and 5 reset-preserving lifecycle cycles under each configuration; and
- 100 firmware teardown cycles and five timer-boundary modes under each configuration.

All test assertions completed with zero failures. Neither sanitizer run reported a memory, concurrency, locking, or undefined-behavior diagnostic. Current sparse reported only two pre-existing warnings outside the changed logic. The st-nci close path was also built and checked separately because it sends a final proprietary command from its close callback.

No in-tree selftest covers these NCI UART and nfcmrvl firmware paths. No physical Marvell controller was available for testing.

Changes since v7:

- keep asynchronous core completion lockless to avoid an inverse lock

    order with driver-private locks;
  - serialize transmit wakeups and retain partial frames across worker
    restarts;
  - publish Marvell transport state before NCI registration while keeping
    receive admission closed until core queues are ready;
  - close command admission and drain response work before cancellation;
  - preserve the close-time reset and a driver's final close command, then
    cancel any command left by an interrupted synchronous request;
  - actively retry partial UART writes during the bounded close flush and
    poison a line-discipline instance whose framing cannot be preserved;

- stop firmware receive, timeout, and command dependencies before core workqueue teardown; and
- document lifecycle sleep, locking, lifetime, and queue-ownership contracts and refresh validation on the final tree.

v7: https://lore.kernel.org/netdev/[email protected]/

Shubham Antil (4):
nfc: nci: uart: serialize driver selection
nfc: reject overlapping firmware downloads
nfc: nci: uart: quiesce callbacks during teardown
nfc: nfcmrvl: stop firmware work before unregistering

 drivers/nfc/nfcmrvl/fw_dnld.c | 237 ++++++++++++-----
 drivers/nfc/nfcmrvl/fw_dnld.h |  11 +
 drivers/nfc/nfcmrvl/main.c    |  52 +++-
 drivers/nfc/nfcmrvl/nfcmrvl.h |   4 +
 drivers/nfc/nfcmrvl/uart.c    |  64 ++++-
 include/net/nfc/nci_core.h    |  29 +++
 net/nfc/core.c                |  20 +-
 net/nfc/nci/core.c            |  82 ++++--
 net/nfc/nci/rsp.c             |   3 +
 net/nfc/nci/uart.c            | 467 +++++++++++++++++++++++++++++-----
 10 files changed, 805 insertions(+), 164 deletions(-)

base-commit: 30c71476d842b094651bd7712f6c8ee8716147d0

Signature · 1 line
2.54.0