From patchwork Wed Oct 19 08:22:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 4531 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4ac7:0:0:0:0:0 with SMTP id y7csp203658wrs; Wed, 19 Oct 2022 01:43:43 -0700 (PDT) X-Google-Smtp-Source: AMsMyM48QxJHsg87hWYcQlMZ2UkinxGOIyQtM4mN6PuhltSlT1ZdIF6TUPYR1CQmuRDR3F2NUoMi X-Received: by 2002:a17:903:284:b0:185:5537:f356 with SMTP id j4-20020a170903028400b001855537f356mr7461627plr.32.1666169023538; Wed, 19 Oct 2022 01:43:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666169023; cv=none; d=google.com; s=arc-20160816; b=ERnXRj6TDLrdILxLayqRdxXkzppfFwmrpf64siXncZ9lEvYlXFEs/7A2M5AYux0GhK hXqdHHJVTdR94Na2rWt1Tb85NV/BkDoQT/cHgXO3xdHVomFlP4X6TlItKZvzAkt00Lqu ig0qWWHvA3IEPdYRp/hzzg1RxwWcpiqEENsfIoI1+vtPkJCbBsPm0/5c0093/AXoQXDI 5n4fFxTSjv6CLiUMraWW7mdbzlcsk2rfq9hqMVhmUDqx21a9/HU7ba+imFl4Lj1M6Ixs RKG1zMhItdRWqtz9Hx6A58R9ah9Vr56EF7Zeu4Cb+siPZTcX6Flkd7PQQk/vozqCJ7Cq 9hhw== 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=iFeCblNChNlaSTZdY8WhlkVGglMokRRAR29ZlMmMZ70=; b=GwnrrmQwbUZrZCl3GX2+zM/FLBeGC871BVzA7moRg5tMVR/KwAdm+eznrPJZCt8Op6 J+E01ogrvcxmA3M3u8vXibYAVOnOVazVqpJb53ijTnayCJeLfPRePfEmdFXWFlS3Djui yoDr58p0TauRjVd4csrr8jO5q+ilTkA0jdwp+W5hLXT1zO7aGaboe0wZeu5ld/PEyHNX IioRiGnDgovrYmnNsgqXD/+Gt7sUKW4AE5EUd2jku4u6NugfEwKcW9Ce983UOi9pK9Bf l2rwcGXrc/Wy6CBhJ3trmHLaEIXAwF9uqTJViPHalwBp6cQf7dvAAhk5eLZ1Yzp+JBVJ mwnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=p9afWCva; 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 t24-20020a635358000000b0043634245eb1si17781412pgl.311.2022.10.19.01.43.29; Wed, 19 Oct 2022 01:43:43 -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=p9afWCva; 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 S231204AbiJSIma (ORCPT + 99 others); Wed, 19 Oct 2022 04:42:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55716 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230323AbiJSIlm (ORCPT ); Wed, 19 Oct 2022 04:41:42 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9231EC55; Wed, 19 Oct 2022 01:39:24 -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 32C9F617F1; Wed, 19 Oct 2022 08:39:23 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 28913C433D7; Wed, 19 Oct 2022 08:39:21 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666168762; bh=HenN0VoiMNEdJ5jaJIOFFLb3urg5OvjE0Y0BVaFny5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=p9afWCva76FYfaTm4VKcIoT8SOuyeXvy+YIBD4wanpdQyJLxYkSuSUL5udhfjbCc0 EJqFx92izN3PriqkDJ/wIS49fu1nW7wTvFsr0j1emboWYGwdmH+Tnag9ri5DTBQmqU dE1DVQH2CpxBxBOc8lceYMHEsidXU3Hp3x+xXvbI= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andri Yngvason , Benjamin Tissoires Subject: [PATCH 6.0 046/862] HID: multitouch: Add memory barriers Date: Wed, 19 Oct 2022 10:22:13 +0200 Message-Id: <20221019083252.034902935@linuxfoundation.org> X-Mailer: git-send-email 2.38.0 In-Reply-To: <20221019083249.951566199@linuxfoundation.org> References: <20221019083249.951566199@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.4 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?1747104850096759631?= X-GMAIL-MSGID: =?utf-8?q?1747104850096759631?= 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 @@ -1186,7 +1186,7 @@ static void mt_touch_report(struct hid_d int contact_count = -1; /* 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; scantime = *app->scantime; @@ -1267,7 +1267,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, @@ -1699,11 +1699,11 @@ static void mt_expired_timeout(struct ti * 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)