Received: by 2002:a25:1104:0:0:0:0:0 with SMTP id 4csp362731ybr; Fri, 22 May 2020 08:23:01 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxWkNEtyOTK52vn8kr8n3UpJ53ckDKBjIym0hb6dBReaQzIsd/mj2V4SbNsqbwXxBHa4dFO X-Received: by 2002:a17:906:924a:: with SMTP id c10mr8970469ejx.360.1590160980887; Fri, 22 May 2020 08:23:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590160980; cv=none; d=google.com; s=arc-20160816; b=jBP/zM/lWCvlIWHhz+mFMTEta1KMV60ivhU9VFna/Bo8A+U6+zF5qfG+M4wugaQc8J 7ob1A2KhNLAET55k+BZd0bIbmsgJ49ho5uu1TaUJXC9zt+Rvmhs/bJwzbBvPQ3f4sL3N KhfNaVabtEO0WJFdQAFLygKPoXXJZntzC/lZJ5NEpjy4XyNc9Kg5A6c2XyNcmAxRW4A+ 3TRlNmlyLmH/RhcajJOukaUSjGodwSlBCQSNbJEmxOcLEL9BORPcXWePRCB9XH+Ka38r WeiHwjUFPTZqF2xGpXryz0ZV8ll2kH0tphF9J4Yx0Oe+jT1qDmnoqQS4QDbcd6aByk45 n8Mw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=XKBewF3F7MBEJ8/HUBV80QTJT/Ts1FvO4EjowDWAM/8=; b=BvBgOWxBiNLC6nzhuBsozjn7l13FEZQ1hglgA87nZImGoj3xQh5M7LJdNTSBpJ43Y4 u8XX8JPhtuKGStOdxE9gAb64+nY86d+WmK/sNzJMfTx9D6Dk+nRTk7gyd+FYuvBnsbC9 E38lRaCItFif9paHDTPSEpa9+CMsPJYkZOFZNOIwYnwOCj2+C+rn5sdGi+vzhFnw0vTB Cpa6Z8NQebvqv9Lvl3JHsI1oUDFQlas9pbt8LhFYgCuEmt2zJSJpPYq8cZera3GDlQJP Lw+lhmtWRCTCNrXtpFCLg6rGphZpqnmKHP35xYN/yNlPfx0ma/7Pk8XjPZOnQjYKdqua 2w7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=BfXBV3FD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id w5si3179434edr.478.2020.05.22.08.22.35; Fri, 22 May 2020 08:23:00 -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 header.i=@gmail.com header.s=20161025 header.b=BfXBV3FD; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730119AbgEVPVJ (ORCPT + 99 others); Fri, 22 May 2020 11:21:09 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:33608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729929AbgEVPVI (ORCPT ); Fri, 22 May 2020 11:21:08 -0400 Received: from mail-pl1-x641.google.com (mail-pl1-x641.google.com [IPv6:2607:f8b0:4864:20::641]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01442C061A0E; Fri, 22 May 2020 08:21:07 -0700 (PDT) Received: by mail-pl1-x641.google.com with SMTP id b12so4507208plz.13; Fri, 22 May 2020 08:21:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=XKBewF3F7MBEJ8/HUBV80QTJT/Ts1FvO4EjowDWAM/8=; b=BfXBV3FDM45lgO3wynnM9a2CkNoUgn2Eklfb0WjzC9xpNzPdSzEo+oBRXI4RalRKwM NKYfotgFtlRiPk8Oz2NPNs9Q1327fdqIsfRLxHEYB8H5DPyUMEu33ZT1z3p/5VSXqWBd X8zJoLVEBTQu6+JYy0VKLXjvuvsYwfS7XxYXX7cscyVy5eDS9iYuAGvn7tlOVp+By5xU rI+4nblRzYcj5GC0z6afyoKicDUbw+PjrGiNQGQZIrtzhjADefsIZBlqn66ppQ5Fcmn7 VthBUzjRuDXbBNNgwT+uOf8TscmaCkYJX5NXNVPJ+WxHHtDcwyaudlgtbmDHB+srkyNT UAFA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=XKBewF3F7MBEJ8/HUBV80QTJT/Ts1FvO4EjowDWAM/8=; b=LqUPvOjpuhWnzafVb4CzjYcGkgLSsjDxsg9gHtd4PchEHWMiGDk0V2QJNyLbRKl6wb OHwCldtIkrRCCBP0n4ZtaCreHUJps7TDRP0WJD2DPI9IEN4eOncUZLx+XJ0YZgYrkWLh bFd9Ug0aJgM2szSlq6ZUFt/28ILz9N/OWTtc/52xV7auGOpx0oW4VvscuSf5ms2A3Llm Uokksx6QycY+C7RmzobwmndV+oCITqzeDnqmDxvOln+IrYluinnZi7NuImqh/Wm3D6az ACLO++3eyrqUtgDh05CCGYooxAaQ0q81glr0/EQCZ2Lq6i3RyEeBU1J4XBL0kq6fHudC yywg== X-Gm-Message-State: AOAM533VZ1Us5DBnK+grTCgjvI5SxXSAh3mRKNAis0GfTa2ANV4cHPcs XAxSfGuC228BRiHgcA8h0cEKBz/diP/Kv29jh0o= X-Received: by 2002:a17:902:6ac2:: with SMTP id i2mr15639807plt.18.1590160867222; Fri, 22 May 2020 08:21:07 -0700 (PDT) MIME-Version: 1.0 References: <20200521074946.21799-1-dinghao.liu@zju.edu.cn> <5a8a6e7b.bef25.1723b588c7f.Coremail.dinghao.liu@zju.edu.cn> In-Reply-To: <5a8a6e7b.bef25.1723b588c7f.Coremail.dinghao.liu@zju.edu.cn> From: Andy Shevchenko Date: Fri, 22 May 2020 18:20:55 +0300 Message-ID: Subject: Re: Re: [PATCH] spi: tegra20-slink: Fix runtime PM imbalance on error To: Dinghao Liu Cc: Kangjie Lu , Laxman Dewangan , Mark Brown , Thierry Reding , Jonathan Hunter , linux-spi , linux-tegra@vger.kernel.org, Linux Kernel Mailing List Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, May 22, 2020 at 10:46 AM wrote: > > Hi Andy, > > Thank you for your advice! You are welcome, but please, stop top-posting. > Your suggestion is to use pm_runtime_put_noidle(), right? > The only difference between pm_runtime_put() and this function > is that pm_runtime_put() will run an extra pm_request_idle(). > > I checked this patched function again and found there is a > pm_runtime_put() in the normal branch of pm_runtime_get_sync(). > Does this mean the original program logic need to execute idle > callback? > > According to runtime PM's doc, the pm_runtime_get_sync() call > paired with a pm_runtime_put() call will be appropriate to ensure > that the device is not put back to sleep during the probe. Correct. > Therefore > I think pm_runtime_put() is more appropriate here. How come to wrong conclusion? We are considering error path. What does documentation say about this? > Do you have > more detailed suggestion for why we should use _put_noidle()? Because in error case there is no need to go through all code patch to be sure that the device is idling. Moreover, consider below case CPU1: ...somewhere in the code... pm_runtime_get() // with success! ...see below... pm_runtime_put() CPU2: ...on parallel thread... ret = pm_runtime_get_sync() // failed! if (ret) pm_runtime_put() // oi vei, we put device into sleep So, there is a potential issue. > > > 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. > > > > ... > > > > > ret = pm_runtime_get_sync(&pdev->dev); > > > if (ret < 0) { > > > dev_err(&pdev->dev, "pm runtime get failed, e = %d\n", ret); > > > > > + pm_runtime_put(&pdev->dev); > > > > For all your patches, please, double check what you are proposing. > > > > Here, I believe, the correct one will be _put_noidle(). > > > > AFAIU you are not supposed to actually suspend the device in case of error. > > But I might be mistaken, thus see above. > > > > > goto exit_pm_disable; > > > } -- With Best Regards, Andy Shevchenko