From eeb252147aef2241d03df81514792788970d30e7 Mon Sep 17 00:00:00 2001 From: Raghu Ananya Arabolu Date: Sun, 17 May 2020 11:36:08 -0700 Subject: [PATCH] msm: kgsl: 'qcom,kgsl-3d0' device does not need to get regulators The vddcx-supply and vdd-supply properties are not defined by the 'qcom,kgsl-3d0' device in GPU DTSI since the corresponding regulators are not required by the device. Invoking devm_regulator_get for vdd and vddcx supply results in obtaining a dummy supply. Only invoke devm_regulator_get for 'qcom,kgsl-3d0' device when the corresponding supply properties are defined in the DTSI. Change-Id: Ie3ae363e5644ff123bc984359abef9af2dc102d9 Signed-off-by: Raghu Ananya Arabolu --- drivers/gpu/msm/adreno.c | 4 ++-- drivers/gpu/msm/kgsl_pwrctrl.c | 9 ++++++--- drivers/gpu/msm/kgsl_util.c | 5 ++++- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index 49e09c641b1c..96863da68b5b 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -1783,11 +1783,11 @@ static bool regulators_left_on(struct kgsl_device *device) if (gmu_core_gpmu_isenabled(device)) return false; - if (!IS_ERR(pwr->cx_gdsc)) + if (!IS_ERR_OR_NULL(pwr->cx_gdsc)) if (regulator_is_enabled(pwr->cx_gdsc)) return true; - if (!IS_ERR(pwr->gx_gdsc)) + if (!IS_ERR_OR_NULL(pwr->gx_gdsc)) return regulator_is_enabled(pwr->gx_gdsc); return false; diff --git a/drivers/gpu/msm/kgsl_pwrctrl.c b/drivers/gpu/msm/kgsl_pwrctrl.c index cb2335a93276..692451e863b3 100644 --- a/drivers/gpu/msm/kgsl_pwrctrl.c +++ b/drivers/gpu/msm/kgsl_pwrctrl.c @@ -1305,7 +1305,7 @@ static int enable_regulator(struct device *dev, struct regulator *regulator, { int ret; - if (IS_ERR(regulator)) + if (IS_ERR_OR_NULL(regulator)) return 0; ret = regulator_enable(regulator); @@ -1547,8 +1547,11 @@ int kgsl_pwrctrl_init(struct kgsl_device *device) _isense_clk_set_rate(pwr, pwr->num_pwrlevels - 1); - pwr->cx_gdsc = devm_regulator_get(&pdev->dev, "vddcx"); - pwr->gx_gdsc = devm_regulator_get(&pdev->dev, "vdd"); + if (of_property_read_bool(pdev->dev.of_node, "vddcx-supply")) + pwr->cx_gdsc = devm_regulator_get(&pdev->dev, "vddcx"); + + if (of_property_read_bool(pdev->dev.of_node, "vdd-supply")) + pwr->gx_gdsc = devm_regulator_get(&pdev->dev, "vdd"); pwr->power_flags = 0; diff --git a/drivers/gpu/msm/kgsl_util.c b/drivers/gpu/msm/kgsl_util.c index fbee7a5ace33..d7ddc602f0d4 100644 --- a/drivers/gpu/msm/kgsl_util.c +++ b/drivers/gpu/msm/kgsl_util.c @@ -1,6 +1,6 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2020, The Linux Foundation. All rights reserved. */ @@ -17,6 +17,9 @@ bool kgsl_regulator_disable_wait(struct regulator *reg, u32 timeout) { ktime_t tout = ktime_add_us(ktime_get(), timeout * 1000); + if (IS_ERR_OR_NULL(reg)) + return true; + regulator_disable(reg); for (;;) {