From nobody Thu Apr 9 15:03:55 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 64CCC34DCEB for ; Sat, 7 Mar 2026 11:42:05 +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=1772883729; cv=none; b=LsWrYYZ5wXUHQhbe3RChJMC8ZhEqIMvGzLi4TbluTqOg5OzMWcCqX4a2RWKBoVwaNUSSMHerese5d8t+nHnvECOt1FaQY+x1d/fBrOquirZFrFp+8uqmIGWLlZMMUAZxPASlHw71xcIqhzlTMshwCyJDs0/u7tXIO3kAj7wd3hc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883729; c=relaxed/simple; bh=1D00kesAnJ6aiS/h94SYG7huQNLbnZVj76ipx20EKSA=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=IPeCdmgOUJPqEGl7aELRb2DquWdTofIrQ79gbduYaOPz/irkMpDnKOn3grW4ld5n2nPUAw4K7LiQeUBpAQgl1GDAcWn36CHNmBPTANpi5gjJKiMibd5IW0er+oBV2LZEUQ806ExNQAEZ50V0NHLeTEc7n7X9YJgfbVWcntHTSOs= 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=HCbuUvWp; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Spgc5YjO; 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="HCbuUvWp"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Spgc5YjO" 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 6276rcOx2404327 for ; Sat, 7 Mar 2026 11:42:05 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= 2juIOgJkND7DShqV2RiQUTSq3Zx05rOAfNWgAcwjbTU=; b=HCbuUvWphECja8SU A2kDK6WliHtoRZfXWqc/zR0oQBdGVDY4QfQRcJF9yhkzjTsAr4AyQtdFNRDbSYPt erGoty491laljVXwtIspmp9SAlNmr9Vhqe6Ig6i2N60j4tirv7g7RyvAhPa+87AL 4EHmbuNvHZoI8feNKXd58UaUDEEO+bhieAOcAmNxqnXn13CDXL4evGCLL1mNIBL6 qa+T6JJgCeumAeRBU+RAy9c7nMwzf+CKBwMMI5a13pyi+MioLxYxZSyxRoBF/bYP euWCNM4cAkcQaBBGhTP01duXXuT+R5YyP8Xh/L66J4bgqQZp7p2AcOOJuXgM04xH 3RHL1A== 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 4cr9qes1fp-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:04 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ae49120e74so62913885ad.3 for ; Sat, 07 Mar 2026 03:42:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883724; x=1773488524; 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=2juIOgJkND7DShqV2RiQUTSq3Zx05rOAfNWgAcwjbTU=; b=Spgc5YjO1i0IArG2qvbHpjS8+IPsPSCPM6d8v/0zQurZvtdma2E6rGgDF/iE14SIwO fdiZ+xIkxhgm6Dj4GET1CTb5gAuyhP1KGfX3OGJAFkoKusZpuPFMG/pue3iCJkuCrTrl dSketh0SYox/okgcNqB7dTHbrfStb5sRoFrHXvBXidcYhotA4yogULNO4jMqjKXgjLMS nKTrxkHRtTE0q04OlA7s7XuUdjbOx/iMrrSN7kOtPmpCqLbfA1tq8pyJ+ifl2Wo/3R1K GAg1OXlETBjo+g2kLqZC8rx77m1StvAG1LsoKtn+iZVTo/3bhSYod5EdoXmdBRqiKMmA kmnw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883724; x=1773488524; 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=2juIOgJkND7DShqV2RiQUTSq3Zx05rOAfNWgAcwjbTU=; b=dsIM1OQM0acoiiit+gXauVI57vc1LBAMaAqX7wvI1ceQxx/OscIyd4gWhHlFmwIv6Z doHtz1sZ1lYSLo2zPGy6YZaGLrTlfwhqpgBP1YrmsWnoMvbhUGdS1rE4J4UrrEv5vCms FRu+RFCjNMKey7Ayrr3uHNEEpdHeHo5GaRJGfW/p3cwehAC7aUROZUTrjHFwv4jxgAdh Tf/WESG524+wNCimxKAcD7ixFE+afruGD+X7jp5lu5xAE9Nf6xsySOf6EQQbOocWqxdj P4xXTHAKGmBUIYhN4YuCZfiRGNFqFAaT7SZ0D69B8sRCXhrN3hJ7pMYjOQ3qt7Ldb//S qPKw== X-Forwarded-Encrypted: i=1; AJvYcCUz/AfeZ5JpBu/HO3IE/pj3RzW+Vz+OYcvHqXwoEFWuljb0WRUrpPMSDJ1/6+Hfo5i/kZ8nF3rdi4h0+DA=@vger.kernel.org X-Gm-Message-State: AOJu0YxzoTfBZBqv3khOfz9guSy3mVdnSZcgH9mh49eIltSAOW6nstg/ bpMBVIqp+2ArbB23Hrg46DO+PiB0/ARWTBc7s8CNuGtEsOYpi+BUJ9TDBGD799NanFQfFYXNCPI J9czLUGz/B6gt+5Ddfr31KnKjOyVPYFvo/J9IY3cwijRg/iDQvqKlmEL4TaY60v5V5xs= X-Gm-Gg: ATEYQzy4UnpsezKKfNIkj4/KzDjtrU51vztdrPrxBa1yA7rk+DsqjVLPhX5dv6NDymK ypdTKMGg6M8SnTkRsffbDPjun4kFlzUtk/ZSf6pjWiLhXx3firWzEYHdI8IKF3Z110OWPxWVWli ieUfDluazy482nlyXSZH5pCRNzx5h7DWPc3738UpGBVmK8mznkTg8WQ09OFFdqzZzKuFwdKi5eM nG3PS1uBqDO3E4U6TzXCIjAiwMzGnPebZD03VQQh71m7mu3WuNOx1OSa3u6quau0Ehm1dyXUqYD 53wpKwYj0bFAf6Q2MByqgFh56MXQm6VBKgaIL8n2MmA1ITWK5k5pj7lnl54SVJ6tdtzQVMuTjQA eU4VWpnwxr4/WyMty2H5hrpn5quMU6bP8WBPNp7b93Hwk/d7Df+0= X-Received: by 2002:a17:902:c94a:b0:2ae:698d:94a6 with SMTP id d9443c01a7336-2ae8241dd3dmr63851845ad.2.1772883723036; Sat, 07 Mar 2026 03:42:03 -0800 (PST) X-Received: by 2002:a17:902:c94a:b0:2ae:698d:94a6 with SMTP id d9443c01a7336-2ae8241dd3dmr63851565ad.2.1772883721960; Sat, 07 Mar 2026 03:42:01 -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.41.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:01 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:22 +0530 Subject: [PATCH v2 1/9] Add documentation for Sahara protocol. 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-1-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=70694; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=1D00kesAnJ6aiS/h94SYG7huQNLbnZVj76ipx20EKSA=; b=URyimUciCklENLJ+pQubefFO/8T814YeNmTzuI8rnlej/SHAIUIT8CfC5TltM3zWHf5UlGYON tOypjDrWRLZCo3JhmjZJ8gszowYXyAzojWehIkcDeeDS/bdPgnT6u23 X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-ORIG-GUID: rK5M5vEo1v8oLHCxAZY0yJh3xsJJH1Wk X-Proofpoint-GUID: rK5M5vEo1v8oLHCxAZY0yJh3xsJJH1Wk X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOCBTYWx0ZWRfX6IhfOQNTKLHp AaOOzv03GwQ1xFpOroL5A9L5wlcar9Ra4fX1qgqyfYK2iXQLWqC0Etjw7yzcOAEYQjsPJ5WGQds CGbwG2TnA5PnU3T690x56r8WbCqxe4r6l8Zg1H4yEr5a9KS0uTH2AAayZwXQ6rF0qXbsKf39EKw 2OJE0GrRCvhNqEYjHE6476mbOVcHKUYoe0ICKp5V7Nk7z032YHnXEiNIbmfdflLataLI8qXl4Kv 6GDb6860cN9B0NTBBi/ZRm4Imt9W4Lkn4C1CuKtGEY+IsrsBtVwnxG8zn9TbqmhpktWHPBsOUO9 cuydKEUJBWFvFup7ZgZ5tVw0d9HOQ/dOuqU+xnLUDMCzisSiLyU5r7CaDO3eZDEylcgT42CQo1x 7Yt3INhZFLvtn7Asn+T/Na7Mltt7b2NfjiS25wfJ7AefqkoXpPnFB3/xirI3aLMD/ydnXZek2yP 2Dvc+A2Qh5A9D8Y7rkA== X-Authority-Analysis: v=2.4 cv=dcqNHHXe c=1 sm=1 tr=0 ts=69ac0f0c 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=eoimf2acIAo5FJnRuUoq:22 a=EUspDBNiAAAA:8 a=MMUwo3wwYuTaqRZ-dQsA:9 a=t_MdwZQk9VBQcGG5:21 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R: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 suspectscore=0 bulkscore=0 spamscore=0 lowpriorityscore=0 adultscore=0 clxscore=1015 impostorscore=0 malwarescore=0 priorityscore=1501 phishscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070108 Introduce documentation for the Sahara protocol, describing its operational modes and their respective functions. The image transfer mode enables firmware transfer from host to device. The memory debug mode allows extraction of device memory contents to host. The command mode facilitates retrieval of DDR training data from the device and also to restore the training data back to device in subsequent boot of device to save boot time. Signed-off-by: Kishore Batta --- Documentation/sahara/index.rst | 14 + Documentation/sahara/sahara_protocol.rst | 1241 ++++++++++++++++++++++++++= ++++ 2 files changed, 1255 insertions(+) diff --git a/Documentation/sahara/index.rst b/Documentation/sahara/index.rst new file mode 100644 index 0000000000000000000000000000000000000000..073002c15a203344524e258b2aa= 0a6ce839e064b --- /dev/null +++ b/Documentation/sahara/index.rst @@ -0,0 +1,14 @@ +.. SPDX-License-Identifier: GPL-2.0-only + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D +Qualcomm Sahara protocol +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + +The Sahara protocol transfers data to and from memory and describes packet +structures, packet flows, and their usage. + +.. toctree:: + :maxdepth: 2 + :caption: Contents + + sahara_protocol diff --git a/Documentation/sahara/sahara_protocol.rst b/Documentation/sahar= a/sahara_protocol.rst new file mode 100644 index 0000000000000000000000000000000000000000..91204bb7d170be4fc4c85f142b8= f0b93d3c421a0 --- /dev/null +++ b/Documentation/sahara/sahara_protocol.rst @@ -0,0 +1,1241 @@ +.. SPDX-License-Identifier: GPL-2.0-only + + +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D +Sahara protocol Specification +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D + +The Qualcomm Sahara protocol driver is primarily designed for transferring +software images from a host device to a target device using a simplified d= ata +transfer mechanism over a link. However, the sahara protocol does not supp= ort +any authentication/validation of the data sent between devices. Such a mec= hanism +is beyond the scope of the protocol. + +The Sahara protocol defines two types of packets - Command packet and Data +packet. + +Command packet +-------------- + These packets are sent between the host and the target to setup transfer= s of + data packets. The command packets contain a command ID and packet length. + Depending on the command, the packet may contain additional command spec= ific + field. + ++-------------+---------------+----------------+----------------+ +| Command ID | Packet length | Optional field | Optional field | ++-------------+---------------+----------------+----------------+ + +Data packet +----------- + The data packets contain RAW data as shown below. + ++---------------------------------------------------------+ +| RAW Data (arbitrary number of bytes) | ++---------------------------------------------------------+ + +Command packet optional fields +------------------------------ + ++---------+---------------+---------+-------------------------------------= ----+ +| ID val | Field | Sent by | Description = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x0 | - | - | Invalid = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x1 | Hello packet | Target | Initializes connection and protocol = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x2 | Hello response| Host | Acknowledges connection and protocol= | +| | | | sent by target. Also used to set mod= e of| +| | | | operation for target to execute. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x3 | Read data | Target | Reads specified number of bytes from= | +| | | | host for a given image. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x4 | End of image | Target | Indicates host that the single image= tx | +| | transfer | | is complete. Also used to indicate a= | +| | | | target failure during an image trans= fer | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x5 | Done packet | Host | Sends acknowledgment from host that = a | +| | | | single image transfer is complete. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x6 | Done response | Target | Provides the following information t= o | +| | | | host. = | +| | | | 1. Target is exiting protocol = | +| | | | 2. Whether the target expects to = | +| | | | re-enter protocol to transfer anothe= r | +| | | | image. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x7 | Reset packet | Host | Instructs target to perform a reset.= | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x8 | Reset response| Target | Indicates host that target is about = to | +| | | | reset. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x9 | Memory debug | Target | Indicates host that target has enter= ed | +| | packet | | a debug mode where it is ready to = | +| | | | transfer its system memory contents = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xA | Memory read | Host | Reads specified number of bytes from= | +| | packet | | target's system memory, starting fro= m a | +| | | | specified address. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xB | Command ready | Target | Indicates host that target is ready = to | +| | packet | | receive client commands. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xC | Command switch| Host | Indicates target to switch modes. = | +| | mode packet | | 1. Image transfer pending mode. = | +| | | | 2. Image transfer complete mode. = | +| | | | 3. Memory debug mode. = | +| | | | 4. Command mode. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xD | Command | Host | Indicates target to execute a given = | +| | execute packet| | client command. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xE | Command | Target | Indicates host that target has execu= ted | +| | execute | | client command. Also used to indicat= e | +| | response | | status of executed command. = | +| | packet | | = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0xF | Command | Host | Indicates target that host is ready = to | +| | execute | | receive data resulting from executin= g | +| | data | | previous client command. = | +| | packet | | = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x10 | 64 bit Memory | Target | Indicates host that target has enter= ed | +| | debug packet | | a debug mode where it is ready to = | +| | | | transfer its 64 bit system memory = | +| | | | contents. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x11 | 64 bit Memory | Host | Reads specified number of bytes from= | +| | read packet | | target's system memory, starting fro= m a | +| | | | 64 bit specified address. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x12 | 64 bit Read | Target | Reads specified number of bytes from= | +| | data | | host for a given 64 bit image. = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x13 | Reset sahara | Host | Resets Sahara state machine and ente= rs | +| | sate machine | | Sahara entry without target reset = | +| | packet | | = | ++---------+---------------+---------+-------------------------------------= ----+ +| 0x14 | Write data | Target | Writes specified number of bytes to = host| +| | packet | | for a given image = | ++---------+---------------+---------+-------------------------------------= ----+ +| Others | - | - | Invalid = | ++---------+---------------+---------+-------------------------------------= ----+ + + +Hello Packet +------------ + +The hello packet is the first packet that the target sends to the host. If= the +host receives any other packet, it sends a reset command to the target. Wh= en the +host receives a valid hello packet, it first verifies that the protocol ru= nning +on the target is compatible with the protocol running on the host. If the +protocol mismatch, the host sends a reset command to the target. The targe= t uses +the following format while sending a hello packet. + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Version | 4 | Version number of this protocol | ++-----------+-------------+--------------------------------------+ +| Version | 4 | Lowest Compatible version | +| Compatible| | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Maximum command packet length | +| packet | | (in bytes) the protocol supports. | +| length | | | ++-----------+-------------+--------------------------------------+ +| Mode | 4 | Expected mode of target operation | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use. | ++-----------+-------------+--------------------------------------+ + +The target also sends the following information: + 1. Maximum length of the command packet that it supports. The host uses = this + information to avoid sending more bytes than the target can support i= n the + receiving command buffer. + 2. Mode of operation it expects to enter, based on the boot up sequence.= The + supported modes of operation for the target are as follows: + ++-----------------------------+---------+---------------------------------= ---+ +| Mode | Mode ID | Description = | ++-----------------------------+---------+---------------------------------= ---+ +| SAHARA_MODE_IMAGE_TX_PENDING| 0x0 | Image transfer is in the pending= | +| | | mode. Transfer image from the ho= st.| +| | | After completion, the host shoul= d | +| | | expect another image transfer = | +| | | request. = | ++-----------------------------+---------+---------------------------------= ---+ +|SAHARA_MODE_IMAGE_TX_COMPLETE| 0x1 | Image transfer is in the complet= e | +| | | mode. Transfer image from the ho= st.| +| | | After completion, the host shoul= d | +| | | not expect another image transfe= r | +| | | request. = | ++-----------------------------+---------+---------------------------------= ---+ +| SAHARA_MODE_MEMORY_DBEUG | 0x2 | Memory debug mode. The host shou= ld | +| | | prepare to receive a memory dump= | +| | | from the target. = | ++-----------------------------+---------+---------------------------------= ---+ +| SAHARA_MODE_COMMAND | 0x3 | Command mode. The host executes = | +| | | operations on the target by send= ing| +| | | the appropriate client command t= o | +| | | the sahara client running on the= | +| | | target. The Sahar client interpr= ets| +| | | the client command and the respo= nse| +| | | is sent after execution of the = | +| | | given command. = | ++-----------------------------+---------+---------------------------------= ---+ + +Hello response packet +--------------------- + +After the host validates the protocol running on the target, it sends a re= sponse +to the target. The response contains the following information. +1. The protocol version that is running. +2. The minimum protocol version that it supports. +3. The mode of operation. + +The host sets the packet status field to success if no errors occur on the= host +side. After the target receives this packet, it can proceed with data tran= sfer +requests or memory debug. The host uses the following format while sending= a +hello response packet. + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet (in bytes) | ++-----------+-------------+--------------------------------------+ +| Version | 4 | Version number of this protocol | ++-----------+-------------+--------------------------------------+ +| Compatible| 4 | Lowest Compatible version | ++-----------+-------------+--------------------------------------+ +| Status | 4 | Success or error code | ++-----------+-------------+--------------------------------------+ +| Mode | 4 | Mode of operation for target to | +| | | execute | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ +| Reserved | 4 | Reserved for future use | ++-----------+-------------+--------------------------------------+ + + +Read data packet / 64 bit read data packet +------------------------------------------ + +The read data packet serves as a generic data transfer packet when any ima= ge +data is to be transferred from the host to the target. This packet allows +flexibility in the way that the image is transferred from the host to the +target. As the target controls which data gets transferred, the target can +determine what parts of the image get transferred and in what order. The h= ost +need not be familiar about the structure of the image. It must open the fi= le and +start transferring the data to the target based on the parameters specifie= d in +the packet. + +This gives the target complete control over how the images are transferred= and +processed. To initiate an image transfer, the target fills the read data p= acket +with the image ID corresponding to the image that it wants to receive. The +target also sends the offset into the image file and the length of the dat= a(in +bytes) it wants to read from the image. After the host receives this packe= t, the +host responds with a data packet, which contains image data with the length +specified in the read data packet. The host uses the following format while +transferring the read data packet and 64-bit read data packet. + + +Read data packet format +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Image ID | 4 | ID of the image to be transferred. | ++-----------+-------------+--------------------------------------+ +| Data | 4 | Offset into the image file to start | +| offset | | transferring data. | ++-----------+-------------+--------------------------------------+ +| Data | 4 | Number of bytes target wants to | +| Length | | transfer from the image. | ++-----------+-------------+--------------------------------------+ + + +64-bit read data packet format +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Image ID | 8 | ID of the image to be transferred. | ++-----------+-------------+--------------------------------------+ +| Data | 8 | Offset into the image file to start | +| offset | | transferring data. | ++-----------+-------------+--------------------------------------+ +| Data | 8 | Number of bytes target wants to | +| Length | | transfer from the image. | ++-----------+-------------+--------------------------------------+ + +If any of the preceding fields are invalid, or if any other error occurs o= n the +host, the host sends a data packet with length that does not match with wh= at the +target was expecting. The resulting error forces the target to send an end= of +image transfer packet with an error code in the status field and enables b= oth +the target and the host to enter an error handling state. + +End of Image transfer packet +---------------------------- + +If an image transfer is successfully completed, the target sends the host = an end +of image transfer packet with a success status. The target then waits for = the +host to send a done packet. If any error occurs during the transfer or +processing of the image data, the status is set to the corresponding error= code, +and the target waits for a different command packet. + +The host uses the following format while transferring end of image transfer +packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Image ID | 4 | ID of the image that was being | +| | | transferred. | ++-----------+-------------+--------------------------------------+ +| Status | 4 | Success or error code | ++-----------+-------------+--------------------------------------+ + +Done packet +----------- + +If the host receives an end of image transfer packet with a success status= , the +host sends a done packet to indicate the target that it can exit the proto= col +and continue execution of code. The host uses the following format while s= ending +the done packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ + +To transfer another image from the host, the target must re-initiate the +protocol by starting with another hello packet. + +Done Response packet +-------------------- + +If the target receives a done packet, it responds with a done response pac= ket +containing the image transfer status. The target uses the following format= while +sending the done response packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Image Tx | 4 | Indicates whether target is | +| Status | | expecting to receive another image | +| | | or not. | ++-----------+-------------+--------------------------------------+ + +If all the images are transferred, the target sends a complete status to e= nable +the host to exit the protocol. If all the images are not transferred, the = target +sends a pending status and waits for another hello packet to arrive. + +Reset Packet +------------ + +The host sends a reset packet to reset the target. The target services a r= eset +request only if its in a state where reset requests are valid. If the targ= et +receives an invalid reset request, the target sends an error in an end of = image +transfer packet. The format of reset packet is as follows: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ + + +Reset response packet +--------------------- + +If the target receives a valid reset request, it sends a reset response pa= cket +just before it resets. The purpose of this response is to acknowledge the = host +that the target received the reset request. The format of reset response p= acket +is as follows: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ + + +Memory debug packet +------------------- + +The target initiates a memory dump by sending the host a memory debug pack= et. +This packet contains the address and length of the memory debug table. The +memory debug table is a listing of memory locations that can be accessed a= nd +dumped to the host. The target uses the following format while sending the +memory debug packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Memory | 4 | Target sets this field to the address| +| table | | in memory that stores the memory | +| Address | | debug table. | ++-----------+-------------+--------------------------------------+ +| Memory | 4 | Length in bytes of memory debug | +| table | | table. | +| Length | | | ++-----------+-------------+--------------------------------------+ + +Given the memory table address and length, the host issues a memory read to +retrieve the table. After the host receives the memory table information, = it can +decode each entry and issue memory read requests to dump each memory locat= ion. + +Memory read packet / 64-bit memory read packet +---------------------------------------------- + +The host issues memory read commands for each section of memory that it du= mps. +The host uses the following format while sending the memory read packet an= d 64 +bit memory read packet: + +Memory read packet format +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Memory | 4 | Memory location to read. | +| Address | | | ++-----------+-------------+--------------------------------------+ +| Memory | 4 | Length in bytes of memory to read | +| Length | | | ++-----------+-------------+--------------------------------------+ + +64 bit memory read packet format +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Memory | 8 | Memory location to read. | +| Address | | | ++-----------+-------------+--------------------------------------+ +| Memory | 8 | Length in bytes of memory to read | +| Length | | | ++-----------+-------------+--------------------------------------+ + +The accessible regions are defined in the memory debug table. For each mem= ory +read command received, the target verifies that the specified memory(addre= ss and +length) is accessible and responds with a raw data packet. The content and +length of the raw data packet is the memory dump starting from the memory +address and length specified in the memory read packet. The memory debug t= able +can also be read using a memory read command by setting the address and le= ngth +to the values specified in the memory debug packet. + +If any error occurs on the target, an end of image transfer packet is sent= with +the corresponding error code and the host recognizes whether it is actual = memory +data or an end of image transfer packet. The host issues a reset command on +completion of a successful memory dump. However, the protocol does not for= ce +this implementation. + +Command ready packet +-------------------- + +The target sends this packet to the host to indicate that the target is re= ady to +execute client commands. The target uses the following format while sendin= g the +command ready packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ + + +Command switch mode packet +-------------------------- + +The host sends the command switch mode packet to the target so that the ta= rget +can switch to another mode. The host uses the following format while sendi= ng the +command switch mode packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Mode | 4 | Mode of operation for target | +| | | to execute. | ++-----------+-------------+--------------------------------------+ + +Command execute packet +---------------------- + +The host sends this packet to execute the given client command on the targ= et. If +the client command successfully executes, the target sends a command execu= te +response packet. If an error occurs, the target sends an end of image tran= sfer +packet with the corresponding error code. The host uses the following form= at +while sending command execute packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Client | 4 | Client Command to be executed. | +| Command | | | ++-----------+-------------+--------------------------------------+ + + +Client commands +=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D + ++------------+-------------+--------------------------------------+ +| Client ID | Length | Description | ++------------+-------------+--------------------------------------+ +| 0x8 | 4 | Get Command ID list. | ++------------+-------------+--------------------------------------+ +| 0x9 | 4 | Get DDR training data. | ++------------+-------------+--------------------------------------+ + +Command execute Response packet +------------------------------- + +The target sends this packet if it successfully executes the client comman= d. The +target uses the following format while sending the command execute response +packet. + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Client | 4 | Client Command to be executed. | +| Command | | | ++-----------+-------------+--------------------------------------+ +| Response | 4 | Number of bytes for response data. | +| Length | | | ++-----------+-------------+--------------------------------------+ + +Command execute data packet +--------------------------- + +The host sends this packet if the response length received in the command +execute response packet is greater than 0. The host uses the following for= mat +while sending command execute data packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Client | 4 | Client Command executed. | +| Command | | | ++-----------+-------------+--------------------------------------+ + +The packet indicates the target to send the response data in a raw data pa= cket. +The target sends the response data upon receiving this packet. + +64-bit memory debug packet +-------------------------- + +The target sends this packet to the host to initiate a memory dump. The pa= cket +contains 64-bit address and length of the memory table. The target uses the +following format while sending 64-bit memory debug packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Memory | 8 | Target sets this field to the 64-bit | +| table | | address in memory that stores the | +| Address | | memory debug table. | ++-----------+-------------+--------------------------------------+ +| Memory | 8 | Length in bytes of memory debug | +| table | | table. | +| Length | | | ++-----------+-------------+--------------------------------------+ + +Reset Sahara state machine packet +--------------------------------- + +The host sends a reset sahara state machine packet whenever it wants to re= set +Sahara state machine. When the target receives a reset sahara state machine +request, it reinitializes sahara protocol and sends the hello packet to the +host. The sahara protocol is restarted without a target reset. The host us= es the +following format while sending the reset sahara state machine packet: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ + +Write data packet +----------------- + +Write data packet serves as a generic data transfer packet when any data is +transferred from the target to the host. This packet allows flexible data +transfer from the target to the host. + +As the target controls what data gets transferred, target can determine wh= at +parts of the data get transferred and in what order. The host does not nee= d to +know anything about the structure of the data. It only needs to open the f= ile +and start accepting the data to the host based on the parameters specified= in +the packet. + +To initiate a write data transfer, the target fills the write data packet = with +the image ID corresponding to the image data that it wants to send. The ta= rget +also sends the offset into the output file and the length of the data(in b= ytes) +it wants to write from the target. As soon as the host receives the packet= , the +host opens an output file and waits to receive the data packets. After the +packet is received, the content from the data pcket is written to the outp= ut +file, The format of the write data packet is as follows: + ++-----------+-------------+--------------------------------------+ +| Field | Length | Description | +| | (bytes) | | ++-----------+-------------+--------------------------------------+ +| Command | 4 | Command identifier code | ++-----------+-------------+--------------------------------------+ +| Length | 4 | Length of the packet(in bytes) | ++-----------+-------------+--------------------------------------+ +| Data | 8 | Offset into the image file to start | +| offset | | writing the data to host. | ++-----------+-------------+--------------------------------------+ +| Image ID | 4 | ID of the image to be transferred. | ++-----------+-------------+--------------------------------------+ +| Data | 4 | Number of bytes target wants to | +| Length | | transfer the data to the host. | ++-----------+-------------+--------------------------------------+ + + +Command packet flow between host and target +------------------------------------------- + +Packet flow is a process of exchange of information as packets between the= host +and the target in a specific way using command packets. The sahara protocol +allows packet processing for the following scenarios: + +1. Transferring an image from the host to the target. +2. Dumping memory from the target to the host. +3. Loading DDR calibration data on flashless target. + +Packet flow for Image transfer +------------------------------ + +The packet flow is performed between the host and target for a successful = image +transfer. + +.. code-block:: text + + Host Target + | HELLO | + | (mode =3D image transfer) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D image transfer) | + |-------------------------->| + | | + | READ_DATA | + | (img ID, 0, offset, | + | size of image header) | + |<--------------------------| + | | + | RAW_DATA | + | (size of image header) | + |-------------------------->| + | | + | READ_DATA | + | (img ID, segment 0 offset,| + | size of segment 0) | + |<--------------------------| + | RAW_DATA | + | (size of segment 0) | + |-------------------------->| + | | + | READ_DATA | + | (img ID, segment 1 offset,| + | size of segment 1) | + |<--------------------------| + | | + | | + | RAW_DATA | + | (size of segment 1) | + |-------------------------->| + | ... | + | ... | + | ... | + | ... | + | | + | | + | READ_DATA | + | (img ID, segment N offset,| + | size of segment N) | + |<--------------------------| + | | + | | + | | + | RAW_DATA | + | (size of segment N) | + |-------------------------->| + | | + | | + | END_IMAGE_TX | + |<--------------------------| + | | + | | + | DONE | + |-------------------------->| + | | + | | + | DONE_RESP | + |<--------------------------| + | | + +The packet flow sequence for image transfer is as follows: + +1. A hello packet is sent from the target to the host to initiate the prot= ocol + with the mode set to either image transfer pending or image transfer + complete (depending on the target's boot sequence). + +2. The host sends a hello response packet with a success status and sets t= he + mode to the mode received in the hello packet. After it receives the he= llo + packet and validates the protocol version running on the target. + +3. After the target receives the hello response, the target initiates the + image transfer request by sending read data packets. Each read data pac= ket + specifies the image that the target wishes to receive and what part of = the + image is to be transferred. + +4. During normal operation, the target first requests image header informa= tion. + + a. The image header information specifies image size and location of the + image data that is to be transferred. + + b. The image header information (which is sent as a read data request) + allows the target to know the format of the image to be transferred. + The protocol does not require the host to know anything about the + image formats and allows the host to read and transfer data from the + image as requested by the target. + + c. If the image is a standalone binary image without any data segmentat= ion + (which means the data is entirely contiguous when stored as well as + transferred to the target system memory), then the target requests f= or + entire image data to be sent in one transfer. + + d. If the image data is segmented and requires scattering of the data + segments to noncontiguous system memory locations, the target issues + multiple read data requests to enable each data segment to be + transferred directly to the respective destination address. This + scattered information resides in the image header and is parsed by t= he + target before issuing the read data requests. + +5. After receiving a read data request, the host parses the image ID, data + offset, and data length to transfer data from the corresponding image f= ile. + The host sends the requested data without any packet header. + +6. The target directly transfers the data to the destination address witho= ut + any software processing or temporarily buffering of the data in system + memory by transferring the image header to the targert and setting the + receive buffer for the data as the destination address in system memory. + +7. After the target successfully receives all segments for an image, the + target sends an end of image transfer packet with the image ID of the + corresponding image, and a success status. The host stops reading and + closes the image file after receiving the success status. + +8. The host sends a done packet to allow the target to exit the protocol a= fter + it receives a successgul end of image transfer packet. + +9. After the target receives the done packet, the target sends a done resp= onse + packet to the host. This packet indicates if the target expects another + image to be transferred and if the host can continue to run the protoco= l. + +Packet flow for memory debug +---------------------------- + +The packet flow is performed between the host and the target for the succe= ssful +memory debug. + +.. code-block:: text + + Host Target + | HELLO | + | (mode =3D memory debug) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D memory debug) | + |-------------------------->| + | | + | MEMORY_DEBUG | + | (location of mem table, | + | size of memory table) | + |<--------------------------| + | | + | MEMORY_READ | + | (Address from region 0 ,| + | size of region 0) | + |-------------------------->| + | RAW_DATA | + | (size of region 0) | + |<--------------------------| + | | + | MEMORY_READ | + | (Address from region 1 ,| + | size of region 1) | + |-------------------------->| + | RAW_DATA | + | (size of region 1) | + |<--------------------------| + | MEMORY_READ | + | (Address from region 2 ,| + | size of region 0) | + |-------------------------->| + | RAW_DATA | + | (size of region 2) | + |<--------------------------| + | ... | + | ... | + | ... | + | ... | + | | + | MEMORY_READ | + | (Address from region N ,| + | size of region N) | + |-------------------------->| + | RAW_DATA | + | (size of region N) | + |<--------------------------| + | | + | RESET | + |-------------------------->| + | | + | | + | RESET_RESP | + |<--------------------------| + | | + +The packet flow sequence for image transfer is as follows: + +1. A hello packet is sent from the target to the host to initiate the prot= ocol + with mode set to memory debug. + +2. The host sends a hello response packet with a success status and sets t= he + mode to memory debug after it receives the hello packet and validates t= he + protocol version running on the target. + +3. After the target receives the hello response, the target initiates the + memory dump by sending a memory debug packet with the location and size= of + the memory debug table. The memory debug table specifies accessible mem= ory + regions. + +4. The host then initiates a memory read packet to read the memory debug + table and receives the table in a raw data packet after it receives the + memory debug packet. + +5. The host then decodes the table and issues memory reads for each access= ible + region. The data for each region is sent in a raw data packet. + +6. Upon completion, the host issues a reset to the target. The target send= s a + reset response and resets the target. + +7. The host can alternatively send a command switch mode packet to allow t= he + target to switch modes and avoid a reset. + + +Packet flow to load DDR calibration data on target +-------------------------------------------------- + +The packet flow is performed between the host and the target to load DDR +calibration data on flashless target. This packet flow is initiated when t= he +device boots up for the first time and needs DDR calibration. This packet = flow +is also initiated in other scenarios, such as build update or any reason f= or +which DDR calibration data gets corrupted. + +First boot scenario or invalid calibration data in filesystem. +-------------------------------------------------------------- + +.. code-block:: text + + Host Target + | HELLO | + | (mode =3D image transfer) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D image transfer) | + |-------------------------->| + | | + | READ_DATA | + | (img ID:34, 0, offset, | + | size of DDR training data)| + |<--------------------------| + | | + | RAW_DATA | + |(size of DDR training data)| + |-------------------------->| + | | + | | + | END_IMAGE_TX | + |<--------------------------| + | | + | | + | DONE | + |-------------------------->| + | | + | | + | DONE_RESP | + | (mode =3D IMAGE_TX_PENDING) | + |<--------------------------| + |1. First boot scenario. | + | DDR driver performs | + | calibration and returns | + | to SBL. | + |2. Next: Push DDR | + | Calibration data to host | + | | + | | + | HELLO | + | (mode =3D COMMAND mode) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D COMMAND mode ) | + |-------------------------->| + | | + | CMD_READY | + |<--------------------------| + | | + | CMD_EXEC | + |(cmd id =3D 8, Get command | + | ID to be executed) | + |-------------------------->| + | | + | CMD_EXEC_RESP | + |(cmd id: 8, resp len =3D 4) | + |<--------------------------| + | | + | CMD_EXEC_GET_DATA | + | (ID =3D 0x8) | + |-------------------------->| + | | + | RAW_DATA | + | (0x00000009) | + |<--------------------------| + | | + | CMD_EXEC | + | (cmd id: 9, resp len > 0) | + |-------------------------->| + | | + | | + | CMD_EXEC_RESP | + |(cmd id: 9, resp len > 0) | + |<--------------------------| + | | + | CMD_EXEC_GET_DATA | + | (ID =3D 0x9) | + |-------------------------->| + | | + | RAW_DATA | + | (valid training data) | + |<--------------------------| + | | + |3. Host sends switch to | + |image tx mode to continue | + |booting. | + | | + | | + | CMD_SWITCH_MODE | + | (mode =3D IMAGE_TX_PENDING) | + |-------------------------->| + | | + | | + | HELLO | + | (mode =3D IMAGE_TX_PENDING) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D IMAGE_TX_PENDING) | + |-------------------------->| + | | + |4. Boot/Load rest of the | + | images.... | + | | + | END_IMAGE_TX | + |<--------------------------| + | | + | | + | DONE | + |-------------------------->| + | | + | | + | DONE_RESP | + |(mode =3D IMAGE_TX_COMPLETE) | + |<--------------------------| + | | + +The packet flow sequence is as follows : + +1. The target sends the hello packet to the host to initiate the protocol + with the mode set to image transfer pending. + +2. The host sends a hello response packet with a success status and sets t= he + mode to image transfer pending after it receives the hello packet and + validates the protocol version running on the target. + +3. After the target receives the hello response, it initiates the data + transfer by requesting the size of DDR training/calibration data. + +4. The host sends back the DDR training/calibration data to the target. + +5. The target decodes the training data and does not find valid DDR + calibration data, target sends END_IMAGE_TX to interrupt the transfer. + +6. The host sends DONE after receives END_IMAGE_TX. + +7. The target sends DONE_RESP with mode =3D IMAGE_TX_PENDING because it has + not received all images. + +8. The target executes DDR training process to generate valid DDR calibrat= ion + data and prepares to push back to host. + +9. The target initiates protocol by sending a hello packet with COMMAND_MO= DE + to the host. + +10. The host sends a hello response packet with a success status and sets = the + mode to COMMAND_MODE. + +11. The target sends CMD_READY to the host. + +12. The host receives CMD_READY and starts to get command IDs to be execut= ed. + +13. The target sends CMD_ID =3D 9 to push DDR calibration data to host. + +14. The host executes CMD_ID =3D 9 to get DDR calibration data from the ta= rget. + +15. The target sends RAW_DATA with the payload which contains DDR calibrat= ion + data to host. + +16. The host saves training data in the kernel buffer and exposes to users= pace + via the sysfs entry. The host sends CMD_SWITCH_MODE with the mode set = to + IMAGE_TX_PENDING to continue booting. + +17. After the target receives the CMD_SWITCH_MODE command, it sends HELLO = to + the host with the mode set to IMAGE_TX_PENDING. The target and the host + repeat the packet flow for image transfer to get all booting-required + images. + +18. Upon successful transfer of all images, the target sends an END_IMAGE_= TX + packet with a success status to the host. + +19. The host sends DONE after it receives END_IMAGE_TX. + +20. The target sends DONE_RESP with the mode set to IMAGE_TX_COMPLETE beca= use + it has received all images. The process has been completed after the h= ost + receives DONE_RESP with the mode set to IMAGE_TX_COMPLETE. + +Subsequent boot scenario with valid DDR calibration data +-------------------------------------------------------- + +The below firgure shows the subsequent boot scenario with valid DDR calibr= ation +data process being loaded from host to target. + +.. code-block:: text + + Host Target + | HELLO | + | (mode =3D image transfer) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D image transfer) | + |-------------------------->| + | | + | READ_DATA | + | (img ID:34, 0, offset, | + | size of DDR training data)| + |<--------------------------| + | | + | RAW_DATA | + |(size of DDR training data)| + |-------------------------->| + | | + | | + | END_IMAGE_TX | + |<--------------------------| + | | + | | + | DONE | + |-------------------------->| + | | + | | + | DONE_RESP | + | (mode =3D IMAGE_TX_PENDING) | + |<--------------------------| + | | + | Subsequent boot scenario | + | (valid calibration data) | + | DDR driver configures DDR | + | using valid calibration | + | data | + | | + | | + | HELLO | + | (mode =3D IMAGE_TX_PENDING) | + |<--------------------------| + | | + | HELLO RESP | + | (mode =3D IMAGE_TX_PENDING) | + |-------------------------->| + | | + | Boot/Load rest of the | + | images.... | + | | + | END_IMAGE_TX | + |<--------------------------| + | | + | | + | DONE | + |-------------------------->| + | | + | | + | DONE_RESP | + |(mode =3D IMAGE_TX_COMPLETE) | + |<--------------------------| + | | + +The packet flow is as follows : + +1. The target sends the hello packet to the host to initiate the protocol + with the mode set to image transfer pending. + +2. The host sends a hello response packet with a success status and sets t= he + mode to image transfer pending after it receives the hello packet and + validates the protocol version running on the target. + +3. After the target receives the hello response, it initiates the images + transfer by requesting the training/calibration data from the host. + +4. The host sends back the DDR training/calibration data to the target. + +5. The target decodes the DDR training/calibration data and finds valid DDR + calibration data. + +6. The host sends RAW_DATA with the size of the DDR calibration data to the + target. + +7. Upon successful transfer of DDR calibration data, the target sends an + END_IMAGE_TX packet with a success status. + +8. The host sends DONE after it receives END_IMAGE_TX. + +9. The target sends DONE_RESP with mode =3D IMAGE_TX_PENDING because it ha= s not + received all images. + +10. The target continues booting with valid DDR calibration data. + +11. The target and the host repeat the packet flow for image transfer to g= et + all booting-required images. + +12. After successful transfer of all images, the target sends an END_IMAGE= _TX + packet with a success status to the host. + +13. The host sends DONE after it receives END_IMAGE_TX. + +14. The target sends DONE_RESP with the mode set to IMAGE_TX_COMPLETE beca= use + it has received all images. The process has been completed after the h= ost + receives DONE_RESP with the mode set to IMAGE_TX_COMPLETE. --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 9C013346A08 for ; Sat, 7 Mar 2026 11:42:08 +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=1772883730; cv=none; b=nYKeIuk44a2LBbqQwzKO1ADCUkT4vG9UZ5y1jW5qLXrrjLQEU7230TEEfrrv4NWQN+Sjc9u+vbGpozvKzy1o9UUgHXIeEiNz2dSgQTdYaNOsQIo7sEsDfDejcpsZ9PilvZGPUN/tDulxbn5TXQD9iJhR4RxreoMxUEV0wZPGc+4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883730; c=relaxed/simple; bh=9tH2JRuQd/Ntg0H7RVSyFLnl0a6EFmaIQsmT7afSET0=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=uNl8jWXXpKZscVdxWdpsa+yEVK2BOo2uv/rqzXRLsfidHebmHd06i9iN0ZuQI3p61cai9dikslJJhHjzFmIVpxkfZqYAQI0G5aYNm9XyBV2nw8vhDwibyL5a4F7lh9uCOLiIej3vJJlbCt6Vxs9cL7f+n5nzf0b9c9EsfqPUCdI= 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=gNk12wwE; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=JxxxvXy3; 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="gNk12wwE"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="JxxxvXy3" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6276rKTm2491046 for ; Sat, 7 Mar 2026 11:42:08 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= pD2aEY9dZogWGWfrJ0ewLTBoCN0zxUacyNzSIWJJ810=; b=gNk12wwEvqGjV6Bw E1UxjUwzpZv5/BpXbGl7Xt6p2L2DrPdJ5Hk4W5/6KkdMcCwlPh+PzuxUmOaoEP+g 3BZEc71w0oH2RF1PHha+FsMsTNZAmy0L1GRzUOHW5D7w56kX5kQl3tRkei4l8nkn x/NCpW0+UcDnQbzwr+nOtY2kivDFwR0XNdqieGkQLNrgQHB3TLkV+QNuZwWgpSJM RP4b25Y13X4pnTMcCeEoPTD54/tsT+8GRbtegH6GvqILF27VBmUd8BOSocZrG9+l pAjZ6wnKFbjZFaOQVPBjqtvQMzIGkkEuknY/i6yf+mmOf2ppFtCEUKaG5KdO5k+n RUWHTQ== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4crc838ppb-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:07 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ae3f446ccfso69228105ad.2 for ; Sat, 07 Mar 2026 03:42:07 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883727; x=1773488527; 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=pD2aEY9dZogWGWfrJ0ewLTBoCN0zxUacyNzSIWJJ810=; b=JxxxvXy3cRtUthXAjZJB9d2QSB+ofK/IQuhdTUIvd9KfOX67sJANtKElDCnFUgnJmr +I0cOmXgJJMQ9MptmClRk+J95st/nwGmJb5FYWDO7LItAOEnh59AOrIjItsm1TFnQz1Q beyI6m01HuW6fBF9wICmhvR+EjrOWWW/5Jp4Gq4ytzpr2cwhfMaj7c5D6NDNFafyNTsn XOAJGro9Ryuc5KTjMRxFGJzhuvQ9UHZBY/ELYL5Q0rsmj1CvPPrGutR0GLKbnSU1zKyW 31ypw7CN1Z/MEbdtRjkV1mWvKT8ofufKnzDXAxdjJooyVWWjatnvEogOCQbxY18ozp1l o4JA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883727; x=1773488527; 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=pD2aEY9dZogWGWfrJ0ewLTBoCN0zxUacyNzSIWJJ810=; b=e+GlBTdLOPlpl95GCkWh1zuWZ+UmGfXKCoHLLnvkiayy+vy2TbABaRmFpOxXRz//lo 04WZtceV4bEu6I1HOlYNilsczhKvA02gUlsAKSFT0WHY2FnwCi2k3wfilEsXShmZPQc/ nm8wPKU/R8pS7kWekAt4dOz325q/NwDym14Lkl4ICf/EHS2wOubn6sy91ImvKnL4TE6O CEdkOFxyg3eZSK1Dz1/+T6RKtpM64mUYny3Ata5oDCugS9GsJusWdYWX0rkK8sQjlquX Cjz4o3zhMLjOVaH3k6t5U9aLIHs9XR4P3OhP/leCSrIt3DL3BC4e39dwTQeabTiI24kh eYgg== X-Forwarded-Encrypted: i=1; AJvYcCUhhBJDB7rlJCmFCMg4gtWEFKYS9FS6fYGmQdRXw8NJZvYeEwYB2+RG2TQXqj36045lF5eJSV+PyaNxoVA=@vger.kernel.org X-Gm-Message-State: AOJu0YxZCEAzWlLVIbcW0MWTck0Uo98MMyyjQRR6TOo7WFqYqvmydpLj d/mCUzry58jlUw0UcNrWrnu2B4x9YNyfNakyvKTUlyPPad6lwDl1qqbrrFG1RUmQ6JtC1zzGLP7 0j0xzZbkqMEuspN+NoUGMew0I002PMmw0NZwAzHNgHipxG4+mEqIT0qn7XCF8uXg08eQ= X-Gm-Gg: ATEYQzy88zduqQ3mW4/wtVQereewMXzXggjQ+bKrJggeix5ImZcvxkLKPl4zixxFQ2S qKn5HMARX+mk/PXbtmeqzUeIntOAWVidwwC0JPr4l2/jjehThDSaAQmSuBDreSkjsFkIOWbZpQM vZyQkN1otmp5jiN4MpN9PZkhUcV5xIVx3/M5bvlB/G4/bWjZhBuRUf8eF+JQGM1wRFUL72P5EID 4e+GoJmRChVMAIx8ArRjEaEUTUbaAO9T4IqBkYTgg8acDsAUfQZIaulUA+wee+xeHGlyTRLnpG3 qsGqplChOi143d2GWd2xLvWYpUcY3IQzZylDo+Dgto+hbWN2usZWoXWow3syFM5QckCM38Gn6V9 cteaUQCqDXwas+DeyC3VVqP5MC4oXxdEQWGB94oQfndgdbouxtoc= X-Received: by 2002:a17:903:f87:b0:2ae:44f4:1678 with SMTP id d9443c01a7336-2ae824b83e7mr49683795ad.57.1772883726704; Sat, 07 Mar 2026 03:42:06 -0800 (PST) X-Received: by 2002:a17:903:f87:b0:2ae:44f4:1678 with SMTP id d9443c01a7336-2ae824b83e7mr49683535ad.57.1772883726214; Sat, 07 Mar 2026 03:42:06 -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.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:05 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:23 +0530 Subject: [PATCH v2 2/9] bus: mhi: Move sahara protocol driver under drivers/bus/mhi 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-2-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=7115; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=9tH2JRuQd/Ntg0H7RVSyFLnl0a6EFmaIQsmT7afSET0=; b=Bo19H5v5jiStPSIXraymY3yh7iYxzNy7Xdt66+3ME/Uk7tUYGKYT26DGqjMR/x2bpA+wuK7Tu XTrWrkx49N6AmMV7cDMJ2+vyyXkxls6jXEAbdyT+j2Y71GvoN/iNbdK X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=R9UO2NRX c=1 sm=1 tr=0 ts=69ac0f10 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=YoiwXk0N_qN2JQiW-xcA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOCBTYWx0ZWRfX3vfWHbA9TKRI /67U/uzek655CikXXWwFRJnRM/JgOf1VgkFXOcwsVsqZZrAvcGLO3icYFy5L0oSqw/nazkvlXmM JLJbYWNK906nSAtoMRd6bwJ1ou/9yK/kq+WTS3l7eYzqNXydo0CiTl9gHzs+oPtnVv3y0HD4s8D q+QbrdnLjtmRUj6/4vKTR/7zJQYSDSeJFJ9PksbVygpKJ745WZITdiBy4nylCXSHMOL9VIcWYHO djfP3hUcvus7Jg3TUot/Bz+jOpUtRFgvn1GYqT6O0aFO1YpP7/9Vg0c9oYsU0q9M+LnmOnmEDfF KTg+E79r98krbUjk7cLtVvYSVw8JCUhuR/Xc4BXkUsagcO1W2h0Rqv9nVLzB4uHjcNynkqV2RYR +UWD20oZ3ELZmVV3PWhWiPjMh+3Vu1qKRxNS0OIn8dACihKvaoN3MPb9aPDZR8BGfBYyBuTkPQG xGu/77XZFmXg9DU0VRA== X-Proofpoint-ORIG-GUID: g6Y_o98Xe9duE2Jrfs1zEfBJGq-bY-4Q X-Proofpoint-GUID: g6Y_o98Xe9duE2Jrfs1zEfBJGq-bY-4Q 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 clxscore=1011 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 spamscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070108 The Sahara protocol driver is currently located under the QAIC accelerator subsystem even though protocol itself is transported over the MHI bus and is used by multiple Qualcomm flashless devices. Relocate the Sahara protocol driver to drivers/bus/mhi and register it as an independent MHI protocol driver. This avoids treating Sahara as QAIC specific and makes it available for reuse by other MHI based devices. As part of this move, introduce a dedicated Kconfig and Makefile under the MHI subsystem and expose the sahara interface via a common header. Signed-off-by: Kishore Batta --- drivers/accel/qaic/Kconfig | 1 + drivers/accel/qaic/Makefile | 3 +-- drivers/accel/qaic/qaic_drv.c | 11 ++--------- drivers/bus/mhi/Kconfig | 1 + drivers/bus/mhi/Makefile | 3 +++ drivers/bus/mhi/sahara/Kconfig | 18 ++++++++++++++++++ drivers/bus/mhi/sahara/Makefile | 2 ++ drivers/{accel/qaic =3D> bus/mhi/sahara}/sahara.c | 16 +++++++++++----- {drivers/accel/qaic =3D> include/linux}/sahara.h | 0 9 files changed, 39 insertions(+), 16 deletions(-) diff --git a/drivers/accel/qaic/Kconfig b/drivers/accel/qaic/Kconfig index 116e42d152ca885b8c59e33c7a87519a0abc6bb3..1e5f1f4fa93c12d8ca8fb37633f= 2f0bee9997499 100644 --- a/drivers/accel/qaic/Kconfig +++ b/drivers/accel/qaic/Kconfig @@ -8,6 +8,7 @@ config DRM_ACCEL_QAIC depends on DRM_ACCEL depends on PCI && HAS_IOMEM depends on MHI_BUS + select MHI_SAHARA select CRC32 select WANT_DEV_COREDUMP help diff --git a/drivers/accel/qaic/Makefile b/drivers/accel/qaic/Makefile index 71f727b74da3bb4478324689f02a7cea24a05c2d..e7b8458800072aa627f7f36c325= 7883aa56f4ce4 100644 --- a/drivers/accel/qaic/Makefile +++ b/drivers/accel/qaic/Makefile @@ -13,7 +13,6 @@ qaic-y :=3D \ qaic_ras.o \ qaic_ssr.o \ qaic_sysfs.o \ - qaic_timesync.o \ - sahara.o + qaic_timesync.o =20 qaic-$(CONFIG_DEBUG_FS) +=3D qaic_debugfs.o diff --git a/drivers/accel/qaic/qaic_drv.c b/drivers/accel/qaic/qaic_drv.c index 63fb8c7b4abcbe4f1b76c32106f4e8b9ea5e2c8e..76cc8086825e7949ed756d51fcb= 56a08f392d228 100644 --- a/drivers/accel/qaic/qaic_drv.c +++ b/drivers/accel/qaic/qaic_drv.c @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -32,7 +33,6 @@ #include "qaic_ras.h" #include "qaic_ssr.h" #include "qaic_timesync.h" -#include "sahara.h" =20 MODULE_IMPORT_NS("DMA_BUF"); =20 @@ -782,18 +782,12 @@ static int __init qaic_init(void) ret =3D pci_register_driver(&qaic_pci_driver); if (ret) { pr_debug("qaic: pci_register_driver failed %d\n", ret); - return ret; + goto free_pci; } =20 ret =3D mhi_driver_register(&qaic_mhi_driver); if (ret) { pr_debug("qaic: mhi_driver_register failed %d\n", ret); - goto free_pci; - } - - ret =3D sahara_register(); - if (ret) { - pr_debug("qaic: sahara_register failed %d\n", ret); goto free_mhi; } =20 @@ -847,7 +841,6 @@ static void __exit qaic_exit(void) qaic_ras_unregister(); qaic_bootlog_unregister(); qaic_timesync_deinit(); - sahara_unregister(); mhi_driver_unregister(&qaic_mhi_driver); pci_unregister_driver(&qaic_pci_driver); } diff --git a/drivers/bus/mhi/Kconfig b/drivers/bus/mhi/Kconfig index b39a11e6c624ba00349cca22d74bd876020590ab..4acedb886adccc6f76f69c241d5= 3106da59b491f 100644 --- a/drivers/bus/mhi/Kconfig +++ b/drivers/bus/mhi/Kconfig @@ -7,3 +7,4 @@ =20 source "drivers/bus/mhi/host/Kconfig" source "drivers/bus/mhi/ep/Kconfig" +source "drivers/bus/mhi/sahara/Kconfig" diff --git a/drivers/bus/mhi/Makefile b/drivers/bus/mhi/Makefile index 354204b0ef3ae4030469a24a659f32429d592aef..e4af535e1bb1bc9481fae60d7eb= 347700d2e874c 100644 --- a/drivers/bus/mhi/Makefile +++ b/drivers/bus/mhi/Makefile @@ -3,3 +3,6 @@ obj-$(CONFIG_MHI_BUS) +=3D host/ =20 # Endpoint MHI stack obj-$(CONFIG_MHI_BUS_EP) +=3D ep/ + +# Sahara MHI protocol +obj-$(CONFIG_MHI_SAHARA) +=3D sahara/ diff --git a/drivers/bus/mhi/sahara/Kconfig b/drivers/bus/mhi/sahara/Kconfig new file mode 100644 index 0000000000000000000000000000000000000000..3f1caf6acd979a4af68aaf0e250= aa54762e8cda5 --- /dev/null +++ b/drivers/bus/mhi/sahara/Kconfig @@ -0,0 +1,18 @@ +config MHI_SAHARA + tristate + depends on MHI_BUS + select FW_LOADER_COMPRESS + select FW_LOADER_COMPRESS_XZ + select FW_LOADER_COMPRESS_ZSTD + help + Enable support for the Sahara protocol transported over the MHI bus. + + The Sahara protocol is used to transfer firmware images, retrieve + memory dumps and exchange command mode DDR calibration data between + host and device. This driver is not tied to a specific SoC and may be + used by multiple MHI based devices. + + If unsure, say N. + + To compile this driver as a module, choose M here: the module will be + called mhi_sahara. diff --git a/drivers/bus/mhi/sahara/Makefile b/drivers/bus/mhi/sahara/Makef= ile new file mode 100644 index 0000000000000000000000000000000000000000..fc02a25935011cbd7138ea8f24b= 88cf5b032a4ce --- /dev/null +++ b/drivers/bus/mhi/sahara/Makefile @@ -0,0 +1,2 @@ +obj-$(CONFIG_MHI_SAHARA) +=3D mhi_sahara.o +mhi_sahara-y :=3D sahara.o diff --git a/drivers/accel/qaic/sahara.c b/drivers/bus/mhi/sahara/sahara.c similarity index 99% rename from drivers/accel/qaic/sahara.c rename to drivers/bus/mhi/sahara/sahara.c index fd3c3b2d1fd3bb698809e6ca669128e2dce06613..8ff7b6425ac5423ef8f32117151= dca10397686a8 100644 --- a/drivers/accel/qaic/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -1,6 +1,8 @@ -// SPDX-License-Identifier: GPL-2.0-only - -/* Copyright (c) 2024 Qualcomm Innovation Center, Inc. All rights reserved= . */ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2018-2020, The Linux Foundation. All rights reserved. + * + */ =20 #include #include @@ -9,12 +11,11 @@ #include #include #include +#include #include #include #include =20 -#include "sahara.h" - #define SAHARA_HELLO_CMD 0x1 /* Min protocol version 1.0 */ #define SAHARA_HELLO_RESP_CMD 0x2 /* Min protocol version 1.0 */ #define SAHARA_READ_DATA_CMD 0x3 /* Min protocol version 1.0 */ @@ -928,8 +929,13 @@ int sahara_register(void) { return mhi_driver_register(&sahara_mhi_driver); } +module_init(sahara_register); =20 void sahara_unregister(void) { mhi_driver_unregister(&sahara_mhi_driver); } +module_exit(sahara_unregister); + +MODULE_LICENSE("GPL"); +MODULE_DESCRIPTION("Qualcomm Sahara MHI protocol driver"); diff --git a/drivers/accel/qaic/sahara.h b/include/linux/sahara.h similarity index 100% rename from drivers/accel/qaic/sahara.h rename to include/linux/sahara.h --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 2F9D034F462 for ; Sat, 7 Mar 2026 11:42:12 +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=1772883733; cv=none; b=ioz4LPknjXNwtT9T8WafIA5e/SNL7J8Iw0QYMiWnPbQVcehZ4AHknDIvIjaiehx3Z+aM/JNefNDzKyYSAx+0FyZhAW0ABSSJ1X6JZWltIgPHOGH4dbQTqRbDgHttGNolsU52u64JRIkux9v1fOZLAXYUXj06WKPPjXreIC61EM4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883733; c=relaxed/simple; bh=IdXz01mR4Rs8f0RYsO8zVitGxgHIzvaHiQFtik+wHJE=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=UfiiOoESZh1afnvDayV36EohpqNhHLI+SgHsnZN6i8K7UTzh5hluVAVUE6kbRPnMXbiRPNKubb4fKn3c20VJftKePni+k+G6ETHDj6FcqVOV2yuVtWYf9UrlVUymwIeIc1/Mpn4Y5/DM2gao1d4zV1gJHLxuDjRIrCx0CFGQtqg= 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=XwzR2mDA; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=Ksxsray+; 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="XwzR2mDA"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="Ksxsray+" Received: from pps.filterd (m0279863.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6276qwnl2488170 for ; Sat, 7 Mar 2026 11:42:11 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= Ql/OBlsnmzWsbfZsETPUc9XH7il2mDmKIxDrs/rob/k=; b=XwzR2mDAVP8gQTmc ONv/9nBbSN6R1/IGchyt5pVMxbvkE+HFfnOaPpL3gKYssoTyJjrdBodQJLB9bkNl bbELNoZRi+f/yXKdHSR2QNGN202Me4tnPDtMvgEFsyEw3v8vSZLOJxjwGvvEygoD 474gv3EinsdqUM2MqtJeKbK7qDKvuRedK8hSnoqO0c6kvLtX0SSF3pqmK5G8QWZK eQ7ExLmVM5by6tSH4MlHvuAjlAO47zPkWYRIHevZg0nOtMuuUi0gEG8lxjT8rBTv 027wBHsbgvg1sshTTQrLhquygJn0fC+aKYAB/hbXM3B/3f7Eu3j2fzcpPiqK8G9s 8CyhJQ== Received: from mail-pl1-f198.google.com (mail-pl1-f198.google.com [209.85.214.198]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4crc838ppf-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:11 +0000 (GMT) Received: by mail-pl1-f198.google.com with SMTP id d9443c01a7336-2ae59e057f1so71130555ad.1 for ; Sat, 07 Mar 2026 03:42:11 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883731; x=1773488531; 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=Ql/OBlsnmzWsbfZsETPUc9XH7il2mDmKIxDrs/rob/k=; b=Ksxsray+yQlWDE6Atop5lEH3UReyPN4H9bY/FhIiI3j0uoJnF/2yApBDgGR5J44Qxm eaUAom893yqqzWrQ8D0KEYsyh0Y7MnE1i7pKHEWldjl9LPx8Rv6Dv/JaTiSGJc8FIP1s wgbDa2VB7d17Uk8TJ5dGH1iva3XSYakGHe0rCgLJWsKdg7E1oHdW6Ts1Fi6fkcx7AbmU qjWOC1+3UAJ7MwgwwDGT+X3X23SBI8n9C+aAnz/ViRZN5k9R0Mu4MQT5vAJWVSD3v8Yg 4S8ph0SxuCtjKuOekmvDocgbrWP69kAjlchqi/pFZRbDHzTbqjpxtRE3s9JbD35jyOsy fafg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883731; x=1773488531; 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=Ql/OBlsnmzWsbfZsETPUc9XH7il2mDmKIxDrs/rob/k=; b=UnuwotAjUoNbr3Z1MWSRJxzT88rVBEbpaG90k/czK5AfdBn6prEbx59OIufVGdRSRt YlsDyppDXCDSHlYl9s73TeNUH8LXbiaaaix5lJ4m8ebGX6lXm461HyAx74EZhg7u0V5i nTRvFiIYX9RsMBgiI2Ek0s8fvN1esAnVC42a6Yu9OBpHjOqO9Tv2KE3DRiplo+5RDVsG MVTLBaUakE80/AQqww/hAEvJCdVcCd4fkiZJuPAg5RADk9pDMyc6vYT1b39/luWLu6qw CQv3mGQFuMumZ+Lgravqk64JFxIxVWTewSS/G8mjozyvp5UIFXQ9mtzV2oiNvfh12CsO PnFQ== X-Forwarded-Encrypted: i=1; AJvYcCUWkoX88eUUQyhqdiijrDkyIjVWPFuZ8m3Xfe2xyd2PHUalINnZnu+S7uaIo5wdiPWQObYdOS2Vpin6+Go=@vger.kernel.org X-Gm-Message-State: AOJu0Ywfxx30hiA3YMOh9vbalUz1Zro8VyxQUdwi8ZDoHcplvsXpPLul 8IQusBsrvtEfazfnbAllv8VYJ17ez1Ht3bPmnu3/7iKKbqsAwELiulsuCGFbRPwOBKOPM4eHwUg I12w5SEzGnd58NYWnbXt01xaX8UgpmglsekoKU2bRKLmk4QGToXgYzCOPfZuxOwnXwL4= X-Gm-Gg: ATEYQzy88hxWFjFgTzQCSFpXG8vGCZHljCkDHylbaeNGXLEivIrialyvDLG4gWIWG6F eWH+vtzgIlvh4QNrUN+k8nQ/2HLEu2x0VcqTt6vBysLxwtuclbO9UL+2zkOENt9pUZxve6MH3Ki 0S3DzzruXZ9WvUZRWMq+XsvL+F/c71s6lzafS1Q95JAS6CqT2fXmqGTEZ2d30moFycgU5kcDc3R oqaGXc4L1RWtFpEYBPEya/KfqI7mN+EOTJ9n44WayrEoOdH8zxDKSRGf7qCJc08G09e1pDjJ7Qo Uhhea444wRQ9B8mOMWbcJJspRycvHWwmIyyzU6AeA6SJeZXKHM9UJZOU1oBkigBpF/+p1x9zAoD 524a1RFzwcDOuSt73T2bvp+gFwodruQjmhH5lQ6Fnig+mT5tXVkQ= X-Received: by 2002:a17:902:ef50:b0:2ae:5797:e082 with SMTP id d9443c01a7336-2ae823aad45mr55366155ad.24.1772883730943; Sat, 07 Mar 2026 03:42:10 -0800 (PST) X-Received: by 2002:a17:902:ef50:b0:2ae:5797:e082 with SMTP id d9443c01a7336-2ae823aad45mr55365825ad.24.1772883730454; Sat, 07 Mar 2026 03:42:10 -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.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:10 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:24 +0530 Subject: [PATCH v2 3/9] bus: mhi: Match devices exposing the protocol on the SAHARA channel 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-3-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=1219; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=IdXz01mR4Rs8f0RYsO8zVitGxgHIzvaHiQFtik+wHJE=; b=3HTb3lNqq1SBlZH8owlRUqgc1PykEjlh9ZnscaYY2XCHwlu9RlWn/8c29wYzbFP832FhPqK4M 6/gbGM0wW/kAcei6sxdVFhRnS5Q53iyxG//r/OMoyPfrXciF+4abQ5k X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=R9UO2NRX c=1 sm=1 tr=0 ts=69ac0f13 cx=c_pps a=MTSHoo12Qbhz2p7MsH1ifg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=yOCtJkima9RkubShWh1s:22 a=EUspDBNiAAAA:8 a=O3MGeqbvIhhX5qxHWLUA:9 a=QEXdDO2ut3YA:10 a=GvdueXVYPmCkWapjIL-Q:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOCBTYWx0ZWRfXxo8ER5bkLh4k agNIvnrM+NsccperRnBQwLzYiKAN9UF9VbLi+NckmLIgb/utYIuhRjmYlwCPE1O+p9EGH9vZCYm FvvaRcDTKdic3W2FDlSVz5I24t26xYsDR4K6CYIdgdHkoJTtCLu17lbd2oIG6wpBqcGlVjoLBQq r0CmZZ0ThcnfpUQJk0mrgHBlPEOzEc07iT9U3Db1O6/KeNHlKv2MMc1E7d2HoW94do4zM13lBrp WbprN2k5vZNbpRUnqXzonaSEAChMQCN7xyfGWtsQjkU9TNiDCWbgJFR3zOw9L7Dj82RsCwIth0c xIu0gnt6Q2621yTVNiYq+yTdg7XJee3VX/PVGBBwnTYXZIofWDJpUhSixIdRCcY+vd0cAoh2tZo YNhA6zODJb0ORctnWZRIvfVsGa49CS/D4tK+0dLeophUU/K5j5DQgjZm00tL+0qnkGUmHdnGPQs qlN/bQrHu1NVvqBKt3A== X-Proofpoint-ORIG-GUID: eWAlzMKQulpShOViM70zThB0MIiUDkRe X-Proofpoint-GUID: eWAlzMKQulpShOViM70zThB0MIiUDkRe 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 clxscore=1011 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 adultscore=0 priorityscore=1501 spamscore=0 malwarescore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070108 Some Qualcomm devices expose the Sahara protocol on a generic SAHARA MHI channel rather than a QAIC specific channel name. As a result, the sahara driver does not currently bind to such devices and never probes. Extend the MHI device ID match table to also match the SAHARA channel name. This allows the Sahara protocol driver to bind to devices that expose the protocol directly on a standard sahara MHI channel. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index 8ff7b6425ac5423ef8f32117151dca10397686a8..e3499977e7c6b53bc624a8eb00d= 0636f2ea63307 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -911,8 +911,10 @@ static void sahara_mhi_dl_xfer_cb(struct mhi_device *m= hi_dev, struct mhi_result =20 static const struct mhi_device_id sahara_mhi_match_table[] =3D { { .chan =3D "QAIC_SAHARA", }, + { .chan =3D "SAHARA"}, {}, }; +MODULE_DEVICE_TABLE(mhi, sahara_mhi_match_table); =20 static struct mhi_driver sahara_mhi_driver =3D { .id_table =3D sahara_mhi_match_table, --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 831A03563E9 for ; Sat, 7 Mar 2026 11:42:16 +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=1772883738; cv=none; b=F5U0Y0SnmiuYPsw7ZjiZXRsw5Ez1VuQkdw5mgVlNhN0SN1HTAOtJougSVocNfA8jcHA1tSB2DtuggzjxP8PGRudo4DDpNsQy1DsXAqDXalqPogHGkxkse2kw4zMNEVG0oLK3eTfOkml1dlCRM88gEhlqEuHs7CHAC6Lc0W5Ib/E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883738; c=relaxed/simple; bh=D9kJlDoQ6LGAQMXZQh6rystru1KGUPI8NHA/TRw7+VQ=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=oBReYetM6O+57reZiYyUT5gOfAzhkDtn0pKeW5Dm4I0zw34TcutTtIGQ8oS0wk7LTVMD4kBl25Z4DGuToIhLCttdoaTOarOT7cHI6wLshmtKFO8uLxdNPLcJV/W1awX8Cj3/68B8q8UGvQb+hC9vEbIOGZ4OM/S7z8XtlxECtXs= 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=WekjT8zM; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=a8sWamLc; 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="WekjT8zM"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="a8sWamLc" 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 6276rAw0277700 for ; Sat, 7 Mar 2026 11:42:16 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= iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=WekjT8zMSpAi5+2F NOC5OFX4Hs7Lvw67uEwHoXkTlsSG9brO0irqbmk5NV+pK6evVNNk31KGWrOem33d lwy8sOLdr6VKl7gUlygdv/+fsJXXiNHrea0cqIOeMe9ZzIiGtE14uJZP1sYtBDTk a9yK+cr+GE9TsHDNzE49XRpZMM0FUU1R8C182+F4yLpw243CUPdPb+cUYR+XykkS fKObjn1Fvl1V9jWgXOrBWiv7XAactbecX84059nCJ+6ebDoAcvltOSyolj7Ya3pG YL9wGJO33LUEyBQdHuEPqFIXJttvP+lG68vka83+W9yZA/YHMG0sfnFf7tdSQXJB foSrtQ== 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 4crcse0m6x-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:15 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ae3badc00dso81045895ad.3 for ; Sat, 07 Mar 2026 03:42:15 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883735; x=1773488535; 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=iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=a8sWamLc4lNN9E3rG9JDnNZrVVGG6IWCMK5aUg3zTn1maRT9m/nlUBDjsminqEoS7E vKmtCf56Y6R0EW5qSoGTLDVKxe9yURIItaCxUwn12FOAM2NqyiyDUPNKjD+ZNYca5gZe VrJvqRBKRnYkuLcCUOJ+uva/TE3QJMXxNP3u/4u4JLSu9EZhno7QRMLQ0xFZVkJmyOXi 7r5pZ/ui4PdexAVvhjFS9oh2TsyZA8EO2s904MratS2ueG1ZZq6vMhPX1qc/I1TMSnDS nR0xZHV/ggruJTgF02gk2FI2PsAkgcrSJ6vwfGU3y71ZufM255RgnSXh7v1Nh8myXhOi AcHg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883735; x=1773488535; 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=iImuO6SGxaLTCiAHgKuG3rSRhW0OgS17DvZFF+54V/Y=; b=eVy52E1JcD3y4hBDA1fl4vlyTsw+0fd47SrX4d3EinoHMPTYzmHGrT/UeTHd03gukP CcF28lqd8dutXxljLxHT1w/LkTpuI6ilJpKOhCn/oMw4XwpjFMsZFQC0Hag7yeYyc17a bn9eDaCIwHRhf9njfBhvr7B7X8jeuVHZ/et/kqF2ZGrtJ6Kach5kV7YKR5bWIr+U5vvc kOsFCUOUFZ66Z8PnGrbrx/nWsL9UzkdM/WX0BdTx7Cwfq6KX78+MwsEv8j6EG94rWUZA vQoct/9VHBbSqFTHQMHmEB4aDwEtI2erxlBN+0qgp37sLaFv4WI7uFH4qhyCK29dwQkC +V+Q== X-Forwarded-Encrypted: i=1; AJvYcCVbWuGVnHhnbnDuTR3iQpEMF1JdJdOZuk6GbusGDHkr+MxtnKheej0rzzA+n2guAtm1x0PckLZbhUdNbdQ=@vger.kernel.org X-Gm-Message-State: AOJu0YyB/qRrZI+NMS9K66y6FZ8dZn14OP34MGx53WzU9FmX4UJoXlBc fSwCOQQFEVl0HmVbFsobQ7Ew3aEz/64uGo53H2wEhJ1O7ef2kRd+BAv244jAm6KemrupQbWCSr0 gCR+q8QinLum+oZf3Y++ROkwK7+++sHt8p9et6OOPxsuhvuxargGiJb7ASJ8aChLPBq8= X-Gm-Gg: ATEYQzw4XifpsVck5awMkaffttnl+cmhrULKeSM5iOmjfXRiupl1yE2yG4YuNpuBtbn xURKLYjEFebVlk9mT71k8LGeE6Y8h9ULZxomnDaOLijdv2iuNI3s1QZ/Fk0NnVOrrdJ42DF61M6 dtwD4ycRZ/5Awo+zxyiU7LpaZOKmr2gTWkUR8M5KiGnWil1STfMrFXG87v8aixO6VLvuJlJijrL Dgsx9gt7G2Qr64sVsxql8r6obazIu0lQH3tLdOAkEwRDXtfu9y+h5lE5l9VtBxYq7lT+8TZeLM3 PNxNa0FyAAJdmTrSGstRae7UQGM0uBDFC/9vHB387W6UqqWy5My8HMxhR6mL3CjioF3dZyk11Co FS3/yWE70oFQfFSobvKvzLzL7X1mf5cSiHXhM/XdzNhAGtlv7qfc= X-Received: by 2002:a17:902:ef46:b0:2ae:3b36:23e7 with SMTP id d9443c01a7336-2ae82398d80mr52195395ad.16.1772883735200; Sat, 07 Mar 2026 03:42:15 -0800 (PST) X-Received: by 2002:a17:902:ef46:b0:2ae:3b36:23e7 with SMTP id d9443c01a7336-2ae82398d80mr52195255ad.16.1772883734674; Sat, 07 Mar 2026 03:42:14 -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.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:14 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:25 +0530 Subject: [PATCH v2 4/9] bus: mhi: Centralize firmware image table selection at probe time 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-4-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=3898; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=D9kJlDoQ6LGAQMXZQh6rystru1KGUPI8NHA/TRw7+VQ=; b=AaVGqgpWF7eVrREnt5Y5EO03kCIUBYl4kZdPLgZDVTiiCm1Kho2b7UaZcoD4cMrp/CaoDgmiD nVWAvjGkYNWD1NS4wgwp5xWhVrRF461rQtmOaVvcy6WrppQya1xF2rq X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=IdqKmGqa c=1 sm=1 tr=0 ts=69ac0f17 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=hNMuCp7LqqrRSepR2eAA:9 a=0bXxn9q0MV6snEgNplNhOjQmxlI=:19 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-GUID: yOuKoSem-gK9XoNWdesP8tGcBIuFtslv X-Proofpoint-ORIG-GUID: yOuKoSem-gK9XoNWdesP8tGcBIuFtslv X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOCBTYWx0ZWRfX6karpATHGHVg q0BPt6WI7bmlZ8mskElF5mjhmluulKhho7IpYCltKIpHRB7yq7UKekuFoo6HD9vwH2sS2hPspLU FNJgErzTwY0+nymCzNiDxwChgfEfZF8RQs5xloxbMtEitaCWU9lHjCPt8QW7bP4ciwdomYIRmP+ dI1m/m9csnGRJ2xbxXugWp+4Bx2C30pVDdAhrGLjhe2nzRoFQy+BeB+wJ0+/OjirHMztpvC5NqV gR4CluOcq2c8eeVN0T4tBV+P8qaaUNSWYyLaz12U7w8aXoXE9K+7lnpd2+NvwvHl8PguW1wdJdA BCj5MZPAIBRujMuKp4J22LKC1Tn1677XJvxlPdrL1Z6JuE7UQhvHA2cSEPZOKejyFoXYSgOTGm7 fOXcOWx0BTpPuHu32ZJynNNY2pFnPpGsbX4P9Y7YGJZvqc+K7eTvTmuChYXsLvLIJkiNAiJLp89 IG6GvSupKtVKDU9F4Dg== 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 adultscore=0 bulkscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 malwarescore=0 clxscore=1015 phishscore=0 priorityscore=1501 impostorscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070108 The Sahara driver currently selects firmware image tables using scattered, device specific conditionals in the probe path, making the logic harder to follow and extend. Refactor firmware image table selection into a single, explicit probe-time mechanism by introducing a variant table that captures device matching, firmware image tables, firmware folder names, and streaming behavior in one place. This centralizes device specific decisions, simplifies the probe logic, and avoids ad-hoc conditionals while preserving the existing behavior for all supported AIC devices. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 66 ++++++++++++++++++++++++++++++++++++-= ---- 1 file changed, 58 insertions(+), 8 deletions(-) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index e3499977e7c6b53bc624a8eb00d0636f2ea63307..8f1c0d72066c0cf80c09d78bfc5= 1df2e482133b9 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -180,6 +180,16 @@ struct sahara_context { u32 read_data_length; bool is_mem_dump_mode; bool non_streaming; + const char *fw_folder; +}; + +struct sahara_variant { + const char *match; + bool match_is_chan; + const char * const *image_table; + size_t table_size; + const char *fw_folder; + bool non_streaming; }; =20 static const char * const aic100_image_table[] =3D { @@ -224,11 +234,50 @@ static const char * const aic200_image_table[] =3D { [78] =3D "qcom/aic200/pvs.bin", }; =20 +static const struct sahara_variant sahara_variants[] =3D { + { + .match =3D "AIC100", + .match_is_chan =3D false, + .image_table =3D aic100_image_table, + .table_size =3D ARRAY_SIZE(aic100_image_table), + .fw_folder =3D "aic100", + .non_streaming =3D true, + }, + { + .match =3D "AIC200", + .match_is_chan =3D false, + .image_table =3D aic200_image_table, + .table_size =3D ARRAY_SIZE(aic200_image_table), + .fw_folder =3D "aic200", + .non_streaming =3D false, + } +}; + static bool is_streaming(struct sahara_context *context) { return !context->non_streaming; } =20 +static const struct sahara_variant *sahara_select_variant(struct mhi_devic= e *mhi_dev, + const struct mhi_device_id *id) +{ + int i; + + for (i =3D 0; i < ARRAY_SIZE(sahara_variants); i++) { + const struct sahara_variant *v =3D &sahara_variants[i]; + + if (v->match_is_chan) { + if (id && id->chan && !strcmp(id->chan, v->match)) + return v; + } else { + if (mhi_dev->mhi_cntrl && mhi_dev->mhi_cntrl->name && + !strcmp(mhi_dev->mhi_cntrl->name, v->match)) + return v; + } + } + return NULL; +} + static int sahara_find_image(struct sahara_context *context, u32 image_id) { int ret; @@ -797,6 +846,7 @@ static void sahara_read_data_processing(struct work_str= uct *work) =20 static int sahara_mhi_probe(struct mhi_device *mhi_dev, const struct mhi_d= evice_id *id) { + const struct sahara_variant *variant; struct sahara_context *context; int ret; int i; @@ -809,14 +859,14 @@ static int sahara_mhi_probe(struct mhi_device *mhi_de= v, const struct mhi_device_ if (!context->rx) return -ENOMEM; =20 - if (!strcmp(mhi_dev->mhi_cntrl->name, "AIC200")) { - context->image_table =3D aic200_image_table; - context->table_size =3D ARRAY_SIZE(aic200_image_table); - } else { - context->image_table =3D aic100_image_table; - context->table_size =3D ARRAY_SIZE(aic100_image_table); - context->non_streaming =3D true; - } + variant =3D sahara_select_variant(mhi_dev, id); + if (!variant) + return -ENODEV; + + context->image_table =3D variant->image_table; + context->table_size =3D variant->table_size; + context->non_streaming =3D variant->non_streaming; + context->fw_folder =3D variant->fw_folder; =20 /* * There are two firmware implementations for READ_DATA handling. --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 BA152358388 for ; Sat, 7 Mar 2026 11:42: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=1772883742; cv=none; b=L6Y3acCv8VlIrt+3NDszIl38S1fq2ivjhxhAH7aagKaWsWKo5ppb14GKPmqrG9ABzCz50Ffnmlh7pCaAnKCsQQa0RXdlkR0TQrhXFLCuNtt/+0JOzFu16+3lGDpe0CixI2olUXlWI7PE+AXatTWElzGtWZLJD9DQ8ikX5jhWLW4= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883742; c=relaxed/simple; bh=vJFCyjoa95JiLXs7Pz6h5TcdiwCOOqlAIPqInF7ZlGw=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=SR4BwWe7JKd/PfmAPBhkX8BS8pkty9rOVDTjAAcU2H3jyzoMTr5vNVBoWBRRM/UvgumKWl0/qqirBb934g4uOxN78z9Nh/5Cu1O2ghENrrPux1BEyI4WM3DjN8NmurZHo1h1BSIfRGOtViPQ9Ix3qnI59XnweCO+0UIM4gr2fJ0= 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=C7xJadM8; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=hPaD2VyV; 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="C7xJadM8"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="hPaD2VyV" Received: from pps.filterd (m0279865.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6276qu4b3098397 for ; Sat, 7 Mar 2026 11:42:20 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= lZxEXn3sdw5rskEYY6XPn9j73RYtVWhCrLqxpAp16Kg=; b=C7xJadM8gA7u/IHN bx4dtl1AbW/A6cZfQt6yenU7Y5LK7ekEYg6RvIcibbyRAJsImpkgbxOYbrCpYEtI oqevAFsv8iKFFLexOKYQXpM0l2QqJPVnGMxKl5drDuvkeEU8JmzsMOK05sNKEUq2 o2gu92anooiqn/tSoEehm0xR8JCq8VorUHZuQc9L2t7poOhjQPaUlCv+V4V/uPv7 jjXFo/6+6AKqyqAxjZ5hL6l3wYlpI+LTC9N37ZKyDtcL5P7shfnribCKtS/w3WtH mKlf2QS8mkf6Hy/qkMeCwZIXk59VMguXNHpVPmieMW48uFGtFyr/Cfrt33m/G1ph SY3TJQ== 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 4crayrgugu-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:20 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ae4b96c259so69826805ad.1 for ; Sat, 07 Mar 2026 03:42:20 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883739; x=1773488539; 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=lZxEXn3sdw5rskEYY6XPn9j73RYtVWhCrLqxpAp16Kg=; b=hPaD2VyVsktmYsd7QAIzIclvG+xrVQ9UBBFzjLnm67hgBlEoeHhb+zx8TquLdHEYYg iK+qf3zbzmqGlNo1cXiDj+8BnHFjD82wJQT3U7ZBlSCPfI25hwnkHypDpnDB9gitvXyH sQdkYHt0izeIHs24jRec2HZgF9GsoSNZNOT5RTMbAnnXa3/r8uMNUnFp2oP/OUFoSN6c pvD8ko1osMadLmj6KzMe+JTMS9BLZzB3x/ImfNsbO/E1gnC8Nti1BGhdVb9QiMntogta iiiedIeZRpsUXyUDN/fxRGrQ5sqRAmpUkxsdmtm1NV6qccNcVigu3Xddxx3hOHP4B7t9 86UA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883739; x=1773488539; 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=lZxEXn3sdw5rskEYY6XPn9j73RYtVWhCrLqxpAp16Kg=; b=K/J+NNzqlO4N6cyd2C9y/+bGEBcGXaiKxFO61GxreO0lbDTobnjN1HZCk8HreR01Wv gdj/3Lg2HxAtW2S0ZKOVDhslH2fKVPfjbQeu1dQrl6+U8qvb6mq0e1E1cyPWJnsCnFa+ 7SnVZyf+6JCJKcv/p3V1ehhYHFbiVQKUFUqn2hZeo+lsouO9Pm849u/2IoxbWjh27ElN gFFJ3fW2ev4rePBM1klnXvRe8cZMHJyF+1wkesxqCn2S9jsCN4IzcMBbfP/hXOpEbRhm RP7UK2YJuzZoYi5CXAi1UMay9aPepBioFKoBeHzUwEN9ANRjShOrUs5PWIlLBF5DmzMO YfQw== X-Forwarded-Encrypted: i=1; AJvYcCXWh0LcE7Do5PX3fJFflUVvAbY3VGnIP8dHQXDxtuHjWywGXqhrNl9x/mTfeOUEi/G24FDEM9ipsRDFM+c=@vger.kernel.org X-Gm-Message-State: AOJu0YytbGm+yDqc//F1xb0WVRcofjb6Wcxr0xk7fuyvl6MeQkdrs9Mq cKIomA95ejOdvom4Fk8VQ1Z3IURnvlWqheEf8FnDVrN8M4DUd60GawaHMZILL8yZESGKqQbEroB Zkt/JU+SyBEXpSnYJiao6QzIzARgR2zDUhxgs03TyIi/Qs4m0Vbvhqv+pQLaWl/t8RRs= X-Gm-Gg: ATEYQzz2/vkZuICunIcdwq4iB5nORPb2X0yat4SyORmH7Td8+PpvDmFmXv7LrunXx6T rZ6SQoMlW3hsMUsdyQMHr6KYFKLZkS8Mw4sGzoaCuj/+H/5JTghEI71VqCFjbIyPPQmvTf8RA6V FoKK9ahd1MzxZya/1thcXiWkRmErZT4SEKXWa+WWNrR5v8ZVfE7Ks7YGvHZ7vzxFWjqZFindJK/ ZqoJqeRaJu/IxhVgYvq4BQU1W9cAnJaPLQjJuAbCSlDiSasiEk9AcK/D+/Gm3qs+Rql9cJkF+25 B75Ikbl6FTossET3w5d0Zu5Pz412oDhMQAY+v8yYw2qV4TAaCVVtEwWuNQHQCHtVb5ml3KW2rX8 vBXIgjj+CveoxwHXexvntaeBccY8H4AUvI7c5AKeDspcU01cJdcA= X-Received: by 2002:a17:902:e845:b0:2ae:4f4f:1672 with SMTP id d9443c01a7336-2ae75c44e3amr81895115ad.24.1772883739466; Sat, 07 Mar 2026 03:42:19 -0800 (PST) X-Received: by 2002:a17:902:e845:b0:2ae:4f4f:1672 with SMTP id d9443c01a7336-2ae75c44e3amr81894975ad.24.1772883738917; Sat, 07 Mar 2026 03:42:18 -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.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:18 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:26 +0530 Subject: [PATCH v2 5/9] bus: mhi: Add QDU100 firmware image table 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-5-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=2740; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=vJFCyjoa95JiLXs7Pz6h5TcdiwCOOqlAIPqInF7ZlGw=; b=E0DvBMVt1yhlU2+bl19BSbFkyOv8lNtMG/XoDDP3el3kAeZ8yYxst3r6uOujsj9J/WiJJhau5 3vsjMZdzA9YC4KOv2yPbPKP9Km3C9tjYx8vksXNq6mmqaYpJDw2zjVs X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=U5qfzOru c=1 sm=1 tr=0 ts=69ac0f1c 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=Um2Pa8k9VHT-vaBCBUpS:22 a=EUspDBNiAAAA:8 a=HyzSnua-yo5JtJyIgQUA:9 a=0bXxn9q0MV6snEgNplNhOjQmxlI=:19 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-ORIG-GUID: ZHpHmLvI6HneqBdCR6X-rujd9tbbBP6u X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOSBTYWx0ZWRfX4AfGWYnQwFS8 qHDSv3w/zq+6/pHZeUOV9157EzTWZzH3faPKy6rOG9c6NZIPYz8Re5PgmxHA2Lhf1GSJaEAZBaP H8niFbevGTGWdUIVal37oq/0rdf/QAsNEOdux8C6yCIKs0WicicNfmq0Ix8G2IrupluOE4byzKV VWu1K/4LWt7jf8mAagcUvQ/mtKgJdecVyOOglBy6GiNtOeMoZrY3wuO+fvh6kTYLWR/DbCKks2W 2Tql2mpq2KBs+p3gFhwBY87/P/1eKmdCVwtaL0bJ9QC27atRjDVssUkPWbnWYwbBfO9C9qYi/Nq wQ0pKRsAF3pDeB9tfPpHm2dmxcIqNjVeW1xlRrBttbY0KxgWnGU2zeWvytksy7Ug5G8mwUeBQ+M qYFB0VfuR0pq0XAaXGSZoUJOel/DWn6zHo1hD7OMV6LI4n84vGCUiO9ZKyIsBtSxf/UcTqhDsap 4x8zzcAEstff46rXPxg== X-Proofpoint-GUID: ZHpHmLvI6HneqBdCR6X-rujd9tbbBP6u 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 clxscore=1015 adultscore=0 impostorscore=0 lowpriorityscore=0 phishscore=0 bulkscore=0 malwarescore=0 priorityscore=1501 spamscore=0 suspectscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070109 Add firmware image table support for the Qualcomm QDU100 device to the sahara protocol driver. The QDU100 device expose the Sahara protocol directly on the SAHARA MHI channel. Select the appropriate firmware image table based on the matched MHI channel, allowing the driver to load QDU100 firmware images without requiring device specific client drivers or additional registration mechanisms. This change integrates QDU100 support into the existing probe time variant selection logic and does not affect the behavior of existing AIC devices. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 39 +++++++++++++++++++++++++++++++++++++= ++ 1 file changed, 39 insertions(+) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index 8f1c0d72066c0cf80c09d78bfc51df2e482133b9..73ae722122a35b77760a4816bc6= 0e6607aa53455 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -234,6 +234,37 @@ static const char * const aic200_image_table[] =3D { [78] =3D "qcom/aic200/pvs.bin", }; =20 +static const char * const qdu100_image_table[] =3D { + [5] =3D "qcom/qdu100/uefi.elf", + [8] =3D "qcom/qdu100/qdsp6sw.mbn", + [16] =3D "qcom/qdu100/efs1.bin", + [17] =3D "qcom/qdu100/efs2.bin", + [20] =3D "qcom/qdu100/efs3.bin", + [23] =3D "qcom/qdu100/aop.mbn", + [25] =3D "qcom/qdu100/tz.mbn", + [29] =3D "qcom/qdu100/zeros_1sector.bin", + [33] =3D "qcom/qdu100/hypvm.mbn", + [34] =3D "qcom/qdu100/mdmddr.mbn", + [36] =3D "qcom/qdu100/multi_image_qti.mbn", + [37] =3D "qcom/qdu100/multi_image.mbn", + [38] =3D "qcom/qdu100/xbl_config.elf", + [39] =3D "qcom/qdu100/abl_userdebug.elf", + [40] =3D "qcom/qdu100/zeros_1sector.bin", + [41] =3D "qcom/qdu100/devcfg.mbn", + [42] =3D "qcom/qdu100/zeros_1sector.bin", + [43] =3D "qcom/qdu100/kernel_boot.elf", + [45] =3D "qcom/qdu100/tools_l.elf", + [46] =3D "qcom/qdu100/Quantum.elf", + [47] =3D "qcom/qdu100/quest.elf", + [48] =3D "qcom/qdu100/xbl_ramdump.elf", + [49] =3D "qcom/qdu100/shrm.elf", + [50] =3D "qcom/qdu100/cpucp.elf", + [51] =3D "qcom/qdu100/aop_devcfg.mbn", + [52] =3D "qcom/qdu100/fw_csm_gsi_3.0.elf", + [53] =3D "qcom/qdu100/qdsp6sw_dtbs.elf", + [54] =3D "qcom/qdu100/qupv3fw.elf", +}; + static const struct sahara_variant sahara_variants[] =3D { { .match =3D "AIC100", @@ -250,6 +281,14 @@ static const struct sahara_variant sahara_variants[] = =3D { .table_size =3D ARRAY_SIZE(aic200_image_table), .fw_folder =3D "aic200", .non_streaming =3D false, + }, + { + .match =3D "SAHARA", + .match_is_chan =3D true, + .image_table =3D qdu100_image_table, + .table_size =3D ARRAY_SIZE(qdu100_image_table), + .fw_folder =3D "qdu100", + .non_streaming =3D false, } }; =20 --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 02B02358369 for ; Sat, 7 Mar 2026 11:42:24 +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=1772883746; cv=none; b=Xv9b74yTXADZm4OSM2zQ3Pv8GKryUFe0fGCEhmsHXi2wz1QZofE0RLvtCNw4pZZtxapJ2CwR0GibbkBiNlVofKxB+l116WYjczM5Z7i2XCQPAtpT0n9oBNuioPTRMRmDGX5SP3V89jcAYq4bOy0yp1e1wgrhHJG5Saes0OJOe4E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883746; c=relaxed/simple; bh=McPnRZC5WUBs06Eu6S+05ajVf/2AASOXcpXG+shgcL8=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=OERZzNbUR0yjsokjDPWxZyzZJoq1JZobHLsuql50JL6ef7q2jqOZbw3tzXuIBP+6AtXSEyjd371R1aPGEWhLcnVw/0ekYuxdhO5L4oFhAQ06ub5eimY40t4PE2RO55PmojtZk1M8DQaZQyVToSR6MsGbFsGi5joFIhWMfMh0rk4= 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=D5xH9dh7; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=ZFars3X6; 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="D5xH9dh7"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="ZFars3X6" Received: from pps.filterd (m0279866.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 6274lkDO1249812 for ; Sat, 7 Mar 2026 11:42:24 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= DyQ60u+QKjNmq9e6aqhBdHEkIcuie4R8oY+qWU1KytI=; b=D5xH9dh762LhVitI i83guZKqD15/hYO5iRREcmno9jDXEswiErwKSxmn+Ozzp9tu0YGwNhMwN/HgNS+R cNHsenMNULEOgzUurieZ1+EDPTLs1pvTTHwKV4i/diV3sdQ3H8qjyTEorsf+Cul9 cYydzxd1Bkzz8KNd1htSVEpBTp3y8xArLNTTRaDHSk8ybNHLjL0eu7UrajEFIi8v 0VPTZ8g5kTEtbXPU1T4HvDfihDLUtzkjJaHVguwAOQOI9ATEgLx/p4BAH2Yyc0cv PzPmlm+oYXFABJuPyWs6Ebh6gkd6XttAItuPkowZNstWTzXJo1wrdJHu4NcMZ/+X t0gaHA== 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 4crda98j17-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:24 +0000 (GMT) Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2ae42659a39so423607165ad.1 for ; Sat, 07 Mar 2026 03:42:24 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883744; x=1773488544; 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=DyQ60u+QKjNmq9e6aqhBdHEkIcuie4R8oY+qWU1KytI=; b=ZFars3X6Xbc6EOJ4ABFTbmsYV4aCjltaJwTtW/MG9LIpvLysLjCV/TLRTTs/wXW2wa FbMtthgBaKZtcztp9/vXdIfZpw/F54fG6jlGxvNGJ6Gu5eXHFNaq5xenhDFnilkvXGQD t7F99dYcb20OYUXM2jckf3qxh1jyIDG1u1nX5KwvdTn3D6SQ6wuOFDby0F+MgLig/rCZ VdMO4CopyUVJAWp5xZNE/MGykWPbJdeZ86AF+qZMmoY0zlANgD5MRxgGquL9nSm/51cC Zt46OktZIWFAw9YT9eXFPgqI+pdih8wJDYoQb69Tp76sASbWpNnsW4gwpjjgqwj4zVMu ltdA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883744; x=1773488544; 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=DyQ60u+QKjNmq9e6aqhBdHEkIcuie4R8oY+qWU1KytI=; b=RVcJfkN4mnu+qf+cQYFwqVZ/ZePGlbQ1HKSpUMIKGw33YFADqaQjw7xJZnMD1/+wrC p0PL50rcsjWts1XUjTwz7/Deh0b+rlDRFxILleaLj8SGB9kULgVRq50gb2xaTbh2hif2 6g1Qd8gGUGinXUV0UpwvP4zza8I4Lc9Mhi7FFasI6wxv2gj9wGvc/lujQZP+Ge0i2dK2 yAHZmsAWzuudgPdTRz/UOa3s9WeC7e3QKjzBp6uq+T6IOy8ut5m1n2sDZtOZSBrfHjRY WlLaBjPL90jKScagvlt3d3Xia2n1KbkSJAd32uQ5CpNs5c7izY/thDPtDvoO1FFM04Kx UYOQ== X-Forwarded-Encrypted: i=1; AJvYcCVr4SAn7tLdklE3koczHrVrzJ3gQ3JwbfuK20+4e2WuzLNjFPcQ4b2b7nDjb43ilzKislpNQicOuvBME7A=@vger.kernel.org X-Gm-Message-State: AOJu0YzJhC6nhoYxZlWbiuq/v43sl67bgvTkGmzB8X5zQ87A+hkCb4G1 XruM9TnMekOiTRKpkfjk8Rssxon5F7h2t6OYeCqv1JJqCcx+zDbyG2IQ5ePhbWQsA791iRJ7x72 lSGcvOMBBWOxk0PCMrG5Dffo2KWhf6BO0KqanuKXdKYlzj50kcVIENGiOPP62DakT5Ic= X-Gm-Gg: ATEYQzxeekRDv6M+eQG9YdVuOYNOSXEljz0UmfTypwI/jQkNN4lcnO5EzeRimoa68Q4 d+6WW8xYmFhI9lJXsUFUK1ylBVKWAf6kuZP5dsIRGG5dp69kpZMYfFsAYhPRLk3OywPL9cIQ5jD Au8slVK2Uw8oAqoPloZfRWsvKYY96nndiYZF97tmMOh24GE9HHgOeVMeo3d1s9zrs4ynqI8y+mq yYkOV65MraYFiV0OCyARvqDWgEmbhkhEmpbJM6Qi2IkCvynqOxyZ+QiaQezzmgfWjSe2WBBdI8v pkpmC+xPgzTBNnpS8GRoraZ5TM0siW9LWMVQwBCNi9FVUehywVGfClpuKjehQVBQWRs9hyZkCU8 GXp1aEgkOJQpTsW+WdRZIJykD2a+8HuONLZW5cGQGg6lkr31FlHU= X-Received: by 2002:a17:903:1968:b0:2ae:8062:8362 with SMTP id d9443c01a7336-2ae82266d9fmr51669105ad.0.1772883743682; Sat, 07 Mar 2026 03:42:23 -0800 (PST) X-Received: by 2002:a17:903:1968:b0:2ae:8062:8362 with SMTP id d9443c01a7336-2ae82266d9fmr51668875ad.0.1772883743238; Sat, 07 Mar 2026 03:42:23 -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.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:22 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:27 +0530 Subject: [PATCH v2 6/9] bus: mhi: Load DDR training data using per-device serial number 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-6-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=3692; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=McPnRZC5WUBs06Eu6S+05ajVf/2AASOXcpXG+shgcL8=; b=/todAhtMbh8tFvxjx2w9XFXvnGlfpGJTYVN+29dh4Z3dq17sjAF3Pro6/6WgjiZnJeVmxJVQ6 LqwCNEkdXMcCqIkt4DUmOEwvVVCLoyVZAnqiZwj2udbkqLxXIQnmFXz X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOSBTYWx0ZWRfX93Sc+GhMmVIo gwrLBHtXlXuCqUKmz4G8yO2UlQjbD02yUXVrcjEDvvXck6Xbrx9j31Jir9q4JKLeEMywzy5YcYM IzglT/2c+hVd25qEsb9QKeylzKE8CwT2IVm/t9txNRC2a1HfJoFD3xjzXOSRGq4RpNbCmsZ/+5c Xzni0hDWnMdFwLkeCpBi4eOC92q6Js8YSGlNsuPtC4qh0NTXAk2Mgz57TKK3E+zrBDPx0dfe4Ib PuCIQXy5wR68kvWiHJ9DPUKpChvxkG/yT2YPNalEq8ecq5DENlPY5nmEDdVb3JDmB8RZZuAQAWy GgH0Rx8rHvTjyzHK9rtgCwFn5/XuwD/ZBDs2H9g96toxW3nK7+aCbrBhUduVCeS09AWhqBAz7Sp aqpHCQt2000G1PPGEGn4Ytf/sAn3Xcaewcf4n4Yq1Y8Q8v7GxnTZIE3PGG+GIOlmcVElNdmGynS 5fx0UB7SeG6854uiFhA== X-Proofpoint-ORIG-GUID: dDYr9ZSLL16S5VrqSkIJIw7G61i-a9ax X-Authority-Analysis: v=2.4 cv=QZtrf8bv c=1 sm=1 tr=0 ts=69ac0f20 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=YMgV9FUhrdKAYTUUvYB2:22 a=EUspDBNiAAAA:8 a=ygoVp7MZ-9MK0Bp9ExEA:9 a=QEXdDO2ut3YA:10 a=uG9DUKGECoFWVXl0Dc02:22 X-Proofpoint-GUID: dDYr9ZSLL16S5VrqSkIJIw7G61i-a9ax 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 adultscore=0 clxscore=1011 bulkscore=0 priorityscore=1501 impostorscore=0 malwarescore=0 phishscore=0 spamscore=0 suspectscore=0 lowpriorityscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070109 Devices may provide device-specific DDR training data that can be reused across boot to avoid retraining and reduce boot time. The Sahara driver currently always falls back to the default DDR training image, even when per-device training data is available. Extend the firmware loading logic to first attempt loading a per-device DDR training image using the device serial number. If the serial-specific image is not present, fallback to the existing default image, preserving current behavior. This change enables DDR training data reuse when available while keeping the existing training flow unchanged for devices without saved data. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 56 ++++++++++++++++++++++++++++++++-----= ---- 1 file changed, 44 insertions(+), 12 deletions(-) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index 73ae722122a35b77760a4816bc60e6607aa53455..19fb9cb78fbecee047ba2767404= 3c0940e749195 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -61,6 +61,8 @@ #define SAHARA_MEM_DEBUG64_LENGTH 0x18 #define SAHARA_MEM_READ64_LENGTH 0x18 =20 +#define SAHARA_DDR_TRAINING_IMG_ID 34 + struct sahara_packet { __le32 cmd; __le32 length; @@ -319,6 +321,7 @@ static const struct sahara_variant *sahara_select_varia= nt(struct mhi_device *mhi =20 static int sahara_find_image(struct sahara_context *context, u32 image_id) { + char *fw_path; int ret; =20 if (image_id =3D=3D context->active_image_id) @@ -335,18 +338,47 @@ static int sahara_find_image(struct sahara_context *c= ontext, u32 image_id) return -EINVAL; } =20 - /* - * This image might be optional. The device may continue without it. - * Only the device knows. Suppress error messages that could suggest an - * a problem when we were actually able to continue. - */ - ret =3D firmware_request_nowarn(&context->firmware, - context->image_table[image_id], - &context->mhi_dev->dev); - if (ret) { - dev_dbg(&context->mhi_dev->dev, "request for image id %d / file %s faile= d %d\n", - image_id, context->image_table[image_id], ret); - return ret; + /* DDR training special case: Try per-serial number file first */ + if (image_id =3D=3D SAHARA_DDR_TRAINING_IMG_ID && context->fw_folder) { + u32 serial_num =3D context->mhi_dev->mhi_cntrl->serial_number; + + fw_path =3D kasprintf(GFP_KERNEL, + "qcom/%s/mdmddr_0x%x.mbn", + context->fw_folder, serial_num); + if (!fw_path) + return -ENOMEM; + + ret =3D firmware_request_nowarn(&context->firmware, + fw_path, + &context->mhi_dev->dev); + kfree(fw_path); + + if (ret) { + ret =3D firmware_request_nowarn(&context->firmware, + context->image_table[image_id], + &context->mhi_dev->dev); + if (ret) { + dev_dbg(&context->mhi_dev->dev, + "request for image id %d / file %s failed %d\n", + image_id, context->image_table[image_id], ret); + } + return ret; + } + } else { + /* + * This image might be optional. The device may continue without it. + * Only the device knows. Suppress error messages that could suggest an + * a problem when we were actually able to continue. + */ + ret =3D firmware_request_nowarn(&context->firmware, + context->image_table[image_id], + &context->mhi_dev->dev); + if (ret) { + dev_dbg(&context->mhi_dev->dev, + "request for image id %d / file %s failed %d\n", + image_id, context->image_table[image_id], ret); + return ret; + } } =20 context->active_image_id =3D image_id; --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 563B234F46F for ; Sat, 7 Mar 2026 11:42:30 +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=1772883753; cv=none; b=gjbmqgpwNGxhiMPdQv1MF4k2BDkpYh7CbdZNi9RtR1onVsgjdeWsVFnwo+XcCJCRXTi+5//WwVbVWW/O2Cb+Q0eEUWXpYSYAzmdePYt70JVZkovBUh89tqQg3FNOX54RIrXuLgRVzFH6auyUrRDAGW9v1RmeyfCGje+8Zex6j0E= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883753; c=relaxed/simple; bh=5sIdXvX5PZJdnK1UBqFxD2++EMsLUAFVX5mI3bvja1w=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=LdOo4ppVm+isUStNjNy5ISF9nkitjBN6fyF3drQoEGQS7aYdMZ4NyDSDBE8+zJvyMUHJ4HOBFfSDQiFOX5fo0N29ndxhlnWsJ5xQ9gDgSHCa10Ynyzm4BfMz39oiKvvhxcv8owHKLVmUmt0KphL5gICjT7jPeKa0oiRMBf0c2SI= 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=Ew4ZU1Sn; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=brhF67Nv; 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="Ew4ZU1Sn"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="brhF67Nv" Received: from pps.filterd (m0279870.ppops.net [127.0.0.1]) by mx0a-0031df01.pphosted.com (8.18.1.11/8.18.1.11) with ESMTP id 627BUsRD4012651 for ; Sat, 7 Mar 2026 11:42:29 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= wocxk5JJlE5LitylZ0nLyYMuinlhyHjhkCpBDBLuVCk=; b=Ew4ZU1SnlTbqE57t uG/TEaNuhgSHV2FA5lqc7CuWeZhxgLQE1pu8psjx49AkjAdQiwJ/6eC9xKxBb+56 bSkHlI0lqXBDb9+YTyr879prBnYD5/yJtVGCyd6rNUiUqF7Ls8F5JO1QvkHVFgJS kmwvHnO8LpQ+qfEBZ12KSityIFoOqUBeQ5HF4df1uYrqF8dG+InjoWI0kxE+YTZq F/qTZCYRFanJE1IgDgPCxwIur/lKsFQDQgpiWQNfFtv2xW5oroPeR0RlcJvft68y orJxBB6qOKwpT/CzULPwWKvlLnIbsJFrmsBBzCCwvpvluEhFuKxBKga8hxY0fq5m Kb4E9A== Received: from mail-pl1-f197.google.com (mail-pl1-f197.google.com [209.85.214.197]) by mx0a-0031df01.pphosted.com (PPS) with ESMTPS id 4crc3v8py6-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:29 +0000 (GMT) Received: by mail-pl1-f197.google.com with SMTP id d9443c01a7336-2ae502a1dd9so81426175ad.3 for ; Sat, 07 Mar 2026 03:42:29 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883748; x=1773488548; 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=wocxk5JJlE5LitylZ0nLyYMuinlhyHjhkCpBDBLuVCk=; b=brhF67NvN3zVXdJWEvXDjJBnwJ73pa5HnIpPhEIPVYbouKs6YnMBEvNbDO8TzVTYfV l+Zzw78vuyHm0ebAivaZvC+IJ3W2l1aaUR0h/rszw17DAcTDFw+/M28MO0h9yUnfi8xL ktwAdK9l2+7OtClZzy8o/JJNDq+bR9gewQaGoxGs+wSYeaHppsroOqjQU/SpNjg1SYiD XPpH4hQrTEcKR8ya2YpDGgwUWysMo3lyPV1nb2kFoEL+PJlJKxa78ZCjWO4iuC4IPoI1 AX4u8kANF35Wwd92Q5ecLHk9EvdaYN4noj9kL8T2N9luREoZR45FLSCohWXZ1MttBY9q OYkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883748; x=1773488548; 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=wocxk5JJlE5LitylZ0nLyYMuinlhyHjhkCpBDBLuVCk=; b=nMs8cB9BkzoVJ5ajL4iMNHVWnbsoAU97BemTj0/Ze09HukKwiQ9ikE+N91hVAtCx5X t4ieNWlCEGuUlCetbIBOZ8WVPo8K+BwjIQyRQ1OjTPFqCa9RR/U1v67bfq3XRMUZBezU xMpw2VS3pztFjTaAmtAys6nMwuG+4c3fpRz+tKymTljHgTQ98v7IMvmPsN5GinpmIDJl RzgvYjzUv6jUTywBo7zU13rJYl5P/xKYEuhakjv96zcmyzKA2yhe+c44T9QsgVCbOIKr sbg1uSqEX5ditPGdVmR0AY74+Dj2SYfe7si999USU8BHrp1PF4F/mTrhiN1AXcO0VeP0 G5nQ== X-Forwarded-Encrypted: i=1; AJvYcCWp1PYdcx3VAqdZAbWRK1mQLpeRhpktmLW5AG47YIYu78o4eUGo8ZjAjPhxGbueAvLkpd48TomVJ4qGjGY=@vger.kernel.org X-Gm-Message-State: AOJu0YxaYwGfjw9NgbfG5djmXXxy9xP7tycFJKT6U/52F//ChfEbjtBa dM32nmsGiDUHeNt1C1Pt2HgzcfxJXtvuhmorzJRDYLehD+w80Ojzn6Ll9RJ7wj1TBdVqcSvPvkd gJT8Gt6XRXjMDQDsRwNBRM+QssjnaTOCaavQiM4QFk7nu5VfFkuWsZNkuHVLrljahC/o= X-Gm-Gg: ATEYQzwXXUcAJ3g1y4bckwrL8i0/suVF0Dig0T2c+VuqHc/ER7Av0qnKIiej4uHgCDv gcFZ0pMa76q23X9QefKjvrh7UVCJJSIdb6o3oZTHdRpb2evnvHgx8c5DeXNKCnx7qdnxrXAit3o MApJvqiRg5I2YvvVd3uDjt4Eyl8LjxRVoCPFji5to0G/XuZ5a/5KR5BjOKw3ypnbBQKubBf/RA6 TKDisrBUc5vwIeoIUgemN5s8PYR3wNKMHp2A9IL9RMQJuY9qv7ele13fiBECBJM88vtvgKMci/M 0FpDizSN1dA0IuZZorFdnqeHWCeawA8JSIZNMS7Ja90tlq3tOieau4yoUWRI5UiaF6ya/yolPrx jmKvb0P6gSHtFYD3OPYRTC93psuFn11OasgNx6J+hsVo3z5dhOyw= X-Received: by 2002:a17:903:380f:b0:2ae:80b8:df16 with SMTP id d9443c01a7336-2ae82526790mr56543385ad.49.1772883748014; Sat, 07 Mar 2026 03:42:28 -0800 (PST) X-Received: by 2002:a17:903:380f:b0:2ae:80b8:df16 with SMTP id d9443c01a7336-2ae82526790mr56543215ad.49.1772883747524; Sat, 07 Mar 2026 03:42:27 -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.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:27 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:28 +0530 Subject: [PATCH v2 7/9] bus: mhi: Capture DDR training data using command mode 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-7-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=14758; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=5sIdXvX5PZJdnK1UBqFxD2++EMsLUAFVX5mI3bvja1w=; b=r2lHpnu5iDL9r8KwKVIvxCT6jJz/84kOPGYJeigyq0YMFYUVG/MwEuHLk1DfPLpQ3jvoNoAEt hTkE1JTAbY4B1XeRibXhCrI8eFL57gGgAHx2dQabrB2jbZIBeEbr5Ql X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Proofpoint-ORIG-GUID: cMrQoJsJxNAlDe7VyxZXqurfcRS-zk3Q X-Proofpoint-GUID: cMrQoJsJxNAlDe7VyxZXqurfcRS-zk3Q X-Authority-Analysis: v=2.4 cv=OOQqHCaB c=1 sm=1 tr=0 ts=69ac0f25 cx=c_pps a=cmESyDAEBpBGqyK7t0alAg==:117 a=ZePRamnt/+rB5gQjfz0u9A==:17 a=IkcTkHD0fZMA:10 a=Yq5XynenixoA:10 a=s4-Qcg_JpJYA:10 a=VkNPw1HP01LnGYTKEx00:22 a=u7WPNUs3qKkmUXheDGA7:22 a=gowsoOTTUOVcmtlkKump:22 a=EUspDBNiAAAA:8 a=_u4x-iUupSARUiuVX_kA:9 a=QEXdDO2ut3YA:10 a=1OuFwYUASf3TG4hYMiVC:22 X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwOSBTYWx0ZWRfX6waR/DRlb2UP zzMTale2Q4lwSa4QKcypVSlXkrXppq4pA/jZEhQu0lHJHDpuN1+tVzWIF/lI8NNUH+Qr1PO2v5Y rSy0ZuXkRCAnOEfDqEjIjZ0mmLVUbqd8/zTZj3Wrmj9snA5vJKUTFQb5BUx1BDnkFk63Gc+o0/T /c4Td2x1SzesqRJyouSlkolynwBVHtXHvMwA6kX9XPEyjx8H/zLkZHtYcv0y6r/t9fOVi10KRYg iJSeJXrRe+7wjPgmNoeVsx+h6E+SJtO/QNTVXqOLDKWbmVmmiIuPpxgMn0WEqRv8LP6CEnlF1WX 0bPDf8jZkrcen1qjRCSgbaJZHEscnRZ5t2aGdJEGf2yNbXrb4LSPdQm2Kg1ADk3LlgIYBifrFCx LL/uble75j/Ked1vYbwhrJm1HK7BBMu94BavuEi7TA0Ne7eUh3VsAg4yXFG26Ki/MFzFUsmx20S bDJQtQmkFVteSs2wBcA== 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 adultscore=0 impostorscore=0 suspectscore=0 spamscore=0 malwarescore=0 bulkscore=0 clxscore=1015 phishscore=0 lowpriorityscore=0 priorityscore=1501 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070109 During early boot, devices may perform DDR training and produce training data that can be reused on subsequent boots to reduce initialization time. The sahara protocol provides a command mode flow to transfer this training data to the host, but the driver currently does not handle command mode and drops the training payload. Add Sahara command mode support to retrieve DDR training data from the device. When the device enters command mode and sends CMD_READY, query the support command list and request DDR training data using EXECUTE and EXECUTE_DATA. Allocate receive buffers based on the reported response size and copy the raw payload directly from the MHI DL completion callback. Store the captured training data in controller-scoped memory using devres, so it remains available after sahara channel teardown. Also distinguish raw payload completion from control packets in the DL callback, avoiding misinterpretation of training data as protocol messages, and requeue the RX buffer after switching back to IMAGE_TX_PENDING to allow the boot flow to continue. Signed-off-by: Kishore Batta --- drivers/bus/mhi/sahara/sahara.c | 328 ++++++++++++++++++++++++++++++++++++= +++- 1 file changed, 320 insertions(+), 8 deletions(-) diff --git a/drivers/bus/mhi/sahara/sahara.c b/drivers/bus/mhi/sahara/sahar= a.c index 19fb9cb78fbecee047ba27674043c0940e749195..1eea93384724f559f3b6b78cb6a= 6e9a77cd5de6b 100644 --- a/drivers/bus/mhi/sahara/sahara.c +++ b/drivers/bus/mhi/sahara/sahara.c @@ -5,11 +5,14 @@ */ =20 #include +#include +#include #include #include #include #include #include +#include #include #include #include @@ -60,8 +63,16 @@ #define SAHARA_RESET_LENGTH 0x8 #define SAHARA_MEM_DEBUG64_LENGTH 0x18 #define SAHARA_MEM_READ64_LENGTH 0x18 - +#define SAHARA_COMMAND_READY_LENGTH 0x8 +#define SAHARA_COMMAND_EXEC_RESP_LENGTH 0x10 +#define SAHARA_COMMAND_EXECUTE_LENGTH 0xc +#define SAHARA_COMMAND_EXEC_DATA_LENGTH 0xc +#define SAHARA_SWITCH_MODE_LENGTH 0xc + +#define SAHARA_EXEC_CMD_GET_COMMAND_ID_LIST 0x8 +#define SAHARA_EXEC_CMD_GET_TRAINING_DATA 0x9 #define SAHARA_DDR_TRAINING_IMG_ID 34 +#define SAHARA_NUM_CMD_BUF SAHARA_NUM_TX_BUF =20 struct sahara_packet { __le32 cmd; @@ -97,6 +108,19 @@ struct sahara_packet { __le64 memory_address; __le64 memory_length; } memory_read64; + struct { + __le32 client_command; + } command_execute; + struct { + __le32 client_command; + __le32 response_length; + } command_execute_resp; + struct { + __le32 client_command; + } command_exec_data; + struct { + __le32 mode; + } mode_switch; }; }; =20 @@ -163,6 +187,7 @@ struct sahara_context { struct work_struct fw_work; struct work_struct dump_work; struct work_struct read_data_work; + struct work_struct cmd_work; struct mhi_device *mhi_dev; const char * const *image_table; u32 table_size; @@ -183,6 +208,24 @@ struct sahara_context { bool is_mem_dump_mode; bool non_streaming; const char *fw_folder; + bool is_cmd_mode; + bool receiving_trng_data; + size_t trng_size; + size_t trng_rcvd; + u32 trng_nbuf; + char *cmd_buff[SAHARA_NUM_CMD_BUF]; +}; + +/* + * Controller-scoped training data store (per MHI controller device). + * Stored as devres resource on mhi_cntrl->cntrl_dev. + */ +struct sahara_ctrl_trng_data { + struct mutex lock; /* Protects data, size, copied and receiving */ + void *data; + size_t size; + size_t copied; + bool receiving; }; =20 struct sahara_variant { @@ -319,6 +362,48 @@ static const struct sahara_variant *sahara_select_vari= ant(struct mhi_device *mhi return NULL; } =20 +static void sahara_ctrl_trng_release(struct device *dev, void *res) +{ + struct sahara_ctrl_trng_data *ct =3D res; + + mutex_lock(&ct->lock); + kfree(ct->data); + ct->data =3D NULL; + ct->size =3D 0; + ct->copied =3D 0; + ct->receiving =3D false; + mutex_unlock(&ct->lock); +} + +static int sahara_ctrl_trng_match(struct device *dev, void *res, void *mat= ch_data) +{ + /* Exactly one instance per controller */ + return 1; +} + +static struct sahara_ctrl_trng_data *sahara_ctrl_trng_get(struct device *d= ev) +{ + struct sahara_ctrl_trng_data *ct; + + ct =3D devres_find(dev, sahara_ctrl_trng_release, + sahara_ctrl_trng_match, NULL); + if (ct) + return ct; + + ct =3D devres_alloc(sahara_ctrl_trng_release, sizeof(*ct), GFP_KERNEL); + if (!ct) + return NULL; + + mutex_init(&ct->lock); + ct->data =3D NULL; + ct->size =3D 0; + ct->copied =3D 0; + ct->receiving =3D false; + + devres_add(dev, ct); + return ct; +} + static int sahara_find_image(struct sahara_context *context, u32 image_id) { char *fw_path; @@ -400,6 +485,11 @@ static void sahara_send_reset(struct sahara_context *c= ontext) context->is_mem_dump_mode =3D false; context->read_data_offset =3D 0; context->read_data_length =3D 0; + context->is_cmd_mode =3D false; + context->receiving_trng_data =3D false; + context->trng_size =3D 0; + context->trng_rcvd =3D 0; + context->trng_nbuf =3D 0; =20 context->tx[0]->cmd =3D cpu_to_le32(SAHARA_RESET_CMD); context->tx[0]->length =3D cpu_to_le32(SAHARA_RESET_LENGTH); @@ -435,7 +525,8 @@ static void sahara_hello(struct sahara_context *context) =20 if (le32_to_cpu(context->rx->hello.mode) !=3D SAHARA_MODE_IMAGE_TX_PENDIN= G && le32_to_cpu(context->rx->hello.mode) !=3D SAHARA_MODE_IMAGE_TX_COMPLE= TE && - le32_to_cpu(context->rx->hello.mode) !=3D SAHARA_MODE_MEMORY_DEBUG) { + le32_to_cpu(context->rx->hello.mode) !=3D SAHARA_MODE_MEMORY_DEBUG && + le32_to_cpu(context->rx->hello.mode) !=3D SAHARA_MODE_COMMAND) { dev_err(&context->mhi_dev->dev, "Unsupported hello packet - mode %d\n", le32_to_cpu(context->rx->hello.mode)); return; @@ -454,6 +545,153 @@ static void sahara_hello(struct sahara_context *conte= xt) dev_err(&context->mhi_dev->dev, "Unable to send hello response %d\n", re= t); } =20 +static void sahara_switch_mode_to_img_tx(struct sahara_context *context) +{ + int ret; + + context->tx[0]->cmd =3D cpu_to_le32(SAHARA_SWITCH_MODE_CMD); + context->tx[0]->length =3D cpu_to_le32(SAHARA_SWITCH_MODE_LENGTH); + context->tx[0]->mode_switch.mode =3D cpu_to_le32(SAHARA_MODE_IMAGE_TX_PEN= DING); + + ret =3D mhi_queue_buf(context->mhi_dev, DMA_TO_DEVICE, context->tx[0], + SAHARA_SWITCH_MODE_LENGTH, MHI_EOT); + + if (ret) + dev_err(&context->mhi_dev->dev, "Unable to send mode switch %d\n", ret); +} + +static void sahara_command_execute(struct sahara_context *context, u32 cli= ent_command) +{ + int ret; + + context->tx[0]->cmd =3D cpu_to_le32(SAHARA_EXECUTE_CMD); + context->tx[0]->length =3D cpu_to_le32(SAHARA_COMMAND_EXECUTE_LENGTH); + context->tx[0]->command_execute.client_command =3D cpu_to_le32(client_com= mand); + + ret =3D mhi_queue_buf(context->mhi_dev, DMA_TO_DEVICE, context->tx[0], + SAHARA_COMMAND_EXECUTE_LENGTH, MHI_EOT); + if (ret) + dev_err(&context->mhi_dev->dev, "Unable to send command execute %d\n", r= et); +} + +static void sahara_command_execute_data(struct sahara_context *context, u3= 2 client_command) +{ + int ret; + + context->tx[0]->cmd =3D cpu_to_le32(SAHARA_EXECUTE_DATA_CMD); + context->tx[0]->length =3D cpu_to_le32(SAHARA_COMMAND_EXEC_DATA_LENGTH); + context->tx[0]->command_exec_data.client_command =3D cpu_to_le32(client_c= ommand); + + ret =3D mhi_queue_buf(context->mhi_dev, DMA_TO_DEVICE, context->tx[0], + SAHARA_COMMAND_EXEC_DATA_LENGTH, MHI_EOT); + if (ret) + dev_err(&context->mhi_dev->dev, "Unable to send execute data %d\n", ret); +} + +static void sahara_command_ready(struct sahara_context *context) +{ + if (le32_to_cpu(context->rx->length) !=3D SAHARA_COMMAND_READY_LENGTH) { + dev_err(&context->mhi_dev->dev, + "Malformed command ready packet - length %u\n", + le32_to_cpu(context->rx->length)); + return; + } + + context->is_cmd_mode =3D true; + context->receiving_trng_data =3D false; + + sahara_command_execute(context, SAHARA_EXEC_CMD_GET_COMMAND_ID_LIST); +} + +static void sahara_command_execute_resp(struct sahara_context *context) +{ + struct device *dev =3D &context->mhi_dev->mhi_cntrl->mhi_dev->dev; + struct sahara_ctrl_trng_data *ct; + u32 client_cmd, resp_len; + int ret; + u64 remaining; + u32 i; + + if (le32_to_cpu(context->rx->length) !=3D SAHARA_COMMAND_EXEC_RESP_LENGTH= || + le32_to_cpu(context->rx->command_execute_resp.response_length) < 0) { + dev_err(&context->mhi_dev->dev, + "Malformed command execute resp packet - length %d\n", + le32_to_cpu(context->rx->length)); + return; + } + + client_cmd =3D le32_to_cpu(context->rx->command_execute_resp.client_comma= nd); + resp_len =3D le32_to_cpu(context->rx->command_execute_resp.response_lengt= h); + + sahara_command_execute_data(context, client_cmd); + + if (client_cmd =3D=3D SAHARA_EXEC_CMD_GET_COMMAND_ID_LIST) { + sahara_command_execute(context, SAHARA_EXEC_CMD_GET_TRAINING_DATA); + return; + } + + if (client_cmd !=3D SAHARA_EXEC_CMD_GET_TRAINING_DATA) + return; + + ct =3D sahara_ctrl_trng_get(dev); + if (!ct) { + context->is_cmd_mode =3D false; + sahara_switch_mode_to_img_tx(context); + return; + } + + mutex_lock(&ct->lock); + kfree(ct->data); + ct->data =3D kzalloc(resp_len, GFP_KERNEL); + ct->size =3D resp_len; + ct->copied =3D 0; + ct->receiving =3D true; + mutex_unlock(&ct->lock); + + if (!ct->data) { + context->is_cmd_mode =3D false; + sahara_switch_mode_to_img_tx(context); + return; + } + + context->trng_size =3D resp_len; + context->trng_rcvd =3D 0; + context->receiving_trng_data =3D true; + + remaining =3D resp_len; + for (i =3D 0; i < SAHARA_NUM_CMD_BUF && remaining; i++) { + size_t pkt =3D min_t(size_t, remaining, SAHARA_PACKET_MAX_SIZE); + + ret =3D mhi_queue_buf(context->mhi_dev, DMA_FROM_DEVICE, + context->cmd_buff[i], pkt, + (remaining <=3D pkt) ? MHI_EOT : MHI_CHAIN); + if (ret) + break; + + remaining -=3D pkt; + } + + context->trng_nbuf =3D i; +} + +static void sahara_command_processing(struct work_struct *work) +{ + struct sahara_context *context =3D container_of(work, struct sahara_conte= xt, cmd_work); + int ret; + + if (le32_to_cpu(context->rx->cmd) =3D=3D SAHARA_EXECUTE_RESP_CMD) + sahara_command_execute_resp(context); + + if (!context->receiving_trng_data) { + ret =3D mhi_queue_buf(context->mhi_dev, DMA_FROM_DEVICE, + context->rx, SAHARA_PACKET_MAX_SIZE, MHI_EOT); + + if (ret) + dev_err(&context->mhi_dev->dev, + "Unable to requeue rx buf %d\n", ret); + } +} + static int read_data_helper(struct sahara_context *context, int buf_index) { enum mhi_flags mhi_flag; @@ -680,6 +918,9 @@ static void sahara_processing(struct work_struct *work) case SAHARA_MEM_DEBUG64_CMD: sahara_memory_debug64(context); break; + case SAHARA_CMD_READY_CMD: + sahara_command_ready(context); + break; default: dev_err(&context->mhi_dev->dev, "Unknown command %d\n", le32_to_cpu(context->rx->cmd)); @@ -980,6 +1221,20 @@ static int sahara_mhi_probe(struct mhi_device *mhi_de= v, const struct mhi_device_ INIT_WORK(&context->fw_work, sahara_processing); INIT_WORK(&context->dump_work, sahara_dump_processing); INIT_WORK(&context->read_data_work, sahara_read_data_processing); + INIT_WORK(&context->cmd_work, sahara_command_processing); + + for (i =3D 0; i < SAHARA_NUM_CMD_BUF; i++) { + context->cmd_buff[i] =3D devm_kzalloc(&mhi_dev->dev, + SAHARA_PACKET_MAX_SIZE, GFP_KERNEL); + if (!context->cmd_buff[i]) + return -ENOMEM; + } + + context->is_cmd_mode =3D false; + context->receiving_trng_data =3D false; + context->trng_size =3D 0; + context->trng_rcvd =3D 0; + context->trng_nbuf =3D 0; =20 context->active_image_id =3D SAHARA_IMAGE_ID_NONE; dev_set_drvdata(&mhi_dev->dev, context); @@ -1003,6 +1258,7 @@ static void sahara_mhi_remove(struct mhi_device *mhi_= dev) =20 cancel_work_sync(&context->fw_work); cancel_work_sync(&context->dump_work); + cancel_work_sync(&context->cmd_work); vfree(context->mem_dump); sahara_release_image(context); mhi_unprepare_from_transfer(mhi_dev); @@ -1019,15 +1275,71 @@ static void sahara_mhi_ul_xfer_cb(struct mhi_device= *mhi_dev, struct mhi_result static void sahara_mhi_dl_xfer_cb(struct mhi_device *mhi_dev, struct mhi_r= esult *mhi_result) { struct sahara_context *context =3D dev_get_drvdata(&mhi_dev->dev); + struct sahara_ctrl_trng_data *ct; + struct device *dev; + size_t copy; + int ret; + u32 i; + + if (mhi_result->transaction_status) + return; + + /* + * Raw training payload completions arrive for cmd_buff[] buffers. + * Do not schedule cmd_work for those. + */ + if (context->is_cmd_mode && context->receiving_trng_data && + mhi_result->buf_addr !=3D context->rx) { + dev =3D &context->mhi_dev->mhi_cntrl->mhi_dev->dev; + ct =3D sahara_ctrl_trng_get(dev); + if (!ct) + return; =20 - if (!mhi_result->transaction_status) { - context->rx_size =3D mhi_result->bytes_xferd; - if (context->is_mem_dump_mode) - schedule_work(&context->dump_work); - else - schedule_work(&context->fw_work); + for (i =3D 0; i < context->trng_nbuf; i++) { + if (mhi_result->buf_addr =3D=3D context->cmd_buff[i]) { + mutex_lock(&ct->lock); + copy =3D min_t(size_t, mhi_result->bytes_xferd, + ct->size - ct->copied); + memcpy((u8 *)ct->data + ct->copied, + mhi_result->buf_addr, copy); + ct->copied +=3D copy; + mutex_unlock(&ct->lock); + + context->trng_rcvd +=3D copy; + + if (context->trng_rcvd >=3D context->trng_size) { + mutex_lock(&ct->lock); + ct->receiving =3D false; + mutex_unlock(&ct->lock); + + context->receiving_trng_data =3D false; + context->is_cmd_mode =3D false; + + sahara_switch_mode_to_img_tx(context); + ret =3D mhi_queue_buf(context->mhi_dev, + DMA_FROM_DEVICE, + context->rx, + SAHARA_PACKET_MAX_SIZE, + MHI_EOT); + if (ret) + dev_err(&context->mhi_dev->dev, + "Unable to requeue rx buf %d\n", ret); + } + return; + } + } + return; } =20 + /* Normal Rx completion */ + context->rx_size =3D mhi_result->bytes_xferd; + if (context->is_mem_dump_mode) + schedule_work(&context->dump_work); + else if (context->is_cmd_mode) + schedule_work(&context->cmd_work); + else + schedule_work(&context->fw_work); + } =20 static const struct mhi_device_id sahara_mhi_match_table[] =3D { --=20 2.34.1 From nobody Thu Apr 9 15:03:55 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 From nobody Thu Apr 9 15:03:55 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 8A93B358398 for ; Sat, 7 Mar 2026 11:42:38 +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=1772883760; cv=none; b=svGvi9UX0WY1xiosKP5eutbFAYgNJ2D9v5TQOa13ehdBvwvYrz/hdwMB4in7rMVF8DzD/gieHJmFzeVr+qBZ9G8GMRFQ+x+JigjfrT5Z3qHFfaNIsj3xlMTbM1tm3HpKv0AtsRmHvZ1tW2k1NvqtY7QMxVznWqXWmZ5Iz26XCCc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1772883760; c=relaxed/simple; bh=PYlMjATY4SM1+jaLjbUMOn336QEIJpGFcRpjUcyzz/4=; h=From:Date:Subject:MIME-Version:Content-Type:Message-Id:References: In-Reply-To:To:Cc; b=Iit8oEr2JFhExaicJMwwGbQQXKYYzY8y3iXPK/Lu1Qi7mzEeJb+ZqqGosRkrsKEu5Bw1yBVI91TFObwxIoJkswk+ogr0C5uIWu4sIjnTr7xHZZqMQfUstIubSG0izCAvs6PSvYYjXR3X9APVT7bIyaHdKGhJgmnyjO1Krutw5Co= 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=MMLBSZCE; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b=eyGgpbJR; 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="MMLBSZCE"; dkim=pass (2048-bit key) header.d=oss.qualcomm.com header.i=@oss.qualcomm.com header.b="eyGgpbJR" 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 6276tXU73908104 for ; Sat, 7 Mar 2026 11:42:37 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= AhZtQR443/E19GewAj1186Zwj+uyAl6zxJPtQ9r8Toc=; b=MMLBSZCEODmf65KM WTGAu6cSZXV8zO7KcZdu1QYppchEuMAjFw9PsZaPDSObGoHSV298OjX4rRlxS31a ShLIjSX4e/Il5ULFHLHHdpiOO+0YTvtxszMTTF1v2IotkKKKuueLpqbJcE9pbAHW q0N93E2L1djGKr7yNLzYkdDgPwJYxGhSmlWn5sn9PVfOxXZFxK5bSrYiEd1sxYy4 DvO8k2StvOjyipliFk/crY/2v/2jFHO/RTy3khQm23o8EdGHwQR5hMVfo7SoQ5vx +KAs/2nqUXTLOUyCE9CoL8u0YM91zUF3WkeOZi14dDXrqs8XwuLS1HFM2utOrtN/ N7KKvA== 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 4crb14ru7d-1 (version=TLSv1.3 cipher=TLS_AES_128_GCM_SHA256 bits=128 verify=NOT) for ; Sat, 07 Mar 2026 11:42:37 +0000 (GMT) Received: by mail-pl1-f199.google.com with SMTP id d9443c01a7336-2ae405e95f5so76209695ad.2 for ; Sat, 07 Mar 2026 03:42:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oss.qualcomm.com; s=google; t=1772883756; x=1773488556; 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=AhZtQR443/E19GewAj1186Zwj+uyAl6zxJPtQ9r8Toc=; b=eyGgpbJRMN0YyZHmmhVq2edKK1PvfrGXZ1cw81wOijSv/chc8/X/QUh/O6PyQRAGlc WKK/8HSynN9BxHImaQtW+AjZjNdYtazUriEkFutJOeYH2VBLe1KAtTisndzOwfGweWNn kkxEKz2JmAqfWrP1QVzzI1k46SsSb36Of+ONwxCq2U8/QeUXt63/iyi8B7cU441JoY4M izi/efQPWlBxfZBraCs3Yl739Xv6sJ4CTIVk1cPNUZFf9t+WUYgdjUOZm2GrqvhwEu5u h0WPXtXgNLFpEr7QJ1OHgoBHN57KPk5cVaLLWwb+4KFs+4BOl/MgZ459Nblj1/zIb5z0 BhdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1772883756; x=1773488556; 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=AhZtQR443/E19GewAj1186Zwj+uyAl6zxJPtQ9r8Toc=; b=k+r87QRZXNZ9GZkwj0FOepMBO2NsgAJ+TV24XpkmIlNOQ9ra53CbHsd1+v3PH9e+GT beZJeraN5PvVrTHyk+vWkq/uKvQrh5xhVDA8LyP4a5zb7Qy6LW/Fhj00YYMHpEiZH9w8 eHVMt96Ey3dYw6Q5EdAHd4bpUXP9FkIO5f9GHr/7+ERK4noGvLiKiPtr/9DzuWlKQliN Mrr0IDIgCRlTtL2HBV9JRjstuLu5u5JHvIkTaqlb72XQClKA45TRQL77GrmFgp7DkEQR peUNDO68/wEo0a8WoAx75XBIQaDfKIxXMBHInLeNWYGxfKC1O5WqU7gvp9AXUQUEUxyn ynbg== X-Forwarded-Encrypted: i=1; AJvYcCWn/Flb/jFWqSy+f/t+YebsKFoYVjCd8qvVPFX85Ii7mpmmmm1MKIMe8szM787QGeeG4tsEd62eDXUjpVs=@vger.kernel.org X-Gm-Message-State: AOJu0Yy9F6ofgkr+HOz1qnw/qwJUXlsvTSNS97A8UKY06XQLdxfDYWgJ KAoZdXWrv5gHzDxfpx/JWF9+WEInUZ2+2k60CXzHAucLOKKvAdo2VEq+ndckMsMgiE/S44VSESF SwkMRlLXb5udf6YDRiXd2GLTrW+1al7mq/5P4WUUnSvzljDLUgsyDmnlOdvqtJuGm7kM= X-Gm-Gg: ATEYQzzPID0IZ2lXVTAL5Ds8KtEQ0xi+SlPrK93ENo21mEpfT96PR6hXM2XN2PZVjIx cz4xqZmPgRoXDOFvKu8OQLqU/j6U+r4ZQKwiMasjLIoGpDRvyv7BtTA1NYbDUd1XuKKIU5NGRj6 /gTv9f4krN4VT4TtVQYc9Vf8bY416KNW80j0NNOwERGD2fUPw7dPRwMLwH25UwwoM2lxSBxZQvg 8jjfCZJH3yNr8LdnJIuVrIdjKviXHiExpdQM5ySAkQz/2/hNSYJOSIYob4GGTkKH7GjjaILB8bW Klfwrhpuunh7+n5ZUmSuX4cJ44ezcrFBarZeTjjlmiromADg66NCHhIY74M1NJwTHNjztq+EHKH vSx1wSry0NzCsqQ9PqoEw4r56qr+zDMNEjR22xxNZlYPl+nu3X4Q= X-Received: by 2002:a17:902:e549:b0:2ae:5848:baf0 with SMTP id d9443c01a7336-2ae8241685bmr59503375ad.2.1772883756449; Sat, 07 Mar 2026 03:42:36 -0800 (PST) X-Received: by 2002:a17:902:e549:b0:2ae:5848:baf0 with SMTP id d9443c01a7336-2ae8241685bmr59503205ad.2.1772883755994; Sat, 07 Mar 2026 03:42:35 -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.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 07 Mar 2026 03:42:35 -0800 (PST) From: Kishore Batta Date: Sat, 07 Mar 2026 17:11:30 +0530 Subject: [PATCH v2 9/9] Documentation: ABI: Add sysfs ABI documentation for DDR training data 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-9-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=1903; i=kishore.batta@oss.qualcomm.com; s=20260206; h=from:subject:message-id; bh=PYlMjATY4SM1+jaLjbUMOn336QEIJpGFcRpjUcyzz/4=; b=w+aHsVXwaMyLhL8Goe7uM28s40e002IzrEGaReObHvVofLk2hwgKkxUc87dYK5Uy5uT4SJ0v/ IsfocM9Rc+BB12kavhO74NwlBai980rYUSUPMwBcVaAgD/rMcxEMAB+ X-Developer-Key: i=kishore.batta@oss.qualcomm.com; a=ed25519; pk=vJo8RvTf+HZpRLK2oOIljmbn9l3zFkibCGh+blaqZCw= X-Authority-Analysis: v=2.4 cv=IYSKmGqa c=1 sm=1 tr=0 ts=69ac0f2d 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=_glEPmIy2e8OvE2BGh3C:22 a=EUspDBNiAAAA:8 a=dkV1H7vRkoxx0F9zaYgA:9 a=QEXdDO2ut3YA:10 a=324X-CrmTo6CU4MGRt3R:22 X-Proofpoint-GUID: z2KBLjtH5bYmAUZ7tZcxH5yXtMK78Xru X-Proofpoint-ORIG-GUID: z2KBLjtH5bYmAUZ7tZcxH5yXtMK78Xru X-Proofpoint-Spam-Details-Enc: AW1haW4tMjYwMzA3MDEwNiBTYWx0ZWRfXxP4t+/VupCz6 IfW/nD0Ke3osz89/Xo5wBdNqWtIQMN9MpGxHg+ID3Uz8fdmszh9CXvVn2rBr1f2XvmZeOIajMLG QJZ0tDAvJCxrqE4cCMYrDZX1KZ+vehVqkFk3eaJvIvF1gDuulGkYhZFfn5I2SD5oZxkApN3udv6 q1H9wdg9VRZwQzg4WcXMfI3vjJSserFU/0IVULMsF5EfltOkY96o0tlbG0mBpwfOoa8KbGQ3q33 SMQG87qMG5/Zv8KKjWAIyicN0wTZ0ZGYs3pGagpLmdWqijjhjH0C0SzeCq3s93QCfJjujcZecQ8 MjDqj8t8o6puNDtGkHzW+tXB27iTFgx43a8oTBRzek/3ZwXttzT9DjSbC8L0sph4QhjrgS25KLM kQi95GPqB6Y6yB58Fsf7+LNrjnstRotsRc3CuHxpPA6BY5ZA0d81NRoX6MXOuJpN+CEUmrMD2Yy Vh1r3rfnduxECELLYKQ== 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 adultscore=0 suspectscore=0 lowpriorityscore=0 spamscore=0 impostorscore=0 phishscore=0 clxscore=1015 priorityscore=1501 malwarescore=0 bulkscore=0 classifier=typeunknown authscore=0 authtc= authcc= route=outbound adjust=0 reason=mlx scancount=1 engine=8.22.0-2602130000 definitions=main-2603070106 Add ABI documentation for the DDR training data sysfs attribute exposed by the sahara MHI driver. The documented sysfs node provides read-only access to the DDR training data captured during sahara command mode and exposed via the MHI controller device. This allows userspace to read the training data and manage it as needed outside the kernel. Signed-off-by: Kishore Batta --- .../ABI/testing/sysfs-bus-mhi-ddr_training_data | 19 +++++++++++++++= ++++ 1 file changed, 19 insertions(+) diff --git a/Documentation/ABI/testing/sysfs-bus-mhi-ddr_training_data b/Do= cumentation/ABI/testing/sysfs-bus-mhi-ddr_training_data new file mode 100644 index 0000000000000000000000000000000000000000..810b487b5a5fdba133d81255f98= 79844e3938a10 --- /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 de= vice + connected. MHI driver populates different controll= er + nodes for each device. The DDR training data is ex= posed + to userspace to read and save the training data fi= le to + the filesystem. In the subsequent boot up of the d= evice, + 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. --=20 2.34.1