Received: by 2002:a05:622a:251a:b0:39a:b4a2:e86 with SMTP id cm26csp313726qtb; Wed, 19 Oct 2022 02:37:45 -0700 (PDT) X-Google-Smtp-Source: AMsMyM57ylaSIZARGesjMZpXQUiAeRGQsV18ZDIZlhDggbROAsw9d/Flf4wqyCvvzrkQKxZ4v2RX X-Received: by 2002:a17:907:1c28:b0:78d:4616:e6b6 with SMTP id nc40-20020a1709071c2800b0078d4616e6b6mr5657218ejc.257.1666172265382; Wed, 19 Oct 2022 02:37:45 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666172265; cv=none; d=google.com; s=arc-20160816; b=ve6kQ52BP0yOsECibtGOFRcWeefj8HASUI1UjVpghcHmEkZPH7C8SH6lCsuvGIOj8n AGnvb6fJ0nS3ilqlZ/UDsrap6+BKa35BAr+upGWlVLlXDfrHsuiZkM/KKczClNCaIn6F M5WLJMlBGW9d17bWfvsG6ZlOcLVdireoPxV90jvKPcBBM2j7LAkovlGfzOMwpooCuDmI dgC2A8PTP3Px8jQFfiwHKg6cGnms1q90NMq/sFG4UjfXbSSCq5/6YPXbYilchN45d/Co ZVTLTrZwTklDIjuFQ1LbZ9QZYEFnDdyKPWQcAOEJAh1cGduBuwlZk6naOC5ZXnXkoSS3 8CcQ== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id gt39-20020a1709072da700b00787e1d77943si15325943ejc.49.2022.10.19.02.37.18; Wed, 19 Oct 2022 02:37:45 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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)