Re: [PATCH 4/6] drm/msm/adreno: Program the SMMU aperture when the secure world can't

From: Akhil P Oommen

Date: Wed Nov 18 2026 - 13:48:24 EST




On 11/18/2026 6:38 PM, Puranam V G Tejaswi wrote:
> The CP switches pagetables by writing the GPU SMMU context bank
> registers itself. It reaches them through the CX SMMU aperture, a
> register block in the GPU, which has to point at context bank 0. The
> secure world normally owns this block and programs it when
> adreno_hw_init() calls qcom_scm_set_gpu_smmu_aperture().
>
> Some platforms have a secure world that does not implement this. Nothing
> programs the aperture on these platforms, so the CP cannot switch
> pagetables.
>
> If the SCM call is not supported, program the aperture from
> adreno_hw_init() instead. Point the GC aperture at context bank 0 and,
> on GPUs with LPAC, the LPAC aperture at context bank 1, the same way
> the secure world does. Disable the other apertures. The SCM call is
> still used whenever it is supported.
>
> The values depend on where context bank 0 sits in the GPU register
> space, which differs between GPUs, so they come from a register list in
> the GPU catalog. The aperture region comes from DT. If DT describes the
> region but it cannot be mapped, fail probe. Add the lists for A702,
> whose entry Shikra's GPU also uses, and for A753.
>
> Signed-off-by: Puranam V G Tejaswi <puranam.tejaswi@xxxxxxxxxxxxxxxx>
> ---
> drivers/gpu/drm/msm/adreno/a6xx_catalog.c | 9 ++++++++
> drivers/gpu/drm/msm/adreno/a7xx_catalog.c | 10 +++++++++
> drivers/gpu/drm/msm/adreno/adreno_gpu.c | 37 +++++++++++++++++++++++++++++++
> drivers/gpu/drm/msm/adreno/adreno_gpu.h | 21 ++++++++++++++++++
> 4 files changed, 77 insertions(+)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_catalog.c b/drivers/gpu/drm/msm/adreno/a6xx_catalog.c
> index 4ef2bd6e7ad2..fe1902b8de16 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_catalog.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_catalog.c
> @@ -736,6 +736,14 @@ static const struct adreno_reglist a702_hwcg[] = {
> {}
> };
>
> +/* GPU aperture: GC to CB0, other apertures disabled */
> +static const struct adreno_reglist a702_aperture_reglist_regs[] = {
> + { 0x00, 0x000a8000 }, /* GC: CB0 */
> + { 0x08, 0x00000000 }, /* CTRL: GC only */

These offsets should be documented in the xml file instead of hardcoded values.
Otherwise LGTM.

-Akhil.
> +};
> +
> +DECLARE_ADRENO_REGPAIR_LIST(a702_aperture_reglist);
> +
> static const struct adreno_info a6xx_gpus[] = {
> {
> .chip_ids = ADRENO_CHIP_IDS(0x06010000),
> @@ -1198,6 +1206,7 @@ static const struct adreno_info a6xx_gpus[] = {
> .quirks = ADRENO_QUIRK_HAS_HW_APRIV,
> .funcs = &a6xx_gmuwrapper_funcs,
> .zapfw = "a702_zap.mbn",
> + .aperture_reglist = &a702_aperture_reglist,
> .a6xx = &(const struct a6xx_info) {
> .hwcg = a702_hwcg,
> .protect = &a650_protect,
> diff --git a/drivers/gpu/drm/msm/adreno/a7xx_catalog.c b/drivers/gpu/drm/msm/adreno/a7xx_catalog.c
> index 9465ffa3dd12..43d681aa3c2e 100644
> --- a/drivers/gpu/drm/msm/adreno/a7xx_catalog.c
> +++ b/drivers/gpu/drm/msm/adreno/a7xx_catalog.c
> @@ -279,6 +279,15 @@ static const struct adreno_reglist_pipe a7xx_dyn_pwrup_reglist_regs[] = {
>
> DECLARE_ADRENO_REGLIST_PIPE_LIST(a7xx_dyn_pwrup_reglist);
>
> +/* GPU aperture: GC to CB0, LPAC to CB1, other apertures disabled */
> +static const struct adreno_reglist a753_aperture_reglist_regs[] = {
> + { 0x00, 0x000c0000 }, /* GC: CB0 */
> + { 0x04, 0x000c1000 }, /* LPAC: CB1 */
> + { 0x08, 0x00000002 }, /* CTRL: GC and LPAC */
> +};
> +
> +DECLARE_ADRENO_REGPAIR_LIST(a753_aperture_reglist);
> +
> static const struct adreno_info a7xx_gpus[] = {
> {
> .chip_ids = ADRENO_CHIP_IDS(0x07030001),
> @@ -465,6 +474,7 @@ static const struct adreno_info a7xx_gpus[] = {
> ADRENO_QUIRK_PREEMPTION |
> ADRENO_QUIRK_IFPC,
> .funcs = &a7xx_gpu_funcs,
> + .aperture_reglist = &a753_aperture_reglist,
> .a6xx = &(const struct a6xx_info) {
> .protect = &a730_protect,
> .pwrup_reglist = &a7xx_pwrup_reglist,
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.c b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> index 54f337475231..c3c84629c5f4 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.c
> @@ -675,6 +675,13 @@ int adreno_hw_init(struct msm_gpu *gpu)
> ret = qcom_scm_set_gpu_smmu_aperture(0);
> if (ret)
> DRM_DEV_ERROR(gpu->dev->dev, "unable to set SMMU aperture: %d\n", ret);
> + } else if (adreno_gpu->aperture) {
> + const struct adreno_regpair_list *list =
> + adreno_gpu->info->aperture_reglist;
> +
> + for (int i = 0; i < list->count; i++)
> + writel(list->regs[i].value,
> + adreno_gpu->aperture + list->regs[i].offset);
> }
>
> for (int i = 0; i < gpu->nr_rings; i++) {
> @@ -1193,6 +1200,32 @@ int adreno_read_speedbin(struct device *dev, u32 *speedbin)
> return nvmem_cell_read_variable_le_u32(dev, "speed_bin", speedbin);
> }
>
> +/*
> + * Map the GPU aperture, so that adreno_hw_init() can program it when
> + * the secure world does not.
> + */
> +static int adreno_gpu_aperture_init(struct platform_device *pdev,
> + struct adreno_gpu *adreno_gpu)
> +{
> + struct resource *res;
> + void __iomem *base;
> +
> + if (!adreno_gpu->info->aperture_reglist)
> + return 0;
> +
> + res = platform_get_resource_byname(pdev, IORESOURCE_MEM, "aperture");
> + if (!res)
> + return 0;
> +
> + base = devm_ioremap_resource(&pdev->dev, res);
> + if (IS_ERR(base))
> + return PTR_ERR(base);
> +
> + adreno_gpu->aperture = base;
> +
> + return 0;
> +}
> +
> int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
> struct adreno_gpu *adreno_gpu,
> const struct adreno_gpu_funcs *funcs, int nr_rings)
> @@ -1238,6 +1271,10 @@ int adreno_gpu_init(struct drm_device *drm, struct platform_device *pdev,
>
> adreno_gpu_config.ioname = "kgsl_3d0_reg_memory";
>
> + ret = adreno_gpu_aperture_init(pdev, adreno_gpu);
> + if (ret)
> + return ret;
> +
> adreno_gpu_config.nr_rings = nr_rings;
>
> ret = adreno_get_pwrlevels(dev, gpu);
> diff --git a/drivers/gpu/drm/msm/adreno/adreno_gpu.h b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> index 2911d440ab17..021802c6830c 100644
> --- a/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> +++ b/drivers/gpu/drm/msm/adreno/adreno_gpu.h
> @@ -88,6 +88,19 @@ struct adreno_reglist {
> u32 value;
> };
>
> +struct adreno_regpair_list {
> + /** @regs: List of register offset and value pairs **/
> + const struct adreno_reglist *regs;
> + /** @count: Number of registers in the list **/
> + u32 count;
> +};
> +
> +#define DECLARE_ADRENO_REGPAIR_LIST(name) \
> +static const struct adreno_regpair_list name = { \
> + .regs = name ## _regs, \
> + .count = ARRAY_SIZE(name ## _regs), \
> +}
> +
> /* Reglist with pipe information */
> struct adreno_reglist_pipe {
> u32 offset;
> @@ -129,6 +142,11 @@ struct adreno_info {
> */
> struct adreno_speedbin *speedbins;
> u64 preempt_record_size;
> + /**
> + * @aperture_reglist: Optional GPU aperture register values. Used if
> + * the secure world does not program the aperture.
> + */
> + const struct adreno_regpair_list *aperture_reglist;
> };
>
> #define ADRENO_CHIP_IDS(tbl...) (uint32_t[]) { tbl, 0 }
> @@ -250,6 +268,9 @@ struct adreno_gpu {
>
> bool has_ray_tracing;
>
> + /* GPU aperture, if the driver may need to program it */
> + void __iomem *aperture;
> +
> u64 uche_trap_base;
> };
> #define to_adreno_gpu(x) container_of(x, struct adreno_gpu, base)
>