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

Commit 1e25bb79 authored by Shankar Ravi's avatar Shankar Ravi Committed by Gerrit - the friendly Code Review server
Browse files

msm: camera: csiphy: Clear secure phy flags on release



Issue:
Phy flags are set on CONFIG_DEV and are cleared on STOP_DEV.
If release is called without stop dev, next session will be opened with
incorrect phy configuration based on the previous stale secure mode
flags.

Fix:
Clear the phy secure mode flags on RELEASE_DEV.

Change-Id: If47a4084c3edbf2a8fb48d22b85c5d04fe878c50
Signed-off-by: default avatarShankar Ravi <rshankar@codeaurora.org>
parent 19dad3f7
Loading
Loading
Loading
Loading
+25 −1
Original line number Diff line number Diff line
/* Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
/* Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -51,6 +51,12 @@ static int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
		return -EINVAL;
	}

	CAM_INFO(CAM_CSIPHY, "PHY : %d offset: %d SEC: %d Mask: %d",
			csiphy_dev->soc_info.index,
			offset,
			protect,
			csiphy_dev->csiphy_cpas_cp_reg_mask[offset]);

	return 0;
}

@@ -837,6 +843,7 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
	}
		break;
	case CAM_RELEASE_DEV: {
		int32_t offset;
		struct cam_release_dev_cmd release;

		if (!csiphy_dev->acquire_count) {
@@ -852,6 +859,23 @@ int32_t cam_csiphy_core_cfg(void *phy_dev,
			goto release_mutex;
		}

		offset = cam_csiphy_get_instance_offset(csiphy_dev,
			release.dev_handle);
		if (offset < 0 || offset >= CSIPHY_MAX_INSTANCES) {
			CAM_ERR(CAM_CSIPHY, "Invalid offset");
			goto release_mutex;
		}

		if (csiphy_dev->csiphy_info.secure_mode[offset])
			cam_csiphy_notify_secure_mode(
				csiphy_dev,
				CAM_SECURE_MODE_NON_SECURE, offset);

		csiphy_dev->csiphy_info.secure_mode[offset] =
			CAM_SECURE_MODE_NON_SECURE;

		csiphy_dev->csiphy_cpas_cp_reg_mask[offset] = 0x0;

		rc = cam_destroy_device_hdl(release.dev_handle);
		if (rc < 0)
			CAM_ERR(CAM_CSIPHY, "destroying the device hdl");