From patchwork Wed Jul 3 15:55:30 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: 168454 Delivered-To: patch@linaro.org Received: by 2002:a92:4782:0:0:0:0:0 with SMTP id e2csp1912217ilk; Thu, 4 Jul 2019 00:26:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqxsUyOzd26xsXNwND7fxIqExc1PDT+wHHfux+HLaZHYjRhVEUtEFdwXfrNPLdnAHYkmQtOe X-Received: by 2002:a17:90a:d983:: with SMTP id d3mr17759509pjv.88.1562225161635; Thu, 04 Jul 2019 00:26:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562225161; cv=none; d=google.com; s=arc-20160816; b=zOw8BVh4/HUgrwhd1HsT7nOlCkH2X9K5/jOxsgzwNcT5PFXCUnXzFO5gCdW///EDQX VavQF+8lk/z2TqhZghylzMYPD9TD8o2BtAtHB/qDlzUsAeNE1ZQ33da3HdHkun80r8+B UYRc5umALND4XLInTJU5Rdbzy/96o6cqJEAi694rS2HNy/9D0axIjWNtl6JfXGZNOnuB iekRx8XgbrMRrMNldp3btdi66KQHGJ6kcet598SbvLFZ5KGCjeDzZb0YNgn7A3zg+6+T LTtfYEvZJR1Qyen09friqJxioVp7sGj++65lXIONmgmC3atnTOTyTpiVdsOY67PnqWtz HR/A== 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=QwCYlpB1+/blPCu3RDN+fF8pFpV5Pf4ryK914UBoh7s=; b=prMOVOm77CRCsxwdlCgaeaRcJU0R2PomUkmQoczpYnF0DWV7Oog320ENG3E30z17eX zR6bqi82R1Sv+t3hzTpiabE6r04XMvys+4Z1OwecoDc3v0lK/h5nlWyHeGWI+IeJ3ZwI k4il3Nz1/knkgz1NCSuMggS+ngs5o0sRHTyIkemyTimj6AtiOC2mFIpF5rJdlwx6203U EUEVSg64ixd3w5hpSSHj8EFucfmvTxGlZO4DXhlX9bb2ramC8mIG+9j9rOURo1qLH8tL Dn4F2/N2EtqcU2RZv6UpNOMb8rfYbTIKnWkz5wej3jIL4zdSE8w4DJ25R1BeoZvOuBJm L92g== 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 m71si4414239pjb.26.2019.07.04.00.26.01 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 04 Jul 2019 00:26:01 -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 514666E28B; Thu, 4 Jul 2019 07:25:17 +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 9DB166E15A for ; Wed, 3 Jul 2019 15:55:46 +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 x63FtiVI015509; Wed, 3 Jul 2019 10:55:44 -0500 Received: from DFLE104.ent.ti.com (dfle104.ent.ti.com [10.64.6.25]) by lelv0265.itg.ti.com (8.15.2/8.15.2) with ESMTPS id x63Ftiea064846 (version=TLSv1.2 cipher=AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 3 Jul 2019 10:55:44 -0500 Received: from DFLE103.ent.ti.com (10.64.6.24) by DFLE104.ent.ti.com (10.64.6.25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1713.5; Wed, 3 Jul 2019 10:55:44 -0500 Received: from fllv0040.itg.ti.com (10.64.41.20) by DFLE103.ent.ti.com (10.64.6.24) 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; Wed, 3 Jul 2019 10:55:44 -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 x63Fth81001306; Wed, 3 Jul 2019 10:55:43 -0500 From: Jean-Jacques Hiblot To: , , , Subject: [PATCH 2/8] drm/omap: add omap_gem_unpin_locked() Date: Wed, 3 Jul 2019 17:55:30 +0200 Message-ID: <20190703155536.28339-3-jjhiblot@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190703155536.28339-1-jjhiblot@ti.com> References: <20190703155536.28339-1-jjhiblot@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 X-Mailman-Approved-At: Thu, 04 Jul 2019 07:25:13 +0000 X-Mailman-Original-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1562169344; bh=TvaYb0Rh4N6CqRqeNnFVOyMwXm8L1ETqUol/LNEx+cY=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=YIqBq7K9C5RUfWBiNTCe4F6sIm0xv5ZCRdOUxjXw4Pl/VDCIXwbclosEg6XbyWh0M DgtOnCbsKXGY5UcSi+7SiKqDTlYbT+/R9DpvDngct7FZQUHwY0pM8Hbe1bskEtZWAN x7RVNrQ/nM5e7fjRbEEto2j3pJIL7noCIEZwYMZk= 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 | 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 e8aafcf0f209..2b745b0cfb73 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -830,20 +830,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) { @@ -859,7 +855,22 @@ void omap_gem_unpin(struct drm_gem_object *obj) 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); }