drm/msm/a6xx: System Cache Support
Subsystems (5)
v2 cover drm/msm/a6xx: System Cache Support
Some hardware variants contain a system level cache or the last level cache(llc). This cache is typically a large block which is shared by multiple clients on the SOC. GPU uses the system cache to cache both the GPU data buffers(like textures) as well the SMMU pagetables. This helps with improved render performance as well as lower power consumption by reducing the bus traffic to the system memory.
The system cache architecture allows the cache to be split into slices which then be used by multiple SOC clients. This patch series is an effort to enable and use two of those slices perallocated for the GPU, one for the GPU data buffers and another for the GPU SMMU hardware pagetables.
v2: Code reviews and rebased code on top of Jordan's split pagetables series
To enable the system cache driver, add [1] to your stack if not already present. Please review.
[1] https://lore.kernel.org/patchwork/patch/1165298/
Jordan Crouse (3):
iommu/arm-smmu: Pass io_pgtable_cfg to impl specific init_context drm/msm: Attach the IOMMU device during initialization drm/msm: Refactor address space initialization
Sharat Masetty (3):
drm: msm: a6xx: Properly free up the iommu objects drm/msm: rearrange the gpu_rmw() function drm/msm/a6xx: Add support for using system cache(LLC)
Vivek Gautam (1):
iommu/arm-smmu: Add domain attribute for QCOM system cache
drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 16 ++++ drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 124 +++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 3 + drivers/gpu/drm/msm/adreno/adreno_gpu.c | 23 ++++-- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 8 ++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 19 ++--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 19 ++--- drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c | 4 - drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 19 +++-- drivers/gpu/drm/msm/msm_drv.c | 8 ++ drivers/gpu/drm/msm/msm_drv.h | 9 +-- drivers/gpu/drm/msm/msm_gem_vma.c | 37 ++------- drivers/gpu/drm/msm/msm_gpu.c | 49 +----------- drivers/gpu/drm/msm/msm_gpu.h | 9 +-- drivers/gpu/drm/msm/msm_gpummu.c | 7 -- drivers/gpu/drm/msm/msm_iommu.c | 22 +++--- drivers/gpu/drm/msm/msm_mmu.h | 5 +- drivers/iommu/arm-smmu-impl.c | 3 +- drivers/iommu/arm-smmu-qcom.c | 10 +++ drivers/iommu/arm-smmu.c | 25 +++++-- drivers/iommu/arm-smmu.h | 4 +- include/linux/iommu.h | 1 + 25 files changed, 269 insertions(+), 158 deletions(-)
--
1.9.1
PATCH v2 1/7 iommu/arm-smmu: Pass io_pgtable_cfg to impl specific init_context
From: Jordan Crouse <[email protected]>
Pass the propposed io_pgtable_cfg to the implementation specific init_context() function to give the implementation an opportunity to to modify it before it gets passed to io-pgtable.
--- drivers/iommu/arm-smmu-impl.c | 3 ++- drivers/iommu/arm-smmu.c | 11 ++++++----- drivers/iommu/arm-smmu.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-)
drivers/iommu/arm-smmu-impl.c +2 -1
@@ -68,7 +68,8 @@ static int cavium_cfg_probe(struct arm_smmu_device *smmu)return 0 ; } -static int cavium_init_context (struct arm_smmu_domain *smmu_domain) +static int cavium_init_context (struct arm_smmu_domain *smmu_domain, +struct io_pgtable_cfg *pgtbl_cfg) {struct cavium_smmu *cs =container_of (smmu_domain->smmu, struct cavium_smmu, smmu);
drivers/iommu/arm-smmu.c +6 -5
@@ -758,11 +758,6 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, cfg->asid = cfg->cbndx; smmu_domain->smmu = smmu; -if (smmu->impl && smmu->impl->init_context) { - ret = smmu->impl->init_context (smmu_domain); -if (ret) - goto out_unlock; - } smmu_domain->pgtbl_cfg = (struct io_pgtable_cfg ) { .pgsize_bitmap = smmu->pgsize_bitmap,
@@ -773,6 +768,12 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, .iommu_dev = smmu->dev, }; +if (smmu->impl && smmu->impl->init_context) { + ret = smmu->impl->init_context (smmu_domain, &smmu_domain->pgtbl_cfg); +if (ret) + goto out_unlock; + } +if (smmu_domain->non_strict) smmu_domain->pgtbl_cfg.quirks |=IO_PGTABLE_QUIRK_NON_STRICT ;
drivers/iommu/arm-smmu.h +2 -1
@@ -335,7 +335,8 @@ struct arm_smmu_impl { u64 val);int (*cfg_probe)(struct arm_smmu_device *smmu);int (*reset)(struct arm_smmu_device *smmu); -int (*init_context)(struct arm_smmu_domain *smmu_domain); +int (*init_context)(struct arm_smmu_domain *smmu_domain, +struct io_pgtable_cfg *pgtbl_cfg); };static inline void __iomem *arm_smmu_page (struct arm_smmu_device *smmu,int n)
--
1.9.1
Re: [PATCH v2 1/7] iommu/arm-smmu: Pass io_pgtable_cfg to impl specific init_context
Hi,
Quoted 45 lines · Sharat Masetty
From: Jordan Crouse <[email protected]>
Pass the propposed
io_pgtable_cfgto the implementation specificinit_context()function to give the implementation an opportunity to to modify it before it gets passed to io-pgtable.Signed-off-by Jordan Crouse <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-impl.c | 3 ++- drivers/iommu/arm-smmu.c | 11 ++++++----- drivers/iommu/arm-smmu.h | 3 ++- 3 files changed, 10 insertions(+), 7 deletions(-)drivers/iommu/arm-smmu-impl.c +2
-1@@ -68,7 +68,8 @@ static int cavium_cfg_probe(struct arm_smmu_device *smmu)return 0 ; } -static int cavium_init_context (struct arm_smmu_domain *smmu_domain) +static int cavium_init_context (struct arm_smmu_domain *smmu_domain, +struct io_pgtable_cfg *pgtbl_cfg) {struct cavium_smmu *cs =container_of (smmu_domain->smmu, struct cavium_smmu, smmu);drivers/iommu/arm-smmu.c +0
-5@@ -758,11 +758,6 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, cfg->asid = cfg->cbndx; smmu_domain->smmu = smmu; -if (smmu->impl && smmu->impl->init_context) { - ret = smmu->impl->init_context (smmu_domain); -if (ret) - goto out_unlock; - } smmu_domain->pgtbl_cfg = (struct io_pgtable_cfg ) { .pgsize_bitmap = smmu->pgsize_bitmap,
drivers/iommu/arm-smmu.c static int arm_smmu_init_domain_context(struct iommu_domain *domain, · line 772
Quoted 5 lines
drivers/iommu/arm-smmu.c +2
-0@@ -773,6 +768,12 @@ static int arm_smmu_init_domain_context(struct iommu_domain *domain, .iommu_dev = smmu->dev, }; +if (smmu->impl && smmu->impl->init_context) { + ret = smmu->impl->init_context (smmu_domain, &smmu_domain->pgtbl_cfg);
Which patch adds 'pgtbl_cfg' to struct arm_smmu_domain? The field does not exist in iommu/next.
PATCH v2 2/7 iommu/arm-smmu: Add domain attribute for QCOM system cache
In reply to Sharat MasettyFrom: Vivek Gautam <[email protected]>
Add iommu domain attribute for using system cache aka last level cache on QCOM SoCs by client drivers like GPU to set right attributes for caching the hardware pagetables into the system cache.
--- drivers/iommu/arm-smmu-qcom.c | 10 ++++++++++ drivers/iommu/arm-smmu.c | 14 ++++++++++++++ drivers/iommu/arm-smmu.h | 1 + include/linux/iommu.h | 1 + 4 files changed, 26 insertions(+)
drivers/iommu/arm-smmu-qcom.c +10 -0
@@ -30,7 +30,17 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu)return ret; } +static int qcom_smmu_init_context (struct arm_smmu_domain *smmu_domain, +struct io_pgtable_cfg *pgtbl_cfg) +{ +if (smmu_domain->sys_cache) + pgtbl_cfg->coherent_walk = false; + +return 0 ; +} +static const struct arm_smmu_impl qcom_smmu_impl = { + .init_context = qcom_smmu_init_context, .reset = qcom_sdm845_smmu500_reset, };
drivers/iommu/arm-smmu.c +14 -0
@@ -1466,6 +1466,9 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain,case DOMAIN_ATTR_NESTING : *(int *)data = (smmu_domain->stage ==ARM_SMMU_DOMAIN_NESTED );return 0 ; +case DOMAIN_ATTR_QCOM_SYS_CACHE : + *((int *)data) = smmu_domain->sys_cache; +return 0 ;default :return -ENODEV ; }
@@ -1506,6 +1509,17 @@ static int arm_smmu_domain_set_attr(struct iommu_domain *domain,else smmu_domain->stage =ARM_SMMU_DOMAIN_S1 ;break ; +case DOMAIN_ATTR_QCOM_SYS_CACHE : +if (smmu_domain->smmu) { + ret = -EPERM ; + goto out_unlock; + } + +if (*((int *)data)) + smmu_domain->sys_cache = true; +else + smmu_domain->sys_cache = false; +break ;default : ret = -ENODEV ; }
drivers/iommu/arm-smmu.h +1 -0
@@ -322,6 +322,7 @@ struct arm_smmu_domain {struct mutex init_mutex;/* Protects smmu pointer */ spinlock_t cb_lock;/* Serialises ATS1* ops and TLB syncs */ struct iommu_domain domain; +bool sys_cache; };
include/linux/iommu.h +1 -0
@@ -127,6 +127,7 @@ enum iommu_attr {DOMAIN_ATTR_FSL_PAMUV1 ,DOMAIN_ATTR_NESTING ,/* two stages of translation */ DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE , +DOMAIN_ATTR_QCOM_SYS_CACHE , DOMAIN_ATTR_MAX, };
Signature · 5 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [Freedreno] [PATCH v2 2/7] iommu/arm-smmu: Add domain attribute for QCOM system cache
Quoted 22 lines · Sharat Masetty
From: Vivek Gautam <[email protected]>
Add iommu domain attribute for using system cache aka last level cache on QCOM SoCs by client drivers like GPU to set right attributes for caching the hardware pagetables into the system cache.
Signed-off-by Vivek Gautam <[email protected]>Co-developed-by Sai Prakash Ranjan <[email protected]>Signed-off-by Sai Prakash Ranjan <[email protected]>--- drivers/iommu/arm-smmu-qcom.c | 10 ++++++++++ drivers/iommu/arm-smmu.c | 14 ++++++++++++++ drivers/iommu/arm-smmu.h | 1 + include/linux/iommu.h | 1 + 4 files changed, 26 insertions(+)drivers/iommu/arm-smmu-qcom.c +0
-0
drivers/iommu/arm-smmu-qcom.c static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu) · line 37
Quoted 8 lines
drivers/iommu/arm-smmu-qcom.c +5
-0@@ -30,7 +30,17 @@ static int qcom_sdm845_smmu500_reset(struct arm_smmu_device *smmu)return ret; } +static int qcom_smmu_init_context (struct arm_smmu_domain *smmu_domain, +struct io_pgtable_cfg *pgtbl_cfg) +{ +if (smmu_domain->sys_cache) + pgtbl_cfg->coherent_walk = false;
just curious, does coherent walk not work with sys-cache, or is it just that it is kind of pointless (given that, afaiu, the pagetables can be cached by the system cache)?
Quoted 58 lines
drivers/iommu/arm-smmu-qcom.c +5
-0+ +return 0 ; +} +static const struct arm_smmu_impl qcom_smmu_impl = { + .init_context = qcom_smmu_init_context, .reset = qcom_sdm845_smmu500_reset, };drivers/iommu/arm-smmu.c +14
-0@@ -1466,6 +1466,9 @@ static int arm_smmu_domain_get_attr(struct iommu_domain *domain,case DOMAIN_ATTR_NESTING : *(int *)data = (smmu_domain->stage ==ARM_SMMU_DOMAIN_NESTED );return 0 ; +case DOMAIN_ATTR_QCOM_SYS_CACHE : + *((int *)data) = smmu_domain->sys_cache; +return 0 ;default :return -ENODEV ; }@@ -1506,6 +1509,17 @@ static int arm_smmu_domain_set_attr(struct iommu_domain *domain,else smmu_domain->stage =ARM_SMMU_DOMAIN_S1 ;break ; +case DOMAIN_ATTR_QCOM_SYS_CACHE : +if (smmu_domain->smmu) { + ret = -EPERM ; + goto out_unlock; + } + +if (*((int *)data)) + smmu_domain->sys_cache = true; +else + smmu_domain->sys_cache = false; +break ;default : ret = -ENODEV ; }drivers/iommu/arm-smmu.h +1
-0@@ -322,6 +322,7 @@ struct arm_smmu_domain {struct mutex init_mutex;/* Protects smmu pointer */ spinlock_t cb_lock;/* Serialises ATS1* ops and TLB syncs */ struct iommu_domain domain; +bool sys_cache; };include/linux/iommu.h +0
-0
include/linux/iommu.h enum iommu_attr { · line 130
Quoted 4 lines
include/linux/iommu.h +1
-0@@ -127,6 +127,7 @@ enum iommu_attr {DOMAIN_ATTR_FSL_PAMUV1 ,DOMAIN_ATTR_NESTING ,/* two stages of translation */ DOMAIN_ATTR_DMA_USE_FLUSH_QUEUE , + DOMAIN_ATTR_QCOM_SYS_CACHE,
Given that IOMMU_QCOM_SYS_CACHE was renamed to IOMMU_SYS_CACHE_ONLY, I wonder if this domain attr should simply be DOMAIN_ATTR_SYS_CACHE?
But that said, the function of this domain attr seems to simply be to disable coherent walk.. I wonder if naming the domain attr after what it does would make more sense?
BR,
-R
Quoted 9 lines
include/linux/iommu.h +0
-1DOMAIN_ATTR_MAX, }; --1.9.1
_______________________________________________
Freedreno mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/freedreno
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 3/7 drm/msm: Attach the IOMMU device during initialization
In reply to Sharat MasettyFrom: Jordan Crouse <[email protected]>
Everywhere an IOMMU object is created by msm_gpu_create_address_space the IOMMU device is attached immediately after. Instead of carrying around the infrastructure to do the attach from the device specific code do it directly in the msm_iommu_init() function. This gets it out of the way for more aggressive cleanups that follow.
--- drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 9 --------- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 5 ----- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 8 -------- drivers/gpu/drm/msm/msm_gem_vma.c | 23 +++++++++++++++++++---- drivers/gpu/drm/msm/msm_gpu.c | 11 +---------- drivers/gpu/drm/msm/msm_gpummu.c | 7 ------- drivers/gpu/drm/msm/msm_iommu.c | 16 +++++++--------- drivers/gpu/drm/msm/msm_mmu.h | 1 - 8 files changed, 27 insertions(+), 53 deletions(-)
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +0 -9
@@ -736,7 +736,6 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms) {struct iommu_domain *domain;struct msm_gem_address_space *aspace; -int ret; domain =iommu_domain_alloc (&platform_bus_type);if (!domain)
@@ -752,14 +751,6 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms)return PTR_ERR (aspace); } - ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports, -ARRAY_SIZE (iommu_ports)); -if (ret) { -DPU_ERROR ("failed to attach iommu %d\n" , ret); -msm_gem_address_space_put (aspace); -return ret; - } - dpu_kms->base.aspace = aspace;return 0 ; }
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +0 -5
@@ -523,11 +523,6 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev) } kms->aspace = aspace; - - ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports, -ARRAY_SIZE (iommu_ports)); -if (ret) - goto fail; }else {DRM_DEV_INFO (dev->dev,"no iommu, fallback to phys " "contig buffers for scanout\n" );
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +0 -8
@@ -736,14 +736,6 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev) } kms->aspace = aspace; - - ret = aspace->mmu->funcs->attach (aspace->mmu, iommu_ports, -ARRAY_SIZE (iommu_ports)); -if (ret) { -DRM_DEV_ERROR (&pdev->dev,"failed to attach iommu: %d\n" , - ret); - goto fail; - } }else {DRM_DEV_INFO (&pdev->dev,"no iommu, fallback to phys contig buffers for scanout\n" );
drivers/gpu/drm/msm/msm_gem_vma.c +19 -4
@@ -131,8 +131,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; +u64 start = domain->geometry.aperture_start; +u64 size = domain->geometry.aperture_end - start; aspace =kzalloc (sizeof (*aspace),GFP_KERNEL );if (!aspace)
@@ -141,9 +141,18 @@ struct msm_gem_address_space *spin_lock_init (&aspace->lock); aspace->name = name; aspace->mmu =msm_iommu_new (dev, domain); +if (IS_ERR (aspace->mmu)) { +int ret =PTR_ERR (aspace->mmu); -drm_mm_init (&aspace->mm, (domain->geometry.aperture_start >>PAGE_SHIFT ), - size >>PAGE_SHIFT ); +kfree (aspace); +return ERR_PTR (ret); + } + +/* +* Attaching the IOMMU device changes the aperture values so use the +* cached values instead +*/ +drm_mm_init (&aspace->mm, start >>PAGE_SHIFT , size >>PAGE_SHIFT );kref_init (&aspace->kref);
@@ -164,6 +173,12 @@ struct msm_gem_address_space *spin_lock_init (&aspace->lock); aspace->name = name; aspace->mmu =msm_gpummu_new (dev, gpu); +if (IS_ERR (aspace->mmu)) { +int ret =PTR_ERR (aspace->mmu); + +kfree (aspace); +return ERR_PTR (ret); + }drm_mm_init (&aspace->mm, (va_start >>PAGE_SHIFT ), size >>PAGE_SHIFT );
drivers/gpu/drm/msm/msm_gpu.c +1 -10
@@ -807,7 +807,6 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) uint64_t va_start, uint64_t va_end) {struct msm_gem_address_space *aspace; -int ret;/* * Setup IOMMU.. eventually we will (I think) do this once per context
@@ -832,17 +831,9 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) va_start, va_end); } -if (IS_ERR (aspace)) { +if (IS_ERR (aspace))DRM_DEV_ERROR (gpu->dev->dev,"failed to init mmu: %ld\n" ,PTR_ERR (aspace)); -return ERR_CAST (aspace); - } - - ret = aspace->mmu->funcs->attach (aspace->mmu,NULL ,0 ); -if (ret) { -msm_gem_address_space_put (aspace); -return ERR_PTR (ret); - }return aspace; }
drivers/gpu/drm/msm/msm_gpummu.c +0 -7
@@ -21,12 +21,6 @@ struct msm_gpummu {#define GPUMMU_PAGE_SIZE SZ_4K#define TABLE_SIZE (sizeof(uint32_t) * GPUMMU_VA_RANGE / GPUMMU_PAGE_SIZE) -static int msm_gpummu_attach (struct msm_mmu *mmu,const char *const *names, -int cnt) -{ -return 0 ; -} -static void msm_gpummu_detach (struct msm_mmu *mmu,const char *const *names,int cnt) {
@@ -87,7 +81,6 @@ static void msm_gpummu_destroy(struct msm_mmu *mmu) }static const struct msm_mmu_funcs funcs = { - .attach = msm_gpummu_attach, .detach = msm_gpummu_detach, .map = msm_gpummu_map, .unmap = msm_gpummu_unmap,
drivers/gpu/drm/msm/msm_iommu.c +7 -9
@@ -23,14 +23,6 @@ static int msm_fault_handler(struct iommu_domain *domain, struct device *dev,return 0 ; } -static int msm_iommu_attach (struct msm_mmu *mmu,const char *const *names, -int cnt) -{ -struct msm_iommu *iommu =to_msm_iommu (mmu); - -return iommu_attach_device (iommu->domain, mmu->dev); -} -static void msm_iommu_detach (struct msm_mmu *mmu,const char *const *names,int cnt) {
@@ -68,7 +60,6 @@ static void msm_iommu_destroy(struct msm_mmu *mmu) }static const struct msm_mmu_funcs funcs = { - .attach = msm_iommu_attach, .detach = msm_iommu_detach, .map = msm_iommu_map, .unmap = msm_iommu_unmap,
@@ -78,6 +69,7 @@ static void msm_iommu_destroy(struct msm_mmu *mmu)struct msm_mmu *msm_iommu_new (struct device *dev,struct iommu_domain *domain) {struct msm_iommu *iommu; +int ret; iommu =kzalloc (sizeof (*iommu),GFP_KERNEL );if (!iommu)
@@ -87,5 +79,11 @@ struct msm_mmu *msm_iommu_new(struct device *dev, struct iommu_domain *domain)msm_mmu_init (&iommu->base, dev, &funcs);iommu_set_fault_handler (domain, msm_fault_handler, iommu); + ret =iommu_attach_device (iommu->domain, dev); +if (ret) { +kfree (iommu); +return ERR_PTR (ret); + } +return &iommu->base; }
drivers/gpu/drm/msm/msm_mmu.h +0 -1
@@ -10,7 +10,6 @@#include <linux/iommu.h> struct msm_mmu_funcs { -int (*attach)(struct msm_mmu *mmu,const char *const *names,int cnt);void (*detach)(struct msm_mmu *mmu,const char *const *names,int cnt);int (*map)(struct msm_mmu *mmu,uint64_t iova,struct sg_table *sgt,unsigned len,int prot);
Signature · 5 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 4/7 drm/msm: Refactor address space initialization
In reply to Sharat MasettyFrom: Jordan Crouse <[email protected]>
Refactor how address space initialization works. Instead of having the address space function create the MMU object (and thus require separate but equal functions for gpummu and iommu) use a single function and pass the MMU struct. Make the generic code cleaner by using target specific functions to create the address space so a2xx can do its own thing in its own space. For all the other targets use a generic helper to initialize IOMMU but leave the door open for newer targets to use customization if they need it.
This patch also adds support for a6xx specific mmu initialization to allow for future extensions like supporting split pagetables.
--- drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 16 ++++++++++ drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 1 + drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 24 +++++++++++++++ drivers/gpu/drm/msm/adreno/adreno_gpu.c | 23 ++++++++++---- drivers/gpu/drm/msm/adreno/adreno_gpu.h | 8 +++++ drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c | 10 +++--- drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c | 14 +++++---- drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c | 4 --- drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c | 11 +++++-- drivers/gpu/drm/msm/msm_drv.h | 8 ++--- drivers/gpu/drm/msm/msm_gem_vma.c | 52 +++++--------------------------- drivers/gpu/drm/msm/msm_gpu.c | 40 ++---------------------- drivers/gpu/drm/msm/msm_gpu.h | 4 +-- drivers/gpu/drm/msm/msm_iommu.c | 3 ++ 16 files changed, 106 insertions(+), 114 deletions(-)
drivers/gpu/drm/msm/adreno/a2xx_gpu.c +16 -0
@@ -401,6 +401,21 @@ static struct msm_gpu_state *a2xx_gpu_state_get(struct msm_gpu *gpu)return state; } +static struct msm_gem_address_space * +a2xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) +{ +struct msm_mmu *mmu =msm_gpummu_new (&pdev->dev, gpu); +struct msm_gem_address_space *aspace; + + aspace =msm_gem_address_space_create (mmu,"gpu" ,SZ_16M , +SZ_16M +0xfff *SZ_64K ); + +if (IS_ERR (aspace) && !IS_ERR (mmu)) + mmu->funcs->destroy (mmu); + +return aspace; +} +/* Register offset defines for A2XX - copy of A3XX */ static const unsigned int a2xx_register_offsets[REG_ADRENO_REGISTER_MAX ] = {REG_ADRENO_DEFINE (REG_ADRENO_CP_RB_BASE ,REG_AXXX_CP_RB_BASE ),
@@ -429,6 +444,7 @@ static struct msm_gpu_state *a2xx_gpu_state_get(struct msm_gpu *gpu)#endif .gpu_state_get = a2xx_gpu_state_get, .gpu_state_put = adreno_gpu_state_put, + .create_address_space = a2xx_create_address_space, }, };
drivers/gpu/drm/msm/adreno/a3xx_gpu.c +1 -0
@@ -448,6 +448,7 @@ static struct msm_gpu_state *a3xx_gpu_state_get(struct msm_gpu *gpu)#endif .gpu_state_get = a3xx_gpu_state_get, .gpu_state_put = adreno_gpu_state_put, + .create_address_space = adreno_iommu_create_address_space, }, };
drivers/gpu/drm/msm/adreno/a4xx_gpu.c +1 -0
@@ -538,6 +538,7 @@ static int a4xx_get_timestamp(struct msm_gpu *gpu, uint64_t *value)#endif .gpu_state_get = a4xx_gpu_state_get, .gpu_state_put = adreno_gpu_state_put, + .create_address_space = adreno_iommu_create_address_space, }, .get_timestamp = a4xx_get_timestamp, };
drivers/gpu/drm/msm/adreno/a5xx_gpu.c +1 -0
@@ -1394,6 +1394,7 @@ static unsigned long a5xx_gpu_busy(struct msm_gpu *gpu) .gpu_busy = a5xx_gpu_busy, .gpu_state_get = a5xx_gpu_state_get, .gpu_state_put = a5xx_gpu_state_put, + .create_address_space = adreno_iommu_create_address_space, }, .get_timestamp = a5xx_get_timestamp, };
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +24 -0
@@ -878,6 +878,29 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)return (unsigned long )busy_time; } +static struct msm_gem_address_space * +a6xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) +{ +struct iommu_domain *iommu =iommu_domain_alloc (&platform_bus_type); +struct msm_gem_address_space *aspace; +struct msm_mmu *mmu; + +if (!iommu) +return ERR_PTR (-ENOMEM ); + + mmu =msm_iommu_new (&pdev->dev, iommu); +if (IS_ERR (mmu)) { +iommu_domain_free (iommu); +return ERR_CAST (mmu); + } + + aspace =msm_gem_address_space_create (mmu,"gpu" ,SZ_16M ,0xffffffff ); +if (IS_ERR (aspace)) +iommu_domain_free (iommu); + +return aspace; +} +static const struct adreno_gpu_funcs funcs = { .base = { .get_param = adreno_get_param,
@@ -899,6 +922,7 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)#if defined(CONFIG_DRM_MSM_GPU_STATE ) .gpu_state_get = a6xx_gpu_state_get, .gpu_state_put = a6xx_gpu_state_put, + .create_address_space = a6xx_create_address_space,#endif }, .get_timestamp = a6xx_get_timestamp,
drivers/gpu/drm/msm/adreno/adreno_gpu.c +17 -6
@@ -156,6 +156,23 @@ int adreno_zap_shader_load(struct msm_gpu *gpu, u32 pasid)return zap_shader_load_mdt (gpu, adreno_gpu->info->zapfw, pasid); } +struct msm_gem_address_space * +adreno_iommu_create_address_space (struct msm_gpu *gpu, +struct platform_device *pdev) +{ +struct iommu_domain *iommu =iommu_domain_alloc (&platform_bus_type); +struct msm_mmu *mmu =msm_iommu_new (&pdev->dev, iommu); +struct msm_gem_address_space *aspace; + + aspace =msm_gem_address_space_create (mmu,"gpu" ,SZ_16M , +0xfffffff ); + +if (IS_ERR (aspace) && !IS_ERR (mmu)) + mmu->funcs->destroy (mmu); + +return aspace; +} +int adreno_get_param (struct msm_gpu *gpu,uint32_t param,uint64_t *value) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -909,12 +926,6 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev, adreno_gpu_config.ioname ="kgsl_3d0_reg_memory" ; - adreno_gpu_config.va_start =SZ_16M ; - adreno_gpu_config.va_end =0xffffffff ; -/* maximum range of a2xx mmu */ -if (adreno_is_a2xx (adreno_gpu)) - adreno_gpu_config.va_end =SZ_16M +0xfff *SZ_64K ; - adreno_gpu_config.nr_rings = nr_rings;adreno_get_pwrlevels (&pdev->dev, gpu);
drivers/gpu/drm/msm/adreno/adreno_gpu.h +8 -0
@@ -258,6 +258,14 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,int adreno_gpu_state_put (struct msm_gpu_state *state);/* +* Common helper function to initialize the default address space for arm-smmu +* attached targets +*/ +struct msm_gem_address_space * +adreno_iommu_create_address_space (struct msm_gpu *gpu, +struct platform_device *pdev); + +/* * For a5xx and a6xx targets load the zap shader that is used to pull the GPU * out of secure mode */
drivers/gpu/drm/msm/disp/dpu1/dpu_kms.c +5 -5
@@ -736,18 +736,18 @@ static int _dpu_kms_mmu_init(struct dpu_kms *dpu_kms) {struct iommu_domain *domain;struct msm_gem_address_space *aspace; +struct msm_mmu *mmu; domain =iommu_domain_alloc (&platform_bus_type);if (!domain)return 0 ; - domain->geometry.aperture_start =0x1000 ; - domain->geometry.aperture_end =0xffffffff ; + mmu =msm_iommu_new (dpu_kms->dev->dev, domain); + aspace =msm_gem_address_space_create (mmu,"dpu1" , +0x1000 ,0xfffffff ); - aspace =msm_gem_address_space_create (dpu_kms->dev->dev, - domain,"dpu1" );if (IS_ERR (aspace)) { -iommu_domain_free (domain); + mmu->funcs->destroy (mmu);return PTR_ERR (aspace); }
drivers/gpu/drm/msm/disp/mdp4/mdp4_kms.c +8 -6
@@ -515,9 +515,15 @@ struct msm_kms *mdp4_kms_init(struct drm_device *dev)mdelay (16 );if (config->iommu) { - aspace =msm_gem_address_space_create (&pdev->dev, - config->iommu,"mdp4" ); +struct msm_mmu *mmu =msm_iommu_new (&pdev->dev, + config->iommu); + + aspace =msm_gem_address_space_create (mmu, +"mdp4" ,0x1000 ,0xffffffff ); +if (IS_ERR (aspace)) { +if (!IS_ERR (mmu)) + mmu->funcs->destroy (mmu); ret =PTR_ERR (aspace); goto fail; }
@@ -570,10 +576,6 @@ static struct mdp4_platform_config *mdp4_get_config(struct platform_device *dev)/* TODO: Chips that aren't apq8064 have a 200 Mhz max_clk */ config.max_clk =266667000 ; config.iommu =iommu_domain_alloc (&platform_bus_type); -if (config.iommu) { - config.iommu->geometry.aperture_start =0x1000 ; - config.iommu->geometry.aperture_end =0xffffffff ; - }return &config; }
drivers/gpu/drm/msm/disp/mdp5/mdp5_cfg.c +0 -4
@@ -843,10 +843,6 @@ static struct mdp5_cfg_platform *mdp5_get_config(struct platform_device *dev)static struct mdp5_cfg_platform config = {}; config.iommu =iommu_domain_alloc (&platform_bus_type); -if (config.iommu) { - config.iommu->geometry.aperture_start =0x1000 ; - config.iommu->geometry.aperture_end =0xffffffff ; - }return &config; }
drivers/gpu/drm/msm/disp/mdp5/mdp5_kms.c +9 -2
@@ -724,13 +724,20 @@ struct msm_kms *mdp5_kms_init(struct drm_device *dev)mdelay (16 );if (config->platform.iommu) { +struct msm_mmu *mmu; + iommu_dev = &pdev->dev;if (!iommu_dev->iommu_fwspec) iommu_dev = iommu_dev->parent; - aspace =msm_gem_address_space_create (iommu_dev, - config->platform.iommu,"mdp5" ); + mmu =msm_iommu_new (iommu_dev, config->platform.iommu); + + aspace =msm_gem_address_space_create (mmu,"mdp5" , +0x1000 ,0xffffffff ); +if (IS_ERR (aspace)) { +if (!IS_ERR (mmu)) + mmu->funcs->destroy (mmu); ret =PTR_ERR (aspace); goto fail; }
drivers/gpu/drm/msm/msm_drv.h +2 -6
@@ -247,12 +247,8 @@ void msm_gem_close_vma(struct msm_gem_address_space *aspace,void msm_gem_address_space_put (struct msm_gem_address_space *aspace);struct msm_gem_address_space * -msm_gem_address_space_create (struct device *dev,struct iommu_domain *domain, -const char *name); - -struct msm_gem_address_space * -msm_gem_address_space_create_a2xx (struct device *dev,struct msm_gpu *gpu, -const char *name,uint64_t va_start,uint64_t va_end); +msm_gem_address_space_create (struct msm_mmu *mmu,const char *name, +u64 va_start,u64 va_end);int msm_register_mmu (struct drm_device *dev,struct msm_mmu *mmu);void msm_unregister_mmu (struct drm_device *dev,struct msm_mmu *mmu);
drivers/gpu/drm/msm/msm_gem_vma.c +7 -45
70 lines not on this page · raw message
drivers/gpu/drm/msm/msm_gpu.c +2 -38
@@ -802,42 +802,6 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu)return 0 ; } -static struct msm_gem_address_space * -msm_gpu_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev, -uint64_t va_start,uint64_t va_end) -{ -struct msm_gem_address_space *aspace; - -/* -* Setup IOMMU.. eventually we will (I think) do this once per context -* and have separate page tables per context. For now, to keep things -* simple and to get something working, just use a single address space: -*/ -if (!adreno_is_a2xx (to_adreno_gpu (gpu))) { -struct iommu_domain *iommu =iommu_domain_alloc (&platform_bus_type); -if (!iommu) -return NULL ; - - iommu->geometry.aperture_start = va_start; - iommu->geometry.aperture_end = va_end; - -DRM_DEV_INFO (gpu->dev->dev,"%s: using IOMMU\n" , gpu->name); - - aspace =msm_gem_address_space_create (&pdev->dev, iommu,"gpu" ); -if (IS_ERR (aspace)) -iommu_domain_free (iommu); - }else { - aspace =msm_gem_address_space_create_a2xx (&pdev->dev, gpu,"gpu" , - va_start, va_end); - } - -if (IS_ERR (aspace)) -DRM_DEV_ERROR (gpu->dev->dev,"failed to init mmu: %ld\n" , -PTR_ERR (aspace)); - -return aspace; -} -int msm_gpu_init (struct drm_device *drm,struct platform_device *pdev,struct msm_gpu *gpu,const struct msm_gpu_funcs *funcs,const char *name,struct msm_gpu_config *config)
@@ -910,8 +874,8 @@ int msm_gpu_init(struct drm_device *drm, struct platform_device *pdev,msm_devfreq_init (gpu); - gpu->aspace =msm_gpu_create_address_space (gpu, pdev, - config->va_start, config->va_end); + + gpu->aspace = gpu->funcs->create_address_space (gpu, pdev);if (gpu->aspace ==NULL )DRM_DEV_INFO (drm->dev,"%s: no IOMMU, fallback to VRAM carveout!\n" , name);
drivers/gpu/drm/msm/msm_gpu.h +2 -2
@@ -21,8 +21,6 @@struct msm_gpu_config {const char *ioname; -uint64_t va_start; -uint64_t va_end;unsigned int nr_rings; };
@@ -64,6 +62,8 @@ struct msm_gpu_funcs {int (*gpu_state_put)(struct msm_gpu_state *state);unsigned long (*gpu_get_freq)(struct msm_gpu *gpu);void (*gpu_set_freq)(struct msm_gpu *gpu,unsigned long freq); +struct msm_gem_address_space *(*create_address_space) + (struct msm_gpu *gpu,struct platform_device *pdev); };struct msm_gpu {
drivers/gpu/drm/msm/msm_iommu.c +3 -0
@@ -71,6 +71,9 @@ struct msm_mmu *msm_iommu_new(struct device *dev, struct iommu_domain *domain)struct msm_iommu *iommu;int ret; +if (!domain) +return ERR_PTR (-ENODEV ); + iommu =kzalloc (sizeof (*iommu),GFP_KERNEL );if (!iommu)return ERR_PTR (-ENOMEM );
--
1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 5/7 drm: msm: a6xx: Properly free up the iommu objects
In reply to Sharat MasettyThis patch calls the right function to destroy the iommu domain as well as free the associated iommu structure there by facilitating proper clean up of resources upon failure of creating an address space.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +1 -1
@@ -896,7 +896,7 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) aspace =msm_gem_address_space_create (mmu,"gpu" ,SZ_16M ,0xffffffff );if (IS_ERR (aspace)) -iommu_domain_free (iommu); + mmu->funcs->destroy (mmu);return aspace; }
--
1.9.1
PATCH v2 6/7 drm/msm: rearrange the gpu_rmw() function
In reply to Sharat MasettyThe register read-modify-write construct is generic enough that it can be used by other subsystems as needed, create a more generic rmw() function and have the gpu_rmw() use this new function.
--- drivers/gpu/drm/msm/msm_drv.c | 8 ++++++++ drivers/gpu/drm/msm/msm_drv.h | 1 + drivers/gpu/drm/msm/msm_gpu.h | 5 +---- 3 files changed, 10 insertions(+), 4 deletions(-)
drivers/gpu/drm/msm/msm_drv.c +8 -0
@@ -165,6 +165,14 @@ u32 msm_readl(const void __iomem *addr)return val; } +void msm_rmw (void __iomem *addr,u32 mask,u32 or) +{ +u32 val =msm_readl (addr); + + val &= ~mask; +msm_writel (val | or, addr); +} +struct msm_vblank_work {struct work_struct work;int crtc_id;
drivers/gpu/drm/msm/msm_drv.h +1 -0
@@ -405,6 +405,7 @@ void __iomem *msm_ioremap(struct platform_device *pdev, const char *name, const char *dbgname);void msm_writel (u32 data,void __iomem *addr);u32 msm_readl (const void __iomem *addr); +void msm_rmw (void __iomem *addr,u32 mask,u32 or);struct msm_gpu_submitqueue ;int msm_submitqueue_init (struct drm_device *drm,struct msm_file_private *ctx);
drivers/gpu/drm/msm/msm_gpu.h +1 -4
@@ -223,10 +223,7 @@ static inline u32 gpu_read(struct msm_gpu *gpu, u32 reg)static inline void gpu_rmw (struct msm_gpu *gpu,u32 reg,u32 mask,u32 or) { -uint32_t val =gpu_read (gpu, reg); - - val &= ~mask; -gpu_write (gpu, reg, val | or); +msm_rmw (gpu->mmio + (reg <<2 ), mask, or); }static inline u64 gpu_read64 (struct msm_gpu *gpu,u32 lo,u32 hi)
Signature · 5 lines
1.9.1 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
PATCH v2 7/7 drm/msm/a6xx: Add support for using system cache(LLC)
In reply to Sharat MasettyThe last level system cache can be partitioned to 32 different slices of which GPU has two slices preallocated. One slice is used for caching GPU buffers and the other slice is used for caching the GPU SMMU pagetables. This patch talks to the core system cache driver to acquire the slice handles, configure the SCID's to those slices and activates and deactivates the slices upon GPU power collapse and restore.
Some support from the IOMMU driver is also needed to make use of the system cache. IOMMU_QCOM_SYS_CACHE is a buffer protection flag which enables caching GPU data buffers in the system cache with memory attributes such as outer cacheable, read-allocate, write-allocate for buffers. The GPU then has the ability to override a few cacheability parameters which it does to override write-allocate to write-no-allocate as the GPU hardware does not benefit much from it.
Similarly DOMAIN_ATTR_QCOM_SYS_CACHE is another domain level attribute used by the IOMMU driver to set the right attributes to cache the hardware pagetables into the system cache.
--- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 100 ++++++++++++++++++++++++++++++++++ drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 3 + drivers/gpu/drm/msm/msm_iommu.c | 3 + drivers/gpu/drm/msm/msm_mmu.h | 4 ++ 4 files changed, 110 insertions(+)
drivers/gpu/drm/msm/adreno/a6xx_gpu.c +100 -0
@@ -9,6 +9,8 @@#include "a6xx_gmu.xml.h" #include <linux/devfreq.h> +#include <linux/bitfield.h> +#include <linux/soc/qcom/llcc-qcom.h> #define GPU_PAS_ID 13
@@ -781,6 +783,81 @@ static void a6xx_bus_clear_pending_transactions(struct adreno_gpu *adreno_gpu)gpu_write (gpu,REG_A6XX_GBIF_HALT ,0x0 ); } +static void a6xx_llc_rmw (struct a6xx_gpu *a6xx_gpu,u32 reg,u32 mask,u32 or) +{ +return msm_rmw (a6xx_gpu->llc_mmio + (reg <<2 ), mask, or); +} + +static void a6xx_llc_write (struct a6xx_gpu *a6xx_gpu,u32 reg,u32 value) +{ +return msm_writel (value, a6xx_gpu->llc_mmio + (reg <<2 )); +} + +static void a6xx_llc_deactivate (struct a6xx_gpu *a6xx_gpu) +{ +llcc_slice_deactivate (a6xx_gpu->llc_slice); +llcc_slice_deactivate (a6xx_gpu->htw_llc_slice); +} + +static void a6xx_llc_activate (struct a6xx_gpu *a6xx_gpu) +{ +u32 cntl1_regval =0 ; + +if (IS_ERR (a6xx_gpu->llc_mmio)) +return ; + +if (!llcc_slice_activate (a6xx_gpu->llc_slice)) { +u32 gpu_scid =llcc_get_slice_id (a6xx_gpu->llc_slice); + + gpu_scid &=0x1f ; + cntl1_regval = (gpu_scid <<0 ) | (gpu_scid <<5 ) | + (gpu_scid <<10 ) | (gpu_scid <<15 ) | (gpu_scid <<20 ); + } + +if (!llcc_slice_activate (a6xx_gpu->htw_llc_slice)) { +u32 gpuhtw_scid =llcc_get_slice_id (a6xx_gpu->htw_llc_slice); + + gpuhtw_scid &=0x1f ; + cntl1_regval |=FIELD_PREP (GENMASK (29 ,25 ), gpuhtw_scid); + } + +if (cntl1_regval) { +/* +* Program the slice IDs for the various GPU blocks and GPU MMU +* pagetables +*/ +a6xx_llc_write (a6xx_gpu,REG_A6XX_CX_MISC_SYSTEM_CACHE_CNTL_1 , + cntl1_regval); + +/* +* Program cacheability overrides to not allocate cache lines on +* a write miss +*/ +a6xx_llc_rmw (a6xx_gpu,REG_A6XX_CX_MISC_SYSTEM_CACHE_CNTL_0 , +0xF ,0x03 ); + } +} + +static void a6xx_llc_slices_destroy (struct a6xx_gpu *a6xx_gpu) +{ +llcc_slice_putd (a6xx_gpu->llc_slice); +llcc_slice_putd (a6xx_gpu->htw_llc_slice); +} + +static void a6xx_llc_slices_init (struct platform_device *pdev, +struct a6xx_gpu *a6xx_gpu) +{ + a6xx_gpu->llc_mmio =msm_ioremap (pdev,"cx_mem" ,"gpu_cx" ); +if (IS_ERR (a6xx_gpu->llc_mmio)) +return ; + + a6xx_gpu->llc_slice =llcc_slice_getd (LLCC_GPU ); + a6xx_gpu->htw_llc_slice =llcc_slice_getd (LLCC_GPUHTW ); + +if (IS_ERR (a6xx_gpu->llc_slice) &&IS_ERR (a6xx_gpu->htw_llc_slice)) + a6xx_gpu->llc_mmio =ERR_PTR (-EINVAL ); +} +static int a6xx_pm_resume (struct msm_gpu *gpu) {struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);
@@ -795,6 +872,8 @@ static int a6xx_pm_resume(struct msm_gpu *gpu)msm_gpu_resume_devfreq (gpu); +a6xx_llc_activate (a6xx_gpu); +return 0 ; }
@@ -803,6 +882,8 @@ static int a6xx_pm_suspend(struct msm_gpu *gpu)struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu);struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu); +a6xx_llc_deactivate (a6xx_gpu); +devfreq_suspend_device (gpu->devfreq.devfreq);/*
@@ -851,6 +932,7 @@ static void a6xx_destroy(struct msm_gpu *gpu)drm_gem_object_put_unlocked (a6xx_gpu->sqe_bo); } +a6xx_llc_slices_destroy (a6xx_gpu);a6xx_gmu_remove (a6xx_gpu);adreno_gpu_cleanup (adreno_gpu);
@@ -881,6 +963,8 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)static struct msm_gem_address_space *a6xx_create_address_space (struct msm_gpu *gpu,struct platform_device *pdev) { +struct adreno_gpu *adreno_gpu =to_adreno_gpu (gpu); +struct a6xx_gpu *a6xx_gpu =to_a6xx_gpu (adreno_gpu);struct iommu_domain *iommu =iommu_domain_alloc (&platform_bus_type);struct msm_gem_address_space *aspace;struct msm_mmu *mmu;
@@ -894,6 +978,20 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu)return ERR_CAST (mmu); } +if (!IS_ERR (a6xx_gpu->llc_slice)) + mmu->features |=MMU_FEATURE_USE_SYSTEM_CACHE ; + +/* +* This allows GPU to set the bus attributes required to use system +* cache on behalf of the iommu page table walker. +*/ +if (!IS_ERR (a6xx_gpu->htw_llc_slice)) { +int gpu_htw_llc =1 ; + +iommu_domain_set_attr (iommu,DOMAIN_ATTR_QCOM_SYS_CACHE , + &gpu_htw_llc); + } + aspace =msm_gem_address_space_create (mmu,"gpu" ,SZ_16M ,0xffffffff );if (IS_ERR (aspace)) mmu->funcs->destroy (mmu);
@@ -948,6 +1046,8 @@ struct msm_gpu *a6xx_gpu_init(struct drm_device *dev) adreno_gpu->registers =NULL ; adreno_gpu->reg_offsets = a6xx_register_offsets; +a6xx_llc_slices_init (pdev, a6xx_gpu); + ret =adreno_gpu_init (dev, pdev, adreno_gpu, &funcs,1 );if (ret) {a6xx_destroy (&(a6xx_gpu->base.base));
drivers/gpu/drm/msm/adreno/a6xx_gpu.h +3 -0
@@ -21,6 +21,9 @@ struct a6xx_gpu {struct msm_ringbuffer *cur_ring;struct a6xx_gmu gmu; +void __iomem *llc_mmio; +void *llc_slice; +void *htw_llc_slice; };#define to_a6xx_gpu (x) container_of(x, struct a6xx_gpu, base)
drivers/gpu/drm/msm/msm_iommu.c +3 -0
@@ -37,6 +37,9 @@ static int msm_iommu_map(struct msm_mmu *mmu, uint64_t iova,struct msm_iommu *iommu =to_msm_iommu (mmu);size_t ret; +if (mmu->features &MMU_FEATURE_USE_SYSTEM_CACHE ) + prot |=IOMMU_QCOM_SYS_CACHE ; + ret =iommu_map_sg (iommu->domain, iova, sgt->sgl, sgt->nents, prot);WARN_ON (!ret);
drivers/gpu/drm/msm/msm_mmu.h +4 -0
@@ -17,11 +17,15 @@ struct msm_mmu_funcs {void (*destroy)(struct msm_mmu *mmu); }; +/* MMU features */ +#define MMU_FEATURE_USE_SYSTEM_CACHE (1 << 0) +struct msm_mmu {const struct msm_mmu_funcs *funcs;struct device *dev;int (*handler)(void *arg,unsigned long iova,int flags);void *arg; +u32 features; }; static inline void msm_mmu_init(struct msm_mmu *mmu, struct device *dev,
--
1.9.1
_______________________________________________
dri-devel mailing list
[email protected]
https://lists.freedesktop.org/mailman/listinfo/dri-devel