From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0b-0031df01.pphosted.com (mx0b-0031df01.pphosted.com [205.220.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5F7E454788 for ; Mon, 17 Aug 2026 20:14:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.180.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786997693; cv=none; b=Diq55Cm7Zs2r4zjwqz41DqaIADLIfedLBTGVK14b9JTOp1nRnIU4buOnggr8aX4b6ijSdNNyUT8GvJVDnovaTJUSbJFKAKMwpWAFoyJzL+mjMOOtDeOdAyhExpzkn+icXAlpbPCm1DB26iqI7YbeyAHY54OrLaBgiDNFkqxOQPA= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786997693; c=relaxed/simple; bh=0p5U2mZ9pFGL+cVxKO+d4T7B5DEZxK2XBgxHmp+6t5Y=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=tYbnVHHulRX2dtt6Esolmp9A6khsY8VpRUvRyvJowoodVo7ikGITIR7JIMWW7M1QbAlHhTfrWxacltxeaU/gOFlCNQt6SXBv0zZh+ZfL98HAWbuDQlx93Smx/lwGEPxD9EOGcayFFFe4Ebz/vTWYINBanNn98YeGDkDe8zlrhYE= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com; spf=pass smtp.mailfrom=oss.qualcomm.com; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b=BNgCGo7U; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=AqMFncfn; arc=none smtp.client-ip=205.220.180.131 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oss.qualcomm.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=qualcomm.com header.i=@qualcomm.com header.b="BNgCGo7U"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="AqMFncfn" Received: from pps.filterd (m0279871.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67HIRkjD3460160 for ; Mon, 17 Aug 2026 20:14:50 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=qualcomm.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to; s=qcppdkim1; bh= u3lGwKZ0pCeF54C056iWA8ghYAbCCtaH8ropmAW0y5A=; b=BNgCGo7Un+ByFUnD 5Oh3jF0sPvxVzWUTOqAgr8lHlQSWzmR7ImIeTzz/Nho0YOtfHCnM7uV8UR+hBuxA a2Bp4kO34kUjnQqTZedrFmGGxDGvsmkoINOncJclGFh1126oEZo22C4TOIgq6OXc KRVhMxFy7pQICl4okZ8aVAiwXlklpYs0UZPnD4jZemsYxD5bCpV6lLZGiXel7ARW FbLRowLENdn38C3ZES/C3X9LEvd2tiNg7EKdM4sdecRXR8p0LL7PuPnNAhHFUVE+ lQ4yqFGgMx3ePGtuHFIkr6UEzqj2cdev7zawTWqbo+YLsngbcNfHcf3FDrQaMXjr s2kNZA== Received: from mail-pg1-f199.google.com (mail-pg1-f199.google.com [209.85.215.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3y77arxs-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 17 Aug 2026 20:14:50 +0000 (GMT) Received: by mail-pg1-f199.google.com with SMTP id 41be03b00d2f7-cbee5bab340so4989069a12.2 for ; Mon, 17 Aug 2026 13:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786997689; x=1787602489; darn=vger.kernel.org; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:from:to:cc:subject:date:message-id:reply-to :content-type; bh=u3lGwKZ0pCeF54C056iWA8ghYAbCCtaH8ropmAW0y5A=; b=AqMFncfnFE13t1lgsn6bUhy68YYzCitgKbNeKU7ZjjOPkCTS14WTaLhzV1eKPf48Cc 2B3VDViAE9/cvMSiIK4Pe/+U61yUpOX5/CLL8PkrAbRTfH/hb2R9mSLJgFb7KiveGltx 7yrQaEWa25MMha1o69oaT5SMuyLbdkBOjAFw+4YgBXmafgQ4Vo4XLadWokQbqUZr/gpA /IGdbfAYIN2byvvzv8hjSU+8qmvSoR7Grj6f7DH7qTstvb6w9EolRghSWJ2zQa0HneY4 YFFhIRfP8zXPV9dsiCpFJebOjXnf8eYbCE0gOUKAszy0buf3duZe1aB1BcEbLJhNsZmS oiOQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786997689; x=1787602489; h=content-transfer-encoding:content-type:in-reply-to:from :content-language:references:cc:to:subject:user-agent:mime-version :date:message-id:x-gm-gg:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to:content-type; bh=u3lGwKZ0pCeF54C056iWA8ghYAbCCtaH8ropmAW0y5A=; b=onKBi9bNUqawUXXrvhhIy2a4xuR73P+3ho2qwVJeeN1ShmaTpc6iPYDNgD04+KdoUY DTXiwB/lyrfStpwYbx46hDGElcr0B8UEAPCMvsmSLG02TanLPLNRu3bbVBqKXSAaHARg m0IVem9E84rG6hN6OLz7uJ2gW+9QiZeXxIQrfgt5XQsNWFwzXpoLcwB4lGvQvDfn/gYM P8C1efqu0vq62xLXOEmb2IaA2tivI2jMBLtNB23KiV+RznVb2aM2wbIRCg6S07IZQ8kh uxieJ/11FpasaRkB+h3YeZKvbXI3IWRJRhXQY19w7qGHq9Jld3T44Ujba1y/u5OYN6gZ +cUw== X-Forwarded-Encrypted: i=1; AHgh+Rp9szbEsM1asWmHRSs+5FiD6+xG/JU/NuYrawcE6zlerxF0IUBv66+SXzt/ugYdnZ3nWCm6QWVl0CMiOIg=@vger.kernel.org X-Gm-Message-State: AOJu0YyyzinzrtzHgn1xhP9+pxp+lhPjX182Nvlzh+eOImyqq5HbqaMJ viGGy4oXWOFyR9wivughB37IkLotwmP/6/JALDzmAxfC5CPcpabkKH10K/TcfAv47TQYYRLCoIi rYNnnudxM/hptYAWY5ya1LN/xYRNz9jPGtELtigaQZp9UhdoC0xxmuwr82VzKJ+GUgHY= X-Gm-Gg: AR+sD11j0cQ2dL8e0uy/M+7dGJ1T2nAXoNf9RuR9EFnyUggsBS7KTauhpXwMV5WQZcp sQMxRyNuH+ktmKr3qx6DLvAiT7JHMzBC96M/kxqKR5Zuyhsm7iTnkwOqHZlmgUprBsCOWq8CM5+ 3IddmX8BMtGQQTD44Z+0b+vqngBnwas9Fw1ruTBm8CLPqVNV67vGpqnPk8lMDj02Qt2iLUZ6nUF XcXRe7aj+lwm0numtVggqOxDMaEkQUuPdicxe6rCg2WAY81rYqPmoyq4xjXplbh1d+7KGzj3Hsq u/aV6+7kEwvG8Q1Z4MqDXK0xBHSS5rzOjR2Yh5w4UzTUb4kUhSFYDy90/gouZM28sletQtUkCyU qRXHJnMGjDNDppq+ZO5Z+dBAagaxKxKPf9EcaqUkFJ29FDB/hKci5hw== X-Received: by 2002:a05:6a21:3a48:b0:3c3:b57b:6291 with SMTP id adf61e73a8af0-3ccdac00616mr3098079637.18.1786997688766; Mon, 17 Aug 2026 13:14:48 -0700 (PDT) X-Received: by 2002:a05:6a21:3a48:b0:3c3:b57b:6291 with SMTP id adf61e73a8af0-3ccdac00616mr3098013637.18.1786997688236; Mon, 17 Aug 2026 13:14:48 -0700 (PDT) Received: from [10.226.59.182] (i-global254.qualcomm.com. [199.106.103.254]) by smtp.gmail.com with ESMTPSA id a92af1059eb24-1415315900csm9043579c88.11.2026.08.17.13.14.47 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 17 Aug 2026 13:14:47 -0700 (PDT) Message-ID: <1b5301df-3d0a-497b-823d-fe43a34a5ee6@oss.qualcomm.com> Date: Mon, 17 Aug 2026 14:14:46 -0600 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v5 1/3] bus: mhi: host: clients: Add loopback driver with sysfs interface To: Sumit Kumar , Manivannan Sadhasivam Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Krishna Chaitanya Chundru References: <20260817-loopback_mhi-v5-0-50efc7360b7f@oss.qualcomm.com> <20260817-loopback_mhi-v5-1-50efc7360b7f@oss.qualcomm.com> Content-Language: en-US From: Jeff Hugo In-Reply-To: <20260817-loopback_mhi-v5-1-50efc7360b7f@oss.qualcomm.com> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDE1NCBTYWx0ZWRfXwKBx4Daf4nmT l9so85PaqHDSajs3UuXYY6RQqqZ076SfU9q4WgUjrSIyxi9UfHQQWGBPMzIws9MkT+9QW3jI/0Z mpTvgqLerOJI7goe8YCj6l0gl29XjEY2ehdVE34odA7q3PuYUHbh30bJnHDZ0fezmploy+tn9LP lvAxczg6VwDPBBCi7asPpIvFDg3Gey5C32O1Z2GIagSJShd919XvGdnErlWu/8mlFI170P/f3T/ OziPag0tkC4jCcggQzoBDjy9uZ6U4DZPxMI7dL30Kj134mWm2buU6b9R5JbdKhFxK9cp++7w7qR Pd8nkUYzE1YnnJT2yHhxAwcBqDv0BoD7brLEQKjzGKnXmZpSXbbicwt7DHkogMc0xsxtQm824d+ Udy+LP6hllYHYlrVHl5H2WFJ+PvLLq2xhcfaPj+pK2kU5tGM+7ioZ65nemcGqmipfLpcP62v4qP y0KVzZ1sU58p9rx7WGQ== X-Proofpoint-ORIG-GUID: 2BdJJk8x2hTSsBuok9LFVSpLi0za7qeV X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDE1NCBTYWx0ZWRfXz8GL6L7q6XVf YixQD1gsRWF5xKs6RJMyJtic/Z/KXUU8ohv45IZLg29EIc+RU84+BqwUl3sjlqiCuyPzF8OHZhn WYkv6w9DRhPzBN+vv00wtLiCzTct8Wk= X-Proofpoint-GUID: 2BdJJk8x2hTSsBuok9LFVSpLi0za7qeV X-Authority-Analysis: v=2.4 cv=WNhPmHsR c=1 sm=1 tr=0 ts=6a836bba cx=c_pps a=Oh5Dbbf/trHjhBongsHeRQ==:117 a=JYp8KDb2vCoCEuGobkYCKw==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=VwQbUJbxAAAA:8 a=a58Mu5QqHWmLOZgColsA:9 a=QEXdDO2ut3YA:10 a=_Vgx9l1VpLgwpw_dHYaR:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1176,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-08-17_03,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 spamscore=0 phishscore=0 impostorscore=0 adultscore=0 malwarescore=0 clxscore=1015 priorityscore=1501 bulkscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170154 On 8/17/2026 4:14 AM, Sumit Kumar wrote: > The MHI specification defines a LOOPBACK channel. 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. > > Add a host-side loopback driver that binds to the LOOPBACK channel and > expose a sysfs interface for data path testing. The sysfs interface allows > users to configure TRE buffer size and count, trigger a loopback test, and > read the result. > > Co-developed-by: Krishna Chaitanya Chundru > Signed-off-by: Krishna Chaitanya Chundru > Signed-off-by: Sumit Kumar > --- > .../ABI/testing/sysfs-bus-mhi-devices-loopback | 39 +++ > MAINTAINERS | 1 + > 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 | 289 +++++++++++++++++++++ > 7 files changed, 350 insertions(+) > > diff --git a/Documentation/ABI/testing/sysfs-bus-mhi-devices-loopback b/Documentation/ABI/testing/sysfs-bus-mhi-devices-loopback > new file mode 100644 > index 0000000000000000000000000000000000000000..1622a146110c2069c8b51e5bdf665c882b853303 > --- /dev/null > +++ b/Documentation/ABI/testing/sysfs-bus-mhi-devices-loopback > @@ -0,0 +1,39 @@ > +What: /sys/bus/mhi/devices/mhi_LOOPBACK/tre_size > +Date: August 2026 > +KernelVersion: 7.2 This series missed 7.2, and will miss 7.3 since the merge window is already open. Next oppertunity is 7.4. > +Contact: mhi@lists.linux.dev > +Description: > + (RW) Size of each Transfer Ring Element (TRE) buffer in bytes > + used for the loopback test. Valid range is 1 to the value > + reported by max_tre_size. Default value is 32 bytes. > + > +What: /sys/bus/mhi/devices/mhi_LOOPBACK/max_tre_size > +Date: August 2026 > +KernelVersion: 7.2 > +Contact: mhi@lists.linux.dev > +Description: > + (RO) Maximum allowed TRE size in bytes. Reading this file Entry before this and after this explains the TRE acronym, but this does not. It probably should, as someone may jump directly to this section and not read the entire document start to finish. > + returns the upper bound for the tre_size attribute. > + > +What: /sys/bus/mhi/devices/mhi_LOOPBACK/num_tre > +Date: August 2026 > +KernelVersion: 7.2 > +Contact: mhi@lists.linux.dev > +Description: > + (RW) Number of Transfer Ring Elements (TREs) to use per > + loopback test. Must be greater than zero and must not exceed > + the channel ring capacity. Default value is 1. How would I know the channel ring capacity? Should I just try values until I get an error? > + > +What: /sys/bus/mhi/devices/mhi_LOOPBACK/start > +Date: August 2026 > +KernelVersion: 7.2 > +Contact: mhi@lists.linux.dev > +Description: > + (WO) Write any value to trigger a loopback test. The driver > + sends random data to the endpoint using the configured tre_size It feels like these kind of interfaces usually give an option to specify a byte pattern as well, but I don't see that option here. Is random data considered to cover all usecases? > + and num_tre parameters, waits for the endpoint to echo it back, > + and verifies the received data matches what was sent. > + > + This is a blocking write that returns when the test completes > + or times out after 5 seconds. The write returns an error code > + if the test fails or times out. > diff --git a/MAINTAINERS b/MAINTAINERS > index a4b89bd497ad5051c190025838e0e93d257ed061..098b12692140514da52565a3200801f5e24a43b7 100644 > --- a/MAINTAINERS > +++ b/MAINTAINERS > @@ -17469,6 +17469,7 @@ L: linux-arm-msm@vger.kernel.org > S: Maintained > T: git git://git.kernel.org/pub/scm/linux/kernel/git/mani/mhi.git > F: Documentation/ABI/stable/sysfs-bus-mhi > +F: Documentation/ABI/testing/sysfs-bus-mhi-devices-loopback Commit text says this ABI is stable. Seems odd its being added to testing. > F: Documentation/mhi/ > F: drivers/bus/mhi/ > F: drivers/pci/endpoint/functions/pci-epf-mhi.c > diff --git a/drivers/bus/mhi/host/Kconfig b/drivers/bus/mhi/host/Kconfig > index da5cd0c9fc620ab595e742c422f1a22a2a84c7b9..627c57948235aa52348179ae8b2d0826ebaed01e 100644 > --- a/drivers/bus/mhi/host/Kconfig > +++ b/drivers/bus/mhi/host/Kconfig > @@ -29,3 +29,4 @@ config MHI_BUS_PCI_GENERIC > This driver provides MHI PCI controller driver for devices such as > Qualcomm SDX55 based PCIe modems. > > +source "drivers/bus/mhi/host/clients/Kconfig" > diff --git a/drivers/bus/mhi/host/Makefile b/drivers/bus/mhi/host/Makefile > index 859c2f38451c669b3d3014c374b2b957c99a1cfe..2a16008aeb38127494782bbff4e1656428d2b776 100644 > --- a/drivers/bus/mhi/host/Makefile > +++ b/drivers/bus/mhi/host/Makefile > @@ -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-y += clients/ > diff --git a/drivers/bus/mhi/host/clients/Kconfig b/drivers/bus/mhi/host/clients/Kconfig > new file mode 100644 > index 0000000000000000000000000000000000000000..312a0b5a8e83b6ad7246453908bd552841a89188 > --- /dev/null > +++ b/drivers/bus/mhi/host/clients/Kconfig > @@ -0,0 +1,17 @@ > +# SPDX-License-Identifier: GPL-2.0 > + > +config MHI_BUS_LOOPBACK > + tristate "MHI LOOPBACK client driver" > + depends on MHI_BUS > + help > + MHI LOOPBACK client driver that binds to the MHI LOOPBACK channel > + as defined in the MHI specification. The LOOPBACK channel is > + implemented by MHI-based devices (modems, WLAN) in the field, where Are modems, WLAN the only devices that implement this, or are those intended to be examples? Current reads as a limitation. > + the endpoint firmware echoes back whatever the host sends. > + > + This driver exposes a sysfs interface for testing MHI data path > + integrity between host and endpoint. Users can configure the TRE > + size and count, and trigger a loopback test. > + > + To compile this driver as a module, choose M here. The module > + will be called mhi_loopback. > diff --git a/drivers/bus/mhi/host/clients/Makefile b/drivers/bus/mhi/host/clients/Makefile > new file mode 100644 > index 0000000000000000000000000000000000000000..3811b6928f42b38f94b1167941cf3b0fe512d32b > --- /dev/null > +++ b/drivers/bus/mhi/host/clients/Makefile > @@ -0,0 +1,2 @@ > +obj-$(CONFIG_MHI_BUS_LOOPBACK) += mhi_loopback.o > +mhi_loopback-y += loopback.o > diff --git a/drivers/bus/mhi/host/clients/loopback.c b/drivers/bus/mhi/host/clients/loopback.c > new file mode 100644 > index 0000000000000000000000000000000000000000..02a952e8e01222cd8cb842c9f9490479df8ea2bd > --- /dev/null > +++ b/drivers/bus/mhi/host/clients/loopback.c > @@ -0,0 +1,289 @@ > +// SPDX-License-Identifier: GPL-2.0 > +/* > + * Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. > + */ > + > +#include > +#include > +#include > +#include > +#include > +#include I'm pretty sure this is now incorrect based on cleanups that just occured in tree. > +#include > +#include > +#include > +#include > +#include > +#include > +#include > +#include > + > +#define MHI_LOOPBACK_DEFAULT_TRE_SIZE 32 > +#define MHI_LOOPBACK_DEFAULT_NUM_TRE 1 > +#define MHI_LOOPBACK_TIMEOUT_MS 5000 > +#define MHI_LOOPBACK_MAX_TRE_SIZE (SZ_64K - 1) > + > +struct mhi_loopback { > + struct mhi_device *mdev; > + /* Serializes the sysfs attributes against a running test */ > + struct mutex lb_mutex; > + struct completion comp; > + atomic_t tre_pending; I'm not really sure I understand what purpose this is serving. > + u32 num_tre; > + u32 tre_size; I'm pretty sure these are the wrong types since they cross kernel boundaries.