From patchwork Wed Mar 29 00:27:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Christopher James Halse Rogers X-Patchwork-Id: 9650743 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 16DA960349 for ; Wed, 29 Mar 2017 00:37:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 09BC72844E for ; Wed, 29 Mar 2017 00:37:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id F157928456; Wed, 29 Mar 2017 00:37:36 +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=-4.2 required=2.0 tests=BAYES_00, 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 7ADDE2844E for ; Wed, 29 Mar 2017 00:37:36 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id ECA5A6E694; Wed, 29 Mar 2017 00:37:25 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail.cooperteam.net (mail.cooperteam.net [150.101.105.211]) by gabe.freedesktop.org (Postfix) with ESMTPS id 4B5406E6AA; Wed, 29 Mar 2017 00:37:21 +0000 (UTC) Received: from localhost.localdomain (unknown [192.168.1.1]) (using TLSv1.2 with cipher ECDHE-ECDSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: chris) by mail.cooperteam.net (Postfix) with ESMTPSA id C0B389D2A74; Wed, 29 Mar 2017 11:27:38 +1100 (AEDT) From: raof@ubuntu.com To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/6] drm/amd/amdgpu: Pin bos from imported dma-bufs to GTT. Date: Wed, 29 Mar 2017 11:27:18 +1100 Message-Id: <20170329002720.11445-5-raof@ubuntu.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170329002720.11445-1-raof@ubuntu.com> References: <20170329002720.11445-1-raof@ubuntu.com> Cc: Christopher James Halse Rogers , amd-gfx@lists.freedesktop.org X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Christopher James Halse Rogers Attempting to migrate the bo will break the sharing of the buffer. Signed-off-by: Christopher James Halse Rogers CC: amd-gfx@lists.freedesktop.org Reviewed-by: Michel Dänzer --- drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c index 3826d5aea0a6..3c84ec5c6ac8 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_prime.c @@ -74,6 +74,17 @@ amdgpu_gem_prime_import_sg_table(struct drm_device *dev, if (ret) return ERR_PTR(ret); + /* Imported bo must be pinned to GTT, as moving it breaks sharing */ + ret = amdgpu_bo_reserve(bo, false); + if (ret) + return ERR_PTR(ret); + + ret = amdgpu_bo_pin(bo, AMDGPU_GEM_DOMAIN_GTT, NULL); + if (ret) + return ERR_PTR(ret); + + amdgpu_bo_unreserve(bo); + bo->prime_shared_count = 1; return &bo->gem_base; }