linux-spi.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: dinghao.liu@zju.edu.cn
To: "Andy Shevchenko" <andy.shevchenko@gmail.com>
Cc: "Kangjie Lu" <kjlu@umn.edu>,
	"Laxman Dewangan" <ldewangan@nvidia.com>,
	"Mark Brown" <broonie@kernel.org>,
	"Thierry Reding" <thierry.reding@gmail.com>,
	"Jonathan Hunter" <jonathanh@nvidia.com>,
	linux-spi <linux-spi@vger.kernel.org>,
	linux-tegra@vger.kernel.org,
	"Linux Kernel Mailing List" <linux-kernel@vger.kernel.org>
Subject: Re: Re: Re: [PATCH] spi: tegra20-slink: Fix runtime PM imbalance on error
Date: Sat, 23 May 2020 19:32:46 +0800 (GMT+08:00)	[thread overview]
Message-ID: <53722a45.c204d.172414e8ed8.Coremail.dinghao.liu@zju.edu.cn> (raw)
In-Reply-To: <CAHp75VexCBc6iCrd_VLj5jXE8cxxdzUUf6pMG6O8LjtNj0J1Aw@mail.gmail.com>

> On Fri, May 22, 2020 at 6:20 PM Andy Shevchenko
> <andy.shevchenko@gmail.com> wrote:
> > On Fri, May 22, 2020 at 10:46 AM <dinghao.liu@zju.edu.cn> wrote:
> 
> ...
> 
> > 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.
> 
> ...and even if it's impossible (no bugs in runtime PM core, etc) the
> code with put() looks suspicious.
> 

I may understand what you are worried about. Do you mean that
executing pm_runtime_put() will influence other threads (e.g.,
one parallel thread can put the device into sleep while other
threads are using this device)?

I think this will never happen. Because in this case the PM usage
counter cannot be decreased to zero if there are still some threads
using this device. Otherwise, pm_runtime_put() should never be
used in the case of multithreading, which is strange since this
API is used widely. 

I also checked many other implementation of probe in drivers.
It seems that using pm_runtime_put() is ok. If I misunderstood
your opinion, please point it out, thanks.

Regards,
Dinghao

> -- 
> With Best Regards,
> Andy Shevchenko

  reply	other threads:[~2020-05-23 11:33 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-21  7:49 [PATCH] spi: tegra20-slink: Fix runtime PM imbalance on error Dinghao Liu
2020-05-21  8:04 ` Andy Shevchenko
2020-05-21  8:06   ` Andy Shevchenko
2020-05-21  8:24     ` dinghao.liu
2020-05-21  8:38   ` Jon Hunter
2020-05-21  8:46     ` Jon Hunter
2020-05-22  7:45   ` dinghao.liu
2020-05-22 15:20     ` Andy Shevchenko
2020-05-22 15:22       ` Andy Shevchenko
2020-05-23 11:32         ` dinghao.liu [this message]
2020-05-23 11:52           ` Andy Shevchenko
2020-05-23 12:04             ` dinghao.liu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=53722a45.c204d.172414e8ed8.Coremail.dinghao.liu@zju.edu.cn \
    --to=dinghao.liu@zju.edu.cn \
    --cc=andy.shevchenko@gmail.com \
    --cc=broonie@kernel.org \
    --cc=jonathanh@nvidia.com \
    --cc=kjlu@umn.edu \
    --cc=ldewangan@nvidia.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-spi@vger.kernel.org \
    --cc=linux-tegra@vger.kernel.org \
    --cc=thierry.reding@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).