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

Commit c3f19574 authored by Tony Lijo Jose's avatar Tony Lijo Jose 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.

CRs-Fixed: 2635529
Change-Id: Ib22bbdaa99ca29419200f0d9eb20792f34aaec0c
Signed-off-by: default avatarTony Lijo Jose <tjose@codeaurora.org>
parent 52bd957a
Loading
Loading
Loading
Loading
+24 −1
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0-only
/*
 * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved.
 * Copyright (c) 2017-2020, The Linux Foundation. All rights reserved.
 */

#include <linux/module.h>
@@ -45,6 +45,11 @@ static int cam_csiphy_notify_secure_mode(struct csiphy_device *csiphy_dev,
		CAM_ERR(CAM_CSIPHY, "scm call to hypervisor failed");
		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;
}
@@ -819,6 +824,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) {
@@ -834,6 +840,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");