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 A59F43546E2 for ; Mon, 22 Jun 2026 05:09:28 +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=1782104970; cv=none; b=mPu836jM911zHWnhkXMYPs/wZcyHMGDxhgFHiBvUxSaHWRDvvSbDpvroXrWYJyn/OdQ8ZyAEViDQEexxUtg56eXNhcLhAYhNL2YdmUYS+g7X4g/FsyqJCjW+pUamFr6IeUGjMEfqd6wFpp2QWdDzyZPAy04kkWnxoXng/ffIDWo= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782104970; c=relaxed/simple; bh=gGfaQBQV4ve45W3l4vga1g6v8XiqE+OMpkXU/G8WWwU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=feeecgSxiwBVhkx65oN6f7El+Z4asYE1w5UeFqe2OLBYHwBz6fWgO4aO6kHwoaQRE7n8Ib+CtY/uPbqeSLlm4jIxIU/HyhbwDdEjbQHxdAmWsNE1DwMs1wdT6FoJL67OIxOnRfWoPT2AsiVfgE+NaKZzTSm2upvJEeLXdoyoius= 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=hvRL0yEL; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=guvsO3tN; 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="hvRL0yEL"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="guvsO3tN" Received: from pps.filterd (m0279862.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 65M59BVW3786565 for ; Mon, 22 Jun 2026 05:09:28 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= rFRW4uvz7oIyfQLLlTaUlea6eRZCi9oGvqy2/uhqCNc=; b=hvRL0yELe8o/N2tO J9l/e+TBTR0BSS8yq8+ypjq9FklOyYMpl/yExOtjX4PWLjwDQ/MjtnZQL/N8cQhE oMdl7X+ORpcnCYlkLpz5EYkG8dwCwp4/G/rmYFx6JFpg63f+2tQSu4DNOoxhCZSY vJK/jNa8NDcD8Dk1Ub6eWJsyaa9G+DhWtTb7r+MRZM3p0RDPlkiwjj7JNEjOT4uZ WVjKsyt+nnNOqOeEFljezIJp5Byf+4hnbWoEiIRvEbhFE6vC1UVx7pDi8nTQtWU7 9FMGFkNA+XhnW+EN5B8FjFr8JxwRyv9am+kd25X3ws/ri/RQiJjzq3B4VkkRH7A5 1cEc+g== Received: from mail-pf1-f199.google.com (mail-pf1-f199.google.com [209.85.210.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4ewkmecpre-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 22 Jun 2026 05:09:27 +0000 (GMT) Received: by mail-pf1-f199.google.com with SMTP id d2e1a72fcca58-845319bb97bso3240561b3a.0 for ; Sun, 21 Jun 2026 22:09:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782104967; x=1782709767; darn=vger.kernel.org; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:from:to:cc:subject:date:message-id :reply-to; bh=rFRW4uvz7oIyfQLLlTaUlea6eRZCi9oGvqy2/uhqCNc=; b=guvsO3tNBBT+/dGGVzwu6Om2aHV1cjjRHegLGXpgUj2e/Ej4dCDShZN8vjV9uXlgTI K7vcenn4Equ0XqACpSeMQANijAcBIbwr97xK1Rl/Bv/aeVqz6FEv3LVc8hDGYo7wWnBo 68ZT/5q0C7msD5XGFwlBMSGbGyLyeTc0Qot6he++J0MJR9SmffUJSSzDxg1xqdRO4q8b eL60pCT/fcS1GcZu1uBd8tA6cNs7rRF0zl0GHuVXQ8AwJc1kbigDvUb1FmEiQsF7aqIj LBuTSfU4GZu2uLhEbxdDZNkhfNGqHe0xa34H1mEn9KQUw6+f+LinmIf5+eiGIizCHgqJ bv+A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782104967; x=1782709767; h=cc:to:in-reply-to:references:message-id:content-transfer-encoding :mime-version:subject:date:from:x-gm-gg:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=rFRW4uvz7oIyfQLLlTaUlea6eRZCi9oGvqy2/uhqCNc=; b=LBHluR1S122rkhhpM4R7HqEmITR+mU/QeCLPJ6Un/Eaz6NnVi8WDChHBOfUicUTGxd uuxUT4HfTIWtCNNS5rTzjnNVG2hJ6M1x2Nnz8suvZ52HPsIvgl+Pq50zRni2//obGmPX 6VNEOes9QQp6zQz9cC8+3cC9pizdv6WwO9dFCh7drlbqJh0usMaXZ/ws58DbjtpbMzhW Q4Le+ESSnUUIax3jPhkC9qnJOC4jid0/Ri70IJ2Y/AvP6BSsWL+QEaSSAj10qEJ8tJkQ qU20CC4UT3DynTsI2MY5L8WogOa0OWT+NfGc1q/OR7eTVscSUWLTpFxWFRwWQSxpBIb4 hQNQ== X-Forwarded-Encrypted: i=1; AFNElJ8iDTbCwzLTic+/+lMmG5yecBUJNNThM15gs9JyHjGh0BWiefH3t3PBw2H9a/XdhQgyMV4Y2TIm8sxC7AE=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7Xyh2L5pt6OAMWrzxz7MdUYJqnDGlavc+ixxcUnKBW42y/iZE x9q6BVXPpVNCJlLg+5KsZ6/4be5JMT9G0pSrsZhTgWAgSV3I1PQoYsBhSNG6W4WnCrCY+fOtivq yBnkvqdhtI/sqkRwj2AuxUdjTkcbHkH6jTaIqsRqH6u065m9XOjR+9eKAL7Fwy/dN1GvO56l9WH g= X-Gm-Gg: AfdE7cnEUQfZyS/7iRbnkaHrKWOLOiEoQ9qsUy5JnzTVkIq4uiFnvMcRHbG8u+l3Uza ST2nHf1mg1onwvKZoDvVZQItzrLjJfAERTDsL10n5D4FIhPAnuKryo86t1GKOZM6FJaP9+k6K8x pJ/PKL4nxOeWe29Fxmg8L+vLwefq6K6GBp4aawk6HWxw5y7r1ovbxms8q8zubZCzIRwUZEnJO7k 1eGUs0mHYc23M+gYYy3KBUlv8aO0RAdYuT/mIVXDwPJ5Vl/7YML2CNfZANsDqjPuUVnhTYpwn4J D1AP0QbLAXT45scUgk5uNPNWyb354lOwbihYHRUZeW/U20IcyMuYeMIzC+C/aNUciReLI6c1yOe TOEvftWzagsAILWQpl2buJcHl8741Fa3c8xDi X-Received: by 2002:a05:6a00:1307:b0:842:21f0:5113 with SMTP id d2e1a72fcca58-8455088e136mr13692116b3a.24.1782104967257; Sun, 21 Jun 2026 22:09:27 -0700 (PDT) X-Received: by 2002:a05:6a00:1307:b0:842:21f0:5113 with SMTP id d2e1a72fcca58-8455088e136mr13692050b3a.24.1782104965798; Sun, 21 Jun 2026 22:09:25 -0700 (PDT) Received: from hu-sumk-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d2e1a72fcca58-84564d6c5dbsm5905996b3a.12.2026.06.21.22.09.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 21 Jun 2026 22:09:25 -0700 (PDT) From: Sumit Kumar Date: Mon, 22 Jun 2026 10:39:16 +0530 Subject: [PATCH v4 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: <20260622-loopback_mhi-v4-2-782b3a0f2eef@oss.qualcomm.com> References: <20260622-loopback_mhi-v4-0-782b3a0f2eef@oss.qualcomm.com> In-Reply-To: <20260622-loopback_mhi-v4-0-782b3a0f2eef@oss.qualcomm.com> To: Manivannan Sadhasivam 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=1782104957; l=4444; i=sumit.kumar@oss.qualcomm.com; s=20250409; h=from:subject:message-id; bh=gGfaQBQV4ve45W3l4vga1g6v8XiqE+OMpkXU/G8WWwU=; b=Inx12IRZtn+PGKi5C1sB8q4ewBGMbnrNj8GYASSzmUwR1k7xA3mbnVEG8aUXfV+Xod2ur6uq5 01H8HcJBDr8BFAzLvLBvrjsrtJTYRYlP8ncdGf4jBCr4NQ0tn5QOv4s X-Developer-Key: i=sumit.kumar@oss.qualcomm.com; a=ed25519; pk=3cys6srXqLACgA68n7n7KjDeM9JiMK1w6VxzMxr0dnM= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNjIyMDA0NyBTYWx0ZWRfX0p3oGUoYhtEQ vzhJa+sY3sz3HvLO9/RaUSM9MI7KuUH8AdK9RvimgfpV4lqO0iBrPlHgRp8mV04VI+mYnU+6xYS 2wJpKIQN3PcNOOu16UzMiHJ6FMf6QOaAZBaEuhxtXjdTYRjhp+U9MLj9jpYo+ikONjeMND9IPnM jLrAhHnP0Iinv66OhVYeT9OyLJSJo+2Wu5W3G54JDD9aOLwprP859BTsAWFbNJ9hwNmJAKaTXww qfK+MjYRlRUtkxKtTdBx7gu23oTVDiQEDfnl+qK8phFy1LBTZ1OOUud7TtuCwoiDImEJQSaYp43 c4V06aGjRvQ/G1uUSeX5H6qfy+L/g8lXlDB32nuNOZqobx+dHPBbyZqT9KymEVoAQIPkMn7BbMn DO46xw4vgqqF3/HZWxe+rDqjBBLrXlGEB4XyHzb4UlI9X0wJebNnrKxogta7PePEiHqxhZHM3u+ KHDKcjoWrvVesbGR+Bg== X-Authority-Analysis: v=2.4 cv=MtFiLWae c=1 sm=1 tr=0 ts=6a38c388 cx=c_pps a=WW5sKcV1LcKqjgzy2JUPuA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=FelO9ux0wxsA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=27Ti7_ZD70JoqEhemiIA:9 a=QEXdDO2ut3YA:10 a=OpyuDcXvxspvyRM73sMx:22 X-Proofpoint-GUID: MqvxTQq4-xTDhHlwUDan5n1vLguMbeVH X-Proofpoint-Spam-Info: AW1haW4tMjYwNjIyMDA0NyBTYWx0ZWRfX5Nx7fe/8WIX3 6X78+QFRQIU+TK4THa0A4piH0iHyi3rvqXtvHY9peMEHydiBdWfAlxGctam+z3cFuWQJQ6g2bFf VreZzcSWR2+5iVZAN0yMPCU2nuGlEzI= X-Proofpoint-ORIG-GUID: MqvxTQq4-xTDhHlwUDan5n1vLguMbeVH X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.125,FMLib:17.12.100.49 definitions=2026-06-22_01,2026-06-18_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 lowpriorityscore=0 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 adultscore=0 spamscore=0 priorityscore=1501 suspectscore=0 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2606220047 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 | 15 +++++++++++++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/drivers/bus/mhi/ep/main.c b/drivers/bus/mhi/ep/main.c index b3eafcf2a2c50d95e3efd3afb27038ecf55552a5..d44e1e54cfb4404b6589aab372e687db7492d3c3 100644 --- a/drivers/bus/mhi/ep/main.c +++ b/drivers/bus/mhi/ep/main.c @@ -516,7 +516,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; @@ -544,22 +544,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); @@ -582,13 +582,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; /* @@ -627,8 +627,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 7b40fc8cbe77ab8419d167e89264b69a817b9fb1..59f796e56207aaf8be09edc9ba4d1f59b665581f 100644 --- a/include/linux/mhi_ep.h +++ b/include/linux/mhi_ep.h @@ -302,4 +302,19 @@ 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 - Send buffer 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 has been sent 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