Skip to content

Commit 822ff99

Browse files
committed
drm/msm: remove duplicated code from a6xx_create_address_space
The function a6xx_create_address_space() is mostly a copy of adreno_iommu_create_address_space() with added quirk setting. Rework these two functions to be a thin wrappers around a common helper. Signed-off-by: Dmitry Baryshkov <[email protected]> Reviewed-by: Rob Clark <[email protected]> Patchwork: https://patchwork.freedesktop.org/patch/509614/ Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Dmitry Baryshkov <[email protected]>
1 parent 3236130 commit 822ff99

File tree

6 files changed

+20
-33
lines changed

6 files changed

+20
-33
lines changed

drivers/gpu/drm/msm/adreno/a3xx_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@ static const struct adreno_gpu_funcs funcs = {
500500
#endif
501501
.gpu_state_get = a3xx_gpu_state_get,
502502
.gpu_state_put = adreno_gpu_state_put,
503-
.create_address_space = adreno_iommu_create_address_space,
503+
.create_address_space = adreno_create_address_space,
504504
.get_rptr = a3xx_get_rptr,
505505
},
506506
};

drivers/gpu/drm/msm/adreno/a4xx_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -635,7 +635,7 @@ static const struct adreno_gpu_funcs funcs = {
635635
#endif
636636
.gpu_state_get = a4xx_gpu_state_get,
637637
.gpu_state_put = adreno_gpu_state_put,
638-
.create_address_space = adreno_iommu_create_address_space,
638+
.create_address_space = adreno_create_address_space,
639639
.get_rptr = a4xx_get_rptr,
640640
},
641641
.get_timestamp = a4xx_get_timestamp,

drivers/gpu/drm/msm/adreno/a5xx_gpu.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1705,7 +1705,7 @@ static const struct adreno_gpu_funcs funcs = {
17051705
.gpu_busy = a5xx_gpu_busy,
17061706
.gpu_state_get = a5xx_gpu_state_get,
17071707
.gpu_state_put = a5xx_gpu_state_put,
1708-
.create_address_space = adreno_iommu_create_address_space,
1708+
.create_address_space = adreno_create_address_space,
17091709
.get_rptr = a5xx_get_rptr,
17101710
},
17111711
.get_timestamp = a5xx_get_timestamp,

drivers/gpu/drm/msm/adreno/a6xx_gpu.c

Lines changed: 1 addition & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1786,10 +1786,6 @@ a6xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev)
17861786
{
17871787
struct adreno_gpu *adreno_gpu = to_adreno_gpu(gpu);
17881788
struct a6xx_gpu *a6xx_gpu = to_a6xx_gpu(adreno_gpu);
1789-
struct iommu_domain_geometry *geometry;
1790-
struct msm_mmu *mmu;
1791-
struct msm_gem_address_space *aspace;
1792-
u64 start, size;
17931789
unsigned long quirks = 0;
17941790

17951791
/*
@@ -1799,29 +1795,7 @@ a6xx_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev)
17991795
if (!IS_ERR_OR_NULL(a6xx_gpu->htw_llc_slice))
18001796
quirks |= IO_PGTABLE_QUIRK_ARM_OUTER_WBWA;
18011797

1802-
mmu = msm_iommu_new(&pdev->dev, quirks);
1803-
if (IS_ERR_OR_NULL(mmu))
1804-
return ERR_CAST(mmu);
1805-
1806-
geometry = msm_iommu_get_geometry(mmu);
1807-
if (IS_ERR(geometry))
1808-
return ERR_CAST(geometry);
1809-
1810-
/*
1811-
* Use the aperture start or SZ_16M, whichever is greater. This will
1812-
* ensure that we align with the allocated pagetable range while still
1813-
* allowing room in the lower 32 bits for GMEM and whatnot
1814-
*/
1815-
start = max_t(u64, SZ_16M, geometry->aperture_start);
1816-
size = geometry->aperture_end - start + 1;
1817-
1818-
aspace = msm_gem_address_space_create(mmu, "gpu",
1819-
start & GENMASK_ULL(48, 0), size);
1820-
1821-
if (IS_ERR(aspace) && !IS_ERR(mmu))
1822-
mmu->funcs->destroy(mmu);
1823-
1824-
return aspace;
1798+
return adreno_iommu_create_address_space(gpu, pdev, quirks);
18251799
}
18261800

18271801
static struct msm_gem_address_space *

drivers/gpu/drm/msm/adreno/adreno_gpu.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -191,16 +191,24 @@ int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid)
191191
return zap_shader_load_mdt(gpu, adreno_gpu->info->zapfw, pasid);
192192
}
193193

194+
struct msm_gem_address_space *
195+
adreno_create_address_space(struct msm_gpu *gpu,
196+
struct platform_device *pdev)
197+
{
198+
return adreno_iommu_create_address_space(gpu, pdev, 0);
199+
}
200+
194201
struct msm_gem_address_space *
195202
adreno_iommu_create_address_space(struct msm_gpu *gpu,
196-
struct platform_device *pdev)
203+
struct platform_device *pdev,
204+
unsigned long quirks)
197205
{
198206
struct iommu_domain_geometry *geometry;
199207
struct msm_mmu *mmu;
200208
struct msm_gem_address_space *aspace;
201209
u64 start, size;
202210

203-
mmu = msm_iommu_new(&pdev->dev, 0);
211+
mmu = msm_iommu_new(&pdev->dev, quirks);
204212
if (IS_ERR_OR_NULL(mmu))
205213
return ERR_CAST(mmu);
206214

drivers/gpu/drm/msm/adreno/adreno_gpu.h

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -335,8 +335,13 @@ void adreno_show_object(struct drm_printer *p, void **ptr, int len,
335335
* attached targets
336336
*/
337337
struct msm_gem_address_space *
338+
adreno_create_address_space(struct msm_gpu *gpu,
339+
struct platform_device *pdev);
340+
341+
struct msm_gem_address_space *
338342
adreno_iommu_create_address_space(struct msm_gpu *gpu,
339-
struct platform_device *pdev);
343+
struct platform_device *pdev,
344+
unsigned long quirks);
340345

341346
int adreno_read_speedbin(struct device *dev, u32 *speedbin);
342347

0 commit comments

Comments
 (0)