From patchwork Mon Oct 24 11:29:34 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8548 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp417062wru; Mon, 24 Oct 2022 05:12:34 -0700 (PDT) X-Google-Smtp-Source: AMsMyM40k4S7h/gRPpeA8QJQJfzsusIZ4VfPgxgfmOy8D++NQDQil/893WoMRDSH8odLyK/2Ik9H X-Received: by 2002:a17:907:703:b0:78e:25be:5455 with SMTP id xb3-20020a170907070300b0078e25be5455mr26814918ejb.630.1666613554299; Mon, 24 Oct 2022 05:12:34 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666613554; cv=none; d=google.com; s=arc-20160816; b=n9fmiQWrJf4MZ+qbIhGjKbnQK/wGZpEhwXvhjjdS/nrIfEbDEr//2c+OenlEDnxH/Q //1UWTYRl/iKTtlIm8tY87YPyX5SQTtHa4BYmcXJeKGSallO2jZrQZ/EW9HyOLlDR4XC W3TNOTJzKadK4lUu4Y84kgQ+fCYiNufOZkwqF8uxEjIV4l2YYS++G7Aw6NBPewNAgHp1 xWSXjcPNE1BPCBqOcVAfBouxbuhV3usup0LdLCQcOA+6/XZbh2wOXnByDLyJ2IrDgUqn O3uJ8yizU7lduhlOb3F95XXx3cZOc6Dxi/n/CTGsY/eTCStNXKFLtOaXnYTFrEkyWLKG nu3Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=3UETVJToKRooLul9VtzlxHjDDpDSZqBsVTpyJjEW/T8=; b=XTh8+8BxUAqH7bhJzNKEVtz2rJryGBr61zahi8BIVeAG4upKjWLhtm5I4+KaTcCWhJ Ikmem5GWc10ZWiQDL3xZ9VHtYDKNHIb+QW6BmT1d4X2vt4htzPQYt+sFOWcnAt4MR+/F vXasaXloRZwP7rbzARVoSzYJe8ssnA+lkZU8Vt83McDdkyCVHO/Y1fNMScOVBZwXYjBK vT0ghZoxnwYs1/gmtkrIXBdrPFmsS2njxwrqHWIMQop88rRq1vnVG5169kMq6JZMAdT5 bXdj3lmAFuN4hTx35uAmdDEkALEx5667FRD1jQ4POAnIPo6OiQRP+8BojS/z8Z8nBO99 INYg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S5ttM9+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i7-20020a1709064fc700b0078d6418dcb8si30958940ejw.456.2022.10.24.05.12.09; Mon, 24 Oct 2022 05:12:34 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=S5ttM9+o; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232456AbiJXMBB (ORCPT + 99 others); Mon, 24 Oct 2022 08:01:01 -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 X-Spam-Status: No, score=-7.6 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747570974395671837?= X-GMAIL-MSGID: =?utf-8?q?1747570974395671837?= 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; /* 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; /* @@ -888,7 +888,7 @@ static void mt_touch_report(struct hid_d del_timer(&td->release_timer); } - clear_bit(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); + clear_bit_unlock(MT_IO_FLAGS_RUNNING, &td->mt_io_flags); } 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); } static int mt_probe(struct hid_device *hdev, const struct hid_device_id *id)