From patchwork Mon Oct 24 11:26:14 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg KH X-Patchwork-Id: 9282 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:6687:0:0:0:0:0 with SMTP id l7csp463095wru; Mon, 24 Oct 2022 06:47:05 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5c9UQAjbGDL6v4w/N1qeFJdldxrhOLAr8bD+B5ftIMfsG2TBbpJ9RQagh8JawuKMYc35rt X-Received: by 2002:a05:6402:3487:b0:45d:2674:d187 with SMTP id v7-20020a056402348700b0045d2674d187mr30746600edc.386.1666619225820; Mon, 24 Oct 2022 06:47:05 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666619225; cv=none; d=google.com; s=arc-20160816; b=wkiw0djDdB9Ffs/AM2vLmW62oRa0m4hOtFsI7AOmPgBUGcdfMzsazwDzXhjSlEjJlI W52LUcPOT9IRlUYxOGzRxQohgKV0CAlR9VSK4+FHbDvKtNNg1U3X0+uGKlf5kLG/glMQ 8I4Kp8VcVLPtdTir31i4X17OIhWdnFvgdXGFPjMotojZECHTKESzW2j4KWuXxHADuCrJ EeHNu0gL/JsL0XRcVCX7s+/gn+lkSKse4Cba9lor3nTRnCygTlmQaVHdCdV2brx6HU3G Dw9bIcDqh6kVWcYv3GuxKfJSiQ+6OBkPAMi6tGu7ZBhUpZSBVi2AY63Aogu1maHfLaH5 nDEQ== 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=Y81Icu7kCpT7nj9Kn1PzJg0XHu0/6oFS4RNhQHDhook=; b=SDymHuqdELYxpcKq1qkdaNTPbMtvYTdtaVw0/92ljXrL+ft6P0FPUKgiD3VRSpCNiC xZujrfUMo/uSjjsCNo9Tge1BZR69nj9ItTKcpLNnGAfd4RxrtSzVYF/YtygPAUzgoByv CYfFVfXcw0kFOS0zH0fJcNWJv+IlU0R/NHF7PmMgJxBgwkJHhZSJKN7dEdkxCk/hCG8u WXfxofANptK2xbdT9JsZnJHseY46YZd7XnlwzbIkrHas3SryckLbeLiO5ZrMuUg0T+xa KQiAVSC/3ek3UymGQletZwGh8dhOlUaa4jlySfYhpjQE2+gI0IL9vnFA+HUtF2PNoYM0 94Tg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=1JHcQn87; 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 m12-20020a056402430c00b00458ebd62c70si30222396edc.32.2022.10.24.06.46.38; Mon, 24 Oct 2022 06:47:05 -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=1JHcQn87; 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 S236204AbiJXNpb (ORCPT + 99 others); Mon, 24 Oct 2022 09:45:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57126 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S237023AbiJXNmH (ORCPT ); Mon, 24 Oct 2022 09:42:07 -0400 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5B2DD64DC; Mon, 24 Oct 2022 05:39:33 -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 21E9A61316; Mon, 24 Oct 2022 12:36:06 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 359C2C433D6; Mon, 24 Oct 2022 12:36:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1666614965; bh=w0pvs4vQHio+0ni4mOFbluVF80DhksymKI915LMYw2I=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=1JHcQn87B1avkBHEQTv52ZV0Q9TrgyIztmej14zkrCVQcK0DoSCCwHB7Zy3dF09WH bEaBk73Wnzxa8ut77GWyyxDfladjJrHtBIKmu0dIGdQH2WC09PHS4Teh21gsZPy1P3 stTjD/ZIFnj/NOeCIS7VNajncuZMyUKk6yI3BteU= 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.15 030/530] HID: multitouch: Add memory barriers Date: Mon, 24 Oct 2022 13:26:14 +0200 Message-Id: <20221024113046.363428590@linuxfoundation.org> X-Mailer: git-send-email 2.38.1 In-Reply-To: <20221024113044.976326639@linuxfoundation.org> References: <20221024113044.976326639@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?1747576921398151734?= X-GMAIL-MSGID: =?utf-8?q?1747576921398151734?= 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, @@ -1702,11 +1702,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)