[PATCH v7 5/7] bus: mhi: Load DDR training data using device serial number
From: Kishore Batta
Date: Thu Oct 08 2026 - 02:25:33 EST
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
serial specific training data is available.
Extend the firmware loading logic for the DDR training image to first
attempt loading a per-device image dervied from the device serial number.
If the serial-specific image is not present, fall back to the existing
default image, preserving current behavior.
This allows reuse of previously generated DDR training data when available,
while keeping the existing training flow unchanged for devices without
saved data or for all other firmware images.
Signed-off-by: Kishore Batta <kishore.batta@xxxxxxxxxxxxxxxx>
---
drivers/bus/mhi/host/clients/sahara/sahara.c | 22 ++++++++++++++++++++++
1 file changed, 22 insertions(+)
diff --git a/drivers/bus/mhi/host/clients/sahara/sahara.c b/drivers/bus/mhi/host/clients/sahara/sahara.c
index 7fe5158c17e9814f50b2065202a629eb10a742a8..460695055572151003110f4aec1d682b92753770 100644
--- a/drivers/bus/mhi/host/clients/sahara/sahara.c
+++ b/drivers/bus/mhi/host/clients/sahara/sahara.c
@@ -59,6 +59,7 @@
#define SAHARA_RESET_LENGTH 0x8
#define SAHARA_MEM_DEBUG64_LENGTH 0x18
#define SAHARA_MEM_READ64_LENGTH 0x18
+#define SAHARA_DDR_TRAINING_IMG_ID 34
struct sahara_packet {
__le32 cmd;
@@ -226,6 +227,27 @@ static int sahara_find_image(struct sahara_context *context, u32 image_id)
return 0;
}
+ /* DDR training special case: Try per-serial number file first */
+ if (image_id == SAHARA_DDR_TRAINING_IMG_ID && context->fw_folder) {
+ u32 serial_num = context->mhi_dev->mhi_cntrl->serial_number;
+
+ fw_path = kasprintf(GFP_KERNEL,
+ "qcom/%s/mdmddr_0x%x.mbn",
+ context->fw_folder, serial_num);
+ if (!fw_path)
+ return -ENOMEM;
+
+ ret = firmware_request_nowarn(&context->firmware,
+ fw_path,
+ &context->mhi_dev->dev);
+ kfree(fw_path);
+
+ if (!ret) {
+ context->active_image_id = image_id;
+ return 0;
+ }
+ }
+
/*
* This image might be optional. The device may continue without it.
* Only the device knows. Suppress error messages that could suggest an
--
2.34.1