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 BDFC238F642 for ; Mon, 13 Jul 2026 07:30:36 +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=1783927839; cv=none; b=BVgHu0aD0qUrRH1DZ2NxL9h98as7xaCtlghJ/QFaaPS7bT5698La5rq+fCaCvdqRCkcz/vxN47v+5MGbQLhNJOsT8dYt9XT0wnUxjbvsN1LCYTTQsZRX8dQvgDK2M2EjHIN6Epqj40/txlLXi+o2hUM9wEBWvZMFTyUnt/LRkPw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1783927839; c=relaxed/simple; bh=Y+CcFGR2oOYkQpeQy0juSOs+7RRYPsi2bo3KBJtoaF0=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=WYZJ1g4ejh+V2kbK1SCS71feFCii9ioVhaHUq0/bfeXeY8CYp07/yN8dr3QrmFl/DDJT3wKIP0RXPsidFuszkzOX7whhAW4btfZsj0zLCJCQzQNNHgQzwADqOrpV4QpJO5ygsw4LYAiKm5krYpucwiYWU8YWDDreJFi/ZMzenl4= 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=oFRZG0FB; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Q+hulXtf; 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="oFRZG0FB"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Q+hulXtf" 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 66D6Nx5e674491 for ; Mon, 13 Jul 2026 07:30:35 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= Em8mVgyGdEfRfVq1ukW+9EQ7G6falQSSjNEsV/umQPg=; b=oFRZG0FBTXeGJMO7 f5LvKnJ3r5wpsshA11v9obYuL3jKH64/1p+uVpjQ89vRdVurxK1TSUVGzT/0IKuH BoZjyVWB5FV1OXcTREh0siUr2XPrPTg9STj2dYweUWCtsivda+Z/lhJ3pno/+E4K +YyVQK1UkoF7yhpr8TQYwBgENLnJOdvUMaNh++9PhlguQ6o+wTG5myzklqYXbS6l upsNOmHwYJJaJQigTKTRI4yLU/7KHJ0MzmLjjEpzdOxpZ9nvT0spUZxRfeLu73CM qVYVITCw5AmSJLIt2y07or3Hk5tWmpz0jnasNBVTpAZ0zXmkQzmJj9bzdWg68lLC Q+DKKQ== Received: from mail-pj1-f72.google.com (mail-pj1-f72.google.com [209.85.216.72]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4fbecgn0fu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Mon, 13 Jul 2026 07:30:35 +0000 (GMT) Received: by mail-pj1-f72.google.com with SMTP id 98e67ed59e1d1-38de842a1a9so1566393a91.3 for ; Mon, 13 Jul 2026 00:30:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1783927834; x=1784532634; 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=Em8mVgyGdEfRfVq1ukW+9EQ7G6falQSSjNEsV/umQPg=; b=Q+hulXtfJ7PgGrkKmnhv9mJUQxVmERD2Zur94HvuCwtmEn1Y6kSOJOAsmCcyzjzX63 TyFKyOoiBqVlgz77Ruby80wLiticcc13y1iu/au2wF4IQnyPGTPnvI9sNsGKw+gQT6h2 frxUz1F9wHC4/qTRWyP5gbREHAYeM3lBWjH16xqJyQw22ZG4kXWisNB3mQ/mZ6PsaegD O/9TX/1vONvVjRPPLzvQ+3xBJxEfo8XwW6hb46f+Mjpl1R7iacPS64RbfDYQYiz2AaBj eDzxyn4cy/05C1DmYhMnkAHzyWrCZ7RT/uzJMsdEHa/W2rp86wR1fl07khNja6M7qD5k xdHw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1783927834; x=1784532634; 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=Em8mVgyGdEfRfVq1ukW+9EQ7G6falQSSjNEsV/umQPg=; b=dvI22TqI4MCzV6XVRGO7weucmJmSRdQ4CK/6FR1nJo7maCevB4aiuo+FgaBSEnY26+ fqe6VGYjFK2LvFX4521+zUa1OmPtw2Edd5lEeDEtJyK9lBfkcjJ612mqmogzyy2XJ2jf PsS+2LzcJxJfA2bu46OIy1AvLw7SWOmCus7zrupjVdN44PF2bRPA+v6Z3+Oc8eIYUs6O NntrctZJP3IFQSjuodMuo1K1R8zDGqg/3J7WxWSFJXrd9ztZXRjkfBq6A+qs9lyY9Fm1 lFnGaGX3+X+WEet8ZuIiS133ab1qZQro88NZ/6ES2nv7eXlETSHmcs8cIUoxiMEEyWz5 ideQ== X-Forwarded-Encrypted: i=1; AHgh+RpMzmZGYE5jZhp1wGF1txkFmXlJGB24fIEX2EwLMKa7zeDVAo5s6p7x5Q0B46u0/4thiPat6gPRT3VKCNQ=@vger.kernel.org X-Gm-Message-State: AOJu0Yw7Xv0OFuNJpj90//3nyz7yCaKAcZOQrE/IrSkyICS0STDw4iKo BAIjLJh1h2wl2tqhH6UCG7EU43HsPMyCCFKY3bugpxOdp26jQfPu/Z+jyvpFCwJOYHdlrTozqyZ BVpra0sObAaux5u5pC6/BAGZZZEgq+yHFp2fjqAoJdkPcxGehz6ua18CFBT33d2Ag3Mw= X-Gm-Gg: AfdE7ck69baLUAKULOtvlPyR4/3td0L9hDdrLkS2LbyijUXAPOm/ZUoUSf/54CKrwSk V6L2SAVArpf/JKCA8HEXxBK8UpU/uYNoBGyA8gvbVlhKggfFBp/YczWnR9LPFVHLsFOLfw+RWN0 WnzXL5eoJR3earP1d1Lhy8PG6BtYA9fc5az6FHff2C5McE6WGBbEGi1A4p6Fv7jhlzFV5QadYFe cUDLLGQpQ/eBjE7GsXqJIdq9bBDPdBBcHAPLH2xX0hCfMKNsMoJuPwqDtqZfhF04A6QMId8r4h1 b3tLLFUQQDRxGElc/N5xXzF6Adf+/eLSCkhYwhejAT8IpY8Dax3bmDGNw+Bf8/uN8LOrCJrmiH9 o06DyIhIDoq+qB6P3X81mxJWWQHRC672phLMDOgRQHy4= X-Received: by 2002:a17:90b:1fc6:b0:382:5c31:1f8a with SMTP id 98e67ed59e1d1-38dc7769973mr7950666a91.27.1783927834381; Mon, 13 Jul 2026 00:30:34 -0700 (PDT) X-Received: by 2002:a17:90b:1fc6:b0:382:5c31:1f8a with SMTP id 98e67ed59e1d1-38dc7769973mr7950579a91.27.1783927832681; Mon, 13 Jul 2026 00:30:32 -0700 (PDT) Received: from [10.217.219.169] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38a56417527sm6208769a91.16.2026.07.13.00.30.28 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Mon, 13 Jul 2026 00:30:32 -0700 (PDT) Message-ID: Date: Mon, 13 Jul 2026 13:00:27 +0530 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 v6 7/7] bus: mhi: Expose DDR training data via controller sysfs To: Manivannan Sadhasivam Cc: Jonathan Corbet , Shuah Khan , Jeff Hugo , Carl Vanderlip , Oded Gabbay , 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 References: <20260701-sahara_protocol_new_v2-v6-0-3a78362c4741@oss.qualcomm.com> <20260701-sahara_protocol_new_v2-v6-7-3a78362c4741@oss.qualcomm.com> Content-Language: en-US From: Kishore Batta In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Proofpoint-Spam-Info: AW1haW4tMjYwNzEzMDA3NiBTYWx0ZWRfX+mpUKo4u3LKo idh6AQrxir63njfF48fpR3B0HFEv5zwl7EChNRm2lUbzfuUiix90jVUImIkysRqyxXLQug3KlcR MlQilDuwgPnw1GAsfoVd0o21C9z22PI= X-Proofpoint-ORIG-GUID: hzxfR7BoOHuc46CGuDRHgMJKSefxucsM X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzEzMDA3NiBTYWx0ZWRfX73kxePF2DG4v AeuxX3aeoQO3pt5V0fkE/KmhrpesYF/dRry4ZAMlmTxlSkObAWWy2zTmrkALPO7JaqWOMlM8ORK v+0QQbK/2B0fw3/yDNv7K8hEdyMcXqHhCBOnUUvq1igBxJrpQAOCPtqwQuOsxFTG3kKH8oPxsLp a0KsKFrGB/p/RBLj01lriCJ7Dnc4XKcXozNOEiguLt/4vq4N/F7XSy1VGsyh8LG7r9KQjWEnA/s az4SwMIIoeUMcnVClxQdmtsrQNvHNI59mjeEIEiTc2WF2F/bQL7+9Dp7FDMpCQWVEJJn8wojrfn 4b/flc5Z37Z4B7W9YKqL6mjShUpyaS7/GKpSGfitum+Ma7ZsFrufcIAW3FO9M+HbnShW7IGn3mv EwsTQ7iawTCndzPynTZhJF4DM+D9aZ/Blf1RYlMimEThNwnlpgvFODMCaNnG/R54NWevvLycGr/ eOG6syyXYRXsMxKMs5g== X-Proofpoint-GUID: hzxfR7BoOHuc46CGuDRHgMJKSefxucsM X-Authority-Analysis: v=2.4 cv=KM9qylFo c=1 sm=1 tr=0 ts=6a54941b cx=c_pps a=RP+M6JBNLl+fLTcSJhASfg==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=0IlxrgZsFcjQ__LXY9EA:9 a=QEXdDO2ut3YA:10 a=iS9zxrgQBfv6-_F4QbHw:22 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.293,Aquarius:18.0.1143,Hydra:6.1.134,FMLib:17.12.100.49 definitions=2026-07-13_02,2026-07-10_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 phishscore=0 malwarescore=0 bulkscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 adultscore=0 priorityscore=1501 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607130076 On 7/9/2026 12:27 PM, Manivannan Sadhasivam wrote: > On Wed, Jul 01, 2026 at 04:07:41PM +0530, Kishore Batta wrote: >> 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: >> >> /sys/bus/mhi/devices//ddr_training_data >> >> The sysfs read callback serves data directly from controller scoped storage >> and protects access with the controller training data lock. The attribute >> lifetime is tied to the controller device via devres, allowing the data to >> remain readable after Sahara channel teardown and ensuring automatic >> cleanup when controller device is removed. >> > If this training data is RO, then what is the use of exposing it to userspace? > > - Mani The userspace component will read this from sysfs and save it to a file named mdmddr_0x.mbn. On the device's next boot, Sahara will read the training data file and send it to the device. The DDR driver on the device validates the training data and restores it without running DDR training again. >> Userspace flow: >> 1. For each controller device, userspace reads the ddr_training_data sysfs >> attribute. >> 2. If the read returns non-zero data, userspace persists it using a >> serial specific filename (for example, mdmddr_0x.mbn). >> 3. On subsequent boots, the Sahara driver attempts to load this serial >> specific DDR training image before falling back to the default >> training image, restoring DDR calibration data and avoiding retraining. >> >> Add ABI documentation for the DDR training data sysfs attribute exposed by >> Sahara MHI driver. >> >> Signed-off-by: Kishore Batta >> --- >> .../ABI/testing/sysfs-bus-mhi-ddr_training_data | 19 +++++++ >> drivers/bus/mhi/host/clients/sahara/sahara.c | 62 ++++++++++++++++++++++ >> 2 files changed, 81 insertions(+) >> >> diff --git a/Documentation/ABI/testing/sysfs-bus-mhi-ddr_training_data b/Documentation/ABI/testing/sysfs-bus-mhi-ddr_training_data >> new file mode 100644 >> index 0000000000000000000000000000000000000000..810b487b5a5fdba133d81255f9879844e3938a10 >> --- /dev/null >> +++ b/Documentation/ABI/testing/sysfs-bus-mhi-ddr_training_data >> @@ -0,0 +1,19 @@ >> +What: /sys/bus/mhi/devices//ddr_training_data >> + >> +Date: March 2026 >> + >> +Contact: Kishore Batta >> + >> +Description: Contains the DDR training data for the Qualcomm device >> + connected. MHI driver populates different controller >> + nodes for each device. The DDR training data is exposed >> + to userspace to read and save the training data file to >> + the filesystem. In the subsequent boot up of the device, >> + the training data is restored from host to device >> + optimizing the boot up time of the device. >> + >> +Usage: Example for reading DDR training data: >> + cat /sys/bus/mhi/devices/mhi0/ddr_training_data >> + >> +Permissions: The file permissions are set to 0444 allowing read >> + access. >> diff --git a/drivers/bus/mhi/host/clients/sahara/sahara.c b/drivers/bus/mhi/host/clients/sahara/sahara.c >> index 07bc743aa061dd2fa85638067d494562152474e3..72ac751c302a98448b5756c9feb438647bd0ce4b 100644 >> --- a/drivers/bus/mhi/host/clients/sahara/sahara.c >> +++ b/drivers/bus/mhi/host/clients/sahara/sahara.c >> @@ -273,6 +273,66 @@ static struct sahara_cntrl_training_data *sahara_cntrl_training_get(struct devic >> return ct; >> } >> >> +static ssize_t ddr_training_data_read(struct file *filp, struct kobject *kobj, >> + const struct bin_attribute *attr, char *buf, >> + loff_t offset, size_t count) >> +{ >> + struct device *dev = kobj_to_dev(kobj); >> + struct sahara_cntrl_training_data *ct; >> + size_t available; >> + >> + ct = sahara_cntrl_training_get(dev); >> + if (!ct) >> + return -ENODEV; >> + >> + mutex_lock(&ct->lock); >> + >> + /* No data yet or offset past end */ >> + if (!ct->data || offset >= ct->size) { >> + mutex_unlock(&ct->lock); >> + return 0; >> + } >> + >> + available = ct->size - offset; >> + count = min(count, available); >> + memcpy(buf, (u8 *)ct->data + offset, count); >> + >> + mutex_unlock(&ct->lock); >> + >> + return count; >> +} >> +static BIN_ATTR_RO(ddr_training_data, 0); >> + >> +static void sahara_sysfs_devres_release(struct device *dev, void *res) >> +{ >> + device_remove_bin_file(dev, &bin_attr_ddr_training_data); >> +} >> + >> +static void sahara_sysfs_create(struct mhi_device *mhi_dev) >> +{ >> + struct device *dev = &mhi_dev->mhi_cntrl->mhi_dev->dev; >> + void *cookie; >> + int ret; >> + >> + if (devres_find(dev, sahara_sysfs_devres_release, NULL, NULL)) >> + return; >> + >> + ret = device_create_bin_file(dev, &bin_attr_ddr_training_data); >> + if (ret) { >> + dev_warn(&mhi_dev->dev, >> + "Failed to create DDR training sysfs node (%d)\n", ret); >> + return; >> + } >> + >> + cookie = devres_alloc(sahara_sysfs_devres_release, 1, GFP_KERNEL); >> + if (!cookie) { >> + device_remove_bin_file(dev, &bin_attr_ddr_training_data); >> + return; >> + } >> + >> + devres_add(dev, cookie); >> +} >> + >> static int sahara_find_image(struct sahara_context *context, u32 image_id) >> { >> char *fw_path; >> @@ -1131,6 +1191,8 @@ static int sahara_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_device_ >> return ret; >> } >> >> + sahara_sysfs_create(mhi_dev); >> + >> return 0; >> } >> >> >> -- >> 2.34.1 >>