From a6dcc0db77568bf88079732d2ac0e092fadbea66 Mon Sep 17 00:00:00 2001 From: Jordan Crouse Date: Mon, 14 Oct 2019 10:41:04 -0600 Subject: [PATCH] msm: kgsl: Consolidate zap shader loading The zap shader is loaded the same way for both a5xx and a6xx targets so consolidate the support in the generic Adreno code. Change-Id: Ic0dedbad964eef9054b549d0df9ba7e84d653f62 Signed-off-by: Jordan Crouse --- drivers/gpu/msm/Kconfig | 1 + drivers/gpu/msm/adreno.c | 18 ++++++++++++++++ drivers/gpu/msm/adreno.h | 11 ++++++++++ drivers/gpu/msm/adreno_a5xx.c | 40 ++++++++++++----------------------- drivers/gpu/msm/adreno_a6xx.c | 19 ++--------------- 5 files changed, 46 insertions(+), 43 deletions(-) diff --git a/drivers/gpu/msm/Kconfig b/drivers/gpu/msm/Kconfig index aec807e3e2a7..9017f1a7c915 100644 --- a/drivers/gpu/msm/Kconfig +++ b/drivers/gpu/msm/Kconfig @@ -3,6 +3,7 @@ config QCOM_KGSL tristate "Qualcomm Technologies, Inc. 3D Graphics driver" depends on ARCH_QCOM depends on QCOM_QFPROM + select MSM_SUBSYSTEM_RESTART help 3D graphics driver for the Adreno family of GPUs from QTI. Required to use hardware accelerated OpenGL, compute and Vulkan diff --git a/drivers/gpu/msm/adreno.c b/drivers/gpu/msm/adreno.c index cd0154a78b85..5170701d9e38 100644 --- a/drivers/gpu/msm/adreno.c +++ b/drivers/gpu/msm/adreno.c @@ -13,6 +13,7 @@ #include #include #include +#include #include "adreno.h" #include "adreno_a3xx.h" @@ -124,6 +125,23 @@ int adreno_get_firmware(struct adreno_device *adreno_dev, return ret; } + +int adreno_zap_shader_load(struct adreno_device *adreno_dev, + const char *name) +{ + void *ptr; + + if (!name || adreno_dev->zap_loaded) + return 0; + + ptr = subsystem_get(name); + + if (!IS_ERR(ptr)) + adreno_dev->zap_loaded = true; + + return PTR_ERR_OR_ZERO(ptr); +} + void adreno_reglist_write(struct adreno_device *adreno_dev, const struct adreno_reglist *list, u32 count) { diff --git a/drivers/gpu/msm/adreno.h b/drivers/gpu/msm/adreno.h index c21ce07945d7..c8221e87ed65 100644 --- a/drivers/gpu/msm/adreno.h +++ b/drivers/gpu/msm/adreno.h @@ -1705,4 +1705,15 @@ void adreno_gmu_send_nmi(struct adreno_device *adreno_dev); */ int adreno_get_firmware(struct adreno_device *adreno_dev, const char *fwfile, struct adreno_firmware *firmware); +/** + * adreno_zap_shader_load - Helper function for loading the zap shader + * adreno_dev: A handle to an Adreno GPU device + * name: Name of the zap shader to load + * + * A target indepedent helper function for loading the zap shader. + * + * Return: 0 on success or negative on failure. + */ +int adreno_zap_shader_load(struct adreno_device *adreno_dev, + const char *name); #endif /*__ADRENO_H */ diff --git a/drivers/gpu/msm/adreno_a5xx.c b/drivers/gpu/msm/adreno_a5xx.c index 890480eb1b35..496155ac0e48 100644 --- a/drivers/gpu/msm/adreno_a5xx.c +++ b/drivers/gpu/msm/adreno_a5xx.c @@ -9,7 +9,6 @@ #include #include #include -#include #include "adreno.h" #include "adreno_a5xx.h" @@ -1681,13 +1680,23 @@ static int a5xx_gpmu_init(struct adreno_device *adreno_dev) return 0; } +static int a5xx_zap_shader_resume(struct kgsl_device *device) +{ + int ret = qcom_scm_set_remote_state(0, 13); + + if (ret) + dev_err(device->dev, + "SCM zap resume call failed: %d\n", ret); + + return ret; +} + /* * a5xx_microcode_load() - Load microcode * @adreno_dev: Pointer to adreno device */ static int a5xx_microcode_load(struct adreno_device *adreno_dev) { - void *ptr; struct kgsl_device *device = KGSL_DEVICE(adreno_dev); struct adreno_firmware *pm4_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PM4); struct adreno_firmware *pfp_fw = ADRENO_FW(adreno_dev, ADRENO_FW_PFP); @@ -1713,32 +1722,11 @@ static int a5xx_microcode_load(struct adreno_device *adreno_dev) if (!device->mmu.secured) return 0; - /* - * Resume call to write the zap shader base address into the - * appropriate register, - * skip if retention is supported for the CPZ register - */ if (adreno_dev->zap_loaded && !(ADRENO_FEATURE(adreno_dev, - ADRENO_CPZ_RETENTION))) { - int ret = qcom_scm_set_remote_state(0, 13); + ADRENO_CPZ_RETENTION))) + return a5xx_zap_shader_resume(device); - if (ret) - dev_err(KGSL_DEVICE(adreno_dev)->dev, - "Unable to resume the zap shader: %d\n", ret); - return ret; - } - - /* Load the zap shader firmware through PIL if its available */ - if (a5xx_core->zap_name && !adreno_dev->zap_loaded) { - ptr = subsystem_get(a5xx_core->zap_name); - - /* Return error if the zap shader cannot be loaded */ - if (IS_ERR_OR_NULL(ptr)) - return (ptr == NULL) ? -ENODEV : PTR_ERR(ptr); - adreno_dev->zap_loaded = 1; - } - - return 0; + return adreno_zap_shader_load(adreno_dev, a5xx_core->zap_name); } static int _me_init_ucode_workarounds(struct adreno_device *adreno_dev) diff --git a/drivers/gpu/msm/adreno_a6xx.c b/drivers/gpu/msm/adreno_a6xx.c index 7fd3aba67596..6103707e1197 100644 --- a/drivers/gpu/msm/adreno_a6xx.c +++ b/drivers/gpu/msm/adreno_a6xx.c @@ -3,11 +3,10 @@ * Copyright (c) 2017-2019, The Linux Foundation. All rights reserved. */ +#include #include #include #include -#include -#include #include "adreno.h" #include "adreno_a6xx.h" @@ -567,8 +566,6 @@ static int a6xx_microcode_load(struct adreno_device *adreno_dev) struct adreno_firmware *fw = ADRENO_FW(adreno_dev, ADRENO_FW_SQE); const struct adreno_a6xx_core *a6xx_core = to_a6xx_core(adreno_dev); uint64_t gpuaddr; - void *zap; - int ret = 0; gpuaddr = fw->memdesc->gpuaddr; kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_LO, @@ -576,19 +573,7 @@ static int a6xx_microcode_load(struct adreno_device *adreno_dev) kgsl_regwrite(device, A6XX_CP_SQE_INSTR_BASE_HI, upper_32_bits(gpuaddr)); - /* Load the zap shader firmware through PIL if its available */ - if (a6xx_core->zap_name && !adreno_dev->zap_loaded) { - zap = subsystem_get(a6xx_core->zap_name); - - /* Return error if the zap shader cannot be loaded */ - if (IS_ERR_OR_NULL(zap)) { - ret = (zap == NULL) ? -ENODEV : PTR_ERR(zap); - zap = NULL; - } else - adreno_dev->zap_loaded = 1; - } - - return ret; + return adreno_zap_shader_load(adreno_dev, a6xx_core->zap_name); }