From nobody Thu Apr 9 16:26:22 2026 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 7683835CBC4 for ; Sat, 7 Mar 2026 11:42:34 +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=1772883757; cv=none; b=mUT5IGnLCsIzBJJ28sjRleU+9wvEVhO/HFqPOcUPJ9Z9rNpsuk8T+u8h2M1Q53iPZEYBV5hGcpYql0St61FeyATZgNgAKpqGXKWd2XZK0wsg0jQVVr28bdYcqjuBXD+yMSfVYpXEGEFZUDFkRDJ/zOV5jOMCn9kulwMZSEO0pNQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883757; c=relaxed/simple; bh=RC4ivP66A8RUn2mgY5duP+YJn6Z5mWCRkIxORYBNQHw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=CIcVSjJvZ3fHCVUkcl1lN+r+9g2LosEWwBXHmbLs6FZeSnYODVBgK0XOZ1MnWr7mf5Ingc2wU3VZSmLtjz5nuM1fYZnMoVf1P6V57f/VJuCORZPwPhZnPBW5JHjNEhwtHl52phdAQwohoU2NlIK1JwkS3Iffz5ODwNoDMbBOhRE= 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=hWGB27ll; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=KgIGLtEY; 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="hWGB27ll"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="KgIGLtEY" 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 6276qw8W1980084 for ; Sat, 7 Mar 2026 11:42:33 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= x1pj+ok54ZPuMkS+PNjBXQIJn7FjoPSNgDGNG77A/LU=; b=hWGB27lloBw/FEY7 X7EQ/4+iRmGn/GWkMXJJkGZLiLCOaaJgDaZMRJN0RYOpZ+mE2U1nrikwHPZBmQ/Q MAnHck7YCQg3HMvgfsCTkiBwywFyMkaijDodxWAWHEBoHkF5BdLL3FKp3O6lU/4I b3lG+MjcjDU9MKixMHZLksg9kD+nEkJtSaq3/YzjNaY30TYte4XM6KlXgWO5A8/u 1smd54gyxHbwSnRNxFJRVsoP8BCIbrhAV8+aFvvFQlHW80suvZVsFSIwcJHk7SCc nVAWYvwJh08ThDiARVyImfSzXNLAr10J/fa/NeuY2Y0+p3SDa3ZZb8em2Uxl17l6 38rtSA== Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4crbkxrrjy-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:33 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ae4e9577ceso284423675ad.1 for ; Sat, 07 Mar 2026 03:42:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883752; x=1773488552; 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=x1pj+ok54ZPuMkS+PNjBXQIJn7FjoPSNgDGNG77A/LU=; b=KgIGLtEYQBMbFpeQCKEW8lfAFW8lkHllhPHi1qaGSIYjvPW/x1hTyOQLb3pU6TAiPY RqeYO/UaKvUqFeACJojcL/rOBpJ48JKwXuhmPikcmKYkBNgKGFlTw3rPokRryplHQiRe BeAeBnyq4taTtUsItJWV/57N1rxxw/W/vwn4Cx+KQhRtL+NWAKYW02EASPXfFZWiyylF cy966fRgj/Qous4j/oBIPV+OYQ3//aU4WsM98R7d7MRs7tk4moZapNGVHXoNBsaxugep ytNINJxn2HL7LMzqBlaVJiEcAZCC7mD3IrWtoiRgkrEFS9cmkXAhvuOWJ2c2GvyJimuW HuKQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883752; x=1773488552; 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=x1pj+ok54ZPuMkS+PNjBXQIJn7FjoPSNgDGNG77A/LU=; b=s14mnbhzIIt7yxf941WimHPNJP751xUtjonDO4YSQeZU9vLZVvzBKo3qZZlyKLIvRg /Y/BDPSlLwLczQsrLvbAzDuedQWbWz1ibwlliCW0/VwpZJFVYNSxgv2XJTb4CHaLv/yc lCXdw7gDtiNVCJDbYaNFdqK2zyjzuO3m5aAFVqZbX8S1DYBQR8BRXbNZAr1R+MrVJh0Y BIl87YVUQV1tiPwGGQEmdlr6Ymdv0dIIMJTsNP8tUZCKWzgzW+WjV3jO7RY1wbtbLrqo Cqr7T2oA18+hg4ow3I85qHAtc8//cF6pEBcEICA5grhRiSbaULAZRK0uyWkfpyUJw34+ WOBg== X-Forwarded-Encrypted: i=1; AJvYcCXqSKn1p9gTdixd7MZN7FKn8Kgn/a11iNmsuxbvK3omuTjs4mg6cBIy4HHL9NjfNavN/eThVu96cJKtZCM=@vger.kernel.org X-Gm-Message-State: AOJu0Yxep0ZHLXeGDnxG9FRLsvdkZu8EmBdPuduIVzI1KTiSFHHwjcGU QdcaAnq8Je4UfJ1CAFdT0TGm87CZaz2sPiEN10X0mxztubCC/7BtN+9oVFoOJB63AR6z63i1y2j x5ElhZ09AZVpsF51GI4BrDDHp7PoqCbW3l5HkNRAtiTnxuvIH+CczIqTK2iPmXXSjpOQ= X-Gm-Gg: ATEYQzw3u/y9PiA0xUOhFk5L223Vao8OTv1tKtEpaisaOGhWP2DySQHACzx2PF5piLp TVvwN1Udof6fPESd10CGGxV2R9t0E+fpRtZ8rrIwc5oBJUo3OajWNFV4R6e3N6Z6RDymlOLMmie muf1l7tIDxmq6xMAFdGtLMEHukYr0EZj8jVn+fmbQRF58MSRVG0ogrPP/cRl/c9365SZfEkrG4U ofv/sq+ziOsy20sEZzlhwG3tJLpT7pags4L+2DBEzZk87EOA9K13e3w1W/MthMQg3wZLHLHexHJ eD7NRylGq3y3ssNCCRabK/JBPNths/y2hMpHGWzO2IDYDikrJUhEyJuBc+7laMG6DsQcfS2npFb zvhAG7Szpt5yYzXAN/ufjIyhIOh/29OhxEIjWGVH3muKPtqPWzmM= X-Received: by 2002:a17:902:e74f:b0:2ae:4ad5:b76a with SMTP id d9443c01a7336-2ae823a246bmr55868075ad.21.1772883752164; Sat, 07 Mar 2026 03:42:32 -0800 (PST) X-Received: by 2002:a17:902:e74f:b0:2ae:4ad5:b76a with SMTP id d9443c01a7336-2ae823a246bmr55867845ad.21.1772883751723; Sat, 07 Mar 2026 03:42:31 -0800 (PST) Received: from hu-batta-hyd.qualcomm.com ([202.46.23.25]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-2ae83f8c713sm47996145ad.66.2026.03.07.03.42.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:31 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:29 +0530 Subject: [PATCH v2 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: <20260307-sahara_protocol_new_v2-v2-8-29dc748b5e9c@oss.qualcomm.com> References: <20260307-sahara_protocol_new_v2-v2-0-29dc748b5e9c@oss.qualcomm.com> In-Reply-To: <20260307-sahara_protocol_new_v2-v2-0-29dc748b5e9c@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=1772883713; l=3311; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=RC4ivP66A8RUn2mgY5duP+YJn6Z5mWCRkIxORYBNQHw=; b=WTCK3v2dWMuJgvV+WvtdUdlEGdN9Q3tZgllxtaV70N5KpZhm5jlgTO4F899UDqqR4f5zYYf9T 1QqtJ9iX5efCi7+fx9C1L6G4XBCBD3USOrXwifUqcHoRjDxe0fTw67n X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOSBTYWx0ZWRfXz+z1JaMsMiIk NSdhdNB53PDRrQKvOnhxLlLq4D54YzSZ9C8A1mhZq553XWheHCtkKTEpzC6z9n8OjASxp4aMkel itIxPmyBHLZSu5qTbqSCQc1/GDIbkLzlMM/brzq3/POTWawmIrnn6sOHF94kwG0TZyXcQ1SfiRR Sqe7TgnBNlv/tjnOWvTyo/sTLTJlq3KDI/rUtOfKyob6NvB8Mh41KoAtLki19chWlG4OI3spN6u 3ISR8IxntCQQjZVTulizMoP1ktaO7J0Du9n33A0w+XOs/y5xuStkknyuh0F85vapBrtxQGNU9he zcFu1aL04u8j4TPEuSOTnJng6uR40Ymv59NgCsE72l5mgN++9MD6YfVwuoConeFD2u/OBICPjJt V+URkSUdsoJchQ8lDIst8W8iKNfVSuia1ARy4K9hIXnJNqvqqS9ZAhOZykJdWtPcO5fezGLgcry qFQIBsymgOxsEQyhbtw== X-Proofpoint-ORIG-GUID: fI7hVXpKOytGkf6nnmCFy578esZoyieH X-Proofpoint-GUID: fI7hVXpKOytGkf6nnmCFy578esZoyieH X-Authority-Analysis: v=2.4 cv=LOprgZW9 c=1 sm=1 tr=0 ts=69ac0f29 cx=c_pps a=IZJwPbhc+fLeJZngyXXI0A==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=3WHJM1ZQz_JShphwDgj5:22 a=EUspDBNiAAAA:8 a=9mPLix8uEUeM4unapbcA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 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-07_04,2026-03-06_02,2025-10-01_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 phishscore=0 bulkscore=0 impostorscore=0 lowpriorityscore=0 suspectscore=0 clxscore=1015 malwarescore=0 adultscore=0 spamscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070109 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 1eea93384724f559f3b6b78cb6a6e9a77cd5de6b..147bbe20c768198851ce78b9ea3= 6867c554867be 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -404,6 +404,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; @@ -1249,6 +1316,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