From patchwork Sat Oct 22 07:18:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 7159 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1088220wrr; Sat, 22 Oct 2022 00:39:12 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5/iTWZ2osxG52dtmd5hkz8QsKByhwx3FbbT9+F3rBM+0lVPCd0mMH+A3697MvRjwrNpL/B X-Received: by 2002:a17:907:2672:b0:734:a952:439a with SMTP id ci18-20020a170907267200b00734a952439amr17750380ejc.539.1666424351827; Sat, 22 Oct 2022 00:39:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666424351; cv=none; d=google.com; s=arc-20160816; b=lLt1uvKp+zspqolFITDzCW+VzsH8V1WIjzUttF4R7sDh2vzpkfppx173AkN5KdINR3 b85NR5/9Uh4FvbZ/UA1HifLgNCJ5AI/O/k+Y4aBFy4Fzn/svOOYxTfFQLKk7ufE95msr mLdeniskdeVOF2jDDFfxDdGp9PywgPJ38e3/siLWpG6/V+7RUuFdtWmwIvCdGJJdN36k xsY6HXrByrq263gJOQyspKSbS8+6hU0WBNeEmbhDsDC3MlYD/daSsI8XgLqdUgvZ2GT1 zb5k7e2VbnTiOEBDU9cF2b7bhuzfjpTG/4D4yV97cBplM2JBlO5urNxMx8GOSc5obTMt ofxw== 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=DkUuLH1WXsHGawYIvzw8dTN99pBC/p+RLLa6qW7PVk6+YN4nZIvBWy9FOwgXKKptkj CRsw3OH40NtBssGzpikqyyvTG/gMK/QIm6nYxCQJRBlo2QcO7gjBUdnLlAMCRofftaVB fwWR8rsWV9+wwignKnGZAIwn2dem6ojq7Onpy6FcKpcIpldq9BydEFwzxcN89a5LYh4o t5TAcWc+OAVKO99lfSUpgIATseR20mIfAkhtkUAT2uOk2OBI5zj0ZIhthvYCDnDqdQJu 54AKR3zJKdOii4cZxHM7EyftlQ6mLQCJI6ub6XvENBZk+BoZ4fzDRBjzutS417R3SwbP 1A0w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=2C1ordG9; 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 q12-20020a056402248c00b004605f289f68si7048042eda.158.2022.10.22.00.38.47; Sat, 22 Oct 2022 00:39:11 -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=2C1ordG9; 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 S230432AbiJVHh5 (ORCPT + 99 others); Sat, 22 Oct 2022 03:37:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48608 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230378AbiJVHg4 (ORCPT ); Sat, 22 Oct 2022 03:36:56 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [IPv6:2604:1380:4601:e00::1]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3C563640F; Sat, 22 Oct 2022 00:35:43 -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 ams.source.kernel.org (Postfix) with ESMTPS id 872EBB82DF2; Sat, 22 Oct 2022 07:35:41 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id EE494C433C1; Sat, 22 Oct 2022 07:35:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666424140; bh=HenN0VoiMNEdJ5jaJIOFFLb3urg5OvjE0Y0BVaFny5Y=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=2C1ordG9NdYwja+8wGrQbCCQtoLLEwvmfatEieZ/jpO+wwNykgBGMneLMzLMs/U2K 1F/vgMEMzrWqXfAGmRt5E+ufboJlSxQNG2KKjQMMjBH59eCGbF5P5UsqK0bamMq2HE ap4Gu1V1zfN7eAXHxTMEbLvfXJEPNAEd9ZmxBDxA= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Andri Yngvason , Benjamin Tissoires Subject: [PATCH 5.19 040/717] HID: multitouch: Add memory barriers Date: Sat, 22 Oct 2022 09:18:39 +0200 Message-Id: <20221022072422.207107285@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221022072415.034382448@linuxfoundation.org> References: <20221022072415.034382448@linuxfoundation.org> User-Agent: quilt/0.67 MIME-Version: 1.0 X-Spam-Status: No, score=-7.3 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?1747372581180922871?= X-GMAIL-MSGID: =?utf-8?q?1747372581180922871?= 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)