From: "Ilpo Järvinen" <ilpo.jarvinen@linux.intel.com>
To: Hans de Goede <hdegoede@redhat.com>
Cc: Armin Wolf <W_Armin@gmx.de>,
"Rafael J. Wysocki" <rafael@kernel.org>,
linux-acpi@vger.kernel.org, platform-driver-x86@vger.kernel.org,
LKML <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] platform/x86: quickstart: Fix race condition when reporting input event
Date: Mon, 8 Apr 2024 13:33:29 +0300 (EEST) [thread overview]
Message-ID: <6d89b1f3-f37d-918d-b497-fc9b877ac297@linux.intel.com> (raw)
In-Reply-To: <b5d808fd-f9c4-48d5-b888-c4ded4b0cad6@redhat.com>
On Sun, 7 Apr 2024, Hans de Goede wrote:
> On 4/6/24 8:57 PM, Armin Wolf wrote:
> > Am 27.03.24 um 22:45 schrieb Armin Wolf:
> >
> >> Since commit e2ffcda16290 ("ACPI: OSL: Allow Notify () handlers to run
> >> on all CPUs"), the ACPI core allows multiple notify calls to be active
> >> at the same time. This means that two instances of quickstart_notify()
> >> running at the same time can mess which each others input sequences.
> >>
> >> Fix this by protecting the input sequence with a mutex.
> >>
> >> Compile-tested only.
> >
> > Any thoughts on this?
>
> I wonder if we need this at all ?
>
> The input_event() / input_report_key() / input_sync() functions
> which underpin sparse_keymap_report_event() all are safe to be called
> from multiple threads at the same time AFAIK.
>
> The only thing which can then still go "wrong" if we have
> 2 sparse_keymap_report_event() functions racing for the same
> quickstart button and thus for the same keycode is that we may
> end up with:
>
> input_report_key(dev, keycode, 1);
> input_report_key(dev, keycode, 1); /* This is a no-op */
> input_sync(); /* + another input_sync() somewhere which is a no-op */
> input_report_key(dev, keycode, 0);
> input_report_key(dev, keycode, 0); /* This is a no-op */
> input_sync(); /* + another input_sync() somewhere which is a no-op */
>
> IOW if 2 racing notifiers hit the perfect race conditions then
> only 1 key press is reported, instead of 2 which seems like
> it is not a problem since arguably if the same event gets
> reported twice at the exact same time it probably really
> is only a single button press.
>
> Also I think it is highly unlikely we will actually see
> 2 notifiers for this racing in practice.
>
> So I don't think we need this at all. But if others feel strongly
> about adding this I can still merge it... ?
Hi,
I know you already merged this and I agree it's not very likely race but
still it can turn two presses into one which seems unwanted side-effect,
even if it's unlikely to occur in practice.
--
i.
next prev parent reply other threads:[~2024-04-08 10:33 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-03-27 21:45 [PATCH] platform/x86: quickstart: Fix race condition when reporting input event Armin Wolf
2024-04-06 18:57 ` Armin Wolf
2024-04-07 15:32 ` Hans de Goede
2024-04-08 6:01 ` Armin Wolf
2024-04-08 7:49 ` Hans de Goede
2024-04-08 8:28 ` Armin Wolf
2024-04-08 10:33 ` Ilpo Järvinen [this message]
2024-04-08 9:21 ` Hans de Goede
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=6d89b1f3-f37d-918d-b497-fc9b877ac297@linux.intel.com \
--to=ilpo.jarvinen@linux.intel.com \
--cc=W_Armin@gmx.de \
--cc=hdegoede@redhat.com \
--cc=linux-acpi@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=platform-driver-x86@vger.kernel.org \
--cc=rafael@kernel.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 read-only IMAP folder(s) and NNTP newsgroup(s).