Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp6944836rwi; Mon, 24 Oct 2022 08:01:17 -0700 (PDT) X-Google-Smtp-Source: AMsMyM54ozuEEC0mX0I3CWqAUyUFcQ7NJ/PBhUea+M/tq1aHJgZdKaQBX4r3c9HpRFhCRsZwRdMm X-Received: by 2002:a63:82c6:0:b0:460:a691:356 with SMTP id w189-20020a6382c6000000b00460a6910356mr28303465pgd.621.1666623677506; Mon, 24 Oct 2022 08:01:17 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666623677; cv=none; d=google.com; s=arc-20160816; b=MhAAO1EVAr90SeZ3M37hxPe92Xfy/ByLgBKRDsv+vO1kEsvIy51CdMAmWpAZfeAC9K 4dMvcrdhFH6yCzVkcMMoV7+3XHRGpX7gJS4u0UA/Q1Z6KaHCjWjXLIc2lg25Njg9kNv+ XqFOOJSdVzE3NIuZN29aVwWXKrGbvAxxawuB+ehUjILLr2X70e7AxZwqjWwb3TLOeKAC llzhmsc25EZjva3jOb8+rI5PsUs7MsHxH0P4wtA96Ov6LN8XoPBshqbeZajLZ+6be2ib pm7oIn6jL6CxaiTF2/H60DMtvE4MYEnBBnd3Bj5nE+gJqQ8Akdi6JNAw8UHy6oxHsHmY IGPA== 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 Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k12-20020a170902ba8c00b00179f9521d08si30217586pls.149.2022.10.24.08.00.54; Mon, 24 Oct 2022 08:01:17 -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 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 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)