From mboxrd@z Thu Jan 1 00:00:00 1970 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 vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 968D5C433EF for ; Sun, 23 Jan 2022 20:11:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240042AbiAWUIl (ORCPT ); Sun, 23 Jan 2022 15:08:41 -0500 Received: from perceval.ideasonboard.com ([213.167.242.64]:46502 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S239970AbiAWUIk (ORCPT ); Sun, 23 Jan 2022 15:08:40 -0500 Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 8896BD41; Sun, 23 Jan 2022 21:08:38 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1642968518; bh=BzIwj895BymBnu36XuRSvpJsdsZBdi4n4qQEJnJH7GM=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=lfnsmWlBHeNPC2W3jBEKqhdzYzuZdV1zsUonGp/6jtKTCupiBJTnPxtACkC3T3+Xf wuT6cqtk1MFcgOVuwnvGII9g4nSdRTNm04r0oKuykJKyKmSZoOw9aW2kMIVd/Y0R1N +MR40gvhe/ZIf3OfngUGIpX4lJj2xgYM4QRoSYKg= Date: Sun, 23 Jan 2022 22:08:22 +0200 From: Laurent Pinchart To: Yongzhi Liu Cc: a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie, daniel@ffwll.ch, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/bridge: Add missing pm_runtime_put_sync Message-ID: References: <1642606560-32287-1-git-send-email-lyz_cs@pku.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <1642606560-32287-1-git-send-email-lyz_cs@pku.edu.cn> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Yongzhi, Thank you for the patch. On Wed, Jan 19, 2022 at 07:36:00AM -0800, Yongzhi Liu wrote: > pm_runtime_get_sync() will increase the rumtime PM counter > even it returns an error. Thus a pairing decrement is needed > to prevent refcount leak. Fix this by replacing this API with > pm_runtime_resume_and_get(), which will not change the runtime > PM counter on error. Besides, a matching decrement is needed > on the error handling path to keep the counter balanced. > > Signed-off-by: Yongzhi Liu > --- > drivers/gpu/drm/bridge/nwl-dsi.c | 17 +++++++++++------ > 1 file changed, 11 insertions(+), 6 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/nwl-dsi.c b/drivers/gpu/drm/bridge/nwl-dsi.c > index 9282e61..e7dce5a 100644 > --- a/drivers/gpu/drm/bridge/nwl-dsi.c > +++ b/drivers/gpu/drm/bridge/nwl-dsi.c > @@ -862,18 +862,19 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, > memcpy(&dsi->mode, adjusted_mode, sizeof(dsi->mode)); > drm_mode_debug_printmodeline(adjusted_mode); > > - pm_runtime_get_sync(dev); > + if (pm_runtime_resume_and_get(dev) < 0) > + return; > > if (clk_prepare_enable(dsi->lcdif_clk) < 0) > - return; > + goto runtime_put; > if (clk_prepare_enable(dsi->core_clk) < 0) > - return; > + goto runtime_put; > > /* Step 1 from DSI reset-out instructions */ > ret = reset_control_deassert(dsi->rst_pclk); > if (ret < 0) { > DRM_DEV_ERROR(dev, "Failed to deassert PCLK: %d\n", ret); > - return; > + goto runtime_put; > } > > /* Step 2 from DSI reset-out instructions */ > @@ -883,13 +884,17 @@ nwl_dsi_bridge_mode_set(struct drm_bridge *bridge, > ret = reset_control_deassert(dsi->rst_esc); > if (ret < 0) { > DRM_DEV_ERROR(dev, "Failed to deassert ESC: %d\n", ret); > - return; > + goto runtime_put; > } > ret = reset_control_deassert(dsi->rst_byte); > if (ret < 0) { > DRM_DEV_ERROR(dev, "Failed to deassert BYTE: %d\n", ret); > - return; > + goto runtime_put; > } You need a return here, otherwise you will unconditionally call pm_runtime_put_sync() even on success. > + > +runtime_put: > + pm_runtime_put_sync(dev); > + return; You can drop the return here. > } > > static void -- Regards, Laurent Pinchart