Received: by 2002:a05:6902:102b:0:0:0:0 with SMTP id x11csp2129528ybt; Mon, 15 Jun 2020 19:58:40 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwPmYAEOZMywzZM7AVClpCQ66EmPKqVZEYKC0wKbit03IqfnlFk3nyab+DJsGuxjQu5d4vL X-Received: by 2002:a17:906:86c5:: with SMTP id j5mr814767ejy.88.1592276320560; Mon, 15 Jun 2020 19:58:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1592276320; cv=none; d=google.com; s=arc-20160816; b=Uw+zDOorEiUpM+l/qkNWbNePUoI4HUYqqWk8uGYPT8MdTWd20a0gQxdYyV+8EtBJCI gIJ2oZGXx6cWTo4D3V6sp0fG9C6nCj0lHUTtxw+C2jeUgdJdW8f17rOQRaEIWdVzcKkE x+YZFjY+l5/pL4lu+r1K4vBCZAiGKkWf+zUrnjd7tklDu6cSpjNbRbaFfImfM05ZeWLT sblBJtQo4lHIpdbbDsR135SxQvNbUPuFVT5cUj5LJs/d86LIj95dvmqcHgaGZPmuGko0 GabpvBBKYDNi2DRXRo+KqyI2Q6WfRptle9oKkfus/OIGnc70yy+UK1672ShJ5aIsNuy5 DMkQ== 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=2JbsPChHK9JhxY+KbKEqnXwjOVNTuuQwE6E4CvlIZPU=; b=UVCi9BL32h3qrItnk4sIzL7cy7vJHtw4XeucspJ0ygEDedA7hCeQ3ASLmavbA/szqq WwbsLO+ioj8bX8U/WyZhdwtYysM2MNkQyoo441GiidBYe4CinWK1GMZLmmiFgZ//GT4g HmiGEGh82045oYBTTzu7sgbkKCzEhiPMIHjFWXdZHs3r9vm24IsE+Axow0Xzqn1C8qDi oRdwbRrYGwS6pUGYz7rHpxsI7sp+n/JTypgmV3ZAzFoLsCNp2ypOBK7F3IYzi0k0VP8K YxOXa+y4dIp2NhjIB+BhUJckY7prMv6vKT0MGJK0JrSlD4NF54MdG8qjfpJAlkFpGOAs 2RAw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=LDcDxbJu; 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 d14si9865018edp.573.2020.06.15.19.58.18; Mon, 15 Jun 2020 19:58:40 -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=LDcDxbJu; 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 S1726466AbgFPC4a (ORCPT + 99 others); Mon, 15 Jun 2020 22:56:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40252 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726025AbgFPC43 (ORCPT ); Mon, 15 Jun 2020 22:56:29 -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 6B43CC061A0E; Mon, 15 Jun 2020 19:56:29 -0700 (PDT) Received: from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi [81.175.216.236]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id B06CEF9; Tue, 16 Jun 2020 04:56:24 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1592276184; bh=+p29mN3O4KA8+pYMxFKIjzQpJJOcdUqinFmYsFDSJwI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=LDcDxbJuHmMXCEwXE1fgvV7P0DQ7rvDH5MFaa0/spasIzJiZrahiaSyVccQo7PxvF Hq9o1J5LX87Zvb548SyDFIR60KZiH6Nx1ygbLLuKTv9XFQwYcQVFcoex2uaTF+5WtP BmtiYGcHquXcbee0W6D5KMulWW+a0goZwTeP/p2k= Date: Tue, 16 Jun 2020 05:56:02 +0300 From: Laurent Pinchart To: Dinghao Liu Cc: kjlu@umn.edu, Kieran Bingham , Mauro Carvalho Chehab , linux-media@vger.kernel.org, linux-renesas-soc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH] [v2] media: vsp1: Fix runtime PM imbalance on error Message-ID: <20200616025602.GG29596@pendragon.ideasonboard.com> References: <20200608052919.4984-1-dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <20200608052919.4984-1-dinghao.liu@zju.edu.cn> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Dinghao, Thank you for the patch. On Mon, Jun 08, 2020 at 01:29:19PM +0800, Dinghao Liu wrote: > pm_runtime_get_sync() increments the runtime PM usage counter even > when it returns an error code. Thus a pairing decrement is needed on > the error handling path to keep the counter balanced. > > Signed-off-by: Dinghao Liu Reviewed-by: Laurent Pinchart I have however received multiple similar patches recently, for different drivers. I've CC'ed Rafael, the PM maintainer, in one of those e-mail threads, and questioned whether we should really mass-patch drivers, or fix the issue in pm_runtime_get_sync(). I'll defer pushing this patch until that discussion comes to a conclusion. > --- > > Changelog: > > v2: - Fix the imbalance in vsp1_device_get(). > Use vsp1_device_get() and vsp1_device_put() > to replace pm_runtime_get_sync() and > pm_runtime_put_sync() in vsp1_probe(). > --- > drivers/media/platform/vsp1/vsp1_drv.c | 11 ++++++++--- > 1 file changed, 8 insertions(+), 3 deletions(-) > > diff --git a/drivers/media/platform/vsp1/vsp1_drv.c b/drivers/media/platform/vsp1/vsp1_drv.c > index c650e45bb0ad..dc62533cf32c 100644 > --- a/drivers/media/platform/vsp1/vsp1_drv.c > +++ b/drivers/media/platform/vsp1/vsp1_drv.c > @@ -562,7 +562,12 @@ int vsp1_device_get(struct vsp1_device *vsp1) > int ret; > > ret = pm_runtime_get_sync(vsp1->dev); > - return ret < 0 ? ret : 0; > + if (ret < 0) { > + pm_runtime_put_noidle(vsp1->dev); > + return ret; > + } > + > + return 0; > } > > /* > @@ -845,12 +850,12 @@ static int vsp1_probe(struct platform_device *pdev) > /* Configure device parameters based on the version register. */ > pm_runtime_enable(&pdev->dev); > > - ret = pm_runtime_get_sync(&pdev->dev); > + ret = vsp1_device_get(vsp1); > if (ret < 0) > goto done; > > vsp1->version = vsp1_read(vsp1, VI6_IP_VERSION); > - pm_runtime_put_sync(&pdev->dev); > + vsp1_device_put(vsp1); > > for (i = 0; i < ARRAY_SIZE(vsp1_device_infos); ++i) { > if ((vsp1->version & VI6_IP_VERSION_MODEL_MASK) == -- Regards, Laurent Pinchart