From patchwork Mon Jul 8 10:45:14 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: 168608 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp6982888ilk; Mon, 8 Jul 2019 03:45:34 -0700 (PDT) X-Google-Smtp-Source: APXvYqz4clQj5WEO/xI48l2ZVa1TGny7yfhIbO75JzA+//KVEE3zD81wzegYcaq0NDtZJQH7bBFj X-Received: by 2002:a17:902:b713:: with SMTP id d19mr23893391pls.267.1562582734127; Mon, 08 Jul 2019 03:45:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562582734; cv=none; d=google.com; s=arc-20160816; b=fMiDjuJPUXJOqbeC3lBARORDS1rnf+NDJZPK7/NOqR98x19uIr0yYQ90qyEqBDjTuy 3K3agGyzPJCYoA0d9PzVo75qVQfQlnhvUatdWlj/jYz+fwAYvc05fcD6Dvqc2Atjyzbd mbFYoEB8PeH/GZZLNThgOWpF+qOjSGYqSQbp1mweBU/d+izVn5FeUWYs/jq22/brS0DA SSsrzRhLVHzDzkTTUdmPDh7ohIF5zKMQt3DvfoKRzGy8nt6y2RMEVGKSz/uoHRAIuG7x vZJf++AUHtDkxZ7VbUdsBWAZ2MbiLXj7Faa5Jy0swCEZFryA2Om/SbIBstcpDpsWM3xP GiIw== 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=ROZ7+rwR0zAobFFgPB/bQiHr+SmEwiVByeWJmqfSMDg=; b=GIUVJv9MUNBvP4LFM0kUhdDutQvdeYIzOFwZCLgV7L3Nha4OAf853+S71hfqpILk5Q lR0Z7eg5wHeO9mJSHfFVc6rbB3loCj/8ankTvi/UmcEJtoOujxog/Ih/kQuTSaftX7jY S+ZGpF4q12ygFaYZYHsEG+pZ4BYJWOeg84n+s4m/9nwOILxU3gBe6JcteWQfcVjRyUAt CgPllysy1Z5Uk5An01e9z9jTVWVrOCmCAIsJHSvIUDV8hsUgRBx29UlNJxIkapsdm9RP G/cAbWyqUygmV2A8TcDWMbo6Ze1C6nYhhWiEAfMop2XZoFxcY5YotL4teAXT3dH8mlim vk1Q== 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 x7si18858418pfi.257.2019.07.08.03.45.33 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 08 Jul 2019 03:45:34 -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 2A2B689C68; Mon, 8 Jul 2019 10:45:33 +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 7352D89C68 for ; Mon, 8 Jul 2019 10:45:31 +0000 (UTC) Received: from lelv0265.itg.ti.com ([10.180.67.224]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x68AjUVA050868; Mon, 8 Jul 2019 05:45:30 -0500 Received: from DLEE105.ent.ti.com (dlee105.ent.ti.com [157.170.170.35]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x68AjT1W030529 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Mon, 8 Jul 2019 05:45:29 -0500 Received: from DLEE112.ent.ti.com (157.170.170.23) by DLEE105.ent.ti.com (157.170.170.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Mon, 8 Jul 2019 05:45:29 -0500 Received: from fllv0039.itg.ti.com (10.64.41.19) by DLEE112.ent.ti.com (157.170.170.23) 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, 8 Jul 2019 05:45:29 -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 x68AjS64094793; Mon, 8 Jul 2019 05:45:29 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH v2 2/8] drm/omap: add omap_gem_unpin_locked() Date: Mon, 8 Jul 2019 12:45:14 +0200 Message-ID: <20190708104520.24217-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190708104520.24217-1-jjhiblot@ti.com> References: <20190708104520.24217-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=1562582730; bh=BMALSdC3eHlLBbEzztt6cvZKxUhSacOKg+qlcp7idFc=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=O4AfInWAcTdAqV3H0atZIMCmmq8eHg13E4oTuUtFfZWDeSgwFI+svJiy07yBxsOfO AGlAAbUHu6UFCGDWiIheY7vOZASoCR/1+b49dAb964ne8AhJ4q0h09LUeoin0M5jRw HIhEXyXAVmjQuSeicyXb1S/SuOiCp5Cxe7ybXqEs= 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 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 --- 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 0b6eef120cc9..3071e815da73 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -832,20 +832,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,6 +858,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); }