Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit f58533dd authored by Deepak Kumar's avatar Deepak Kumar
Browse files

msm: kgsl: Don't allocate memory for microcode if it is already allocated



This change adds a check to avoid allocating memory for loading microcode
in case it is already allocated. This avoids memory allocation failure
for microcode during multiple tries by userspace to open the kgsl device
in case of errors.

Change-Id: I018ebdb0dab1fc13af8d85a273c1c8b477fa1e26
Signed-off-by: default avatarDeepak Kumar <dkumar@codeaurora.org>
parent 0130e341
Loading
Loading
Loading
Loading
+4 −1
Original line number Diff line number Diff line
@@ -1106,7 +1106,10 @@ static int adreno_init(struct kgsl_device *device)
	struct adreno_gpudev *gpudev = ADRENO_GPU_DEVICE(adreno_dev);
	int ret;

	kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
	ret = kgsl_pwrctrl_change_state(device, KGSL_STATE_INIT);
	if (ret)
		return ret;

	/*
	 * initialization only needs to be done once initially until
	 * device is shutdown
+18 −10
Original line number Diff line number Diff line
@@ -2784,17 +2784,25 @@ static int a5xx_microcode_read(struct adreno_device *adreno_dev)
{
	int ret;

	if (adreno_dev->pm4.hostptr == NULL) {
		ret = _load_firmware(KGSL_DEVICE(adreno_dev),
			 adreno_dev->gpucore->pm4fw_name, &adreno_dev->pm4,
			 &adreno_dev->pm4_fw_size, &adreno_dev->pm4_fw_version);
				 adreno_dev->gpucore->pm4fw_name,
				 &adreno_dev->pm4,
				 &adreno_dev->pm4_fw_size,
				 &adreno_dev->pm4_fw_version);
		if (ret)
			return ret;
	}

	if (adreno_dev->pfp.hostptr == NULL) {
		ret = _load_firmware(KGSL_DEVICE(adreno_dev),
			 adreno_dev->gpucore->pfpfw_name, &adreno_dev->pfp,
			 &adreno_dev->pfp_fw_size, &adreno_dev->pfp_fw_version);
				 adreno_dev->gpucore->pfpfw_name,
				 &adreno_dev->pfp,
				 &adreno_dev->pfp_fw_size,
				 &adreno_dev->pfp_fw_version);
		if (ret)
			return ret;
	}

	ret = _load_gpmu_firmware(adreno_dev);
	if (ret)