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 A324F3B8D79 for ; Thu, 8 Oct 2026 06:12:08 +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=1791439930; cv=none; b=OTywj6zm8oho9kfN/LoKreHz4nc4puRJSxogMqaoxW5iSll8VsOepaCQq6eGxecsOdlFsvw7la3MOxtulao63hKHIM1oyMi3Trpb1+neuuIwKsyWt/sXfi+Z8m2dVkVdW18oupL2+RjsOn+Ls8KcMFGvgRlAilkD0MisdoaJ6B4= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1791439930; c=relaxed/simple; bh=BYJ5rVqFRgTnxeMSjvRhSgYe8ffD+B5w+Tjsrc21jZ4=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=DWbImyFLqrWPG1DELBHsDXT+mpkPqfT7e9MUwY9CxsOYUnorCCt4Pi5nPrhQ1fx33UDflDjSMeTFDlvOfyV49M2DGtKf4GJ/0Fu0RBb/qqFJZGclnaThWEAPs0j9XfwfWPy559kOJrDKG3ose2wRuFCsITTl+HulfPFArTpByyM= 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=Fqnbnf5D; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=UfrUam4S; 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="Fqnbnf5D"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="UfrUam4S" Received: from pps.filterd (m0279869.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6984C1N22146766 for ; Thu, 8 Oct 2026 06:12:07 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= s0KchWkDklqgs7rB211yiwG6I+6COkYJkCvle0beTDA=; b=Fqnbnf5DNqxV1Qjr xFJ00qsGb+AHPKJk2tXgx+blgdntm/qaHerXv9ZoOjfh9Bzr/dhUOAPt4fROgDYm BC1KgEWfNEbYYx2UTlpOGutf/+W1GjoA73ESXBPdO6hklKsEDo98TEFidH9mISFw mql3VFK5F+HiuPIlgW21Dn7zh/CtwRXByM0i6uX8tks76YPQ7Ke1I1kj1zTKUsx2 tJ0daANecaMunovsfAfFGuKAStk4BAGqYxQJ9L5KZ2/HOYZxiZvQZ2fQHYns8y8l cGNxOrbtOS5WliWA+5bjdssRnDEdWu+MfdaFhKHj6nL5IgoB6yNlLjc4JfAod8PH q2YHQw== Received: from mail-pj1-f69.google.com (mail-pj1-f69.google.com [209.85.216.69]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4h5xe81bx4-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Thu, 08 Oct 2026 06:12:07 +0000 (GMT) Received: by mail-pj1-f69.google.com with SMTP id 98e67ed59e1d1-3a8041a532eso3849212a91.3 for ; Wed, 07 Oct 2026 23:12:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1791439926; x=1792044726; 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=s0KchWkDklqgs7rB211yiwG6I+6COkYJkCvle0beTDA=; b=UfrUam4SKjNn6DcvqGfOkRn8eHhw5fhCcyvidEO12Aj+WFN76PEMwmrPeTzbciiPj5 X1jED70dPYah+N1Mf/mIFRCTVlr/DdLctTmCC55duYr7D6c3iJ8iegol1cfR35ebfqBl 71CG3kZwNZWIsk+EXU2nwU86zxi/1d1m96zFQRYmvjathizzONoDnHOIcGhWeL3uZ+iQ 7nalk64IQY67/ftLD/A41fEB6X0zHQfW11vXGc32YsjyEMhHtH3bpf/ILYnYpKC1vB+N OQBCLA+Ljed/+Jv3Ch3Zxq+3TADn5DmtxsZ7P1FZbFOf1Fj5y4N5XWud8HaRrrzYrZbH bP3A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20260707; t=1791439926; x=1792044726; 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=s0KchWkDklqgs7rB211yiwG6I+6COkYJkCvle0beTDA=; b=ToQSdan7QDJLzru6XZMmIBgQwmQ60GHMkDSraU0qurOAiQ427htei09pHkCElWBIxW xzlqW6PyGthMNiJk95YBvmX5kXfnwV7Ud/L7H1vjx2h7in6kIKTRF5wQaZcXESpzjRm8 G2GwCyzE48bNWDpZuPDu1ufz5RpV2DXKNTv0JegvTLi3Im9dojMdh0mZLmOpNvqwZSRc yHfSYTYXVcyh+1c7OSNSNg/iRkS4fb/VTFJyZv6g/QR0F7Ov55/XfoDCSlWs4LWVSvPq F377CnTpO5Q+23woKrof1MrvbaoSimG9E+AxVQOongx1oazBf644nTFQOnWqK7AUbXfj BVgg== X-Forwarded-Encrypted: i=1; AKwUvBxvK+z7ckF/f+IycKdYnCcA+HXfZu8lumm75AZj/y6xx/Wb78w5Lifqqrjjf1iJg2RQeCjrAVenyxVV+uIQ@vger.kernel.org X-Gm-Message-State: AFq9FYK8X29b8sZl+DWmdEFkvvizZStAONhHtSrCi9YWqbhoKLWvls77 CoFJlSljC7ZAM06swwDM7jsjl2oa6xpcUAITFn9vmKHUULHikxIWiYjuR2K3HEq6d6kOllWWEkw UbNsEgQsFoileKP+BL1oM1kH/Suti7NVzSxQkuO0FyV3Wycs34CAE7PbR6LnrwJaO+iTK X-Gm-Gg: AYBFou3H4VMeXWdEorVs1T6+5/DjHIxPm834aQub2SxkqVgw+pMuM8DXie3daB0Qamw ECXhBrv4SJYKwuETaRPjtKN46TH7nR+tdrTsVZnSuz7S3gLNJSJujA0J7p8YJ1vknOBVLuG0cFd BXzGd6iPhIkscGvSh0NsrS07YUSj3AhBGQ3uzKCwDwnIRqROMo74YMNh5woQKtSmFNsllw+RLSG WvmUf3XCFVscY+jRqu3hV5Bd4cbiVA5K0vdf2EWdzP2cJpiOBypzUklqFjeSDNPPhGgXSIgenbz WIuPh+qnaVZZTXFwDs0wJht9MpxyRvtIxZ0y1GmkIJjCsc0EcZHoEaDif6yNoif3yQwx0PuLPYx v4Fvv5zeB3JTxGCSv7xRX9Zs9NPg3oGHv X-Received: by 2002:a17:90b:3ec9:b0:3a9:8482:420 with SMTP id 98e67ed59e1d1-3a984821aadmr1865880a91.40.1791439926369; Wed, 07 Oct 2026 23:12:06 -0700 (PDT) X-Received: by 2002:a17:90b:3ec9:b0:3a9:8482:420 with SMTP id 98e67ed59e1d1-3a984821aadmr1865857a91.40.1791439925817; Wed, 07 Oct 2026 23:12:05 -0700 (PDT) Received: from [10.217.219.169] ([202.46.22.19]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-3aafbb29c12sm803186a91.2.2026.10.07.23.12.01 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 07 Oct 2026 23:12:05 -0700 (PDT) Message-ID: <4e3cbe78-7a32-42e8-90be-db5158907cad@oss.qualcomm.com> Date: Thu, 8 Oct 2026 11:41:59 +0530 Precedence: bulk X-Mailing-List: linux-arm-msm@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-Details-Enc: AW1haW4tMjYxMDA4MDAyNCBTYWx0ZWRfX7V/G9RBZQ7BR jIRBAQbxuxuhLPxE3YvTCCwR7Wb/6SIlMG1JowH8KR80oQwPB8hKkc1CYsTFkr2TmNZAGrFXW/o jSo2UDvedVfW3NsDcMCbqQ+I6ePlMJ3xAZfZdbTPkpZULBKDMmDwOJZQv4dqUHbBSUJBDASsMGY w2KtTJpYmWsfmc3Vj0KvUjDAoagwlHde81MECRcvFB0jPC/bOQPBu2QIuxVOg65deE7DP0fgEfE jq/728+qu9SVCm6HOrIPEnQqZPrVUxLv+s+/eAYgtlvKbfxP4rwfsYQ1RAihYKqZFGvo+yNEMYU jMnxlxViiJH7yYbsd78jJuZDpOlo78HTJxG4O3om2axanOZBubB+5wRi9YrrCQxId3sGHCzqeP8 92JPTyooM6Qpktutp0BRvZqWGmJidF0KUyYBX3r+ZseNgll5T1v091QYQ31mHUSqprdJPdA5hwy zLsDUQMO17HiMR0tKCQ== X-Proofpoint-GUID: XMdaxWpk1y6uTIjJbo8EqPw_NzS3epAj X-Proofpoint-ORIG-GUID: XMdaxWpk1y6uTIjJbo8EqPw_NzS3epAj X-Proofpoint-Spam-Info: AW1haW4tMjYxMDA4MDAyNCBTYWx0ZWRfX3j7DALSrcBwR XY4xGYQgXHZzDTdIhaNQRlUYOWEtWbOAfvshf4eIXtUj+N1AzHg/LoJPyRwV0WVqd5cDgzte4Q2 rrsVM/lVxqix9XE5H4mAgaM+dGQAO9w= X-Authority-Analysis: v=2.4 cv=MPT1C8Zl c=1 sm=1 tr=0 ts=6ac73437 cx=c_pps a=vVfyC5vLCtgYJKYeQD43oA==:117 a=fChuTYTh2wq5r3m49p7fHw==:17 a=IkcTkHD0fZMA:10 a=660iZSQnnn4A:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=pIBEpd9KSKheSvzPkZgA:9 a=QEXdDO2ut3YA:10 a=rl5im9kqc5Lf4LNbBjHf: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-10-08_02,2026-10-06_03,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 bulkscore=0 adultscore=0 priorityscore=1501 suspectscore=0 malwarescore=0 phishscore=0 lowpriorityscore=0 clxscore=1015 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2610020000 definitions=main-2610080024 On 7/22/2026 5:52 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. >> >> 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; >> + > I think I asked this question before, but didn't follow up. This attribute > should be tied to the SAHARA channel, not the controller. There is no reason for > it to be available when the channel is gone. > > - Mani Sure. Let me clarify. In this flow, the sahara channel is used during boot and is torn down after the image transfer sequence completes. If the sysfs attribute is tied to the Sahara channel, its removal can occur before userspace has an opportunity to read and save the training data. This is why the attribute is intentionally tied to the MHI controller device. The controller remains available after the Sahara channel is removed, allowing userspace to read: /sys/bus/mhi/devices//ddr_training_data. This attribute remains empty until valid training data is captured and is removed only when the controller device itself is released. Thus, its controller lifetime is required to preserve the captured data across sahara channel teardown.