From nobody Mon Apr 6 16:31:56 2026 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 BB69C346FA9 for ; Thu, 19 Mar 2026 06:32:23 +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=1773901945; cv=none; b=cdQBpwQwF1Wm9EZ2poN6xlwMr4i77tOlmbJCj0hBhVd5mhKeoKl3PLPcq4aRA+5Niz4Fq/nUZaOlr9ia1wf+hC2+vByw23mObdyJ8I+FvaYSeXeJN/cvjcJam96mRVlWVNqiLlgrjqNQD9ozy67B1BNCaIR7aQDBcgHjWlMR/7E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1773901945; c=relaxed/simple; bh=zLHdxvYlh3SgJM3zwdFzuQdChe4Q/8MyqXYe5cHG93o=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SuvSw+7Mwi8BHS6Focb9ne+/Hkugvj00aqLQsjzasRbLpuFFqzF60kEIWyms29MLWMD/vA8G9cXHGx65PvhmVfyC2ruHvo1uL3jkA8h3slKqwazUv5wWfmowGh6ZHumADWRgMhG+7+Xq87fLyzKR9/sQBfieLEqZcAgnkv9+hPc= 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=YsLNHs4E; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ADrZ42HO; 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="YsLNHs4E"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ADrZ42HO" 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 62J5XUgu3574169 for ; Thu, 19 Mar 2026 06:32:23 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= iiXrCv65t5Cfe7JS9CAoM+yCgarvykPh0XYvrPKdD3o=; b=YsLNHs4ESlAlVBun SQlyjD5zscJyYzZ7SvkeNmzOkYaKxSikbLg1ELzJJZTBiU+CnRu0Dx9bOa+N2KnG nCil+AlRj/yvaGwbkgjj6glQdR3T1c4k462uSVSibHHPGdCdcfmabwlZDOOYxMO7 39pj0Y8ztpK4W/badPXfvDZxs2VxverZt2Mw4BmjpoztOT4e0GyUK+bsQl5QwmtM KwDA+Yl6es15EM1RIIkpRVffWm+vHCLZS6HzUpx/Er8VHY5Toq/KgqDVsnl+ZYDo G9fVCXHqEVcK7L+RjRr/lD9sG72Ov3sMYc4KH9xPW6m068gobAecuggJq98q07TV Whm45w== Received: from mail-pl1-f199.google.com (mail-pl1-f199.google.com [209.85.214.199]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4d083r8nf3-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 19 Mar 2026 06:32:23 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2b064f043adso6001175ad.0 for ; Wed, 18 Mar 2026 23:32:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1773901942; x=1774506742; 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=iiXrCv65t5Cfe7JS9CAoM+yCgarvykPh0XYvrPKdD3o=; b=ADrZ42HOJabjta4ZEQgi4Fu7uy02LXKrd0n8kJHF30hoUObXNHcn3oqwhDReNZsq01 i5M3EYEmsrFh265xI37g9yRmX41rD4ikxWxDDC7irJB6RlFHUSbhQScv8o+btIDJBamE NqHwIppceUdyHWhKUWqmwd4DBDyS/NFjGpybhYDqyAWY2Q/UTGPn2yRoWkNed3YjGbtU w+ilV1H475mVVl+MkrWAYWUoVm3miaHZkDAYdKOwxWLFsTSXJyp7X05uV61SMIfr3vvb 5iIGIcMppQkNR5ymDryByy3mRnMp5CkwdV7obiYbH/LxIpxOCFpH65hhGMemW/KF6SA0 6Mpg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1773901942; x=1774506742; 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=iiXrCv65t5Cfe7JS9CAoM+yCgarvykPh0XYvrPKdD3o=; b=SmKKFZZlCcA1wMnSUap9ycqzkDxnhb9ZpqLdJ1V+0cblzRFk5nooiSQ93nOPssl+Wy pm0TlLAh/tW0o44MSyFFBqqRshUkJvPSPh9XK1tymvjZR2EUhXKLjJGEXzhq7YSBLQRx kNrAe6UgV4IZyciLz6PDEpkAZHn9GMehhw3qrYofD0acetw56RTl1TDaardTDU04Jb3z 8Nj0GZ2phJyOT5aV+3z61ijDs2zeIu7K5A76It0JXgj3pQ8psCvo6KcWhTx/Mam7MWqm sz+IQ9BK4LqaZNZ7NkKxrtHMHbAnJbQ8/HNLKtB1S1LbunBoOJ1b2yjBmRi/1mvQOqbT 7Z3w== X-Forwarded-Encrypted: i=1; AJvYcCWkGtrqJ3qML0748K/bBZVkAYaXKpIuI8otd2In7UoDDDkc8+yV1tPE+CGbs7gQ7TiwhBIjb+45M9wdhA8=@vger.kernel.org X-Gm-Message-State: AOJu0YwLElr3Mp1vbKc9WDPpaNtMwMzJgApzW9GCntIGsZl941gu7L6z lD17O1y2DvcJUDyi7EXpcoalxj2lD5cw2bSrVqkrSw65mJ0+4UI6xtVXuityubgk1R5+SNIJZOz fBBVLKtWJuyXa4PhL4eamZJCuzzqoF/iFJ1kgNrk5ZV5KutKi3ONuQTE3TMaQg3P9uxc= X-Gm-Gg: ATEYQzycE3HMq4QWvj6CXiHfcuvY0y/4B44+WWkzZwHffvz9tBZDwcUVdlyqzilGb3J EN8X34INoKBHC86EarlTTKVUBn1vgphyF1/V04r6Ht3Sc0PH+hTobN0VFuwnRgLOpgXL2NO0U2C xR/4uIrUIXJ+qAyxXKhktjVubV1NYuA0fwQEhkvTnB/IHj9dS5r4OAuw/7OHD4+oa15GH0wATtM ckB2X/2+sjR1kwm3y0FD0vs4e8lLFRx4EIQH4mxIyeAQgnrmpb2LqlFT0XBfmKu5ur+dFshGxxJ a2GcVQxl5QHAA1Z3tkbo8Ep2W+rcCcs6hoXv9ncE+DdSL994q6U/5O5dNApAaOVfm7BlSpNkvJv l7Yk/DJago8/U6NU2V7WZDo0jTBJG5JanYLWRgq/S4BN+2O9AcHU= X-Received: by 2002:a17:903:1a67:b0:2b0:5a4c:726a with SMTP id d9443c01a7336-2b06e41afc9mr57939965ad.43.1773901942219; Wed, 18 Mar 2026 23:32:22 -0700 (PDT) X-Received: by 2002:a17:903:1a67:b0:2b0:5a4c:726a with SMTP id d9443c01a7336-2b06e41afc9mr57939835ad.43.1773901941736; Wed, 18 Mar 2026 23:32:21 -0700 (PDT) Received: from hu-batta-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2b06e603937sm48572485ad.57.2026.03.18.23.32.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 18 Mar 2026 23:32:21 -0700 (PDT) From: Kishore Batta Date: Thu, 19 Mar 2026 12:01:48 +0530 Subject: [PATCH v4 8/9] bus: mhi: Expose DDR training data via controller sysfs 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: quoted-printable Message-Id: <20260319-sahara_protocol_new_v2-v4-8-47ad79308762@oss.qualcomm.com> References: <20260319-sahara_protocol_new_v2-v4-0-47ad79308762@oss.qualcomm.com> In-Reply-To: <20260319-sahara_protocol_new_v2-v4-0-47ad79308762@oss.qualcomm.com> To: Jonathan Corbet , Shuah Khan , Jeff Hugo , Carl Vanderlip , Oded Gabbay , Manivannan Sadhasivam , andersson@kernel.org Cc: linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, mhi@lists.linux.dev, Kishore Batta X-Mailer: b4 0.14.2 X-Developer-Signature: v=1; a=ed25519-sha256; t=1773901902; l=3311; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=zLHdxvYlh3SgJM3zwdFzuQdChe4Q/8MyqXYe5cHG93o=; b=E912BIRgk2tIUK4/M4i8++DPEcAM8x+0kS4yuwICPrM81yr9VdRFAzP87se9p2qP1rqiZUxb4 9ZzAK2xR+g5DkO5ycJfNGU8vhWZhLd/M+V0j9MwRw2DwL6pPFoJCvz0 X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-GUID: UF-3ix-_kMyWrSvrt3Y6v-v-8uHbtxxc X-Proofpoint-ORIG-GUID: UF-3ix-_kMyWrSvrt3Y6v-v-8uHbtxxc X-Authority-Analysis: v=2.4 cv=ApTjHe9P c=1 sm=1 tr=0 ts=69bb9877 cx=c_pps a=JL+w9abYAAE89/QcEU+0QA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_K5XuSEh1TEqbUxoQ0s3:22 a=EUspDBNiAAAA:8 a=9mPLix8uEUeM4unapbcA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzE5MDA0OSBTYWx0ZWRfXzJG6zeMVBlP2 rNtoZkjrPHqocZc4ECNYf5hxgoyn/UJWZaPtW4bAxsj8oNun1u3CSIHXSYFeE0587a6Za30cMHq 1pkxGzQ40d83nyJrlDc0tWgOFwzd2U71ScvkcxWaDwKkv2kVUxHlLi0mrwnCEJUvoZwa6lcnmvT gxNtxiBW5yGiV/hU6gn5YEW+qXkbEBZ8h1LO8hdhdpt5PvvrMb8K5gbuMqZpN2g599k8+fe/qsQ NNdZa69wDX4WOCOzskb+UY1WaNWT5WtEhxAFacf1Gyp8iPF/vj5DLbYv6iv1QV2iBapLYfeJHp+ 7XulJDRsFcCCHHel2YZ8ehATYWbQeBWboHwQPUCSsdiddH3JZ6Q/Zw9IhP5fxAdHh1NLanvczXc VMRnwTTmGMbSlovl7fh26neyn0DUKqIPZfVuaCPILVw0aYSnOIRilehOVnrbMANU4o8Fy7G8xs/ RbTqvqbQXLzSSktgxLg== X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.51,FMLib:17.12.100.49 definitions=2026-03-19_01,2026-03-17_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 phishscore=0 lowpriorityscore=0 adultscore=0 malwarescore=0 suspectscore=0 clxscore=1015 impostorscore=0 priorityscore=1501 spamscore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2603050001 definitions=main-2603190049 DDR training data captured during Sahara command mode needs to be accessible to userspace so it can be persisted and reused on subsequent boots. Currently, the training data is stored internally in the driver but has no external visibility once the sahara channel is torn down. Expose the captured DDR training data via a read-only binary sysfs attribute on the MHI controller device. The sysfs file is created under the controller node, allowing userspace to read the training data even after the sahara channel device has been removed. The sysfs attribute reads directly from controller-scoped storage and relies on device managed resources for cleanup when the controller device is destroyed. No explicit sysfs removal is required, avoiding lifetime dependencies on the Sahara channel device. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 69 +++++++++++++++++++++++++++++++++++++= ++++ 1 file changed, 69 insertions(+) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index c88f1220199ac4373d3552167870c19a0d5f23b9..b7208738df10fc3c3895acd4687= 3412818dc1730 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -415,6 +415,73 @@ static struct sahara_ctrl_trng_data *sahara_ctrl_trng_= get(struct device *dev) return ct; } =20 +static ssize_t ddr_training_data_read(struct file *filp, struct kobject *k= obj, + const struct bin_attribute *attr, char *buf, + loff_t offset, size_t count) +{ + struct device *dev =3D kobj_to_dev(kobj); + struct sahara_ctrl_trng_data *ct; + size_t available; + + ct =3D sahara_ctrl_trng_get(dev); + if (!ct) + return -ENODEV; + + mutex_lock(&ct->lock); + + /* No data yet or offset past end */ + if (!ct->data || offset >=3D ct->size) { + mutex_unlock(&ct->lock); + return 0; + } + + available =3D ct->size - offset; + count =3D min(count, available); + memcpy(buf, (u8 *)ct->data + offset, count); + + mutex_unlock(&ct->lock); + + return count; +} + +static const struct bin_attribute ddr_training_data_attr =3D { + .attr =3D { + .name =3D "ddr_training_data", + .mode =3D 0444, + }, + .read =3D ddr_training_data_read, +}; + +static void sahara_sysfs_devres_release(struct device *dev, void *res) +{ + device_remove_bin_file(dev, &ddr_training_data_attr); +} + +static void sahara_sysfs_create(struct mhi_device *mhi_dev) +{ + struct device *dev =3D &mhi_dev->mhi_cntrl->mhi_dev->dev; + void *cookie; + int ret; + + if (devres_find(dev, sahara_sysfs_devres_release, NULL, NULL)) + return; + + ret =3D device_create_bin_file(dev, &ddr_training_data_attr); + if (ret) { + dev_warn(&mhi_dev->dev, + "Failed to create DDR training sysfs node (%d)\n", ret); + return; + } + + cookie =3D devres_alloc(sahara_sysfs_devres_release, 1, GFP_KERNEL); + if (!cookie) { + device_remove_bin_file(dev, &ddr_training_data_attr); + return; + } + + devres_add(dev, cookie); +} + static int sahara_find_image(struct sahara_context *context, u32 image_id) { char *fw_path; @@ -1272,6 +1339,8 @@ static int sahara_mhi_probe(struct mhi_device *mhi_de= v, const struct mhi_device_ return ret; } =20 + sahara_sysfs_create(mhi_dev); + return 0; } =20 --=20 2.34.1