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 20818425CF7 for ; Wed, 1 Jul 2026 10:38:20 +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=1782902301; cv=none; b=mfCFs9v38Ut7kwVt0WmM9BZ9PY6b8eAwxJfAMZMIA6x3Pzi6FsmKP95toB/LCoqsTm2Te+eAg0rW6wXj4OUqbR8nQheLOKIg6U5aDPY6kQ3tUtPd2ZJwoo+7a2NekRQz5+c1HnJ/mezzD8Df1Xj1/arZvqtUhXYlgLe1aIN2xQs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1782902301; c=relaxed/simple; bh=Jan+rO3lHREsYWShXbf2aFwmvonRIbh7Bu+veXE/AIU=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=YR5XpLDc1lYADdrsycZjc14KkA41x8NyQkmB8eycszx+5RSyhkFovE8HHJXJI1Y1AlHnS6QUSiFe9JmiSwT6KZh5/QJR6GWCbllOET/RMMWkCpncJTqP5ElH3bKEMRE1cTEwmIlaEGBW2gU5+43IjNzCE1F7vP96zRHlmyGU2QA= 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=aEs6ogGG; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=czPhsKRu; 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="aEs6ogGG"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="czPhsKRu" Received: from pps.filterd (m0279867.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 661A8Wfd761663 for ; Wed, 1 Jul 2026 10:38:19 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= Ok+6fNf56WQpIHo1nYgzH/b5G92QcDwfXWueRnDPmYA=; b=aEs6ogGGQDI74RO/ lRblGrlJ+2OeazJFLlUe+c44as9KDJvck6imiu0lQHDBWfm2IQyJosWij8m2Mizo GE9DvpzYy5FdSuPaYc9UaaV6dh9CWfjTJwRkpz4bVhHIqwTleNU3wSvVzmCVGd8l pupHFbqm3H9fGUE9EzjwK160C0hiRWLiuFzGQQ9Rw6ilImQgPfjY6vAfpzzwyPyA fAD531S9z3di9k3RX+keHKw5am3xfo1kf9MRqfMfDDn7/dOkve1mkA2D8omnuVoS hoxA9OH5EI/hbC4nvfbQJjTTK0cUUujvbG4jfjyZ5veoz7Nb+sza9Va9oFdO6Bt1 Dtu9jQ== 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 4f4kgw3kbg-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Wed, 01 Jul 2026 10:38:19 +0000 (GMT) Received: by mail-pj1-f70.google.com with SMTP id 98e67ed59e1d1-37fe5d16d15so858592a91.0 for ; Wed, 01 Jul 2026 03:38:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1782902299; x=1783507099; 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=Ok+6fNf56WQpIHo1nYgzH/b5G92QcDwfXWueRnDPmYA=; b=czPhsKRu4mw1jLz4t4q2lXOoBvZWNRwAWHBWP70HadnTi6r9c28lXM48NqM/ntdXvW Bq30lD1tjkusitIG/0Lay2XHqNjTXQ+ILJD7HM5ZuEVap2Gwmlm859MvRMTj4enbsktR 3osKp3u4bRXsJdIVtgE3ppP9et0AFI/6BUIbuLwS3yHOYQ4Apll6M1y3H9Ky1wCFf7pA gudugqR95dGdCbXeZC7v4cSHTUBjX8VZTaUE434R07P6EW0FKrKcSBOt/kUvhSGO0+an A3/2F95lgbj3RTQn+Q0BsW6BrDPzp8ykUDP9rZ/fhMD02WSyvELE6ZdUNYCkf4mEG+VG vo6g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1782902299; x=1783507099; 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=Ok+6fNf56WQpIHo1nYgzH/b5G92QcDwfXWueRnDPmYA=; b=a1hspVgKZH4brPdOFc077gX9TL0AItR8woc08UstdXRRmT8Dq+Mp8jTH71VTCGhMZK e0DPHu5yKQmyqXHpj+j/2+ieKy7DkGHOCOblaKCZ0xG1mhxyKfED4AQYX+QX4+xTnQu1 YRr7XOhui1YKmlqgak4hwTdTrWPzmkXEpSwMxzOLn5F8nMkEycCOvFUTIJM7o5h3OrPG 1QBCnrjEHmMLR96GGG6p4ohJuQnEHh3czyuP0EEY/YDmoq916IFo+3OGd3HtrPN6KElV TiHMCXxUpD22ei7rvWzxQAups8MkLedEpz3b2m27Kq5D9GbaU8OJShY3VmMKhii3nl7q z/tA== X-Forwarded-Encrypted: i=1; AHgh+RpFbDeNmGQHLPSmiDmiZ4ORYUkBCOiHnXsIt8OHRSghcKnc+fAJoD7wAUuZhLYt+NE5BegAEEfR28VVvOc=@vger.kernel.org X-Gm-Message-State: AOJu0YwnoRZph5wnb4SGTi0X/PoeUhmGbGQhJjnNBKJGgSSYAd9GjNlF OHa/8dsj7b8kIIo11K1yoRdOH6CLNv3x/Fv6/EprkZUAa/seJjglwDL4w0z9t/ZJIeKYEysOr2k jOplI4Ytqn/k9s0Qe8sWg9WZcTq55QG1Pz6Urah0jjL2A8bD7AIlw5+uLiQCEugksmRY= X-Gm-Gg: AfdE7clpl4VGUdkR1nS8NTXkvHK5F/xJeMslQQ09NdLZTCYTN+RlfeArxDKPrXmkHGr W7csaYoWQcJpCxkdch5pPS4yQEamqlHCcOSRfskx55wiT6W8DRtfWMR8F3aBguHdd8oqCcd/I9u PEJHNsuVU4jkmS0okxN7PAUGg3fJMmvM/OMl0ZEyjMdgTy32wnTcp6nDR90qiDsYatnhiOA8Xaa CQ3Agy4xVguYF1will0z/09LNK5jfRf7QPPHaKpZjAeFrfIbO1LkXmYoLtTss5lO337L+dNKXvn zapedqFsCZgidJMwEuiwhBxZhcySY4ZubO/mVEAmG+Mq+gY1l3jnUgEkiqLUXDLyPsyFmaGibDu OBW/pAp9nNQSVk88uQFfZ1kreQyM6hv8EQneC03+5 X-Received: by 2002:a17:90b:17cd:b0:36b:9c4a:e05d with SMTP id 98e67ed59e1d1-380ba9455b4mr221622a91.17.1782902298748; Wed, 01 Jul 2026 03:38:18 -0700 (PDT) X-Received: by 2002:a17:90b:17cd:b0:36b:9c4a:e05d with SMTP id 98e67ed59e1d1-380ba9455b4mr221594a91.17.1782902298250; Wed, 01 Jul 2026 03:38:18 -0700 (PDT) Received: from hu-batta-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id 98e67ed59e1d1-38095bc8a2asm765251a91.0.2026.07.01.03.38.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 01 Jul 2026 03:38:17 -0700 (PDT) From: Kishore Batta Date: Wed, 01 Jul 2026 16:07:41 +0530 Subject: [PATCH v6 7/7] 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: 7bit Message-Id: <20260701-sahara_protocol_new_v2-v6-7-3a78362c4741@oss.qualcomm.com> References: <20260701-sahara_protocol_new_v2-v6-0-3a78362c4741@oss.qualcomm.com> In-Reply-To: <20260701-sahara_protocol_new_v2-v6-0-3a78362c4741@oss.qualcomm.com> To: Jonathan Corbet , Shuah Khan , Jeff Hugo , Carl Vanderlip , Oded Gabbay , Manivannan Sadhasivam 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=1782902263; l=5210; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=Jan+rO3lHREsYWShXbf2aFwmvonRIbh7Bu+veXE/AIU=; b=1aIjX2/TG/4sjfrA0UmBKYhS7juF931y5uK7Gq7FUFa9jfohXouXcnQFh9yaSzTv8NA4fWyk3 +pWLVc+XgmyD6NA7Aks92EyaC86mt609EWMML0n5d2hWDNfOuI52pJL X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=Co2PtH4D c=1 sm=1 tr=0 ts=6a44ee1b cx=c_pps a=0uOsjrqzRL749jD1oC5vDA==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=RAioF0-LDSMA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=6t33SRJ6vQwVIDTtI9kA:9 a=QEXdDO2ut3YA:10 a=mQ_c8vxmzFEMiUWkPHU9:22 X-Proofpoint-ORIG-GUID: h0Y4WaGtcD8NX3tJNpf985hbuLrJr6Aw X-Proofpoint-Spam-Info: AW1haW4tMjYwNzAxMDExMSBTYWx0ZWRfX8YeaONpWVeEa lqtMIIr9h6oa02rYK1XgnbEe6wTvKmatTwFgLgzFIDqyP/ib5fbs8KblNn18xiXa/ZrtvJ39L6V iV37SoXDRew6H06pstxheqVY/5ky1sQ= X-Proofpoint-GUID: h0Y4WaGtcD8NX3tJNpf985hbuLrJr6Aw X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwNzAxMDExMSBTYWx0ZWRfXyRXcn7FgqBdh fKzyEooa6x9o7GXwd06m26JJ4J8uYBnPX4JG5kEJSA98SP9Hrdhy/neOPeeci+Iq9EFr4y/HWcC 80RgIGhUCQFofpm2aSlLIgLpWNx1j3S1rxwsAHtMI7YyCtKE0cIrkmlZ67Xw0KqWgWDcAJfFAcf AiVjqr2pfkBgqaOZXZH/Hd3eYxF009EqVACEmzFIUAhM1L6HMOueDL/BnSYdE73Bap1i2qFkT8G yhld2jrDOUUWy1SngcL9svLib98nA2wl12K2IxlKC4L0PK80nHZhflm9hnvC+1hzWKzFjRWJgvy 37wdQN5e2kCr6qh4sS0u9bafzoqiBK4sULTD4pqaoZc7S6dgQd/nEpSBKoYj0kKNRabbq9ZU8OT 3pwNQIWXMO3SwKXMwBfWQupVTaqbeXIZBIQbOJ9u9xEjH7+wZnX9yJ2tch+4pmg3lwk9cRjo6XZ t42O2jSF5cLgvQk0/Tg== 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-07-01_03,2026-06-26_01,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 clxscore=1015 bulkscore=0 suspectscore=0 phishscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 impostorscore=0 malwarescore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2606150000 definitions=main-2607010111 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; + + 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