From patchwork Wed Feb 21 22:59:19 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10234335 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 7D81760385 for ; Wed, 21 Feb 2018 23:10:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6D8C527031 for ; Wed, 21 Feb 2018 23:10:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 61F802855C; Wed, 21 Feb 2018 23:10:30 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=unavailable version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id E398527031 for ; Wed, 21 Feb 2018 23:10:29 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=VDt/oVGJ6Osebyop2wkfLnv+ENKtfmHmuTl82zpj1kU=; b=SNntm3WCkHuyrTU66zcShTF4k3 Xi6YDx99L6AnZu4Wv9JtZm2Q+0FSmRvV1k0oXSrjk3Doo1ebUTwQfxWuCvkWK7xTbDnG+7RNGHGOv QigsxOVfV8PJ/LXJ+XLV9OX+2AfnN9a9HdJv+6G8oWWjwEQPgF9SCfIa06CoaetWxkHVk94vRAOLd jDOqNBs+IPLOVdhqyb+LinDACXFDOCBotWgtyWz8t+7MB+4mllqqhc1zOJYBoiSw2di7PI4IkBrj9 8pXITtmf78RetHOkMg0JKyB+7C0LtZhG6OqeiChQv7gIrIpi184tstmFmKNqgCnH/THOhlvE4CKg7 0qfrpIgg==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.89 #1 (Red Hat Linux)) id 1eodWr-0005QB-10; Wed, 21 Feb 2018 23:10:25 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eodMm-0005Nq-JQ for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2018 23:00:30 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id B0F836084A; Wed, 21 Feb 2018 22:59:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253993; bh=1rsiVD4kkx+5qLw13ImwO4z8aYN1mDylg83cbqcJeEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=PaPKfb/ccy/0hQLRv4zL1x8MJqi/v7ogEjzUhNnozOcNSQzq0+MfEMmCLwVanpXky 2DN7NC786MX+s9PF0k2SP0r3XpcZOFO2wE03RxC1Do4iE14aug4mqSgqH120Rsv03K pTyS51m5wVaF/7bnQoAZlg45Lew3rtR03d0C1Pak= Received: from jcrouse-lnx.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: jcrouse@smtp.codeaurora.org) by smtp.codeaurora.org (Postfix) with ESMTPSA id 3E9FE60FB1; Wed, 21 Feb 2018 22:59:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253985; bh=1rsiVD4kkx+5qLw13ImwO4z8aYN1mDylg83cbqcJeEw=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rk0X3FA/IA7nTk05MWeinr+B/nNYu4ScwDwx4GGajiEOMgo1fmfUTw6LuJXOe3yfu +q/piO1UrwHCTW8Z5kHklHj1rS1XMqqe0xM0+MdXoqUjIJTIWOcjcTlls/ne2lRqck Yo4NHe9RMJhE/3mqAjlJJmX/FOihqfEqyiJkvBcA= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 3E9FE60FB1 Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH 09/14] drm/msm/gpu: Support using TTBR1 for kernel buffer objects Date: Wed, 21 Feb 2018 15:59:19 -0700 Message-Id: <20180221225924.30737-10-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.16.1 In-Reply-To: <20180221225924.30737-1-jcrouse@codeaurora.org> References: <20180221225924.30737-1-jcrouse@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180221_150001_455363_6A4698C1 X-CRM114-Status: GOOD ( 17.45 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe.brucker@arm.com, linux-arm-msm@vger.kernel.org, dri-devel@lists.freedesktop.org, tfiga@chromium.org, iommu@lists.linux-foundation.org, vivek.gautam@codeaurora.org, linux-arm-kernel@lists.infradead.org MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP arm-smmu based targets can support split pagetables (TTBR0/TTBR1). This is most useful for implementing per-instance pagetables so that the "user" pagetable can be swapped out while the "kernel" or "global" pagetable remains entact. if the target specifies a global virtual memory range then try to enable TTBR1 (the "global" pagetable) on the domain and and if successful use the global virtual memory range for allocations on the default GPU address space - this ensures that the global allocations make it into the right space. Per-instance pagetables still need additional support to be enabled but even if they aren't set up it isn't harmful to just use TTBR1 for all virtual memory regions and leave the other pagetable unused. If TTBR1 support isn't enabled then fall back to the "legacy" virtual address space both kernel and user. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_gpu.c | 20 ++++++++++++++++++-- drivers/gpu/drm/msm/msm_gpu.h | 4 ++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_gpu.c b/drivers/gpu/drm/msm/msm_gpu.c index 086fb347b554..94332faa316f 100644 --- a/drivers/gpu/drm/msm/msm_gpu.c +++ b/drivers/gpu/drm/msm/msm_gpu.c @@ -701,7 +701,8 @@ static int get_clocks(struct platform_device *pdev, struct msm_gpu *gpu) 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) + u64 va_start, u64 va_end, + u64 va_global_start, u64 va_global_end) { struct iommu_domain *iommu; struct msm_gem_address_space *aspace; @@ -719,6 +720,20 @@ msm_gpu_create_address_space(struct msm_gpu *gpu, struct platform_device *pdev, iommu->geometry.aperture_start = va_start; iommu->geometry.aperture_end = va_end; + /* If a va_global range was specified then try to set up TTBR1 */ + if (va_global_start && va_global_end) { + int val = 1; + + /* Try to enable TTBR1 on the domain */ + ret = iommu_domain_set_attr(iommu, DOMAIN_ATTR_ENABLE_TTBR1, + &val); + + if (!WARN(ret, "Unable to enable TTBR1 for the IOMMU\n")) { + iommu->geometry.aperture_start = va_global_start; + iommu->geometry.aperture_end = va_global_end; + } + } + dev_info(gpu->dev->dev, "%s: using IOMMU\n", gpu->name); aspace = msm_gem_address_space_create(&pdev->dev, iommu, "gpu"); @@ -811,7 +826,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); + config->va_start, config->va_end, config->va_start_global, + config->va_end_global); if (gpu->aspace == NULL) dev_info(drm->dev, "%s: no IOMMU, fallback to VRAM carveout!\n", name); diff --git a/drivers/gpu/drm/msm/msm_gpu.h b/drivers/gpu/drm/msm/msm_gpu.h index fccfccd303af..698eca2c1431 100644 --- a/drivers/gpu/drm/msm/msm_gpu.h +++ b/drivers/gpu/drm/msm/msm_gpu.h @@ -31,8 +31,8 @@ struct msm_gpu_perfcntr; struct msm_gpu_config { const char *ioname; const char *irqname; - uint64_t va_start; - uint64_t va_end; + uint64_t va_start, va_end; + uint64_t va_start_global, va_end_global; unsigned int nr_rings; };