Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp528448ybm; Thu, 28 May 2020 08:41:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxbS23j5tBc13VQHfv2OtIav0xhZLt0+OZesG5vOpLKXTthZFm5TyzGwykMCEccPjEJsWtI X-Received: by 2002:a17:906:5590:: with SMTP id y16mr3702185ejp.228.1590680493412; Thu, 28 May 2020 08:41:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590680493; cv=none; d=google.com; s=arc-20160816; b=Vu2WE7PRU6f9K8I9Y9kO+6Zu2pKq79z12UyyeSMEak0BcQV+rCtqohDf3i7De9BhhQ Tpau4/lpWXMJCNB7/8h1MUNH0qhHVxdaCmX9mGlW18ClhI37wAxAGJtjgbKtnNmsCxr8 DIT3ry/D5K3R8UJ0cHMXgyNAJD2250HZEeDvBNPFfIv/asMd5beBAfCf5IjrtDjiYB99 0Ft+LC2fNmKBXPIXAsJS2qbErUlz4c07mAUAI6yfWz6Gj8pw7LFUPQ++gQkc1qUBblOC b64v817uK83g2CpZ3+nq8U7ny8qEBi8ityCAjaC8EC4b0ucxmzxjw+VGCUnYe3HuqUD+ R/dQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=meVhmEVB/gXn5wy2LUiYtYgi/wRDL2Zi0kdm2rfbNiI=; b=o5M0GMTprm3dvccaVYMNZ/eB60GPSaU11EKxJhXzzEtcpLZovSp11w+tZ+V+Miw2f5 S/aPbOgnOuNikUBWjUWtVPHGkNx0/UUbwjS30DcJWNFYBZfqSWHAAT15lUULtZULd8Cq xag/fOfkRDSZBgw1pOs7gl1ImgPDf+AWLOhveFW5wdrg/1g6CDgmAukM5Wx/Cm3Tut8G 64BYCdwchegSl/PuV59QVftegnUupW1G30GFDtwvOzSHsbWRd8KGu8YqKDFLIbkWBSLH nq40d3hnGGQ3mculh3tpdrpm8N45zMKNK3BXRwjUgEdG4rVGltVKtxwfiSSgH1G++DPx xlOA== ARC-Authentication-Results: i=1; mx.google.com; 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 q5si533839edn.1.2020.05.28.08.41.10; Thu, 28 May 2020 08:41:33 -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; 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 S2404503AbgE1PjS (ORCPT + 99 others); Thu, 28 May 2020 11:39:18 -0400 Received: from netrider.rowland.org ([192.131.102.5]:41099 "HELO netrider.rowland.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with SMTP id S2404416AbgE1PjR (ORCPT ); Thu, 28 May 2020 11:39:17 -0400 Received: (qmail 13719 invoked by uid 1000); 28 May 2020 11:39:14 -0400 Date: Thu, 28 May 2020 11:39:14 -0400 From: "stern@rowland.harvard.edu" To: Herbert Xu Cc: "Sverdlin, Alexander \(Nokia - DE/Ulm\)" , "dinghao.liu@zju.edu.cn" , "kjlu@umn.edu" , "mpm@selenic.com" , "gregkh@linuxfoundation.org" , "ben.dooks@codethink.co.uk" , "linux-kernel@vger.kernel.org" , "arnd@arndb.de" , "allison@lohutok.net" , "yuehaibing@huawei.com" , "rfontana@redhat.com" , "linux-crypto@vger.kernel.org" , "tglx@linutronix.de" , "Rafael J. Wysocki" Subject: Re: [PATCH] hwrng: ks-sa - fix runtime pm imbalance on error Message-ID: <20200528153914.GA11831@rowland.harvard.edu> References: <20200520132957.18776-1-dinghao.liu@zju.edu.cn> <20200520164556.GC11084@rowland.harvard.edu> <20200528065519.GA26960@gondor.apana.org.au> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20200528065519.GA26960@gondor.apana.org.au> User-Agent: Mutt/1.10.1 (2018-07-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 28, 2020 at 04:55:19PM +1000, Herbert Xu wrote: > On Wed, May 20, 2020 at 12:45:56PM -0400, stern@rowland.harvard.edu wrote: > > On Wed, May 20, 2020 at 03:42:17PM +0000, Sverdlin, Alexander (Nokia - DE/Ulm) wrote: > > > Hello Dinghao, > > > > > > On Wed, 2020-05-20 at 21:29 +0800, Dinghao Liu wrote: > > > > pm_runtime_get_sync() increments the runtime PM usage counter even > > > > the call returns an error code. Thus a pairing decrement is needed > > > > on the error handling path to keep the counter balanced. > > > > > > I believe, this is the wrong place for such kind of fix. > > > pm_runtime_get_sync() has obviously a broken semantics with regards to > > > your observation but no other driver does what you propose. > > > > Look again. For example, see what usb_autoresume_device() in > > drivers/usb/core/driver.c does. > > However, there seems to be some disagreement as to what to do > when pm_runtime_get_sync fails. Your driver chooses to call > put_sync while others prefer pm_runtime_put_noidle (e.g., see > drivers/base/power/runtime.c). It doesn't matter which function gets called; in these circumstances (device still suspended or in an error state because a resume attempt failed) they will do the same thing. > This API does seem to be in a bit of a mess. Suggestions and patches are welcome. Alan Stern