linux-input.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Raul E Rangel <rrangel@chromium.org>
To: linux-input@vger.kernel.org
Cc: dmitry.torokhov@gmail.com, Shirish.S@amd.com,
	Raul E Rangel <rrangel@chromium.org>,
	Rajat Jain <rajatja@google.com>,
	Stephen Boyd <swboyd@chromium.org>,
	linux-kernel@vger.kernel.org
Subject: [PATCH v2 2/2] Input: i8042 - Lock i8042_mutex before flushing
Date: Thu, 27 Aug 2020 14:41:54 -0600	[thread overview]
Message-ID: <20200827144112.v2.2.I1417edfd3526143f14fea2546787ba4bb6f32ae8@changeid> (raw)
In-Reply-To: <20200827144112.v2.1.I6981f9a9f0c12e60f8038f3b574184f8ffc1b9b5@changeid>

Make i8042_flush lock the i8042_mutex before flushing the buffer. This
will prevent i8042_flush from clearing the buffer while a PS/2 command is
in progress. I'm not sure if this is really possible. We already
hold the lock when calling i8042_command, so this makes i8042_flush have
the same behavior.

Signed-off-by: Raul E Rangel <rrangel@chromium.org>
---

(no changes since v1)

 drivers/input/serio/i8042.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/input/serio/i8042.c b/drivers/input/serio/i8042.c
index 65ca6b47f41e8..b7ed93c5095c4 100644
--- a/drivers/input/serio/i8042.c
+++ b/drivers/input/serio/i8042.c
@@ -254,6 +254,8 @@ static int i8042_flush(void)
 	int count = 0;
 	int retval = 0;
 
+	mutex_lock(&i8042_mutex);
+
 	spin_lock_irqsave(&i8042_lock, flags);
 
 	while ((str = i8042_read_status()) & I8042_STR_OBF) {
@@ -270,6 +272,8 @@ static int i8042_flush(void)
 
 	spin_unlock_irqrestore(&i8042_lock, flags);
 
+	mutex_unlock(&i8042_mutex);
+
 	return retval;
 }
 
-- 
2.28.0.297.g1956fa8f8d-goog


  reply	other threads:[~2020-08-27 20:42 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-08-27 20:41 [PATCH v2 1/2] Input: i8042 - Prevent intermixing i8042 commands Raul E Rangel
2020-08-27 20:41 ` Raul E Rangel [this message]
2020-10-28 20:35 ` Hans de Goede
2020-12-07  6:40 ` Dmitry Torokhov

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=20200827144112.v2.2.I1417edfd3526143f14fea2546787ba4bb6f32ae8@changeid \
    --to=rrangel@chromium.org \
    --cc=Shirish.S@amd.com \
    --cc=dmitry.torokhov@gmail.com \
    --cc=linux-input@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=rajatja@google.com \
    --cc=swboyd@chromium.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).