From patchwork Mon Oct 7 11:25:49 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: 175321 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp4143321ill; Mon, 7 Oct 2019 04:26:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqwVjdYPkarqGvBeDnHZkBr9nsMYVwz/R6kZoIVUnFPVxbZMifG/LRcYDVH5shm6F3kI5lOQ X-Received: by 2002:a17:902:222:: with SMTP id 31mr29578562plc.167.1570447569056; Mon, 07 Oct 2019 04:26:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570447569; cv=none; d=google.com; s=arc-20160816; b=NGSvmCYre9pmRExS5QpMhrD/W1gvqx6aZF/K1rViy0J8PZi7t074MyQua/kxJvZWfl lg8Wcz4b8DS+ww/CecGh8c64y/4IukP5NtKYgGQw/sZgPEDNCqex/711x2Ftta63vHqC lJbbYLd75+Eq4lcbNq3mnwYR7JOYJIumZ+lffYm8Skh5uf+QW1lIiBiorFaDoZ8T9N8j kqcNAFO7m3wL0u1y9iPyzdZSQfV1WlrDtWbVDhcWhYfQySMD389LL7D+j4B2HVbhotII mTbMZN8T+0rz1caZJsRxtt2IpB/XIKqhIl5S7pil6duhe8QkBtlKxk+aPgRBPfy5hH7C iJsg== 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=fZr/iwo1+X2VLs++bU9UCuLBNhP+Q6iy0u5E6EbIzo4=; b=GXSYopIZpbDrUJJFCZ5c7P+HzySTOOVdxAUlaavJWSZ5V2rZFGSuvqMidBz9cTA2dO /w9m8yRYgxJFnofBuTbNEHdyfY9H7PduQgmHPAyJstIWyx7Au/qbY7RcKBf5igPAXxKw rzyyD+gtXBXzKFF6ZnijcKaqCHmwwwfTh18lueyFGg277QYcXBBaQddskISO2YhWIVnX s7MC2xAovf2c1pTktScoafEngQ1ALNmk22wmun9vDjQ1OQ5yHE7FmC8PDoBRxQHJxrM+ dakYLe8uJvndNsOLP9NqgXIv/4XC8nLQbs/A6tdw4RGHr+TVDLfrpE0PyZr9wN0uVs7Q SIPw== 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 u5si5297143pgc.379.2019.10.07.04.26.08 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 07 Oct 2019 04:26:09 -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 C2FC66E55E; Mon, 7 Oct 2019 11:26:07 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from fllv0015.ext.ti.com (fllv0015.ext.ti.com [198.47.19.141]) by gabe.freedesktop.org (Postfix) with ESMTPS id 26D976E55E for ; Mon, 7 Oct 2019 11:26:06 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by fllv0015.ext.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ3Jw012407; Mon, 7 Oct 2019 06:26:03 -0500 Received: from DFLE100.ent.ti.com (dfle100.ent.ti.com [10.64.6.21]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x97BQ3ge011463 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 7 Oct 2019 06:26:03 -0500 Received: from DFLE105.ent.ti.com (10.64.6.26) by DFLE100.ent.ti.com (10.64.6.21) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 7 Oct 2019 06:26:01 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DFLE105.ent.ti.com (10.64.6.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; Mon, 7 Oct 2019 06:26:03 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0039.itg.ti.com (8.15.2/8.15.2) with ESMTP id x97BQ2HY058976; Mon, 7 Oct 2019 06:26:02 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v3 2/8] drm/omap: add omap_gem_unpin_locked() Date: Mon, 7 Oct 2019 13:25:49 +0200 Message-ID: <20191007112555.25278-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191007112555.25278-1-jjhiblot@ti.com> References: <20191007112555.25278-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=1570447563; bh=BZ7phGWHu9w3u3UYwxJIySH+VtutbkKNKZ9gvsE7pAE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=qk9hkIkm5y8GlLL/YaNMwVY7/XNvymIpNaDFBfxozgOvk/j6d2KomqP8DshzZEb1y a2gFh8n48uXFTydY4Yli250pRpQWYK8/pk7hL2v54ADi0hB5XTd7ooDM6iSOkdeR/L ZLOnskem0s6XtL/AEtcrGVMXtUDvcsB5qDsy4ECA= 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: 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 | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 51ede7777083..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) { @@ -864,6 +860,20 @@ void omap_gem_unpin(struct drm_gem_object *obj) } } +/** + * 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); }