summaryrefslogtreecommitdiff
path: root/mali_kbase/ipa
diff options
context:
space:
mode:
authorSidath Senanayake <sidaths@google.com>2018-01-22 13:55:38 +0100
committerSidath Senanayake <sidaths@google.com>2018-01-22 13:55:38 +0100
commite42736e67f7d84d329d9595b7393e6784c5b887f (patch)
tree03608c098294da4426551ec7127cfe0aa4f806ee /mali_kbase/ipa
parentdbd2655766535ffc24e24503a7279f3abfd40d7e (diff)
downloadgpu-e42736e67f7d84d329d9595b7393e6784c5b887f.tar.gz
Mali Bifrost DDK r10p0 KMD
Provenance: 27ee08eb4 (collaborate/EAC/b_r10p0) BX304L01B-BU-00000-r10p0-01rel0 BX304L06A-BU-00000-r10p0-01rel0 BX304X07X-BU-00000-r10p0-01rel0 Signed-off-by: Sidath Senanayake <sidaths@google.com> Change-Id: I31c8d66dad91c5b998f3e07757054c37c6aea963
Diffstat (limited to 'mali_kbase/ipa')
-rw-r--r--mali_kbase/ipa/Kbuild14
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa.c37
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa.h15
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_debugfs.c31
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_debugfs.h15
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_simple.c53
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_simple.h15
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c15
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h15
-rw-r--r--mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c15
10 files changed, 165 insertions, 60 deletions
diff --git a/mali_kbase/ipa/Kbuild b/mali_kbase/ipa/Kbuild
index 8e37f40..fcc079c 100644
--- a/mali_kbase/ipa/Kbuild
+++ b/mali_kbase/ipa/Kbuild
@@ -6,12 +6,18 @@
# Foundation, and any use by you of this program is subject to the terms
# of such GNU licence.
#
-# A copy of the licence is included with the program, and can also be obtained
-# from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
-# Boston, MA 02110-1301, USA.
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, you can access it online at
+# http://www.gnu.org/licenses/gpl-2.0.html.
+#
+# SPDX-License-Identifier: GPL-2.0
#
#
-
mali_kbase-y += \
ipa/mali_kbase_ipa_simple.o \
diff --git a/mali_kbase/ipa/mali_kbase_ipa.c b/mali_kbase/ipa/mali_kbase_ipa.c
index 1450c2c..d16069f 100644
--- a/mali_kbase/ipa/mali_kbase_ipa.c
+++ b/mali_kbase/ipa/mali_kbase_ipa.c
@@ -7,13 +7,18 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#include <linux/thermal.h>
#include <linux/devfreq_cooling.h>
#include <linux/of.h>
@@ -109,6 +114,10 @@ static struct device_node *get_model_dt_node(struct kbase_ipa_model *model)
snprintf(compat_string, sizeof(compat_string), "arm,%s",
model->ops->name);
+ /* of_find_compatible_node() will call of_node_put() on the root node,
+ * so take a reference on it first.
+ */
+ of_node_get(model->kbdev->dev->of_node);
model_dt_node = of_find_compatible_node(model->kbdev->dev->of_node,
NULL, compat_string);
if (!model_dt_node && !model->missing_dt_node_warning) {
@@ -130,6 +139,10 @@ int kbase_ipa_model_add_param_s32(struct kbase_ipa_model *model,
char *origin;
err = of_property_read_u32_array(model_dt_node, name, addr, num_elems);
+ /* We're done with model_dt_node now, so drop the reference taken in
+ * get_model_dt_node()/of_find_compatible_node().
+ */
+ of_node_put(model_dt_node);
if (err && dt_required) {
memset(addr, 0, sizeof(s32) * num_elems);
@@ -177,6 +190,12 @@ int kbase_ipa_model_add_param_string(struct kbase_ipa_model *model,
err = of_property_read_string(model_dt_node, name,
&string_prop_value);
+
+ /* We're done with model_dt_node now, so drop the reference taken in
+ * get_model_dt_node()/of_find_compatible_node().
+ */
+ of_node_put(model_dt_node);
+
if (err && dt_required) {
strncpy(addr, "", size - 1);
dev_warn(model->kbdev->dev,
@@ -198,7 +217,6 @@ int kbase_ipa_model_add_param_string(struct kbase_ipa_model *model,
err = kbase_ipa_model_param_add(model, name, addr, size,
PARAM_TYPE_STRING);
-
return err;
}
@@ -325,8 +343,11 @@ int kbase_ipa_init(struct kbase_device *kbdev)
ops = kbase_ipa_model_ops_find(kbdev, model_name);
kbdev->ipa.configured_model = kbase_ipa_init_model(kbdev, ops);
if (!kbdev->ipa.configured_model) {
- err = -EINVAL;
- goto end;
+ dev_warn(kbdev->dev,
+ "Failed to initialize ipa-model: \'%s\'\n"
+ "Falling back on default model\n",
+ model_name);
+ kbdev->ipa.configured_model = default_model;
}
} else {
kbdev->ipa.configured_model = default_model;
diff --git a/mali_kbase/ipa/mali_kbase_ipa.h b/mali_kbase/ipa/mali_kbase_ipa.h
index 469f33c..736399a 100644
--- a/mali_kbase/ipa/mali_kbase_ipa.h
+++ b/mali_kbase/ipa/mali_kbase_ipa.h
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#ifndef _KBASE_IPA_H_
#define _KBASE_IPA_H_
diff --git a/mali_kbase/ipa/mali_kbase_ipa_debugfs.c b/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
index d3ac7c3..029023c 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_debugfs.c
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#include <linux/debugfs.h>
#include <linux/list.h>
#include <linux/mutex.h>
@@ -56,14 +61,18 @@ static int param_int_set(void *data, u64 val)
struct kbase_ipa_model_param *param = data;
struct kbase_ipa_model *model = param->model;
s64 sval = (s64) val;
+ s32 old_val;
int err = 0;
if (sval < S32_MIN || sval > S32_MAX)
return -ERANGE;
mutex_lock(&param->model->kbdev->ipa.lock);
+ old_val = *param->addr.s32p;
*param->addr.s32p = val;
err = kbase_ipa_model_recalculate(model);
+ if (err < 0)
+ *param->addr.s32p = old_val;
mutex_unlock(&param->model->kbdev->ipa.lock);
return err;
@@ -92,6 +101,7 @@ static ssize_t param_string_set(struct file *file, const char __user *user_buf,
{
struct kbase_ipa_model_param *param = file->private_data;
struct kbase_ipa_model *model = param->model;
+ char *old_str = NULL;
ssize_t ret = count;
size_t buf_size;
int err;
@@ -103,6 +113,12 @@ static ssize_t param_string_set(struct file *file, const char __user *user_buf,
goto end;
}
+ old_str = kstrndup(param->addr.str, param->size, GFP_KERNEL);
+ if (!old_str) {
+ ret = -ENOMEM;
+ goto end;
+ }
+
buf_size = min(param->size - 1, count);
if (copy_from_user(param->addr.str, user_buf, buf_size)) {
ret = -EFAULT;
@@ -112,10 +128,13 @@ static ssize_t param_string_set(struct file *file, const char __user *user_buf,
param->addr.str[buf_size] = '\0';
err = kbase_ipa_model_recalculate(model);
- if (err < 0)
+ if (err < 0) {
ret = err;
+ strlcpy(param->addr.str, old_str, param->size);
+ }
end:
+ kfree(old_str);
mutex_unlock(&model->kbdev->ipa.lock);
return ret;
diff --git a/mali_kbase/ipa/mali_kbase_ipa_debugfs.h b/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
index f624de9..a983d9c 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
+++ b/mali_kbase/ipa/mali_kbase_ipa_debugfs.h
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#ifndef _KBASE_IPA_DEBUGFS_H_
#define _KBASE_IPA_DEBUGFS_H_
diff --git a/mali_kbase/ipa/mali_kbase_ipa_simple.c b/mali_kbase/ipa/mali_kbase_ipa_simple.c
index 70e08b3..639ade2 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_simple.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_simple.c
@@ -7,14 +7,20 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
+#include <uapi/linux/thermal.h>
#include <linux/thermal.h>
#ifdef CONFIG_DEVFREQ_THERMAL
#include <linux/devfreq_cooling.h>
@@ -91,7 +97,7 @@ struct kbase_ipa_model_simple_data {
u32 dynamic_coefficient;
u32 static_coefficient;
s32 ts[4];
- char tz_name[16];
+ char tz_name[THERMAL_NAME_LENGTH];
struct thermal_zone_device *gpu_tz;
struct task_struct *poll_temperature_thread;
int current_temperature;
@@ -283,20 +289,43 @@ static int kbase_simple_power_model_recalculate(struct kbase_ipa_model *model)
(struct kbase_ipa_model_simple_data *)model->model_data;
struct thermal_zone_device *tz;
+ lockdep_assert_held(&model->kbdev->ipa.lock);
+
if (!strnlen(model_data->tz_name, sizeof(model_data->tz_name))) {
- tz = NULL;
+ model_data->gpu_tz = NULL;
} else {
- tz = thermal_zone_get_zone_by_name(model_data->tz_name);
+ char tz_name[THERMAL_NAME_LENGTH];
+
+ strlcpy(tz_name, model_data->tz_name, sizeof(tz_name));
+
+ /* Release ipa.lock so that thermal_list_lock is not acquired
+ * with ipa.lock held, thereby avoid lock ordering violation
+ * lockdep warning. The warning comes as a chain of locks
+ * ipa.lock --> thermal_list_lock --> tz->lock gets formed
+ * on registering devfreq cooling device when probe method
+ * of mali platform driver is invoked.
+ */
+ mutex_unlock(&model->kbdev->ipa.lock);
+ tz = thermal_zone_get_zone_by_name(tz_name);
+ mutex_lock(&model->kbdev->ipa.lock);
if (IS_ERR_OR_NULL(tz)) {
pr_warn_ratelimited("Error %ld getting thermal zone \'%s\', not yet ready?\n",
- PTR_ERR(tz), model_data->tz_name);
- tz = NULL;
+ PTR_ERR(tz), tz_name);
return -EPROBE_DEFER;
}
- }
- ACCESS_ONCE(model_data->gpu_tz) = tz;
+ /* Check if another thread raced against us & updated the
+ * thermal zone name string. Update the gpu_tz pointer only if
+ * the name string did not change whilst we retrieved the new
+ * thermal_zone_device pointer, otherwise model_data->tz_name &
+ * model_data->gpu_tz would become inconsistent with each other.
+ * The below check will succeed only for the thread which last
+ * updated the name string.
+ */
+ if (strncmp(tz_name, model_data->tz_name, sizeof(tz_name)) == 0)
+ model_data->gpu_tz = tz;
+ }
return 0;
}
diff --git a/mali_kbase/ipa/mali_kbase_ipa_simple.h b/mali_kbase/ipa/mali_kbase_ipa_simple.h
index e78d617..fed67d5 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_simple.h
+++ b/mali_kbase/ipa/mali_kbase_ipa_simple.h
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#ifndef _KBASE_IPA_SIMPLE_H_
#define _KBASE_IPA_SIMPLE_H_
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
index 9b9fa0e..b9a9e57 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.c
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#include "mali_kbase_ipa_vinstr_common.h"
#if MALI_UNIT_TEST
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
index d212c87..7233642 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_common.h
@@ -7,14 +7,19 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#ifndef _KBASE_IPA_VINSTR_COMMON_H_
#define _KBASE_IPA_VINSTR_COMMON_H_
diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
index 4e4c059..d07fb36 100644
--- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
+++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c
@@ -7,13 +7,18 @@
* Foundation, and any use by you of this program is subject to the terms
* of such GNU licence.
*
- * A copy of the licence is included with the program, and can also be obtained
- * from Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
- * Boston, MA 02110-1301, USA.
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, you can access it online at
+ * http://www.gnu.org/licenses/gpl-2.0.html.
+ *
+ * SPDX-License-Identifier: GPL-2.0
*
*/
-
-
#include <linux/thermal.h>
#include "mali_kbase_ipa_vinstr_common.h"