From patchwork Thu Oct 10 09:34:39 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: 175735 Delivered-To: patch@linaro.org Received: by 2002:a92:7e96:0:0:0:0:0 with SMTP id q22csp2030165ill; Thu, 10 Oct 2019 02:35:16 -0700 (PDT) X-Google-Smtp-Source: APXvYqzGkD/wryXtIvhNQqdGiVPTBSdhxd8dSLteMT5+5Q2CFJXs4BCQgFiTcYwPEB4yS5IHQRPX X-Received: by 2002:a62:4ed6:: with SMTP id c205mr9327482pfb.208.1570700116360; Thu, 10 Oct 2019 02:35:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1570700116; cv=none; d=google.com; s=arc-20160816; b=fxFbITCpiSWNvLWzfTxZWkfHoAkxRaMB7AkiGlgWnxp41b7a/VIBRxg15Z0uRpyjN5 ApFXYzt7hmdCp84EB5uZFlBS9mdRoCWmxbEnS8v/GET3xj/jBI6lweEacnaM29dzDSgX QiAhC4G5lo5IfN2OmsFzp9KgTVU5/V60MeFjhZFK53rEJJ4HJTdhWQOKPBsZBsSgK2QY OXcXomgbOUCBqCxBuVcw54TZe7h0p+RUn4NULJiPcpXigFPwtgymo2KBikYrmUZjd3NG ATi1KzEKjCSKu7RITboYTxXQWmSpXasoU1wtNUEye4T/OBRW7ay87/sM0xnzkFSWXX8n q1Og== 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=Je2BB/VZ9st3/vJiXWxjKzeeB0psD1SDjIWmlklf370=; b=03d7vFUuHPOPdx8QoXHYDGHYoXrGpKIkdZPms6hfcfguMIeWoilRX/IZaIBBF8aXmW OzTyCER3cmEm0fZDw3+df/QU6lut+DuHSfQhfa1ayUCei3Xon605w38+VO+58OsBo0Dn 5rr/mJ5ai2n23c63SiNX8tvE1EHE5azkD7UU7gOeGymvphdBmnuasSOUMXEnGQXwRIpU YU37vZEEvq+G1Pt6KZ6KJKCicQR11AmXc6dAgnUJszTUoa32Dx+qJ/mbXy/xtGCecXK/ X5XPlGcKvrT4BxJ0KIAIJcHO0LQnjme1dwX4xf0kgiOlVeF4k+zp9UpPR7ti2wEHqaoq mniA== 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 131.252.210.177 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. [131.252.210.177]) by mx.google.com with ESMTPS id l17si5741145pgt.540.2019.10.10.02.35.16 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 10 Oct 2019 02:35:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 as permitted sender) client-ip=131.252.210.177; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of dri-devel-bounces@lists.freedesktop.org designates 131.252.210.177 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 CB36E6EADC; Thu, 10 Oct 2019 09:35:12 +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 483076EADE for ; Thu, 10 Oct 2019 09:35:11 +0000 (UTC) Received: from lelv0266.itg.ti.com ([10.180.67.225]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id x9A9Z9h8010274; Thu, 10 Oct 2019 04:35:09 -0500 Received: from DFLE108.ent.ti.com (dfle108.ent.ti.com [10.64.6.29]) by lelv0266.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x9A9Z9Wh087885 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Thu, 10 Oct 2019 04:35:09 -0500 Received: from DFLE101.ent.ti.com (10.64.6.22) by DFLE108.ent.ti.com (10.64.6.29) 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 04:35:05 -0500 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE101.ent.ti.com (10.64.6.22) 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 04:35:09 -0500 Received: from localhost (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id x9A9Z8h6129773; Thu, 10 Oct 2019 04:35:08 -0500 From: Jean-Jacques Hiblot To: , , Subject: [PATCH v4 2/8] drm/omap: add omap_gem_unpin_locked() Date: Thu, 10 Oct 2019 11:34:39 +0200 Message-ID: <20191010093445.11069-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191010093445.11069-1-jjhiblot@ti.com> References: <20191010093445.11069-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=1570700109; bh=0PpOvCL0mMxzWKvBjDpjKpovRlUYaLcsFQUetpU5AoQ=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=LlJQichuxXMORUEKJmT6I5s3T5hwn+tJh9XaxVFcGpow1YVEEgOYN99QT6/PnWk+x vh2kj+lpRfB3gIVz81Bzgf6Sk6ELBqGbx/8mDsh78XWDvdbK6X2kuLa56xTV6wATRH dDbk7RQ9Zt+uSDRvr788aHvY4e4IwyZdti5saSmk= 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 | 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 5c97ff810b5d..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) { @@ -860,7 +856,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); }