diff options
author | Jordan Crouse <jcrouse@codeaurora.org> | 2018-02-01 14:15:17 -0500 |
---|---|---|
committer | Rob Clark <robdclark@gmail.com> | 2018-02-20 10:41:22 -0500 |
commit | 9de43e79c10149d29c77ff2c3dae048d1db9cbce (patch) | |
tree | aafed18c986056303ed99ac4f12de6fddf186808 /drivers | |
parent | c5e3548c295ace44c2ec8c3af1c10e82bc47f9b3 (diff) |
drm/msm/adreno: Use generic function to load firmware 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.
Signed-off-by: Jordan Crouse <jcrouse@codeaurora.org>
Signed-off-by: Rob Clark <robdclark@gmail.com>
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 23 | ||||
-rw-r--r-- | drivers/gpu/drm/msm/adreno/adreno_gpu.c | 19 | ||||
-rw-r--r-- | drivers/gpu/drm/msm/adreno/adreno_gpu.h | 2 |
3 files changed, 23 insertions, 21 deletions
diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c index 517e19c3f9ed..a4f68affc13b 100644 --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c | |||
@@ -497,25 +497,6 @@ static int a5xx_preempt_start(struct msm_gpu *gpu) | |||
497 | return a5xx_idle(gpu, ring) ? 0 : -EINVAL; | 497 | return a5xx_idle(gpu, ring) ? 0 : -EINVAL; |
498 | } | 498 | } |
499 | 499 | ||
500 | |||
501 | static struct drm_gem_object *a5xx_ucode_load_bo(struct msm_gpu *gpu, | ||
502 | const struct firmware *fw, u64 *iova) | ||
503 | { | ||
504 | struct drm_gem_object *bo; | ||
505 | void *ptr; | ||
506 | |||
507 | ptr = msm_gem_kernel_new_locked(gpu->dev, fw->size - 4, | ||
508 | MSM_BO_UNCACHED | MSM_BO_GPU_READONLY, gpu->aspace, &bo, iova); | ||
509 | |||
510 | if (IS_ERR(ptr)) | ||
511 | return ERR_CAST(ptr); | ||
512 | |||
513 | memcpy(ptr, &fw->data[4], fw->size - 4); | ||
514 | |||
515 | msm_gem_put_vaddr(bo); | ||
516 | return bo; | ||
517 | } | ||
518 | |||
519 | static int a5xx_ucode_init(struct msm_gpu *gpu) | 500 | static int a5xx_ucode_init(struct msm_gpu *gpu) |
520 | { | 501 | { |
521 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); | 502 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); |
@@ -523,7 +504,7 @@ static int a5xx_ucode_init(struct msm_gpu *gpu) | |||
523 | int ret; | 504 | int ret; |
524 | 505 | ||
525 | if (!a5xx_gpu->pm4_bo) { | 506 | if (!a5xx_gpu->pm4_bo) { |
526 | a5xx_gpu->pm4_bo = a5xx_ucode_load_bo(gpu, | 507 | a5xx_gpu->pm4_bo = adreno_fw_create_bo(gpu, |
527 | adreno_gpu->fw[ADRENO_FW_PM4], &a5xx_gpu->pm4_iova); | 508 | adreno_gpu->fw[ADRENO_FW_PM4], &a5xx_gpu->pm4_iova); |
528 | 509 | ||
529 | if (IS_ERR(a5xx_gpu->pm4_bo)) { | 510 | if (IS_ERR(a5xx_gpu->pm4_bo)) { |
@@ -536,7 +517,7 @@ static int a5xx_ucode_init(struct msm_gpu *gpu) | |||
536 | } | 517 | } |
537 | 518 | ||
538 | if (!a5xx_gpu->pfp_bo) { | 519 | if (!a5xx_gpu->pfp_bo) { |
539 | a5xx_gpu->pfp_bo = a5xx_ucode_load_bo(gpu, | 520 | a5xx_gpu->pfp_bo = adreno_fw_create_bo(gpu, |
540 | adreno_gpu->fw[ADRENO_FW_PFP], &a5xx_gpu->pfp_iova); | 521 | adreno_gpu->fw[ADRENO_FW_PFP], &a5xx_gpu->pfp_iova); |
541 | 522 | ||
542 | if (IS_ERR(a5xx_gpu->pfp_bo)) { | 523 | if (IS_ERR(a5xx_gpu->pfp_bo)) { |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c index 4a8ee5ec571e..87133c6c6f91 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c | |||
@@ -162,6 +162,25 @@ static int adreno_load_fw(struct adreno_gpu *adreno_gpu) | |||
162 | return 0; | 162 | return 0; |
163 | } | 163 | } |
164 | 164 | ||
165 | struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu, | ||
166 | const struct firmware *fw, u64 *iova) | ||
167 | { | ||
168 | struct drm_gem_object *bo; | ||
169 | void *ptr; | ||
170 | |||
171 | ptr = msm_gem_kernel_new_locked(gpu->dev, fw->size - 4, | ||
172 | MSM_BO_UNCACHED | MSM_BO_GPU_READONLY, gpu->aspace, &bo, iova); | ||
173 | |||
174 | if (IS_ERR(ptr)) | ||
175 | return ERR_CAST(ptr); | ||
176 | |||
177 | memcpy(ptr, &fw->data[4], fw->size - 4); | ||
178 | |||
179 | msm_gem_put_vaddr(bo); | ||
180 | |||
181 | return bo; | ||
182 | } | ||
183 | |||
165 | int adreno_hw_init(struct msm_gpu *gpu) | 184 | int adreno_hw_init(struct msm_gpu *gpu) |
166 | { | 185 | { |
167 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); | 186 | struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu); |
diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h index 499092af81a2..d6b0e7b813f4 100644 --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h | |||
@@ -206,6 +206,8 @@ static inline int adreno_is_a530(struct adreno_gpu *gpu) | |||
206 | int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value); | 206 | int adreno_get_param(struct msm_gpu *gpu, uint32_t param, uint64_t *value); |
207 | const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu, | 207 | const struct firmware *adreno_request_fw(struct adreno_gpu *adreno_gpu, |
208 | const char *fwname); | 208 | const char *fwname); |
209 | struct drm_gem_object *adreno_fw_create_bo(struct msm_gpu *gpu, | ||
210 | const struct firmware *fw, u64 *iova); | ||
209 | int adreno_hw_init(struct msm_gpu *gpu); | 211 | int adreno_hw_init(struct msm_gpu *gpu); |
210 | void adreno_recover(struct msm_gpu *gpu); | 212 | void adreno_recover(struct msm_gpu *gpu); |
211 | void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, | 213 | void adreno_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, |