DivestOS/Patches/Linux_CVEs/CVE-2017-8264/0.patch

236 lines
8.0 KiB
Diff

From 4268b75208ca04bc63dcfadbb9a1eca8e964a697 Mon Sep 17 00:00:00 2001
From: Nick Desaulniers <ndesaulniers@google.com>
Date: Wed, 10 May 2017 11:39:45 -0700
Subject: BACKPORT: msm: camera: Add regulator enable and disable independent
of CSID
Regulator enable and disable of CSIPHY depends on the CSID module.
Make the enable and disable of clk regulator independent of CSIPHY.
Bug: 33299365
CRs-Fixed: 1107702
Change-Id: Iabb5eb28d63b34a4c3201c53be17054a1907f4fe
Signed-off-by: Ravi Kishore Tanuku <rktanuku@codeaurora.org>
Signed-off-by: VijayaKumar T M <vtmuni@codeaurora.org>
Signed-off-by: Dennis Cagle <d-cagle@codeaurora.org>
(cherry picked from commit b1bb44c9cca61e48ec6158abad6e7969a8e58abf)
---
arch/arm/boot/dts/qcom/apq8084-camera.dtsi | 6 ++
.../msm/camera_v2/sensor/csiphy/msm_csiphy.c | 95 +++++++++++++++++++++-
.../msm/camera_v2/sensor/csiphy/msm_csiphy.h | 2 +
3 files changed, 102 insertions(+), 1 deletion(-)
diff --git a/arch/arm/boot/dts/qcom/apq8084-camera.dtsi b/arch/arm/boot/dts/qcom/apq8084-camera.dtsi
index 2d7e126..abc85bf9 100644
--- a/arch/arm/boot/dts/qcom/apq8084-camera.dtsi
+++ b/arch/arm/boot/dts/qcom/apq8084-camera.dtsi
@@ -26,6 +26,8 @@
reg-names = "csiphy", "csiphy_clk_mux";
interrupts = <0 78 0>;
interrupt-names = "csiphy";
+ qcom,csi-vdd-voltage = <1800000>;
+ qcom,mipi-csi-vdd-supply = <&pma8084_l12>;
};
qcom,csiphy@fda0b000 {
@@ -36,6 +38,8 @@
reg-names = "csiphy", "csiphy_clk_mux";
interrupts = <0 79 0>;
interrupt-names = "csiphy";
+ qcom,csi-vdd-voltage = <1800000>;
+ qcom,mipi-csi-vdd-supply = <&pma8084_l12>;
};
qcom,csiphy@fda0b400 {
@@ -46,6 +50,8 @@
reg-names = "csiphy", "csiphy_clk_mux";
interrupts = <0 80 0>;
interrupt-names = "csiphy";
+ qcom,csi-vdd-voltage = <1800000>;
+ qcom,mipi-csi-vdd-supply = <&pma8084_l12>;
};
qcom,csid@fda08000 {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
index 8aac9b6..5301b33 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.c
@@ -1,4 +1,4 @@
-/* Copyright (c) 2011-2014, The Linux Foundation. All rights reserved.
+/* Copyright (c) 2011-2014, 2017 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
@@ -28,6 +28,10 @@
#define CSIPHY_VERSION_V30 0x10
#define MSM_CSIPHY_DRV_NAME "msm_csiphy"
+static struct camera_vreg_t csiphy_vreg_info[] = {
+ {"qcom,mipi-csi-vdd", 0, 0, 12000},
+};
+
#undef CDBG
#ifdef CONFIG_MSMB_CAMERA_DEBUG
#define CDBG(fmt, args...) pr_err(fmt, ##args)
@@ -205,6 +209,21 @@ static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
}
CDBG("%s:%d called\n", __func__, __LINE__);
+ rc = msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 1);
+ if (rc < 0) {
+ pr_err("%s: regulator config failed\n", __func__);
+ goto csiphy_vreg_config_fail;
+ }
+ rc = msm_camera_enable_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 1);
+ if (rc < 0) {
+ pr_err("%s: regulator enable failed\n", __func__);
+ goto csiphy_vreg_enable_fail;
+ }
+
if (CSIPHY_VERSION == CSIPHY_VERSION_V22) {
rc = msm_cam_clk_enable(&csiphy_dev->pdev->dev,
csiphy_8610_clk_info, csiphy_dev->csiphy_clk,
@@ -268,6 +287,16 @@ static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
csiphy_dev->hw_version);
csiphy_dev->csiphy_state = CSIPHY_POWER_UP;
return 0;
+
+csiphy_vreg_enable_fail:
+ rc = msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+csiphy_vreg_config_fail:
+ iounmap(csiphy_dev->base);
+ csiphy_dev->base = NULL;
+ return rc;
+
}
#else
static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
@@ -303,6 +332,22 @@ static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
rc = -ENOMEM;
return rc;
}
+
+ rc = msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 1);
+ if (rc < 0) {
+ pr_err("%s: regulator config failed\n", __func__);
+ goto csiphy_vreg_config_fail;
+ }
+ rc = msm_camera_enable_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 1);
+ if (rc < 0) {
+ pr_err("%s: regulator enable failed\n", __func__);
+ goto csiphy_vreg_enable_fail;
+ }
+
if (CSIPHY_VERSION == CSIPHY_VERSION_V22) {
rc = msm_cam_clk_enable(&csiphy_dev->pdev->dev,
csiphy_8610_clk_info, csiphy_dev->csiphy_clk,
@@ -364,6 +409,15 @@ static int msm_csiphy_init(struct csiphy_device *csiphy_dev)
csiphy_dev->hw_version);
csiphy_dev->csiphy_state = CSIPHY_POWER_UP;
return 0;
+
+csiphy_vreg_enable_fail:
+ rc = msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+csiphy_vreg_config_fail:
+ iounmap(csiphy_dev->base);
+ csiphy_dev->base = NULL;
+ return rc;
}
#endif
@@ -445,6 +499,19 @@ static int msm_csiphy_release(struct csiphy_device *csiphy_dev, void *arg)
ARRAY_SIZE(csiphy_clk_info), 0);
iounmap(csiphy_dev->clk_mux_base);
}
+
+ msm_camera_enable_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+ msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+
+ if (!IS_ERR_OR_NULL(csiphy_dev->reg_ptr)) {
+ regulator_disable(csiphy_dev->reg_ptr);
+ regulator_put(csiphy_dev->reg_ptr);
+ }
+
iounmap(csiphy_dev->base);
csiphy_dev->base = NULL;
csiphy_dev->csiphy_state = CSIPHY_POWER_DOWN;
@@ -527,6 +594,18 @@ static int msm_csiphy_release(struct csiphy_device *csiphy_dev, void *arg)
iounmap(csiphy_dev->clk_mux_base);
}
+ msm_camera_enable_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+ msm_camera_config_vreg(&csiphy_dev->pdev->dev,
+ csiphy_vreg_info, ARRAY_SIZE(csiphy_vreg_info),
+ NULL, 0, &csiphy_dev->csi_vdd, 0);
+
+ if (!IS_ERR_OR_NULL(csiphy_dev->reg_ptr)) {
+ regulator_disable(csiphy_dev->reg_ptr);
+ regulator_put(csiphy_dev->reg_ptr);
+ }
+
iounmap(csiphy_dev->base);
csiphy_dev->base = NULL;
csiphy_dev->csiphy_state = CSIPHY_POWER_DOWN;
@@ -630,6 +709,7 @@ static const struct v4l2_subdev_ops msm_csiphy_subdev_ops = {
static int csiphy_probe(struct platform_device *pdev)
{
struct csiphy_device *new_csiphy_dev;
+ uint32_t csi_vdd_voltage = 0;
int rc = 0;
new_csiphy_dev = kzalloc(sizeof(struct csiphy_device), GFP_KERNEL);
@@ -649,6 +729,19 @@ static int csiphy_probe(struct platform_device *pdev)
"cell-index", &pdev->id);
CDBG("%s: device id = %d\n", __func__, pdev->id);
+ rc = of_property_read_u32((&pdev->dev)->of_node,
+ "qcom,csi-vdd-voltage", &csi_vdd_voltage);
+ if (rc < 0) {
+ pr_err("%s:%d failed to read qcom,csi-vdd-voltage\n",
+ __func__, __LINE__);
+ return rc;
+ }
+ CDBG("%s:%d reading mipi_csi_vdd is %d\n", __func__, __LINE__,
+ csi_vdd_voltage);
+
+ csiphy_vreg_info[0].min_voltage = csi_vdd_voltage;
+ csiphy_vreg_info[0].max_voltage = csi_vdd_voltage;
+
new_csiphy_dev->mem = platform_get_resource_byname(pdev,
IORESOURCE_MEM, "csiphy");
if (!new_csiphy_dev->mem) {
diff --git a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
index ff97ab7..3c843a2 100644
--- a/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
+++ b/drivers/media/platform/msm/camera_v2/sensor/csiphy/msm_csiphy.h
@@ -47,6 +47,8 @@ struct csiphy_device {
int32_t ref_count;
uint16_t lane_mask[MAX_CSIPHY];
+ struct regulator *csi_vdd;
+ struct regulator *reg_ptr;
};
#define VIDIOC_MSM_CSIPHY_RELEASE \
--
cgit v1.1