Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save justfortherec/7eae2341f5f46f93f1cabb91d96b525e to your computer and use it in GitHub Desktop.
Save justfortherec/7eae2341f5f46f93f1cabb91d96b525e to your computer and use it in GitHub Desktop.
Linux kernel patch in Fairphone 19.02.1 to fix shutdown issue
From eb244d10da4f96f8147cc0bcadf2e043106745a4 Mon Sep 17 00:00:00 2001
From: Francesco Salvatore <francesco@fairphone.com>
Date: Fri, 14 Dec 2018 16:15:44 +0100
Subject: [PATCH] Fix reboot-on-shutdown issue with the new camera module
Since the introduction of Android N on FP2 devices equipped
with the new camera module, when an user tries to shutdown the device
it starts the power-off procedure but reboots before finishing.
This makes it impossible to turn off the phone and,
as a side effect, even to encrypt the device.
The encryption issue has been present also on Android M.
This commit fixes that issue, probably caused by a race condition
on shared access on CCI bus.
Issue: FP2N-133
Issue: FP2N-269
Test: 'cts-tradefed run cts -m CtsCameraTestCases'
Change-Id: I3c38822e052303b98169a09ddd90a7ac885f8b2c
---
drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c | 5 +++++
drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h | 1 +
2 files changed, 6 insertions(+)
diff --git a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
index 831084424557..d31e4f27e9b4 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.c
@@ -797,6 +797,9 @@ static int32_t msm_cci_config(struct v4l2_subdev *sd,
struct msm_camera_cci_ctrl *cci_ctrl)
{
int32_t rc = 0;
+ struct cci_device *cci_dev = v4l2_get_subdevdata(sd);
+
+ mutex_lock(&cci_dev->mutex);
CDBG("%s line %d cmd %d\n", __func__, __LINE__,
cci_ctrl->cmd);
switch (cci_ctrl->cmd) {
@@ -820,6 +823,7 @@ static int32_t msm_cci_config(struct v4l2_subdev *sd,
}
CDBG("%s line %d rc %d\n", __func__, __LINE__, rc);
cci_ctrl->status = rc;
+ mutex_unlock(&cci_dev->mutex);
return rc;
}
@@ -1128,6 +1132,7 @@ static int __devinit msm_cci_probe(struct platform_device *pdev)
CDBG("%s: no enough memory\n", __func__);
return -ENOMEM;
}
+ mutex_init(&new_cci_dev->mutex);
v4l2_subdev_init(&new_cci_dev->msm_sd.sd, &msm_cci_subdev_ops);
new_cci_dev->msm_sd.sd.internal_ops = &msm_cci_internal_ops;
snprintf(new_cci_dev->msm_sd.sd.name,
diff --git a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
index 283bd28ee1bb..bbf94e1330fc 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/cci/msm_cci.h
@@ -129,6 +129,7 @@ struct cci_device {
uint32_t hw_version;
uint8_t ref_count;
+ struct mutex mutex;
enum msm_cci_state_t cci_state;
struct clk *cci_clk[CCI_NUM_CLK_MAX];
--
2.17.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment