Received: by 2002:a25:683:0:0:0:0:0 with SMTP id 125csp4057711ybg; Sun, 7 Jun 2020 20:14:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxFGuGp8dM+sqMLgE2031Q/po00/rHRUrLnP8eVTtxfv6uU3nOF7NVNXCDw0ifEjpTTGN64 X-Received: by 2002:a17:907:20ee:: with SMTP id rh14mr19301917ejb.395.1591586049204; Sun, 07 Jun 2020 20:14:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1591586049; cv=none; d=google.com; s=arc-20160816; b=fEtSRZabH+1aJEU06865Gtoa+GatlgECCphJ2Zn/nEtnmlXv3CQmoOCvl33q57zc9n 0A2I0i0y566cAZUXmlie0qxtDEYMZJuwYSRa0Oy9Y48w6dYcaIPuibefFqDtv43/vml6 K9ZTZmvldLQs6igpv+u0nJSDquQIZSOsKOfaSPhJUU4f/AjVfseAgxz/q/VnIINQ9lSo qxhREVImZXNW5H8FKXhshl6/Vo5/kHXrDi+lrIlDIvhH6cjClixBx2GBzYy8/x+iVV8H Q4fipCWUomYzumKFyZIrcZI17plyaZqpw0gcuoopK3uVilM8iI1tV2+Pv1X9yYX9ag9i GgPQ== 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=DDctYR6pa7TlPlFjwGIJXT4dgQ02ylYINQnbH6+fpMY=; b=c5/u4f9LD1ZtRHsXMHoahzNEM836wLdjeMLOWmWaYyVXXsaSQngEldqBhJelL4hNKS S2O7HSPid/l2Ms1lnfsOnsODelK+yP7SHVgRkXUqEn3HF6x0p0vwiog8n156zitJCTBV OlrOKMB3RFd6+fHH8gCSuJTy7HvRUxRZatSrCqdOga7H0HSeKzu3dcmWUusfPcPtOcNw sQo/LyzasGGxU2OKYcZ/nnDVYIJ2Kqs2Vtafx1Pv+j4pslofohniJGYUx2yQnbgQh7br Si9SroAALlCdkIxoHd3ARmK+md4CQ9ECRvE8qu3RyV+dFtbv6zrTTJQtsxiYZRK45QDd VYbw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass (test mode) header.i=@ideasonboard.com header.s=mail header.b=cyC+6XTL; 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 gg12si8299488ejb.27.2020.06.07.20.13.44; Sun, 07 Jun 2020 20:14:09 -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=cyC+6XTL; 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 S1728763AbgFHDL4 (ORCPT + 99 others); Sun, 7 Jun 2020 23:11:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50670 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728065AbgFHDL4 (ORCPT ); Sun, 7 Jun 2020 23:11:56 -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 F22ACC08C5C3; Sun, 7 Jun 2020 20:11:55 -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 6E89E2C9; Mon, 8 Jun 2020 05:11:53 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1591585913; bh=o3gXWP2/3hk/aMnwZ9n2UL8s6c1rZAqBPrr54YZAGh0=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=cyC+6XTL60swUYZA4YrYqawpNeex+1EmJFY99syleO6FgNjMqyQOtmDiDP7KbcWQP cgviici9KeGVjP0c2KwLIhUn2OoJxrNNa7sZLo8OhkK1WrPwZvA52KT+1Ss1eQUXR9 pR4Hn/35uFKUFwnH5CQzGpDVv8CXJRiVosmhYAxI= Date: Mon, 8 Jun 2020 06:11:34 +0300 From: Laurent Pinchart To: dinghao.liu@zju.edu.cn 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: Re: [PATCH] media: vsp1: Fix runtime PM imbalance in vsp1_probe Message-ID: <20200608031134.GO22208@pendragon.ideasonboard.com> References: <20200523115426.19285-1-dinghao.liu@zju.edu.cn> <20200608015456.GJ22208@pendragon.ideasonboard.com> <20200608015753.GK22208@pendragon.ideasonboard.com> <7b79863f.f636d.17291e1ff94.Coremail.dinghao.liu@zju.edu.cn> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <7b79863f.f636d.17291e1ff94.Coremail.dinghao.liu@zju.edu.cn> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Dianghao, On Mon, Jun 08, 2020 at 11:03:26AM +0800, dinghao.liu@zju.edu.cn wrote: > Hi Laurent, > > > > I wonder how many bugs we have today, and how many bugs will keep > > > appearing in the future, due to this historical design mistake :-( > > Good question. It's hard to say if this is a design mistake (some use > of this API does not check its return value and expects it always to > increment the usage counter). But it does make developers misuse it easier. > > > > This change looks good to me, but we also need a similar change in the > > > vsp1_device_get() function if I'm not mistaken. Could you combine both > > > in the same patch ? > > Thank you for your advice! I think you are right and I will fix this in the > next version of patch. > > > And actually, after fixing vsp1_device_get(), we should replace the > > pm_runtime_get_sync() call here with vsp1_device_get(), and the > > pm_runtime_put_sync() below with vsp1_device_put(), so there would be no > > need to call pm_runtime_put_sync() manually in the error path here. > > The parameter type of vsp1_device_get() and vsp1_device_put() is "struct > vsp1_device". If we want to use these two wrappers, we need to adjust their > parameter type to "struct platform_device" or "struct device", which may > lead to errors in other callers. Maybe we should leave it as it is. The vsp1_probe() function has a struct vsp1_device whose dev field is populated by the time it needs to call pm_runtime_get_sync() and pm_runtime_get_put(), so I think you can use vsp1_device_get() and vsp1_device_put() as drop-in replacements without changing the parameters to these two functions. -- Regards, Laurent Pinchart