From patchwork Wed Feb 21 22:59:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Crouse X-Patchwork-Id: 10234329 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 7849260385 for ; Wed, 21 Feb 2018 23:07:54 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6A929281D2 for ; Wed, 21 Feb 2018 23:07:54 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5F06128334; Wed, 21 Feb 2018 23:07:54 +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 DA2E6281D2 for ; Wed, 21 Feb 2018 23:07:53 +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=FAI1fcpOSozBZy9y4b3RDOqonqK4gcyKtkZ24Zv2vEI=; b=c5Le6DRm71/sdtGGt5h6mBqCKW YuCC6JRmZUas8cev77HS4lfzoO4fPWXaN9axTw3vwDxTsIM5LZG67Y0Fv/z21LlpFu7dGuBzVpTrq nMRMgyxO7GLN/UE9uBTMtRmp4356zBUNYT0XhO/VW0EJTBhkckUCo1eSAgeKZREjroA3b5mKYM/Zb G3ADUQRZ4vCIQNcv79C5XaMX4qoUhT/fePNVhmPLjnc2KCO/WNwxyA1hwlvfb+1T+BfClVzwnkK3a Jji/S5oBH8wILAfHFlRdp85qcPRJtDivRi3LW3ASfz7u/mjBpw+YvDrgM9CAAkZR545TRjiVPpwD6 RYK8Ep2Q==; 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 1eodUE-0003Ll-70; Wed, 21 Feb 2018 23:07:42 +0000 Received: from smtp.codeaurora.org ([198.145.29.96]) by bombadil.infradead.org with esmtps (Exim 4.89 #1 (Red Hat Linux)) id 1eodNR-0006bj-5w for linux-arm-kernel@lists.infradead.org; Wed, 21 Feb 2018 23:01:02 +0000 Received: by smtp.codeaurora.org (Postfix, from userid 1000) id 997BD60FF0; Wed, 21 Feb 2018 22:59:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519254029; bh=LPtv8k7ynBH7/nudyvjlRgVvFjPo8JCYzlTwjd0Ngq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=MmiYRdrpLESfOd73r4uSZ93aDaM771gvn5iR6eEflfCYsnVFSEBIpuJWGN9KeufzJ 0Z+69bWnUwjA03U80Mk2T1PLXALjvCoq3IzUaQGTIDuWobuRwa7LDnMKuZymn5ANO9 AhabT9vWanSAsb04ZmKvYtzc+dVAd8PwjM8IL6+I= 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 9F07F60BEB; Wed, 21 Feb 2018 22:59:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=codeaurora.org; s=default; t=1519253989; bh=LPtv8k7ynBH7/nudyvjlRgVvFjPo8JCYzlTwjd0Ngq4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=onERaNNOh6vXeJuRJxFK2R6GwFf7OK7s97lwxjd15d6nDBePCYEvyqXD6Ah6N/7nP rLZ2SlYMxdCYFbvn8j+JDbwYP2VqEEU8QgpcSQECXpsnPBRUFJwsUqXLYNhgMpP5+U +QOqwLBpUPV9jOtkKbATOKxYRCb3nqrNgTw1V5Mg= DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 9F07F60BEB 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 13/14] drm/msm: Support per-instance address spaces Date: Wed, 21 Feb 2018 15:59:23 -0700 Message-Id: <20180221225924.30737-14-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_150041_424795_690B6189 X-CRM114-Status: GOOD ( 15.75 ) 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 74dd09db93d7..24d23293b090 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)