From f02489b4c8dde503d9abe2eef2ad2c63d797af96 Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Wed, 11 Mar 2020 10:58:06 -0600 Subject: [PATCH 1/2] msm: kgsl: Restrict gpu governors to gpu devfreq devices These governors should fail if being set for any device other than the gpu device. Do this by checking that the devfreq device for which this governor is being set for has the gpu device as it's parent device. Change-Id: I391557c0d52a1f4ffba70e010401a0769587dea0 Signed-off-by: Harshdeep Dhatt --- drivers/gpu/msm/governor_gpubw_mon.c | 3 +++ drivers/gpu/msm/governor_msm_adreno_tz.c | 15 ++++++++++----- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/msm/governor_gpubw_mon.c b/drivers/gpu/msm/governor_gpubw_mon.c index 8813cc60c921..50695088900a 100644 --- a/drivers/gpu/msm/governor_gpubw_mon.c +++ b/drivers/gpu/msm/governor_gpubw_mon.c @@ -197,6 +197,9 @@ static int devfreq_gpubw_event_handler(struct devfreq *devfreq, int result = 0; unsigned long freq; + if (strcmp(dev_name(devfreq->dev.parent), "kgsl-busmon")) + return -EINVAL; + mutex_lock(&devfreq->lock); freq = devfreq->previous_freq; switch (event) { diff --git a/drivers/gpu/msm/governor_msm_adreno_tz.c b/drivers/gpu/msm/governor_msm_adreno_tz.c index 0a363218112f..360ff0cc91d5 100644 --- a/drivers/gpu/msm/governor_msm_adreno_tz.c +++ b/drivers/gpu/msm/governor_msm_adreno_tz.c @@ -1,12 +1,13 @@ // SPDX-License-Identifier: GPL-2.0-only /* - * Copyright (c) 2010-2019, The Linux Foundation. All rights reserved. + * Copyright (c) 2010-2020, The Linux Foundation. All rights reserved. */ #include #include #include #include #include +#include #include #include #include @@ -505,11 +506,15 @@ static int tz_suspend(struct devfreq *devfreq) static int tz_handler(struct devfreq *devfreq, unsigned int event, void *data) { int result; + struct msm_adreno_extended_profile *gpu_profile; + struct device_node *node = devfreq->dev.parent->of_node; - struct msm_adreno_extended_profile *gpu_profile = container_of( - (devfreq->profile), - struct msm_adreno_extended_profile, - profile); + if (!of_device_is_compatible(node, "qcom,kgsl-3d0")) + return -EINVAL; + + gpu_profile = container_of((devfreq->profile), + struct msm_adreno_extended_profile, + profile); switch (event) { case DEVFREQ_GOV_START: From 85dbbd221a27b98c33e1ddbe1d473e8b29ca185c Mon Sep 17 00:00:00 2001 From: Harshdeep Dhatt Date: Fri, 17 Apr 2020 12:39:11 -0600 Subject: [PATCH 2/2] msm: kgsl: Make the gpubw governor immutable The kgsl-busmon devfreq device is only set up to work with the gpubw governor. So make it immutable to avoid unexpected failures when re-assigning a different governor. Change-Id: I545fa12efebf80aa38ff6270488f088fdaac2b84 Signed-off-by: Harshdeep Dhatt --- drivers/gpu/msm/governor_gpubw_mon.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/gpu/msm/governor_gpubw_mon.c b/drivers/gpu/msm/governor_gpubw_mon.c index 50695088900a..0b8cf34c707f 100644 --- a/drivers/gpu/msm/governor_gpubw_mon.c +++ b/drivers/gpu/msm/governor_gpubw_mon.c @@ -236,6 +236,7 @@ static struct devfreq_governor devfreq_gpubw = { .name = "gpubw_mon", .get_target_freq = devfreq_gpubw_get_target, .event_handler = devfreq_gpubw_event_handler, + .immutable = 1, }; static int __init devfreq_gpubw_init(void)