bus: mhi: Add loopback driver
Status from this message: Applied, thanks!
Get series with b4
b4 am [email protected] change-id 20250903-loopback_mhi-dee55ff0d462Versions newest first
- v7 Latest3 patches 1 replyApplied
- v63 patches 5 repliesSuperseded inferred link
- v53 patches 6 repliesSuperseded
Earlier versions · 4
| Version | Posted | Patches | Replies | Status |
|---|---|---|---|---|
| v4 | 3 patches | 6 replies | Superseded | |
| v3 | 3 patches | 0 replies | Superseded | |
| v2 | 3 patches | 7 replies | Superseded | |
| v1 | 2 patches | 1 reply | Superseded |
Changes in v7 from the cover letter
- Fix the tre_pending comment: it only tracks DL completions, not DL+UL completions (Mani)
- Add a new 'max_num_tre' RO sysfs attribute reporting the live channel ring capacity, and reword the num_tre ABI description to reference it, so callers don't have to guess a value and parse dmesg on failure
- Reset the channel on every early-failure path in start_store(), not just the timeout path, so TREs already queued to the device can't outlive the buffers they point to once freed (Mani)
- Replace sysfs_create_group()/sysfs_remove_group() with driver.dev_groups so the driver core manages the sysfs group across probe()/remove() (Mani)
- ep: restore the blank line after mhi_ep_buf_completion() (Mani)
- Link to v6: https://lore.kernel.org/r/[email protected]
Patches in v7 Applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/3 | bus: mhi: host: clients: Add loopback driver with sysfs interfaceDocumentation/ MAINTAINERS drivers/ +4 more | +383 | 0 replies | |
| 2/3 | bus: mhi: ep: Add mhi_ep_queue_buf() API for raw buffer queuingdrivers/ include/ | +36 | 0 replies | |
| 3/3 | bus: mhi: ep: clients: Add loopback driver for data path testingdrivers/ drivers/ drivers/ +2 more | +150 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v7 yet.
Cover letter [PATCH v7 0/3] bus: mhi: Add loopback driver
The MHI specification defines a LOOPBACK channel that is already implemented by MHI-based devices (modems, WLAN) deployed in the field. The endpoint firmware echoes back whatever the host sends on this channel. Without a host-side driver, there is no way to exercise this channel to validate MHI data path integrity between host and endpoint.
This series adds drivers to exercise the LOOPBACK channel from both the host and endpoint sides. The host driver (patch 1) binds to the LOOPBACK channel and provides a sysfs interface for configuring transfer parameters, triggering a test, and reading the result. The sysfs interface is stable ABI because the wire protocol is fixed by the endpoint firmware already deployed in the field and cannot be changed.
The endpoint driver (patch 3) echoes received data back to the host using a workqueue for asynchronous processing. Patch 2 introduces the mhi_ep_queue_buf() API needed by the endpoint driver for raw buffer queuing without an skb dependency.
---
Changes in v7:
- Fix the tre_pending comment: it only tracks DL completions, not DL+UL completions (Mani)
- Add a new 'max_num_tre' RO sysfs attribute reporting the live channel ring capacity, and reword the num_tre ABI description to reference it, so callers don't have to guess a value and parse dmesg on failure
- Reset the channel on every early-failure path in start_store(), not just the timeout path, so TREs already queued to the device can't outlive the buffers they point to once freed (Mani)
- Replace sysfs_create_group()/sysfs_remove_group() with driver.dev_groups so the driver core manages the sysfs group across probe()/remove() (Mani)
- ep: restore the blank line after mhi_ep_buf_completion() (Mani)
- Link to v6: https://lore.kernel.org/r/[email protected]
Changes in v6:
- Add comment explaining the purpose of atomic_t tre_pending (Jeff)
- Drop <linux/mod_devicetable.h>; already covered by <linux/mhi.h> after
recent tree cleanups (Jeff, Uwe)
- Drop the trailing comma after the NULL sentinel in
mhi_loopback_attrs[] (Uwe)
- Use dev_err_probe() in the probe() error path (Uwe)
- Fix spacing in the mhi_device_id table entries (Uwe)
- Reword Kconfig help text so modems/WLAN read as examples of LOOPBACK
channel implementers, not an exhaustive list (Jeff)
- Spell out Transfer Ring Element (TRE) in the max_tre_size ABI
description, matching the neighbouring entries (Jeff)
- Clarify in the commit message that the new ABI is added under Documentation/ABI/testing/, not stable/, and is unrelated to the
existing stable MHI ABI entry sharing the same MAINTAINERS line (Jeff)
- Bump KernelVersion from 7.2 to 7.4 in the ABI documentation, since
this series missed both 7.2 and 7.3 (Jeff)
- Link to v5: https://lore.kernel.org/all/[email protected]/
Changes in v5:
- Rebase onto mhi-next to pick up the EP flush_async() support, which
disables the channels and flushes the in-flight transfers before calling
the client driver's remove()
- Drop the file header comment block duplicating the Kconfig help text (Mani)
- Rename tres_pending to tre_pending (Mani)
- Replace devm_device_add_group() with sysfs_create_group() and remove it explicitly in remove(); this drops the !loopback guards from all sysfs show/store callbacks (Mani)
- Reset the channel in the start_store() timeout path so the device releases
the queued TREs before the buffers are freed (Mani)
- Drop the status sysfs attribute; start already blocks and returns the
errno (Mani)
- Capitalize the error strings and print the errno (Mani)
- Drop the mutex_lock()/mutex_unlock() pair and dev_set_drvdata(NULL) from mhi_loopback_remove() (Mani)
- Use ret instead of rc and return 0 on the probe() success path (Mani)
- Validate num_tre against both the UL and DL rings, and check both for free space in start_store() before queuing any TRE
- Log the transaction status in the host ul_xfer_cb() callback
- ep: rename loopback_wq to wq, log the kmemdup()/kmalloc() failures, and
reword the error strings (Mani)
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Fix MHI_LOOPBACK_MAX_TRE_SIZE: change SZ_64K to (SZ_64K - 1) since the TRE length field is 16 bits and cannot encode 65536 (sashiko)
- Move mhi_prepare_for_transfer() to probe() so ring->el_size is initialized before num_tre_store() calls mhi_get_free_desc_count() (sashiko)
- Add mhi_unprepare_from_transfer() in mhi_loopback_remove() (sashiko)
- Add NULL guard in all sysfs show/store callbacks against post-remove drvdata race with devres teardown (sashiko)
- Add KMALLOC_MAX_SIZE check before kzalloc() to prevent page allocator WARN
on large tre_count * tre_size values (sashiko)
- Fix start_store() to use __free(kfree) locals instead of goto-based cleanup
to comply with cleanup.h guard+goto mixing rule (sashiko)
- Change buf_left and read_offset from u32 to size_t in mhi_ep_queue() to
avoid truncation of size_t len parameter (sashiko)
- Add zero-length guard in mhi_ep_loopback_ul_callback() before kmemdup() to handle 0-byte transfers returning ZERO_SIZE_PTR (sashiko)
- Add NULL guard in mhi_ep_loopback_ul_callback() against post-remove drvdata race (sashiko)
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Move ep driver to drivers/bus/mhi/ep/clients/loopback.c (Mani)
- Move host driver to drivers/bus/mhi/host/clients/loopback.c; keep
module name mhi_loopback (Bjorn, Mani)
- Add ABI documentation in Documentation/ABI/testing/sysfs-bus-mhi-devices-loopback (Bjorn, Mani)
- Rename sysfs attribute 'size' to 'tre_size'; add 'max_tre_size' attribute
- Update Kconfig title to 'MHI LOOPBACK client driver' and describe that
the driver binds to the MHI LOOPBACK channel defined in the MHI spec
(Mani).
- Fix memory leak in ep loopback DL transfer error path.
- Rename mhi_ep_skb_completion() to mhi_ep_buf_completion().
- Document buffer ownership semantics in mhi_ep_queue_buf() kernel-doc
- Fix use-after-free in host loopback
- Fix completion race: arm completion before queuing recv TREs
- Fix teardown race: synchronize mhi_loopback_remove() with start_store()
via lb_mutex
- Fix u32 multiplication overflow in total_size: use size_mul()
- Replace kmalloc+memcpy with kmemdup in ep loopback UL callback
- Update mhi_ep_queue_buf() kernel-doc: note per-TRE callback behavior
when buffer length spans multiple host DL TREs
- Move mhi_prepare_for_transfer()/mhi_unprepare_from_transfer() into start_store() to avoid holding the channel open when idle
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Use __free(kfree) macro for buffers
- Removed NET layer socket buffer dependency, now using buffer and len
- Created a New Api for queuing buffers for clients which do not use skb
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Sumit Kumar (3):
bus: mhi: host: clients: Add loopback driver with sysfs interface
bus: mhi: ep: Add mhi_ep_queue_buf() API for raw buffer queuing
bus: mhi: ep: clients: Add loopback driver for data path testing
.../ABI/testing/sysfs-bus-mhi-devices-loopback | 49 ++++ MAINTAINERS | 1 + drivers/bus/mhi/ep/Kconfig | 2 + drivers/bus/mhi/ep/Makefile | 1 + drivers/bus/mhi/ep/clients/Kconfig | 16 ++ drivers/bus/mhi/ep/clients/Makefile | 2 + drivers/bus/mhi/ep/clients/loopback.c | 129 +++++++++ drivers/bus/mhi/ep/main.c | 28 +- drivers/bus/mhi/host/Kconfig | 1 + drivers/bus/mhi/host/Makefile | 1 + drivers/bus/mhi/host/clients/Kconfig | 17 ++ drivers/bus/mhi/host/clients/Makefile | 2 + drivers/bus/mhi/host/clients/loopback.c | 312 +++++++++++++++++++++ include/linux/mhi_ep.h | 16 ++ 14 files changed, 569 insertions(+), 8 deletions(-)
---
base-commit: 6a746cd265aed59107ebdaa9ce039bb832922969
change-id: 20260820-lb-f1be38c98c83
Best regards,
Signature · 1 line
Sumit Kumar <[email protected]>