From: Pavel Machek <pavel@ucw.cz>
To: William Breathitt Gray <william.gray@linaro.org>
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
linux-iio@vger.kernel.org, linux-kernel@vger.kernel.org,
Jonathan Cameron <jic23@kernel.org>,
stable@vger.kernel.org
Subject: Re: [RESEND PATCH 5.15 v3 5/5] counter: 104-quad-8: Fix race condition between FLAG and CNTR reads
Date: Tue, 2 May 2023 10:19:07 +0200 [thread overview]
Message-ID: <ZFDHe0a7kcJXQoNM@duo.ucw.cz> (raw)
In-Reply-To: <ZD1MZO3KpRmuzy42@fedora>
[-- Attachment #1: Type: text/plain, Size: 979 bytes --]
Hi!
> On Tue, Apr 11, 2023 at 11:52:20AM -0400, William Breathitt Gray wrote:
> > commit 4aa3b75c74603c3374877d5fd18ad9cc3a9a62ed upstream.
> >
> > The Counter (CNTR) register is 24 bits wide, but we can have an
> > effective 25-bit count value by setting bit 24 to the XOR of the Borrow
> > flag and Carry flag. The flags can be read from the FLAG register, but a
> > race condition exists: the Borrow flag and Carry flag are instantaneous
> > and could change by the time the count value is read from the CNTR
> > register.
> > Since the race condition could result in an incorrect 25-bit count
> > value, remove support for 25-bit count values from this driver.
I believe usual solution is to read the carry, read the counter, and
read the carry again. If old_carry = new_carry, we are pretty sure we
did not hit the race, and can use 25 bit value.
Best regards,
Pavel
--
People of Russia, stop Putin before his war on Ukraine escalates.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
next prev parent reply other threads:[~2023-05-02 8:20 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-04-11 15:52 [RESEND PATCH 4.14 v3 1/5] iio: " William Breathitt Gray
2023-04-11 15:52 ` [RESEND PATCH 4.19 v3 2/5] " William Breathitt Gray
2023-04-11 15:52 ` [RESEND PATCH 5.4 v3 3/5] " William Breathitt Gray
2023-04-11 15:52 ` [RESEND PATCH 5.10 v3 4/5] " William Breathitt Gray
2023-04-11 15:52 ` [RESEND PATCH 5.15 v3 5/5] " William Breathitt Gray
2023-04-17 13:40 ` William Breathitt Gray
2023-04-18 9:41 ` Greg Kroah-Hartman
2023-04-18 10:12 ` William Breathitt Gray
2023-05-02 8:19 ` Pavel Machek [this message]
2023-05-03 0:12 ` William Breathitt Gray
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=ZFDHe0a7kcJXQoNM@duo.ucw.cz \
--to=pavel@ucw.cz \
--cc=gregkh@linuxfoundation.org \
--cc=jic23@kernel.org \
--cc=linux-iio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=william.gray@linaro.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
all inboxes | Powered by JetHome®