From patchwork Wed Feb 21 22:59:22 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10234323 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 7F89260385 for ; Wed, 21 Feb 2018 23:06:33 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 712BF2855E for ; Wed, 21 Feb 2018 23:06:33 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 65E40285D2; Wed, 21 Feb 2018 23:06:33 +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 D1C6D2855E for ; Wed, 21 Feb 2018 23:06:32 +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=FHj4rp9X9+WkCF8+ugIBSgugM7G5ojvwD4pjwbJuCi4=; b=JvHf7ldNHszf8E0XvvEOszRHxQ AvS5ZYMNE9FSwsXicIsAaQXjwg+G6FjBKLUPKHM+GPxiZudK4UPY1ddrce2f9frqLOhjfCVLek8k/ ow+mFWi2bVbXg9hFwJviJ1gx6F0ZS9JmGE8IsFLafx8Qinv8xUqg3nuCRdVeqY8TbcmDU7tcq3KXp uAsx00RFON92h00mob0P2u8edaW0Ohyo5EHCDdWLrddrjz/N4BhwqPd/tmzOrG1/bSnJcG4Tftd35 /XmQzFXAcZcqQc0P4Cyhbj6r6wuHyg/bRu/odbbkFjlIPNjndzrONnP4Ry+6q/iYGZeuGiWkmO4V8 L7IWgstg==; 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 1eodSs-0002ff-S3; Wed, 21 Feb 2018 23:06:18 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eodMy-0005bn-Gy for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2018 23:00:32 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 5C45B610D9; Wed, 21 Feb 2018 22:59:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519254008; bh=qkCh1FnbO3ylKyR3g4veb7iDiCtfbDtQ3QiTs7o4hxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=A2qYFX9njWCeTa0nnC5ZJjleGfRw4u4f03DfdFFlP51CRoZ+1Jrp9mTohuiY4S3O1 ELt0UJG4Zb8WC4DTCFM3I76PUIXBYv4LUMc/C6COmD72hbAPv/n3jOHm797J9CO+sT 1ii+YmmmJMQzJl5Cx0uvqewwxh7vRfiZuz04qOSI= 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 822B361136; Wed, 21 Feb 2018 22:59:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253988; bh=qkCh1FnbO3ylKyR3g4veb7iDiCtfbDtQ3QiTs7o4hxs=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=bF19qt6AlPZ3cE70Zp25vtZKk0eV152KqSb8d8ow3zY4dWWcRsHsQfPanG5S42TLd L7+vq017Xa1DVapzPBC/eEEBE8Hn1DmQuZoKmeSaaCYUgRCf3eurQaoVlvuXRsJhZH vmHLedpgANknEh6EcTYwo7ppjKn3qI0agOrzUqcU= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 822B361136 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/14] drm/msm: Add support for per-instance address spaces Date: Wed, 21 Feb 2018 15:59:22 -0700 Message-Id: <20180221225924.30737-13-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_150012_897850_F58EE060 X-CRM114-Status: GOOD ( 13.14 ) 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 | 36 +++++++++++++++++++++++++++++++----- 2 files changed, 34 insertions(+), 5 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.h b/drivers/gpu/drm/msm/msm_drv.h index 0499b1708f52..4fbc3188d776 100644 --- a/drivers/gpu/drm/msm/msm_drv.h +++ b/drivers/gpu/drm/msm/msm_drv.h @@ -178,6 +178,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 d34e331554f3..ef33026f593f 100644 --- a/drivers/gpu/drm/msm/msm_gem_vma.c +++ b/drivers/gpu/drm/msm/msm_gem_vma.c @@ -92,10 +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 = end - start; aspace = kzalloc(sizeof(*aspace), GFP_KERNEL); if (!aspace) @@ -103,12 +104,37 @@ 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), - (domain->geometry.aperture_end >> PAGE_SHIFT) - 1); + 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); +}