bus: mhi: Add loopback driver for host & ep
Subsystems (2)
cover bus: mhi: Add loopback driver for host & ep
This series add MHI loopback drivers to enable comprehensive testing and validation of MHI data path functionality between host controllers and endpoint devices. The drivers support configurable transfer sizes, TRE chaining, and provide real-time status reporting for thorough testing.
---
Sumit Kumar (2):
bus: mhi: host: Add loopback driver with sysfs interface
bus: mhi: ep: Add loopback driver for data path testing
drivers/bus/mhi/ep/Kconfig | 8 + drivers/bus/mhi/ep/Makefile | 1 + drivers/bus/mhi/ep/mhi_ep_loopback.c | 132 +++++++++++++ drivers/bus/mhi/host/Kconfig | 7 + drivers/bus/mhi/host/Makefile | 1 + drivers/bus/mhi/host/mhi_loopback.c | 348 +++++++++++++++++++++++++++++++++++ 6 files changed, 497 insertions(+)
---
base-commit: e6b9dce0aeeb91dfc0974ab87f02454e24566182
change-id: 20250903-loopback_mhi-dee55ff0d462
Best regards,
Signature · 1 line
Sumit Kumar <[email protected]>
PATCH 1/2 bus: mhi: host: Add loopback driver with sysfs interface
Add loopback driver for MHI host controllers that provides sysfs based testing interface for data path validation. The driver supports the "LOOPBACK" channel and offers configurable test parameters.
Sysfs interface provides:
- size: Configure TRE size
- num_tre: Set number of TREs for chained transfers
- start: Initiate loopback test
- status: Read test results
The driver is useful for testing TRE chaining functionality, and verifying data integrity.
--- drivers/bus/mhi/host/Kconfig | 7 + drivers/bus/mhi/host/Makefile | 1 + drivers/bus/mhi/host/mhi_loopback.c | 348 ++++++++++++++++++++++++++++++++++++ 3 files changed, 356 insertions(+)
drivers/bus/mhi/host/Kconfig +7 -0
@@ -29,3 +29,10 @@ config MHI_BUS_PCI_GENERIC This driver provides MHI PCI controller driver for devices such as Qualcomm SDX55 based PCIe modems. +config MHI_BUS_LOOPBACK + tristate "MHI loopback driver" + depends on MHI_BUS + help + MHI loopback driver for data path testing. This driver + provides a mechanism to test MHI data transfer functionality + by implementing an echo service between host and endpoint.
drivers/bus/mhi/host/Makefile +1 -0
@@ -4,3 +4,4 @@ mhi-$(CONFIG_MHI_BUS_DEBUG) += debugfs.o obj-$(CONFIG_MHI_BUS_PCI_GENERIC) += mhi_pci_generic.o mhi_pci_generic-y += pci_generic.o +obj-$(CONFIG_MHI_BUS_LOOPBACK) += mhi_loopback.o
drivers/bus/mhi/host/mhi_loopback.c new file +348 -0
348 lines not on this page · raw message
Signature · 1 line
2.34.1
Re: [PATCH 1/2] bus: mhi: host: Add loopback driver with sysfs interface
…
Quoted 2 lines
+++
b/drivers/bus/mhi/host/mhi_loopback.c(quoted diff) +0
-0@@ -0,0 +1,348 @@
…
Quoted 6 lines
drivers/bus/mhi/host/mhi_loopback.c new file +6
-0+static ssize_t start_store (struct device *dev, +struct device_attribute *attr, +const char *buf,size_t count) +{ +struct mhi_loopback *mhi_lb =dev_get_drvdata (dev); +void *send_buf, *recv_buf;
…
Quoted 1 line
(quoted diff) +1
-0+ guard(mutex)(&mhi_lb->lb_mutex);
…
drivers/bus/mhi/host/mhi_loopback.c line 205
Quoted 5 lines
drivers/bus/mhi/host/mhi_loopback.c new file +5
-0+free_buf: +kfree (send_buf); +free_recv_buf: +kfree (recv_buf); +unlock:
+ mhi_lb->loopback_in_progress = false;
Review
Quoted 2 lines
(quoted diff) +2
-0+ return ret; +}
…
Under which circumstances would you become interested to apply an attribute like “__free(kfree)”?
https://elixir.bootlin.com/linux/v6.17-rc7/source/include/linux/slab.h#L476
Regards,
Markus
PATCH 2/2 bus: mhi: ep: Add loopback driver for data path testing
In reply to Sumit KumarAdd loopback driver for MHI endpoint devices. The driver receives data on the uplink channel and echoes it back on the downlink channel using a workqueue for asynchronous processing.
The driver is useful for testing MHI endpoint data path functionality and debugging communication issues.
--- drivers/bus/mhi/ep/Kconfig | 8 +++ drivers/bus/mhi/ep/Makefile | 1 + drivers/bus/mhi/ep/mhi_ep_loopback.c | 132 +++++++++++++++++++++++++++++++++++ 3 files changed, 141 insertions(+)
drivers/bus/mhi/ep/Kconfig +8 -0
@@ -8,3 +8,11 @@ config MHI_BUS_EP MHI_BUS_EP implements the MHI protocol for the endpoint devices, such as SDX55 modem connected to the host machine over PCIe. + +config MHI_BUS_EP_LOOPBACK + tristate "MHI Endpoint loopback driver" + depends on MHI_BUS_EP + help + MHI endpoint loopback driver for data path testing. + This driver receives data on the uplink channel and echoes + it back on the downlink channel for testing purposes.
drivers/bus/mhi/ep/Makefile +1 -0
@@ -1,2 +1,3 @@ obj-$(CONFIG_MHI_BUS_EP) += mhi_ep.o mhi_ep-y := main.o mmio.o ring.o sm.o +obj-$(CONFIG_MHI_BUS_EP_LOOPBACK) += mhi_ep_loopback.o
drivers/bus/mhi/ep/mhi_ep_loopback.c new file +132 -0
132 lines not on this page · raw message
Signature · 1 line
2.34.1
kernel test robot
build botRe: [PATCH 2/2] bus: mhi: ep: Add loopback driver for data path testing
kernel test robot noticed the following build errors:
Hi Sumit,
kernel test robot noticed the following build errors:
[auto build test ERROR on e6b9dce0aeeb91dfc0974ab87f02454e24566182]
url: https://github.com/intel-lab-lkp/linux/commits/Sumit-Kumar/bus-mhi-host-Add-loopback-driver-with-sysfs-interface/20250923-144109 base: e6b9dce0aeeb91dfc0974ab87f02454e24566182 patch link: https://lore.kernel.org/r/20250923-loopback_mhi-v1-2-8618f31f44aa%40oss.qualcomm.com patch subject: [PATCH 2/2] bus: mhi: ep: Add loopback driver for data path testing config: loongarch-randconfig-001-20250929 (https://download.01.org/0day-ci/archive/20250929/[email protected]/config) compiler: loongarch64-linux-gcc (GCC) 12.5.0 reproduce (this is a W=1 build): (https://download.01.org/0day-ci/archive/20250929/[email protected]/reproduce)
If you fix the issue in a separate patch/commit (i.e. not just a new version of the same patch/commit), kindly add following tags
| Reported-by: kernel test robot <[email protected]>
| Closes: https://lore.kernel.org/oe-kbuild-all/[email protected]/
All errors (new ones prefixed by >>):
loongarch64-linux-ld: drivers/bus/mhi/ep/mhi_ep_loopback.o: in function `mhi_ep_loopback_dl_callback':
>> mhi_ep_loopback.c:(.text+0x20): undefined reference to `sk_skb_reason_drop' loongarch64-linux-ld: drivers/bus/mhi/ep/mhi_ep_loopback.o: in function `mhi_ep_loopback_work_handler': mhi_ep_loopback.c:(.text+0x74): undefined reference to `sk_skb_reason_drop' loongarch64-linux-ld: drivers/bus/mhi/ep/mhi_ep_loopback.o: in function `mhi_ep_loopback_ul_callback': >> mhi_ep_loopback.c:(.text+0x19c): undefined reference to `__alloc_skb' >> loongarch64-linux-ld: mhi_ep_loopback.c:(.text+0x1e4): undefined reference to `skb_put' >> loongarch64-linux-ld: mhi_ep_loopback.c:(.text+0x2b8): undefined reference to `sk_skb_reason_drop'
Signature · 2 lines
0-DAY CI Kernel Test Service https://github.com/intel/lkp-tests/wiki