From patchwork Mon Oct 24 11:27:02 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 8997 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp439987wru; Mon, 24 Oct 2022 06:03:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6kf2U4X5Kq32F2n5mrruqe4zR9y17jCM2f+hgsvX2S6SfbwAVMFf/MFEsgEv/hdlb3f70X X-Received: by 2002:a63:9044:0:b0:46b:2ea0:5852 with SMTP id a65-20020a639044000000b0046b2ea05852mr27954467pge.301.1666616616774; Mon, 24 Oct 2022 06:03:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666616616; cv=none; d=google.com; s=arc-20160816; b=sYbx6+pZQ+gOJpzFaeIR/U9Y5M3moY5b8Wo40w9vRee2q9esMELHD29PhagxfMKLwI OYboIzuW4uwMxf0H1+e0orteMNuhuNau2zuMdHrJLlLmO8qKIiXydsQwiMp7HSsZLGEH fwRF4+BCKMhkHHaCIEjv0/4cYGraRRiG5oi3HNlfFBx9Yqed6JIPAEn4YIWrIks575Ah lQUpUNhIs5D+dX7qTj/kLx7YBwhlxVnTf/Bk+O6WLQAeHgz4/qrFl/yu04RhqvXSQ8qm 4wW9HU3QFVVM8ZxnWd6nlx+JBpODlvY3HkzfWwsQwwsy/RRwL30MylcqhNSI1TpX2PMA BJpw== 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=Iv5zl/akg9ZqxcFDKPOAexPRjUSYCQ67y4QCOnbAOn8=; b=FGZbZAW2IExDNMNfQd5IYAdWFsw+vAd9JYfKfcIeLMzAt70NxHuK//xFmdPuPDrXe6 wAJi1IklebJcLDeUzJBulGo6tT27tJ0PVe4edRRJZLlVH7B2oNGyVhKQf+MKha1Awmwn mpaGmKjbzb1A4R2BhRc5Xi6hWrs/k+F97Y4jE60pDYmjNVdutYPJBEbFjKxvxXHzMvcH uz7jjDnLtVMQZRlnDJN0jJmKNV8nF4WfXM631dumQdckk8J0XYfoAkpPapw61CEUj6hT xSP9V0/Mml0oqkYVemAT3Jl/apH2hE6A/jNcf5N7QOvrC4/MnpKRzVnfEksNkjiYbK3y 1MZA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=itJ6N4RP; 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 cp8-20020a056a00348800b0054096da12b1si30615812pfb.39.2022.10.24.06.02.30; Mon, 24 Oct 2022 06:03:36 -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=itJ6N4RP; 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 S235092AbiJXNBv (ORCPT + 99 others); Mon, 24 Oct 2022 09:01:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235079AbiJXM7R (ORCPT ); Mon, 24 Oct 2022 08:59:17 -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 768D89AC0F; Mon, 24 Oct 2022 05:18:32 -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 8082361325; Mon, 24 Oct 2022 12:16:56 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 92E78C433D6; Mon, 24 Oct 2022 12:16:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613815; bh=sAAZ5pRd2DSlqiAtcZGxWiOGWMZMMsEwtSJnTlmIEPk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=itJ6N4RPEFtzvGHX0oGVDQFD2qpLILHsh4hX850zhGyTf9QIwkPAefG8MiW6i3p4o VrJ7emUseJu7PE4uPbn7ihF1J87uZ18F8ugOse1oriBGMF4LN2X6c3rGmROi/VCKn3 U2+/F8TN2YIxrHxScrx6ybVJ9edn/s3jU9lGuGIU= 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.10 025/390] HID: multitouch: Add memory barriers Date: Mon, 24 Oct 2022 13:27:02 +0200 Message-Id: <20221024113023.636657531@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113022.510008560@linuxfoundation.org> References: <20221024113022.510008560@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?1747574185533567296?= X-GMAIL-MSGID: =?utf-8?q?1747574185533567296?= 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 @@ -1155,7 +1155,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; @@ -1236,7 +1236,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, @@ -1671,11 +1671,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)