From patchwork Thu Nov 14 08:03:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 179377 Delivered-To: patch@linaro.org Received: by 2002:a92:38d5:0:0:0:0:0 with SMTP id g82csp10722765ilf; Thu, 14 Nov 2019 00:03:59 -0800 (PST) X-Google-Smtp-Source: APXvYqzjS+Q0zQBQeLjJFwfSiCnlvm2TSI8M/8PMFPpSqv4RB+64J7H/oAmnkn25Szi1vdlrBKvp X-Received: by 2002:a63:d550:: with SMTP id v16mr8542159pgi.443.1573718639123; Thu, 14 Nov 2019 00:03:59 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1573718639; cv=none; d=google.com; s=arc-20160816; b=AbMDCxa7sphlex8QKTcmk8vXV4JxsxAyZr+b+EGgxktaoZkSCQH09Gm4Pgw/jivIOR bmXFqqbZY57uC1R808HySZS63JAoRUXDRNP3MiGTCLjPFHGj530dRGlEGUMFzx8Oi/oX 0krlPFsV8trkOyZ0ffDvgK2IUf2X7XePjI6YmnXuKEfWTafNyTSEXy1P1qeSr2DhFoKa /FoU1dYDl6hbI+0gKWUHRTP4TT6YDkjcNw+3bQB7ksBm2xhWbu/Oj1LqW8nEGqweTRW4 KkQiVNyqzBKzRRMxZZFSK9FmZucLe52fpsHpiv/rfLC98Fmjxk0OHFdn0cI67QtHoywg F+rw== 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:message-id:date:subject:to:from :delivered-to; bh=RoR5jFMjZ6Oq4eBcNjP/HSSLokSL2OnSDD9OU2qdL2w=; b=sSF7RWdds4wCh9p+3iLTMU5qIV5fvfgaZV1BFjB2jYXoAJnwvBj7qdd2lNm7tkarlT 6Kh8qz7hXDh4uvyhmbYF4nbhfAjZCDTLt2KzEXmwInhXcymDV8kS8TS7vwlUaD5hdO3F kfSJT9xmXFLvq0Ehuy16jHzNxvqp8TiL7Ns9AHspQp7L6e3215i/hi3/Xllb8XHfNAbT royoWnxpyt1JaJHDIS7+NpSiTO9Ud6DDiwQ1yMmEtWJ48wx/dLbZUGbAignKfn+pZItf ro3eiX9Q/liAXXZjn1hvQOTuYX3lb/CSiAoF/yBOBxbrJyqcd8MbJZe7YmMAzMPV2Em3 rzCw== 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 v3si5849880pgn.304.2019.11.14.00.03.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Thu, 14 Nov 2019 00:03:59 -0800 (PST) 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 6D72A6E186; Thu, 14 Nov 2019 08:03:57 +0000 (UTC) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from lelv0142.ext.ti.com (lelv0142.ext.ti.com [198.47.23.249]) by gabe.freedesktop.org (Postfix) with ESMTPS id D8E026E186 for ; Thu, 14 Nov 2019 08:03:55 +0000 (UTC) Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0142.ext.ti.com (8.15.2/8.15.2) with ESMTP id xAE83qVD118533; Thu, 14 Nov 2019 02:03:52 -0600 Received: from DFLE105.ent.ti.com (dfle105.ent.ti.com [10.64.6.26]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xAE83qWo105830; Thu, 14 Nov 2019 02:03:52 -0600 Received: from DFLE114.ent.ti.com (10.64.6.35) 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.1847.3; Thu, 14 Nov 2019 02:03:51 -0600 Received: from lelv0327.itg.ti.com (10.180.67.183) by DFLE114.ent.ti.com (10.64.6.35) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Thu, 14 Nov 2019 02:03:51 -0600 Received: from deskari.lan (ileax41-snat.itg.ti.com [10.172.224.153]) by lelv0327.itg.ti.com (8.15.2/8.15.2) with ESMTP id xAE83nLM117686; Thu, 14 Nov 2019 02:03:50 -0600 From: Tomi Valkeinen To: , Jean-Jacques Hiblot Subject: [PATCH] drm/omap: fix dma_addr refcounting Date: Thu, 14 Nov 2019 10:03:43 +0200 Message-ID: <20191114080343.30704-1-tomi.valkeinen@ti.com> X-Mailer: git-send-email 2.17.1 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=1573718632; bh=xrNN+1fSFg7BhDQ0s6YIVwKBL/mmvsIj1e6cCTdyZHE=; h=From:To:CC:Subject:Date; b=fpyRXjC4IsRiy/B+RlLmpNlJyGKbmPh4dL1hcixkkT/vII9HqJl3Xfxo7mmIvfS+T MtoeMNxImb/004BzNn37muykBrAr7/yAXCUp+JL39ifTWlHMPOsx6GlMIxenXsXYhX Ee1CPdY3uIohF1EfyB6Nt3cSN3zTlhmL2bXMMT+8= 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: Tomi Valkeinen , Laurent Pinchart Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" cec4fa7511ef7a73eb635834e9d85b25a5b47a98 ("drm/omap: use refcount API to track the number of users of dma_addr") changed omap_gem.c to use refcounting API to track dma_addr uses. However, the driver only tracks the refcounts for non-contiguous buffers, and the patch didn't fully take this in account. After the patch, the driver always decreased refcount in omap_gem_unpin, instead of decreasing the refcount only for non-contiguous buffers. This leads to refcounting mismatch. As for the contiguous cases the refcount is never increased, fix this issue by returning from omap_gem_unpin if the buffer being unpinned is contiguous. Signed-off-by: Tomi Valkeinen Reviewed-by: Laurent Pinchart --- drivers/gpu/drm/omapdrm/omap_gem.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index e518d93ca6df..d08ae95ecc0a 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c @@ -843,9 +843,13 @@ int omap_gem_pin(struct drm_gem_object *obj, dma_addr_t *dma_addr) */ static void omap_gem_unpin_locked(struct drm_gem_object *obj) { + struct omap_drm_private *priv = obj->dev->dev_private; struct omap_gem_object *omap_obj = to_omap_bo(obj); int ret; + if (omap_gem_is_contiguous(omap_obj) || !priv->has_dmm) + return; + if (refcount_dec_and_test(&omap_obj->dma_addr_cnt)) { ret = tiler_unpin(omap_obj->block); if (ret) {