From nobody Mon Dec 15 17:57:49 2025 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 177E1C38A2D for ; Mon, 24 Oct 2022 12:01:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232457AbiJXMBC (ORCPT ); Mon, 24 Oct 2022 08:01:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232458AbiJXL7A (ORCPT ); Mon, 24 Oct 2022 07:59:00 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [IPv6:2604:1380:4641:c500::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B552675FEF; Mon, 24 Oct 2022 04:48:03 -0700 (PDT) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 07D5A61290; Mon, 24 Oct 2022 11:47:48 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 1B521C433D6; Mon, 24 Oct 2022 11:47:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666612067; bh=OF1W0WRv6N1A+be9khkZucbgqhbZdDpuAKasngrywT0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=S5ttM9+o9pm1IcIyoso/T/IYzO2U96a5jXjkBKf2ZNePWjZxJFfLC15niX277lOEr y9fo5Emga39KcZRSDqQsZDccGD5PI8gsaxOXQmTHuiYeY7Mn41GbiZM/yLhuTDeG51 9bW00ltPRJ2B7TFJGbR2YnCMgWVC0d/JYfEp9C/E= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andri Yngvason , Benjamin Tissoires Subject: [PATCH 4.14 057/210] HID: multitouch: Add memory barriers Date: Mon, 24 Oct 2022 13:29:34 +0200 Message-Id: <20221024112958.876996172@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024112956.797777597@linuxfoundation.org> References: <20221024112956.797777597@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Type: text/plain; charset="utf-8" From: Andri Yngvason commit be6e2b5734a425941fcdcdbd2a9337be498ce2cf upstream. 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: stable@vger.kernel.org Fixes: 9609827458c3 ("HID: multitouch: optimize the sticky fingers timer") Signed-off-by: Andri Yngvason Signed-off-by: Benjamin Tissoires Link: https://lore.kernel.org/r/20220907150159.2285460-1-andri@yngvason.is Signed-off-by: Greg Kroah-Hartman --- drivers/hid/hid-multitouch.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) --- a/drivers/hid/hid-multitouch.c +++ b/drivers/hid/hid-multitouch.c @@ -832,7 +832,7 @@ static void mt_touch_report(struct hid_d int r, n; =20 /* sticky fingers release in progress, abort */ - if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) + if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) return; =20 /* @@ -888,7 +888,7 @@ static void mt_touch_report(struct hid_d del_timer(&td->release_timer); } =20 - clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); + clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); } =20 static int mt_touch_input_configured(struct hid_device *hdev, @@ -1271,11 +1271,11 @@ static void mt_expired_timeout(unsigned * An input report came in just before we release the sticky fingers, * it will take care of the sticky fingers. */ - if (test_and_set_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) + if (test_and_set_bit_lock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags)) return; if (test_bit(MT_IO_FLAGS_PENDING_SLOTS, &td->mt_io_flags)) mt_release_contacts(hdev); - clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); + clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); } =20 static int mt_probe(struct hid_device *hdev, const struct hid_device_id *i= d)