From patchwork Tue May 21 16:13:58 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10954281 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 D77D41708 for ; Tue, 21 May 2019 16:14:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C837C2897E for ; Tue, 21 May 2019 16:14:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BCB4C28ABC; Tue, 21 May 2019 16:14:52 +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,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher DHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 377072897E for ; Tue, 21 May 2019 16:14:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2F1D08941D; Tue, 21 May 2019 16:14:51 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from smtp.codeaurora.org (smtp.codeaurora.org [198.145.29.96]) by gabe.freedesktop.org (Postfix) with ESMTPS id 30BD18941D; Tue, 21 May 2019 16:14:50 +0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1000) id C84F261A72; Tue, 21 May 2019 16:14:27 +0000 (UTC) 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 2E48561A5C; Tue, 21 May 2019 16:14:24 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 2E48561A5C From: Jordan Crouse To: freedreno@lists.freedesktop.org Subject: [PATCH v2 10/15] drm/msm: Add a helper function for a per-instance address space Date: Tue, 21 May 2019 10:13:58 -0600 Message-Id: <1558455243-32746-11-git-send-email-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1558455243-32746-1-git-send-email-jcrouse@codeaurora.org> References: <1558455243-32746-1-git-send-email-jcrouse@codeaurora.org> X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1558455290; bh=9aXhSj9Phw8JHRWY+YFRT00OkAJ1xzvQFBspXjSWjck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=FFf3W9q+PijduigovDnLfhX/WdknhM67/QkUEefNq3J+brJklduC9hzP6rMQjLY8M KgvOYHHdmGVFOM8QUFKQ7Cr2ibAlfHvaty5Q4+tUndvXVV2aasnKlEkO5CgFTFgQkb bK3r9z1L2C5H3BkSx8B8smn6MH8ofE6LfMS222aE= X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1558455265; bh=9aXhSj9Phw8JHRWY+YFRT00OkAJ1xzvQFBspXjSWjck=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SVnDGffrzPDaouD/31loIWc92bGnmmbA4g62WezNnVT6esjiwklpM6/VbBxRNAKl6 tPqzNybOhQem/ehtZUUG2Uv+o8bhn1mV+Jx/rFBeULrOuilrm1a0EwOsC1qYOmdobY gws1wRzfdfkVrxlfx3lemXB0NGJ/V/B53TTsen7k= X-Mailman-Original-Authentication-Results: pdx-caf-mail.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org X-Mailman-Original-Authentication-Results: pdx-caf-mail.web.codeaurora.org; spf=none smtp.mailfrom=jcrouse@codeaurora.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jean-philippe.brucker@arm.com, linux-arm-msm@vger.kernel.org, dianders@chromium.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org, David Airlie , hoegsberg@google.com, Sean Paul MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP Add a helper function to create a GEM address space attached to an iommu auxiliary domain for a per-instance pagetable. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_drv.h | 4 +++ drivers/gpu/drm/msm/msm_gem_vma.c | 53 +++++++++++++++++++++++---------------- 2 files changed, 36 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index d9aa7ba..1d4b45a 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -262,6 +262,10 @@ struct msm_gem_address_space * msm_gem_address_space_create_a2xx(struct device *dev, struct msm_gpu *gpu, const char *name, uint64_t va_start, uint64_t va_end); +struct msm_gem_address_space * +msm_gem_address_space_create_instance(struct device *dev, const char *name, + u64 va_start, u64 va_end); + int msm_register_mmu(struct drm_device *dev, struct msm_mmu *mmu); void msm_unregister_mmu(struct drm_device *dev, struct msm_mmu *mmu); diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c index fcf7a83..0ee11b4 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c @@ -136,14 +136,12 @@ int msm_gem_init_vma(struct msm_gem_address_space *aspace, return 0; } - -struct msm_gem_address_space * -msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, - const char *name) +static struct msm_gem_address_space * +msm_gem_address_space_new(struct msm_mmu *mmu, const char *name, + u64 va_start, u64 va_end) { struct msm_gem_address_space *aspace; - u64 size = domain->geometry.aperture_end - - domain->geometry.aperture_start; + u64 size = va_end - va_start; aspace = kzalloc(sizeof(*aspace), GFP_KERNEL); if (!aspace) @@ -151,10 +149,9 @@ msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, spin_lock_init(&aspace->lock); aspace->name = name; - aspace->mmu = msm_iommu_new(dev, domain); + aspace->mmu = mmu; - drm_mm_init(&aspace->mm, (domain->geometry.aperture_start >> PAGE_SHIFT), - size >> PAGE_SHIFT); + drm_mm_init(&aspace->mm, (va_start >> PAGE_SHIFT), size >> PAGE_SHIFT); kref_init(&aspace->kref); @@ -162,24 +159,38 @@ msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, } struct msm_gem_address_space * +msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, + const char *name) +{ + struct msm_mmu *mmu = msm_iommu_new(dev, domain); + + if (IS_ERR(mmu)) + return ERR_CAST(mmu); + + return msm_gem_address_space_new(mmu, name, + domain->geometry.aperture_start, domain->geometry.aperture_end); +} + +struct msm_gem_address_space * msm_gem_address_space_create_a2xx(struct device *dev, struct msm_gpu *gpu, const char *name, uint64_t va_start, uint64_t va_end) { - struct msm_gem_address_space *aspace; - u64 size = va_end - va_start; + struct msm_mmu *mmu = msm_gpummu_new(dev, gpu); - aspace = kzalloc(sizeof(*aspace), GFP_KERNEL); - if (!aspace) - return ERR_PTR(-ENOMEM); + if (IS_ERR(mmu)) + return ERR_CAST(mmu); - spin_lock_init(&aspace->lock); - aspace->name = name; - aspace->mmu = msm_gpummu_new(dev, gpu); + return msm_gem_address_space_new(mmu, name, va_start, va_end); +} - drm_mm_init(&aspace->mm, (va_start >> PAGE_SHIFT), - size >> PAGE_SHIFT); +struct msm_gem_address_space * +msm_gem_address_space_create_instance(struct device *dev, const char *name, + u64 va_start, u64 va_end) +{ + struct msm_mmu *mmu = msm_iommu_new_instance(dev); - kref_init(&aspace->kref); + if (IS_ERR(mmu)) + return ERR_CAST(mmu); - return aspace; + return msm_gem_address_space_new(mmu, name, va_start, va_end); }