From patchwork Mon Aug 24 09:43:30 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Christian_K=C3=B6nig?= X-Patchwork-Id: 7063011 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id CBD9CC05AC for ; Mon, 24 Aug 2015 09:43:48 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 098122061E for ; Mon, 24 Aug 2015 09:43:48 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 2A77B20619 for ; Mon, 24 Aug 2015 09:43:47 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 6B5276E5E1; Mon, 24 Aug 2015 02:43:46 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from pegasos-out.vodafone.de (pegasos-out.vodafone.de [80.84.1.38]) by gabe.freedesktop.org (Postfix) with ESMTP id 94B0C6E4F7 for ; Mon, 24 Aug 2015 02:43:41 -0700 (PDT) Received: from localhost (localhost.localdomain [127.0.0.1]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id 7D975556EF for ; Mon, 24 Aug 2015 11:43:39 +0200 (CEST) X-Virus-Scanned: amavisd-new at vodafone.de X-Spam-Score: -0.044 X-Spam-Level: X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,DKIM_SIGNED, FREEMAIL_FROM,RCVD_IN_DNSWL_MED,RP_MATCHES_RCVD,T_DKIM_INVALID, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 Authentication-Results: rohrpostix2.prod.vfnet.de (amavisd-new); dkim=pass header.i=@vodafone.de Received: from pegasos-out.vodafone.de ([127.0.0.1]) by localhost (rohrpostix2.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id CqNVwp7UgrDC for ; Mon, 24 Aug 2015 11:43:37 +0200 (CEST) Received: from smtp-04.vodafone.de (smtp-04.vodafone.de [10.215.254.39]) by pegasos-out.vodafone.de (Rohrpostix2 Daemon) with ESMTP id D5E5255716 for ; Mon, 24 Aug 2015 11:43:37 +0200 (CEST) X-DKIM: OpenDKIM Filter v2.6.8 pegasos-out.vodafone.de D5E5255716 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vodafone.de; s=mail; t=1440409417; bh=Ap4TNkeEF0Gzh8AyPakVdbUKoKI37d54kn20KOBLyxA=; h=From:To:Subject:Date:In-Reply-To:References; b=JDh8pW2unqBUp44m3tLaji+SwyfwTYfm2nXgPdM5IvldafE3IoHPNXRuRXn1pV002 XOSj1VPuhyNbbS4BIpVkKqwwiUiG+KAtYpbMBo1iRd5TOtIuocW3l7YnzVZEqfwWy1 YiJrJLeCHTO7gb0AgC3H6JnrMjFz1wuNojCa/drE= X-Virus-Scanned: amavisd-new at vodafone.de Received: from smtp-04.vodafone.de ([127.0.0.1]) by localhost (xsmail-dmz8.prod.vfnet.de [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 90msLTRXUmIH for ; Mon, 24 Aug 2015 11:43:35 +0200 (CEST) From: =?UTF-8?q?Christian=20K=C3=B6nig?= To: dri-devel@lists.freedesktop.org Subject: [PATCH 2/2] amdgpu: serialize drmPrimeFDToHandle Date: Mon, 24 Aug 2015 11:43:30 +0200 Message-Id: <1440409410-7907-2-git-send-email-deathsimple@vodafone.de> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1440409410-7907-1-git-send-email-deathsimple@vodafone.de> References: <1440409410-7907-1-git-send-email-deathsimple@vodafone.de> MIME-Version: 1.0 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: Christian König Fixes the same problem as "intel: Serialize drmPrimeFDToHandle with struct_mutex". Signed-off-by: Christian König --- amdgpu/amdgpu_bo.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/amdgpu/amdgpu_bo.c b/amdgpu/amdgpu_bo.c index dab3804..adf4253 100644 --- a/amdgpu/amdgpu_bo.c +++ b/amdgpu/amdgpu_bo.c @@ -289,6 +289,10 @@ int amdgpu_bo_import(amdgpu_device_handle dev, int dma_fd; uint64_t dma_buf_size = 0; + /* We must maintain a list of pairs , so that we always + * return the same amdgpu_bo instance for the same handle. */ + pthread_mutex_lock(&dev->bo_table_mutex); + /* Convert a DMA buf handle to a KMS handle now. */ if (type == amdgpu_bo_handle_type_dma_buf_fd) { uint32_t handle; @@ -303,6 +307,7 @@ int amdgpu_bo_import(amdgpu_device_handle dev, /* Query the buffer size. */ size = lseek(shared_handle, 0, SEEK_END); if (size == (off_t)-1) { + pthread_mutex_unlock(&dev->bo_table_mutex); amdgpu_close_kms_handle(dev, handle); return -errno; } @@ -312,10 +317,6 @@ int amdgpu_bo_import(amdgpu_device_handle dev, shared_handle = handle; } - /* We must maintain a list of pairs , so that we always - * return the same amdgpu_bo instance for the same handle. */ - pthread_mutex_lock(&dev->bo_table_mutex); - /* If we have already created a buffer with this handle, find it. */ switch (type) { case amdgpu_bo_handle_type_gem_flink_name: