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 X-Spam-Level: X-Spam-Status: No, score=-15.7 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 10697C47076 for ; Fri, 21 May 2021 15:32:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E5DCC6135B for ; Fri, 21 May 2021 15:32:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S237472AbhEUPdh (ORCPT ); Fri, 21 May 2021 11:33:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55864 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232010AbhEUPdg (ORCPT ); Fri, 21 May 2021 11:33:36 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BBE7C061574 for ; Fri, 21 May 2021 08:32:13 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id j14so19741732wrq.5 for ; Fri, 21 May 2021 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=CNMKcijQVquaMBJ+WGo20PjbrA43l1fqxKOe5bq3x5g=; b=F9unqGpK9ZQWLu39xhVuEsxgo/Cbu5rApxCHVDojuxkO9F4/RQCxzbo8HGlGB9Dwu5 sM9mNN3i5SwK9YGrVlkvXFAxgPngSsy9cqNGKYFZDGruGE0vZ1KPnWms9rkNWPMq86ue LNYGJnmtkyvjXNUO8651tNd4MS/Gs8LBCpzKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=CNMKcijQVquaMBJ+WGo20PjbrA43l1fqxKOe5bq3x5g=; b=JCQfDhVZgGhW8ypDYpMKEFeC0ZVyp9cuZIJUwJeaPdcCcQO9GJ0AoStPjRSAIV9SjU dLlEJjndScY7lNkSE8CJJTLg+YW2AtMge+qZU2ceWrN+f5UseNWHIr9EFM8LyPiJtHE2 m+HCuqDZWEgrocRZEn17VcJDXHfX/AzwZTn+CieCYmvY7VEQ06NN0VCcMz/ZgngnsRUQ 8lEkC0RdGYDk/ujkoWkCyvXi5GhgbVxY1YPP9zt9R2DkQpMFwlNCAHrT5dofZ9fhdPVs l/WCAUPQicReT1+ozrYvN8+52g0I8iSXtfPR5DCXArmM0f0y3OafUF54bxzKHcu99jn+ mCvw== X-Gm-Message-State: AOAM530jUF7sW9AmXi55UxCKPkR87FWHBKCgh3OQ8n0sGhzOev24I5f5 M3IG61iGsaevSRgbkkqD7mK+mQ== X-Google-Smtp-Source: ABdhPJy7hNKHarTmPB2N61OrXBmySG8p0l/JeTOBfBGdkOtjecHjbovid48JSrymvCZOc64qF7pPxA== X-Received: by 2002:adf:e4c8:: with SMTP id v8mr10338485wrm.345.1621611131705; Fri, 21 May 2021 08:32:11 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q1sm12703589wmq.48.2021.05.21.08.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 08:32:11 -0700 (PDT) Date: Fri, 21 May 2021 17:32:09 +0200 From: Daniel Vetter To: Zou Wei Cc: a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie, daniel@ffwll.ch, emma@anholt.net, mripard@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH -next] drm: Fix PM reference leak Message-ID: Mail-Followup-To: Zou Wei , a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie, emma@anholt.net, mripard@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1621602186-74786-1-git-send-email-zou_wei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1621602186-74786-1-git-send-email-zou_wei@huawei.com> X-Operating-System: Linux phenom 5.10.32scarlett+ Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 21, 2021 at 09:03:06PM +0800, Zou Wei wrote: > pm_runtime_get_sync will increment pm usage counter even it failed. > Forgetting to putting operation will result in reference leak here. > Fix it by replacing it with pm_runtime_resume_and_get to keep usage > counter balanced. > > Reported-by: Hulk Robot > Signed-off-by: Zou Wei Looks good, but can you pls split this up into a patch per driver (vc and bridge/cdns-dsi here)? Thanks, Daniel > --- > drivers/gpu/drm/bridge/cdns-dsi.c | 2 +- > drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c > index 76373e3..b31281f 100644 > --- a/drivers/gpu/drm/bridge/cdns-dsi.c > +++ b/drivers/gpu/drm/bridge/cdns-dsi.c > @@ -1028,7 +1028,7 @@ static ssize_t cdns_dsi_transfer(struct mipi_dsi_host *host, > struct mipi_dsi_packet packet; > int ret, i, tx_len, rx_len; > > - ret = pm_runtime_get_sync(host->dev); > + ret = pm_runtime_resume_and_get(host->dev); > if (ret < 0) > return ret; > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c > index c27b287..f20a65b 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -798,7 +798,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, > unsigned long pixel_rate, hsm_rate; > int ret; > > - ret = pm_runtime_get_sync(&vc4_hdmi->pdev->dev); > + ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); > if (ret < 0) { > DRM_ERROR("Failed to retain power domain: %d\n", ret); > return; > -- > 2.6.2 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch 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 X-Spam-Level: X-Spam-Status: No, score=-13.5 required=3.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 84ED7C47078 for ; Fri, 21 May 2021 15:32:15 +0000 (UTC) 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 mail.kernel.org (Postfix) with ESMTPS id 469866135B for ; Fri, 21 May 2021 15:32:15 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 469866135B Authentication-Results: mail.kernel.org; dmarc=none (p=none dis=none) header.from=ffwll.ch Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=dri-devel-bounces@lists.freedesktop.org Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 54E246EB0E; Fri, 21 May 2021 15:32:14 +0000 (UTC) Received: from mail-wr1-x429.google.com (mail-wr1-x429.google.com [IPv6:2a00:1450:4864:20::429]) by gabe.freedesktop.org (Postfix) with ESMTPS id EEAD26EB63 for ; Fri, 21 May 2021 15:32:12 +0000 (UTC) Received: by mail-wr1-x429.google.com with SMTP id r12so21488132wrp.1 for ; Fri, 21 May 2021 08:32:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ffwll.ch; s=google; h=date:from:to:cc:subject:message-id:mail-followup-to:references :mime-version:content-disposition:in-reply-to; bh=CNMKcijQVquaMBJ+WGo20PjbrA43l1fqxKOe5bq3x5g=; b=F9unqGpK9ZQWLu39xhVuEsxgo/Cbu5rApxCHVDojuxkO9F4/RQCxzbo8HGlGB9Dwu5 sM9mNN3i5SwK9YGrVlkvXFAxgPngSsy9cqNGKYFZDGruGE0vZ1KPnWms9rkNWPMq86ue LNYGJnmtkyvjXNUO8651tNd4MS/Gs8LBCpzKk= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id :mail-followup-to:references:mime-version:content-disposition :in-reply-to; bh=CNMKcijQVquaMBJ+WGo20PjbrA43l1fqxKOe5bq3x5g=; b=YaXl3p0k/Y9QG+WRCIAvAdie0a3aXrywu2Sp8zq6ax24nP2MDDj7SKHV1MtS/rYaoS rd/QkgzQwBshsLdQ84Vbm48fdso0ahtiKb4PkcOmqRh3hyowoEgEHEPvF+TWUJKNIfH4 jTl3c50ew9GeQDycUmCAwY0N8+18d5vi4sAvaWW0uQnqRW+jRi/ZFbJG/9PxtT4w7UyV f9WE/MSQbIdWt5BWnyuwX+WZ+I9qbn7dclZgDidrItFfuNfQXNwIcjyRv38mlllZPZYZ glzJxJ4YHnIZOBCVA/lQgi9e24XyUV4drDqy5GzjnpSwEYQL7Rf7qdpgbNS/T2TrkkZT GLfg== X-Gm-Message-State: AOAM530F5Z4v4L0l+pE+KlS/bCnuzPrHc3CBCl6PRsKU/KItDGMvuDdi Jrz2KDGviLTjTTXXCmFp74RBPg== X-Google-Smtp-Source: ABdhPJy7hNKHarTmPB2N61OrXBmySG8p0l/JeTOBfBGdkOtjecHjbovid48JSrymvCZOc64qF7pPxA== X-Received: by 2002:adf:e4c8:: with SMTP id v8mr10338485wrm.345.1621611131705; Fri, 21 May 2021 08:32:11 -0700 (PDT) Received: from phenom.ffwll.local ([2a02:168:57f4:0:efd0:b9e5:5ae6:c2fa]) by smtp.gmail.com with ESMTPSA id q1sm12703589wmq.48.2021.05.21.08.32.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 21 May 2021 08:32:11 -0700 (PDT) Date: Fri, 21 May 2021 17:32:09 +0200 From: Daniel Vetter To: Zou Wei Subject: Re: [PATCH -next] drm: Fix PM reference leak Message-ID: Mail-Followup-To: Zou Wei , a.hajda@samsung.com, narmstrong@baylibre.com, robert.foss@linaro.org, Laurent.pinchart@ideasonboard.com, jonas@kwiboo.se, jernej.skrabec@gmail.com, airlied@linux.ie, emma@anholt.net, mripard@kernel.org, dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org References: <1621602186-74786-1-git-send-email-zou_wei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1621602186-74786-1-git-send-email-zou_wei@huawei.com> X-Operating-System: Linux phenom 5.10.32scarlett+ 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: emma@anholt.net, jonas@kwiboo.se, airlied@linux.ie, robert.foss@linaro.org, dri-devel@lists.freedesktop.org, narmstrong@baylibre.com, linux-kernel@vger.kernel.org, jernej.skrabec@gmail.com, a.hajda@samsung.com, Laurent.pinchart@ideasonboard.com Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" On Fri, May 21, 2021 at 09:03:06PM +0800, Zou Wei wrote: > pm_runtime_get_sync will increment pm usage counter even it failed. > Forgetting to putting operation will result in reference leak here. > Fix it by replacing it with pm_runtime_resume_and_get to keep usage > counter balanced. > > Reported-by: Hulk Robot > Signed-off-by: Zou Wei Looks good, but can you pls split this up into a patch per driver (vc and bridge/cdns-dsi here)? Thanks, Daniel > --- > drivers/gpu/drm/bridge/cdns-dsi.c | 2 +- > drivers/gpu/drm/vc4/vc4_hdmi.c | 2 +- > 2 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/drivers/gpu/drm/bridge/cdns-dsi.c b/drivers/gpu/drm/bridge/cdns-dsi.c > index 76373e3..b31281f 100644 > --- a/drivers/gpu/drm/bridge/cdns-dsi.c > +++ b/drivers/gpu/drm/bridge/cdns-dsi.c > @@ -1028,7 +1028,7 @@ static ssize_t cdns_dsi_transfer(struct mipi_dsi_host *host, > struct mipi_dsi_packet packet; > int ret, i, tx_len, rx_len; > > - ret = pm_runtime_get_sync(host->dev); > + ret = pm_runtime_resume_and_get(host->dev); > if (ret < 0) > return ret; > > diff --git a/drivers/gpu/drm/vc4/vc4_hdmi.c b/drivers/gpu/drm/vc4/vc4_hdmi.c > index c27b287..f20a65b 100644 > --- a/drivers/gpu/drm/vc4/vc4_hdmi.c > +++ b/drivers/gpu/drm/vc4/vc4_hdmi.c > @@ -798,7 +798,7 @@ static void vc4_hdmi_encoder_pre_crtc_configure(struct drm_encoder *encoder, > unsigned long pixel_rate, hsm_rate; > int ret; > > - ret = pm_runtime_get_sync(&vc4_hdmi->pdev->dev); > + ret = pm_runtime_resume_and_get(&vc4_hdmi->pdev->dev); > if (ret < 0) { > DRM_ERROR("Failed to retain power domain: %d\n", ret); > return; > -- > 2.6.2 > -- Daniel Vetter Software Engineer, Intel Corporation http://blog.ffwll.ch