From patchwork Wed May 29 20:54:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10967687 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DB4FD912 for ; Wed, 29 May 2019 20:55:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CC316219AC for ; Wed, 29 May 2019 20:55:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C07F4288F1; Wed, 29 May 2019 20:55:22 +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=-5.2 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED 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 4E785289AA for ; Wed, 29 May 2019 20:55:22 +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: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:In-Reply-To: References:List-Owner; bh=ZooXboQ7yblX0zNX5cgMysBPiNrxidXp/p2MR68nPcE=; b=Ddr noeqUs9bFGgriTSmNT6vCkuuyZBRHC+DpZ+MpwkK2yxP4X0x2jGho+96MarvK9pRH1rSegeaMZO// Pi/pk8e4QpWIt1u8REsXmhSNPeetZje0DXCD3kq8lb8zKBwjFd6tVo0W5l0X/ILy/+B6vEo6+bpBN B+uz/kIzEgDhrStk6tVj3Te5GDnNDDX5CtE9CaYQ0qikd9uMk6y39QKAD6VvCQVqWOpbpVf9ysLej 1qNswIXnBl8MXpmyzKvl3nCeYk95L6QLeBE1/zbDWLMEmPwKFwVNvJWT2DZ/4eyQYZVYxBJz7SqbQ ZB46FmsqnMgbP23qcyAc7Rl/vXAKnfw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1hW5bR-0007Ll-2f; Wed, 29 May 2019 20:55:17 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1hW5bI-0006vf-Pz for linux-arm-kernel@lists.infradead.org; Wed, 29 May 2019 20:55:10 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 45E0360A4E; Wed, 29 May 2019 20:55:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1559163306; bh=a10cqXD3K1rvMJw3L43nt+iaIhgdpjlzVZD15xJBhaA=; h=From:To:Cc:Subject:Date:From; b=Vp0ytwik6JEWAQFO/yG5VFu3Z6MkCfPENawBVa/y59bquj5SpgduvRjs2xXk0Pdrg xAShGzTeW+ZhTTQJhO/ke4tluOhH90QajK5uXiU5Odl6uJsGHhWHgplxm1hmnN+M9s WYMKWEjF49mjefdBuETfWF9op/mMPhoYsCjvOGFs= Received: from jcrouse1-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 00F036030E; Wed, 29 May 2019 20:54:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1559163304; bh=a10cqXD3K1rvMJw3L43nt+iaIhgdpjlzVZD15xJBhaA=; h=From:To:Cc:Subject:Date:From; b=cSnhvA7BCJGATHq0sbtLanP6Lv34+whQEyH5M/1UWMBpLxrtk5CUaKV7c2SE1lSQd 3/RMJ4i5inUbtIPaeQtlZgTz/sjprVqxt79t2tdd0hrHLlltv1Ng8V263HFJzEQIKv 05ODYE8MeXimWoQrEpyB//MZ6ROo8rVnPKiBQOC0= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 00F036030E 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 v3 00/16] drm/msm: Per-instance pagetable support Date: Wed, 29 May 2019 14:54:36 -0600 Message-Id: <1559163292-4792-1-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.7.4 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20190529_135509_024793_8710B1FF X-CRM114-Status: GOOD ( 18.46 ) 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: David Airlie , Will Deacon , dri-devel@lists.freedesktop.org, dianders@chromium.org, Wen Yang , Rob Herring , Jonathan Marek , jean-philippe.brucker@arm.com, Joerg Roedel , iommu@lists.linux-foundation.org, Mamta Shukla , Kees Cook , linux-arm-msm@vger.kernel.org, Sharat Masetty , Zhen Lei , Daniel Vetter , Sean Paul , linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Rob Clark , hoegsberg@google.com, Thomas Zimmermann , Robin Murphy 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 This is v3 of the per-instance pagetable support. Biggest change in this revision is moving nearly all of the split pagetable support into io-pgtable-arm and setting up specific ops to handle the unique behavior of the split pagetables. Now that I've spent some time with it, I like how it turned out. For background: Per-instance pagetables allow the target GPU driver to create and manage an individual pagetable for each file descriptor instance and switch between them asynchronously using the GPU to reprogram the pagetable registers on the fly. Most of the heavy lifting for this is done in the arm-smmu-v2 driver by taking advantage of the newly added multiple domain API. The first patch in the series allows opted-in clients to direct map a device with iommu_request_dm_for_dev(). This bypasses the DMA domain creation in the IOMMU core which serves several purposes for the GPU by skipping the otherwise unused DMA domain and also keeping context bank 0 unused on the hardware (for better or worse, the GPU is hardcoded to only use context bank 0 for switching). The next several patches enable split pagetable support. This is used to map global buffers for the GPU so we can safely switch the TTBR0 pagetable for the instance. The last two arm-smmu-v2 patches enable auxillary domain support. Again the SMMU client can opt-in to allow auxiliary domains, and if enabled will create a pagetable but not otherwise touch the hardware. The client can get the address of the pagetable through an attribute to perform its own switching. After the arm-smmu-v2 patches are more than several msm/gpu patches to allow for target specific address spaces, enable 64 bit virtual addressing and implement the mechanics of pagetable switching. For the purposes of merging all the patches between drm/msm/adreno: Enable 64 bit mode by default on a5xx and a6xx targets and drm/msm: Add support to create target specific address spaces can be merged to the msm-next tree without dependencies on the IOMMU changes. Only the last three patches will require coordination between the two areas. Jordan Crouse (16): iommu/arm-smmu: Allow client devices to select direct mapping iommu: Add DOMAIN_ATTR_SPLIT_TABLES iommu/io-pgtable-arm: Add support for AARCH64 split pagetables iommu/arm-smmu: Add support for DOMAIN_ATTR_SPLIT_TABLES iommu: Add DOMAIN_ATTR_PTBASE iommu/arm-smmu: Add auxiliary domain support for arm-smmuv2 drm/msm/adreno: Enable 64 bit mode by default on a5xx and a6xx targets drm/msm: Print all 64 bits of the faulting IOMMU address drm/msm: Pass the MMU domain index in struct msm_file_private drm/msm/gpu: Move address space setup to the GPU targets drm/msm: Add support for IOMMU auxiliary domains drm/msm: Add a helper function for a per-instance address space drm/msm: Add support to create target specific address spaces drm/msm/gpu: Add ttbr0 to the memptrs drm/msm/a6xx: Support per-instance pagetables drm/msm/a5xx: Support per-instance pagetables drivers/gpu/drm/msm/adreno/a2xx_gpu.c | 37 +++-- drivers/gpu/drm/msm/adreno/a3xx_gpu.c | 50 ++++-- drivers/gpu/drm/msm/adreno/a4xx_gpu.c | 51 ++++-- drivers/gpu/drm/msm/adreno/a5xx_gpu.c | 163 ++++++++++++++++++- drivers/gpu/drm/msm/adreno/a5xx_gpu.h | 19 +++ drivers/gpu/drm/msm/adreno/a5xx_preempt.c | 70 ++++++-- drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 166 ++++++++++++++++++- drivers/gpu/drm/msm/adreno/a6xx_gpu.h | 1 + drivers/gpu/drm/msm/adreno/adreno_gpu.c | 7 - drivers/gpu/drm/msm/msm_drv.c | 25 ++- drivers/gpu/drm/msm/msm_drv.h | 5 + drivers/gpu/drm/msm/msm_gem.h | 2 + drivers/gpu/drm/msm/msm_gem_submit.c | 13 +- drivers/gpu/drm/msm/msm_gem_vma.c | 53 +++--- drivers/gpu/drm/msm/msm_gpu.c | 59 +------ drivers/gpu/drm/msm/msm_gpu.h | 3 + drivers/gpu/drm/msm/msm_iommu.c | 99 +++++++++++- drivers/gpu/drm/msm/msm_mmu.h | 4 + drivers/gpu/drm/msm/msm_ringbuffer.h | 1 + drivers/iommu/arm-smmu.c | 176 ++++++++++++++++++-- drivers/iommu/io-pgtable-arm.c | 261 +++++++++++++++++++++++++++--- drivers/iommu/io-pgtable.c | 1 + include/linux/io-pgtable.h | 2 + include/linux/iommu.h | 2 + 24 files changed, 1082 insertions(+), 188 deletions(-)