Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.1 required=3.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY, SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4DA77C433DF for ; Fri, 12 Jun 2020 17:22:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 217582084D for ; Fri, 12 Jun 2020 17:22:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="sf9LAlea" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbgFLRWC (ORCPT ); Fri, 12 Jun 2020 13:22:02 -0400 Received: from mail27.static.mailgun.info ([104.130.122.27]:41921 "EHLO mail27.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726085AbgFLRWC (ORCPT ); Fri, 12 Jun 2020 13:22:02 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1591982520; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=fWknkGYfbRq73n5akkvEQmXOR+Mhuj3iaaByL0gFj24=; b=sf9LAlea2z7ecL+/2NDZsk1FrgGPb6xNVHQEmdUcK8w5AI78zw4ucu1VLZ2skfXpIquJuwm2 v7mAYWv8Y67GMz8xdId5sOrtNQ3gT1FsuhKKdqJ9IEGk5QNMnGWhtDr1J+56waJQtt6PUyDn I/2yqoasluk4JK5yDZu9M+PReWU= X-Mailgun-Sending-Ip: 104.130.122.27 X-Mailgun-Sid: WyI1MzIzYiIsICJsaW51eC1hcm0tbXNtQHZnZXIua2VybmVsLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n01.prod.us-east-1.postgun.com with SMTP id 5ee3b9b5a3d8a447431a6887 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Fri, 12 Jun 2020 17:21:57 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 18D73C433AD; Fri, 12 Jun 2020 17:21:57 +0000 (UTC) Received: from jcrouse1-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse) by smtp.codeaurora.org (Postfix) with ESMTPSA id D60C1C43391; Fri, 12 Jun 2020 17:21:54 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org D60C1C43391 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org Date: Fri, 12 Jun 2020 11:21:51 -0600 From: Jordan Crouse To: Rob Clark Cc: linux-arm-msm , freedreno , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Akhil P Oommen , Daniel Vetter , David Airlie , Eric Anholt , Jonathan Marek , Sean Paul , Sharat Masetty , dri-devel , Linux Kernel Mailing List Subject: Re: [PATCH 6/6] drm/msm/a6xx: Add support for per-instance pagetables Message-ID: <20200612172151.GA12783@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Rob Clark , linux-arm-msm , freedreno , "list@263.net:IOMMU DRIVERS , Joerg Roedel ," , Akhil P Oommen , Daniel Vetter , David Airlie , Eric Anholt , Jonathan Marek , Sean Paul , Sharat Masetty , dri-devel , Linux Kernel Mailing List References: <20200611222921.464-1-jcrouse@codeaurora.org> <20200611222921.464-7-jcrouse@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.5.24 (2015-08-30) Sender: linux-arm-msm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org On Thu, Jun 11, 2020 at 08:22:29PM -0700, Rob Clark wrote: > On Thu, Jun 11, 2020 at 3:29 PM Jordan Crouse wrote: > > > > Add support for using per-instance pagetables if all the dependencies are > > available. > > > > Signed-off-by: Jordan Crouse > > --- > > > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 69 ++++++++++++++++++++++++++- > > drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + > > 2 files changed, 69 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > > index a1589e040c57..5e82b85d4d55 100644 > > --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > > +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > > @@ -79,6 +79,58 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, > > OUT_RING(ring, upper_32_bits(iova)); > > } > > > > +static void a6xx_set_pagetable(struct msm_gpu *gpu, struct msm_ringbuffer *ring, > > + struct msm_file_private *ctx) > > +{ > > + phys_addr_t ttbr; > > + u32 asid; > > + > > + if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid)) > > + return; > > + > > + OUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1); > > + OUT_RING(ring, 0); > > + > > + /* Turn on APIV mode to access critical regions */ > > + OUT_PKT4(ring, REG_A6XX_CP_MISC_CNTL, 1); > > + OUT_RING(ring, 1); > > + > > + /* Make sure the ME is synchronized before staring the update */ > > + OUT_PKT7(ring, CP_WAIT_FOR_ME, 0); > > + > > + /* Execute the table update */ > > + OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4); > > + OUT_RING(ring, lower_32_bits(ttbr)); > > + OUT_RING(ring, (((u64) asid) << 48) | upper_32_bits(ttbr)); > > + /* CONTEXTIDR is currently unused */ > > + OUT_RING(ring, 0); > > + /* CONTEXTBANK is currently unused */ > > + OUT_RING(ring, 0); > > I can add this to xml (on userspace side, we've been describing packet > payload in xml and using the generated builders), and update generated > headers, if you agree to not add more open-coded pkt7 building ;-) But open coding opcode is so much fun! :) Its fine to put this in the XML. It can only be executed from the ringbuffer FWIW. > > + > > + /* > > + * Write the new TTBR0 to the memstore. This is good for debugging. > > + */ > > + OUT_PKT7(ring, CP_MEM_WRITE, 4); > > + OUT_RING(ring, lower_32_bits(rbmemptr(ring, ttbr0))); > > + OUT_RING(ring, upper_32_bits(rbmemptr(ring, ttbr0))); > > + OUT_RING(ring, lower_32_bits(ttbr)); > > + OUT_RING(ring, (((u64) asid) << 48) | upper_32_bits(ttbr)); > > + > > + /* Invalidate the draw state so we start off fresh */ > > + OUT_PKT7(ring, CP_SET_DRAW_STATE, 3); > > + OUT_RING(ring, 0x40000); > > + OUT_RING(ring, 1); > > + OUT_RING(ring, 0); > > Ie, this would look like: > > OUT_PKT7(ring, CP_SET_DRAW_STATE, 3); > OUT_RING(ring, CP_SET_DRAW_STATE__0_COUNT(0) | > CP_SET_DRAW_STATE__0_DISABLE_ALL_GROUPS | > CP_SET_DRAW_STATE__0_GROUP_ID(0)); > OUT_RING(ring, CP_SET_DRAW_STATE__1_ADDR_LO(1)); > OUT_RING(ring, CP_SET_DRAW_STATE__2_ADDR_HI(0)); > > .. but written that way, I think you meant ADDR_LO to be zero? > > (it is possible we need to regen headers for that to work, the kernel > headers are somewhat out of date by now) As we discussed on IRC this bit isn't needed because the CP_SMMU_TABLE_UPDATE handles it for us. I'll remove that. > BR, > -R Jordan > > + > > + /* Turn off APRIV */ > > + OUT_PKT4(ring, REG_A6XX_CP_MISC_CNTL, 1); > > + OUT_RING(ring, 0); > > + > > + /* Turn off protected mode */ > > + OUT_PKT7(ring, CP_SET_PROTECTED_MODE, 1); > > + OUT_RING(ring, 1); > > +} > > + > > static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, > > struct msm_file_private *ctx) > > { > > @@ -89,6 +141,8 @@ static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit, > > struct msm_ringbuffer *ring = submit->ring; > > unsigned int i; > > > > + a6xx_set_pagetable(gpu, ring, ctx); > > + > > get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, > > rbmemptr_stats(ring, index, cpcycles_start)); > > > > @@ -872,6 +926,18 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) > > return (unsigned long)busy_time; > > } > > > > +struct msm_gem_address_space *a6xx_address_space_instance(struct msm_gpu *gpu) > > +{ > > + struct msm_mmu *mmu; > > + > > + mmu = msm_iommu_pagetable_create(gpu->aspace->mmu); > > + if (IS_ERR(mmu)) > > + return msm_gem_address_space_get(gpu->aspace); > > + > > + return msm_gem_address_space_create(mmu, > > + "gpu", 0x100000000ULL, 0x1ffffffffULL); > > +} > > + > > static const struct adreno_gpu_funcs funcs = { > > .base = { > > .get_param = adreno_get_param, > > @@ -893,8 +959,9 @@ static const struct adreno_gpu_funcs funcs = { > > #if defined(CONFIG_DRM_MSM_GPU_STATE) > > .gpu_state_get = a6xx_gpu_state_get, > > .gpu_state_put = a6xx_gpu_state_put, > > - .create_address_space = adreno_iommu_create_address_space, > > #endif > > + .create_address_space = adreno_iommu_create_address_space, > > + .address_space_instance = a6xx_address_space_instance, > > }, > > .get_timestamp = a6xx_get_timestamp, > > }; > > diff --git a/drivers/gpu/drm/msm/msm_ringbuffer.h b/drivers/gpu/drm/msm/msm_ringbuffer.h > > index 7764373d0ed2..0987d6bf848c 100644 > > --- a/drivers/gpu/drm/msm/msm_ringbuffer.h > > +++ b/drivers/gpu/drm/msm/msm_ringbuffer.h > > @@ -31,6 +31,7 @@ struct msm_rbmemptrs { > > volatile uint32_t fence; > > > > volatile struct msm_gpu_submit_stats stats[MSM_GPU_SUBMIT_STATS_COUNT]; > > + volatile u64 ttbr0; > > }; > > > > struct msm_ringbuffer { > > -- > > 2.17.1 > > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project