From patchwork Mon Oct 24 11:28:53 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9762 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp550226wru; Mon, 24 Oct 2022 09:45:35 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5spd/wkVzeSUrSxCq8NfF340YN2Fp2zQJO/vxCDNWsyRKvc37is7tXtfOztVuC17Fl8DiT X-Received: by 2002:a17:90b:1e4c:b0:213:32a5:a778 with SMTP id pi12-20020a17090b1e4c00b0021332a5a778mr1654426pjb.172.1666629935304; Mon, 24 Oct 2022 09:45:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666629935; cv=none; d=google.com; s=arc-20160816; b=MwdsCXstMlG2YXYi7RCITKV8BEthr9YTLksSYpSoFNZczDUEkCaj7cols+Ni0jW+y3 0cCrfiByaFOEPPVAm+FUar/W4Qrr7KXlotd6AGAWWXFwywN5I3FIlt3gqUOXNsRXhdmP wufcifXkFRJ9O5YH/FwoevVmcp1ILoOP25HRpnXWv1JOZUBI7k/lBjun46HNkygseGhp ymA7bQKQHNZc1cl8vE22P/Mv0mE8YwC+DOvKqCsYWJSnQX/VZ5XFU9qcwAs9bt2kCLT8 ijK4EqoyOzvNvFEODmOMCApWWIIj4g7igX4UhOVbcj+aDMwZEGFPVTeYg6t0vsaYp9Um OJrw== 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=RCXAHMnwp2QUgqpOtbSvyxFSvrnyD+e5biFEcIG11H8=; b=UYDKG/BnNE1htSYfIVld7Wn8x6QpG9Dl0IpFVz1KaDh+wRmVOPBMxfGKRRPf6W8s2H GJxYz/fivYyNHG4KlDoVtsAmirswgGgXTqXIUf9asOc8D6p4S73fvhuCWf8XHls0inDD rzRGtAi79YPaWG3A9nwRIwDV6re06srKVfUu/416PlBwjzJ0+fIgzQbg2uBLZ3BG0Br8 XUqATw9tvnU0hjZRUhh/dSF1dHWKNB6sVBXkaU1k1vT0JOw0h3R34Ie5Xwnp11YPU1+c hpNRRsZbAKNiunICy/gJtfhQrUOM13SPchaNX78q1cYp3VH0jQMUSdM9J3kqO8g2a0wA nIpA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=r6stMrOv; 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 j13-20020a65558d000000b0041cc7bac015si38600871pgs.102.2022.10.24.09.45.21; Mon, 24 Oct 2022 09:45:35 -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=r6stMrOv; 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 S234792AbiJXQo4 (ORCPT + 99 others); Mon, 24 Oct 2022 12:44:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234953AbiJXQoF (ORCPT ); Mon, 24 Oct 2022 12:44:05 -0400 Received: from ams.source.kernel.org (ams.source.kernel.org [145.40.68.75]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E4F49C5893; Mon, 24 Oct 2022 08:30:36 -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 352D6B8125B; Mon, 24 Oct 2022 12:07:24 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 8A1AFC433D6; Mon, 24 Oct 2022 12:07:22 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666613242; bh=9shEacYI84F8JDBsGRgFtl6swnxAE9iunptkZdKsg9A=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=r6stMrOv0NDAf1BK7Q1Tabk3sqRwOPYGxRMWAbsuxnFlcE0PLED57eZGR8B5lLVyq JnerTkpmGWUkKZgHiHccrmLdA4ZWfdm0EEnUL92SSdjMgN3p6uAVe56LQVycZqhwMF wIsAMS6Ii+RGeSqCvK7lB8x9nc/RGftCKS0GDbEM= 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.4 023/255] HID: multitouch: Add memory barriers Date: Mon, 24 Oct 2022 13:28:53 +0200 Message-Id: <20221024113003.209473654@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113002.471093005@linuxfoundation.org> References: <20221024113002.471093005@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?1747588150994998559?= X-GMAIL-MSGID: =?utf-8?q?1747588150994998559?= 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 @@ -1162,7 +1162,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; @@ -1243,7 +1243,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, @@ -1680,11 +1680,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)