From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.1 required=3.0 tests=BAYES_00,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=unavailable 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 D91D4C433EB for ; Mon, 17 Aug 2020 16:47:57 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AF597206FA for ; Mon, 17 Aug 2020 16:47:57 +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="DgwjSrHb" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388889AbgHQQru (ORCPT ); Mon, 17 Aug 2020 12:47:50 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:46409 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388852AbgHQQrc (ORCPT ); Mon, 17 Aug 2020 12:47:32 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597682850; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=cJGHnK9LZROPEDWmJysaGgCbhijGlhi6d8SwrJT3rM8=; b=DgwjSrHbwE+HRSFGXh3XkeHKJbUga8JdAF7sBBru+BKxYv3+sdK+H2Gdj67qeKdnnW6S4ud0 0Yd91Jt9nxVLMDwBccPxt2amVWXnyiBGRa19vRxQ975xJuVEbsR6P6XtRTH68VecOWM6JOQa LucmENT5sirJPzwA41h7x0DaDvQ= X-Mailgun-Sending-Ip: 69.72.43.7 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-n07.prod.us-west-2.postgun.com with SMTP id 5f3ab49c2f4952907dfa1378 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 17 Aug 2020 16:47:24 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 9B1A8C433A1; Mon, 17 Aug 2020 16:47:23 +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 11C53C433C6; Mon, 17 Aug 2020 16:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11C53C433C6 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: Mon, 17 Aug 2020 10:47:17 -0600 From: Jordan Crouse To: Akhil P Oommen Cc: Rob Clark , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jonathan Marek , Sharat Masetty , Eric Anholt , open list Subject: Re: [PATCH 16/19] drm/msm/a6xx: Add support for per-instance pagetables Message-ID: <20200817164716.GE3221@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Akhil P Oommen , Rob Clark , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jonathan Marek , Sharat Masetty , Eric Anholt , open list References: <20200810222657.1841322-1-jcrouse@codeaurora.org> <20200814024114.1177553-17-robdclark@gmail.com> <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> 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 Mon, Aug 17, 2020 at 09:10:46PM +0530, Akhil P Oommen wrote: > On 8/14/2020 8:11 AM, Rob Clark wrote: > >From: Jordan Crouse > > > >Add support for using per-instance pagetables if all the dependencies are > >available. > > > >Signed-off-by: Jordan Crouse > >Signed-off-by: Rob Clark > >--- > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 70 +++++++++++++++++++++++++++ > > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > > drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + > > 3 files changed, 72 insertions(+) > > > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >index 5eabb0109577..9653ac9b3cb8 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >@@ -81,6 +81,56 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, > > OUT_RING(ring, upper_32_bits(iova)); > > } > >+static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, > >+ struct msm_ringbuffer *ring, struct msm_file_private *ctx) > >+{ > >+ phys_addr_t ttbr; > >+ u32 asid; > >+ u64 memptr = rbmemptr(ring, ttbr0); > >+ > >+ if (ctx == a6xx_gpu->cur_ctx) > >+ return; > >+ > >+ if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid)) > >+ return; > >+ > >+ /* Execute the table update */ > >+ OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_0_TTBR0_LO(lower_32_bits(ttbr))); > >+ > >+ /* > >+ * For now ignore the asid since the smmu driver uses a TLBIASID to > >+ * flush the TLB when we use iommu_flush_tlb_all() and the smmu driver > >+ * isn't aware that the asid changed. Instead, keep the default asid > >+ * (0, same as the context bank) to make sure the TLB is properly > >+ * flushed. > >+ */ > >+ OUT_RING(ring, > >+ CP_SMMU_TABLE_UPDATE_1_TTBR0_HI(upper_32_bits(ttbr)) | > >+ CP_SMMU_TABLE_UPDATE_1_ASID(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_2_CONTEXTIDR(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_3_CONTEXTBANK(0)); > >+ > >+ /* > >+ * Write the new TTBR0 to the memstore. This is good for debugging. > >+ */ > >+ OUT_PKT7(ring, CP_MEM_WRITE, 4); > >+ OUT_RING(ring, CP_MEM_WRITE_0_ADDR_LO(lower_32_bits(memptr))); > >+ OUT_RING(ring, CP_MEM_WRITE_1_ADDR_HI(upper_32_bits(memptr))); > >+ OUT_RING(ring, lower_32_bits(ttbr)); > >+ OUT_RING(ring, (0 << 16) | upper_32_bits(ttbr)); > why (0 << 16) is required here? Because that is the ASID we are using and we would want the debug TTBR0 to match the hardware as closely as possible. > >+ > >+ /* > >+ * And finally, trigger a uche flush to be sure there isn't anything > >+ * lingering in that part of the GPU > >+ */ > >+ > >+ OUT_PKT7(ring, CP_EVENT_WRITE, 1); > >+ OUT_RING(ring, 0x31); > This may be unnecessary, but no harm in keeping it. SMMU_TABLE_UPDATE is > supposed to do a UCHE flush. Correct but I think it is wise to try to match the downstream sequence as much as possible. Jordan > -Akhil > >+ > >+ a6xx_gpu->cur_ctx = ctx; > >+} > >+ > > static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) > > { > > unsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > >@@ -90,6 +140,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(a6xx_gpu, ring, submit->queue->ctx); > >+ > > get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, > > rbmemptr_stats(ring, index, cpcycles_start)); > >@@ -696,6 +748,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu) > > /* Always come up on rb 0 */ > > a6xx_gpu->cur_ring = gpu->rb[0]; > >+ a6xx_gpu->cur_ctx = NULL; > >+ > > /* Enable the SQE_to start the CP engine */ > > gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 1); > >@@ -1008,6 +1062,21 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) > > return (unsigned long)busy_time; > > } > >+static struct msm_gem_address_space * > >+a6xx_create_private_address_space(struct msm_gpu *gpu) > >+{ > >+ struct msm_gem_address_space *aspace = NULL; > >+ struct msm_mmu *mmu; > >+ > >+ mmu = msm_iommu_pagetable_create(gpu->aspace->mmu); > >+ > >+ if (!IS_ERR(mmu)) > >+ aspace = msm_gem_address_space_create(mmu, > >+ "gpu", 0x100000000ULL, 0x1ffffffffULL); > >+ > >+ return aspace; > >+} > >+ > > static const struct adreno_gpu_funcs funcs = { > > .base = { > > .get_param = adreno_get_param, > >@@ -1031,6 +1100,7 @@ static const struct adreno_gpu_funcs funcs = { > > .gpu_state_put = a6xx_gpu_state_put, > > #endif > > .create_address_space = adreno_iommu_create_address_space, > >+ .create_private_address_space = a6xx_create_private_address_space, > > }, > > .get_timestamp = a6xx_get_timestamp, > > }; > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >index 03ba60d5b07f..da22d7549d9b 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >@@ -19,6 +19,7 @@ struct a6xx_gpu { > > uint64_t sqe_iova; > > struct msm_ringbuffer *cur_ring; > >+ struct msm_file_private *cur_ctx; > > struct a6xx_gmu gmu; > > }; > >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 { > > > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.1 required=3.0 tests=BAYES_00,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 0CA92C433F2 for ; Mon, 17 Aug 2020 16:47:45 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id B5C8920716 for ; Mon, 17 Aug 2020 16:47:44 +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="YhG7Hldj" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org B5C8920716 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=pass smtp.mailfrom=iommu-bounces@lists.linux-foundation.org Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id 515B3203D1; Mon, 17 Aug 2020 16:47:44 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id S51WSnay-TEF; Mon, 17 Aug 2020 16:47:42 +0000 (UTC) Received: from lists.linuxfoundation.org (lf-lists.osuosl.org [140.211.9.56]) by silver.osuosl.org (Postfix) with ESMTP id 5A32A20378; Mon, 17 Aug 2020 16:47:42 +0000 (UTC) Received: from lf-lists.osuosl.org (localhost [127.0.0.1]) by lists.linuxfoundation.org (Postfix) with ESMTP id 4D2E9C07FF; Mon, 17 Aug 2020 16:47:42 +0000 (UTC) Received: from silver.osuosl.org (smtp3.osuosl.org [140.211.166.136]) by lists.linuxfoundation.org (Postfix) with ESMTP id C4674C0051 for ; Mon, 17 Aug 2020 16:47:40 +0000 (UTC) Received: from localhost (localhost [127.0.0.1]) by silver.osuosl.org (Postfix) with ESMTP id BEF261FD21 for ; Mon, 17 Aug 2020 16:47:40 +0000 (UTC) X-Virus-Scanned: amavisd-new at osuosl.org Received: from silver.osuosl.org ([127.0.0.1]) by localhost (.osuosl.org [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id NS80luiQY6f3 for ; Mon, 17 Aug 2020 16:47:39 +0000 (UTC) X-Greylist: from auto-whitelisted by SQLgrey-1.7.6 Received: from mail29.static.mailgun.info (mail29.static.mailgun.info [104.130.122.29]) by silver.osuosl.org (Postfix) with ESMTPS id BFC2620378 for ; Mon, 17 Aug 2020 16:47:34 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597682858; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=cJGHnK9LZROPEDWmJysaGgCbhijGlhi6d8SwrJT3rM8=; b=YhG7HldjT6fpKbhGFu0MV1IWlFtebmvTwyFd4NU9HnF88PuBZkl40cvQWZ2LSLTC8MygjVo/ eblQzvMA6IussJASKqOxG4RhjkT09gsUmIf2mWwnzjWNWn9FIbi+BV5svFJxnzTv1qbo1Z4M vWQ4Nii/RlVasY99AmnXPmmsGY4= X-Mailgun-Sending-Ip: 104.130.122.29 X-Mailgun-Sid: WyI3NDkwMCIsICJpb21tdUBsaXN0cy5saW51eC1mb3VuZGF0aW9uLm9yZyIsICJiZTllNGEiXQ== Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n05.prod.us-west-2.postgun.com with SMTP id 5f3ab49c668ab3fef69006e4 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 17 Aug 2020 16:47:24 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id C4266C433B2; Mon, 17 Aug 2020 16:47:23 +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 11C53C433C6; Mon, 17 Aug 2020 16:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11C53C433C6 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: Mon, 17 Aug 2020 10:47:17 -0600 From: Jordan Crouse To: Akhil P Oommen Subject: Re: [PATCH 16/19] drm/msm/a6xx: Add support for per-instance pagetables Message-ID: <20200817164716.GE3221@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Akhil P Oommen , Rob Clark , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jonathan Marek , Sharat Masetty , Eric Anholt , open list References: <20200810222657.1841322-1-jcrouse@codeaurora.org> <20200814024114.1177553-17-robdclark@gmail.com> <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) Cc: David Airlie , dri-devel@lists.freedesktop.org, Eric Anholt , Vivek Gautam , Will Deacon , Rob Clark , Jonathan Marek , Sibi Sankar , linux-arm-msm@vger.kernel.org, Sharat Masetty , Stephen Boyd , Sean Paul , linux-arm-kernel@lists.infradead.org, Robin Murphy , open list , iommu@lists.linux-foundation.org, Daniel Vetter , freedreno@lists.freedesktop.org X-BeenThere: iommu@lists.linux-foundation.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: Development issues for Linux IOMMU support List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: iommu-bounces@lists.linux-foundation.org Sender: "iommu" On Mon, Aug 17, 2020 at 09:10:46PM +0530, Akhil P Oommen wrote: > On 8/14/2020 8:11 AM, Rob Clark wrote: > >From: Jordan Crouse > > > >Add support for using per-instance pagetables if all the dependencies are > >available. > > > >Signed-off-by: Jordan Crouse > >Signed-off-by: Rob Clark > >--- > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 70 +++++++++++++++++++++++++++ > > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > > drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + > > 3 files changed, 72 insertions(+) > > > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >index 5eabb0109577..9653ac9b3cb8 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >@@ -81,6 +81,56 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, > > OUT_RING(ring, upper_32_bits(iova)); > > } > >+static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, > >+ struct msm_ringbuffer *ring, struct msm_file_private *ctx) > >+{ > >+ phys_addr_t ttbr; > >+ u32 asid; > >+ u64 memptr = rbmemptr(ring, ttbr0); > >+ > >+ if (ctx == a6xx_gpu->cur_ctx) > >+ return; > >+ > >+ if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid)) > >+ return; > >+ > >+ /* Execute the table update */ > >+ OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_0_TTBR0_LO(lower_32_bits(ttbr))); > >+ > >+ /* > >+ * For now ignore the asid since the smmu driver uses a TLBIASID to > >+ * flush the TLB when we use iommu_flush_tlb_all() and the smmu driver > >+ * isn't aware that the asid changed. Instead, keep the default asid > >+ * (0, same as the context bank) to make sure the TLB is properly > >+ * flushed. > >+ */ > >+ OUT_RING(ring, > >+ CP_SMMU_TABLE_UPDATE_1_TTBR0_HI(upper_32_bits(ttbr)) | > >+ CP_SMMU_TABLE_UPDATE_1_ASID(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_2_CONTEXTIDR(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_3_CONTEXTBANK(0)); > >+ > >+ /* > >+ * Write the new TTBR0 to the memstore. This is good for debugging. > >+ */ > >+ OUT_PKT7(ring, CP_MEM_WRITE, 4); > >+ OUT_RING(ring, CP_MEM_WRITE_0_ADDR_LO(lower_32_bits(memptr))); > >+ OUT_RING(ring, CP_MEM_WRITE_1_ADDR_HI(upper_32_bits(memptr))); > >+ OUT_RING(ring, lower_32_bits(ttbr)); > >+ OUT_RING(ring, (0 << 16) | upper_32_bits(ttbr)); > why (0 << 16) is required here? Because that is the ASID we are using and we would want the debug TTBR0 to match the hardware as closely as possible. > >+ > >+ /* > >+ * And finally, trigger a uche flush to be sure there isn't anything > >+ * lingering in that part of the GPU > >+ */ > >+ > >+ OUT_PKT7(ring, CP_EVENT_WRITE, 1); > >+ OUT_RING(ring, 0x31); > This may be unnecessary, but no harm in keeping it. SMMU_TABLE_UPDATE is > supposed to do a UCHE flush. Correct but I think it is wise to try to match the downstream sequence as much as possible. Jordan > -Akhil > >+ > >+ a6xx_gpu->cur_ctx = ctx; > >+} > >+ > > static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) > > { > > unsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > >@@ -90,6 +140,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(a6xx_gpu, ring, submit->queue->ctx); > >+ > > get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, > > rbmemptr_stats(ring, index, cpcycles_start)); > >@@ -696,6 +748,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu) > > /* Always come up on rb 0 */ > > a6xx_gpu->cur_ring = gpu->rb[0]; > >+ a6xx_gpu->cur_ctx = NULL; > >+ > > /* Enable the SQE_to start the CP engine */ > > gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 1); > >@@ -1008,6 +1062,21 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) > > return (unsigned long)busy_time; > > } > >+static struct msm_gem_address_space * > >+a6xx_create_private_address_space(struct msm_gpu *gpu) > >+{ > >+ struct msm_gem_address_space *aspace = NULL; > >+ struct msm_mmu *mmu; > >+ > >+ mmu = msm_iommu_pagetable_create(gpu->aspace->mmu); > >+ > >+ if (!IS_ERR(mmu)) > >+ aspace = msm_gem_address_space_create(mmu, > >+ "gpu", 0x100000000ULL, 0x1ffffffffULL); > >+ > >+ return aspace; > >+} > >+ > > static const struct adreno_gpu_funcs funcs = { > > .base = { > > .get_param = adreno_get_param, > >@@ -1031,6 +1100,7 @@ static const struct adreno_gpu_funcs funcs = { > > .gpu_state_put = a6xx_gpu_state_put, > > #endif > > .create_address_space = adreno_iommu_create_address_space, > >+ .create_private_address_space = a6xx_create_private_address_space, > > }, > > .get_timestamp = a6xx_get_timestamp, > > }; > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >index 03ba60d5b07f..da22d7549d9b 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >@@ -19,6 +19,7 @@ struct a6xx_gpu { > > uint64_t sqe_iova; > > struct msm_ringbuffer *cur_ring; > >+ struct msm_file_private *cur_ctx; > > struct a6xx_gmu gmu; > > }; > >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 { > > > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ iommu mailing list iommu@lists.linux-foundation.org https://lists.linuxfoundation.org/mailman/listinfo/iommu From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_PATCH, MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable 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 57B17C433E3 for ; Mon, 17 Aug 2020 16:49:18 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 296C120674 for ; Mon, 17 Aug 2020 16:49:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="c69j7Od9"; dkim=fail reason="signature verification failed" (1024-bit key) header.d=mg.codeaurora.org header.i=@mg.codeaurora.org header.b="bSEO9y8y" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 296C120674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:References:Message-ID: Subject:To:From:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=H3PFczQDQfFbZwmpCNdQ166xsAM2OSlLKJGDqrb1SGs=; b=c69j7Od93awkmkV9qALcb2VrU DHf2El44vx65gsN9lGeKZkCdLkhrQcvKsQ+UuRUDnmgOHpjh2lpEUgwJgitJOQA+uC4gFEomaOA1c yfG215bzQwTfv1uT5Tuw36D/6jEODL4c7BEHdCvsJlOqcEUrAFUu7yJ/KgsEaKsdT+b3SOmqEQlq/ HnJgGBS4kzFbrR9SzwL3FPpE+4TdwZCwqVtRT898riM3DGgswcqIlgkfLL20XUlS7/AGaGQsyFj9x HfgKuNL3fjzJTb/VB75O3s7+Dl1jwM7LvS7Q294rhl/gQnX7VNCVgoEGLkIg3KbIMCft9Qz+jnlcP 4lqm4E0ww==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7iIT-0002em-Dr; Mon, 17 Aug 2020 16:47:45 +0000 Received: from m43-7.mailgun.net ([69.72.43.7]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1k7iIN-0002e4-MZ for linux-arm-kernel@lists.infradead.org; Mon, 17 Aug 2020 16:47:42 +0000 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597682861; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=cJGHnK9LZROPEDWmJysaGgCbhijGlhi6d8SwrJT3rM8=; b=bSEO9y8ykbv79wo6E1tLsmLtGtJ788Ag2UVXS0X0bgkciO9BgfRhguJqrSyBxCbwmrl/MvPt bf15Gk2V3LZLbvAuM7VswqRfkGtrCyWccZNPJHICm42hYOjYeHBaSwp98r3XiOtvv5QaqMqB ZAbFlI7NyTVMVCHuMspZBi81kiY= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyJiYzAxZiIsICJsaW51eC1hcm0ta2VybmVsQGxpc3RzLmluZnJhZGVhZC5vcmciLCAiYmU5ZTRhIl0= Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 5f3ab49cc85a1092b0ee0d2c (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 17 Aug 2020 16:47:24 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BF0D4C433AF; Mon, 17 Aug 2020 16:47:23 +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 11C53C433C6; Mon, 17 Aug 2020 16:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11C53C433C6 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: Mon, 17 Aug 2020 10:47:17 -0600 From: Jordan Crouse To: Akhil P Oommen Subject: Re: [PATCH 16/19] drm/msm/a6xx: Add support for per-instance pagetables Message-ID: <20200817164716.GE3221@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Akhil P Oommen , Rob Clark , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jonathan Marek , Sharat Masetty , Eric Anholt , open list References: <20200810222657.1841322-1-jcrouse@codeaurora.org> <20200814024114.1177553-17-robdclark@gmail.com> <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20200817_124741_937153_5B76D71D X-CRM114-Status: GOOD ( 30.75 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, Bjorn Andersson , Eric Anholt , Vivek Gautam , Will Deacon , Rob Clark , Sai Prakash Ranjan , Jonathan Marek , Joerg Roedel , Rob Clark , Sibi Sankar , linux-arm-msm@vger.kernel.org, Sharat Masetty , Stephen Boyd , Sean Paul , linux-arm-kernel@lists.infradead.org, Robin Murphy , open list , iommu@lists.linux-foundation.org, Daniel Vetter , freedreno@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Mon, Aug 17, 2020 at 09:10:46PM +0530, Akhil P Oommen wrote: > On 8/14/2020 8:11 AM, Rob Clark wrote: > >From: Jordan Crouse > > > >Add support for using per-instance pagetables if all the dependencies are > >available. > > > >Signed-off-by: Jordan Crouse > >Signed-off-by: Rob Clark > >--- > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 70 +++++++++++++++++++++++++++ > > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > > drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + > > 3 files changed, 72 insertions(+) > > > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >index 5eabb0109577..9653ac9b3cb8 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >@@ -81,6 +81,56 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, > > OUT_RING(ring, upper_32_bits(iova)); > > } > >+static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, > >+ struct msm_ringbuffer *ring, struct msm_file_private *ctx) > >+{ > >+ phys_addr_t ttbr; > >+ u32 asid; > >+ u64 memptr = rbmemptr(ring, ttbr0); > >+ > >+ if (ctx == a6xx_gpu->cur_ctx) > >+ return; > >+ > >+ if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid)) > >+ return; > >+ > >+ /* Execute the table update */ > >+ OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_0_TTBR0_LO(lower_32_bits(ttbr))); > >+ > >+ /* > >+ * For now ignore the asid since the smmu driver uses a TLBIASID to > >+ * flush the TLB when we use iommu_flush_tlb_all() and the smmu driver > >+ * isn't aware that the asid changed. Instead, keep the default asid > >+ * (0, same as the context bank) to make sure the TLB is properly > >+ * flushed. > >+ */ > >+ OUT_RING(ring, > >+ CP_SMMU_TABLE_UPDATE_1_TTBR0_HI(upper_32_bits(ttbr)) | > >+ CP_SMMU_TABLE_UPDATE_1_ASID(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_2_CONTEXTIDR(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_3_CONTEXTBANK(0)); > >+ > >+ /* > >+ * Write the new TTBR0 to the memstore. This is good for debugging. > >+ */ > >+ OUT_PKT7(ring, CP_MEM_WRITE, 4); > >+ OUT_RING(ring, CP_MEM_WRITE_0_ADDR_LO(lower_32_bits(memptr))); > >+ OUT_RING(ring, CP_MEM_WRITE_1_ADDR_HI(upper_32_bits(memptr))); > >+ OUT_RING(ring, lower_32_bits(ttbr)); > >+ OUT_RING(ring, (0 << 16) | upper_32_bits(ttbr)); > why (0 << 16) is required here? Because that is the ASID we are using and we would want the debug TTBR0 to match the hardware as closely as possible. > >+ > >+ /* > >+ * And finally, trigger a uche flush to be sure there isn't anything > >+ * lingering in that part of the GPU > >+ */ > >+ > >+ OUT_PKT7(ring, CP_EVENT_WRITE, 1); > >+ OUT_RING(ring, 0x31); > This may be unnecessary, but no harm in keeping it. SMMU_TABLE_UPDATE is > supposed to do a UCHE flush. Correct but I think it is wise to try to match the downstream sequence as much as possible. Jordan > -Akhil > >+ > >+ a6xx_gpu->cur_ctx = ctx; > >+} > >+ > > static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) > > { > > unsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > >@@ -90,6 +140,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(a6xx_gpu, ring, submit->queue->ctx); > >+ > > get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, > > rbmemptr_stats(ring, index, cpcycles_start)); > >@@ -696,6 +748,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu) > > /* Always come up on rb 0 */ > > a6xx_gpu->cur_ring = gpu->rb[0]; > >+ a6xx_gpu->cur_ctx = NULL; > >+ > > /* Enable the SQE_to start the CP engine */ > > gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 1); > >@@ -1008,6 +1062,21 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) > > return (unsigned long)busy_time; > > } > >+static struct msm_gem_address_space * > >+a6xx_create_private_address_space(struct msm_gpu *gpu) > >+{ > >+ struct msm_gem_address_space *aspace = NULL; > >+ struct msm_mmu *mmu; > >+ > >+ mmu = msm_iommu_pagetable_create(gpu->aspace->mmu); > >+ > >+ if (!IS_ERR(mmu)) > >+ aspace = msm_gem_address_space_create(mmu, > >+ "gpu", 0x100000000ULL, 0x1ffffffffULL); > >+ > >+ return aspace; > >+} > >+ > > static const struct adreno_gpu_funcs funcs = { > > .base = { > > .get_param = adreno_get_param, > >@@ -1031,6 +1100,7 @@ static const struct adreno_gpu_funcs funcs = { > > .gpu_state_put = a6xx_gpu_state_put, > > #endif > > .create_address_space = adreno_iommu_create_address_space, > >+ .create_private_address_space = a6xx_create_private_address_space, > > }, > > .get_timestamp = a6xx_get_timestamp, > > }; > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >index 03ba60d5b07f..da22d7549d9b 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >@@ -19,6 +19,7 @@ struct a6xx_gpu { > > uint64_t sqe_iova; > > struct msm_ringbuffer *cur_ring; > >+ struct msm_file_private *cur_ctx; > > struct a6xx_gmu gmu; > > }; > >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 { > > > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel From mboxrd@z Thu Jan 1 00:00:00 1970 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=-11.1 required=3.0 tests=BAYES_00,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=unavailable 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 528B3C433ED for ; Mon, 17 Aug 2020 16:47:50 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 239C120674 for ; Mon, 17 Aug 2020 16:47:50 +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="PiGDwgpM" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 239C120674 Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 83D036E03F; Mon, 17 Aug 2020 16:47:49 +0000 (UTC) Received: from m43-7.mailgun.net (m43-7.mailgun.net [69.72.43.7]) by gabe.freedesktop.org (Postfix) with ESMTPS id 41B0E6E03F for ; Mon, 17 Aug 2020 16:47:45 +0000 (UTC) DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1597682867; h=In-Reply-To: Content-Type: MIME-Version: References: Message-ID: Subject: Cc: To: From: Date: Sender; bh=cJGHnK9LZROPEDWmJysaGgCbhijGlhi6d8SwrJT3rM8=; b=PiGDwgpMcEwc4YSLRxkupTED4Q2g5HNYHroIJo7wr/U+FlCXVn3WkySPENthM0GV3AjuFq3Y QQg1lbw/skbD+bVhW+5a8BDMpkjbRJM3j+Nq2HGwyPRCu11Px+6BagjyS/WxnRitqtH5ZRIN 6dr9zKA0TWBCG7/MHAGENVLE664= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyJkOTU5ZSIsICJkcmktZGV2ZWxAbGlzdHMuZnJlZWRlc2t0b3Aub3JnIiwgImJlOWU0YSJd 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-west-2.postgun.com with SMTP id 5f3ab49d668ab3fef6900842 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 17 Aug 2020 16:47:25 GMT Received: by smtp.codeaurora.org (Postfix, from userid 1001) id BBDD9C433C6; Mon, 17 Aug 2020 16:47:24 +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 11C53C433C6; Mon, 17 Aug 2020 16:47:19 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 11C53C433C6 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: Mon, 17 Aug 2020 10:47:17 -0600 From: Jordan Crouse To: Akhil P Oommen Subject: Re: [PATCH 16/19] drm/msm/a6xx: Add support for per-instance pagetables Message-ID: <20200817164716.GE3221@jcrouse1-lnx.qualcomm.com> Mail-Followup-To: Akhil P Oommen , Rob Clark , dri-devel@lists.freedesktop.org, iommu@lists.linux-foundation.org, linux-arm-msm@vger.kernel.org, Sai Prakash Ranjan , Will Deacon , freedreno@lists.freedesktop.org, Bjorn Andersson , Sibi Sankar , Vivek Gautam , Stephen Boyd , Robin Murphy , Joerg Roedel , linux-arm-kernel@lists.infradead.org, Rob Clark , Sean Paul , David Airlie , Daniel Vetter , Jonathan Marek , Sharat Masetty , Eric Anholt , open list References: <20200810222657.1841322-1-jcrouse@codeaurora.org> <20200814024114.1177553-17-robdclark@gmail.com> <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <7c130df7-c7f4-8694-c7be-ce3debe01662@codeaurora.org> User-Agent: Mutt/1.5.24 (2015-08-30) X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: David Airlie , dri-devel@lists.freedesktop.org, Bjorn Andersson , Vivek Gautam , Will Deacon , Rob Clark , Sai Prakash Ranjan , Jonathan Marek , Joerg Roedel , Sibi Sankar , linux-arm-msm@vger.kernel.org, Sharat Masetty , Stephen Boyd , Sean Paul , linux-arm-kernel@lists.infradead.org, Robin Murphy , open list , iommu@lists.linux-foundation.org, freedreno@lists.freedesktop.org Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Mon, Aug 17, 2020 at 09:10:46PM +0530, Akhil P Oommen wrote: > On 8/14/2020 8:11 AM, Rob Clark wrote: > >From: Jordan Crouse > > > >Add support for using per-instance pagetables if all the dependencies are > >available. > > > >Signed-off-by: Jordan Crouse > >Signed-off-by: Rob Clark > >--- > > drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 70 +++++++++++++++++++++++++++ > > drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + > > drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + > > 3 files changed, 72 insertions(+) > > > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >index 5eabb0109577..9653ac9b3cb8 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c > >@@ -81,6 +81,56 @@ static void get_stats_counter(struct msm_ringbuffer *ring, u32 counter, > > OUT_RING(ring, upper_32_bits(iova)); > > } > >+static void a6xx_set_pagetable(struct a6xx_gpu *a6xx_gpu, > >+ struct msm_ringbuffer *ring, struct msm_file_private *ctx) > >+{ > >+ phys_addr_t ttbr; > >+ u32 asid; > >+ u64 memptr = rbmemptr(ring, ttbr0); > >+ > >+ if (ctx == a6xx_gpu->cur_ctx) > >+ return; > >+ > >+ if (msm_iommu_pagetable_params(ctx->aspace->mmu, &ttbr, &asid)) > >+ return; > >+ > >+ /* Execute the table update */ > >+ OUT_PKT7(ring, CP_SMMU_TABLE_UPDATE, 4); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_0_TTBR0_LO(lower_32_bits(ttbr))); > >+ > >+ /* > >+ * For now ignore the asid since the smmu driver uses a TLBIASID to > >+ * flush the TLB when we use iommu_flush_tlb_all() and the smmu driver > >+ * isn't aware that the asid changed. Instead, keep the default asid > >+ * (0, same as the context bank) to make sure the TLB is properly > >+ * flushed. > >+ */ > >+ OUT_RING(ring, > >+ CP_SMMU_TABLE_UPDATE_1_TTBR0_HI(upper_32_bits(ttbr)) | > >+ CP_SMMU_TABLE_UPDATE_1_ASID(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_2_CONTEXTIDR(0)); > >+ OUT_RING(ring, CP_SMMU_TABLE_UPDATE_3_CONTEXTBANK(0)); > >+ > >+ /* > >+ * Write the new TTBR0 to the memstore. This is good for debugging. > >+ */ > >+ OUT_PKT7(ring, CP_MEM_WRITE, 4); > >+ OUT_RING(ring, CP_MEM_WRITE_0_ADDR_LO(lower_32_bits(memptr))); > >+ OUT_RING(ring, CP_MEM_WRITE_1_ADDR_HI(upper_32_bits(memptr))); > >+ OUT_RING(ring, lower_32_bits(ttbr)); > >+ OUT_RING(ring, (0 << 16) | upper_32_bits(ttbr)); > why (0 << 16) is required here? Because that is the ASID we are using and we would want the debug TTBR0 to match the hardware as closely as possible. > >+ > >+ /* > >+ * And finally, trigger a uche flush to be sure there isn't anything > >+ * lingering in that part of the GPU > >+ */ > >+ > >+ OUT_PKT7(ring, CP_EVENT_WRITE, 1); > >+ OUT_RING(ring, 0x31); > This may be unnecessary, but no harm in keeping it. SMMU_TABLE_UPDATE is > supposed to do a UCHE flush. Correct but I think it is wise to try to match the downstream sequence as much as possible. Jordan > -Akhil > >+ > >+ a6xx_gpu->cur_ctx = ctx; > >+} > >+ > > static void a6xx_submit(struct msm_gpu *gpu, struct msm_gem_submit *submit) > > { > > unsigned int index = submit->seqno % MSM_GPU_SUBMIT_STATS_COUNT; > >@@ -90,6 +140,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(a6xx_gpu, ring, submit->queue->ctx); > >+ > > get_stats_counter(ring, REG_A6XX_RBBM_PERFCTR_CP_0_LO, > > rbmemptr_stats(ring, index, cpcycles_start)); > >@@ -696,6 +748,8 @@ static int a6xx_hw_init(struct msm_gpu *gpu) > > /* Always come up on rb 0 */ > > a6xx_gpu->cur_ring = gpu->rb[0]; > >+ a6xx_gpu->cur_ctx = NULL; > >+ > > /* Enable the SQE_to start the CP engine */ > > gpu_write(gpu, REG_A6XX_CP_SQE_CNTL, 1); > >@@ -1008,6 +1062,21 @@ static unsigned long a6xx_gpu_busy(struct msm_gpu *gpu) > > return (unsigned long)busy_time; > > } > >+static struct msm_gem_address_space * > >+a6xx_create_private_address_space(struct msm_gpu *gpu) > >+{ > >+ struct msm_gem_address_space *aspace = NULL; > >+ struct msm_mmu *mmu; > >+ > >+ mmu = msm_iommu_pagetable_create(gpu->aspace->mmu); > >+ > >+ if (!IS_ERR(mmu)) > >+ aspace = msm_gem_address_space_create(mmu, > >+ "gpu", 0x100000000ULL, 0x1ffffffffULL); > >+ > >+ return aspace; > >+} > >+ > > static const struct adreno_gpu_funcs funcs = { > > .base = { > > .get_param = adreno_get_param, > >@@ -1031,6 +1100,7 @@ static const struct adreno_gpu_funcs funcs = { > > .gpu_state_put = a6xx_gpu_state_put, > > #endif > > .create_address_space = adreno_iommu_create_address_space, > >+ .create_private_address_space = a6xx_create_private_address_space, > > }, > > .get_timestamp = a6xx_get_timestamp, > > }; > >diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >index 03ba60d5b07f..da22d7549d9b 100644 > >--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.h > >@@ -19,6 +19,7 @@ struct a6xx_gpu { > > uint64_t sqe_iova; > > struct msm_ringbuffer *cur_ring; > >+ struct msm_file_private *cur_ctx; > > struct a6xx_gmu gmu; > > }; > >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 { > > > -- The Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, a Linux Foundation Collaborative Project _______________________________________________ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel