netdev.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Alex Elder <elder@linaro.org>
To: David Miller <davem@davemloft.net>
Cc: kuba@kernel.org, evgreen@chromium.org, subashab@codeaurora.org,
	cpratapa@codeaurora.org, bjorn.andersson@linaro.org,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next 1/5] net: ipa: use atomic exchange for suspend reference
Date: Wed, 9 Sep 2020 08:43:44 -0500	[thread overview]
Message-ID: <bd61d3fb-44b7-9bc3-ccad-1101c5c34ebc@linaro.org> (raw)
In-Reply-To: <20200908.202731.923992684489468023.davem@davemloft.net>

On 9/8/20 10:27 PM, David Miller wrote:
> From: Alex Elder <elder@linaro.org>
> Date: Tue,  8 Sep 2020 19:21:23 -0500
> 
>> We take a single IPA clock reference to keep the clock running
>> until we get a system suspend operation.  When a system suspend
>> request arrives, we drop that reference, and if that's the last
>> reference (likely) we'll proceed with suspending endpoints and
>> disabling the IPA core clock and interconnects.
>>
>> In most places we simply set the reference count to 0 or 1
>> atomically.  Instead--primarily to catch coding errors--use an
>> atomic exchange to update the reference count value, and report
>> an error in the event the previous value was unexpected.
>>
>> In a few cases it's not hard to see that the error message should
>> never be reported.  Report them anyway, but add some excitement
>> to the message by ending it with an exclamation point.
>>
>> Signed-off-by: Alex Elder <elder@linaro.org>
> 
> Please use refcount_t if you're wanting to validate things like
> this.

There is exactly one reference here; the "reference" is
essentially a Boolean flag.  So the value is always either
0 or 1.

I can use refcount_dec_if_one() for the 1->0 transition,
but I'm not sure how I can do the 0->1 transition with
refcount_t.  I admit I might be missing something.

Would you like me to add refcount_inc_if_zero()?

Otherwise would you prefer a different naming convention
to use for this Boolean "reference count"?

Thanks.

					-Alex

> 
> Thank you.
> 


  reply	other threads:[~2020-09-09 16:43 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-09-09  0:21 [PATCH net-next 0/5] net: ipa: wake up system on RX available Alex Elder
2020-09-09  0:21 ` [PATCH net-next 1/5] net: ipa: use atomic exchange for suspend reference Alex Elder
2020-09-09  3:27   ` David Miller
2020-09-09 13:43     ` Alex Elder [this message]
2020-09-09 21:14       ` David Miller
2020-09-09 21:23         ` Alex Elder
2020-09-09  0:21 ` [PATCH net-next 2/5] net: ipa: manage endpoints separate from clock Alex Elder
2020-09-09  0:21 ` [PATCH net-next 3/5] net: ipa: use device_init_wakeup() Alex Elder
2020-09-09  0:21 ` [PATCH net-next 4/5] net: ipa: enable wakeup on IPA interrupt Alex Elder
2020-09-09  0:21 ` [PATCH net-next 5/5] net: ipa: do not enable GSI interrupt for wakeup Alex Elder

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=bd61d3fb-44b7-9bc3-ccad-1101c5c34ebc@linaro.org \
    --to=elder@linaro.org \
    --cc=bjorn.andersson@linaro.org \
    --cc=cpratapa@codeaurora.org \
    --cc=davem@davemloft.net \
    --cc=evgreen@chromium.org \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=subashab@codeaurora.org \
    /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).