From patchwork Tue Nov 5 20:54:55 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 13863539 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 7FBB9D35E4D for ; Tue, 5 Nov 2024 20:55:19 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 8A1EB10E050; Tue, 5 Nov 2024 20:55:18 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="AtPb5s9i"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id C156810E050 for ; Tue, 5 Nov 2024 20:55:16 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1730840109; cv=none; d=zohomail.com; s=zohoarc; b=R4URFRu68qMBbJlAKi9VTm1Ne07Q1ZI9slaTrkvjkTvxySPKS6/5uiiyl8A1r4jHm/FThTKQvxjH0FjjFt9JWt3J1lB+AldwPgpgZtzTvt3l1eVMRD0eKlDMbwMi5VF1+GK1/fBiGkv/JCB7JP2hQZ9Y97SD/Xh6oAshhFU1RzA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730840109; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:MIME-Version:Message-ID:Subject:Subject:To:To:Message-Id:Reply-To; bh=nj7nP9zQoF3AEa+3/reQIoPhVeubnSxEu3NbYWDKKx4=; b=G7Q5CrCYp1rB+jO88ETsFDFvBKNygFgeVb8T4UL8VZPpw31xtkUtQH+1IUHyEoS0IJArGjym+wJl9OQ1ehFZdQlxQwYsLdHHrc2F6z/Q2rksfddi4opgq8KceaO59tLumTQkreDCm+pM1rnII5NwAgKR4ifQLQyXDghnPw2lVH4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1730840109; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=nj7nP9zQoF3AEa+3/reQIoPhVeubnSxEu3NbYWDKKx4=; b=AtPb5s9iyVHf5cVM1C4rChxIAD/jXlty83NGkwb4qef0johFykNflbVKICQ9JTA0 Ki7K53IZwGqds8TkACcJwWrk+5uBGRb/pcT6itQ5fUYcNG1dgZe1Lqv/35RPNeDfBe/ ZCU4coechi/n4O9zwsX3Pmd+nY7F07mHGIUKnPSo= Received: by mx.zohomail.com with SMTPS id 1730840108167855.385300677661; Tue, 5 Nov 2024 12:55:08 -0800 (PST) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , =?utf-8?q?Adri=C3=A1n_Larumbe?= Cc: kernel@collabora.com, Liviu Dudau , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 1/2] drm/panfrost: Add missing OPP table refcnt decremental Date: Tue, 5 Nov 2024 20:54:55 +0000 Message-ID: <20241105205458.1318989-1-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.46.2 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Commit f11b0417eec2 ("drm/panfrost: Add fdinfo support GPU load metrics") retrieves the OPP for the maximum device clock frequency, but forgets to keep the reference count balanced by putting the returned OPP object. This eventually leads to an OPP core warning when removing the device. Fix it by putting OPP objects as many times as they're retrieved. Also remove an unnecessary whitespace. Signed-off-by: Adrián Larumbe Fixes: f11b0417eec2 ("drm/panfrost: Add fdinfo support GPU load metrics") Reviewed-by: Steven Price Reviewed-by: Liviu Dudau --- drivers/gpu/drm/panfrost/panfrost_devfreq.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) base-commit: aadcf584583ca9833b4fb2140a4f437569ddbcd7 diff --git a/drivers/gpu/drm/panfrost/panfrost_devfreq.c b/drivers/gpu/drm/panfrost/panfrost_devfreq.c index 2d30da38c2c3..3385fd3ef41a 100644 --- a/drivers/gpu/drm/panfrost/panfrost_devfreq.c +++ b/drivers/gpu/drm/panfrost/panfrost_devfreq.c @@ -38,7 +38,7 @@ static int panfrost_devfreq_target(struct device *dev, unsigned long *freq, return PTR_ERR(opp); dev_pm_opp_put(opp); - err = dev_pm_opp_set_rate(dev, *freq); + err = dev_pm_opp_set_rate(dev, *freq); if (!err) ptdev->pfdevfreq.current_frequency = *freq; @@ -182,6 +182,7 @@ int panfrost_devfreq_init(struct panfrost_device *pfdev) * if any and will avoid a switch off by regulator_late_cleanup() */ ret = dev_pm_opp_set_opp(dev, opp); + dev_pm_opp_put(opp); if (ret) { DRM_DEV_ERROR(dev, "Couldn't set recommended OPP\n"); return ret; From patchwork Tue Nov 5 20:54:56 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Adri=C3=A1n_Larumbe?= X-Patchwork-Id: 13863540 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 47F98D35E53 for ; Tue, 5 Nov 2024 20:55:26 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id CC62610E42F; Tue, 5 Nov 2024 20:55:25 +0000 (UTC) Authentication-Results: gabe.freedesktop.org; dkim=pass (1024-bit key; unprotected) header.d=collabora.com header.i=adrian.larumbe@collabora.com header.b="NxaUSgXm"; dkim-atps=neutral Received: from sender4-pp-f112.zoho.com (sender4-pp-f112.zoho.com [136.143.188.112]) by gabe.freedesktop.org (Postfix) with ESMTPS id 5596710E114 for ; Tue, 5 Nov 2024 20:55:24 +0000 (UTC) ARC-Seal: i=1; a=rsa-sha256; t=1730840113; cv=none; d=zohomail.com; s=zohoarc; b=Q92ZMBTzX2Ovt80kwYpz9CfZB2hnVMAmuq+lC4ecC99Q6Byndqvw/lwYe5dnpaItsjxKp+4nLguCk4DJ3iAn/aOIVuvqHU+jQ6sxCmJxo8RKgs+tRTphngSQHEDfDdpbo+yRHfhokPe9BYarH7XEa9uj7A3yv/zhPR19k9cChg0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1730840113; h=Content-Type:Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:MIME-Version:Message-ID:References:Subject:Subject:To:To:Message-Id:Reply-To; bh=AwrxtqiIa4mKWF1bEvs38Az3WJm9z6mQPcyAOFFvEs8=; b=TsEr5VLOugB/3IGrwlQlcn54Wz+J34uu38BKDQJF7CkaD6zyWwdMHWFX6eFiQRPpGJxUVPwD8Or3DvG/rw+ypAmLz/QhJKVfiJX2kvajblN1JZ1M308z93F7zzEcZ4PgnYbaZ2wBq1O1N0YU70cMFy/qimCz7V8vN3V7oeOCtmc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass header.i=collabora.com; spf=pass smtp.mailfrom=adrian.larumbe@collabora.com; dmarc=pass header.from= DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; t=1730840113; s=zohomail; d=collabora.com; i=adrian.larumbe@collabora.com; h=From:From:To:To:Cc:Cc:Subject:Subject:Date:Date:Message-ID:In-Reply-To:References:MIME-Version:Content-Type:Content-Transfer-Encoding:Message-Id:Reply-To; bh=AwrxtqiIa4mKWF1bEvs38Az3WJm9z6mQPcyAOFFvEs8=; b=NxaUSgXmjFfWIK1qjGuGmSupIsgjS1zh0Q/hDgVXFB6ECVl0jR/vcEGLBKamY7bY e+o5RU6VK/0oLYEHUq2rDVqJojeLsflH6wKt7V1xJN/H2d+DUhG3IM4oAaHCNDh6epy APzvVGXpQLmUtY9ON85MYP6xA9LBcdptWtm30GEk= Received: by mx.zohomail.com with SMTPS id 1730840111631663.6545608679393; Tue, 5 Nov 2024 12:55:11 -0800 (PST) From: =?utf-8?q?Adri=C3=A1n_Larumbe?= To: Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , =?utf-8?q?Adri=C3=A1n_Larumbe?= , Liviu Dudau , =?utf-8?b?Q2zDqW1lbnQgUMOpcm9u?= , Heiko Stuebner Cc: kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 2/2] drm/panthor: Fix OPP refcnt leaks in devfreq initialisation Date: Tue, 5 Nov 2024 20:54:56 +0000 Message-ID: <20241105205458.1318989-2-adrian.larumbe@collabora.com> X-Mailer: git-send-email 2.46.2 In-Reply-To: <20241105205458.1318989-1-adrian.larumbe@collabora.com> References: <20241105205458.1318989-1-adrian.larumbe@collabora.com> 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: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" Rearrange lookup of recommended OPP for the Mali GPU device and its refcnt decremental to make sure no OPP object leaks happen in the error path. Signed-off-by: Adrián Larumbe Fixes: fac9b22df4b1 ("drm/panthor: Add the devfreq logical block") Reviewed-by: Steven Price Reviewed-by: Liviu Dudau --- drivers/gpu/drm/panthor/panthor_devfreq.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/drivers/gpu/drm/panthor/panthor_devfreq.c b/drivers/gpu/drm/panthor/panthor_devfreq.c index 9d0f891b9b53..ecc7a52bd688 100644 --- a/drivers/gpu/drm/panthor/panthor_devfreq.c +++ b/drivers/gpu/drm/panthor/panthor_devfreq.c @@ -163,13 +163,6 @@ int panthor_devfreq_init(struct panthor_device *ptdev) cur_freq = clk_get_rate(ptdev->clks.core); - opp = devfreq_recommended_opp(dev, &cur_freq, 0); - if (IS_ERR(opp)) - return PTR_ERR(opp); - - panthor_devfreq_profile.initial_freq = cur_freq; - ptdev->current_frequency = cur_freq; - /* Regulator coupling only takes care of synchronizing/balancing voltage * updates, but the coupled regulator needs to be enabled manually. * @@ -200,18 +193,24 @@ int panthor_devfreq_init(struct panthor_device *ptdev) return ret; } + opp = devfreq_recommended_opp(dev, &cur_freq, 0); + if (IS_ERR(opp)) + return PTR_ERR(opp); + + panthor_devfreq_profile.initial_freq = cur_freq; + ptdev->current_frequency = cur_freq; + /* * Set the recommend OPP this will enable and configure the regulator * if any and will avoid a switch off by regulator_late_cleanup() */ ret = dev_pm_opp_set_opp(dev, opp); + dev_pm_opp_put(opp); if (ret) { DRM_DEV_ERROR(dev, "Couldn't set recommended OPP\n"); return ret; } - dev_pm_opp_put(opp); - /* Find the fastest defined rate */ opp = dev_pm_opp_find_freq_floor(dev, &freq); if (IS_ERR(opp))