Received: by 2002:a05:6a10:a0d1:0:0:0:0 with SMTP id j17csp889783pxa; Sat, 22 Aug 2020 03:52:26 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzzPH+AKueF/1gfGigbY8jd0ZRzF5nfRERocBBZechgIZx8YK/Zo75ao3NnWAmkKQ7osJQy X-Received: by 2002:a05:6402:3121:: with SMTP id dd1mr6854813edb.72.1598093546285; Sat, 22 Aug 2020 03:52:26 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1598093546; cv=none; d=google.com; s=arc-20160816; b=CWjG6tGpFD8jkLIwWu+0IaFhrkJeMhgYbeQHov0uQAyN7/yidCWGeEL1YFL4W3hurM qvT3I7lKVpWXS+Xz0gr1ApiHbuoxgkR7+p0Xz1Yk/nN9aGngfdcTDCdKATzfgaPIhcgj UT6kn4rZTtyFd1C9RXFKcsOehQ+tapLmbgqOE3uHSwSfFl+L0KFWa32tMG1Xv5fdLrnt UyS/3snSBSif6T2lb8JmeUqr+40GU4lX4YBOv+k85yg7E3zvLTx9q4vfuQZF0x54SHcy 7cswpcZVpjpQUAgptrP8nTVXcL40Nuy4KeCqyInDu31Ow5M3XX8Fr/PlFzXl4i1kFYOx T/qg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date :dkim-signature; bh=f3QfxKGds9LqnZ8Q3jwRfKK7t8caYVEcyU+8PumSAHQ=; b=u2xaJ+WlRUJd8RMsK0F/1c7xhLgrc9cMzaVu7gU5UE57p84xTifnexydX+iSY3YjNx xR0pN1Vx6IHKcOEU9shWULG5hsVeYOmf9o9RcR2Y1qIapQYFhQTu6azNeTmbgEIgfIey oyNGC2RKPKnOAvACtF+CshSy7cEh1ynt6mU3TUxs7sc44PFPISdEdE7fdB/9rKVLHf+g cyi2kNUk4s27PD/dyPVNnJLW8T8ApopesJZlPzzOPwNsi68y42o+1kRr0hJe73UhjvPh sc8TzYZkzCGzn95suY7h0z2ox0dwvSPMdS6WKBwNXgG92Kwjv4VhRUyeUH1nN0iVWeaB KuTA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=itHGOg+Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id j14si3094810ejd.406.2020.08.22.03.52.02; Sat, 22 Aug 2020 03:52:26 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=itHGOg+Z; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727880AbgHVKtS (ORCPT + 99 others); Sat, 22 Aug 2020 06:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:34856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726222AbgHVKtQ (ORCPT ); Sat, 22 Aug 2020 06:49:16 -0400 Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9BCD4C061573 for ; Sat, 22 Aug 2020 03:49:16 -0700 (PDT) Received: from pendragon.ideasonboard.com (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id C84E329E; Sat, 22 Aug 2020 12:49:10 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1598093351; bh=6ZFChGwd762tCp/370F4TKuD3RwxOvJ1DZ6OuHN5zuE=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=itHGOg+ZIvnoNWi+pGYY56X7MbWkLwzzVhseWqf3t6LdEpx0eM0qu9Jwnx1mYU0LA inxtDv8xCDX5FDPhV299gaj36blqWuqmApICGtJHTi6PcK+Pcqg05ap06jxodZY3WJ RWte8cGrZs4xZQcPxiSDaIOA9a2tzD2ic4DSQcLI= Date: Sat, 22 Aug 2020 13:48:52 +0300 From: Laurent Pinchart To: Tomi Valkeinen Cc: Dinghao Liu , kjlu@umn.edu, David Airlie , Daniel Vetter , Sebastian Reichel , Tony Lindgren , zhengbin , dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] drm/omap: Fix runtime PM imbalance in dsi_runtime_get Message-ID: <20200822104852.GA5966@pendragon.ideasonboard.com> References: <20200821074506.32359-1-dinghao.liu@zju.edu.cn> <5123d7ae-f491-d2d2-788d-b5250ae9e31d@ti.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5123d7ae-f491-d2d2-788d-b5250ae9e31d@ti.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Tomi, On Fri, Aug 21, 2020 at 03:06:59PM +0300, Tomi Valkeinen wrote: > On 21/08/2020 10:45, Dinghao Liu wrote: > > pm_runtime_get_sync() increments the runtime PM usage counter > > even when it returns an error code. However, users of > > dsi_runtime_get(), a direct wrapper of pm_runtime_get_sync(), > > assume that PM usage counter will not change on error. Thus a > > pairing decrement is needed on the error handling path to keep > > the counter balanced. > > > > Fixes: 4fbafaf371be7 ("OMAP: DSS2: Use PM runtime & HWMOD support") > > Signed-off-by: Dinghao Liu > > --- > > drivers/gpu/drm/omapdrm/dss/dsi.c | 7 +++++-- > > 1 file changed, 5 insertions(+), 2 deletions(-) > > > > diff --git a/drivers/gpu/drm/omapdrm/dss/dsi.c b/drivers/gpu/drm/omapdrm/dss/dsi.c > > index eeccf40bae41..973bfa14a104 100644 > > --- a/drivers/gpu/drm/omapdrm/dss/dsi.c > > +++ b/drivers/gpu/drm/omapdrm/dss/dsi.c > > @@ -1112,8 +1112,11 @@ static int dsi_runtime_get(struct dsi_data *dsi) > > DSSDBG("dsi_runtime_get\n"); > > > > r = pm_runtime_get_sync(dsi->dev); > > - WARN_ON(r < 0); > > - return r < 0 ? r : 0; > > + if (WARN_ON(r < 0)) { > > + pm_runtime_put_noidle(dsi->dev); > > + return r; > > + } > > + return 0; > > } > > Thanks! Good catch. I think this is broken in all the other modules in omapdrm too (e.g. dispc.c, > venc.c, etc). > > Would you like to update the patch to cover the whole omapdrm? Just for yoru information, there has been quite a few similar patches submitted all across the kernel. I believe this is an issue of the pm_runtime_get_sync() API, which really shouldn't require a put() when it fails. For drivers that really don't expect pm_runtime_get_sync() to fail (no I2C access to a regulator for instance, only SoC-internal operations) I've instead decided to ignore the error completely. I don't think poluting the whole kernel code base with this kind of "fixes" is a good idea. -- Regards, Laurent Pinchart