drm/msm/gpu: Code reorganization ahead of a6xx
Subsystems (4)
v2 cover drm/msm/gpu: Code reorganization ahead of a6xx
In anticipation of forthcoming a6xx support here is a handful of changes to reorganize the generic code a bit to make it easier to plug in the new target. Also included are a few minor bug fixes for issues that popped up in the midst of the new code development.
Resending because I messed up a email address and used my personal email by accident on another change.
[v2 - fix messed up emails ]
Jordan Crouse (5):
drm/msm/adreno: Make microcode loading target specific drm/msm/adreno: Use generic function to load firwmare to a buffer object drm/msm/gpu: Set number of clocks to 0 if the list allocation fails drm/msm: Pass the correct aperture end to drm_mm_init drm/msm/adreno: Rename gpmufw to powerfw
drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 83 ++++++++++++++++++++---------- drivers/gpu/drm/msm/adreno/a3xx_gpu.h | 2 + drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 69 ++++++++++++++++++------- drivers/gpu/drm/msm/adreno/a4xx_gpu.h | 2 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 26 ++-------- drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 43 ++++++++-------- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 7 ++- drivers/gpu/drm/msm/msm_gem_vma.c | 4 +- drivers/gpu/drm/msm/msm_gpu.c | 4 +- 11 files changed, 146 insertions(+), 98 deletions(-)
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 1/5 drm/msm/adreno: Make microcode loading target specific
Move microcode loading to be target specific. While this results in a bit more code duplication (especially between A3XX/A4XX) this gives us more flexibility for newer targets that don't need to keep an extra copy of the firmware data around in memory.
--- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 83 ++++++++++++++++++++++----------- drivers/gpu/drm/msm/adreno/a3xx_gpu.h | 2 + drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 69 ++++++++++++++++++++------- drivers/gpu/drm/msm/adreno/a4xx_gpu.h | 2 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 24 +++++++--- drivers/gpu/drm/msm/adreno/adreno_gpu.c | 30 ------------ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 3 -- 7 files changed, 127 insertions(+), 86 deletions(-)
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +55 -28
@@ -69,11 +69,58 @@ static bool a3xx_me_init(struct msm_gpu *gpu)return a3xx_idle (gpu); } -static int a3xx_hw_init (struct msm_gpu *gpu) +static int a3xx_ucode_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a3xx_gpu *a3xx_gpu =to_a3xx_gpu (adreno_gpu); +const struct firmware *fw;uint32_t *ptr, len; +int i; + +if (!a3xx_gpu->pm4) { + fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->pm4fw); +if (IS_ERR (fw)) +return PTR_ERR (fw); + + a3xx_gpu->pm4 = fw; + } + +if (!a3xx_gpu->pfp) { + fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->pfpfw); +if (IS_ERR (fw)) +return PTR_ERR (fw); + + a3xx_gpu->pfp = fw; + } + +/* Load PM4: */ + ptr = (uint32_t *)(a3xx_gpu->pm4->data); + len = a3xx_gpu->pm4->size /4 ; +DBG ("loading PM4 ucode version: %x" , ptr[1 ]); + +gpu_write (gpu,REG_AXXX_CP_DEBUG , +AXXX_CP_DEBUG_DYNAMIC_CLK_DISABLE | +AXXX_CP_DEBUG_MIU_128BIT_WRITE_ENABLE ); +gpu_write (gpu,REG_AXXX_CP_ME_RAM_WADDR ,0 ); +for (i =1 ; i < len; i++) +gpu_write (gpu,REG_AXXX_CP_ME_RAM_DATA , ptr[i]); + +/* Load PFP: */ + ptr = (uint32_t *)(a3xx_gpu->pfp->data); + len = a3xx_gpu->pfp->size /4 ; +DBG ("loading PFP ucode version: %x" , ptr[5 ]); + +gpu_write (gpu,REG_A3XX_CP_PFP_UCODE_ADDR ,0 ); +for (i =1 ; i < len; i++) +gpu_write (gpu,REG_A3XX_CP_PFP_UCODE_DATA , ptr[i]); + +return 0 ; +} + +static int a3xx_hw_init (struct msm_gpu *gpu) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a3xx_gpu *a3xx_gpu =to_a3xx_gpu (adreno_gpu);int i, ret;DBG ("%s" , gpu->name);
@@ -225,6 +272,10 @@ static int a3xx_hw_init(struct msm_gpu *gpu)if (ret)return ret; + ret =a3xx_ucode_init (gpu); +if (ret) +return ret; +/* setup access protection: */ gpu_write (gpu,REG_A3XX_CP_PROTECT_CTRL ,0x00000007 );
@@ -249,33 +300,6 @@ static int a3xx_hw_init(struct msm_gpu *gpu)/* VBIF registers */ gpu_write (gpu,REG_A3XX_CP_PROTECT (12 ),0x6b00c000 ); -/* NOTE: PM4/micro-engine firmware registers look to be the same -* for a2xx and a3xx.. we could possibly push that part down to -* adreno_gpu base class. Or push both PM4 and PFP but -* parameterize the pfp ucode addr/data registers.. -*/ - -/* Load PM4: */ - ptr = (uint32_t *)(adreno_gpu->pm4->data); - len = adreno_gpu->pm4->size /4 ; -DBG ("loading PM4 ucode version: %x" , ptr[1 ]); - -gpu_write (gpu,REG_AXXX_CP_DEBUG , -AXXX_CP_DEBUG_DYNAMIC_CLK_DISABLE | -AXXX_CP_DEBUG_MIU_128BIT_WRITE_ENABLE ); -gpu_write (gpu,REG_AXXX_CP_ME_RAM_WADDR ,0 ); -for (i =1 ; i < len; i++) -gpu_write (gpu,REG_AXXX_CP_ME_RAM_DATA , ptr[i]); - -/* Load PFP: */ - ptr = (uint32_t *)(adreno_gpu->pfp->data); - len = adreno_gpu->pfp->size /4 ; -DBG ("loading PFP ucode version: %x" , ptr[5 ]); - -gpu_write (gpu,REG_A3XX_CP_PFP_UCODE_ADDR ,0 ); -for (i =1 ; i < len; i++) -gpu_write (gpu,REG_A3XX_CP_PFP_UCODE_DATA , ptr[i]); -/* CP ROQ queue sizes (bytes) - RB:16, ST:16, IB1:32, IB2:64 */ if (adreno_is_a305 (adreno_gpu) ||adreno_is_a306 (adreno_gpu) ||adreno_is_a320 (adreno_gpu)) {
@@ -326,6 +350,9 @@ static void a3xx_destroy(struct msm_gpu *gpu)DBG ("%s" , gpu->name); +release_firmware (a3xx_gpu->pm4); +release_firmware (a3xx_gpu->pfp); +adreno_gpu_cleanup (adreno_gpu);#ifdef CONFIG_MSM_OCMEM
drivers/gpu/drm/msm/adreno/a3xx_gpu.h +2 -0
@@ -32,6 +32,8 @@ struct a3xx_gpu {/* if OCMEM is used for GMEM: */ uint32_t ocmem_base;void *ocmem_hdl; + +const struct firmware *pm4, *pfp; };#define to_a3xx_gpu (x) container_of(x, struct a3xx_gpu, base)
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +51 -18
91 lines not on this page · raw message
drivers/gpu/drm/msm/adreno/a4xx_gpu.h +2 -0
@@ -27,6 +27,8 @@ struct a4xx_gpu {/* if OCMEM is used for GMEM: */ uint32_t ocmem_base;void *ocmem_hdl; + +const struct firmware *pm4, *pfp; };#define to_a4xx_gpu (x) container_of(x, struct a4xx_gpu, base)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +17 -7
@@ -434,20 +434,30 @@ static int a5xx_preempt_start(struct msm_gpu *gpu)static struct drm_gem_object *a5xx_ucode_load_bo (struct msm_gpu *gpu, -const struct firmware *fw,u64 *iova) +const char *fwname,u64 *iova) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +const struct firmware *fw;struct drm_gem_object *bo;void *ptr; + fw =adreno_request_fw (adreno_gpu, fwname); +if (IS_ERR (fw)) +return ERR_CAST (fw); + ptr =msm_gem_kernel_new_locked (gpu->dev, fw->size -4 ,MSM_BO_UNCACHED |MSM_BO_GPU_READONLY , gpu->aspace, &bo, iova); -if (IS_ERR (ptr)) -return ERR_CAST (ptr); +if (IS_ERR (ptr)) { + bo =ERR_CAST (ptr); + goto out; + }memcpy (ptr, &fw->data[4 ], fw->size -4 );msm_gem_put_vaddr (bo); +out: +release_firmware (fw);return bo; }
@@ -458,8 +468,8 @@ static int a5xx_ucode_init(struct msm_gpu *gpu)int ret;if (!a5xx_gpu->pm4_bo) { - a5xx_gpu->pm4_bo =a5xx_ucode_load_bo (gpu, adreno_gpu->pm4, - &a5xx_gpu->pm4_iova); + a5xx_gpu->pm4_bo =a5xx_ucode_load_bo (gpu, + adreno_gpu->info->pm4fw, &a5xx_gpu->pm4_iova);if (IS_ERR (a5xx_gpu->pm4_bo)) { ret =PTR_ERR (a5xx_gpu->pm4_bo);
@@ -471,8 +481,8 @@ static int a5xx_ucode_init(struct msm_gpu *gpu) }if (!a5xx_gpu->pfp_bo) { - a5xx_gpu->pfp_bo =a5xx_ucode_load_bo (gpu, adreno_gpu->pfp, - &a5xx_gpu->pfp_iova); + a5xx_gpu->pfp_bo =a5xx_ucode_load_bo (gpu, + adreno_gpu->info->pfpfw, &a5xx_gpu->pfp_iova);if (IS_ERR (a5xx_gpu->pfp_bo)) { ret =PTR_ERR (a5xx_gpu->pfp_bo);
drivers/gpu/drm/msm/adreno/adreno_gpu.c +0 -30
@@ -138,29 +138,6 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)return ERR_PTR (-ENOENT ); } -static int adreno_load_fw (struct adreno_gpu *adreno_gpu) -{ -const struct firmware *fw; - -if (adreno_gpu->pm4) -return 0 ; - - fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->pm4fw); -if (IS_ERR (fw)) -return PTR_ERR (fw); - adreno_gpu->pm4 = fw; - - fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->pfpfw); -if (IS_ERR (fw)) { -release_firmware (adreno_gpu->pm4); - adreno_gpu->pm4 =NULL ; -return PTR_ERR (fw); - } - adreno_gpu->pfp = fw; - -return 0 ; -} -int adreno_hw_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -168,10 +145,6 @@ int adreno_hw_init(struct msm_gpu *gpu)DBG ("%s" , gpu->name); - ret =adreno_load_fw (adreno_gpu); -if (ret) -return ret; -for (i =0 ; i < gpu->nr_rings; i++) {struct msm_ringbuffer *ring = gpu->rb[i];
@@ -569,8 +542,5 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,void adreno_gpu_cleanup (struct adreno_gpu *adreno_gpu) { -release_firmware (adreno_gpu->pm4); -release_firmware (adreno_gpu->pfp); -msm_gpu_cleanup (&adreno_gpu->base); }
drivers/gpu/drm/msm/adreno/adreno_gpu.h +0 -3
@@ -114,9 +114,6 @@ struct adreno_gpu { FW_LOCATION_HELPER, } fwloc; -/* firmware: */ -const struct firmware *pm4, *pfp; -/* * Register offsets are different between some GPUs. * GPU specific offsets will be exported by GPU specific
Signature · 1 line
1.9.1
A message that is not in the archive (sent off-list or not yet received): 1516644647-7507-1-git-send-email-jcrouse-sgV2jX0FEOL9JmXXK+q4OQ@public.gmane.org
PATCH 2/5 drm/msm/adreno: Use generic function to load firwmare to a buffer object
Move a5xx specific code to load firmware into a buffer object to the generic Adreno code. This will come in useful for future targets.
--- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 32 ++------------------------------ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 29 +++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 ++ 3 files changed, 33 insertions(+), 30 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +2 -30
@@ -433,34 +433,6 @@ static int a5xx_preempt_start(struct msm_gpu *gpu) } -static struct drm_gem_object *a5xx_ucode_load_bo (struct msm_gpu *gpu, -const char *fwname,u64 *iova) -{ -struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); -const struct firmware *fw; -struct drm_gem_object *bo; -void *ptr; - - fw =adreno_request_fw (adreno_gpu, fwname); -if (IS_ERR (fw)) -return ERR_CAST (fw); - - ptr =msm_gem_kernel_new_locked (gpu->dev, fw->size -4 , -MSM_BO_UNCACHED |MSM_BO_GPU_READONLY , gpu->aspace, &bo, iova); - -if (IS_ERR (ptr)) { - bo =ERR_CAST (ptr); - goto out; - } - -memcpy (ptr, &fw->data[4 ], fw->size -4 ); - -msm_gem_put_vaddr (bo); -out: -release_firmware (fw); -return bo; -} -static int a5xx_ucode_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -468,7 +440,7 @@ static int a5xx_ucode_init(struct msm_gpu *gpu)int ret;if (!a5xx_gpu->pm4_bo) { - a5xx_gpu->pm4_bo =a5xx_ucode_load_bo (gpu, + a5xx_gpu->pm4_bo =adreno_request_fw_bo (gpu, adreno_gpu->info->pm4fw, &a5xx_gpu->pm4_iova);if (IS_ERR (a5xx_gpu->pm4_bo)) {
@@ -481,7 +453,7 @@ static int a5xx_ucode_init(struct msm_gpu *gpu) }if (!a5xx_gpu->pfp_bo) { - a5xx_gpu->pfp_bo =a5xx_ucode_load_bo (gpu, + a5xx_gpu->pfp_bo =adreno_request_fw_bo (gpu, adreno_gpu->info->pfpfw, &a5xx_gpu->pfp_iova);if (IS_ERR (a5xx_gpu->pfp_bo)) {
drivers/gpu/drm/msm/adreno/adreno_gpu.c +29 -0
@@ -138,6 +138,35 @@ int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value)return ERR_PTR (-ENOENT ); } +struct drm_gem_object *adreno_request_fw_bo (struct msm_gpu *gpu, +const char *fwname,u64 *iova) +{ +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +const struct firmware *fw; +struct drm_gem_object *bo; +void *ptr; + + fw =adreno_request_fw (adreno_gpu, fwname); +if (IS_ERR (fw)) +return ERR_CAST (fw); + + ptr =msm_gem_kernel_new_locked (gpu->dev, fw->size -4 , +MSM_BO_UNCACHED |MSM_BO_GPU_READONLY , gpu->aspace, &bo, iova); + +if (IS_ERR (ptr)) { + bo =ERR_CAST (ptr); + goto out; + } + +memcpy (ptr, &fw->data[4 ], fw->size -4 ); + +msm_gem_put_vaddr (bo); +out: +release_firmware (fw); +return bo; +} + +int adreno_hw_init (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
drivers/gpu/drm/msm/adreno/adreno_gpu.h +2 -0
@@ -197,6 +197,8 @@ static inline int adreno_is_a530(struct adreno_gpu *gpu)int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value);const struct firmware *adreno_request_fw (struct adreno_gpu *adreno_gpu,const char *fwname); +struct drm_gem_object *adreno_request_fw_bo (struct msm_gpu *gpu, +const char *fwname,u64 *iova);int adreno_hw_init (struct msm_gpu *gpu);void adreno_recover (struct msm_gpu *gpu); void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit,
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 4/5 drm/msm: Pass the correct aperture end to drm_mm_init
In reply to a message not in the archivedrm_mm_init() takes the start and length of the intended virtual memory address region but the msm code is passing the end of the region instead. That would work out if the region started at 0 but it doesn't so the top of the region sneaks above the 32 bit boundary which won't work because the driver doesn't support 64 bit addresses for the GPU yet.
--- drivers/gpu/drm/msm/msm_gem_vma.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gem_vma.c +3 -1
@@ -96,6 +96,8 @@ struct msm_gem_address_space * const char *name) {struct msm_gem_address_space *aspace; +u64 size = domain->geometry.aperture_end - + domain->geometry.aperture_start; aspace =kzalloc (sizeof (*aspace),GFP_KERNEL );if (!aspace)
@@ -106,7 +108,7 @@ struct msm_gem_address_space * aspace->mmu =msm_iommu_new (dev, domain);drm_mm_init (&aspace->mm, (domain->geometry.aperture_start >>PAGE_SHIFT ), - (domain->geometry.aperture_end >>PAGE_SHIFT ) -1 ); + size >>PAGE_SHIFT );kref_init (&aspace->kref);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH 5/5 drm/msm/adreno: Rename gpmufw to powerfw
In reply to a message not in the archiveThe power management device on the a5xx cores is known as the GPMU (Graphics Power Management Unit). On a6xx cores the device was expanded and renamed as the GMU (Graphics Management Unit). Rename the 'gpmufw' name struct adreno_info as 'powerfw' to avoid confusion.
--- drivers/gpu/drm/msm/adreno/a5xx_power.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_device.c | 2 +- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-)
drivers/gpu/drm/msm/adreno/a5xx_power.c +1 -1
@@ -270,7 +270,7 @@ void a5xx_gpmu_ucode_init(struct msm_gpu *gpu)return ;/* Get the firmware */ - fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->gpmufw); + fw =adreno_request_fw (adreno_gpu, adreno_gpu->info->powerfw);if (IS_ERR (fw)) {DRM_ERROR ("%s: Could not get GPMU firmware. GPMU will not be active\n" , gpu->name);
drivers/gpu/drm/msm/adreno/adreno_device.c +1 -1
@@ -84,7 +84,7 @@ .quirks = ADRENO_QUIRK_TWO_PASS_USE_WFI | ADRENO_QUIRK_FAULT_DETECT_MASK, .init = a5xx_gpu_init, - .gpmufw = "a530v3_gpmu.fw2", + .powerfw = "a530v3_gpmu.fw2", .zapfw = "a530_zap.mdt", }, };
drivers/gpu/drm/msm/adreno/adreno_gpu.h +1 -1
@@ -73,7 +73,7 @@ struct adreno_info {uint32_t revn;const char *name;const char *pm4fw, *pfpfw; -const char *gpmufw; +const char *powerfw;uint32_t gmem;enum adreno_quirks quirks;struct msm_gpu *(*init)(struct drm_device *dev);
Signature · 6 lines
1.9.1 _______________________________________________ Freedreno mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/freedreno
PATCH v2 3/5 drm/msm/gpu: Set number of clocks to 0 if the list allocation fails
In reply to Jordan CrouseIf we fail to allocate gpu->grp_clks reset the number of available clocks to zero to avoid referencing the missing array later.
--- drivers/gpu/drm/msm/msm_gpu.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/gpu/drm/msm/msm_gpu.c +3 -1
@@ -682,8 +682,10 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) gpu->grp_clks =devm_kcalloc (dev,sizeof (struct clk *), gpu->nr_clocks,GFP_KERNEL ); -if (!gpu->grp_clks) +if (!gpu->grp_clks) { + gpu->nr_clocks =0 ;return -ENOMEM ; + }of_property_for_each_string (dev->of_node,"clock-names" , prop, name) { gpu->grp_clks[i] =get_clock (dev, name);
Signature · 6 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel