From patchwork Fri Sep 12 12:48:38 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lionel Landwerlin X-Patchwork-Id: 4894461 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id F17A79F32F for ; Fri, 12 Sep 2014 12:43:54 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 0ADFA202D1 for ; Fri, 12 Sep 2014 12:48:54 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id C49AE2010E for ; Fri, 12 Sep 2014 12:48:52 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 345376E6B9; Fri, 12 Sep 2014 05:48:52 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mga02.intel.com (mga02.intel.com [134.134.136.20]) by gabe.freedesktop.org (Postfix) with ESMTP id ED6536E6B8 for ; Fri, 12 Sep 2014 05:48:48 -0700 (PDT) Received: from azsmga001.ch.intel.com ([10.2.17.19]) by orsmga101.jf.intel.com with ESMTP; 12 Sep 2014 05:48:47 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.04,513,1406617200"; d="scan'208";a="477113648" Received: from unknown (HELO ivy.amr.corp.intel.com) ([10.255.12.173]) by azsmga001.ch.intel.com with ESMTP; 12 Sep 2014 05:48:46 -0700 From: Lionel Landwerlin To: dri-devel@lists.freedesktop.org Subject: [PATCH 4/4] intel: make drm_intel_gem_bo_get_reloc_count() thread safe Date: Fri, 12 Sep 2014 13:48:38 +0100 Message-Id: <1410526118-8421-5-git-send-email-lionel.g.landwerlin@intel.com> X-Mailer: git-send-email 2.0.1 In-Reply-To: <1410526118-8421-1-git-send-email-lionel.g.landwerlin@intel.com> References: <1410526118-8421-1-git-send-email-lionel.g.landwerlin@intel.com> X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.15 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-Spam-Status: No, score=-6.4 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_MED, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Lionel Landwerlin --- intel/intel_bufmgr_gem.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/intel/intel_bufmgr_gem.c b/intel/intel_bufmgr_gem.c index bf6745d..4e34f75 100644 --- a/intel/intel_bufmgr_gem.c +++ b/intel/intel_bufmgr_gem.c @@ -1783,6 +1783,7 @@ drm_intel_gem_bo_get_reloc_count(drm_intel_bo *bo) drm_public void drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start) { + drm_intel_bufmgr_gem *bufmgr_gem = (drm_intel_bufmgr_gem *) bo->bufmgr; drm_intel_bo_gem *bo_gem = (drm_intel_bo_gem *) bo; int i; struct timespec time; @@ -1790,7 +1791,10 @@ drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start) clock_gettime(CLOCK_MONOTONIC, &time); assert(bo_gem->reloc_count >= start); + /* Unreference the cleared target buffers */ + pthread_mutex_lock(&bufmgr_gem->lock); + for (i = start; i < bo_gem->reloc_count; i++) { drm_intel_bo_gem *target_bo_gem = (drm_intel_bo_gem *) bo_gem->reloc_target_info[i].bo; if (&target_bo_gem->bo != bo) { @@ -1800,6 +1804,9 @@ drm_intel_gem_bo_clear_relocs(drm_intel_bo *bo, int start) } } bo_gem->reloc_count = start; + + pthread_mutex_unlock(&bufmgr_gem->lock); + } /**