From patchwork Fri May 18 21:34:56 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10412391 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 EFAA76031B for ; Fri, 18 May 2018 22:07:10 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D7E3428A81 for ; Fri, 18 May 2018 22:07:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C9F3F28AA8; Fri, 18 May 2018 22:07:10 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI 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 3083628A81 for ; Fri, 18 May 2018 22:07:10 +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=jyb2VdF+HbezAw2ia5ypmL7fRuBI/238Ic4bc5sr8G4=; b=B2ODutKJDgEeWrAwv1MOmy4EHn wOI4ewq7zo4DpQQenRWtl6YB4Bd8cJYbFBh7ODYSetNfHjDyj8pd6E5dGK+18vKW/MiCvcdLhZT2m 2gvXnpy5ahweMgxECWafyKIwNW/SEE6XUggUktwenw9Zw3UyVrzVWKpU0dkyhf5haMipTLCB0LmPS LbZB4bVDABadoax4Dh2qEWVGcWjJq2c0Z4FoEFXRAVSVPsXEh6FHOZzR+vyrWpozIsfRY7smeBTqb LLNU7TadYoKMOw3XRhL9QPVhsjOhPup+yxpo5OOFZc95zGmkpStMpbivtcdOb5OMi1QWN2zW+PnPT CmgA34Ig==; 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 1fJnWk-0001ST-T6; Fri, 18 May 2018 22:07:06 +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 1fJn2B-0000A8-5X for linux-arm-kernel@lists.infradead.org; Fri, 18 May 2018 21:35:45 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 7C81C60F94; Fri, 18 May 2018 21:35:17 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526679325; bh=+P66CQqNuL/KCWrdRPCKmobD0JJ9mKRL7RODc8mOKI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=oZzJxb9qkBQASs1C4SaBGx7j8VQ+USEjkDnbFSgq8tfIuAWnPmOeI9j4lNQ9VgZI1 +KU8YutWZXbXpT4oovzmffCmUNPZNYRmpvosoJiedRpDfl9pgc31m+fDvBICvC/cH8 pKz7GuOGtyq8ncwjP9A50odG+T3Qx43latDcB1W8= 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 E7A9A61139; Fri, 18 May 2018 21:35:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526679316; bh=+P66CQqNuL/KCWrdRPCKmobD0JJ9mKRL7RODc8mOKI4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=CueEVJP3mJvF3KS220928G6Xy0NKKPs4kGVr6TPemRKjHPnQMVgx3hJywTeNDcX0c VQjKo4cL0C87sCeoAg5IRymuJDjFNnNC/+x7ijuw2XjwovPf1VIdJMqihjCxuqZj3Q gOAfIlW2fo+5fB1xsd4F+Jqp5NpGM4Oqn6uMC7pg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org E7A9A61139 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 12/16] drm/msm: Add support for per-instance address spaces Date: Fri, 18 May 2018 15:34:56 -0600 Message-Id: <20180518213500.31595-13-jcrouse@codeaurora.org> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180518213500.31595-1-jcrouse@codeaurora.org> References: <20180518213500.31595-1-jcrouse@codeaurora.org> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180518_143531_373829_C895F130 X-CRM114-Status: GOOD ( 12.63 ) 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 Add a function to allocate a new pasid from a existing MMU domain and create a per-instance address space. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_drv.h | 3 +++ drivers/gpu/drm/msm/msm_gem_vma.c | 37 +++++++++++++++++++++++++------ 2 files changed, 33 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 897b08135927..d92b009dfef4 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -177,6 +177,9 @@ void msm_gem_address_space_put(struct msm_gem_address_space *aspace); struct msm_gem_address_space * msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, const char *name); +struct msm_gem_address_space * +msm_gem_address_space_create_instance(struct msm_mmu *parent, const char *name, + u64 start, u64 end); void msm_gem_submit_free(struct msm_gem_submit *submit); int msm_ioctl_gem_submit(struct drm_device *dev, void *data, diff --git a/drivers/gpu/drm/msm/msm_gem_vma.c b/drivers/gpu/drm/msm/msm_gem_vma.c index ffbec224551b..d75b56119752 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c @@ -92,12 +92,11 @@ msm_gem_map_vma(struct msm_gem_address_space *aspace, } struct msm_gem_address_space * -msm_gem_address_space_create(struct device *dev, struct iommu_domain *domain, - const char *name) +msm_gem_address_space_new(struct msm_mmu *mmu, const char *name, + u64 start, u64 end) { struct msm_gem_address_space *aspace; - u64 size = domain->geometry.aperture_end - - domain->geometry.aperture_start; + u64 size = end - start; aspace = kzalloc(sizeof(*aspace), GFP_KERNEL); if (!aspace) @@ -105,12 +104,36 @@ 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, (start >> PAGE_SHIFT), size >> PAGE_SHIFT); kref_init(&aspace->kref); return aspace; } + +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_instance(struct msm_mmu *parent, const char *name, + u64 start, u64 end) +{ + struct msm_mmu *instance = msm_iommu_pasid_new(parent); + if (IS_ERR(instance)) + return ERR_CAST(instance); + + return msm_gem_address_space_new(instance, name, start, end); +}