From patchwork Thu Oct 10 11:59:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jean-Jacques Hiblot X-Patchwork-Id: 175773 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2181543ill; Thu, 10 Oct 2019 05:00:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqxaJvE2SC+V75Oi8UBz7SnfMwaa+icDX//9fW2JFebc5jIUbeAcjMqRaTrQIdl5Sc5EUHau X-Received: by 2002:aa7:9832:: with SMTP id q18mr10193147pfl.102.1570708816324; Thu, 10 Oct 2019 05:00:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570708816; cv=none; d=google.com; s=arc-20160816; b=wPbhZkS19kmWMWdyB4HMtCTFLfRT+d/4ipgmfAfHNPvchZrRaseQFoAU3mH12oGVh0 uo7Q+/ej5Fk2NXJXPvNN/CpUhOCri79BLdWotfoC3HPBK4cVAWetm0zYYciWpURSul8M T/cK/Us8SfMqzl0oRw4znJxOPt5lu0w2hj5BWViwOouc0cJpdnDRMbH6r/D55Oog56ol 0mtnQIdqJOeKpkB8eNugigGhwDeOHjgnU3o7A5DjCJW9/R3yV4fwP7DNuSOcWEehZbLw OVr1kl/8Tui7/jRZGwnw6GznmsRwnbGAiB8yODg2/ga8zVarbWGyxevZoFZmOXLUXriU gpgw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:list-subscribe :list-help:list-post:list-archive:list-unsubscribe:list-id :precedence:mime-version:references:in-reply-to:message-id:date :subject:to:from:delivered-to; bh=jUoUPWa1RSzZ4shrii/uS/eemSGvXD2MygQHBOPr2is=; b=kpxfa4pmfWqeMXYbP7K0Dhna9tWxwEErJa7NHkR16IsnB8U+KC34GOJQO9uSR8+WEx CoK2QcpM7SO5hsW4MhK7HwvM4Rl+n/ZDV96WsSa861O1v0MOaTTlUpzzzeTAzxBnwxh4 WD3SANG50Nif5z6/snD3PsAYjraMuX/SYPpptzWhHNg6uXEWINWQXOhOEc9uwz2a7I1d QEX4j3B7IRe0GybfFXZjiVvUijuYHGkuxoWElYKgWu45r0Lgw+EzMxjK5MQKNMzsiJxp qbb+1Bzm3FwEYqSiqC/JGwJu+kxCvJR+sxdgVhCuxIxRtQjicWGm0Yiy4NcAW79wVr2F 343A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from gabe.freedesktop.org (gabe.freedesktop.org. [2610:10:20:722:a800:ff:fe36:1795]) by mx.google.com with ESMTPS id p22si5537721plo.32.2019.10.10.05.00.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 05:00:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) client-ip=2610:10:20:722:a800:ff:fe36:1795; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 2610:10:20:722:a800:ff:fe36:1795 as permitted sender) smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org; dmarc=fail (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 980886EB0B; Thu, 10 Oct 2019 12:00:14 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0143.ext.ti.com (lelv0143.ext.ti.com [198.47.23.248]) by gabe.freedesktop.org (Postfix) with ESMTPS id BAEE16EB0B for ; Thu, 10 Oct 2019 12:00:11 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0ASx043470; Thu, 10 Oct 2019 07:00:10 -0500 Received: from DLEE104.ent.ti.com (dlee104.ent.ti.com [157.170.170.34]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC0AYq016934; Thu, 10 Oct 2019 07:00:10 -0500 Received: from DLEE115.ent.ti.com (157.170.170.26) by DLEE104.ent.ti.com (157.170.170.34) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Thu, 10 Oct 2019 07:00:06 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE115.ent.ti.com (157.170.170.26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5 via Frontend Transport; Thu, 10 Oct 2019 07:00:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9AC08ij121674; Thu, 10 Oct 2019 07:00:09 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v5 2/8] drm/omap: add omap_gem_unpin_locked() Date: Thu, 10 Oct 2019 13:59:54 +0200 Message-ID: <20191010120000.1421-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010120000.1421-1-jjhiblot@ti.com> References: <20191010120000.1421-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1570708810; bh=jURwAB1QUaF+ZHV6PUO9XNEuGkNY8qCFsc3a86GgHpk=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=yxPr4tvfzc8NfGW4k1/XcSIKBIijhvPaYLWAQcZO75/C55P+17SakiePzH1ea1WEJ kBIN7vBylbxBya0StWqzXaLijKNdmYhDQOKtHjLXSWbmirGI1VsND+X0N5vLb95UAj gDYYD/Q1VPvKDhrv6cxgt2vtD+wFms5n36q0caX0= X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: jjhiblot@ti.com, jsarha@ti.com, dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" From: Tomi Valkeinen Add omap_gem_unpin_locked() which is a version of omap_gem_unpin() that expects the caller to hold the omap_obj lock. Signed-off-by: Tomi Valkeinen Reviewed-by: Jean-Jacques Hiblot --- drivers/gpu/drm/omapdrm/omap_gem.c | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 61caa7a1a24b..9201c21e206f 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -834,20 +834,16 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) } /** - * omap_gem_unpin() - Unpin a GEM object from memory + * omap_gem_unpin_locked() - Unpin a GEM object from memory * @obj: the GEM object * - * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are - * reference-counted, the actualy unpin will only be performed when the number - * of calls to this function matches the number of calls to omap_gem_pin(). + * omap_gem_unpin() without locking. */ -void omap_gem_unpin(struct drm_gem_object *obj) +static void omap_gem_unpin_locked(struct drm_gem_object *obj) { struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; - mutex_lock(&omap_obj->lock); - if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { ret = tiler_unpin(omap_obj->block); if (ret) { @@ -862,7 +858,22 @@ void omap_gem_unpin(struct drm_gem_object *obj) omap_obj->dma_addr = 0; omap_obj->block = NULL; } +} +/** + * omap_gem_unpin() - Unpin a GEM object from memory + * @obj: the GEM object + * + * Unpin the given GEM object previously pinned with omap_gem_pin(). Pins are + * reference-counted, the actual unpin will only be performed when the number + * of calls to this function matches the number of calls to omap_gem_pin(). + */ +void omap_gem_unpin(struct drm_gem_object *obj) +{ + struct omap_gem_object *omap_obj = to_omap_bo(obj); + + mutex_lock(&omap_obj->lock); + omap_gem_unpin_locked(obj); mutex_unlock(&omap_obj->lock); }