From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from foss.arm.com (foss.arm.com [217.140.110.172]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 9B9C51D3631 for ; Mon, 7 Oct 2024 13:18:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.140.110.172 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728307096; cv=none; b=QFcVjIoGHMMaflGdcqo/tFol1rO0zLpOxeBMaA+2IqCk+LOfxReqGzq7B/l/LXZOisj2DiFyENTBvJ4ISQLEXiTEVteDQ6A2nejl8JdfrJQcEa7Hi0i2djeLsvlKSQ8c5aC5Ze1IWtH1zcYgXFFjEtHmuDJivhcKk17ymETiDvI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1728307096; c=relaxed/simple; bh=dZK6kvcyzCqDjfqcIZsbVEH+5Bx/jLFVt7liNE6pC7s=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=fy9tvWUIWLBktR3ff6ATOzPPzvY/8rKgsTI79cylCEHsStyQOJlnwXZh0ss5ftOnDVZi/exjEoMOeV44LDRkV3Ct8NR/8HX0CHjeXqaQxld4pUZOdWpocU2TFrQUw94TKd+jHwrTz2NCX2Y+dkv9tTS5fzy2vNuTcpTGufbVyug= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com; spf=pass smtp.mailfrom=arm.com; arc=none smtp.client-ip=217.140.110.172 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=arm.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=arm.com Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 83616DA7 for ; Mon, 7 Oct 2024 06:18:43 -0700 (PDT) Received: from e110455-lin.cambridge.arm.com (usa-sjc-imap-foss1.foss.arm.com [10.121.207.14]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id BD99F3F640 for ; Mon, 7 Oct 2024 06:18:13 -0700 (PDT) Date: Mon, 7 Oct 2024 14:17:58 +0100 From: Liviu Dudau To: =?utf-8?Q?Adri=C3=A1n?= Larumbe Cc: Boris Brezillon , Rob Herring , Steven Price , Maarten Lankhorst , Maxime Ripard , Thomas Zimmermann , David Airlie , Simona Vetter , AngeloGioacchino Del Regno , Grant Likely , Heiko Stuebner , kernel@collabora.com, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v3 2/2] drm/panthor: Fix OPP refcnt leaks in devfreq initialisation Message-ID: References: <20241005160857.347796-1-adrian.larumbe@collabora.com> <20241005160857.347796-2-adrian.larumbe@collabora.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20241005160857.347796-2-adrian.larumbe@collabora.com> On Sat, Oct 05, 2024 at 05:08:53PM +0100, Adrián Larumbe wrote: > 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 Best regards, Liviu > --- > 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)) > -- > 2.46.2 > -- ==================== | I would like to | | fix the world, | | but they're not | | giving me the | \ source code! / --------------- ¯\_(ツ)_/¯