From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mx0a-0031df01.pphosted.com (mx0a-0031df01.pphosted.com [205.220.168.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 EE91B3DA5DA for ; Mon, 17 Aug 2026 10:14:46 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=205.220.168.131 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961689; cv=none; b=SgN+8ru+w/c6H5MQws+raOjRNUTvE4UW2wfKb0GRoOTrgsqi4p9hjb/gTSDP353NqkuBEVF6Hs+LdFjsfQ+C+4rdRjPL7wNrLfqL9TAGS0O+uRoNmW+U17jJLyuIw4QQmSbm8dsbs/csox0dF9LEJbsL3SMUafIbXTtl0GePHrM= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1786961689; c=relaxed/simple; bh=ApMUAuZs3L2v5RzHWa7346il7lYG55ETS5DCt1UhV9I=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=bRSUFTQqdNxYB16fLVCwYFqtiYe5uEMkp0o7xoafL1Feb6y9k7Y3ulD6s4ebwjZFNztnu1WyO75j2a96pZL58AHIyh/KUrzbwdCYAPqLB74qFdMY+B7eJeyHpERoSR4/G1KjbCB2hXpYCpnHC1PbcgtnRs5B6OMrtmb5+i6KR7Q= 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=LUoZz0O4; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=HXHspIk6; arc=none smtp.client-ip=205.220.168.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="LUoZz0O4"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="HXHspIk6" Received: from pps.filterd (m0279864.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 67H9ddt71058307 for ; Mon, 17 Aug 2026 10:14:46 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= s08t3lOMFf+kNQ18LHM3sQsH9kbgW1CP2CV275SRJLM=; b=LUoZz0O43HuxfbdA 5RdfhAqWVwvHtWOYuCn9rzCcJ8VxcH+Ilmp6GbqDHbEp3GgMl+RH/Vz4rCrWXD+b Q2Dp/ngTGUoUyB0ZIv1tHpDr5TjDcTYaCaIWlzQCaBumu7IAeIToSjeYJmsUsMW+ htLySgYC7CeIZNF8s+bLn+Qs+qpR2Yu9/ENbiwZF6CgXMQOd/JeovkJsEN3XY9gV Ug5HXnVnUFztllhqRWtHmIaqxKx1RsPxbGpi+9UUkvxqQt9Pl/T71DvkyZx9Br4c CYoGs1C7kVDf4hO4Da4NN/hZRDgVsZYDWbMrgt0mk4HRnUzyp11xbxojmrh7psYn 2qNFJQ== Received: from mail-pj1-f70.google.com (mail-pj1-f70.google.com [209.85.216.70]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4g3x30gk1c-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 17 Aug 2026 10:14:46 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-38dc085b0a7so6082700a91.2 for ; Mon, 17 Aug 2026 03:14:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1786961685; x=1787566485; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:from:to:cc:subject:date :message-id:reply-to:content-type; bh=s08t3lOMFf+kNQ18LHM3sQsH9kbgW1CP2CV275SRJLM=; b=HXHspIk6EhxfWLoU0NJAq8wrU6SovCeprIlyoGdSAynG2rmMn4mwNeJSRsX8V1LNOx XnABST+p+53oSnZgUDpK01V9EHiGJsei3xSbENBIWprOhZygBth5B+fQcqfMOJeE4T9m NqNsreBLVBa/9yDhcMyAUofQCAQOwEDFdqou52ykz8L/q8Wh1A1mIPX1kx6smCE8JQnN WTdu35/GyWE4njTBGDWPLv6Bppc+pdlsXm0HzasB5J5ltNBOyLTKxHnSMCiBQhr5iAxn W2vMZNLrJhGc1QTUJUaEgyNbKDIsgXeXfKS5KmZZLVi8kqXtrIvT0QdWYKoohdjQL9Ad LAjw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1786961685; x=1787566485; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :content-type:mime-version:subject:date:from:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to :content-type; bh=s08t3lOMFf+kNQ18LHM3sQsH9kbgW1CP2CV275SRJLM=; b=Inje+5C6eVFgeYZMHLxIHxQ9puKZdvK38m1pbOGRvewePS3BxSH2Y2u6dqSd9BXdiJ nIv1NTlORtM+U2UJ/V9mXX4QRaOyPyFbByHjVBvMDL5x5kdhnUEJIAGa07LB17bLGMEI X9qF5/MxW4Rtwk3KqcOqkLCVI5+jqxw0uilOw76xQXROp2PatZdFHn+3tUWReaKvd6l8 KM964KSe2unlXkwXw978KnAGr8ibIVnbJ0Mi8V+j2PosaCw+BYKTLJcbutXdTl6eKjEw /9gbtHj/poni+yqRs+O1pHO9+BRFK1QVHi3kdZAW4B93IZfafFxZRvwPV1dIu8LhIqbh sOZQ== X-Forwarded-Encrypted: i=1; AHgh+Rp5orZ4PmZjOTiIsWyEh0xp3wm8c6Ua1DDitQ98Q+uX57jg3FW5D6H+fZmEhv1ertWJ7P0sMlxCDkRLcQA=@vger.kernel.org X-Gm-Message-State: AOJu0YxsTVksz3WYa6U2yFq7gupoQEFgqVui+1obYaaLx5xd0SN0jCP/ X3x6RtLSVo5/2cJIPYoeJ8mTqd00GMdQHHjFtApypzynZaG1A3k7q36xgRwGerIvL/5FpS6Xw7i TzY6BTAYXLbY8v7lobRkRqV/iPRL2MtFcnpZc8W2A9zFbJOHMwnMsYSLromq4bcC18Vo9t3ygOy 0= X-Gm-Gg: AR+sD121Brp/j9d0SQIyCOUjCzqHVJW9QJXN83tpnveJcsiN8bYg7KVuc+Jpb8sYbjY 383o1vYhUcgMzhMvu6GbiCcbOD5CYWCdqe1V05rYxk3uLoSX1PFyuRF87rYjgxQZRd1OWzXyJaa 93N/YD0DSrXrQnfJtpYeGxWvJI3ogMqTJNQaIcO+5PjecCthrXdxmh5H8AnrttUtnj54Jay9I7O Q6Xw1AIKhjQ5pZV13tujGU01f6KxAljevznrddIy+ucjdCwF+N+V2VoqWoYrmJT7QjFuuyavONd ewXkgWlSZQOo+24YKGx+DZu/86TrBMYbPl7vLSgiSG4a72IL+6dmQN265xbh+gkRcLBlku+9T34 HQ6RGd89DcOSRzoVpSdDlJUBx+A== X-Received: by 2002:a17:90b:2f0d:b0:38e:7268:220d with SMTP id 98e67ed59e1d1-3933ed5e238mr26276646a91.20.1786961685353; Mon, 17 Aug 2026 03:14:45 -0700 (PDT) X-Received: by 2002:a17:90b:2f0d:b0:38e:7268:220d with SMTP id 98e67ed59e1d1-3933ed5e238mr26276588a91.20.1786961684805; Mon, 17 Aug 2026 03:14:44 -0700 (PDT) Received: from hu-sumk-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3954d3d2adcsm1744315a91.17.2026.08.17.03.14.42 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 17 Aug 2026 03:14:44 -0700 (PDT) From: Sumit Kumar Date: Mon, 17 Aug 2026 15:44:35 +0530 Subject: [PATCH v5 2/3] bus: mhi: ep: Add mhi_ep_queue_buf() API for raw buffer queuing Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: 7bit Message-Id: <20260817-loopback_mhi-v5-2-50efc7360b7f@oss.qualcomm.com> References: <20260817-loopback_mhi-v5-0-50efc7360b7f@oss.qualcomm.com> In-Reply-To: <20260817-loopback_mhi-v5-0-50efc7360b7f@oss.qualcomm.com> To: Manivannan Sadhasivam , Jeff Hugo Cc: mhi@lists.linux.dev, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org, Sumit Kumar X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1786961675; l=4480; i=sumit.kumar@oss.qualcomm.com; s=20250409; h=from:subject:message-id; bh=ApMUAuZs3L2v5RzHWa7346il7lYG55ETS5DCt1UhV9I=; b=t1VhTPN6kzGBpFfFaDq9P+GpbUSoTNNPt96OcLRkBbdB+qO5xEt10P9IafMXqPtGefWixkP2U GkiUlE3ZbEYCzWXObScFhi4FvoINKcxzpn+hXD89a5zbH4nYH3Bcre6 X-Developer-Key: i=sumit.kumar@oss.qualcomm.com; a=ed25519; pk=3cys6srXqLACgA68n7n7KjDeM9JiMK1w6VxzMxr0dnM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwODE3MDA3NSBTYWx0ZWRfX43ppBhvVcTfN hlknX4Y13mJ48VxELWoVH8/duCsUf5iPzmk5OiWIQIIpmhi5g0q8Uvs8QYcuUQ1Ft9akQfIisUd +AkjVEnNw6G3C6Tf5lM1DEknzEcsy5+VNoX8NIkR3pgKCRMQ61XzteUWwuDzHbHfm4Q/ny8CiMP dVryVbAl8lNObUrFusHTQ+nyL9NiDIVFUANOtVxKsZ3P3dG7loN6Qbq2Hc8znkXapl4FWkMwPmY GlrPv/q0NxaqLwQLtQjNk9DmYtKWGPWl1mZ0m5YreL4s5Ybs4HxYwG/qBABd+zgLwke8NUu851D XC73ukOT1yudl4+HK78D2nEzsulLD5QRMgHqTDRA8lFHWYNtEY0OoOdUOnCAMfZC1G3EC91/OaL iRnuZ3i8aKJhBYJ7wmAlAfx4WoxKCOshtA/QOyJ3Po6QWCiKmVgGsr9vj75F+0OgkXkNYAPkAFd TD7g/BCyQfWRWVTvV8A== X-Proofpoint-GUID: nv2RIipZu3L5qsyzH0wI2-gSWBIeApJN X-Proofpoint-ORIG-GUID: nv2RIipZu3L5qsyzH0wI2-gSWBIeApJN X-Authority-Analysis: v=2.4 cv=Y9/IdBeN c=1 sm=1 tr=0 ts=6a82df16 cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Sv0fKeRqtYgA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=DJpcGTmdVt4CTyJn9g5Z:22 a=EUspDBNiAAAA:8 a=27Ti7_ZD70JoqEhemiIA:9 a=QEXdDO2ut3YA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-Spam-Info: AW1haW4tMjYwODE3MDA3NSBTYWx0ZWRfXwtyAuE27dwIi S1Hqf5IgAerDS0WGVhNGSsFtPmhLMJVymFqq2gbHTnSRyFQIw0RwiXLY3RD0YkMv70cFjKYf6xd FxTYAKonLJU+Dmc0Xf3lr9zMP6XVxpU= 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-16_06,2026-08-12_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 adultscore=0 priorityscore=1501 impostorscore=0 clxscore=1015 bulkscore=0 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2608170075 Some MHI endpoint clients do not use socket buffers and need a way to queue raw buffers for DL transfers. Add mhi_ep_queue_buf() to support this use case. Refactor mhi_ep_queue_skb() to delegate to a new internal mhi_ep_queue() helper shared by both APIs, and rename mhi_ep_skb_completion() to mhi_ep_buf_completion() to reflect its broader use. Signed-off-by: Sumit Kumar --- drivers/bus/mhi/ep/main.c | 29 ++++++++++++++++++++--------- include/linux/mhi_ep.h | 16 ++++++++++++++++ 2 files changed, 36 insertions(+), 9 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index 038b47158f0e0c905194779e24da1ad851e76061..7be1d3bbf5339156fee85d6b47603a5c8d46a8d5 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -505,7 +505,7 @@ static int mhi_ep_process_ch_ring(struct mhi_ep_ring *ring) return 0; } -static void mhi_ep_skb_completion(struct mhi_ep_buf_info *buf_info) +static void mhi_ep_buf_completion(struct mhi_ep_buf_info *buf_info) { struct mhi_ep_device *mhi_dev = buf_info->mhi_dev; struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl; @@ -533,22 +533,22 @@ static void mhi_ep_skb_completion(struct mhi_ep_buf_info *buf_info) mhi_ep_ring_inc_index(ring); } - /* TODO: Handle partially formed TDs */ -int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) +static int mhi_ep_queue(struct mhi_ep_device *mhi_dev, void *buf, size_t len, + void *cb_buf) { struct mhi_ep_cntrl *mhi_cntrl = mhi_dev->mhi_cntrl; struct mhi_ep_chan *mhi_chan = mhi_dev->dl_chan; struct device *dev = &mhi_chan->mhi_dev->dev; struct mhi_ep_buf_info buf_info = {}; struct mhi_ring_element *el; - u32 buf_left, read_offset; + size_t buf_left, read_offset; struct mhi_ep_ring *ring; size_t tr_len; u32 tre_len; int ret; - buf_left = skb->len; + buf_left = len; ring = &mhi_cntrl->mhi_chan[mhi_chan->chan].ring; mutex_lock(&mhi_chan->lock); @@ -571,13 +571,13 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) tre_len = MHI_TRE_DATA_GET_LEN(el); tr_len = min(buf_left, tre_len); - read_offset = skb->len - buf_left; + read_offset = len - buf_left; - buf_info.dev_addr = skb->data + read_offset; + buf_info.dev_addr = buf + read_offset; buf_info.host_addr = MHI_TRE_DATA_GET_PTR(el); buf_info.size = tr_len; - buf_info.cb = mhi_ep_skb_completion; - buf_info.cb_buf = skb; + buf_info.cb = mhi_ep_buf_completion; + buf_info.cb_buf = cb_buf; buf_info.mhi_dev = mhi_dev; /* @@ -616,8 +616,19 @@ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) return ret; } + +int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb) +{ + return mhi_ep_queue(mhi_dev, skb->data, skb->len, skb); +} EXPORT_SYMBOL_GPL(mhi_ep_queue_skb); +int mhi_ep_queue_buf(struct mhi_ep_device *mhi_dev, void *buf, size_t len) +{ + return mhi_ep_queue(mhi_dev, buf, len, buf); +} +EXPORT_SYMBOL_GPL(mhi_ep_queue_buf); + static int mhi_ep_cache_host_cfg(struct mhi_ep_cntrl *mhi_cntrl) { size_t cmd_ctx_host_size, ch_ctx_host_size, ev_ctx_host_size; diff --git a/include/linux/mhi_ep.h b/include/linux/mhi_ep.h index f6383a57a872bf3cdea236ae9fe65f4ec8747b3e..852f331f03fda5c0212585de7d6f4eb9f8270609 100644 --- a/include/linux/mhi_ep.h +++ b/include/linux/mhi_ep.h @@ -304,4 +304,20 @@ bool mhi_ep_queue_is_empty(struct mhi_ep_device *mhi_dev, enum dma_data_directio */ int mhi_ep_queue_skb(struct mhi_ep_device *mhi_dev, struct sk_buff *skb); +/** + * mhi_ep_queue_buf - Transfer buffer contents to host over MHI Endpoint + * @mhi_dev: Device associated with the DL channel + * @buf: Buffer to be queued. On success, ownership passes to the MHI stack; + * the caller must not free @buf until the DL transfer callback fires + * with result->buf_addr equal to @buf. On failure, the caller retains + * ownership and must free @buf. + * Note: if @len spans multiple host DL TREs, the DL transfer callback + * fires once per TRE, each time with result->buf_addr equal to @buf. + * @len: Size of the buffer + * + * Return: 0 if the buffer contents have been transferred successfully, a + * negative error code otherwise. + */ +int mhi_ep_queue_buf(struct mhi_ep_device *mhi_dev, void *buf, size_t len); + #endif -- 2.34.1