Re: [PATCH v6 5/7] bus: mhi: Load DDR training data using device serial number

Manivannan Sadhasivam <[email protected]> Thu, 9 Jul 2026 08:21:15 +0200
Newsgroups dev.linux.lists.mhi,org.freedesktop.lists.dri-devel,org.kernel.vger.linux-arm-msm,org.kernel.vger.linux-doc,org.kernel.vger.linux-kernel
Message-ID <ysumvduurfx5jq7r2eaa4ik24eqk5at24frvjl3zyif4wc4ojj@2bhq4vzuqlnw>
On Wed, Jul 01, 2026 at 04:07:39PM +0530, Kishore Batta wrote:
> 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 <[email protected]>
> ---
>  drivers/bus/mhi/host/clients/sahara/sahara.c | 25 ++++++++++++++++++++++++-
>  1 file changed, 24 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/bus/mhi/host/clients/sahara/sahara.c b/drivers/bus/mhi/host/clients/sahara/sahara.c
> index 9adbd84859073d8024ba2a5fcfa33897439d6759..b5ca6353540dc3815db6539e7424afdb749fd3f6 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
> @@ -235,7 +257,8 @@ static int sahara_find_image(struct sahara_context *context, u32 image_id)
>  				      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",
> +		dev_dbg(&context->mhi_dev->dev,
> +			"request for image id %d / file %s failed %d\n",

Spurious change.

- Mani

-- 
மணிவண்ணன் சதாசிவம்