From patchwork Mon Feb 7 13:19:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Perttunen X-Patchwork-Id: 12737257 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 93BC4C433EF for ; Mon, 7 Feb 2022 13:42:06 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 918A410F14A; Mon, 7 Feb 2022 13:42:05 +0000 (UTC) Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by gabe.freedesktop.org (Postfix) with ESMTPS id E2C2710F14A for ; Mon, 7 Feb 2022 13:42:03 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:Message-Id:Date:Subject :Cc:To:From:Sender:Reply-To:Content-Type:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: In-Reply-To:References:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=THrB40q/yOSt5cd0Iu4CGyYT6zUZMR21yUK3lUKzKZ8=; b=wB2ahBMfpiwLs/yizKobnktO1e r1u64pQ6f24ow6srdnt3Tbbva76WV8L8463+JUWKL3EdW+oeDAx51OZ4NzY5WAXVmWu/Aq6OBWkxj vTo9jDJYwzGZ24k4AH2YGFaoM9mozOGAjZi2eBO/pEHTrh2n+xpsYWzbCqmv+gPd8ktYKkDAEQV9Q 2A95CHTFjEVx0gbbujjtbHavxlbhEolM08i63GQHByszZgJElzML0b0ATOVEn2RBfjhkFN1BNzG3F 9JLisrq26hRVnpdL5xr1V2nTyQI8NjfX+xpegLm0Cho5LmnxXtR18JLfoNpzFflNJBIKQ5iqp8bOP BtEShDFA==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nH3vx-0007xv-M8; Mon, 07 Feb 2022 15:19:57 +0200 From: Mikko Perttunen To: thierry.reding@gmail.com Subject: [PATCH 1/2] gpu: host1x: Always return syncpoint value when waiting Date: Mon, 7 Feb 2022 15:19:31 +0200 Message-Id: <20220207131932.2164560-1-mperttunen@nvidia.com> X-Mailer: git-send-email 2.35.0 MIME-Version: 1.0 X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: mperttunen@nvidia.com X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Mikko Perttunen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The new TegraDRM UAPI uses syncpoint waiting with timeout set to zero to indicate reading the syncpoint value. To support that we need to return the syncpoint value always when waiting. Fixes: 44e961381354 ("drm/tegra: Implement syncpoint wait UAPI") Signed-off-by: Mikko Perttunen --- drivers/gpu/host1x/syncpt.c | 19 ++----------------- 1 file changed, 2 insertions(+), 17 deletions(-) diff --git a/drivers/gpu/host1x/syncpt.c b/drivers/gpu/host1x/syncpt.c index e08e331e46ae..fb4036a32095 100644 --- a/drivers/gpu/host1x/syncpt.c +++ b/drivers/gpu/host1x/syncpt.c @@ -227,27 +227,12 @@ int host1x_syncpt_wait(struct host1x_syncpt *sp, u32 thresh, long timeout, void *ref; struct host1x_waitlist *waiter; int err = 0, check_count = 0; - u32 val; if (value) - *value = 0; - - /* first check cache */ - if (host1x_syncpt_is_expired(sp, thresh)) { - if (value) - *value = host1x_syncpt_load(sp); + *value = host1x_syncpt_load(sp); + if (host1x_syncpt_is_expired(sp, thresh)) return 0; - } - - /* try to read from register */ - val = host1x_hw_syncpt_load(sp->host, sp); - if (host1x_syncpt_is_expired(sp, thresh)) { - if (value) - *value = val; - - goto done; - } if (!timeout) { err = -EAGAIN; From patchwork Mon Feb 7 13:19:32 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mikko Perttunen X-Patchwork-Id: 12737256 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 9FF16C4167E for ; Mon, 7 Feb 2022 13:42:01 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CD63710F011; Mon, 7 Feb 2022 13:42:00 +0000 (UTC) X-Greylist: delayed 1321 seconds by postgrey-1.36 at gabe; Mon, 07 Feb 2022 13:42:00 UTC Received: from mail.kapsi.fi (mail.kapsi.fi [IPv6:2001:67c:1be8::25]) by gabe.freedesktop.org (Postfix) with ESMTPS id 3873D10F011 for ; Mon, 7 Feb 2022 13:42:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=kapsi.fi; s=20161220; h=Content-Transfer-Encoding:MIME-Version:References:In-Reply-To: Message-Id:Date:Subject:Cc:To:From:Sender:Reply-To:Content-Type:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Id:List-Help:List-Unsubscribe:List-Subscribe: List-Post:List-Owner:List-Archive; bh=dHg/vhDPEuP5iogqPGsue7712DGBhW3650gIFC1Qb+E=; b=UqQGnHOU9YM+5BMtZNfiecBhWW eRdcJv6NQBSYivUNOVEQrM2aPfgo8s03Lxggz0aX+7IchPggvo5+B6KbZMsHrwSqbU921kMxirC5/ umhDBnN9oy+b725nLdA2zGQnN+IfBjsaA2456mv5FKEuaiUYiAdR+cLxyJoocuUL0muoNF/i1E4Ak AzgmplJO4/xBME1q9OkMmCZE6Z6/MpwzmFFfXTobD56bXbhY4snYSJYa/Fu+mF7pxaHdKtwJSLBed iY8AzERFcqqpSF7V37sEJEkekLu3YRX4enkOAFVAA9OtiN/4SdvQO6+h1zeJuGMA4RNVBNbp5gKuV jGp5jIIQ==; Received: from 91-158-25-70.elisa-laajakaista.fi ([91.158.25.70] helo=toshino.localdomain) by mail.kapsi.fi with esmtpsa (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.89) (envelope-from ) id 1nH3vx-0007xv-Nd; Mon, 07 Feb 2022 15:19:57 +0200 From: Mikko Perttunen To: thierry.reding@gmail.com Subject: [PATCH 2/2] gpu: host1x: Fix refcount leak in buffer cache Date: Mon, 7 Feb 2022 15:19:32 +0200 Message-Id: <20220207131932.2164560-2-mperttunen@nvidia.com> X-Mailer: git-send-email 2.35.0 In-Reply-To: <20220207131932.2164560-1-mperttunen@nvidia.com> References: <20220207131932.2164560-1-mperttunen@nvidia.com> MIME-Version: 1.0 X-SA-Exim-Connect-IP: 91.158.25.70 X-SA-Exim-Mail-From: mperttunen@nvidia.com X-SA-Exim-Scanned: No (on mail.kapsi.fi); SAEximRunCond expanded to false X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-tegra@vger.kernel.org, dri-devel@lists.freedesktop.org, Mikko Perttunen Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" The recently introduced buffer cache is causing cached BOs to leak, as cache entries are dropped when a BO's refcount goes to zero but the cache itself keeps a reference to each cache BO, causing a circular reference. Fix this by not taking a reference to the cached BOs within the cache itself. Fixes: 1f39b1dfa53c ("drm/tegra: Implement buffer object cache") Signed-off-by: Mikko Perttunen --- NOTE As is, applying this patch reveals a BO refcounting issue in the DC driver. A fix for that bug should be applied before applying this patch. I believe Thierry will be posting a fix for that shortly. --- drivers/gpu/host1x/bus.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index bdee16a0bb8e..66ba04501c94 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -938,9 +938,6 @@ struct host1x_bo_mapping *host1x_bo_pin(struct device *dev, struct host1x_bo *bo mapping->cache = cache; list_add_tail(&mapping->entry, &cache->mappings); - - /* bump reference count to track the copy in the cache */ - kref_get(&mapping->ref); } unlock: