From patchwork Thu Jan 12 09:12:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Maxime Ripard X-Patchwork-Id: 13097693 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 50DA5C54EBC for ; Thu, 12 Jan 2023 09:12:54 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 7716410E8A9; Thu, 12 Jan 2023 09:12:53 +0000 (UTC) Received: from out2-smtp.messagingengine.com (out2-smtp.messagingengine.com [66.111.4.26]) by gabe.freedesktop.org (Postfix) with ESMTPS id EAB4910E8A9 for ; Thu, 12 Jan 2023 09:12:50 +0000 (UTC) Received: from compute4.internal (compute4.nyi.internal [10.202.2.44]) by mailout.nyi.internal (Postfix) with ESMTP id 7DDD95C0105; Thu, 12 Jan 2023 04:12:47 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute4.internal (MEProxy); Thu, 12 Jan 2023 04:12:47 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=cerno.tech; h=cc :cc:content-transfer-encoding:date:date:from:from:in-reply-to :message-id:mime-version:reply-to:sender:subject:subject:to:to; s=fm1; t=1673514767; x=1673601167; bh=Tri+DR+cVs/Auk8o+T2XwgOXI oNZqmidUJrivwOD7n0=; b=s2CbTOS/YBQFqx7/22J/Nmrvqq1JxowlxuwwJwUeU 7+tSSz6BtkvBTkeA1e6eTHFgOI9uSYdOTIAm8gL7CuKOKt7sj9ASMKlxLZ3ujIWD 2h994zEts+5riysq/fDZxfDX+KT95Bk62IsDWx34Ido3/DXTcINo6/j3jkaY59Q3 gU2Q/IC9BZ8Vcq2sLuzg9Q8rNuuCbCujJlK1Nf2HwlxHCrZTixagCHKUWV69ib/f kjyOr7Jsej+jpwSf1hjQAkLVaRVv59Hyl8JvBX9H3u+7tmkb+A9R+OxigpYo50Sx KTcfdY06N6CgzBfD8QaBaNw34zandWyJ+ltTtxy+vZESw== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-transfer-encoding:date:date :feedback-id:feedback-id:from:from:in-reply-to:message-id :mime-version:reply-to:sender:subject:subject:to:to:x-me-proxy :x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; t= 1673514767; x=1673601167; bh=Tri+DR+cVs/Auk8o+T2XwgOXIoNZqmidUJr ivwOD7n0=; b=r5EDYnfEL6TKUF8vYevqpjQYApT2TzIGvB5mVmo59lHODBrEfd6 BpHSIOqR3LUkio9A4GPgOWDJoeij3k1AA+16wREc4h9yQ9s+RZixG2797AebAVdN r/QZi2QiD2b+d2YjdOIA0Dj5+/wWGF6gbERw9pQfL2ihPubYpCnXKGjf3b/Tj+cC Tt0SRs20XCELCPPfZw+5t+Wd3wrQgJzNu/kAc134YwUfn+5Ml2lfuyDJWcgGTkov tvyinSgA/9k+Oj/p4Eeg+fLTK7ZgWhMFIjsJsxeV7qqfe6imUGiAWtzyw2KdhdOy 9Odx7VA2XJIshpSbifwiNrszG9FOBpmQd4g== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrleeiucetufdoteggodetrfdotffvucfrrh hofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgenuceurghi lhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmnecujfgurh ephffvvefufffkofgggfestdekredtredttdenucfhrhhomhepofgrgihimhgvucftihhp rghrugcuoehmrgigihhmvgestggvrhhnohdrthgvtghhqeenucggtffrrghtthgvrhhnpe ektedujeeijeefhfejuedtudegtdejffffvdettdeigeekffeileelgeevgfdvvdenucev lhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehmrgigihhmvg estggvrhhnohdrthgvtghh X-ME-Proxy: Feedback-ID: i8771445c:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Thu, 12 Jan 2023 04:12:46 -0500 (EST) From: Maxime Ripard To: Daniel Vetter , David Airlie , Maarten Lankhorst , Thomas Zimmermann , Maxime Ripard Subject: [PATCH] drm/vc4: bo: Fix drmm_mutex_init memory hog Date: Thu, 12 Jan 2023 10:12:43 +0100 Message-Id: <20230112091243.490799-1-maxime@cerno.tech> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 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: dri-devel@lists.freedesktop.org Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit 374146cad469 ("drm/vc4: Switch to drmm_mutex_init") converted, among other functions, vc4_create_object() to use drmm_mutex_init(). However, that function is used to allocate a BO, and therefore the mutex needs to be freed much sooner than when the DRM device is removed from the system. For each buffer allocation we thus end up allocating a small structure as part of the DRM-managed mechanism that is never freed, eventually leading us to no longer having any free memory anymore. Let's switch back to mutex_init/mutex_destroy to deal with it properly. Fixes: 374146cad469 ("drm/vc4: Switch to drmm_mutex_init") Signed-off-by: Maxime Ripard Reviewed-by: Daniel Vetter --- drivers/gpu/drm/vc4/vc4_bo.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_bo.c b/drivers/gpu/drm/vc4/vc4_bo.c index c2b7573bd92b..49320e4d595d 100644 --- a/drivers/gpu/drm/vc4/vc4_bo.c +++ b/drivers/gpu/drm/vc4/vc4_bo.c @@ -179,6 +179,7 @@ static void vc4_bo_destroy(struct vc4_bo *bo) bo->validated_shader = NULL; } + mutex_destroy(&bo->madv_lock); drm_gem_dma_free(&bo->base); } @@ -406,9 +407,7 @@ struct drm_gem_object *vc4_create_object(struct drm_device *dev, size_t size) bo->madv = VC4_MADV_WILLNEED; refcount_set(&bo->usecnt, 0); - ret = drmm_mutex_init(dev, &bo->madv_lock); - if (ret) - return ERR_PTR(ret); + mutex_init(&bo->madv_lock); mutex_lock(&vc4->bo_lock); bo->label = VC4_BO_TYPE_KERNEL;