summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWookey <wookey@debian.org>2017-10-25 17:50:01 +0100
committerWookey <wookey@debian.org>2017-10-25 18:00:27 +0100
commit2cd839bb78d0007494ab0468b6398adb6054bc91 (patch)
tree5aad425b4e65866bdb908dc21d294b9d71655395
parenta497438fa4980183a02089c3876cc2daeae105c2 (diff)
Update to mali-midgard-16.0 as released
-rw-r--r--README9
-rw-r--r--debian/README.Debian15
-rw-r--r--debian/copyright12
-rw-r--r--debian/dkms4
-rwxr-xr-xdebian/postinst2
-rwxr-xr-xdebian/prerm2
-rw-r--r--debian/source/format1
-rwxr-xr-xmali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.c169
-rwxr-xr-xmali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.h47
9 files changed, 253 insertions, 8 deletions
diff --git a/README b/README
new file mode 100644
index 0000000..20b324b
--- /dev/null
+++ b/README
@@ -0,0 +1,9 @@
+This repository contains the out-of-tree Linux kernel driver for the ARM Mali
+Midgard GPU. It is based on the r16p0 release, called 16.0 in this Debian DKMS
+package. It also contains some patches to make it work with mainline device
+tree bindings backported to v4.9 kernel. Newer kernel versions are not
+supported in this driver version.
+
+Tested on Firefly rk3288 board with Debian Jessie and Stretch using kernel
+package linux-image-4.9.0-3-armmp_4.9.30-2+deb9u3_armhf.deb from Stretch and
+its backport to Jessie. \ No newline at end of file
diff --git a/debian/README.Debian b/debian/README.Debian
new file mode 100644
index 0000000..3a23741
--- /dev/null
+++ b/debian/README.Debian
@@ -0,0 +1,15 @@
+This package is a kernel driver for the ARM Mali GPU, supporting the
+6xx and 7xx series GPUs (first released in 2012 and 2015
+respectively). A corresponding binary userspace driver (separately
+packaged) is also needed to display graphics.
+
+In theory separate drivers are needed for midgard (6xx) GPUs and
+bifrost (7xx) GPUs, however currently the drivers are identical so
+this driver covers both. This could change in the future.
+
+Look up your hardware on
+https://en.wikipedia.org/wiki/Mali_(GPU)#Implementations if you are
+not sure what you have.
+
+https://wiki.debian.org/MaliGraphics has further details of the Debian
+packaging, and supported hardware.
diff --git a/debian/copyright b/debian/copyright
index 6671252..12c64c1 100644
--- a/debian/copyright
+++ b/debian/copyright
@@ -3,18 +3,22 @@ Source: http://malideveloper.arm.com/resources/drivers/open-source-mali-midgard-
Files: *
Copyright: 2015-2017 ARM Limited
-License: GPL2
+License: GPL-2
Files: debian/*
Copyright: 2017 Wookey <wookey@wookware.org>
-License: GPL2
+License: GPL-2
-Licence: GPL2
+License: GPL-2
This program is free software and is provided to you under the terms of the
GNU General Public License version 2 as published by the Free Software
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.
+ .
+ On Debian systems, the full text of the GNU General Public
+ License version 2 can be found in the file
+ '/usr/share/common-licenses/GPL-2'. \ No newline at end of file
diff --git a/debian/dkms b/debian/dkms
index b73916c..2bddbd1 100644
--- a/debian/dkms
+++ b/debian/dkms
@@ -1,7 +1,7 @@
PACKAGE_VERSION="#MODULE_VERSION#"
PACKAGE_NAME="mali-midgard"
BUILT_MODULE_NAME[0]="mali_kbase"
-BUILD_EXCLUSIVE_ARCH="armhf|armel"
+BUILD_EXCLUSIVE_ARCH="armhf|armel|armv7l"
MAKE[0]="make SCONS_CFLAGS='\
-DCONFIG_MALI_MIDGARD=m \
-DCONFIG_MALI_DEVFREQ=y \
@@ -13,7 +13,7 @@ CONFIG_MALI_DEVFREQ=y \
CONFIG_MALI_EXPERT=y \
CONFIG_MALI_BACKEND=gpu \
CONFIG_MALI_PLATFORM_DEVICETREE=y"
-DEST_MODULE_LOCATION[0]="/kernel/drivers/gpu/"
+DEST_MODULE_LOCATION[0]="/extra/"
AUTOINSTALL="yes"
PATCH[0]=0001-gpu-midgard-replace-device-tree-compatible-strings.patch
PATCH[1]=0002-gpu-midgard-drop-clk_mali-name.patch
diff --git a/debian/postinst b/debian/postinst
index c8e8151..de67541 100755
--- a/debian/postinst
+++ b/debian/postinst
@@ -44,6 +44,6 @@ esac
# dh_installdeb will replace this with shell code automatically
# generated by other debhelper scripts.
-
+#DEBHELPER#
exit 0
diff --git a/debian/prerm b/debian/prerm
index bea671c..e54b048 100755
--- a/debian/prerm
+++ b/debian/prerm
@@ -21,7 +21,7 @@ case "$1" in
;;
esac
-
+#DEBHELPER#
exit 0
diff --git a/debian/source/format b/debian/source/format
new file mode 100644
index 0000000..163aaf8
--- /dev/null
+++ b/debian/source/format
@@ -0,0 +1 @@
+3.0 (quilt)
diff --git a/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.c b/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.c
new file mode 100755
index 0000000..d965033
--- /dev/null
+++ b/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.c
@@ -0,0 +1,169 @@
+/*
+ *
+ * (C) COPYRIGHT 2011-2016 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * 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.
+ *
+ */
+
+
+
+#include <linux/devfreq_cooling.h>
+#include <linux/thermal.h>
+#include <linux/of.h>
+#include <mali_kbase.h>
+#include <mali_kbase_defs.h>
+#include <backend/gpu/mali_kbase_power_model_simple.h>
+
+/*
+ * This model is primarily designed for the Juno platform. It may not be
+ * suitable for other platforms.
+ */
+
+#define FALLBACK_STATIC_TEMPERATURE 55000
+
+static u32 dynamic_coefficient;
+static u32 static_coefficient;
+static s32 ts[4];
+static struct thermal_zone_device *gpu_tz;
+
+static unsigned long model_static_power(unsigned long voltage)
+{
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 3, 0)
+ unsigned long temperature;
+#else
+ int temperature;
+#endif
+ unsigned long temp;
+ unsigned long temp_squared, temp_cubed, temp_scaling_factor;
+ const unsigned long voltage_cubed = (voltage * voltage * voltage) >> 10;
+
+ if (gpu_tz) {
+ int ret;
+
+ ret = gpu_tz->ops->get_temp(gpu_tz, &temperature);
+ if (ret) {
+ pr_warn_ratelimited("Error reading temperature for gpu thermal zone: %d\n",
+ ret);
+ temperature = FALLBACK_STATIC_TEMPERATURE;
+ }
+ } else {
+ temperature = FALLBACK_STATIC_TEMPERATURE;
+ }
+
+ /* Calculate the temperature scaling factor. To be applied to the
+ * voltage scaled power.
+ */
+ temp = temperature / 1000;
+ temp_squared = temp * temp;
+ temp_cubed = temp_squared * temp;
+ temp_scaling_factor =
+ (ts[3] * temp_cubed)
+ + (ts[2] * temp_squared)
+ + (ts[1] * temp)
+ + ts[0];
+
+ return (((static_coefficient * voltage_cubed) >> 20)
+ * temp_scaling_factor)
+ / 1000000;
+}
+
+static unsigned long model_dynamic_power(unsigned long freq,
+ unsigned long voltage)
+{
+ /* The inputs: freq (f) is in Hz, and voltage (v) in mV.
+ * The coefficient (c) is in mW/(MHz mV mV).
+ *
+ * This function calculates the dynamic power after this formula:
+ * Pdyn (mW) = c (mW/(MHz*mV*mV)) * v (mV) * v (mV) * f (MHz)
+ */
+ const unsigned long v2 = (voltage * voltage) / 1000; /* m*(V*V) */
+ const unsigned long f_mhz = freq / 1000000; /* MHz */
+
+ return (dynamic_coefficient * v2 * f_mhz) / 1000000; /* mW */
+}
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
+struct devfreq_cooling_ops power_model_simple_ops = {
+#else
+struct devfreq_cooling_power power_model_simple_ops = {
+#endif
+ .get_static_power = model_static_power,
+ .get_dynamic_power = model_dynamic_power,
+};
+
+int kbase_power_model_simple_init(struct kbase_device *kbdev)
+{
+ struct device_node *power_model_node;
+ const char *tz_name;
+ u32 static_power, dynamic_power;
+ u32 voltage, voltage_squared, voltage_cubed, frequency;
+
+ power_model_node = of_get_child_by_name(kbdev->dev->of_node,
+ "power_model");
+ if (!power_model_node) {
+ dev_err(kbdev->dev, "could not find power_model node\n");
+ return -ENODEV;
+ }
+ if (!of_device_is_compatible(power_model_node,
+ "arm,mali-simple-power-model")) {
+ dev_err(kbdev->dev, "power_model incompatible with simple power model\n");
+ return -ENODEV;
+ }
+
+ if (of_property_read_string(power_model_node, "thermal-zone",
+ &tz_name)) {
+ dev_err(kbdev->dev, "ts in power_model not available\n");
+ return -EINVAL;
+ }
+
+ gpu_tz = thermal_zone_get_zone_by_name(tz_name);
+ if (IS_ERR(gpu_tz)) {
+ pr_warn_ratelimited("Error getting gpu thermal zone (%ld), not yet ready?\n",
+ PTR_ERR(gpu_tz));
+ gpu_tz = NULL;
+
+ return -EPROBE_DEFER;
+ }
+
+ if (of_property_read_u32(power_model_node, "static-power",
+ &static_power)) {
+ dev_err(kbdev->dev, "static-power in power_model not available\n");
+ return -EINVAL;
+ }
+ if (of_property_read_u32(power_model_node, "dynamic-power",
+ &dynamic_power)) {
+ dev_err(kbdev->dev, "dynamic-power in power_model not available\n");
+ return -EINVAL;
+ }
+ if (of_property_read_u32(power_model_node, "voltage",
+ &voltage)) {
+ dev_err(kbdev->dev, "voltage in power_model not available\n");
+ return -EINVAL;
+ }
+ if (of_property_read_u32(power_model_node, "frequency",
+ &frequency)) {
+ dev_err(kbdev->dev, "frequency in power_model not available\n");
+ return -EINVAL;
+ }
+ voltage_squared = (voltage * voltage) / 1000;
+ voltage_cubed = voltage * voltage * voltage;
+ static_coefficient = (static_power << 20) / (voltage_cubed >> 10);
+ dynamic_coefficient = (((dynamic_power * 1000) / voltage_squared)
+ * 1000) / frequency;
+
+ if (of_property_read_u32_array(power_model_node, "ts", (u32 *)ts, 4)) {
+ dev_err(kbdev->dev, "ts in power_model not available\n");
+ return -EINVAL;
+ }
+
+ return 0;
+}
+
diff --git a/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.h b/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.h
new file mode 100755
index 0000000..9b5e69a
--- /dev/null
+++ b/mali-midgard-16.0/backend/gpu/mali_kbase_power_model_simple.h
@@ -0,0 +1,47 @@
+/*
+ *
+ * (C) COPYRIGHT 2014-2016 ARM Limited. All rights reserved.
+ *
+ * This program is free software and is provided to you under the terms of the
+ * GNU General Public License version 2 as published by the Free Software
+ * 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.
+ *
+ */
+
+
+
+#ifndef _BASE_POWER_MODEL_SIMPLE_H_
+#define _BASE_POWER_MODEL_SIMPLE_H_
+
+/**
+ * kbase_power_model_simple_init - Initialise the simple power model
+ * @kbdev: Device pointer
+ *
+ * The simple power model estimates power based on current voltage, temperature,
+ * and coefficients read from device tree. It does not take utilization into
+ * account.
+ *
+ * The power model requires coefficients from the power_model node in device
+ * tree. The absence of this node will prevent the model from functioning, but
+ * should not prevent the rest of the driver from running.
+ *
+ * Return: 0 on success
+ * -ENOSYS if the power_model node is not present in device tree
+ * -EPROBE_DEFER if the thermal zone specified in device tree is not
+ * currently available
+ * Any other negative value on failure
+ */
+int kbase_power_model_simple_init(struct kbase_device *kbdev);
+
+#if LINUX_VERSION_CODE < KERNEL_VERSION(4, 4, 0)
+extern struct devfreq_cooling_ops power_model_simple_ops;
+#else
+extern struct devfreq_cooling_power power_model_simple_ops;
+#endif
+
+#endif /* _BASE_POWER_MODEL_SIMPLE_H_ */