From patchwork Fri May 18 21:34:58 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10412387 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 3AC0D60230 for ; Fri, 18 May 2018 22:05:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2572228A81 for ; Fri, 18 May 2018 22:05:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1A2BA28AA8; Fri, 18 May 2018 22:05: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=-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 A19F428A81 for ; Fri, 18 May 2018 22:05:51 +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=S7ffHxAQv3/LkP3IzzL6lmFVMZmTKYeJtLcKU48eXjc=; b=Mlt1rZJKXYP6h+Xoj2QkZIa7JI B2lxhaj7UaMFb4s/Zp3XJBQEeuXMm5u7pfy52gwMgf4YmpDmGl7WMXKbZ6QVr1V19acZfnqwVpknN BTd/ouFsR6IkwbN6aZWD6SaP9pnfBAziUdqpTM4TxBKPi/1wgQbwT9H0IJ7ywqr8hTnU2GUW0jIV7 tUkROEAF6PUnxCvLwZ96KLA84BNmVLMnEDqOhNFfHF79mT7bmvQru2CEnr0flgHT5w7YQd3aWGvYk t/d692RacAmoASPEpkRAwZzUb89S7g2wbEQbgxC97vPrgRC/pVPNape+zLJKeKZusxgWDiGGENW24 O4m+8jnA==; 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 1fJnVP-00008d-0n; Fri, 18 May 2018 22:05:43 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJnV6-00005J-ED for linux-arm-kernel@bombadil.infradead.org; Fri, 18 May 2018 22:05:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=EiQvOPbSf1nH2g8YQ8TyI4ZcKdOgbnDn53IhXFR/FmU=; b=b499pxoAXkAswecJeaKDwx9ns BKB0sNYRXImyjPNZZpvRPPga/DvMstdhVQWnHVCepJNSvE4GolL2DqJfoDRqvOWWQLKoQ9sSLtYhX No1sr9bVTuvUhM3t9/FaVZE596iukiTn18frk+M5TFYp3CN+3K++1cYi6NMkNW9QNFsStkoJ6Y8zB cs2GY+8hIT5K+DmVTcfcojXSGNamoEujG2X4SjieubJvf/cqFS93UO6OE1xYapH8OyfQmMjJtYyqx TToSAFS0Uaa5qNSQQHwc+hwTYbCliLJxaCVxwljU+aCq3xw+88IBXYdeME7uLWtp1IyeljLN+kXoy 7r7doWcdw==; Received: from smtp.codeaurora.org ([198.145.29.96]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fJn2T-00067t-MW for linux-arm-kernel@lists.infradead.org; Fri, 18 May 2018 21:35:50 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id CFB216110A; Fri, 18 May 2018 21:35:19 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1526679333; bh=WXq8cv2xs6OyU0BIiicCIFxFlM8RS1iE+tFVdGRCTsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=E/SBpWJkC69aIK7O9CEEnHX6PEivuXIh5y3Z3WltkM0xoJVTVdCTHCV7ip+itT2yM V/WKAT8hnWExeDX9/XYZtcEYZSsPckQhS3Zk1SLVGQY256t3chbzIJNLpr5HGrAcdj bS16a8lx3vH/oCpYIGcN7MOMrNsHEY5xLSwRTFIo= 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 0283D61139; 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=1526679318; bh=WXq8cv2xs6OyU0BIiicCIFxFlM8RS1iE+tFVdGRCTsk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=JWGQiMi2su3juJfZJZtA0ZteuniZygYYYHO64oaDuVWlfittkzDD1llLu3BHD5Gjm yKWRqlhEH+TU9Hg7XukIUIceTzr6mZGccMwd7wbwYcf+LMPMzwxB1Qwsk+Xmn5Oq0Z 0p0TES+y+h7iI+BIOxO1+pLOFIWgxFijaYhyI7Dc= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0283D61139 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 14/16] drm/msm: Support per-instance address spaces Date: Fri, 18 May 2018 15:34:58 -0600 Message-Id: <20180518213500.31595-15-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_173549_881543_E3D41DCF X-CRM114-Status: GOOD ( 16.83 ) 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 Create a per-instance address spaces when a new DRM file instance is opened assuming the target supports it and the underlying infrastructure exists. If the operation is unsupported fall back quietly to use the global pagetable. Signed-off-by: Jordan Crouse --- drivers/gpu/drm/msm/msm_drv.c | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/msm/msm_drv.c b/drivers/gpu/drm/msm/msm_drv.c index 2b663435a3f7..31d1e7589892 100644 --- a/drivers/gpu/drm/msm/msm_drv.c +++ b/drivers/gpu/drm/msm/msm_drv.c @@ -22,6 +22,7 @@ #include "msm_fence.h" #include "msm_gpu.h" #include "msm_kms.h" +#include "msm_gem.h" /* @@ -511,7 +512,27 @@ static int context_init(struct drm_device *dev, struct drm_file *file) msm_submitqueue_init(dev, ctx); - ctx->aspace = priv->gpu->aspace; + /* FIXME: Do we want a dynamic name of some sort? */ + /* FIXME: We need a smarter way to set the range based on target */ + + ctx->aspace = msm_gem_address_space_create_instance( + priv->gpu->aspace->mmu, "gpu", 0x100000000, 0x1ffffffff); + + if (IS_ERR(ctx->aspace)) { + int ret = PTR_ERR(ctx->aspace); + + /* + * if per-instance pagetables are not supported, fall back to + * using the generic address space + */ + if (ret == -EOPNOTSUPP) + ctx->aspace = priv->gpu->aspace; + else { + kfree(ctx); + return ret; + } + } + file->driver_priv = ctx; return 0; @@ -527,8 +548,12 @@ static int msm_open(struct drm_device *dev, struct drm_file *file) return context_init(dev, file); } -static void context_close(struct msm_file_private *ctx) +static void context_close(struct msm_drm_private *priv, + struct msm_file_private *ctx) { + if (ctx && ctx->aspace != priv->gpu->aspace) + msm_gem_address_space_put(ctx->aspace); + msm_submitqueue_close(ctx); kfree(ctx); } @@ -543,7 +568,7 @@ static void msm_postclose(struct drm_device *dev, struct drm_file *file) priv->lastctx = NULL; mutex_unlock(&dev->struct_mutex); - context_close(ctx); + context_close(priv, ctx); } static irqreturn_t msm_irq(int irq, void *arg)