diff options
53 files changed, 489 insertions, 698 deletions
diff --git a/mali_kbase/Kbuild b/mali_kbase/Kbuild index a9b23c2..49d016e 100644 --- a/mali_kbase/Kbuild +++ b/mali_kbase/Kbuild @@ -15,14 +15,14 @@ # Driver version string which is returned to userspace via an ioctl -MALI_RELEASE_NAME ?= "r7p0-01rel0" +MALI_RELEASE_NAME ?= "r8p0-01rel0" # Paths required for build KBASE_PATH = $(src) KBASE_PLATFORM_PATH = $(KBASE_PATH)/platform_dummy UMP_PATH = $(src)/../../../base -ifeq ($(CONFIG_MALI_ERROR_INJECTION),y) +ifeq ($(CONFIG_MALI_ERROR_INJECT),y) MALI_ERROR_INJECT_ON = 1 endif @@ -34,6 +34,7 @@ MALI_ERROR_INJECT_ON ?= 0 MALI_MOCK_TEST ?= 0 MALI_COVERAGE ?= 0 MALI_INSTRUMENTATION_LEVEL ?= 0 +CONFIG_MALI_PLATFORM_NAME ?= "devicetree" # This workaround is for what seems to be a compiler bug we observed in # GCC 4.7 on AOSP 4.3. The bug caused an intermittent failure compiling # the "_Pragma" syntax, where an error message is returned: @@ -60,10 +61,10 @@ DEFINES = \ ifeq ($(KBUILD_EXTMOD),) # in-tree -DEFINES +=-DMALI_KBASE_THIRDPARTY_PATH=../../$(src)/platform/$(CONFIG_MALI_PLATFORM_THIRDPARTY_NAME) +DEFINES +=-DMALI_KBASE_PLATFORM_PATH=../../$(src)/platform/$(CONFIG_MALI_PLATFORM_NAME) else # out-of-tree -DEFINES +=-DMALI_KBASE_THIRDPARTY_PATH=$(src)/platform/$(CONFIG_MALI_PLATFORM_THIRDPARTY_NAME) +DEFINES +=-DMALI_KBASE_PLATFORM_PATH=$(src)/platform/$(CONFIG_MALI_PLATFORM_NAME) endif DEFINES += -I$(srctree)/drivers/staging/android @@ -128,45 +129,17 @@ endif ccflags-y += -I$(KBASE_PATH) -ifeq ($(CONFIG_MALI_PLATFORM_FAKE),y) - SRC += mali_kbase_platform_fake.c - - ifeq ($(CONFIG_MALI_PLATFORM_VEXPRESS),y) - SRC += platform/vexpress/mali_kbase_config_vexpress.c \ - platform/vexpress/mali_kbase_cpu_vexpress.c - ccflags-y += -I$(src)/platform/vexpress - endif - - ifeq ($(CONFIG_MALI_PLATFORM_RTSM_VE),y) - SRC += platform/rtsm_ve/mali_kbase_config_vexpress.c - ccflags-y += -I$(src)/platform/rtsm_ve - endif - - ifeq ($(CONFIG_MALI_PLATFORM_VEXPRESS_1XV7_A57),y) - SRC += platform/vexpress_1xv7_a57/mali_kbase_config_vexpress.c - ccflags-y += -I$(src)/platform/vexpress_1xv7_a57 - endif - - ifeq ($(CONFIG_MALI_PLATFORM_VEXPRESS_6XVIRTEX7_10MHZ),y) - SRC += platform/vexpress_6xvirtex7_10mhz/mali_kbase_config_vexpress.c \ - platform/vexpress_6xvirtex7_10mhz/mali_kbase_cpu_vexpress.c - ccflags-y += -I$(src)/platform/vexpress_6xvirtex7_10mhz - endif -endif # CONFIG_MALI_PLATFORM_FAKE=y - # Tell the Linux build system from which .o file to create the kernel module obj-$(CONFIG_MALI_MIDGARD) += mali_kbase.o # Tell the Linux build system to enable building of our .c files mali_kbase-y := $(SRC:.c=.o) -ifeq ($(CONFIG_MALI_PLATFORM_THIRDPARTY),y) - # Kconfig passes in the name with quotes for in-tree builds - remove them. - platform_name := $(shell echo $(CONFIG_MALI_PLATFORM_THIRDPARTY_NAME)) - MALI_PLATFORM_THIRDPARTY_DIR := platform/$(platform_name) - ccflags-y += -I$(src)/$(MALI_PLATFORM_THIRDPARTY_DIR) - include $(src)/$(MALI_PLATFORM_THIRDPARTY_DIR)/Kbuild -endif +# Kconfig passes in the name with quotes for in-tree builds - remove them. +platform_name := $(shell echo $(CONFIG_MALI_PLATFORM_NAME)) +MALI_PLATFORM_DIR := platform/$(platform_name) +ccflags-y += -I$(src)/$(MALI_PLATFORM_DIR) +include $(src)/$(MALI_PLATFORM_DIR)/Kbuild ifeq ($(CONFIG_MALI_DEVFREQ),y) ifeq ($(CONFIG_DEVFREQ_THERMAL),y) @@ -185,34 +158,17 @@ mali_kbase-$(CONFIG_SYNC_FILE) += \ mali_kbase_sync_common.o \ mali_kbase_fence.o -MALI_BACKEND_PATH ?= backend -CONFIG_MALI_BACKEND ?= gpu -CONFIG_MALI_BACKEND_REAL ?= $(CONFIG_MALI_BACKEND) - ifeq ($(MALI_MOCK_TEST),1) -ifeq ($(CONFIG_MALI_BACKEND_REAL),gpu) # Test functionality mali_kbase-y += tests/internal/src/mock/mali_kbase_pm_driver_mock.o endif -endif -include $(src)/$(MALI_BACKEND_PATH)/$(CONFIG_MALI_BACKEND_REAL)/Kbuild +include $(src)/backend/gpu/Kbuild mali_kbase-y += $(BACKEND:.c=.o) -ccflags-y += -I$(src)/$(MALI_BACKEND_PATH)/$(CONFIG_MALI_BACKEND_REAL) -subdir-ccflags-y += -I$(src)/$(MALI_BACKEND_PATH)/$(CONFIG_MALI_BACKEND_REAL) - -# Default to devicetree platform if neither a fake platform or a thirdparty -# platform is configured. -ifeq ($(CONFIG_MALI_PLATFORM_THIRDPARTY)$(CONFIG_MALI_PLATFORM_FAKE),) -CONFIG_MALI_PLATFORM_DEVICETREE := y -endif - -mali_kbase-$(CONFIG_MALI_PLATFORM_DEVICETREE) += \ - platform/devicetree/mali_kbase_runtime_pm.o \ - platform/devicetree/mali_kbase_config_devicetree.o -ccflags-$(CONFIG_MALI_PLATFORM_DEVICETREE) += -I$(src)/platform/devicetree +ccflags-y += -I$(src)/backend/gpu +subdir-ccflags-y += -I$(src)/backend/gpu # For kutf and mali_kutf_irq_latency_test obj-$(CONFIG_MALI_KUTF) += tests/ diff --git a/mali_kbase/Kconfig b/mali_kbase/Kconfig index af91dd7..dc78f84 100644 --- a/mali_kbase/Kconfig +++ b/mali_kbase/Kconfig @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2012-2015 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2012-2017 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 @@ -36,7 +36,7 @@ config MALI_GATOR_SUPPORT config MALI_MIDGARD_DVFS bool "Enable legacy DVFS" - depends on MALI_MIDGARD && !MALI_DEVFREQ && !MALI_PLATFORM_DEVICETREE + depends on MALI_MIDGARD && !MALI_DEVFREQ default n help Choose this option to enable legacy DVFS in the Mali Midgard DDK. @@ -69,6 +69,15 @@ config MALI_DMA_FENCE This option should only be enabled if KDS is not present and the Linux Kernel has built in support for DMA_BUF fences. +config MALI_PLATFORM_NAME + depends on MALI_MIDGARD + string "Platform name" + default "devicetree" + help + Enter the name of the desired platform configuration directory to + include in the build. 'platform/$(MALI_PLATFORM_NAME)/Kbuild' must + exist. + # MALI_EXPERT configuration options menuconfig MALI_EXPERT @@ -105,61 +114,6 @@ config MALI_PRFCNT_SET_SECONDARY If unsure, say N. -config MALI_PLATFORM_FAKE - bool "Enable fake platform device support" - depends on MALI_MIDGARD && MALI_EXPERT - default n - help - When you start to work with the Mali Midgard series device driver the platform-specific code of - the Linux kernel for your platform may not be complete. In this situation the kernel device driver - supports creating the platform device outside of the Linux platform-specific code. - Enable this option if would like to use a platform device configuration from within the device driver. - -choice - prompt "Platform configuration" - depends on MALI_MIDGARD && MALI_EXPERT - default MALI_PLATFORM_DEVICETREE - help - Select the SOC platform that contains a Mali Midgard GPU - -config MALI_PLATFORM_DEVICETREE - bool "Device Tree platform" - depends on OF - help - Select this option to use Device Tree with the Mali driver. - - When using this option the Mali driver will get the details of the - GPU hardware from the Device Tree. This means that the same driver - binary can run on multiple platforms as long as all the GPU hardware - details are described in the device tree. - - Device Tree is the recommended method for the Mali driver platform - integration. - -config MALI_PLATFORM_VEXPRESS - depends on ARCH_VEXPRESS && (ARCH_VEXPRESS_CA9X4 || ARCH_VEXPRESS_CA15X4) - bool "Versatile Express" -config MALI_PLATFORM_VEXPRESS_VIRTEX7_40MHZ - depends on ARCH_VEXPRESS && (ARCH_VEXPRESS_CA9X4 || ARCH_VEXPRESS_CA15X4) - bool "Versatile Express w/Virtex7 @ 40Mhz" -config MALI_PLATFORM_GOLDFISH - depends on ARCH_GOLDFISH - bool "Android Goldfish virtual CPU" -config MALI_PLATFORM_PBX - depends on ARCH_REALVIEW && REALVIEW_EB_A9MP && MACH_REALVIEW_PBX - bool "Realview PBX-A9" -config MALI_PLATFORM_THIRDPARTY - bool "Third Party Platform" -endchoice - -config MALI_PLATFORM_THIRDPARTY_NAME - depends on MALI_MIDGARD && MALI_PLATFORM_THIRDPARTY && MALI_EXPERT - string "Third party platform name" - help - Enter the name of a third party platform that is supported. The third part configuration - file must be in midgard/config/tpip/mali_kbase_config_xxx.c where xxx is the name - specified here. - config MALI_DEBUG bool "Debug build" depends on MALI_MIDGARD && MALI_EXPERT @@ -220,21 +174,6 @@ config MALI_SYSTEM_TRACE minimal overhead when not in use. Enable only if you know what you are doing. -config MALI_GPU_MMU_AARCH64 - bool "Use AArch64 page tables" - depends on MALI_MIDGARD && MALI_EXPERT - default n - help - Use AArch64 format page tables for the GPU instead of LPAE-style. - The two formats have the same functionality and performance but a - future GPU may deprecate or remove the legacy LPAE-style format. - - The LPAE-style format is supported on all Midgard and current Bifrost - GPUs. Enabling AArch64 format restricts the driver to only supporting - Bifrost GPUs. - - If in doubt, say N. - config MALI_2MB_ALLOC bool "Attempt to allocate 2MB pages" depends on MALI_MIDGARD && MALI_EXPERT diff --git a/mali_kbase/Makefile b/mali_kbase/Makefile index 9aa242c..26522d5 100644 --- a/mali_kbase/Makefile +++ b/mali_kbase/Makefile @@ -26,7 +26,7 @@ ifeq ($(MALI_UNIT_TEST), 1) EXTRA_SYMBOLS += $(KBASE_PATH_RELATIVE)/tests/internal/src/kernel_assert_module/linux/Module.symvers endif -ifeq ($(MALI_BUS_LOG), 1) +ifeq ($(CONFIG_MALI_FPGA_BUS_LOGGER),y) #Add bus logger symbols EXTRA_SYMBOLS += $(BUSLOG_PATH_RELATIVE)/drivers/base/bus_logger/Module.symvers endif diff --git a/mali_kbase/backend/gpu/mali_kbase_gpu.c b/mali_kbase/backend/gpu/mali_kbase_gpu.c index d578fd7..3b78100 100644 --- a/mali_kbase/backend/gpu/mali_kbase_gpu.c +++ b/mali_kbase/backend/gpu/mali_kbase_gpu.c @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2014-2016 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2014-2017 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 @@ -43,19 +43,19 @@ int kbase_backend_early_init(struct kbase_device *kbdev) /* We're done accessing the GPU registers for now. */ kbase_pm_register_access_disable(kbdev); - err = kbase_hwaccess_pm_init(kbdev); - if (err) - goto fail_pm; - err = kbase_install_interrupts(kbdev); if (err) goto fail_interrupts; + err = kbase_hwaccess_pm_init(kbdev); + if (err) + goto fail_pm; + return 0; -fail_interrupts: - kbase_hwaccess_pm_term(kbdev); fail_pm: + kbase_release_interrupts(kbdev); +fail_interrupts: kbasep_platform_device_term(kbdev); return err; @@ -63,8 +63,8 @@ fail_pm: void kbase_backend_early_term(struct kbase_device *kbdev) { - kbase_release_interrupts(kbdev); kbase_hwaccess_pm_term(kbdev); + kbase_release_interrupts(kbdev); kbasep_platform_device_term(kbdev); } diff --git a/mali_kbase/backend/gpu/mali_kbase_jm_hw.c b/mali_kbase/backend/gpu/mali_kbase_jm_hw.c index 92c36d1..be88ec8 100644 --- a/mali_kbase/backend/gpu/mali_kbase_jm_hw.c +++ b/mali_kbase/backend/gpu/mali_kbase_jm_hw.c @@ -696,13 +696,11 @@ void kbase_backend_jm_kill_jobs_from_kctx(struct kbase_context *kctx) { unsigned long flags; struct kbase_device *kbdev; - struct kbasep_js_device_data *js_devdata; int i; KBASE_DEBUG_ASSERT(kctx != NULL); kbdev = kctx->kbdev; KBASE_DEBUG_ASSERT(kbdev != NULL); - js_devdata = &kbdev->js_data; /* Cancel any remaining running jobs for this kctx */ mutex_lock(&kctx->jctx.lock); diff --git a/mali_kbase/backend/gpu/mali_kbase_pm_driver.c b/mali_kbase/backend/gpu/mali_kbase_pm_driver.c index ed19a8a..cbc258c 100644 --- a/mali_kbase/backend/gpu/mali_kbase_pm_driver.c +++ b/mali_kbase/backend/gpu/mali_kbase_pm_driver.c @@ -1297,6 +1297,7 @@ static void kbase_pm_hw_issues_detect(struct kbase_device *kbdev) } } + if (!kbdev->hw_quirks_jm) kbdev->hw_quirks_jm = kbase_reg_read(kbdev, GPU_CONTROL_REG(JM_CONFIG), NULL); diff --git a/mali_kbase/ipa/mali_kbase_ipa.c b/mali_kbase/ipa/mali_kbase_ipa.c index 4319893..e7e2299 100644 --- a/mali_kbase/ipa/mali_kbase_ipa.c +++ b/mali_kbase/ipa/mali_kbase_ipa.c @@ -242,18 +242,17 @@ struct kbase_ipa_model *kbase_ipa_init_model(struct kbase_device *kbdev, dev_err(kbdev->dev, "init of power model \'%s\' returned error %d\n", ops->name, err); - goto term_model; + kfree(model); + return NULL; } err = kbase_ipa_model_recalculate(model); - if (err) - goto term_model; + if (err) { + kbase_ipa_term_model(model); + return NULL; + } return model; - -term_model: - kbase_ipa_term_model(model); - return NULL; } KBASE_EXPORT_TEST_API(kbase_ipa_init_model); diff --git a/mali_kbase/ipa/mali_kbase_ipa_simple.c b/mali_kbase/ipa/mali_kbase_ipa_simple.c index dd65d33..de6c3e6 100644 --- a/mali_kbase/ipa/mali_kbase_ipa_simple.c +++ b/mali_kbase/ipa/mali_kbase_ipa_simple.c @@ -26,6 +26,7 @@ #include "mali_kbase.h" #include "mali_kbase_defs.h" #include "mali_kbase_ipa_simple.h" +#include "mali_kbase_ipa_debugfs.h" #if MALI_UNIT_TEST @@ -252,10 +253,8 @@ static int kbase_simple_power_model_init(struct kbase_ipa_model *model) model_data = kzalloc(sizeof(struct kbase_ipa_model_simple_data), GFP_KERNEL); - if (!model_data) { - err = -ENOMEM; - goto exit; - } + if (!model_data) + return -ENOMEM; model->model_data = (void *) model_data; @@ -263,17 +262,15 @@ static int kbase_simple_power_model_init(struct kbase_ipa_model *model) model_data->poll_temperature_thread = kthread_run(poll_temperature, (void *) model_data, "mali-simple-power-model-temp-poll"); - if (!model_data->poll_temperature_thread) { - err = -ENOMEM; - goto exit; + if (IS_ERR(model_data->poll_temperature_thread)) { + kfree(model_data); + return PTR_ERR(model_data->poll_temperature_thread); } err = add_params(model); - -exit: if (err) { - if (model_data->poll_temperature_thread) - kthread_stop(model_data->poll_temperature_thread); + kbase_ipa_model_param_free_all(model); + kthread_stop(model_data->poll_temperature_thread); kfree(model_data); } diff --git a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c index 14241a0..81f6fdd 100644 --- a/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c +++ b/mali_kbase/ipa/mali_kbase_ipa_vinstr_g71.c @@ -18,6 +18,7 @@ #include "mali_kbase_ipa_vinstr_common.h" #include "mali_kbase.h" +#include "mali_kbase_ipa_debugfs.h" #define JM_BASE (0 * KBASE_IPA_NR_BYTES_PER_BLOCK) @@ -78,7 +79,7 @@ static int kbase_g71_power_model_init(struct kbase_ipa_model *model) model_data = kzalloc(sizeof(*model_data), GFP_KERNEL); if (!model_data) - return -EINVAL; + return -ENOMEM; model_data->kbdev = model->kbdev; model_data->groups_def = ipa_groups_def; @@ -95,16 +96,23 @@ static int kbase_g71_power_model_init(struct kbase_ipa_model *model) &model_data->group_values[i], 1, false); if (err) - break; + goto exit; } model_data->scaling_factor = 15000; err = kbase_ipa_model_add_param_s32(model, "scale", &model_data->scaling_factor, 1, false); + if (err) + goto exit; err = kbase_ipa_attach_vinstr(model_data); +exit: + if (err) { + kbase_ipa_model_param_free_all(model); + kfree(model_data); + } return err; } diff --git a/mali_kbase/mali_base_hwconfig_features.h b/mali_kbase/mali_base_hwconfig_features.h index bead0ab..219586d 100644 --- a/mali_kbase/mali_base_hwconfig_features.h +++ b/mali_kbase/mali_base_hwconfig_features.h @@ -52,6 +52,7 @@ enum base_hw_feature { BASE_HW_FEATURE_COHERENCY_REG, BASE_HW_FEATURE_PROTECTED_DEBUG_MODE, BASE_HW_FEATURE_AARCH64_MMU, + BASE_HW_FEATURE_TLS_HASHING, BASE_HW_FEATURE_END }; @@ -275,94 +276,7 @@ static const enum base_hw_feature base_hw_features_tDVx[] = { }; -#ifdef MALI_INCLUDE_TGOX -static const enum base_hw_feature base_hw_features_tGOx[] = { - BASE_HW_FEATURE_JOBCHAIN_DISAMBIGUATION, - BASE_HW_FEATURE_PWRON_DURING_PWROFF_TRANS, - BASE_HW_FEATURE_XAFFINITY, - BASE_HW_FEATURE_WARPING, - BASE_HW_FEATURE_INTERPIPE_REG_ALIASING, - BASE_HW_FEATURE_32_BIT_UNIFORM_ADDRESS, - BASE_HW_FEATURE_ATTR_AUTO_TYPE_INFERRAL, - BASE_HW_FEATURE_BRNDOUT_CC, - BASE_HW_FEATURE_BRNDOUT_KILL, - BASE_HW_FEATURE_LD_ST_LEA_TEX, - BASE_HW_FEATURE_LD_ST_TILEBUFFER, - BASE_HW_FEATURE_LINEAR_FILTER_FLOAT, - BASE_HW_FEATURE_MRT, - BASE_HW_FEATURE_MSAA_16X, - BASE_HW_FEATURE_NEXT_INSTRUCTION_TYPE, - BASE_HW_FEATURE_OUT_OF_ORDER_EXEC, - BASE_HW_FEATURE_T7XX_PAIRING_RULES, - BASE_HW_FEATURE_TEST4_DATUM_MODE, - BASE_HW_FEATURE_FLUSH_REDUCTION, - BASE_HW_FEATURE_PROTECTED_MODE, - BASE_HW_FEATURE_PROTECTED_DEBUG_MODE, - BASE_HW_FEATURE_COHERENCY_REG, - BASE_HW_FEATURE_AARCH64_MMU, - BASE_HW_FEATURE_END -}; - -#endif /* MALI_INCLUDE_TGOX */ - -#ifdef MALI_INCLUDE_TKAX -static const enum base_hw_feature base_hw_features_tKAx[] = { - BASE_HW_FEATURE_33BIT_VA, - BASE_HW_FEATURE_JOBCHAIN_DISAMBIGUATION, - BASE_HW_FEATURE_PWRON_DURING_PWROFF_TRANS, - BASE_HW_FEATURE_XAFFINITY, - BASE_HW_FEATURE_WARPING, - BASE_HW_FEATURE_INTERPIPE_REG_ALIASING, - BASE_HW_FEATURE_32_BIT_UNIFORM_ADDRESS, - BASE_HW_FEATURE_ATTR_AUTO_TYPE_INFERRAL, - BASE_HW_FEATURE_BRNDOUT_CC, - BASE_HW_FEATURE_BRNDOUT_KILL, - BASE_HW_FEATURE_LD_ST_LEA_TEX, - BASE_HW_FEATURE_LD_ST_TILEBUFFER, - BASE_HW_FEATURE_LINEAR_FILTER_FLOAT, - BASE_HW_FEATURE_MRT, - BASE_HW_FEATURE_MSAA_16X, - BASE_HW_FEATURE_NEXT_INSTRUCTION_TYPE, - BASE_HW_FEATURE_OUT_OF_ORDER_EXEC, - BASE_HW_FEATURE_T7XX_PAIRING_RULES, - BASE_HW_FEATURE_TEST4_DATUM_MODE, - BASE_HW_FEATURE_FLUSH_REDUCTION, - BASE_HW_FEATURE_PROTECTED_MODE, - BASE_HW_FEATURE_PROTECTED_DEBUG_MODE, - BASE_HW_FEATURE_COHERENCY_REG, - BASE_HW_FEATURE_END -}; -#endif /* MALI_INCLUDE_TKAX */ - -#ifdef MALI_INCLUDE_TTRX -static const enum base_hw_feature base_hw_features_tTRx[] = { - BASE_HW_FEATURE_33BIT_VA, - BASE_HW_FEATURE_JOBCHAIN_DISAMBIGUATION, - BASE_HW_FEATURE_PWRON_DURING_PWROFF_TRANS, - BASE_HW_FEATURE_XAFFINITY, - BASE_HW_FEATURE_WARPING, - BASE_HW_FEATURE_INTERPIPE_REG_ALIASING, - BASE_HW_FEATURE_32_BIT_UNIFORM_ADDRESS, - BASE_HW_FEATURE_ATTR_AUTO_TYPE_INFERRAL, - BASE_HW_FEATURE_BRNDOUT_CC, - BASE_HW_FEATURE_BRNDOUT_KILL, - BASE_HW_FEATURE_LD_ST_LEA_TEX, - BASE_HW_FEATURE_LD_ST_TILEBUFFER, - BASE_HW_FEATURE_LINEAR_FILTER_FLOAT, - BASE_HW_FEATURE_MRT, - BASE_HW_FEATURE_MSAA_16X, - BASE_HW_FEATURE_NEXT_INSTRUCTION_TYPE, - BASE_HW_FEATURE_OUT_OF_ORDER_EXEC, - BASE_HW_FEATURE_T7XX_PAIRING_RULES, - BASE_HW_FEATURE_TEST4_DATUM_MODE, - BASE_HW_FEATURE_FLUSH_REDUCTION, - BASE_HW_FEATURE_PROTECTED_MODE, - BASE_HW_FEATURE_PROTECTED_DEBUG_MODE, - BASE_HW_FEATURE_COHERENCY_REG, - BASE_HW_FEATURE_END -}; -#endif /* MALI_INCLUDE_TTRX */ #endif /* _BASE_HWCONFIG_FEATURES_H_ */ diff --git a/mali_kbase/mali_base_hwconfig_issues.h b/mali_kbase/mali_base_hwconfig_issues.h index d068aaf..1c5ee49 100644 --- a/mali_kbase/mali_base_hwconfig_issues.h +++ b/mali_kbase/mali_base_hwconfig_issues.h @@ -981,9 +981,10 @@ static const enum base_hw_issue base_hw_issues_tMIx_r0p0[] = { BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_model_tMIx[] = { - BASE_HW_ISSUE_5736, +static const enum base_hw_issue base_hw_issues_tMIx_r0p1[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_10682, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_7891, BASE_HW_ISSUE_TMIX_7940, BASE_HW_ISSUE_TMIX_8042, @@ -991,95 +992,106 @@ static const enum base_hw_issue base_hw_issues_model_tMIx[] = { BASE_HW_ISSUE_TMIX_8138, BASE_HW_ISSUE_TMIX_8206, BASE_HW_ISSUE_TMIX_8343, + BASE_HW_ISSUE_TMIX_8463, BASE_HW_ISSUE_TMIX_8456, + BASE_HW_ISSUE_TMIX_8438, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tHEx_r0p0[] = { +static const enum base_hw_issue base_hw_issues_model_tMIx[] = { + BASE_HW_ISSUE_5736, BASE_HW_ISSUE_9435, - BASE_HW_ISSUE_10682, BASE_HW_ISSUE_TMIX_7891, + BASE_HW_ISSUE_TMIX_7940, BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, + BASE_HW_ISSUE_TMIX_8138, + BASE_HW_ISSUE_TMIX_8206, + BASE_HW_ISSUE_TMIX_8343, + BASE_HW_ISSUE_TMIX_8456, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tHEx_r0p1[] = { +static const enum base_hw_issue base_hw_issues_tHEx_r0p0[] = { BASE_HW_ISSUE_9435, BASE_HW_ISSUE_10682, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_7891, BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_model_tHEx[] = { - BASE_HW_ISSUE_5736, +static const enum base_hw_issue base_hw_issues_tHEx_r0p1[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_10682, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_7891, BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tSIx_r0p0[] = { +static const enum base_hw_issue base_hw_issues_tHEx_r0p2[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_10682, + BASE_HW_ISSUE_11054, + BASE_HW_ISSUE_TMIX_7891, + BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, - BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tSIx_r0p1[] = { +static const enum base_hw_issue base_hw_issues_tHEx_r0p3[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_10682, + BASE_HW_ISSUE_TMIX_7891, + BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, - BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tSIx_r1p0[] = { +static const enum base_hw_issue base_hw_issues_model_tHEx[] = { + BASE_HW_ISSUE_5736, BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_TMIX_7891, + BASE_HW_ISSUE_TMIX_8042, BASE_HW_ISSUE_TMIX_8133, - BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_model_tSIx[] = { - BASE_HW_ISSUE_5736, +static const enum base_hw_issue base_hw_issues_tSIx_r0p0[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_tDVx_r0p0[] = { +static const enum base_hw_issue base_hw_issues_tSIx_r0p1[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -static const enum base_hw_issue base_hw_issues_model_tDVx[] = { - BASE_HW_ISSUE_5736, +static const enum base_hw_issue base_hw_issues_tSIx_r1p0[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; - - -#ifdef MALI_INCLUDE_TGOX -static const enum base_hw_issue base_hw_issues_tGOx_r0p0[] = { +static const enum base_hw_issue base_hw_issues_tSIx_r1p1[] = { BASE_HW_ISSUE_9435, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -#endif /* MALI_INCLUDE_TGOX */ - -#ifdef MALI_INCLUDE_TGOX -static const enum base_hw_issue base_hw_issues_model_tGOx[] = { +static const enum base_hw_issue base_hw_issues_model_tSIx[] = { BASE_HW_ISSUE_5736, BASE_HW_ISSUE_9435, BASE_HW_ISSUE_TMIX_8133, @@ -1087,20 +1099,15 @@ static const enum base_hw_issue base_hw_issues_model_tGOx[] = { BASE_HW_ISSUE_END }; -#endif /* MALI_INCLUDE_TGOX */ - -#ifdef MALI_INCLUDE_TKAX -static const enum base_hw_issue base_hw_issues_tKAx_r0p0[] = { +static const enum base_hw_issue base_hw_issues_tDVx_r0p0[] = { BASE_HW_ISSUE_9435, + BASE_HW_ISSUE_11054, BASE_HW_ISSUE_TMIX_8133, BASE_HW_ISSUE_TSIX_1116, BASE_HW_ISSUE_END }; -#endif /* MALI_INCLUDE_TKAX */ - -#ifdef MALI_INCLUDE_TKAX -static const enum base_hw_issue base_hw_issues_model_tKAx[] = { +static const enum base_hw_issue base_hw_issues_model_tDVx[] = { BASE_HW_ISSUE_5736, BASE_HW_ISSUE_9435, BASE_HW_ISSUE_TMIX_8133, @@ -1108,27 +1115,12 @@ static const enum base_hw_issue base_hw_issues_model_tKAx[] = { BASE_HW_ISSUE_END }; -#endif /* MALI_INCLUDE_TKAX */ -#ifdef MALI_INCLUDE_TTRX -static const enum base_hw_issue base_hw_issues_tTRx_r0p0[] = { - BASE_HW_ISSUE_9435, - BASE_HW_ISSUE_TMIX_8133, - BASE_HW_ISSUE_TSIX_1116, - BASE_HW_ISSUE_END -}; -#endif /* MALI_INCLUDE_TTRX */ -#ifdef MALI_INCLUDE_TTRX -static const enum base_hw_issue base_hw_issues_model_tTRx[] = { - BASE_HW_ISSUE_5736, - BASE_HW_ISSUE_9435, - BASE_HW_ISSUE_TMIX_8133, - BASE_HW_ISSUE_TSIX_1116, - BASE_HW_ISSUE_END -}; -#endif /* MALI_INCLUDE_TTRX */ + + + #endif /* _BASE_HWCONFIG_ISSUES_H_ */ diff --git a/mali_kbase/mali_base_kernel.h b/mali_kbase/mali_base_kernel.h index 998d097..6f5c68e 100644 --- a/mali_kbase/mali_base_kernel.h +++ b/mali_kbase/mali_base_kernel.h @@ -48,12 +48,6 @@ typedef struct base_mem_handle { */ #define BASE_JD_ATOM_COUNT 256 -#define BASEP_JD_SEM_PER_WORD_LOG2 5 -#define BASEP_JD_SEM_PER_WORD (1 << BASEP_JD_SEM_PER_WORD_LOG2) -#define BASEP_JD_SEM_WORD_NR(x) ((x) >> BASEP_JD_SEM_PER_WORD_LOG2) -#define BASEP_JD_SEM_MASK_IN_WORD(x) (1 << ((x) & (BASEP_JD_SEM_PER_WORD - 1))) -#define BASEP_JD_SEM_ARRAY_SIZE BASEP_JD_SEM_WORD_NR(BASE_JD_ATOM_COUNT) - /* Set/reset values for a software event */ #define BASE_JD_SOFT_EVENT_SET ((unsigned char)1) #define BASE_JD_SOFT_EVENT_RESET ((unsigned char)0) @@ -187,11 +181,18 @@ typedef u32 base_mem_alloc_flags; */ #define BASE_MEM_IMPORT_SHARED ((base_mem_alloc_flags)1 << 18) +/** + * Bit 19 is reserved. + * + * Do not remove, use the next unreserved bit for new flags + **/ +#define BASE_MEM_RESERVED_BIT_19 ((base_mem_alloc_flags)1 << 19) + /* Number of bits used as flags for base memory management * * Must be kept in sync with the base_mem_alloc_flags flags */ -#define BASE_MEM_FLAGS_NR_BITS 19 +#define BASE_MEM_FLAGS_NR_BITS 20 /* A mask for all output bits, excluding IN/OUT bits. */ @@ -918,13 +919,21 @@ static inline void base_jd_atom_dep_copy(struct base_dependency *dep, * be set to trigger when a GPU job has finished. * * The base fence object must not be terminated until the atom - * has been submitted to @a base_jd_submit and @a base_jd_submit has returned. + * has been submitted to @ref base_jd_submit and @ref base_jd_submit + * has returned. * * @a fence must be a valid fence set up with @a base_fence_init. * Calling this function with a uninitialized fence results in undefined behavior. * * @param[out] atom A pre-allocated atom to configure as a fence trigger SW atom * @param[in] fence The base fence object to trigger. + * + * @pre @p fence must reference a @ref base_fence successfully initialized by + * calling @ref base_fence_init. + * @pre @p fence was @e not initialized by calling @ref base_fence_import, nor + * is it associated with a fence-trigger job that was already submitted + * by calling @ref base_jd_submit. + * @post @p atom can be submitted by calling @ref base_jd_submit. */ static inline void base_jd_fence_trigger_setup_v2(struct base_jd_atom_v2 *atom, struct base_fence *fence) { @@ -947,13 +956,17 @@ static inline void base_jd_fence_trigger_setup_v2(struct base_jd_atom_v2 *atom, * be set to block a GPU job until it has been triggered. * * The base fence object must not be terminated until the atom - * has been submitted to @a base_jd_submit and @a base_jd_submit has returned. - * - * @a fence must be a valid fence set up with @a base_fence_init or @a base_fence_import. - * Calling this function with a uninitialized fence results in undefined behavior. + * has been submitted to @ref base_jd_submit and + * @ref base_jd_submit has returned. * * @param[out] atom A pre-allocated atom to configure as a fence wait SW atom * @param[in] fence The base fence object to wait on + * + * @pre @p fence must reference a @ref base_fence successfully initialized by + * calling @ref base_fence_import, or it must be associated with a + * fence-trigger job that was already submitted by calling + * @ref base_jd_submit. + * @post @p atom can be submitted by calling @ref base_jd_submit. */ static inline void base_jd_fence_wait_setup_v2(struct base_jd_atom_v2 *atom, struct base_fence *fence) { @@ -1152,22 +1165,15 @@ typedef struct base_jd_event_v2 { } base_jd_event_v2; /** - * Padding required to ensure that the @ref struct base_dump_cpu_gpu_counters structure fills - * a full cache line. - */ - -#define BASE_CPU_GPU_CACHE_LINE_PADDING (36) - - -/** * @brief Structure for BASE_JD_REQ_SOFT_DUMP_CPU_GPU_COUNTERS jobs. * - * This structure is stored into the memory pointed to by the @c jc field of @ref base_jd_atom. + * This structure is stored into the memory pointed to by the @c jc field + * of @ref base_jd_atom. * - * This structure must be padded to ensure that it will occupy whole cache lines. This is to avoid - * cases where access to pages containing the structure is shared between cached and un-cached - * memory regions, which would cause memory corruption. Here we set the structure size to be 64 bytes - * which is the cache line for ARM A15 processors. + * It must not occupy the same CPU cache line(s) as any neighboring data. + * This is to avoid cases where access to pages containing the structure + * is shared between cached and un-cached memory regions, which would + * cause memory corruption. */ typedef struct base_dump_cpu_gpu_counters { @@ -1175,11 +1181,9 @@ typedef struct base_dump_cpu_gpu_counters { u64 cycle_counter; u64 sec; u32 usec; - u8 padding[BASE_CPU_GPU_CACHE_LINE_PADDING]; + u8 padding[36]; } base_dump_cpu_gpu_counters; - - /** @} end group base_user_api_job_dispatch */ #define GPU_MAX_JOB_SLOTS 16 diff --git a/mali_kbase/mali_kbase.h b/mali_kbase/mali_kbase.h index d77f186..56b364e 100644 --- a/mali_kbase/mali_kbase.h +++ b/mali_kbase/mali_kbase.h @@ -35,6 +35,9 @@ #include <linux/mutex.h> #include <linux/rwsem.h> #include <linux/sched.h> +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) +#include <linux/sched/mm.h> +#endif #include <linux/slab.h> #include <linux/spinlock.h> #include <linux/vmalloc.h> diff --git a/mali_kbase/mali_kbase_config.h b/mali_kbase/mali_kbase_config.h index 356d52b..212e3b1 100644 --- a/mali_kbase/mali_kbase_config.h +++ b/mali_kbase/mali_kbase_config.h @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2010-2016 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2010-2017 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 @@ -317,9 +317,8 @@ void kbasep_platform_device_term(struct kbase_device *kbdev); int kbase_platform_early_init(void); #ifndef CONFIG_OF -#ifdef CONFIG_MALI_PLATFORM_FAKE /** - * kbase_platform_fake_register - Register a platform device for the GPU + * kbase_platform_register - Register a platform device for the GPU * * This can be used to register a platform device on systems where device tree * is not enabled and the platform initialisation code in the kernel doesn't @@ -327,15 +326,14 @@ int kbase_platform_early_init(void); * * Return: 0 for success, any other fail causes module initialisation to fail */ -int kbase_platform_fake_register(void); +int kbase_platform_register(void); /** - * kbase_platform_fake_unregister - Unregister a fake platform device + * kbase_platform_unregister - Unregister a fake platform device * - * Unregister the platform device created with kbase_platform_fake_register() + * Unregister the platform device created with kbase_platform_register() */ -void kbase_platform_fake_unregister(void); -#endif +void kbase_platform_unregister(void); #endif /** @} *//* end group kbase_config */ diff --git a/mali_kbase/mali_kbase_core_linux.c b/mali_kbase/mali_kbase_core_linux.c index 0cccb0b..3da2b6c 100644 --- a/mali_kbase/mali_kbase_core_linux.c +++ b/mali_kbase/mali_kbase_core_linux.c @@ -45,11 +45,6 @@ #include <backend/gpu/mali_kbase_device_internal.h> #include "mali_kbase_ioctl.h" -#ifdef CONFIG_KDS -#include <linux/kds.h> -#include <linux/syscalls.h> -#endif /* CONFIG_KDS */ - #include <linux/module.h> #include <linux/init.h> #include <linux/poll.h> @@ -70,9 +65,6 @@ #include <linux/version.h> #include <mali_kbase_hw.h> #include <platform/mali_kbase_platform_common.h> -#ifdef CONFIG_MALI_PLATFORM_FAKE -#include <platform/mali_kbase_platform_fake.h> -#endif /*CONFIG_MALI_PLATFORM_FAKE */ #if defined(CONFIG_SYNC) || defined(CONFIG_SYNC_FILE) #include <mali_kbase_sync.h> #endif /* CONFIG_SYNC || CONFIG_SYNC_FILE */ @@ -474,11 +466,19 @@ copy_failed: case KBASE_FUNC_JOB_SUBMIT: { struct kbase_uk_job_submit *job = args; + char __user *user_buf; if (sizeof(*job) != args_size) goto bad_size; - if (kbase_jd_submit(kctx, u64_to_user_ptr(job->addr), +#ifdef CONFIG_COMPAT + if (kbase_ctx_flag(kctx, KCTX_COMPAT)) + user_buf = compat_ptr(job->addr); + else +#endif + user_buf = u64_to_user_ptr(job->addr); + + if (kbase_jd_submit(kctx, user_buf, job->nr_atoms, job->stride, false) != 0) @@ -1113,7 +1113,7 @@ static int kbase_open(struct inode *inode, struct file *filp) kbase_debug_job_fault_context_init(kctx); - kbase_mem_pool_debugfs_init(kctx->kctx_dentry, &kctx->mem_pool); + kbase_mem_pool_debugfs_init(kctx->kctx_dentry, &kctx->mem_pool, &kctx->lp_mem_pool); kbase_jit_debugfs_init(kctx); #endif /* CONFIG_DEBUG_FS */ @@ -1130,7 +1130,7 @@ static int kbase_open(struct inode *inode, struct file *filp) list_add(&element->link, &kbdev->kctx_list); KBASE_TLSTREAM_TL_NEW_CTX( element->kctx, - (u32)(element->kctx->id), + element->kctx->id, (u32)(element->kctx->tgid)); mutex_unlock(&kbdev->kctx_list_lock); } else { @@ -3167,7 +3167,7 @@ static ssize_t kbase_show_gpuinfo(struct device *dev, { .id = GPU_ID2_PRODUCT_TMIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT, .name = "Mali-G71" }, { .id = GPU_ID2_PRODUCT_THEX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT, - .name = "Mali-THEx" }, + .name = "Mali-G72" }, { .id = GPU_ID2_PRODUCT_TSIX >> GPU_ID_VERSION_PRODUCT_ID_SHIFT, .name = "Mali-G51" }, }; @@ -3496,6 +3496,119 @@ static ssize_t set_mem_pool_max_size(struct device *dev, static DEVICE_ATTR(mem_pool_max_size, S_IRUGO | S_IWUSR, show_mem_pool_max_size, set_mem_pool_max_size); +/** + * show_lp_mem_pool_size - Show size of the large memory pages pool. + * @dev: The device this sysfs file is for. + * @attr: The attributes of the sysfs file. + * @buf: The output buffer to receive the pool size. + * + * This function is called to get the number of large memory pages which currently populate the kbdev pool. + * + * Return: The number of bytes output to @buf. + */ +static ssize_t show_lp_mem_pool_size(struct device *dev, + struct device_attribute *attr, char * const buf) +{ + struct kbase_device *kbdev; + + kbdev = to_kbase_device(dev); + if (!kbdev) + return -ENODEV; + + return scnprintf(buf, PAGE_SIZE, "%zu\n", kbase_mem_pool_size(&kbdev->lp_mem_pool)); +} + +/** + * set_lp_mem_pool_size - Set size of the large memory pages pool. + * @dev: The device this sysfs file is for. + * @attr: The attributes of the sysfs file. + * @buf: The value written to the sysfs file. + * @count: The number of bytes written to the sysfs file. + * + * This function is called to set the number of large memory pages which should populate the kbdev pool. + * This may cause existing pages to be removed from the pool, or new pages to be created and then added to the pool. + * + * Return: @count if the function succeeded. An error code on failure. + */ +static ssize_t set_lp_mem_pool_size(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct kbase_device *kbdev; + unsigned long new_size; + int err; + + kbdev = to_kbase_device(dev); + if (!kbdev) + return -ENODEV; + + err = kstrtoul(buf, 0, &new_size); + if (err) + return err; + + kbase_mem_pool_trim(&kbdev->lp_mem_pool, new_size); + + return count; +} + +static DEVICE_ATTR(lp_mem_pool_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_size, + set_lp_mem_pool_size); + +/** + * show_lp_mem_pool_max_size - Show maximum size of the large memory pages pool. + * @dev: The device this sysfs file is for. + * @attr: The attributes of the sysfs file. + * @buf: The output buffer to receive the pool size. + * + * This function is called to get the maximum number of large memory pages that the kbdev pool can possibly contain. + * + * Return: The number of bytes output to @buf. + */ +static ssize_t show_lp_mem_pool_max_size(struct device *dev, + struct device_attribute *attr, char * const buf) +{ + struct kbase_device *kbdev; + + kbdev = to_kbase_device(dev); + if (!kbdev) + return -ENODEV; + + return scnprintf(buf, PAGE_SIZE, "%zu\n", kbase_mem_pool_max_size(&kbdev->lp_mem_pool)); +} + +/** + * set_lp_mem_pool_max_size - Set maximum size of the large memory pages pool. + * @dev: The device this sysfs file is for. + * @attr: The attributes of the sysfs file. + * @buf: The value written to the sysfs file. + * @count: The number of bytes written to the sysfs file. + * + * This function is called to set the maximum number of large memory pages that the kbdev pool can possibly contain. + * + * Return: @count if the function succeeded. An error code on failure. + */ +static ssize_t set_lp_mem_pool_max_size(struct device *dev, + struct device_attribute *attr, const char *buf, size_t count) +{ + struct kbase_device *kbdev; + unsigned long new_max_size; + int err; + + kbdev = to_kbase_device(dev); + if (!kbdev) + return -ENODEV; + + err = kstrtoul(buf, 0, &new_max_size); + if (err) + return -EINVAL; + + kbase_mem_pool_set_max_size(&kbdev->lp_mem_pool, new_max_size); + + return count; +} + +static DEVICE_ATTR(lp_mem_pool_max_size, S_IRUGO | S_IWUSR, show_lp_mem_pool_max_size, + set_lp_mem_pool_max_size); + #ifdef CONFIG_DEBUG_FS /* Number of entries in serialize_jobs_settings[] */ @@ -3702,7 +3815,7 @@ static void kbase_common_reg_unmap(struct kbase_device * const kbdev) #else /* CONFIG_MALI_NO_MALI */ static int kbase_common_reg_map(struct kbase_device *kbdev) { - int err = -ENOMEM; + int err = 0; if (!request_mem_region(kbdev->reg_start, kbdev->reg_size, dev_name(kbdev->dev))) { dev_err(kbdev->dev, "Register window unavailable\n"); @@ -3717,7 +3830,7 @@ static int kbase_common_reg_map(struct kbase_device *kbdev) goto out_ioremap; } - return 0; + return err; out_ioremap: release_mem_region(kbdev->reg_start, kbdev->reg_size); @@ -4153,6 +4266,8 @@ static struct attribute *kbase_attrs[] = { &dev_attr_core_mask.attr, &dev_attr_mem_pool_size.attr, &dev_attr_mem_pool_max_size.attr, + &dev_attr_lp_mem_pool_size.attr, + &dev_attr_lp_mem_pool_max_size.attr, NULL }; @@ -4774,25 +4889,22 @@ static int __init kbase_driver_init(void) if (ret) return ret; -#ifdef CONFIG_MALI_PLATFORM_FAKE - ret = kbase_platform_fake_register(); + ret = kbase_platform_register(); if (ret) return ret; -#endif + ret = platform_driver_register(&kbase_platform_driver); -#ifdef CONFIG_MALI_PLATFORM_FAKE + if (ret) - kbase_platform_fake_unregister(); -#endif + kbase_platform_unregister(); + return ret; } static void __exit kbase_driver_exit(void) { platform_driver_unregister(&kbase_platform_driver); -#ifdef CONFIG_MALI_PLATFORM_FAKE - kbase_platform_fake_unregister(); -#endif + kbase_platform_unregister(); } module_init(kbase_driver_init); diff --git a/mali_kbase/mali_kbase_ctx_sched.h b/mali_kbase/mali_kbase_ctx_sched.h index e551525..2330d48 100644 --- a/mali_kbase/mali_kbase_ctx_sched.h +++ b/mali_kbase/mali_kbase_ctx_sched.h @@ -23,12 +23,12 @@ /* The Context Scheduler manages address space assignment and reference * counting to kbase_context. The interface has been designed to minimise * interactions between the Job Scheduler and Power Management/MMU to support - * both the existing Job Scheduler and Command Stream Frontend interface. + * the existing Job Scheduler interface. * * The initial implementation of the Context Scheduler does not schedule - * contexts. Instead it relies on the Job Scheduler/CSF to make decisions of + * contexts. Instead it relies on the Job Scheduler to make decisions of * when to schedule/evict contexts if address spaces are starved. In the - * future, once an interface between the CS and JS/CSF have been devised to + * future, once an interface between the CS and JS have been devised to * provide enough information about how each context is consuming GPU resources, * those decisions can be made in the CS itself, thereby reducing duplicated * code. diff --git a/mali_kbase/mali_kbase_debug.h b/mali_kbase/mali_kbase_debug.h index 5fff289..d7873c5 100644 --- a/mali_kbase/mali_kbase_debug.h +++ b/mali_kbase/mali_kbase_debug.h @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2012-2015 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2012-2015, 2017 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 @@ -64,7 +64,7 @@ struct kbasep_debug_assert_cb { /** * @def KBASEP_DEBUG_ASSERT_OUT(trace, function, ...) - * @brief (Private) system printing function associated to the @see KBASE_DEBUG_ASSERT_MSG event. + * @brief (Private) system printing function associated to the @ref KBASE_DEBUG_ASSERT_MSG event. * @param trace location in the code from where the message is printed * @param function function from where the message is printed * @param ... Format string followed by format arguments. @@ -90,9 +90,9 @@ struct kbasep_debug_assert_cb { /** * @def KBASE_DEBUG_ASSERT(expr) - * @brief Calls @see KBASE_PRINT_ASSERT and prints the expression @a expr if @a expr is false + * @brief Calls @ref KBASE_PRINT_ASSERT and prints the expression @a expr if @a expr is false * - * @note This macro does nothing if the flag @see KBASE_DEBUG_DISABLE_ASSERTS is set to 1 + * @note This macro does nothing if the flag @ref KBASE_DEBUG_DISABLE_ASSERTS is set to 1 * * @param expr Boolean expression */ @@ -104,9 +104,9 @@ struct kbasep_debug_assert_cb { #else /** * @def KBASE_DEBUG_ASSERT_MSG(expr, ...) - * @brief Calls @see KBASEP_DEBUG_ASSERT_OUT and prints the given message if @a expr is false + * @brief Calls @ref KBASEP_DEBUG_ASSERT_OUT and prints the given message if @a expr is false * - * @note This macro does nothing if the flag @see KBASE_DEBUG_DISABLE_ASSERTS is set to 1 + * @note This macro does nothing if the flag @ref KBASE_DEBUG_DISABLE_ASSERTS is set to 1 * * @param expr Boolean expression * @param ... Message to display when @a expr is false, as a format string followed by format arguments. diff --git a/mali_kbase/mali_kbase_defs.h b/mali_kbase/mali_kbase_defs.h index 047ea41..1ab6425 100644 --- a/mali_kbase/mali_kbase_defs.h +++ b/mali_kbase/mali_kbase_defs.h @@ -32,7 +32,6 @@ #include <mali_base_hwconfig_issues.h> #include <mali_kbase_mem_lowlevel.h> #include <mali_kbase_mmu_hw.h> -#include <mali_kbase_mmu_mode.h> #include <mali_kbase_instr_defs.h> #include <mali_kbase_pm.h> #include <protected_mode_switcher.h> @@ -223,6 +222,12 @@ /* Reset the GPU after each atom completion */ #define KBASE_SERIALIZE_RESET (1 << 2) +/* Forward declarations */ +struct kbase_context; +struct kbase_device; +struct kbase_as; +struct kbase_mmu_setup; + #ifdef CONFIG_DEBUG_FS struct base_job_fault_event { @@ -946,6 +951,24 @@ struct kbase_devfreq_opp { u64 core_mask; }; +struct kbase_mmu_mode { + void (*update)(struct kbase_context *kctx); + void (*get_as_setup)(struct kbase_context *kctx, + struct kbase_mmu_setup * const setup); + void (*disable_as)(struct kbase_device *kbdev, int as_nr); + phys_addr_t (*pte_to_phy_addr)(u64 entry); + int (*ate_is_valid)(u64 ate, unsigned int level); + int (*pte_is_valid)(u64 pte, unsigned int level); + void (*entry_set_ate)(u64 *entry, struct tagged_addr phy, + unsigned long flags, unsigned int level); + void (*entry_set_pte)(u64 *entry, phys_addr_t phy); + void (*entry_invalidate)(u64 *entry); +}; + +struct kbase_mmu_mode const *kbase_mmu_mode_get_lpae(void); +struct kbase_mmu_mode const *kbase_mmu_mode_get_aarch64(void); + + #define DEVNAME_SIZE 16 struct kbase_device { @@ -1346,7 +1369,7 @@ struct kbase_sub_alloc { struct kbase_context { struct file *filp; struct kbase_device *kbdev; - int id; /* System wide unique id */ + u32 id; /* System wide unique id */ unsigned long api_version; phys_addr_t pgd; struct list_head event_list; diff --git a/mali_kbase/mali_kbase_fence.h b/mali_kbase/mali_kbase_fence.h index 8d39299..f3ed025 100644 --- a/mali_kbase/mali_kbase_fence.h +++ b/mali_kbase/mali_kbase_fence.h @@ -134,7 +134,11 @@ static inline bool kbase_fence_out_is_ours(struct kbase_jd_atom *katom) static inline int kbase_fence_out_signal(struct kbase_jd_atom *katom, int status) { +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) + katom->dma_fence.fence->error = status; +#else katom->dma_fence.fence->status = status; +#endif return dma_fence_signal(katom->dma_fence.fence); } diff --git a/mali_kbase/mali_kbase_gator_hwcnt_names.h b/mali_kbase/mali_kbase_gator_hwcnt_names.h index cad19b6..24103e2 100644 --- a/mali_kbase/mali_kbase_gator_hwcnt_names.h +++ b/mali_kbase/mali_kbase_gator_hwcnt_names.h @@ -2163,8 +2163,5 @@ static const char * const hardware_counters_mali_t88x[] = { #include "mali_kbase_gator_hwcnt_names_tsix.h" -#ifdef MALI_INCLUDE_TKAX -#include "mali_kbase_gator_hwcnt_names_tkax.h" -#endif /* MALI_INCLUDE_TKAX */ #endif diff --git a/mali_kbase/mali_kbase_gpu_id.h b/mali_kbase/mali_kbase_gpu_id.h index 9763f96..2d368df 100644 --- a/mali_kbase/mali_kbase_gpu_id.h +++ b/mali_kbase/mali_kbase_gpu_id.h @@ -101,18 +101,7 @@ #define GPU_ID2_PRODUCT_TMIX GPU_ID2_MODEL_MAKE(6u, 0) #define GPU_ID2_PRODUCT_THEX GPU_ID2_MODEL_MAKE(6u, 1) #define GPU_ID2_PRODUCT_TSIX GPU_ID2_MODEL_MAKE(7u, 0) -#ifdef MALI_INCLUDE_TDVX #define GPU_ID2_PRODUCT_TDVX GPU_ID2_MODEL_MAKE(7u, 3) -#endif /* MALI_INCLUDE_TDVX */ -#ifdef MALI_INCLUDE_TGOX -#define GPU_ID2_PRODUCT_TGOX GPU_ID2_MODEL_MAKE(7u, 2) -#endif /* MALI_INCLUDE_TGOX */ -#ifdef MALI_INCLUDE_TKAX -#define GPU_ID2_PRODUCT_TKAX GPU_ID2_MODEL_MAKE(9u, 0) -#endif /* MALI_INCLUDE_TKAX */ -#ifdef MALI_INCLUDE_TTRX -#define GPU_ID2_PRODUCT_TTRX GPU_ID2_MODEL_MAKE(10u, 0) -#endif /* MALI_INCLUDE_TTRX */ /* Values for GPU_ID_VERSION_STATUS field for PRODUCT_ID GPU_ID_PI_T60X */ #define GPU_ID_S_15DEV0 0x1 diff --git a/mali_kbase/mali_kbase_hw.c b/mali_kbase/mali_kbase_hw.c index bacb32f..eb8368c 100644 --- a/mali_kbase/mali_kbase_hw.c +++ b/mali_kbase/mali_kbase_hw.c @@ -48,26 +48,9 @@ void kbase_hw_set_features_mask(struct kbase_device *kbdev) case GPU_ID2_PRODUCT_TSIX: features = base_hw_features_tSIx; break; -#ifdef MALI_INCLUDE_TDVX case GPU_ID2_PRODUCT_TDVX: features = base_hw_features_tDVx; break; -#endif /* MALI_INCLUDE_TDVX */ -#ifdef MALI_INCLUDE_TGOX - case GPU_ID2_PRODUCT_TGOX: - features = base_hw_features_tGOx; - break; -#endif /* MALI_INCLUDE_TGOX */ -#ifdef MALI_INCLUDE_TKAX - case GPU_ID2_PRODUCT_TKAX: - features = base_hw_features_tKAx; - break; -#endif /* MALI_INCLUDE_TKAX */ -#ifdef MALI_INCLUDE_TTRX - case GPU_ID2_PRODUCT_TTRX: - features = base_hw_features_tTRx; - break; -#endif /* MALI_INCLUDE_TTRX */ default: features = base_hw_features_generic; break; @@ -143,12 +126,16 @@ static const enum base_hw_issue *kbase_hw_get_issues_for_new_id( {{GPU_ID2_VERSION_MAKE(0, 0, 1), base_hw_issues_tMIx_r0p0_05dev0}, {GPU_ID2_VERSION_MAKE(0, 0, 2), base_hw_issues_tMIx_r0p0}, + {GPU_ID2_VERSION_MAKE(0, 1, 0), base_hw_issues_tMIx_r0p1}, {U32_MAX /* sentinel value */, NULL} } }, {GPU_ID2_PRODUCT_THEX, {{GPU_ID2_VERSION_MAKE(0, 0, 0), base_hw_issues_tHEx_r0p0}, {GPU_ID2_VERSION_MAKE(0, 0, 1), base_hw_issues_tHEx_r0p0}, {GPU_ID2_VERSION_MAKE(0, 1, 0), base_hw_issues_tHEx_r0p1}, + {GPU_ID2_VERSION_MAKE(0, 1, 1), base_hw_issues_tHEx_r0p1}, + {GPU_ID2_VERSION_MAKE(0, 2, 0), base_hw_issues_tHEx_r0p2}, + {GPU_ID2_VERSION_MAKE(0, 3, 0), base_hw_issues_tHEx_r0p3}, {U32_MAX, NULL} } }, {GPU_ID2_PRODUCT_TSIX, @@ -156,32 +143,16 @@ static const enum base_hw_issue *kbase_hw_get_issues_for_new_id( {GPU_ID2_VERSION_MAKE(0, 0, 1), base_hw_issues_tSIx_r0p0}, {GPU_ID2_VERSION_MAKE(0, 1, 0), base_hw_issues_tSIx_r0p1}, {GPU_ID2_VERSION_MAKE(1, 0, 0), base_hw_issues_tSIx_r1p0}, + {GPU_ID2_VERSION_MAKE(1, 1, 0), base_hw_issues_tSIx_r1p1}, {U32_MAX, NULL} } }, -#ifdef MALI_INCLUDE_TDVX {GPU_ID2_PRODUCT_TDVX, {{GPU_ID2_VERSION_MAKE(0, 0, 0), base_hw_issues_tDVx_r0p0}, {U32_MAX, NULL} } }, -#endif /* MALI_INCLUDE_TDVX */ -#ifdef MALI_INCLUDE_TGOX - {GPU_ID2_PRODUCT_TGOX, - {{GPU_ID2_VERSION_MAKE(0, 0, 0), base_hw_issues_tGOx_r0p0}, - {U32_MAX, NULL} } }, -#endif /* MALI_INCLUDE_TGOX */ -#ifdef MALI_INCLUDE_TKAX - {GPU_ID2_PRODUCT_TKAX, - {{GPU_ID2_VERSION_MAKE(0, 0, 0), base_hw_issues_tKAx_r0p0}, - {U32_MAX, NULL} } }, -#endif /* MALI_INCLUDE_TKAX */ -#ifdef MALI_INCLUDE_TTRX - {GPU_ID2_PRODUCT_TTRX, - {{GPU_ID2_VERSION_MAKE(0, 0, 0), base_hw_issues_tTRx_r0p0}, - {U32_MAX, NULL} } }, -#endif /* MALI_INCLUDE_TTRX */ }; u32 gpu_id = kbdev->gpu_props.props.raw_props.gpu_id; @@ -396,26 +367,9 @@ int kbase_hw_set_issues_mask(struct kbase_device *kbdev) case GPU_ID2_PRODUCT_TSIX: issues = base_hw_issues_model_tSIx; break; -#ifdef MALI_INCLUDE_TDVX case GPU_ID2_PRODUCT_TDVX: issues = base_hw_issues_model_tDVx; break; -#endif /* MALI_INCLUDE_TNOX */ -#ifdef MALI_INCLUDE_TGOX - case GPU_ID2_PRODUCT_TGOX: - issues = base_hw_issues_model_tGOx; - break; -#endif /* MALI_INCLUDE_TGOX */ -#ifdef MALI_INCLUDE_TKAX - case GPU_ID2_PRODUCT_TKAX: - issues = base_hw_issues_model_tKAx; - break; -#endif /* MALI_INCLUDE_TKAX */ -#ifdef MALI_INCLUDE_TTRX - case GPU_ID2_PRODUCT_TTRX: - issues = base_hw_issues_model_tTRx; - break; -#endif /* MALI_INCLUDE_TTRX */ default: dev_err(kbdev->dev, "Unknown GPU ID %x", gpu_id); diff --git a/mali_kbase/mali_kbase_ioctl.h b/mali_kbase/mali_kbase_ioctl.h index 3957cd1..e7c1dae 100644 --- a/mali_kbase/mali_kbase_ioctl.h +++ b/mali_kbase/mali_kbase_ioctl.h @@ -325,7 +325,7 @@ union kbase_ioctl_mem_find_cpu_offset { * @id: The kernel context ID */ struct kbase_ioctl_get_context_id { - int id; /* This should really be __u32, but see GPUCORE-10048 */ + __u32 id; }; #define KBASE_IOCTL_GET_CONTEXT_ID \ diff --git a/mali_kbase/mali_kbase_jd.c b/mali_kbase/mali_kbase_jd.c index 15ed061..9f9e0c4 100644 --- a/mali_kbase/mali_kbase_jd.c +++ b/mali_kbase/mali_kbase_jd.c @@ -1219,7 +1219,7 @@ bool jd_submit_atom(struct kbase_context *kctx, const struct base_jd_atom_v2 *us #ifdef CONFIG_GPU_TRACEPOINTS katom->work_id = atomic_inc_return(&jctx->work_id); - trace_gpu_job_enqueue((u32)kctx->id, katom->work_id, + trace_gpu_job_enqueue(kctx->id, katom->work_id, kbasep_map_core_reqs_to_string(katom->core_req)); #endif diff --git a/mali_kbase/mali_kbase_jd_debugfs.h b/mali_kbase/mali_kbase_jd_debugfs.h index 0935f1d..fae3291 100644 --- a/mali_kbase/mali_kbase_jd_debugfs.h +++ b/mali_kbase/mali_kbase_jd_debugfs.h @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2014-2016 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2014-2017 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 @@ -25,10 +25,11 @@ #include <linux/debugfs.h> -#include <mali_kbase.h> - #define MALI_JD_DEBUGFS_VERSION 2 +/* Forward declarations */ +struct kbase_context; + /** * kbasep_jd_debugfs_ctx_init() - Add debugfs entries for JD system * diff --git a/mali_kbase/mali_kbase_js.c b/mali_kbase/mali_kbase_js.c index 2be32d6..219e8c8 100644 --- a/mali_kbase/mali_kbase_js.c +++ b/mali_kbase/mali_kbase_js.c @@ -1246,12 +1246,10 @@ struct kbase_context *kbasep_js_runpool_lookup_ctx(struct kbase_device *kbdev, int as_nr) { unsigned long flags; - struct kbasep_js_device_data *js_devdata; struct kbase_context *found_kctx = NULL; KBASE_DEBUG_ASSERT(kbdev != NULL); KBASE_DEBUG_ASSERT(0 <= as_nr && as_nr < BASE_MAX_NR_AS); - js_devdata = &kbdev->js_data; spin_lock_irqsave(&kbdev->hwaccess_lock, flags); @@ -2391,7 +2389,6 @@ bool kbase_js_complete_atom_wq(struct kbase_context *kctx, struct kbase_jd_atom *kbase_js_complete_atom(struct kbase_jd_atom *katom, ktime_t *end_timestamp) { - u64 microseconds_spent = 0; struct kbase_device *kbdev; struct kbase_context *kctx = katom->kctx; struct kbase_jd_atom *x_dep = katom->x_post_dep; @@ -2416,24 +2413,6 @@ struct kbase_jd_atom *kbase_js_complete_atom(struct kbase_jd_atom *katom, katom->slot_nr), NULL, 0); #endif - /* Calculate the job's time used */ - if (end_timestamp != NULL) { - /* Only calculating it for jobs that really run on the HW (e.g. - * removed from next jobs never actually ran, so really did take - * zero time) */ - ktime_t tick_diff = ktime_sub(*end_timestamp, - katom->start_timestamp); - - microseconds_spent = ktime_to_ns(tick_diff); - - do_div(microseconds_spent, 1000); - - /* Round up time spent to the minimum timer resolution */ - if (microseconds_spent < KBASEP_JS_TICK_RESOLUTION_US) - microseconds_spent = KBASEP_JS_TICK_RESOLUTION_US; - } - - kbase_jd_done(katom, katom->slot_nr, end_timestamp, 0); /* Unblock cross dependency if present */ diff --git a/mali_kbase/mali_kbase_mem.c b/mali_kbase/mali_kbase_mem.c index 6fefffe..34222cb 100644 --- a/mali_kbase/mali_kbase_mem.c +++ b/mali_kbase/mali_kbase_mem.c @@ -1510,12 +1510,15 @@ int kbase_alloc_phy_pages_helper( struct page *np = NULL; do { - int err = kbase_mem_pool_grow(&kctx->lp_mem_pool, 1); + int err; + np = kbase_mem_pool_alloc(&kctx->lp_mem_pool); + if (np) + break; + err = kbase_mem_pool_grow(&kctx->lp_mem_pool, 1); if (err) break; - np = kbase_mem_pool_alloc(&kctx->lp_mem_pool); - } while (!np); + } while (1); if (np) { int i; @@ -1571,7 +1574,7 @@ no_new_partial: kbase_zone_cache_clear(alloc); KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); alloc->nents += nr_pages_requested; @@ -1708,7 +1711,7 @@ int kbase_free_phy_pages_helper( &kctx->kbdev->memdev.used_pages); KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); } @@ -2517,8 +2520,7 @@ static int kbase_jd_umm_map(struct kbase_context *kctx, KBASE_DEBUG_ASSERT(pa); for_each_sg(sgt->sgl, s, sgt->nents, i) { - int j; - size_t pages = PFN_UP(sg_dma_len(s)); + size_t j, pages = PFN_UP(sg_dma_len(s)); WARN_ONCE(sg_dma_len(s) & (PAGE_SIZE-1), "sg_dma_len(s)=%u is not a multiple of PAGE_SIZE\n", diff --git a/mali_kbase/mali_kbase_mem.h b/mali_kbase/mali_kbase_mem.h index e9a8d5d..820a9be 100644 --- a/mali_kbase/mali_kbase_mem.h +++ b/mali_kbase/mali_kbase_mem.h @@ -256,8 +256,7 @@ struct kbase_va_region { /* Can grow on pf? */ #define KBASE_REG_PF_GROW (1ul << 7) -/* VA managed by us */ -#define KBASE_REG_CUSTOM_VA (1ul << 8) +/* Bit 8 is unused */ /* inner shareable coherency */ #define KBASE_REG_SHARE_IN (1ul << 9) @@ -285,6 +284,11 @@ struct kbase_va_region { /* Imported buffer is padded? */ #define KBASE_REG_IMPORT_PAD (1ul << 21) +/* Bit 22 is reserved. + * + * Do not remove, use the next unreserved bit for new flags */ +#define KBASE_REG_RESERVED_BIT_22 (1ul << 22) + #define KBASE_REG_ZONE_SAME_VA KBASE_REG_ZONE(0) /* only used with 32-bit clients */ diff --git a/mali_kbase/mali_kbase_mem_linux.c b/mali_kbase/mali_kbase_mem_linux.c index b1f2c46..842444c 100644 --- a/mali_kbase/mali_kbase_mem_linux.c +++ b/mali_kbase/mali_kbase_mem_linux.c @@ -589,7 +589,7 @@ static void kbase_mem_evictable_mark_reclaim(struct kbase_mem_phy_alloc *alloc) kbase_atomic_sub_pages(alloc->nents, &kctx->kbdev->memdev.used_pages); KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); } @@ -637,7 +637,7 @@ void kbase_mem_evictable_unmark_reclaim(struct kbase_mem_phy_alloc *alloc) } KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); } @@ -796,7 +796,9 @@ int kbase_mem_flags_change(struct kbase_context *kctx, u64 gpu_addr, unsigned in switch (reg->gpu_alloc->type) { #ifdef CONFIG_UMP case KBASE_MEM_TYPE_IMPORTED_UMP: - ret = kbase_mmu_update_pages(kctx, reg->start_pfn, kbase_get_cpu_phy_pages(reg), reg->gpu_alloc->nents, reg->flags); + ret = kbase_mmu_update_pages(kctx, reg->start_pfn, + kbase_get_gpu_phy_pages(reg), + reg->gpu_alloc->nents, reg->flags); break; #endif #ifdef CONFIG_DMA_SHARED_BUFFER @@ -1788,8 +1790,14 @@ static void kbase_cpu_vm_close(struct vm_area_struct *vma) KBASE_EXPORT_TEST_API(kbase_cpu_vm_close); +#if (LINUX_VERSION_CODE < KERNEL_VERSION(4, 11, 0)) static int kbase_cpu_vm_fault(struct vm_area_struct *vma, struct vm_fault *vmf) { +#else +static int kbase_cpu_vm_fault(struct vm_fault *vmf) +{ + struct vm_area_struct *vma = vmf->vma; +#endif struct kbase_cpu_mapping *map = vma->vm_private_data; pgoff_t rel_pgoff; size_t i; @@ -2540,7 +2548,6 @@ static int kbase_tracking_page_setup(struct kbase_context *kctx, struct vm_area_ } void *kbase_va_alloc(struct kbase_context *kctx, u32 size, struct kbase_hwc_dma_mapping *handle) { - int i; int res; void *va; dma_addr_t dma_pa; @@ -2555,6 +2562,7 @@ void *kbase_va_alloc(struct kbase_context *kctx, u32 size, struct kbase_hwc_dma_ u32 pages = ((size - 1) >> PAGE_SHIFT) + 1; u32 flags = BASE_MEM_PROT_CPU_RD | BASE_MEM_PROT_CPU_WR | BASE_MEM_PROT_GPU_RD | BASE_MEM_PROT_GPU_WR; + u32 i; KBASE_DEBUG_ASSERT(kctx != NULL); KBASE_DEBUG_ASSERT(0 != size); diff --git a/mali_kbase/mali_kbase_mem_pool_debugfs.c b/mali_kbase/mali_kbase_mem_pool_debugfs.c index 585fba0..319cf25 100644 --- a/mali_kbase/mali_kbase_mem_pool_debugfs.c +++ b/mali_kbase/mali_kbase_mem_pool_debugfs.c @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2014-2015 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2014-2015, 2017 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 @@ -69,13 +69,20 @@ DEFINE_SIMPLE_ATTRIBUTE(kbase_mem_pool_debugfs_max_size_fops, "%llu\n"); void kbase_mem_pool_debugfs_init(struct dentry *parent, - struct kbase_mem_pool *pool) + struct kbase_mem_pool *pool, + struct kbase_mem_pool *lp_pool) { debugfs_create_file("mem_pool_size", S_IRUGO | S_IWUSR, parent, pool, &kbase_mem_pool_debugfs_size_fops); debugfs_create_file("mem_pool_max_size", S_IRUGO | S_IWUSR, parent, pool, &kbase_mem_pool_debugfs_max_size_fops); + + debugfs_create_file("lp_mem_pool_size", S_IRUGO | S_IWUSR, parent, + lp_pool, &kbase_mem_pool_debugfs_size_fops); + + debugfs_create_file("lp_mem_pool_max_size", S_IRUGO | S_IWUSR, parent, + lp_pool, &kbase_mem_pool_debugfs_max_size_fops); } #endif /* CONFIG_DEBUG_FS */ diff --git a/mali_kbase/mali_kbase_mem_pool_debugfs.h b/mali_kbase/mali_kbase_mem_pool_debugfs.h index 1442854..496eaf3 100644 --- a/mali_kbase/mali_kbase_mem_pool_debugfs.h +++ b/mali_kbase/mali_kbase_mem_pool_debugfs.h @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2014-2015 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2014-2015, 2017 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 @@ -22,15 +22,19 @@ /** * kbase_mem_pool_debugfs_init - add debugfs knobs for @pool - * @parent: Parent debugfs dentry - * @pool: Memory pool to control + * @parent: Parent debugfs dentry + * @pool: Memory pool of small pages to control + * @lp_pool: Memory pool of large pages to control * - * Adds two debugfs files under @parent: + * Adds four debugfs files under @parent: * - mem_pool_size: get/set the current size of @pool * - mem_pool_max_size: get/set the max size of @pool + * - lp_mem_pool_size: get/set the current size of @lp_pool + * - lp_mem_pool_max_size: get/set the max size of @lp_pool */ void kbase_mem_pool_debugfs_init(struct dentry *parent, - struct kbase_mem_pool *pool); + struct kbase_mem_pool *pool, + struct kbase_mem_pool *lp_pool); #endif /*_KBASE_MEM_POOL_DEBUGFS_H*/ diff --git a/mali_kbase/mali_kbase_mmu.c b/mali_kbase/mali_kbase_mmu.c index b3aa9e0..2dd20fc 100644 --- a/mali_kbase/mali_kbase_mmu.c +++ b/mali_kbase/mali_kbase_mmu.c @@ -411,7 +411,7 @@ phys_addr_t kbase_mmu_alloc_pgd(struct kbase_context *kctx) goto sub_pages; KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); page = kmap(p); @@ -828,7 +828,7 @@ int kbase_mmu_insert_pages_no_flush(struct kbase_context *kctx, unsigned int level_index = (insert_vpfn >> 9) & 0x1FF; u64 *target = &pgd_page[level_index]; - if (mmu_mode->pte_is_valid(*target)) + if (mmu_mode->pte_is_valid(*target, cur_level)) cleanup_empty_pte(kctx, target); mmu_mode->entry_set_ate(target, *phys, flags, cur_level); @@ -1111,7 +1111,7 @@ int kbase_mmu_teardown_pages(struct kbase_context *kctx, u64 vpfn, size_t nr) page = kmap(phys_to_page(pgd)); if (mmu_mode->ate_is_valid(page[index], level)) break; /* keep the mapping */ - else if (!mmu_mode->pte_is_valid(page[index])) { + else if (!mmu_mode->pte_is_valid(page[index], level)) { /* nothing here, advance */ switch (level) { case MIDGARD_MMU_LEVEL(0): @@ -1315,7 +1315,7 @@ static void mmu_teardown_level(struct kbase_context *kctx, phys_addr_t pgd, target_pgd = mmu_mode->pte_to_phy_addr(pgd_page[i]); if (target_pgd) { - if (mmu_mode->pte_is_valid(pgd_page[i])) { + if (mmu_mode->pte_is_valid(pgd_page[i], level)) { mmu_teardown_level(kctx, target_pgd, level + 1, @@ -1370,7 +1370,7 @@ void kbase_mmu_free_pgd(struct kbase_context *kctx) mutex_unlock(&kctx->mmu_lock); KBASE_TLSTREAM_AUX_PAGESALLOC( - (u32)kctx->id, + kctx->id, (u64)new_page_count); } @@ -1413,7 +1413,7 @@ static size_t kbasep_mmu_dump_level(struct kbase_context *kctx, phys_addr_t pgd, if (level < MIDGARD_MMU_BOTTOMLEVEL) { for (i = 0; i < KBASE_MMU_PAGE_ENTRIES; i++) { - if (mmu_mode->pte_is_valid(pgd_page[i])) { + if (mmu_mode->pte_is_valid(pgd_page[i], level)) { target_pgd = mmu_mode->pte_to_phy_addr( pgd_page[i]); @@ -1458,7 +1458,7 @@ void *kbase_mmu_dump(struct kbase_context *kctx, int nr_pages) char *buffer; char *mmu_dump_buffer; u64 config[3]; - size_t size; + size_t dump_size, size = 0; buffer = (char *)kaddr; mmu_dump_buffer = buffer; @@ -1473,27 +1473,24 @@ void *kbase_mmu_dump(struct kbase_context *kctx, int nr_pages) memcpy(buffer, &config, sizeof(config)); mmu_dump_buffer += sizeof(config); size_left -= sizeof(config); + size += sizeof(config); } - - - size = kbasep_mmu_dump_level(kctx, + dump_size = kbasep_mmu_dump_level(kctx, kctx->pgd, MIDGARD_MMU_TOPLEVEL, &mmu_dump_buffer, &size_left); - if (!size) + if (!dump_size) goto fail_free; + size += dump_size; + /* Add on the size for the end marker */ size += sizeof(u64); - /* Add on the size for the config */ - if (kctx->api_version >= KBASE_API_VERSION(8, 4)) - size += sizeof(config); - - if (size > nr_pages * PAGE_SIZE || size_left < sizeof(u64)) { + if (size > (nr_pages * PAGE_SIZE)) { /* The buffer isn't big enough - free the memory and return failure */ goto fail_free; } diff --git a/mali_kbase/mali_kbase_mmu_mode.h b/mali_kbase/mali_kbase_mmu_mode.h deleted file mode 100644 index a2c3862..0000000 --- a/mali_kbase/mali_kbase_mmu_mode.h +++ /dev/null @@ -1,49 +0,0 @@ -/* - * - * (C) COPYRIGHT 2014-2015,2017 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 _MALI_KBASE_MMU_MODE_ -#define _MALI_KBASE_MMU_MODE_ - -#include <linux/types.h> -#include <mali_kbase.h> - -/* Forward declarations */ -struct kbase_context; -struct kbase_device; -struct kbase_as; -struct kbase_mmu_setup; - -struct kbase_mmu_mode { - void (*update)(struct kbase_context *kctx); - void (*get_as_setup)(struct kbase_context *kctx, - struct kbase_mmu_setup * const setup); - void (*disable_as)(struct kbase_device *kbdev, int as_nr); - phys_addr_t (*pte_to_phy_addr)(u64 entry); - int (*ate_is_valid)(u64 ate, unsigned int level); - int (*pte_is_valid)(u64 pte); - void (*entry_set_ate)(u64 *entry, struct tagged_addr phy, - unsigned long flags, unsigned int level); - void (*entry_set_pte)(u64 *entry, phys_addr_t phy); - void (*entry_invalidate)(u64 *entry); -}; - -struct kbase_mmu_mode const *kbase_mmu_mode_get_lpae(void); -struct kbase_mmu_mode const *kbase_mmu_mode_get_aarch64(void); - -#endif /* _MALI_KBASE_MMU_MODE_ */ diff --git a/mali_kbase/mali_kbase_mmu_mode_aarch64.c b/mali_kbase/mali_kbase_mmu_mode_aarch64.c index eccb33a..0fb717b 100644 --- a/mali_kbase/mali_kbase_mmu_mode_aarch64.c +++ b/mali_kbase/mali_kbase_mmu_mode_aarch64.c @@ -17,10 +17,9 @@ -#include "mali_kbase_mmu_mode.h" - #include "mali_kbase.h" #include "mali_midg_regmap.h" +#include "mali_kbase_defs.h" #define ENTRY_TYPE_MASK 3ULL /* For valid ATEs bit 1 = ((level == 3) ? 1 : 0). @@ -131,8 +130,11 @@ static int ate_is_valid(u64 ate, unsigned int level) return ((ate & ENTRY_TYPE_MASK) == ENTRY_IS_ATE_L02); } -static int pte_is_valid(u64 pte) +static int pte_is_valid(u64 pte, unsigned int level) { + /* PTEs cannot exist at the bottom level */ + if (level == MIDGARD_MMU_BOTTOMLEVEL) + return false; return ((pte & ENTRY_TYPE_MASK) == ENTRY_IS_PTE); } diff --git a/mali_kbase/mali_kbase_mmu_mode_lpae.c b/mali_kbase/mali_kbase_mmu_mode_lpae.c index 5500127..f080fdc 100644 --- a/mali_kbase/mali_kbase_mmu_mode_lpae.c +++ b/mali_kbase/mali_kbase_mmu_mode_lpae.c @@ -17,10 +17,9 @@ -#include "mali_kbase_mmu_mode.h" - #include "mali_kbase.h" #include "mali_midg_regmap.h" +#include "mali_kbase_defs.h" #define ENTRY_TYPE_MASK 3ULL #define ENTRY_IS_ATE 1ULL @@ -130,7 +129,7 @@ static int ate_is_valid(u64 ate, unsigned int level) return ((ate & ENTRY_TYPE_MASK) == ENTRY_IS_ATE); } -static int pte_is_valid(u64 pte) +static int pte_is_valid(u64 pte, unsigned int level) { return ((pte & ENTRY_TYPE_MASK) == ENTRY_IS_PTE); } diff --git a/mali_kbase/mali_kbase_platform_fake.c b/mali_kbase/mali_kbase_platform_fake.c index 1a44957..0152b35 100644 --- a/mali_kbase/mali_kbase_platform_fake.c +++ b/mali_kbase/mali_kbase_platform_fake.c @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2011-2014, 2016 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2011-2014, 2016-2017 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 @@ -15,8 +15,6 @@ -#ifdef CONFIG_MALI_PLATFORM_FAKE - #include <linux/errno.h> #include <linux/export.h> #include <linux/ioport.h> @@ -74,7 +72,7 @@ static void kbasep_config_parse_io_resources(const struct kbase_io_resources *io } #endif /* CONFIG_OF */ -int kbase_platform_fake_register(void) +int kbase_platform_register(void) { struct kbase_platform_config *config; #ifndef CONFIG_OF @@ -111,14 +109,11 @@ int kbase_platform_fake_register(void) return 0; } -EXPORT_SYMBOL(kbase_platform_fake_register); +EXPORT_SYMBOL(kbase_platform_register); -void kbase_platform_fake_unregister(void) +void kbase_platform_unregister(void) { if (mali_device) platform_device_unregister(mali_device); } -EXPORT_SYMBOL(kbase_platform_fake_unregister); - -#endif /* CONFIG_MALI_PLATFORM_FAKE */ - +EXPORT_SYMBOL(kbase_platform_unregister); diff --git a/mali_kbase/mali_kbase_softjobs.c b/mali_kbase/mali_kbase_softjobs.c index 29e76a9..cd86b98 100644 --- a/mali_kbase/mali_kbase_softjobs.c +++ b/mali_kbase/mali_kbase_softjobs.c @@ -35,9 +35,8 @@ #include <linux/ktime.h> #include <linux/pfn.h> #include <linux/sched.h> - -/* Mask to check cache alignment of data structures */ -#define KBASE_CACHE_ALIGNMENT_MASK ((1<<L1_CACHE_SHIFT)-1) +#include <linux/kernel.h> +#include <linux/cache.h> /** * @file mali_kbase_softjobs.c @@ -710,12 +709,11 @@ out_unlock: kbase_gpu_vm_unlock(katom->kctx); out_cleanup: - kfree(buffers); - kfree(user_buffers); - /* Frees allocated memory for kbase_debug_copy_job struct, including * members, and sets jc to 0 */ kbase_debug_copy_finish(katom); + kfree(user_buffers); + return ret; } @@ -770,6 +768,7 @@ static int kbase_mem_copy_from_extres(struct kbase_context *kctx, u64 offset = buf_data->offset; size_t extres_size = buf_data->nr_extres_pages*PAGE_SIZE; size_t to_copy = min(extres_size, buf_data->size); + size_t dma_to_copy; struct kbase_mem_phy_alloc *gpu_alloc = buf_data->gpu_alloc; int ret = 0; @@ -807,18 +806,20 @@ static int kbase_mem_copy_from_extres(struct kbase_context *kctx, struct dma_buf *dma_buf = gpu_alloc->imported.umm.dma_buf; KBASE_DEBUG_ASSERT(dma_buf != NULL); - KBASE_DEBUG_ASSERT(dma_buf->size == - buf_data->nr_extres_pages * PAGE_SIZE); + if (dma_buf->size > buf_data->nr_extres_pages * PAGE_SIZE) + dev_warn(kctx->kbdev->dev, "External resources buffer size mismatch"); + dma_to_copy = min(dma_buf->size, + (size_t)(buf_data->nr_extres_pages * PAGE_SIZE)); ret = dma_buf_begin_cpu_access(dma_buf, #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) && !defined(CONFIG_CHROMEOS) - 0, buf_data->nr_extres_pages*PAGE_SIZE, + 0, dma_to_copy, #endif DMA_FROM_DEVICE); if (ret) goto out_unlock; - for (i = 0; i < buf_data->nr_extres_pages; i++) { + for (i = 0; i < dma_to_copy/PAGE_SIZE; i++) { void *extres_page = dma_buf_kmap(dma_buf, i); @@ -835,7 +836,7 @@ static int kbase_mem_copy_from_extres(struct kbase_context *kctx, } dma_buf_end_cpu_access(dma_buf, #if LINUX_VERSION_CODE < KERNEL_VERSION(4, 6, 0) && !defined(CONFIG_CHROMEOS) - 0, buf_data->nr_extres_pages*PAGE_SIZE, + 0, dma_to_copy, #endif DMA_FROM_DEVICE); break; @@ -1348,7 +1349,7 @@ int kbase_prepare_soft_job(struct kbase_jd_atom *katom) switch (katom->core_req & BASE_JD_REQ_SOFT_JOB_TYPE) { case BASE_JD_REQ_SOFT_DUMP_CPU_GPU_TIME: { - if (0 != (katom->jc & KBASE_CACHE_ALIGNMENT_MASK)) + if (!IS_ALIGNED(katom->jc, cache_line_size())) return -EINVAL; } break; diff --git a/mali_kbase/mali_kbase_sync_file.c b/mali_kbase/mali_kbase_sync_file.c index 4e1621c..ef5b7ce 100644 --- a/mali_kbase/mali_kbase_sync_file.c +++ b/mali_kbase/mali_kbase_sync_file.c @@ -161,7 +161,11 @@ static void kbase_fence_wait_callback(struct dma_fence *fence, struct kbase_context *kctx = katom->kctx; /* Cancel atom if fence is erroneous */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) + if (dma_fence_is_signaled(kcb->fence) && kcb->fence->error) +#else if (dma_fence_is_signaled(kcb->fence) && kcb->fence->status < 0) +#endif katom->event_code = BASE_JD_EVENT_JOB_CANCELLED; if (kbase_fence_dep_count_dec_and_test(katom)) { @@ -273,8 +277,13 @@ static void kbase_sync_fence_info_get(struct dma_fence *fence, * 1 : signaled */ if (dma_fence_is_signaled(fence)) { - if (fence->status < 0) - info->status = fence->status; /* signaled with error */ +#if (LINUX_VERSION_CODE >= KERNEL_VERSION(4, 11, 0)) + int status = fence->error; +#else + int status = fence->status; +#endif + if (status < 0) + info->status = status; /* signaled with error */ else info->status = 1; /* signaled with success */ } else { diff --git a/mali_kbase/mali_kbase_tlstream.c b/mali_kbase/mali_kbase_tlstream.c index c952993..d01aa23 100644 --- a/mali_kbase/mali_kbase_tlstream.c +++ b/mali_kbase/mali_kbase_tlstream.c @@ -1427,7 +1427,7 @@ static void kbase_create_timeline_objects(struct kbase_context *kctx) list_for_each_entry(element, &kbdev->kctx_list, link) { KBASE_TLSTREAM_TL_SUMMARY_NEW_CTX( element->kctx, - (u32)(element->kctx->id), + element->kctx->id, (u32)(element->kctx->tgid)); } /* Before releasing the lock, reset body stream buffers. diff --git a/mali_kbase/mali_kbase_vinstr.c b/mali_kbase/mali_kbase_vinstr.c index 165841d..ed12945 100644 --- a/mali_kbase/mali_kbase_vinstr.c +++ b/mali_kbase/mali_kbase_vinstr.c @@ -373,7 +373,7 @@ static void kbasep_vinstr_unmap_kernel_dump_buffer( static int kbasep_vinstr_create_kctx(struct kbase_vinstr_context *vinstr_ctx) { struct kbase_device *kbdev = vinstr_ctx->kbdev; - struct kbasep_kctx_list_element *element; + struct kbasep_kctx_list_element *element = NULL; unsigned long flags; bool enable_backend = false; int err; @@ -385,11 +385,8 @@ static int kbasep_vinstr_create_kctx(struct kbase_vinstr_context *vinstr_ctx) /* Map the master kernel dump buffer. The HW dumps the counters * into this memory region. */ err = kbasep_vinstr_map_kernel_dump_buffer(vinstr_ctx); - if (err) { - kbase_destroy_context(vinstr_ctx->kctx); - vinstr_ctx->kctx = NULL; - return err; - } + if (err) + goto failed_map; /* Add kernel context to list of contexts associated with device. */ element = kzalloc(sizeof(*element), GFP_KERNEL); @@ -403,7 +400,7 @@ static int kbasep_vinstr_create_kctx(struct kbase_vinstr_context *vinstr_ctx) * being created in both body and summary stream. */ KBASE_TLSTREAM_TL_NEW_CTX( vinstr_ctx->kctx, - (u32)(vinstr_ctx->kctx->id), + vinstr_ctx->kctx->id, (u32)(vinstr_ctx->kctx->tgid)); mutex_unlock(&kbdev->kctx_list_lock); @@ -423,41 +420,38 @@ static int kbasep_vinstr_create_kctx(struct kbase_vinstr_context *vinstr_ctx) spin_unlock_irqrestore(&vinstr_ctx->state_lock, flags); if (enable_backend) err = enable_hwcnt(vinstr_ctx); - - if (err) { - kbasep_vinstr_unmap_kernel_dump_buffer(vinstr_ctx); - kbase_destroy_context(vinstr_ctx->kctx); - if (element) { - mutex_lock(&kbdev->kctx_list_lock); - list_del(&element->link); - kfree(element); - mutex_unlock(&kbdev->kctx_list_lock); - } - KBASE_TLSTREAM_TL_DEL_CTX(vinstr_ctx->kctx); - vinstr_ctx->kctx = NULL; - return err; - } + if (err) + goto failed_enable; vinstr_ctx->thread = kthread_run( kbasep_vinstr_service_task, vinstr_ctx, "mali_vinstr_service"); if (IS_ERR(vinstr_ctx->thread)) { - disable_hwcnt(vinstr_ctx); - kbasep_vinstr_unmap_kernel_dump_buffer(vinstr_ctx); - kbase_destroy_context(vinstr_ctx->kctx); - if (element) { - mutex_lock(&kbdev->kctx_list_lock); - list_del(&element->link); - kfree(element); - mutex_unlock(&kbdev->kctx_list_lock); - } - KBASE_TLSTREAM_TL_DEL_CTX(vinstr_ctx->kctx); - vinstr_ctx->kctx = NULL; - return -EFAULT; + err = PTR_ERR(vinstr_ctx->thread); + goto failed_kthread; } return 0; + +failed_kthread: + disable_hwcnt(vinstr_ctx); +failed_enable: + spin_lock_irqsave(&vinstr_ctx->state_lock, flags); + vinstr_ctx->clients_present = false; + spin_unlock_irqrestore(&vinstr_ctx->state_lock, flags); + kbasep_vinstr_unmap_kernel_dump_buffer(vinstr_ctx); + if (element) { + mutex_lock(&kbdev->kctx_list_lock); + list_del(&element->link); + kfree(element); + mutex_unlock(&kbdev->kctx_list_lock); + KBASE_TLSTREAM_TL_DEL_CTX(vinstr_ctx->kctx); + } +failed_map: + kbase_destroy_context(vinstr_ctx->kctx); + vinstr_ctx->kctx = NULL; + return err; } /** @@ -476,7 +470,6 @@ static void kbasep_vinstr_destroy_kctx(struct kbase_vinstr_context *vinstr_ctx) vinstr_ctx->thread = NULL; disable_hwcnt(vinstr_ctx); kbasep_vinstr_unmap_kernel_dump_buffer(vinstr_ctx); - kbase_destroy_context(vinstr_ctx->kctx); /* Simplify state transitions by specifying that we have no clients. */ spin_lock_irqsave(&vinstr_ctx->state_lock, flags); @@ -497,6 +490,9 @@ static void kbasep_vinstr_destroy_kctx(struct kbase_vinstr_context *vinstr_ctx) if (!found) dev_warn(kbdev->dev, "kctx not in kctx_list\n"); + /* Destroy context. */ + kbase_destroy_context(vinstr_ctx->kctx); + /* Inform timeline client about context destruction. */ KBASE_TLSTREAM_TL_DEL_CTX(vinstr_ctx->kctx); diff --git a/mali_kbase/mali_midg_regmap.h b/mali_kbase/mali_midg_regmap.h index 7d7b7bc..554ed8d 100644 --- a/mali_kbase/mali_midg_regmap.h +++ b/mali_kbase/mali_midg_regmap.h @@ -163,7 +163,7 @@ #define L2_PWROFF_HI 0x1E4 /* (WO) Level 2 cache power off bitmap, high word */ #define STACK_PWROFF_LO 0xE30 /* (RO) Core stack power off bitmap, low word */ -#define STACK_PRWOFF_HI 0xE34 /* (RO) Core stack power off bitmap, high word */ +#define STACK_PWROFF_HI 0xE34 /* (RO) Core stack power off bitmap, high word */ #define SHADER_PWRTRANS_LO 0x200 /* (RO) Shader core power transition bitmap, low word */ @@ -176,7 +176,7 @@ #define L2_PWRTRANS_HI 0x224 /* (RO) Level 2 cache power transition bitmap, high word */ #define STACK_PWRTRANS_LO 0xE40 /* (RO) Core stack power transition bitmap, low word */ -#define STACK_PRWTRANS_HI 0xE44 /* (RO) Core stack power transition bitmap, high word */ +#define STACK_PWRTRANS_HI 0xE44 /* (RO) Core stack power transition bitmap, high word */ #define SHADER_PWRACTIVE_LO 0x240 /* (RO) Shader core active bitmap, low word */ @@ -513,9 +513,8 @@ /* Set to write back memory, outer caching */ #define AS_MEMATTR_LPAE_OUTER_WA 0x8Dull -/* Symbol for default MEMATTR to use */ - -/* Default is - HW implementation defined caching */ +/* Symbols for default MEMATTR to use + * Default is - HW implementation defined caching */ #define AS_MEMATTR_INDEX_DEFAULT 0 #define AS_MEMATTR_INDEX_DEFAULT_ACE 3 @@ -585,6 +584,7 @@ #define SC_SDC_DISABLE_OQ_DISCARD (1ul << 6) #define SC_LS_ALLOW_ATTR_TYPES (1ul << 16) #define SC_LS_PAUSEBUFFER_DISABLE (1ul << 16) +#define SC_TLS_HASH_ENABLE (1ul << 17) #define SC_LS_ATTR_CHECK_DISABLE (1ul << 18) #define SC_ENABLE_TEXGRD_FLAGS (1ul << 25) /* End SHADER_CONFIG register */ diff --git a/mali_kbase/platform/Kconfig b/mali_kbase/platform/Kconfig index 8fb4e91..38835d3 100644 --- a/mali_kbase/platform/Kconfig +++ b/mali_kbase/platform/Kconfig @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2012 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2012-2013, 2017 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 @@ -19,6 +19,6 @@ # # "drivers/gpu/arm/midgard/platform/xxx/Kconfig" # -# Where xxx is the platform name is the name set in MALI_PLATFORM_THIRDPARTY_NAME +# Where xxx is the platform name is the name set in MALI_PLATFORM_NAME # diff --git a/mali_kbase/platform/devicetree/Kbuild b/mali_kbase/platform/devicetree/Kbuild index e888a42..d40d798 100644 --- a/mali_kbase/platform/devicetree/Kbuild +++ b/mali_kbase/platform/devicetree/Kbuild @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2012-2016 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2012-2017 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 @@ -14,5 +14,5 @@ mali_kbase-y += \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_config_devicetree.o \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_runtime_pm.o + $(MALI_PLATFORM_DIR)/mali_kbase_config_devicetree.o \ + $(MALI_PLATFORM_DIR)/mali_kbase_runtime_pm.o diff --git a/mali_kbase/platform/devicetree/mali_kbase_config_devicetree.c b/mali_kbase/platform/devicetree/mali_kbase_config_devicetree.c index b2a7c93..29ccc29 100644 --- a/mali_kbase/platform/devicetree/mali_kbase_config_devicetree.c +++ b/mali_kbase/platform/devicetree/mali_kbase_config_devicetree.c @@ -1,6 +1,6 @@ /* * - * (C) COPYRIGHT 2015 ARM Limited. All rights reserved. + * (C) COPYRIGHT 2015, 2017 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 @@ -29,3 +29,12 @@ struct kbase_platform_config *kbase_get_platform_config(void) { return &dummy_platform_config; } + +int kbase_platform_register(void) +{ + return 0; +} + +void kbase_platform_unregister(void) +{ +} diff --git a/mali_kbase/platform/devicetree/mali_kbase_runtime_pm.c b/mali_kbase/platform/devicetree/mali_kbase_runtime_pm.c index 50cfb2c..9fe37c8 100644 --- a/mali_kbase/platform/devicetree/mali_kbase_runtime_pm.c +++ b/mali_kbase/platform/devicetree/mali_kbase_runtime_pm.c @@ -18,7 +18,6 @@ #include <mali_kbase.h> #include <mali_kbase_defs.h> #include <linux/pm_runtime.h> -#include <linux/suspend.h> #include "mali_kbase_config_platform.h" static int pm_callback_power_on(struct kbase_device *kbdev) diff --git a/mali_kbase/platform/mali_kbase_platform_fake.h b/mali_kbase/platform/mali_kbase_platform_fake.h deleted file mode 100644 index 01f9dfc..0000000 --- a/mali_kbase/platform/mali_kbase_platform_fake.h +++ /dev/null @@ -1,38 +0,0 @@ -/* - * - * (C) COPYRIGHT 2010-2014 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. - * - */ - - - -#ifdef CONFIG_MALI_PLATFORM_FAKE - -/** - * kbase_platform_fake_register - Entry point for fake platform registration - * - * This function is called early on in the initialization during execution of - * kbase_driver_init. - * - * Return: 0 to indicate success, non-zero for failure. - */ -int kbase_platform_fake_register(void); - -/** - * kbase_platform_fake_unregister - Entry point for fake platform unregistration - * - * This function is called in the termination during execution of - * kbase_driver_exit. - */ -void kbase_platform_fake_unregister(void); - -#endif /* CONFIG_MALI_PLATFORM_FAKE */ diff --git a/mali_kbase/platform/vexpress/Kbuild b/mali_kbase/platform/vexpress/Kbuild index 1caa293..d9d5e90 100644 --- a/mali_kbase/platform/vexpress/Kbuild +++ b/mali_kbase/platform/vexpress/Kbuild @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2012-2013, 2016 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2012-2013, 2016-2017 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 @@ -14,5 +14,6 @@ mali_kbase-y += \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_config_vexpress.o \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_cpu_vexpress.o + $(MALI_PLATFORM_DIR)/mali_kbase_config_vexpress.o \ + $(MALI_PLATFORM_DIR)/mali_kbase_cpu_vexpress.o \ + mali_kbase_platform_fake.o diff --git a/mali_kbase/platform/vexpress_1xv7_a57/Kbuild b/mali_kbase/platform/vexpress_1xv7_a57/Kbuild index 7efe8fa..df87c74 100644 --- a/mali_kbase/platform/vexpress_1xv7_a57/Kbuild +++ b/mali_kbase/platform/vexpress_1xv7_a57/Kbuild @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2013-2014, 2016 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2013-2014, 2016-2017 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 @@ -13,4 +13,6 @@ # -mali_kbase-y += $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_config_vexpress.o +mali_kbase-y += \ + $(MALI_PLATFORM_DIR)/mali_kbase_config_vexpress.o \ + mali_kbase_platform_fake.o diff --git a/mali_kbase/platform/vexpress_6xvirtex7_10mhz/Kbuild b/mali_kbase/platform/vexpress_6xvirtex7_10mhz/Kbuild index 1caa293..d9d5e90 100644 --- a/mali_kbase/platform/vexpress_6xvirtex7_10mhz/Kbuild +++ b/mali_kbase/platform/vexpress_6xvirtex7_10mhz/Kbuild @@ -1,5 +1,5 @@ # -# (C) COPYRIGHT 2012-2013, 2016 ARM Limited. All rights reserved. +# (C) COPYRIGHT 2012-2013, 2016-2017 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 @@ -14,5 +14,6 @@ mali_kbase-y += \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_config_vexpress.o \ - $(MALI_PLATFORM_THIRDPARTY_DIR)/mali_kbase_cpu_vexpress.o + $(MALI_PLATFORM_DIR)/mali_kbase_config_vexpress.o \ + $(MALI_PLATFORM_DIR)/mali_kbase_cpu_vexpress.o \ + mali_kbase_platform_fake.o diff --git a/mali_kbase/sconscript b/mali_kbase/sconscript index ff23d7a..e738dd7 100644 --- a/mali_kbase/sconscript +++ b/mali_kbase/sconscript @@ -20,19 +20,13 @@ SConscript( 'tests/sconscript' ) mock_test = 0 -# Fake platform is a transient solution for GPL drivers running in kernel that does not provide configuration via platform data. -# For such kernels fake_platform_device should be set to 1. For kernels providing platform data fake_platform_device should be set to 0. -if env['platform_config']=='devicetree' or env['platform_config']=='juno_soc': - fake_platform_device = 0 -else: - fake_platform_device = 1 - # Source files required for kbase. kbase_src = [ Glob('*.c'), Glob('backend/*/*.c'), Glob('internal/*/*.c'), - Glob('ipa/*.c') + Glob('ipa/*.c'), + Glob('platform/%s/*.c' % env['platform_config']), ] if env['platform_config']=='juno_soc': @@ -44,20 +38,7 @@ if Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock') and env['unit kbase_src += [Glob('#kernel/drivers/gpu/arm/midgard/tests/internal/src/mock/*.c')] mock_test = 1 -# we need platform config for GPL version using fake platform -if fake_platform_device==1: - # Check if we are compiling for PBX - if env.KernelConfigEnabled("CONFIG_MACH_REALVIEW_PBX") and \ - env["platform_config"] in {"vexpress", "vexpress_6xvirtex7_10mhz"}: - sys.stderr.write("WARNING: Building for a PBX kernel but with platform_config=vexpress*\n") - # if the file platform config file is in the tpip directory then use that, otherwise use the default config directory - if Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config'])): - kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/tpip/*%s.c' % (env['platform_config'])) - else: - kbase_src += Glob('#kernel/drivers/gpu/arm/midgard/config/*%s.c' % (env['platform_config'])) - -make_args = env.kernel_get_config_defines(ret_list = True, - fake = fake_platform_device) + [ +make_args = env.kernel_get_config_defines(ret_list = True) + [ 'PLATFORM=%s' % env['platform'], 'MALI_ERROR_INJECT_ON=%s' % env['error_inject'], 'MALI_KERNEL_TEST_API=%s' % env['debug'], @@ -67,7 +48,6 @@ make_args = env.kernel_get_config_defines(ret_list = True, 'MALI_CUSTOMER_RELEASE=%s' % env['release'], 'MALI_INSTRUMENTATION_LEVEL=%s' % env['instr'], 'MALI_COVERAGE=%s' % env['coverage'], - 'MALI_BUS_LOG=%s' % env['buslog'] ] kbase = env.BuildKernelModule('$STATIC_LIB_PATH/mali_kbase.ko', kbase_src, diff --git a/mali_kbase/tests/kutf/kutf_helpers_user.c b/mali_kbase/tests/kutf/kutf_helpers_user.c index 5c34120..cf3b005 100644 --- a/mali_kbase/tests/kutf/kutf_helpers_user.c +++ b/mali_kbase/tests/kutf/kutf_helpers_user.c @@ -322,7 +322,6 @@ int kutf_helper_textbuf_receive_named_val(struct kutf_helper_named_val *named_va err = KUTF_HELPER_ERR_NO_END_DELIMITER; } } else { - int err; /* possibly a number value - strtoull will parse it */ err = kstrtoull(recv_str, 0, &u64val); /* unlike userspace can't get an end ptr, but if kstrtoull() @@ -336,7 +335,6 @@ int kutf_helper_textbuf_receive_named_val(struct kutf_helper_named_val *named_va } else { /* special case: not a number, report as such */ pr_err("Rest of received string was not a numeric value or quoted string value: '%s'\n", recv_str); - err = KUTF_HELPER_ERR_INVALID_VALUE; } } diff --git a/mali_kbase/tests/mali_kutf_irq_test/Makefile b/mali_kbase/tests/mali_kutf_irq_test/Makefile index 4e94876..2ac4f97 100644 --- a/mali_kbase/tests/mali_kutf_irq_test/Makefile +++ b/mali_kbase/tests/mali_kutf_irq_test/Makefile @@ -25,11 +25,7 @@ endif TEST_CCFLAGS := \ -DMALI_DEBUG=$(MALI_DEBUG) \ -DMALI_BACKEND_KERNEL=$(MALI_BACKEND_KERNEL) \ - -DMALI_MODEL=$(MALI_MODEL) \ -DMALI_NO_MALI=$(MALI_NO_MALI) \ - -DMALI_BASE_QA_LEAK=$(MALI_BASE_QA_LEAK) \ - -DMALI_BASE_QA_RESFAIL=$(MALI_BASE_QA_RESFAIL) \ - -DMALI_BASE_QA_USE_AFTER_FREE=$(MALI_BASE_QA_USE_AFTER_FREE) \ -DMALI_UNIT_TEST=$(MALI_UNIT_TEST) \ -DMALI_USE_UMP=$(MALI_USE_UMP) \ -DMALI_ERROR_INJECT_ON=$(MALI_ERROR_INJECT_ON) \ diff --git a/mali_kbase/tests/mali_kutf_irq_test/sconscript b/mali_kbase/tests/mali_kutf_irq_test/sconscript index ec837f1..280fa98 100644 --- a/mali_kbase/tests/mali_kutf_irq_test/sconscript +++ b/mali_kbase/tests/mali_kutf_irq_test/sconscript @@ -23,7 +23,7 @@ if env.GetOption('clean') : cmd = env.Command('$STATIC_LIB_PATH/mali_kutf_irq_test.ko', src, []) env.KernelObjTarget('mali_kutf_irq_test', cmd) else: - makeAction=Action("cd ${SOURCE.dir} && make MALI_DEBUG=${debug} MALI_BACKEND_KERNEL=1 MALI_ERROR_INJECT_ON=${error_inject} MALI_MODEL=${mali_model} MALI_NO_MALI=${no_mali} MALI_HW_VERSION=${hwver} MALI_UNIT_TEST=${unit} MALI_USE_UMP=${ump} MALI_CUSTOMER_RELEASE=${release} %s %s && ( ( [ -f mali_kutf_irq_test.ko ] && cp mali_kutf_irq_test.ko $STATIC_LIB_PATH/ ) || touch $STATIC_LIB_PATH/mali_kutf_irq_test.ko)" % (env.base_get_qa_settings(), env.kernel_get_config_defines()), '$MAKECOMSTR') + makeAction=Action("cd ${SOURCE.dir} && make MALI_DEBUG=${debug} MALI_BACKEND_KERNEL=1 MALI_ERROR_INJECT_ON=${error_inject} MALI_NO_MALI=${no_mali} MALI_UNIT_TEST=${unit} MALI_USE_UMP=${ump} MALI_CUSTOMER_RELEASE=${release} %s && ( ( [ -f mali_kutf_irq_test.ko ] && cp mali_kutf_irq_test.ko $STATIC_LIB_PATH/ ) || touch $STATIC_LIB_PATH/mali_kutf_irq_test.ko)" % env.kernel_get_config_defines(), '$MAKECOMSTR') cmd = env.Command('$STATIC_LIB_PATH/mali_kutf_irq_test.ko', src, [makeAction]) env.Depends('$STATIC_LIB_PATH/mali_kutf_irq_test.ko', '$STATIC_LIB_PATH/kutf.ko') env.Depends('$STATIC_LIB_PATH/mali_kutf_irq_test.ko', '$STATIC_LIB_PATH/mali_kbase.ko') |