Skip to content

Commit be6e2b5

Browse files
any1bentiss
authored andcommitted
HID: multitouch: Add memory barriers
This fixes broken atomic checks which cause a race between the release-timer and processing of hid input. I noticed that contacts were sometimes sticking, even with the "sticky fingers" quirk enabled. This fixes that problem. Cc: [email protected] Fixes: 9609827 ("HID: multitouch: optimize the sticky fingers timer") Signed-off-by: Andri Yngvason <[email protected]> Signed-off-by: Benjamin Tissoires <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent a1f7642 commit be6e2b5

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/hid/hid-multitouch.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ static void mt_touch_report(struct hid_device *hid,
11861186
int contact_count = -1;
11871187

11881188
/* sticky fingers release in progress, abort */
1189-
if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
1189+
if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
11901190
return;
11911191

11921192
scantime = *app->scantime;
@@ -1267,7 +1267,7 @@ static void mt_touch_report(struct hid_device *hid,
12671267
del_timer(&td->release_timer);
12681268
}
12691269

1270-
clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
1270+
clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
12711271
}
12721272

12731273
static int mt_touch_input_configured(struct hid_device *hdev,
@@ -1699,11 +1699,11 @@ static void mt_expired_timeout(struct timer_list *t)
16991699
* An input report came in just before we release the sticky fingers,
17001700
* it will take care of the sticky fingers.
17011701
*/
1702-
if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
1702+
if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags))
17031703
return;
17041704
if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags))
17051705
mt_release_contacts(hdev);
1706-
clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
1706+
clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags);
17071707
}
17081708

17091709
static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)

0 commit comments

Comments
 (0)